Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.63 KB | None | 0 0
  1. #include "StdAfx.h"
  2. #include "PythonApplication.h"
  3. #include "ProcessScanner.h"
  4. #include "PythonExceptionSender.h"
  5. #include "resource.h"
  6. #include "Version.h"
  7.  
  8. #ifdef _DEBUG
  9. #include <crtdbg.h>
  10. #endif
  11.  
  12. #include "../eterPack/EterPackManager.h"
  13. #include "../eterLib/Util.h"
  14. #include "../CWebBrowser/CWebBrowser.h"
  15. #include "../eterBase/CPostIt.h"
  16.  
  17. #include "CheckLatestFiles.h"
  18.  
  19. #include "Hackshield.h"
  20. #include "NProtectGameGuard.h"
  21. #include "WiseLogicXTrap.h"
  22.  
  23. extern "C" {
  24. extern int _fltused;
  25. volatile int _AVOID_FLOATING_POINT_LIBRARY_BUG = _fltused;
  26. };
  27.  
  28. #pragma comment(linker, "/NODEFAULTLIB:libci.lib")
  29.  
  30. #pragma comment( lib, "version.lib" )
  31. #pragma comment( lib, "python22.lib" )
  32. #pragma comment( lib, "imagehlp.lib" )
  33. #pragma comment( lib, "devil.lib" )
  34. #pragma comment( lib, "granny2.lib" )
  35. #pragma comment( lib, "mss32.lib" )
  36. #pragma comment( lib, "winmm.lib" )
  37. #pragma comment( lib, "imm32.lib" )
  38. #pragma comment( lib, "oldnames.lib" )
  39. #pragma comment( lib, "SpeedTreeRT.lib" )
  40. #pragma comment( lib, "dinput8.lib" )
  41. #pragma comment( lib, "dxguid.lib" )
  42. #pragma comment( lib, "ws2_32.lib" )
  43. #pragma comment( lib, "strmiids.lib" )
  44. #pragma comment( lib, "ddraw.lib" )
  45. #pragma comment( lib, "dmoguids.lib" )
  46. //#pragma comment( lib, "wsock32.lib" )
  47. #include <stdlib.h>
  48. #include <cryptopp/cryptoppLibLink.h>
  49. bool __IS_TEST_SERVER_MODE__=false;
  50.  
  51. extern bool SetDefaultCodePage(DWORD codePage);
  52.  
  53. #ifdef USE_OPENID
  54. extern int openid_test;
  55. #endif
  56.  
  57. static const char * sc_apszPythonLibraryFilenames[] =
  58. {
  59. "UserDict.pyc",
  60. "__future__.pyc",
  61. "copy_reg.pyc",
  62. "linecache.pyc",
  63. "ntpath.pyc",
  64. "os.pyc",
  65. "site.pyc",
  66. "stat.pyc",
  67. "string.pyc",
  68. "traceback.pyc",
  69. "types.pyc",
  70. "\n",
  71. };
  72.  
  73. char gs_szErrorString[512] = "";
  74.  
  75. void ApplicationSetErrorString(const char* szErrorString)
  76. {
  77. strcpy(gs_szErrorString, szErrorString);
  78. }
  79.  
  80. bool CheckPythonLibraryFilenames()
  81. {
  82. for (int i = 0; *sc_apszPythonLibraryFilenames[i] != '\n'; ++i)
  83. {
  84. std::string stFilename = "lib\\";
  85. stFilename += sc_apszPythonLibraryFilenames[i];
  86.  
  87. if (_access(stFilename.c_str(), 0) != 0)
  88. {
  89. return false;
  90. }
  91.  
  92. MoveFile(stFilename.c_str(), stFilename.c_str());
  93. }
  94.  
  95. return true;
  96. }
  97.  
  98. struct ApplicationStringTable
  99. {
  100. HINSTANCE m_hInstance;
  101. std::map<DWORD, std::string> m_kMap_dwID_stLocale;
  102. } gs_kAppStrTable;
  103.  
  104. void ApplicationStringTable_Initialize(HINSTANCE hInstance)
  105. {
  106. gs_kAppStrTable.m_hInstance=hInstance;
  107. }
  108.  
  109. const std::string& ApplicationStringTable_GetString(DWORD dwID, LPCSTR szKey)
  110. {
  111. char szBuffer[512];
  112. char szIniFileName[256];
  113. char szLocale[256];
  114.  
  115. ::GetCurrentDirectory(sizeof(szIniFileName), szIniFileName);
  116. if(szIniFileName[lstrlen(szIniFileName)-1] != '\\')
  117. strcat(szIniFileName, "\\");
  118. strcat(szIniFileName, "metin2client.dat");
  119.  
  120. strcpy(szLocale, LocaleService_GetLocalePath());
  121. if(strnicmp(szLocale, "locale/", strlen("locale/")) == 0)
  122. strcpy(szLocale, LocaleService_GetLocalePath() + strlen("locale/"));
  123. ::GetPrivateProfileString(szLocale, szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
  124. if(szBuffer[0] == '\0')
  125. LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
  126. if(szBuffer[0] == '\0')
  127. ::GetPrivateProfileString("en", szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
  128. if(szBuffer[0] == '\0')
  129. strcpy(szBuffer, szKey);
  130.  
  131. std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
  132. rstLocale=szBuffer;
  133.  
  134. return rstLocale;
  135. }
  136.  
  137. const std::string& ApplicationStringTable_GetString(DWORD dwID)
  138. {
  139. char szBuffer[512];
  140.  
  141. LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
  142. std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
  143. rstLocale=szBuffer;
  144.  
  145. return rstLocale;
  146. }
  147.  
  148. const char* ApplicationStringTable_GetStringz(DWORD dwID, LPCSTR szKey)
  149. {
  150. return ApplicationStringTable_GetString(dwID, szKey).c_str();
  151. }
  152.  
  153. const char* ApplicationStringTable_GetStringz(DWORD dwID)
  154. {
  155. return ApplicationStringTable_GetString(dwID).c_str();
  156. }
  157.  
  158. ////////////////////////////////////////////
  159.  
  160. int Setup(LPSTR lpCmdLine); // Internal function forward
  161.  
  162. bool PackInitialize(const char * c_pszFolder)
  163. {
  164. NANOBEGIN
  165. if (_access(c_pszFolder, 0) != 0)
  166. return true;
  167.  
  168. std::string stFolder(c_pszFolder);
  169. stFolder += "/";
  170.  
  171. std::string stFileName(stFolder);
  172. stFileName += "Index";
  173.  
  174. CMappedFile file;
  175. LPCVOID pvData;
  176.  
  177. if (!file.Create(stFileName.c_str(), &pvData, 0, 0))
  178. {
  179. LogBoxf("FATAL ERROR! File not exist: %s", stFileName.c_str());
  180. TraceError("FATAL ERROR! File not exist: %s", stFileName.c_str());
  181. return true;
  182. }
  183.  
  184. CMemoryTextFileLoader TextLoader;
  185. TextLoader.Bind(file.Size(), pvData);
  186.  
  187. bool bPackFirst = TRUE;
  188.  
  189. const std::string& strPackType = TextLoader.GetLineString(0);
  190.  
  191. if (strPackType.compare("FILE") && strPackType.compare("PACK"))
  192. {
  193. TraceError("Pack/Index has invalid syntax. First line must be 'PACK' or 'FILE'");
  194. return false;
  195. }
  196.  
  197. #ifdef _DISTRIBUTE
  198. Tracef("알림: 팩 모드입니다.\n");
  199.  
  200. //if (0 == strPackType.compare("FILE"))
  201. //{
  202. // bPackFirst = FALSE;
  203. // Tracef("알림: 파일 모드입니다.\n");
  204. //}
  205. //else
  206. //{
  207. // Tracef("알림: 팩 모드입니다.\n");
  208. //}
  209. #else
  210. bPackFirst = FALSE;
  211. Tracef("알림: 파일 모드입니다.\n");
  212. #endif
  213.  
  214. CTextFileLoader::SetCacheMode();
  215. #if defined(USE_RELATIVE_PATH)
  216. CEterPackManager::Instance().SetRelativePathMode();
  217. #endif
  218. CEterPackManager::Instance().SetCacheMode();
  219. CEterPackManager::Instance().SetSearchMode(bPackFirst);
  220.  
  221. CSoundData::SetPackMode(); // Miles 파일 콜백을 셋팅
  222.  
  223. std::string strPackName, strTexCachePackName;
  224. for (DWORD i = 1; i < TextLoader.GetLineCount() - 1; i += 2)
  225. {
  226. const std::string & c_rstFolder = TextLoader.GetLineString(i);
  227. const std::string & c_rstName = TextLoader.GetLineString(i + 1);
  228.  
  229. strPackName = stFolder + c_rstName;
  230. strTexCachePackName = strPackName + "_texcache";
  231.  
  232. CEterPackManager::Instance().RegisterPack(strPackName.c_str(), c_rstFolder.c_str());
  233. CEterPackManager::Instance().RegisterPack(strTexCachePackName.c_str(), c_rstFolder.c_str());
  234. }
  235.  
  236. CEterPackManager::Instance().RegisterRootPack((stFolder + std::string("metin2_patch_eu")).c_str());
  237. NANOEND
  238. return true;
  239. }
  240.  
  241. bool RunMainScript(CPythonLauncher& pyLauncher, const char* lpCmdLine)
  242. {
  243. initpack();
  244. initdbg();
  245. initime();
  246. initgrp();
  247. initgrpImage();
  248. initgrpText();
  249. initwndMgr();
  250. /////////////////////////////////////////////
  251. initudp();
  252. initapp();
  253. initsystem();
  254. initchr();
  255. initchrmgr();
  256. initPlayer();
  257. initItem();
  258. initNonPlayer();
  259. initTrade();
  260. initChat();
  261. initTextTail();
  262. initnet();
  263. initMiniMap();
  264. initProfiler();
  265. initEvent();
  266. initeffect();
  267. initfly();
  268. initsnd();
  269. initeventmgr();
  270. initshop();
  271. initskill();
  272. #ifdef NEW_PET_SYSTEM
  273. initskillpet();
  274. #endif
  275. initquest();
  276. initBackground();
  277. initMessenger();
  278. initsafebox();
  279. initguild();
  280. initServerStateChecker();
  281.  
  282. NANOBEGIN
  283.  
  284. // RegisterDebugFlag
  285. {
  286. std::string stRegisterDebugFlag;
  287.  
  288. #ifdef _DISTRIBUTE
  289. stRegisterDebugFlag ="__DEBUG__ = 0";
  290. #else
  291. stRegisterDebugFlag ="__DEBUG__ = 1";
  292. #endif
  293.  
  294. if (!pyLauncher.RunLine(stRegisterDebugFlag.c_str()))
  295. {
  296. TraceError("RegisterDebugFlag Error");
  297. return false;
  298. }
  299. }
  300.  
  301. // RegisterCommandLine
  302. {
  303. std::string stRegisterCmdLine;
  304.  
  305. const char * loginMark = "-cs";
  306. const char * loginMark_NonEncode = "-ncs";
  307. const char * seperator = " ";
  308.  
  309. std::string stCmdLine;
  310. const int CmdSize = 3;
  311. vector<std::string> stVec;
  312. SplitLine(lpCmdLine,seperator,&stVec);
  313. if (CmdSize == stVec.size() && stVec[0]==loginMark)
  314. {
  315. char buf[MAX_PATH]; //TODO 아래 함수 string 형태로 수정
  316. base64_decode(stVec[2].c_str(),buf);
  317. stVec[2] = buf;
  318. string_join(seperator,stVec,&stCmdLine);
  319. }
  320. else if (CmdSize <= stVec.size() && stVec[0]==loginMark_NonEncode)
  321. {
  322. stVec[0] = loginMark;
  323. string_join(" ",stVec,&stCmdLine);
  324. }
  325. else
  326. stCmdLine = lpCmdLine;
  327.  
  328. stRegisterCmdLine ="__COMMAND_LINE__ = ";
  329. stRegisterCmdLine+='"';
  330. stRegisterCmdLine+=stCmdLine;
  331. stRegisterCmdLine+='"';
  332.  
  333. const CHAR* c_szRegisterCmdLine=stRegisterCmdLine.c_str();
  334. if (!pyLauncher.RunLine(c_szRegisterCmdLine))
  335. {
  336. TraceError("RegisterCommandLine Error");
  337. return false;
  338. }
  339. }
  340. {
  341. vector<std::string> stVec;
  342. SplitLine(lpCmdLine," " ,&stVec);
  343.  
  344. if (stVec.size() != 0 && "--pause-before-create-window" == stVec[0])
  345. {
  346. #ifdef XTRAP_CLIENT_ENABLE
  347. if (!XTrap_CheckInit())
  348. return false;
  349. #endif
  350. system("pause");
  351. }
  352. if (!pyLauncher.RunFile("system.py"))
  353. {
  354. TraceError("RunMain Error");
  355. return false;
  356. }
  357. }
  358.  
  359. NANOEND
  360. return true;
  361. }
  362.  
  363. bool Main(HINSTANCE hInstance, LPSTR lpCmdLine)
  364. {
  365. #ifdef LOCALE_SERVICE_YMIR
  366. extern bool g_isScreenShotKey;
  367. g_isScreenShotKey = true;
  368. #endif
  369.  
  370. DWORD dwRandSeed=time(NULL)+DWORD(GetCurrentProcess());
  371. srandom(dwRandSeed);
  372. srand(random());
  373.  
  374. SetLogLevel(1);
  375.  
  376. #ifdef LOCALE_SERVICE_VIETNAM_MILD
  377. extern BOOL USE_VIETNAM_CONVERT_WEAPON_VNUM;
  378. USE_VIETNAM_CONVERT_WEAPON_VNUM = true;
  379. #endif
  380.  
  381. if (_access("perf_game_update.txt", 0)==0)
  382. {
  383. DeleteFile("perf_game_update.txt");
  384. }
  385.  
  386. if (_access("newpatch.exe", 0)==0)
  387. {
  388. system("patchupdater.exe");
  389. return false;
  390. }
  391. #ifndef __VTUNE__
  392. ilInit();
  393. #endif
  394. if (!Setup(lpCmdLine))
  395. return false;
  396.  
  397. #ifdef _DEBUG
  398. OpenConsoleWindow();
  399. OpenLogFile(true); // true == uses syserr.txt and log.txt
  400. #else
  401. OpenLogFile(false); // false == uses syserr.txt only
  402. #endif
  403.  
  404. static CLZO lzo;
  405. static CEterPackManager EterPackManager;
  406.  
  407. if (!PackInitialize("pack"))
  408. {
  409. LogBox("Pack Initialization failed. Check log.txt file..");
  410. return false;
  411. }
  412.  
  413. if(LocaleService_LoadGlobal(hInstance))
  414. SetDefaultCodePage(LocaleService_GetCodePage());
  415.  
  416. CPythonApplication * app = new CPythonApplication;
  417.  
  418. app->Initialize(hInstance);
  419.  
  420. bool ret=false;
  421. {
  422. CPythonLauncher pyLauncher;
  423. CPythonExceptionSender pyExceptionSender;
  424. SetExceptionSender(&pyExceptionSender);
  425.  
  426. if (pyLauncher.Create())
  427. {
  428. ret=RunMainScript(pyLauncher, lpCmdLine); //게임 실행중엔 함수가 끝나지 않는다.
  429. }
  430.  
  431. //ProcessScanner_ReleaseQuitEvent();
  432.  
  433. //게임 종료시.
  434. app->Clear();
  435.  
  436. timeEndPeriod(1);
  437. pyLauncher.Clear();
  438. }
  439.  
  440. app->Destroy();
  441. delete app;
  442.  
  443. return ret;
  444. }
  445.  
  446. HANDLE CreateMetin2GameMutex()
  447. {
  448. SECURITY_ATTRIBUTES sa;
  449. ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
  450. sa.nLength = sizeof(sa);
  451. sa.lpSecurityDescriptor = NULL;
  452. sa.bInheritHandle = FALSE;
  453.  
  454. return CreateMutex(&sa, FALSE, "Metin2GameMutex");
  455. }
  456.  
  457. void DestroyMetin2GameMutex(HANDLE hMutex)
  458. {
  459. if (hMutex)
  460. {
  461. ReleaseMutex(hMutex);
  462. hMutex = NULL;
  463. }
  464. }
  465.  
  466. void __ErrorPythonLibraryIsNotExist()
  467. {
  468. LogBoxf("FATAL ERROR!! Python Library file not exist!");
  469. }
  470.  
  471. bool __IsTimeStampOption(LPSTR lpCmdLine)
  472. {
  473. const char* TIMESTAMP = "/timestamp";
  474. return (strncmp(lpCmdLine, TIMESTAMP, strlen(TIMESTAMP))==0);
  475. }
  476.  
  477. void __PrintTimeStamp()
  478. {
  479. #ifdef _DEBUG
  480. if (__IS_TEST_SERVER_MODE__)
  481. LogBoxf("METIN2 BINARY TEST DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  482. else
  483. LogBoxf("METIN2 BINARY DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  484.  
  485. #else
  486. if (__IS_TEST_SERVER_MODE__)
  487. LogBoxf("METIN2 BINARY TEST VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  488. else
  489. LogBoxf("METIN2 BINARY DISTRIBUTE VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  490. #endif
  491. }
  492.  
  493. bool __IsLocaleOption(LPSTR lpCmdLine)
  494. {
  495. return (strcmp(lpCmdLine, "--locale") == 0);
  496. }
  497.  
  498. bool __IsLocaleVersion(LPSTR lpCmdLine)
  499. {
  500. return (strcmp(lpCmdLine, "--perforce-revision") == 0);
  501. }
  502.  
  503. #ifdef USE_OPENID
  504. //2012.07.16 김용욱
  505. //일본 OpenID 지원. 인증키 인자 추가
  506. bool __IsOpenIDAuthKeyOption(LPSTR lpCmdLine)
  507. {
  508. return (strcmp(lpCmdLine, "--openid-authkey") == 0);
  509. }
  510.  
  511. bool __IsOpenIDTestOption(LPSTR lpCmdLine) //클라이언트에서 로그인이 가능하다.
  512. {
  513. return (strcmp(lpCmdLine, "--openid-test") == 0);
  514. }
  515. #endif /* USE_OPENID */
  516.  
  517. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  518. {
  519. //GameGuard Metin2Argo end
  520. if (strstr(lpCmdLine, "--hackshield") != 0)
  521. return 0;
  522.  
  523. #ifdef _DEBUG
  524. _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF );
  525. //_CrtSetBreakAlloc( 110247 );
  526. #endif
  527.  
  528. ApplicationStringTable_Initialize(hInstance);
  529.  
  530. LocaleService_LoadConfig("locale.cfg");
  531. SetDefaultCodePage(LocaleService_GetCodePage());
  532.  
  533. #ifdef XTRAP_CLIENT_ENABLE
  534. if (!XTrap_Init())
  535. return 0;
  536. #endif
  537.  
  538. #ifdef USE_AHNLAB_HACKSHIELD
  539. if (!HackShield_Init())
  540. return 0;
  541. #endif
  542.  
  543. #ifdef USE_NPROTECT_GAMEGUARD
  544. if (!GameGuard_Init())
  545. return 0;
  546. #endif
  547.  
  548. #if defined(CHECK_LATEST_DATA_FILES)
  549. if (!CheckLatestFiles())
  550. return 0;
  551. #endif
  552.  
  553. bool bQuit = false;
  554. bool bAuthKeyChecked = false; //OpenID 버전에서 인증키가 들어왔는지 알기 위한 인자.
  555. int nArgc = 0;
  556. PCHAR* szArgv = CommandLineToArgv( lpCmdLine, &nArgc );
  557.  
  558. for( int i=0; i < nArgc; i++ ) {
  559. if(szArgv[i] == 0)
  560. continue;
  561. if (__IsLocaleVersion(szArgv[i])) // #0000829: [M2EU] 버전 파일이 항상 생기지 않도록 수정
  562. {
  563. char szModuleName[MAX_PATH];
  564. char szVersionPath[MAX_PATH];
  565. GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
  566. sprintf(szVersionPath, "%s.version", szModuleName);
  567. FILE* fp = fopen(szVersionPath, "wt");
  568. if (fp)
  569. {
  570. extern int METIN2_GET_VERSION();
  571. fprintf(fp, "r%d\n", METIN2_GET_VERSION());
  572. fclose(fp);
  573. }
  574. bQuit = true;
  575. } else if (__IsLocaleOption(szArgv[i]))
  576. {
  577. FILE* fp=fopen("locale.txt", "wt");
  578. fprintf(fp, "service[%s] code_page[%d]",
  579. LocaleService_GetName(), LocaleService_GetCodePage());
  580. fclose(fp);
  581. bQuit = true;
  582. } else if (__IsTimeStampOption(szArgv[i]))
  583. {
  584. __PrintTimeStamp();
  585. bQuit = true;
  586. } else if ((strcmp(szArgv[i], "--force-set-locale") == 0))
  587. {
  588. // locale 설정엔 인자가 두 개 더 필요함 (로케일 명칭, 데이터 경로)
  589. if (nArgc <= i + 2)
  590. {
  591. MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  592. goto Clean;
  593. }
  594.  
  595. const char* localeName = szArgv[++i];
  596. const char* localePath = szArgv[++i];
  597.  
  598. LocaleService_ForceSetLocale(localeName, localePath);
  599. }
  600. #ifdef USE_OPENID
  601. else if (__IsOpenIDAuthKeyOption(szArgv[i])) //2012.07.16 OpenID : 김용욱
  602. {
  603. // 인증키 설정엔 인자가 한 개 더 필요함 (인증키)
  604. if (nArgc <= i + 1)
  605. {
  606. MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  607. goto Clean;
  608. }
  609.  
  610. const char* authKey = szArgv[++i];
  611.  
  612. //ongoing (2012.07.16)
  613. //인증키 저장하는 부분
  614. LocaleService_SetOpenIDAuthKey(authKey);
  615.  
  616. bAuthKeyChecked = true;
  617. }
  618. else if (__IsOpenIDTestOption(szArgv[i]))
  619. {
  620. openid_test = 1;
  621.  
  622. }
  623. #endif /* USE_OPENID */
  624. }
  625.  
  626. #ifdef USE_OPENID
  627. //OpenID
  628. //OpenID 클라이언트의 경우인증키를 받아오지 않을 경우 (웹을 제외하고 실행 시) 클라이언트 종료.
  629.  
  630. if (false == bAuthKeyChecked && !openid_test)
  631. {
  632. MessageBox(NULL, "Invalid execution", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  633. goto Clean;
  634. }
  635. #endif /* USE_OPENID */
  636.  
  637.  
  638. if(bQuit)
  639. goto Clean;
  640.  
  641. #if defined(NEEDED_COMMAND_ARGUMENT)
  642. // 옵션이 없으면 비정상 실행으로 간주, 프로그램 종료
  643. if (strstr(lpCmdLine, NEEDED_COMMAND_ARGUMENT) == 0) {
  644. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  645. goto Clean;
  646. }
  647. #endif
  648.  
  649. #if defined(NEEDED_COMMAND_CLIPBOARD)
  650. {
  651. CHAR szSecKey[256];
  652. CPostIt cPostIt( "VOLUME1" );
  653.  
  654. if( cPostIt.Get( "SEC_KEY", szSecKey, sizeof(szSecKey) ) == FALSE ) {
  655. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  656. goto Clean;
  657. }
  658. if( strstr(szSecKey, NEEDED_COMMAND_CLIPBOARD) == 0 ) {
  659. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  660. goto Clean;
  661. }
  662. cPostIt.Empty();
  663. }
  664. #endif
  665.  
  666. WebBrowser_Startup(hInstance);
  667.  
  668. if (!CheckPythonLibraryFilenames())
  669. {
  670. __ErrorPythonLibraryIsNotExist();
  671. goto Clean;
  672. }
  673.  
  674. Main(hInstance, lpCmdLine);
  675.  
  676. #ifdef USE_NPROTECT_GAMEGUARD
  677. GameGuard_NoticeMessage();
  678. #endif
  679.  
  680. WebBrowser_Cleanup();
  681.  
  682. ::CoUninitialize();
  683.  
  684. if(gs_szErrorString[0])
  685. MessageBox(NULL, gs_szErrorString, ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  686.  
  687. Clean:
  688. #ifdef USE_AHNLAB_HACKSHIELD
  689. HackShield_Shutdown();
  690. #endif
  691. SAFE_FREE_GLOBAL(szArgv);
  692.  
  693. return 0;
  694. }
  695.  
  696. static void GrannyError(granny_log_message_type Type,
  697. granny_log_message_origin Origin,
  698. char const *Error,
  699. void *UserData)
  700. {
  701. TraceError("GRANNY: %s", Error);
  702. }
  703.  
  704. int Setup(LPSTR lpCmdLine)
  705. {
  706. /*
  707. * 타이머 정밀도를 올린다.
  708. */
  709. TIMECAPS tc;
  710. UINT wTimerRes;
  711.  
  712. if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
  713. return 0;
  714.  
  715. wTimerRes = MINMAX(tc.wPeriodMin, 1, tc.wPeriodMax);
  716. timeBeginPeriod(wTimerRes);
  717.  
  718. /*
  719. * 그래니 에러 핸들링
  720. */
  721.  
  722. granny_log_callback Callback;
  723. Callback.Function = GrannyError;
  724. Callback.UserData = 0;
  725. GrannySetLogCallback(&Callback);
  726. return 1;
  727. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement