BOOL CKirikiriApp::Option() { BOOL bRetVal = TRUE; CKirikiriOptionDlg od; if(m_ScriptMgr.m_bCacheToZIP && m_ScriptMgr.m_bCacheToFile) od.m_nCacheMode = 2; else if(m_ScriptMgr.m_bCacheToFile) od.m_nCacheMode = 1; else od.m_nCacheMode = 0; od.m_bAlsoSrc = m_ScriptMgr.m_bCacheSrc; od.m_bUseCP2 = m_bUseCodePoint2; od.m_nCP2Type = m_nCodePoint2Type; if( od.DoModal() == IDOK ) { COptionNode tmpRoot; COptionNode* pChildNode = NULL; COptionNode* pChildChildNode = NULL; // 저장소 운용 모드 pChildNode = tmpRoot.CreateChild(); pChildNode->SetValue(_T("CACHE")); pChildChildNode = pChildNode->CreateChild(); switch(od.m_nCacheMode) { case 1: pChildChildNode->SetValue(_T("FILE")); break; case 2: pChildChildNode->SetValue(_T("HYBRID")); break; default: pChildChildNode->SetValue(_T("ZIP")); } // 원문 저장 여부 if(od.m_bAlsoSrc) { pChildChildNode = pChildNode->CreateChild(); pChildChildNode->SetValue(_T("ALSOSRC")); } if (od.m_bUseCP2) { TCHAR szValue[10]; pChildNode = tmpRoot.CreateChild(); pChildNode->SetValue(_T("CP2")); pChildChildNode = pChildNode->CreateChild(); wsprintf(szValue, _T("%d"), od.m_nCP2Type); pChildChildNode->SetValue(szValue); } ApplyOption(&tmpRoot); } return bRetVal; }
// ac and av are commandline options passed along from main() // Commandline options override config file options. void ZigConfig::Init( int ac, char* av[] ) { // try to read in opts from file { std::string inname = JoinPath( ZigUserDir(), "options" ); std::ifstream in( inname.c_str() ); int linenum = 0; while( in.good() ) { std::string line; std::getline( in, line ); ++linenum; std::vector< std::string > opts; SplitLine( line, opts ); if( opts.empty() ) // ignore blank lines continue; ApplyOption( *this, opts ); } } // now apply commandline opts on top. int i=1; while( i<ac ) { std::vector< std::string > opt; if( av[i][0] != '-' ) throw Wobbly( "Syntax error: '%s'", av[i] ); opt.push_back( &av[i][1] ); ++i; // collect args for this option while( i<ac && av[i][0] != '-' ) { opt.push_back( av[i] ); ++i; } ApplyOption( *this, opt ); } }
BOOL CATCodeMgr::Option() { BOOL bRetVal = TRUE; CString strCurOptionString = m_optionRoot.ChildrenToString(); COptionNode tmpRoot; if( tmpRoot.ParseChildren(strCurOptionString) == FALSE ) return FALSE; COptionDlg od; od.SetRootOptionNode(&tmpRoot); if( od.DoModal() == IDOK ) { ApplyOption(&tmpRoot); } return bRetVal; }
////////////////////////////////////////////////////////////////////////// // // OnPluginOption // ////////////////////////////////////////////////////////////////////////// extern "C" __declspec(dllexport) BOOL __stdcall OnPluginOption() { BOOL bRetVal = FALSE; // Show option dialog and Interact with user. if (g_hAralWnd && IsWindow(g_hAralWnd)) { memcpy(&g_sTempOption, &g_sMainOption, sizeof(FONT_MAPPER_OPTION)); if (DialogBox((HINSTANCE)g_hThisModule, MAKEINTRESOURCE(IDD_OPTION_DLG), g_hAralWnd, OptionDialogProc) == IDOK) { if(ApplyOption(&g_sTempOption) == TRUE) { memcpy(&g_sMainOption, &g_sTempOption, sizeof(FONT_MAPPER_OPTION)); CSettingMgr::OptionToXml(&g_sMainOption, g_wszPluginOption, MAX_OPTION_LEN); bRetVal = TRUE; } } } return bRetVal; }
////////////////////////////////////////////////////////////////////////// // // OnPluginInit // ////////////////////////////////////////////////////////////////////////// extern "C" __declspec(dllexport) BOOL __stdcall OnPluginInit(HWND hAralWnd, LPWSTR wszPluginOption) { BOOL bRetVal = FALSE; try { ////////////////////////////////////////////////////////////////////////// // Initializing Code ////////////////////////////////////////////////////////////////////////// g_hAralWnd = hAralWnd; if(NULL == g_hAralWnd || INVALID_HANDLE_VALUE == g_hAralWnd) throw _T("Invalid AralTrans Window Handle!"); g_wszPluginOption = wszPluginOption; if(NULL == g_wszPluginOption) throw _T("Invalid Option String Pointer!"); // Get AT container HMODULE hATCTNR3 = GetModuleHandle(_T("ATCTNR3.DLL")); if(NULL == hATCTNR3 || INVALID_HANDLE_VALUE == hATCTNR3) throw _T("Can not find ATCTNR3.DLL handle!"); // Get AT container procedures ZeroMemory(&g_sATCTNR3, sizeof(CONTAINER_PROC_ENTRY)); g_sATCTNR3.procHookWin32Api = (PROC_HookWin32Api) GetProcAddress(hATCTNR3, "HookWin32Api"); g_sATCTNR3.procUnhookWin32Api = (PROC_UnhookWin32Api) GetProcAddress(hATCTNR3, "UnhookWin32Api"); g_sATCTNR3.procHookCodePoint = (PROC_HookCodePoint) GetProcAddress(hATCTNR3, "HookCodePoint"); g_sATCTNR3.procUnhookCodePoint = (PROC_UnhookCodePoint) GetProcAddress(hATCTNR3, "UnhookCodePoint"); g_sATCTNR3.procCreateTransCtx = (PROC_CreateTransCtx) GetProcAddress(hATCTNR3, "CreateTransCtx"); g_sATCTNR3.procDeleteTransCtx = (PROC_DeleteTransCtx) GetProcAddress(hATCTNR3, "DeleteTransCtx"); g_sATCTNR3.procTranslateUsingCtx = (PROC_TranslateUsingCtx) GetProcAddress(hATCTNR3, "TranslateUsingCtx"); g_sATCTNR3.procIsAppLocaleLoaded = (PROC_IsAppLocaleLoaded) GetProcAddress(hATCTNR3, "IsAppLocaleLoaded"); g_sATCTNR3.procSuspendAllThread = (PROC_SuspendAllThread) GetProcAddress(hATCTNR3, "SuspendAllThread"); g_sATCTNR3.procResumeAllThread = (PROC_ResumeAllThread) GetProcAddress(hATCTNR3, "ResumeAllThread"); g_sATCTNR3.procIsAllThreadSuspended = (PROC_IsAllThreadSuspended) GetProcAddress(hATCTNR3, "IsAllThreadSuspended"); if(!(g_sATCTNR3.procHookWin32Api && g_sATCTNR3.procUnhookWin32Api && g_sATCTNR3.procHookCodePoint && g_sATCTNR3.procUnhookCodePoint && g_sATCTNR3.procCreateTransCtx && g_sATCTNR3.procDeleteTransCtx && g_sATCTNR3.procTranslateUsingCtx && g_sATCTNR3.procIsAppLocaleLoaded && g_sATCTNR3.procSuspendAllThread && g_sATCTNR3.procResumeAllThread && g_sATCTNR3.procIsAllThreadSuspended)) throw _T("Failed to get container procedures!"); // Suspend All Threads g_sATCTNR3.procSuspendAllThread(); // Hook Font API if( g_sATCTNR3.procHookWin32Api( L"GDI32.dll", L"CreateFontA", NewCreateFontA, 10 ) == FALSE ) throw _T("Failed to hook 'CreateFontA'!"); if( g_sATCTNR3.procHookWin32Api( L"GDI32.dll", L"CreateFontW", NewCreateFontW, 10 ) == FALSE ) throw _T("Failed to hook 'CreateFontW'!"); if( g_sATCTNR3.procHookWin32Api( L"GDI32.dll", L"CreateFontIndirectA", NewCreateFontIndirectA, 10 ) == FALSE ) throw _T("Failed to hook 'CreateFontIndirectA'!"); if( g_sATCTNR3.procHookWin32Api( L"GDI32.dll", L"CreateFontIndirectW", NewCreateFontIndirectW, 10 ) == FALSE ) throw _T("Failed to hook 'CreateFontIndirectW'!"); // Hook Drawing API if( g_sATCTNR3.procHookWin32Api( L"GDI32.DLL", L"GetGlyphOutlineA", NewGetGlyphOutlineA, 10 ) == FALSE ) throw _T("Failed to hook 'GetGlyphOutlineA'!"); if( g_sATCTNR3.procHookWin32Api( L"GDI32.DLL", L"GetGlyphOutlineW", NewGetGlyphOutlineW, 10 ) == FALSE ) throw _T("Failed to hook 'GetGlyphOutlineW'!"); if( g_sATCTNR3.procHookWin32Api( L"GDI32.DLL", L"TextOutA", NewTextOutA, 10 ) == FALSE ) throw _T("Failed to hook 'TextOutA'!"); if( g_sATCTNR3.procHookWin32Api( L"GDI32.DLL", L"TextOutW", NewTextOutW, 10 ) == FALSE ) throw _T("Failed to hook 'TextOutW'!"); if( g_sATCTNR3.procHookWin32Api( L"GDI32.DLL", L"ExtTextOutA", NewExtTextOutA, 10 ) == FALSE ) throw _T("Failed to hook 'ExtTextOutA'!"); if( g_sATCTNR3.procHookWin32Api( L"GDI32.DLL", L"ExtTextOutW", NewExtTextOutW, 10 ) == FALSE ) throw _T("Failed to hook 'ExtTextOutW'!"); if( g_sATCTNR3.procHookWin32Api( L"USER32.DLL", L"DrawTextA", NewDrawTextA, 10 ) == FALSE ) throw _T("Failed to hook 'DrawTextA'!"); if( g_sATCTNR3.procHookWin32Api( L"USER32.DLL", L"DrawTextW", NewDrawTextW, 10 ) == FALSE ) throw _T("Failed to hook 'DrawTextW'!"); if( g_sATCTNR3.procHookWin32Api( L"USER32.DLL", L"DrawTextExA", NewDrawTextExA, 10 ) == FALSE ) throw _T("Failed to hook 'DrawTextExA'!"); if( g_sATCTNR3.procHookWin32Api( L"USER32.DLL", L"DrawTextExW", NewDrawTextExW, 10 ) == FALSE ) throw _T("Failed to hook 'DrawTextExW'!"); // Prevent Applocale Redirection HKEY hCategoryKey = HKEY_CURRENT_USER; HKEY hKey = NULL; LONG lRet = RegOpenKeyEx(hCategoryKey, _T("Software\\AralGood"), 0, KEY_READ, &hKey); // 키를 여는데 성공했다면 if(lRet == ERROR_SUCCESS) { DWORD type = REG_DWORD; DWORD size = MAX_PATH*2; BYTE dir[MAX_PATH*2]; if(RegQueryValueEx(hKey, _T("M2WAddr"), 0, &type, (LPBYTE)&dir, &size) == ERROR_SUCCESS) memcpy( &g_pfnOrigMultiByteToWideChar, &dir, sizeof(DWORD) ); if(RegQueryValueEx(hKey, _T("W2MAddr"), 0, &type, (LPBYTE)&dir, &size) == ERROR_SUCCESS) memcpy( &g_pfnOrigWideCharToMultiByte, &dir, sizeof(DWORD) ); } // 옵션 스트링 파싱 g_wszPluginOption = wszPluginOption; // 모든 쓰레드 재가동 g_sATCTNR3.procResumeAllThread(); bRetVal = TRUE; } catch (LPCTSTR strErr) { ::MessageBox(NULL, strErr, _T("Font Mapper"), MB_OK | MB_TOPMOST); OnPluginClose(); } if( bRetVal == TRUE ) { // for Test //wcscpy_s(g_wszPluginOption, MAX_OPTION_LEN, L"<?xml version=\"1.0\" standalone=yes><FontMapperSetting><ProgramCodePage>932</ProgramCodePage><CharacterEncoding>True</CharacterEncoding></FontMapperSetting>"); // 옵션 적용 if(CSettingMgr::XmlToOption(g_wszPluginOption, &g_sMainOption) == TRUE) ApplyOption(&g_sMainOption); } return bRetVal; }