Advertisement
Guest User

Untitled

a guest
May 30th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.81 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, "python27.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("root")).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. initquest();
  273. initBackground();
  274. initMessenger();
  275. initSash();
  276. initsafebox();
  277. initguild();
  278. initServerStateChecker();
  279.  
  280. NANOBEGIN
  281.  
  282. // RegisterDebugFlag
  283. {
  284. std::string stRegisterDebugFlag;
  285.  
  286. #ifdef _DISTRIBUTE
  287. stRegisterDebugFlag ="__DEBUG__ = 0";
  288. #else
  289. stRegisterDebugFlag ="__DEBUG__ = 1";
  290. #endif
  291.  
  292. if (!pyLauncher.RunLine(stRegisterDebugFlag.c_str()))
  293. {
  294. TraceError("RegisterDebugFlag Error");
  295. return false;
  296. }
  297. }
  298.  
  299. // RegisterCommandLine
  300. {
  301. std::string stRegisterCmdLine;
  302.  
  303. const char * loginMark = "-cs";
  304. const char * loginMark_NonEncode = "-ncs";
  305. const char * seperator = " ";
  306.  
  307. std::string stCmdLine;
  308. const int CmdSize = 3;
  309. vector<std::string> stVec;
  310. SplitLine(lpCmdLine,seperator,&stVec);
  311. if (CmdSize == stVec.size() && stVec[0]==loginMark)
  312. {
  313. char buf[MAX_PATH]; //TODO ¾Æ·¡ ÇÔ¼ö string ÇüÅ·Π¼öÁ¤
  314. base64_decode(stVec[2].c_str(),buf);
  315. stVec[2] = buf;
  316. string_join(seperator,stVec,&stCmdLine);
  317. }
  318. else if (CmdSize <= stVec.size() && stVec[0]==loginMark_NonEncode)
  319. {
  320. stVec[0] = loginMark;
  321. string_join(" ",stVec,&stCmdLine);
  322. }
  323. else
  324. stCmdLine = lpCmdLine;
  325.  
  326. stRegisterCmdLine ="__COMMAND_LINE__ = ";
  327. stRegisterCmdLine+='"';
  328. stRegisterCmdLine+=stCmdLine;
  329. stRegisterCmdLine+='"';
  330.  
  331. const CHAR* c_szRegisterCmdLine=stRegisterCmdLine.c_str();
  332. if (!pyLauncher.RunLine(c_szRegisterCmdLine))
  333. {
  334. TraceError("RegisterCommandLine Error");
  335. return false;
  336. }
  337. }
  338. {
  339. vector<std::string> stVec;
  340. SplitLine(lpCmdLine," " ,&stVec);
  341.  
  342. if (stVec.size() != 0 && "--pause-before-create-window" == stVec[0])
  343. {
  344. #ifdef XTRAP_CLIENT_ENABLE
  345. if (!XTrap_CheckInit())
  346. return false;
  347. #endif
  348. system("pause");
  349. }
  350. if (!pyLauncher.RunFile("system.py"))
  351. {
  352. TraceError("RunMain Error");
  353. return false;
  354. }
  355. }
  356.  
  357. NANOEND
  358. return true;
  359. }
  360.  
  361. bool Main(HINSTANCE hInstance, LPSTR lpCmdLine)
  362. {
  363. #ifdef LOCALE_SERVICE_YMIR
  364. extern bool g_isScreenShotKey;
  365. g_isScreenShotKey = true;
  366. #endif
  367.  
  368. DWORD dwRandSeed=time(NULL)+DWORD(GetCurrentProcess());
  369. srandom(dwRandSeed);
  370. srand(random());
  371.  
  372. SetLogLevel(1);
  373.  
  374. #ifdef LOCALE_SERVICE_VIETNAM_MILD
  375. extern BOOL USE_VIETNAM_CONVERT_WEAPON_VNUM;
  376. USE_VIETNAM_CONVERT_WEAPON_VNUM = true;
  377. #endif
  378.  
  379. if (_access("perf_game_update.txt", 0)==0)
  380. {
  381. DeleteFile("perf_game_update.txt");
  382. }
  383.  
  384. if (_access("newpatch.exe", 0)==0)
  385. {
  386. system("patchupdater.exe");
  387. return false;
  388. }
  389. #ifndef __VTUNE__
  390. ilInit();
  391. #endif
  392. if (!Setup(lpCmdLine))
  393. return false;
  394.  
  395. #ifdef _DEBUG
  396. OpenConsoleWindow();
  397. OpenLogFile(true); // true == uses syserr.txt and log.txt
  398. #else
  399. OpenLogFile(false); // false == uses syserr.txt only
  400. #endif
  401.  
  402. static CLZO lzo;
  403. static CEterPackManager EterPackManager;
  404.  
  405. if (!PackInitialize("pack"))
  406. {
  407. LogBox("Pack Initialization failed. Check log.txt file..");
  408. return false;
  409. }
  410.  
  411. if(LocaleService_LoadGlobal(hInstance))
  412. SetDefaultCodePage(LocaleService_GetCodePage());
  413.  
  414. CPythonApplication * app = new CPythonApplication;
  415.  
  416. app->Initialize(hInstance);
  417.  
  418. bool ret=false;
  419. {
  420. CPythonLauncher pyLauncher;
  421. CPythonExceptionSender pyExceptionSender;
  422. SetExceptionSender(&pyExceptionSender);
  423.  
  424. if (pyLauncher.Create())
  425. {
  426. ret=RunMainScript(pyLauncher, lpCmdLine); //°ÔÀÓ ½ÇÇàÁß¿£ ÇÔ¼ö°¡ ³¡³ªÁö ¾Ê´Â´Ù.
  427. }
  428.  
  429. //ProcessScanner_ReleaseQuitEvent();
  430.  
  431. //°ÔÀÓ Á¾·á½Ã.
  432. app->Clear();
  433.  
  434. timeEndPeriod(1);
  435. pyLauncher.Clear();
  436. }
  437.  
  438. app->Destroy();
  439. delete app;
  440.  
  441. return ret;
  442. }
  443.  
  444. HANDLE CreateMetin2GameMutex()
  445. {
  446. SECURITY_ATTRIBUTES sa;
  447. ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
  448. sa.nLength = sizeof(sa);
  449. sa.lpSecurityDescriptor = NULL;
  450. sa.bInheritHandle = FALSE;
  451.  
  452. return CreateMutex(&sa, FALSE, "Metin2GameMutex");
  453. }
  454.  
  455. void DestroyMetin2GameMutex(HANDLE hMutex)
  456. {
  457. if (hMutex)
  458. {
  459. ReleaseMutex(hMutex);
  460. hMutex = NULL;
  461. }
  462. }
  463.  
  464. void __ErrorPythonLibraryIsNotExist()
  465. {
  466. LogBoxf("FATAL ERROR!! Python Library file not exist!");
  467. }
  468.  
  469. bool __IsTimeStampOption(LPSTR lpCmdLine)
  470. {
  471. const char* TIMESTAMP = "/timestamp";
  472. return (strncmp(lpCmdLine, TIMESTAMP, strlen(TIMESTAMP))==0);
  473. }
  474.  
  475. void __PrintTimeStamp()
  476. {
  477. #ifdef _DEBUG
  478. if (__IS_TEST_SERVER_MODE__)
  479. LogBoxf("METIN2 BINARY TEST DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  480. else
  481. LogBoxf("METIN2 BINARY DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  482.  
  483. #else
  484. if (__IS_TEST_SERVER_MODE__)
  485. LogBoxf("METIN2 BINARY TEST VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  486. else
  487. LogBoxf("METIN2 BINARY DISTRIBUTE VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  488. #endif
  489. }
  490.  
  491. bool __IsLocaleOption(LPSTR lpCmdLine)
  492. {
  493. return (strcmp(lpCmdLine, "--locale") == 0);
  494. }
  495.  
  496. bool __IsLocaleVersion(LPSTR lpCmdLine)
  497. {
  498. return (strcmp(lpCmdLine, "--perforce-revision") == 0);
  499. }
  500.  
  501. #ifdef USE_OPENID
  502. //2012.07.16 ±è¿ë¿í
  503. //ÀϺ» OpenID Áö¿ø. ÀÎÁõÅ° ÀÎÀÚ Ãß°¡
  504. bool __IsOpenIDAuthKeyOption(LPSTR lpCmdLine)
  505. {
  506. return (strcmp(lpCmdLine, "--openid-authkey") == 0);
  507. }
  508.  
  509. bool __IsOpenIDTestOption(LPSTR lpCmdLine) //Ŭ¶óÀ̾ðÆ®¿¡¼­ ·Î±×ÀÎÀÌ °¡´ÉÇÏ´Ù.
  510. {
  511. return (strcmp(lpCmdLine, "--openid-test") == 0);
  512. }
  513. #endif /* USE_OPENID */
  514.  
  515. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  516. {
  517. if (strstr(lpCmdLine, "--hackshield") != 0)
  518. return 0;
  519.  
  520. #ifdef _DEBUG
  521. _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF );
  522. //_CrtSetBreakAlloc( 110247 );
  523. #endif
  524.  
  525. ApplicationStringTable_Initialize(hInstance);
  526.  
  527. LocaleService_LoadConfig("locale.cfg");
  528. SetDefaultCodePage(LocaleService_GetCodePage());
  529.  
  530. #ifdef XTRAP_CLIENT_ENABLE
  531. if (!XTrap_Init())
  532. return 0;
  533. #endif
  534.  
  535. #ifdef USE_AHNLAB_HACKSHIELD
  536. if (!HackShield_Init())
  537. return 0;
  538. #endif
  539.  
  540. #ifdef USE_NPROTECT_GAMEGUARD
  541. if (!GameGuard_Init())
  542. return 0;
  543. #endif
  544.  
  545. #if defined(CHECK_LATEST_DATA_FILES)
  546. if (!CheckLatestFiles())
  547. return 0;
  548. #endif
  549.  
  550. bool bQuit = false;
  551. bool bAuthKeyChecked = false; //OpenID ¹öÀü¿¡¼­ ÀÎÁõÅ°°¡ µé¾î¿Ô´ÂÁö ¾Ë±â À§ÇÑ ÀÎÀÚ.
  552. int nArgc = 0;
  553. PCHAR* szArgv = CommandLineToArgv( lpCmdLine, &nArgc );
  554.  
  555. for( int i=0; i < nArgc; i++ ) {
  556. if(szArgv[i] == 0)
  557. continue;
  558. if (__IsLocaleVersion(szArgv[i])) // #0000829: [M2EU] ¹öÀü ÆÄÀÏÀÌ Ç×»ó »ý±âÁö ¾Êµµ·Ï ¼öÁ¤
  559. {
  560. char szModuleName[MAX_PATH];
  561. char szVersionPath[MAX_PATH];
  562. GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
  563. sprintf(szVersionPath, "%s.version", szModuleName);
  564. FILE* fp = fopen(szVersionPath, "wt");
  565. if (fp)
  566. {
  567. extern int METIN2_GET_VERSION();
  568. fprintf(fp, "r%d\n", METIN2_GET_VERSION());
  569. fclose(fp);
  570. }
  571. bQuit = true;
  572. } else if (__IsLocaleOption(szArgv[i]))
  573. {
  574. FILE* fp=fopen("locale.txt", "wt");
  575. fprintf(fp, "service[%s] code_page[%d]",
  576. LocaleService_GetName(), LocaleService_GetCodePage());
  577. fclose(fp);
  578. bQuit = true;
  579. } else if (__IsTimeStampOption(szArgv[i]))
  580. {
  581. __PrintTimeStamp();
  582. bQuit = true;
  583. } else if ((strcmp(szArgv[i], "--force-set-locale") == 0))
  584. {
  585. // locale ¼³Á¤¿£ ÀÎÀÚ°¡ µÎ °³ ´õ ÇÊ¿äÇÔ (·ÎÄÉÀÏ ¸íĪ, µ¥ÀÌÅÍ °æ·Î)
  586. if (nArgc <= i + 2)
  587. {
  588. MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  589. goto Clean;
  590. }
  591.  
  592. const char* localeName = szArgv[++i];
  593. const char* localePath = szArgv[++i];
  594.  
  595. LocaleService_ForceSetLocale(localeName, localePath);
  596. }
  597. #ifdef USE_OPENID
  598. else if (__IsOpenIDAuthKeyOption(szArgv[i])) //2012.07.16 OpenID : ±è¿ë¿í
  599. {
  600. // ÀÎÁõÅ° ¼³Á¤¿£ ÀÎÀÚ°¡ ÇÑ °³ ´õ ÇÊ¿äÇÔ (ÀÎÁõÅ°)
  601. if (nArgc <= i + 1)
  602. {
  603. MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  604. goto Clean;
  605. }
  606.  
  607. const char* authKey = szArgv[++i];
  608.  
  609. //ongoing (2012.07.16)
  610. //ÀÎÁõÅ° ÀúÀåÇÏ´Â ºÎºÐ
  611. LocaleService_SetOpenIDAuthKey(authKey);
  612.  
  613. bAuthKeyChecked = true;
  614. }
  615. else if (__IsOpenIDTestOption(szArgv[i]))
  616. {
  617. openid_test = 1;
  618.  
  619. }
  620. #endif /* USE_OPENID */
  621. }
  622.  
  623. #ifdef USE_OPENID
  624. //OpenID
  625. //OpenID Ŭ¶óÀ̾ðÆ®ÀÇ °æ¿ìÀÎÁõÅ°¸¦ ¹Þ¾Æ¿ÀÁö ¾ÊÀ» °æ¿ì (À¥À» Á¦¿ÜÇÏ°í ½ÇÇà ½Ã) Ŭ¶óÀ̾ðÆ® Á¾·á.
  626.  
  627. if (false == bAuthKeyChecked && !openid_test)
  628. {
  629. MessageBox(NULL, "Invalid execution", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  630. goto Clean;
  631. }
  632. #endif /* USE_OPENID */
  633.  
  634.  
  635. if(bQuit)
  636. goto Clean;
  637.  
  638. #if defined(NEEDED_COMMAND_ARGUMENT)
  639. // ¿É¼ÇÀÌ ¾øÀ¸¸é ºñÁ¤»ó ½ÇÇàÀ¸·Î °£ÁÖ, ÇÁ·Î±×·¥ Á¾·á
  640. if (strstr(lpCmdLine, NEEDED_COMMAND_ARGUMENT) == 0) {
  641. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  642. goto Clean;
  643. }
  644. #endif
  645.  
  646. #if defined(NEEDED_COMMAND_CLIPBOARD)
  647. {
  648. CHAR szSecKey[256];
  649. CPostIt cPostIt( "VOLUME1" );
  650.  
  651. if( cPostIt.Get( "SEC_KEY", szSecKey, sizeof(szSecKey) ) == FALSE ) {
  652. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  653. goto Clean;
  654. }
  655. if( strstr(szSecKey, NEEDED_COMMAND_CLIPBOARD) == 0 ) {
  656. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  657. goto Clean;
  658. }
  659. cPostIt.Empty();
  660. }
  661. #endif
  662.  
  663. WebBrowser_Startup(hInstance);
  664.  
  665. if (!CheckPythonLibraryFilenames())
  666. {
  667. __ErrorPythonLibraryIsNotExist();
  668. goto Clean;
  669. }
  670.  
  671. Main(hInstance, lpCmdLine);
  672.  
  673. #ifdef USE_NPROTECT_GAMEGUARD
  674. GameGuard_NoticeMessage();
  675. #endif
  676.  
  677. WebBrowser_Cleanup();
  678.  
  679. ::CoUninitialize();
  680.  
  681. if(gs_szErrorString[0])
  682. MessageBox(NULL, gs_szErrorString, ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  683.  
  684. Clean:
  685. #ifdef USE_AHNLAB_HACKSHIELD
  686. HackShield_Shutdown();
  687. #endif
  688. SAFE_FREE_GLOBAL(szArgv);
  689.  
  690. return 0;
  691. }
  692.  
  693. static void GrannyError(granny_log_message_type Type,
  694. granny_log_message_origin Origin,
  695. char const *Error,
  696. void *UserData)
  697. {
  698. TraceError("GRANNY: %s", Error);
  699. }
  700.  
  701. int Setup(LPSTR lpCmdLine)
  702. {
  703. /*
  704. * ŸÀÌ¸Ó Á¤¹Ðµµ¸¦ ¿Ã¸°´Ù.
  705. */
  706. TIMECAPS tc;
  707. UINT wTimerRes;
  708.  
  709. if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
  710. return 0;
  711.  
  712. wTimerRes = MINMAX(tc.wPeriodMin, 1, tc.wPeriodMax);
  713. timeBeginPeriod(wTimerRes);
  714.  
  715. /*
  716. * ±×·¡´Ï ¿¡·¯ Çڵ鸵
  717. */
  718.  
  719. granny_log_callback Callback;
  720. Callback.Function = GrannyError;
  721. Callback.UserData = 0;
  722. GrannySetLogCallback(&Callback);
  723. return 1;
  724. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement