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. #ifdef _DEBUG
  8. #include <crtdbg.h>
  9. #endif
  10. #include "../eterPack/EterPackManager.h"
  11. #include "../eterLib/Util.h"
  12. #include "../CWebBrowser/CWebBrowser.h"
  13. #include "../eterBase/CPostIt.h"
  14. #include "CheckLatestFiles.h"
  15. #include "Hackshield.h"
  16. #include "NProtectGameGuard.h"
  17. #include "WiseLogicXTrap.h"
  18. extern "C" {
  19. extern int _fltused;
  20. volatile int _AVOID_FLOATING_POINT_LIBRARY_BUG = _fltused;
  21. };
  22. #pragma comment(linker, "/NODEFAULTLIB:libci.lib")
  23. #pragma comment( lib, "version.lib" )
  24. #pragma comment( lib, "python27.lib" )
  25. #pragma comment( lib, "imagehlp.lib" )
  26. #pragma comment( lib, "devil.lib" )
  27. #pragma comment( lib, "granny2.lib" )
  28. #pragma comment( lib, "mss32.lib" )
  29. #pragma comment( lib, "winmm.lib" )
  30. #pragma comment( lib, "imm32.lib" )
  31. #pragma comment( lib, "oldnames.lib" )
  32. #pragma comment( lib, "SpeedTreeRT.lib" )
  33. #pragma comment( lib, "dinput8.lib" )
  34. #pragma comment( lib, "dxguid.lib" )
  35. #pragma comment( lib, "ws2_32.lib" )
  36. #pragma comment( lib, "strmiids.lib" )
  37. #pragma comment( lib, "ddraw.lib" )
  38. #pragma comment( lib, "dmoguids.lib" )
  39. //#pragma comment( lib, "wsock32.lib" )
  40. #include <stdlib.h>
  41. #include <cryptopp/cryptoppLibLink.h>
  42. bool __IS_TEST_SERVER_MODE__=false;
  43. extern bool SetDefaultCodePage(DWORD codePage);
  44. #ifdef USE_OPENID
  45. extern int openid_test;
  46. #endif
  47. static const char * sc_apszPythonLibraryFilenames[] =
  48. {
  49. "UserDict.pyc",
  50. "__future__.pyc",
  51. "copy_reg.pyc",
  52. "linecache.pyc",
  53. "ntpath.pyc",
  54. "os.pyc",
  55. "site.pyc",
  56. "stat.pyc",
  57. "string.pyc",
  58. "traceback.pyc",
  59. "types.pyc",
  60. "\n",
  61. };
  62. char gs_szErrorString[512] = "";
  63. void ApplicationSetErrorString(const char* szErrorString)
  64. {
  65. strcpy_s(gs_szErrorString, szErrorString);
  66. }
  67. bool CheckPythonLibraryFilenames()
  68. {
  69. for (int i = 0; *sc_apszPythonLibraryFilenames[i] != '\n'; ++i)
  70. {
  71. std::string stFilename = "lib\\";
  72. stFilename += sc_apszPythonLibraryFilenames[i];
  73. if (_access(stFilename.c_str(), 0) != 0)
  74. {
  75. return false;
  76. }
  77. MoveFile(stFilename.c_str(), stFilename.c_str());
  78. }
  79. return true;
  80. }
  81. struct ApplicationStringTable
  82. {
  83. HINSTANCE m_hInstance;
  84. std::map<DWORD, std::string> m_kMap_dwID_stLocale;
  85. } gs_kAppStrTable;
  86. void ApplicationStringTable_Initialize(HINSTANCE hInstance)
  87. {
  88. gs_kAppStrTable.m_hInstance=hInstance;
  89. }
  90. const std::string& ApplicationStringTable_GetString(DWORD dwID, LPCSTR szKey)
  91. {
  92. char szBuffer[512];
  93. char szIniFileName[256];
  94. char szLocale[256];
  95. ::GetCurrentDirectory(sizeof(szIniFileName), szIniFileName);
  96. if(szIniFileName[lstrlen(szIniFileName)-1] != '\\')
  97. strcat_s(szIniFileName, "\\");
  98. strcat_s(szIniFileName, "metin2client.dat");
  99. strcpy_s(szLocale, LocaleService_GetLocalePath());
  100. if(strnicmp(szLocale, "locale/", strlen("locale/")) == 0)
  101. strcpy_s(szLocale, LocaleService_GetLocalePath() + strlen("locale/"));
  102. ::GetPrivateProfileString(szLocale, szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
  103. if(szBuffer[0] == '\0')
  104. LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
  105. if(szBuffer[0] == '\0')
  106. ::GetPrivateProfileString("en", szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
  107. if(szBuffer[0] == '\0')
  108. strcpy_s(szBuffer, szKey);
  109. std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
  110. rstLocale=szBuffer;
  111. return rstLocale;
  112. }
  113. const std::string& ApplicationStringTable_GetString(DWORD dwID)
  114. {
  115. char szBuffer[512];
  116. LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
  117. std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
  118. rstLocale=szBuffer;
  119. return rstLocale;
  120. }
  121. const char* ApplicationStringTable_GetStringz(DWORD dwID, LPCSTR szKey)
  122. {
  123. return ApplicationStringTable_GetString(dwID, szKey).c_str();
  124. }
  125. const char* ApplicationStringTable_GetStringz(DWORD dwID)
  126. {
  127. return ApplicationStringTable_GetString(dwID).c_str();
  128. }
  129. ////////////////////////////////////////////
  130. int Setup(LPSTR lpCmdLine); // Internal function forward
  131. bool PackInitialize(const char * c_pszFolder)
  132. {
  133. NANOBEGIN
  134. if (_access(c_pszFolder, 0) != 0)
  135. return true;
  136. std::string stFolder(c_pszFolder);
  137. stFolder += "/";
  138. std::string stFileName(stFolder);
  139. stFileName += "Index";
  140. CMappedFile file;
  141. LPCVOID pvData;
  142. if (!file.Create(stFileName.c_str(), &pvData, 0, 0))
  143. {
  144. LogBoxf("FATAL ERROR! File not exist: %s", stFileName.c_str());
  145. TraceError("FATAL ERROR! File not exist: %s", stFileName.c_str());
  146. return true;
  147. }
  148. CMemoryTextFileLoader TextLoader;
  149. TextLoader.Bind(file.Size(), pvData);
  150. bool bPackFirst = TRUE;
  151. const std::string& strPackType = TextLoader.GetLineString(0);
  152. if (strPackType.compare("FILE") && strPackType.compare("PACK"))
  153. {
  154. TraceError("Pack/Index has invalid syntax. First line must be 'PACK' or 'FILE'");
  155. return false;
  156. }
  157. #ifdef _DISTRIBUTE
  158. Tracef("¾Ë¸²: ÆÑ ¸ğµåÀÔ´Ï´Ù.\n");
  159. //if (0 == strPackType.compare("FILE"))
  160. //{
  161. // bPackFirst = FALSE;
  162. // Tracef("¾Ë¸²: ÆÄÀÏ ¸ğµåÀÔ´Ï´Ù.\n");
  163. //}
  164. //else
  165. //{
  166. // Tracef("¾Ë¸²: ÆÑ ¸ğµåÀÔ´Ï´Ù.\n");
  167. //}
  168. #else
  169. bPackFirst = FALSE;
  170. Tracef("¾Ë¸²: ÆÄÀÏ ¸ğµåÀÔ´Ï´Ù.\n");
  171. #endif
  172. CTextFileLoader::SetCacheMode();
  173. #if defined(USE_RELATIVE_PATH)
  174. CEterPackManager::Instance().SetRelativePathMode();
  175. #endif
  176. CEterPackManager::Instance().SetCacheMode();
  177. CEterPackManager::Instance().SetSearchMode(bPackFirst);
  178. CSoundData::SetPackMode(); // Miles ÆÄÀÏ ÄݹéÀ» ¼ÂÆÃ
  179. std::string strPackName, strTexCachePackName;
  180. for (DWORD i = 1; i < TextLoader.GetLineCount() - 1; i += 2)
  181. {
  182. const std::string & c_rstFolder = TextLoader.GetLineString(i);
  183. const std::string & c_rstName = TextLoader.GetLineString(i + 1);
  184. strPackName = stFolder + c_rstName;
  185. strTexCachePackName = strPackName + "_texcache";
  186. CEterPackManager::Instance().RegisterPack(strPackName.c_str(), c_rstFolder.c_str());
  187. CEterPackManager::Instance().RegisterPack(strTexCachePackName.c_str(), c_rstFolder.c_str());
  188. }
  189. CEterPackManager::Instance().RegisterRootPack((stFolder + std::string("root")).c_str());
  190. NANOEND
  191. return true;
  192. }
  193. bool RunMainScript(CPythonLauncher& pyLauncher, const char* lpCmdLine)
  194. {
  195. initpack();
  196. initdbg();
  197. initime();
  198. initgrp();
  199. initgrpImage();
  200. initgrpText();
  201. initwndMgr();
  202. /////////////////////////////////////////////
  203. initudp();
  204. initapp();
  205. initsystem();
  206. initchr();
  207. initchrmgr();
  208. initPlayer();
  209. initItem();
  210. initNonPlayer();
  211. initTrade();
  212. initChat();
  213. initTextTail();
  214. initnet();
  215. initMiniMap();
  216. initProfiler();
  217. initEvent();
  218. initeffect();
  219. initfly();
  220. initsnd();
  221. initeventmgr();
  222. initshop();
  223. initskill();
  224. initquest();
  225. initBackground();
  226. initMessenger();
  227. initsafebox();
  228. initguild();
  229. initServerStateChecker();
  230. NANOBEGIN
  231. // RegisterDebugFlag
  232. {
  233. std::string stRegisterDebugFlag;
  234. #ifdef _DISTRIBUTE
  235. stRegisterDebugFlag ="__DEBUG__ = 0";
  236. #else
  237. stRegisterDebugFlag ="__DEBUG__ = 1";
  238. #endif
  239. if (!pyLauncher.RunLine(stRegisterDebugFlag.c_str()))
  240. {
  241. TraceError("RegisterDebugFlag Error");
  242. return false;
  243. }
  244. }
  245. // RegisterCommandLine
  246. {
  247. std::string stRegisterCmdLine;
  248. const char * loginMark = "-cs";
  249. const char * loginMark_NonEncode = "-ncs";
  250. const char * seperator = " ";
  251. std::string stCmdLine;
  252. const int CmdSize = 3;
  253. vector<std::string> stVec;
  254. SplitLine(lpCmdLine,seperator,&stVec);
  255. if (CmdSize == stVec.size() && stVec[0]==loginMark)
  256. {
  257. char buf[MAX_PATH]; //TODO ¾Æ·¡ ÇÔ¼ö string ÇüÅ·Π¼öÁ¤
  258. base64_decode(stVec[2].c_str(),buf);
  259. stVec[2] = buf;
  260. string_join(seperator,stVec,&stCmdLine);
  261. }
  262. else if (CmdSize <= stVec.size() && stVec[0]==loginMark_NonEncode)
  263. {
  264. stVec[0] = loginMark;
  265. string_join(" ",stVec,&stCmdLine);
  266. }
  267. else
  268. stCmdLine = lpCmdLine;
  269. stRegisterCmdLine ="__COMMAND_LINE__ = ";
  270. stRegisterCmdLine+='"';
  271. stRegisterCmdLine+=stCmdLine;
  272. stRegisterCmdLine+='"';
  273. const CHAR* c_szRegisterCmdLine=stRegisterCmdLine.c_str();
  274. if (!pyLauncher.RunLine(c_szRegisterCmdLine))
  275. {
  276. TraceError("RegisterCommandLine Error");
  277. return false;
  278. }
  279. }
  280. {
  281. vector<std::string> stVec;
  282. SplitLine(lpCmdLine," " ,&stVec);
  283. if (stVec.size() != 0 && "--pause-before-create-window" == stVec[0])
  284. {
  285. #ifdef XTRAP_CLIENT_ENABLE
  286. if (!XTrap_CheckInit())
  287. return false;
  288. #endif
  289. system("pause");
  290. }
  291. if (!pyLauncher.RunFile("system.py"))
  292. {
  293. TraceError("RunMain Error");
  294. return false;
  295. }
  296. }
  297. NANOEND
  298. return true;
  299. }
  300. bool Main(HINSTANCE hInstance, LPSTR lpCmdLine)
  301. {
  302. #ifdef LOCALE_SERVICE_YMIR
  303. extern bool g_isScreenShotKey;
  304. g_isScreenShotKey = true;
  305. #endif
  306. DWORD dwRandSeed=time(NULL)+DWORD(GetCurrentProcess());
  307. srandom(dwRandSeed);
  308. srand(random());
  309. SetLogLevel(1);
  310. #ifdef LOCALE_SERVICE_VIETNAM_MILD
  311. extern BOOL USE_VIETNAM_CONVERT_WEAPON_VNUM;
  312. USE_VIETNAM_CONVERT_WEAPON_VNUM = true;
  313. #endif
  314. if (_access("perf_game_update.txt", 0)==0)
  315. {
  316. DeleteFile("perf_game_update.txt");
  317. }
  318. if (_access("newpatch.exe", 0)==0)
  319. {
  320. system("patchupdater.exe");
  321. return false;
  322. }
  323. #ifndef __VTUNE__
  324. ilInit();
  325. #endif
  326. if (!Setup(lpCmdLine))
  327. return false;
  328. #ifdef _DEBUG
  329. OpenConsoleWindow();
  330. OpenLogFile(true); // true == uses syserr.txt and log.txt
  331. #else
  332. OpenLogFile(false); // false == uses syserr.txt only
  333. #endif
  334. static CLZO lzo;
  335. static CEterPackManager EterPackManager;
  336. if (!PackInitialize("pack"))
  337. {
  338. LogBox("Pack Initialization failed. Check log.txt file..");
  339. return false;
  340. }
  341. if(LocaleService_LoadGlobal(hInstance))
  342. SetDefaultCodePage(LocaleService_GetCodePage());
  343. CPythonApplication * app = new CPythonApplication;
  344. app->Initialize(hInstance);
  345. bool ret=false;
  346. {
  347. CPythonLauncher pyLauncher;
  348. CPythonExceptionSender pyExceptionSender;
  349. SetExceptionSender(&pyExceptionSender);
  350. if (pyLauncher.Create())
  351. {
  352. ret=RunMainScript(pyLauncher, lpCmdLine); //°ÔÀÓ ½ÇÇàÁß¿£ ÇÔ¼ö°¡ ³¡³ªÁö ¾Ê´Â´Ù.
  353. }
  354. //ProcessScanner_ReleaseQuitEvent();
  355. //°ÔÀÓ Á¾·á½Ã.
  356. app->Clear();
  357. timeEndPeriod(1);
  358. pyLauncher.Clear();
  359. }
  360. app->Destroy();
  361. delete app;
  362. return ret;
  363. }
  364. HANDLE CreateMetin2GameMutex()
  365. {
  366. SECURITY_ATTRIBUTES sa;
  367. ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
  368. sa.nLength = sizeof(sa);
  369. sa.lpSecurityDescriptor = NULL;
  370. sa.bInheritHandle = FALSE;
  371. return CreateMutex(&sa, FALSE, "Metin2GameMutex");
  372. }
  373. void DestroyMetin2GameMutex(HANDLE hMutex)
  374. {
  375. if (hMutex)
  376. {
  377. ReleaseMutex(hMutex);
  378. hMutex = NULL;
  379. }
  380. }
  381. void __ErrorPythonLibraryIsNotExist()
  382. {
  383. LogBoxf("FATAL ERROR!! Python Library file not exist!");
  384. }
  385. bool __IsTimeStampOption(LPSTR lpCmdLine)
  386. {
  387. const char* TIMESTAMP = "/timestamp";
  388. return (strncmp(lpCmdLine, TIMESTAMP, strlen(TIMESTAMP))==0);
  389. }
  390. void __PrintTimeStamp()
  391. {
  392. #ifdef _DEBUG
  393. if (__IS_TEST_SERVER_MODE__)
  394. LogBoxf("METIN2 BINARY TEST DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  395. else
  396. LogBoxf("METIN2 BINARY DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  397. #else
  398. if (__IS_TEST_SERVER_MODE__)
  399. LogBoxf("METIN2 BINARY TEST VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  400. else
  401. LogBoxf("METIN2 BINARY DISTRIBUTE VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  402. #endif
  403. }
  404. bool __IsLocaleOption(LPSTR lpCmdLine)
  405. {
  406. return (strcmp(lpCmdLine, "--locale") == 0);
  407. }
  408. bool __IsLocaleVersion(LPSTR lpCmdLine)
  409. {
  410. return (strcmp(lpCmdLine, "--perforce-revision") == 0);
  411. }
  412. #ifdef USE_OPENID
  413. //2012.07.16 ±è¿ë¿í
  414. //ÀϺ» OpenID Áö¿ø. ÀÎÁõŰ ÀÎÀÚ Ãß°¡
  415. bool __IsOpenIDAuthKeyOption(LPSTR lpCmdLine)
  416. {
  417. return (strcmp(lpCmdLine, "--openid-authkey") == 0);
  418. }
  419. bool __IsOpenIDTestOption(LPSTR lpCmdLine) //Ŭ¶óÀÌ¾ğÆ®¿¡¼­ ·Î±×ÀÎÀÌ °¡´ÉÇÏ´Ù.
  420. {
  421. return (strcmp(lpCmdLine, "--openid-test") == 0);
  422. }
  423. #endif /* USE_OPENID */
  424. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  425. {
  426. if (strstr(lpCmdLine, "--hackshield") != 0)
  427. return 0;
  428. #ifdef _DEBUG
  429. _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF );
  430. //_CrtSetBreakAlloc( 110247 );
  431. #endif
  432. ApplicationStringTable_Initialize(hInstance);
  433. LocaleService_LoadConfig("locale.cfg");
  434. SetDefaultCodePage(LocaleService_GetCodePage());
  435. #ifdef XTRAP_CLIENT_ENABLE
  436. if (!XTrap_Init())
  437. return 0;
  438. #endif
  439. #ifdef USE_AHNLAB_HACKSHIELD
  440. if (!HackShield_Init())
  441. return 0;
  442. #endif
  443. #ifdef USE_NPROTECT_GAMEGUARD
  444. if (!GameGuard_Init())
  445. return 0;
  446. #endif
  447. #if defined(CHECK_LATEST_DATA_FILES)
  448. if (!CheckLatestFiles())
  449. return 0;
  450. #endif
  451. bool bQuit = false;
  452. bool bAuthKeyChecked = false; //OpenID ¹öÀü¿¡¼­ ÀÎÁõ۰¡ µé¾î¿Ô´ÂÁö ¾Ë±â À§ÇÑ ÀÎÀÚ.
  453. int nArgc = 0;
  454. PCHAR* szArgv = CommandLineToArgv( lpCmdLine, &nArgc );
  455. for( int i=0; i < nArgc; i++ ) {
  456. if(szArgv[i] == 0)
  457. continue;
  458. if (__IsLocaleVersion(szArgv[i])) // #0000829: [M2EU] ¹öÀü ÆÄÀÏÀÌ Ç×»ó »ı±âÁö ¾Êµµ·Ï ¼öÁ¤
  459. {
  460. char szModuleName[MAX_PATH];
  461. char szVersionPath[MAX_PATH];
  462. GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
  463. snprintf_s(szVersionPath, "%s.version", szModuleName);
  464. FILE* fp = fopen(szVersionPath, "wt");
  465. if (fp)
  466. {
  467. extern int METIN2_GET_VERSION();
  468. fprintf(fp, "r%d\n", METIN2_GET_VERSION());
  469. fclose(fp);
  470. }
  471. bQuit = true;
  472. } else if (__IsLocaleOption(szArgv[i]))
  473. {
  474. FILE* fp=fopen("locale.txt", "wt");
  475. fprintf(fp, "service[%s] code_page[%d]",
  476. LocaleService_GetName(), LocaleService_GetCodePage());
  477. fclose(fp);
  478. bQuit = true;
  479. } else if (__IsTimeStampOption(szArgv[i]))
  480. {
  481. __PrintTimeStamp();
  482. bQuit = true;
  483. } else if ((strcmp(szArgv[i], "--force-set-locale") == 0))
  484. {
  485. // locale ¼³Á¤¿£ ÀÎÀÚ°¡ µÎ °³ ´õ ÇÊ¿äÇÔ (·ÎÄÉÀÏ ¸íĪ, µ¥ÀÌÅÍ °æ·Î)
  486. if (nArgc <= i + 2)
  487. {
  488. MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  489. goto Clean;
  490. }
  491. const char* localeName = szArgv[++i];
  492. const char* localePath = szArgv[++i];
  493. LocaleService_ForceSetLocale(localeName, localePath);
  494. }
  495. #ifdef USE_OPENID
  496. else if (__IsOpenIDAuthKeyOption(szArgv[i])) //2012.07.16 OpenID : ±è¿ë¿í
  497. {
  498. // ÀÎÁõŰ ¼³Á¤¿£ ÀÎÀÚ°¡ ÇÑ °³ ´õ ÇÊ¿äÇÔ (ÀÎÁõŰ)
  499. if (nArgc <= i + 1)
  500. {
  501. MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  502. goto Clean;
  503. }
  504. const char* authKey = szArgv[++i];
  505. //ongoing (2012.07.16)
  506. //ÀÎÁõŰ ÀúÀåÇÏ´Â ºÎºĞ
  507. LocaleService_SetOpenIDAuthKey(authKey);
  508. bAuthKeyChecked = true;
  509. }
  510. else if (__IsOpenIDTestOption(szArgv[i]))
  511. {
  512. openid_test = 1;
  513. }
  514. #endif /* USE_OPENID */
  515. }
  516. #ifdef USE_OPENID
  517. //OpenID
  518. //OpenID Ŭ¶óÀ̾ğÆ®ÀÇ °æ¿ìÀÎÁõ۸¦ ¹Ş¾Æ¿ÀÁö ¾ÊÀ» °æ¿ì (À¥À» Á¦¿ÜÇÏ°í ½ÇÇà ½Ã) Ŭ¶óÀÌ¾ğÆ® Á¾·á.
  519. if (false == bAuthKeyChecked && !openid_test)
  520. {
  521. MessageBox(NULL, "Invalid execution", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  522. goto Clean;
  523. }
  524. #endif /* USE_OPENID */
  525. if(bQuit)
  526. goto Clean;
  527. #if defined(NEEDED_COMMAND_ARGUMENT)
  528. // ¿É¼ÇÀÌ ¾øÀ¸¸é ºñÁ¤»ó ½ÇÇàÀ¸·Î °£ÁÖ, ÇÁ·Î±×·¥ Á¾·á
  529. if (strstr(lpCmdLine, NEEDED_COMMAND_ARGUMENT) == 0) {
  530. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  531. goto Clean;
  532. }
  533. #endif
  534. #if defined(NEEDED_COMMAND_CLIPBOARD)
  535. {
  536. CHAR szSecKey[256];
  537. CPostIt cPostIt( "VOLUME1" );
  538. if( cPostIt.Get( "SEC_KEY", szSecKey, sizeof(szSecKey) ) == FALSE ) {
  539. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  540. goto Clean;
  541. }
  542. if( strstr(szSecKey, NEEDED_COMMAND_CLIPBOARD) == 0 ) {
  543. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  544. goto Clean;
  545. }
  546. cPostIt.Empty();
  547. }
  548. #endif
  549. WebBrowser_Startup(hInstance);
  550. if (!CheckPythonLibraryFilenames())
  551. {
  552. __ErrorPythonLibraryIsNotExist();
  553. goto Clean;
  554. }
  555. Main(hInstance, lpCmdLine);
  556. #ifdef USE_NPROTECT_GAMEGUARD
  557. GameGuard_NoticeMessage();
  558. #endif
  559. WebBrowser_Cleanup();
  560. ::CoUninitialize();
  561. if(gs_szErrorString[0])
  562. MessageBox(NULL, gs_szErrorString, ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  563. Clean:
  564. #ifdef USE_AHNLAB_HACKSHIELD
  565. HackShield_Shutdown();
  566. #endif
  567. SAFE_FREE_GLOBAL(szArgv);
  568. return 0;
  569. }
  570. static void GrannyError(granny_log_message_type Type,
  571. granny_log_message_origin Origin,
  572. char const* File,
  573. granny_int32x Line,
  574. char const *Error,
  575. void *UserData)
  576. {
  577. //TraceError("GRANNY: %s", Error);
  578. }
  579. int Setup(LPSTR lpCmdLine)
  580. {
  581. /*
  582. * ŸÀÌ¸Ó Á¤¹Ğµµ¸¦ ¿Ã¸°´Ù.
  583. */
  584. TIMECAPS tc;
  585. UINT wTimerRes;
  586. if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
  587. return 0;
  588. wTimerRes = MINMAX(tc.wPeriodMin, 1, tc.wPeriodMax);
  589. timeBeginPeriod(wTimerRes);
  590. /*
  591. * ±×·¡´Ï ¿¡·¯ Çڵ鸵
  592. */
  593. // granny_log_callback Callback;
  594. // Callback.Function = GrannyError;
  595. // Callback.UserData = 0;
  596. // GrannySetLogCallback(&Callback);
  597. return 1;
  598. }

UserInterface.cpp