Advertisement
Guest User

UserInterface.cpp

a guest
Jan 21st, 2019
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.23 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.  
  9. #ifdef ENABLE_CHECK_FILES_MD5
  10. #include "md5.h"
  11. #include <windows.h>
  12. #endif//
  13.  
  14. #ifdef _DEBUG
  15. #include <crtdbg.h>
  16. #endif
  17. //zerant -iti canta dolanescu in burta
  18. #include "../eterPack/EterPackManager.h"
  19. #include "../eterLib/Util.h"
  20. #include "../CWebBrowser/CWebBrowser.h"
  21. #include "../eterBase/CPostIt.h"
  22.  
  23. #include "CheckLatestFiles.h"
  24.  
  25. #include "Hackshield.h"
  26. #include "NProtectGameGuard.h"
  27. #include "WiseLogicXTrap.h"
  28. #define INDEX_FILE_FROM_C
  29. extern "C" {
  30. extern int _fltused;
  31. volatile int _AVOID_FLOATING_POINT_LIBRARY_BUG = _fltused;
  32. };
  33.  
  34. #pragma comment(linker, "/NODEFAULTLIB:libci.lib")
  35.  
  36. #pragma comment( lib, "version.lib" )
  37.  
  38. //#ifdef _DEBUG
  39. //#pragma comment( lib, "python2_d.lib" )
  40. //#else
  41. #pragma comment( lib, "python2.lib" )
  42. //#endif
  43. #pragma comment( lib, "imagehlp.lib" )
  44. #pragma comment( lib, "devil.lib" )
  45.  
  46. #if GrannyProductMinorVersion==4
  47. #pragma comment( lib, "granny2.4.0.10.lib" )
  48. #elif GrannyProductMinorVersion==7
  49. #pragma comment( lib, "granny2.7.0.30.lib" )
  50. #elif GrannyProductMinorVersion==9
  51. #pragma comment( lib, "granny2.9.12.0.lib" )
  52. #else
  53. #error "unknown granny version"
  54. #endif
  55. #pragma comment( lib, "mss32.lib" )
  56. #pragma comment( lib, "winmm.lib" )
  57. #pragma comment( lib, "imm32.lib" )
  58. #pragma comment( lib, "oldnames.lib" )
  59. #pragma comment( lib, "SpeedTreeRT.lib" )
  60. #pragma comment( lib, "dinput8.lib" )
  61. #pragma comment( lib, "dxguid.lib" )
  62. #pragma comment( lib, "ws2_32.lib" )
  63. #pragma comment( lib, "strmiids.lib" )
  64. #pragma comment( lib, "ddraw.lib" )
  65. #pragma comment( lib, "dmoguids.lib" )
  66. //#pragma comment( lib, "wsock32.lib" )
  67. #include <stdlib.h>
  68. #include <cryptopp/cryptoppLibLink.h>
  69. bool __IS_TEST_SERVER_MODE__=false;
  70.  
  71. // #define __USE_CYTHON__
  72. #ifdef __USE_CYTHON__
  73. // don't include these two files .h .cpp if you're implementing cython via .pyd
  74. // #include "PythonrootlibManager.h"
  75. // it would be better including such file in the project, but this is easier at this moment:
  76. // #include "PythonrootlibManager.cpp"
  77. #endif
  78.  
  79. // #define __USE_EXTRA_CYTHON__
  80. #ifdef __USE_EXTRA_CYTHON__
  81. // don't include these two files .h .cpp if you're implementing cython via .pyd
  82. // #include "PythonuiscriptlibManager.h"
  83. // it would be better including such file in the project, but this is easier at this moment:
  84. // #include "PythonuiscriptlibManager.cpp"
  85. #endif
  86.  
  87. #define ENABLE_PYLIB_CHECK
  88. #define ENABLE_MILES_CHECK
  89. // #define ENABLE_DAEMONPROTECTION
  90.  
  91. #ifdef ENABLE_DAEMONPROTECTION
  92. #define DPDLL_FILENAME "dpdll.dll"
  93. #define DPDLL_CRC32 0x48104810
  94. #define DPDLL_FILESIZE 1234567+4
  95. #endif
  96.  
  97. extern bool SetDefaultCodePage(DWORD codePage);
  98.  
  99. #ifdef USE_OPENID
  100. extern int openid_test;
  101. #endif
  102.  
  103. static const char * sc_apszPythonLibraryFilenames[] =
  104. {
  105. "UserDict.pyc",
  106. "__future__.pyc",
  107. "copy_reg.pyc",
  108. "linecache.pyc",
  109. "ntpath.pyc",
  110. "os.pyc",
  111. "site.pyc",
  112. "stat.pyc",
  113. "string.pyc",
  114. "traceback.pyc",
  115. "types.pyc",
  116. "\n",
  117. };
  118.  
  119. #ifdef ENABLE_CHECK_FILES_MD5
  120. #define MAX_ROWS_MD5 38
  121. static char * ar_szMD5FileNames[MAX_ROWS_MD5][38] =
  122. {
  123. //// Example of list:
  124. //{ "pack/eren.eix", "c31719a1c1223ad1b20ddec5f2384101" },
  125. //{ "pack/eren.epk", "dbfa860220915abb45324ff2a805510f" },
  126. //{ "pack/etc.eix", "cdc35c79b1b8b192320843301a6b16e4" },
  127. //{ "pack/etc.epk", "1b7094a41ab7eceedfa3ac8c334d2017" },
  128. //{ "pack/locale_ro.eix", "e6d869923c45e0efa349c0d3facbbfe8" },
  129. //{ "pack/locale_ro.epk", "60392d5865eb0c7fdcb21b1ecdd19ada" },
  130. //{ "pack/maps_empire.eix", "938ce4a82899460793a8d6a36ba3e5ff" },
  131. //{ "pack/maps_empire.epk", "71e8de0fe130b23a19cb33eb080df823" },
  132. //{ "pack/monsters.eix", "b012eca113060ae54ace08b26a57f150" },
  133. //{ "pack/monsters.epk", "cd05175ee08ba3e4c56e9aea16e4a6fd" },
  134. //{ "pack/outdoor.eix", "00e1e9bb442269a53e5b7f54fb70eac4" },
  135. //{ "pack/outdoor.epk", "be07382ea2a62aa83529310bcd07d1f2" },
  136. //{ "pack/PC.eix", "5614cb463ac9e0af029a1229ca85ea34" },
  137. //{ "pack/PC.epk", "0f66399d6b73dd7adf5250d60840c7f4" },
  138. //{ "pack/pc2.eix", "a483bf010a4d3aa2dfc8e847dea4a44c" },
  139. //{ "pack/pc2.epk", "9d230ab903020cb9ffb83df91ae00442" },
  140. //{ "pack/Property.eix", "e6d869923c45e0efa349c0d3facbbfe8" },
  141. //{ "pack/Property.epk", "d0576304be9dd726a92bba6902797cc9" },
  142. //{ "pack/resource.eix", "df8662eb66c04e122ccb3cf134dab146" },
  143. //{ "pack/resource.epk", "6246c8ecedf6f22e92523e022223a685" },
  144. //{ "pack/root.eix", "e6d869923c45e0efa349c0d3facbbfe8" },
  145. //{ "pack/root.epk", "2d9e0f24571f42f4d19116cf5a6c2ec9" },
  146. //{ "pack/season1.eix", "cdc35c79b1b8b192320843301a6b16e4" },
  147. //{ "pack/season1.epk", "b2217b4555c13eb5db2f834ffd3b7bf3" },
  148. //{ "miles/mss32.dll", "3713b70df4337874fb32e2bd37dbf699" },
  149. //{ "miles/mssa3d.m3d", "e089ce52b0617a6530069f22e0bdba2a" },
  150. //{ "miles/mssds3d.m3d", "85267776d45dbf5475c7d9882f08117c" },
  151. //{ "miles/mssdsp.flt", "cb71b1791009eca618e9b1ad4baa4fa9" },
  152. //{ "miles/mssdx7.m3d", "2727e2671482a55b2f1f16aa88d2780f" },
  153. //{ "miles/msseax.m3d", "788bd950efe89fa5166292bd6729fa62" },
  154. //{ "miles/mssmp3.asi", "189576dfe55af3b70db7e3e2312cd0fd" },
  155. //{ "miles/mssrsx.m3d", "7fae15b559eb91f491a5f75cfa103cd4" },
  156. //{ "miles/msssoft.m3d", "bdc9ad58ade17dbd939522eee447416f" },
  157. //{ "miles/mssvoice.asi", "3d5342edebe722748ace78c930f4d8a5" },
  158. //{ "pack/Index", "7b18cde0863cc904f85989083c4cea0e" },
  159. //{ "devil.dll", "8df4d4324e5755f1a0567db3c5be4c58" },
  160. //{ "python27.dll", "ff8c5a52431fdacfb9913aa47a4af2c2" },
  161. { "msvcr910.dll", "321470e158573d20149028021fc550c1" }
  162. /*
  163. Unlimited files
  164. *///
  165. };
  166. #endif
  167.  
  168.  
  169. #ifdef ENABLE_PYLIB_CHECK
  170. #define PRINT_LEVEL 0
  171. #define PRINTME(level, ...) if(PRINT_LEVEL>=level) TraceError(__VA_ARGS__);
  172. #define PYFOLD "./lib"
  173. // #define PYFORCE
  174.  
  175. typedef struct PyLibFiles_s
  176. {
  177. std::string sFileName;
  178. size_t stSize;
  179. DWORD dwCRC32;
  180. } PyLibFiles_t;
  181.  
  182. PyLibFiles_t PyLibFilesTable[] =
  183. {
  184. #if PY_VERSION_HEX==0x020706f0
  185. { PYFOLD"/UserDict.pyc", 9000, 1431875928},
  186. { PYFOLD"/__future__.pyc", 4431, 2857792867},
  187. { PYFOLD"/copy_reg.pyc", 5157, 536292604},
  188. { PYFOLD"/linecache.pyc", 3235, 4048207604},
  189. { PYFOLD"/ntpath.pyc", 11961, 2765879465},
  190. { PYFOLD"/os.pyc", 25769, 911432770},
  191. { PYFOLD"/site.pyc", 20019, 3897044925},
  192. { PYFOLD"/stat.pyc", 2791, 1375966108},
  193. { PYFOLD"/string.pyc", 13514, 648740690},
  194. { PYFOLD"/traceback.pyc", 11703, 3768933732},
  195. { PYFOLD"/types.pyc", 2530, 920695307},
  196. #elif PY_VERSION_HEX==0x020203f0
  197. #else
  198. #error "unknown python version"
  199. #endif
  200. };
  201.  
  202. bool checkPyLibDir(const string szDirName)
  203. {
  204. bool HasHack = false;
  205.  
  206. char szDirNamePath[MAX_PATH];
  207. sprintf(szDirNamePath, "%s\\*", szDirName.c_str());
  208.  
  209. WIN32_FIND_DATA f;
  210. HANDLE h = FindFirstFile(szDirNamePath, &f);
  211.  
  212. if (h == INVALID_HANDLE_VALUE) { return HasHack; }
  213.  
  214. do
  215. {
  216. if (HasHack)
  217. break;
  218. const char * name = f.cFileName;
  219.  
  220. if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) { continue; }
  221.  
  222. if (f.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
  223. {
  224. char filePath[MAX_PATH];
  225. sprintf(filePath, "%s%s%s", szDirName.c_str(), "\\", name);
  226. PRINTME(1, "sub %s", filePath);
  227. checkPyLibDir(filePath);
  228. }
  229. else
  230. {
  231. // start processing file
  232. PRINTME(1, "starting %s", name);
  233. std::string sName(name);
  234. std::string sPathName(szDirName+"/"+name);
  235. // change \\ to /
  236. std::replace(sPathName.begin(), sPathName.end(), '\\', '/');
  237. PRINTME(1, "path %s", sPathName.c_str());
  238. // lower file name
  239. std::transform(sName.begin(), sName.end(), sName.begin(), ::tolower);
  240. {
  241. PRINTME(1, "verify %s", sName.c_str());
  242. bool isPyLibFound = false;
  243. for (PyLibFiles_t *i1=std::begin(PyLibFilesTable), *e1=std::end(PyLibFilesTable); i1<e1; i1++)
  244. {
  245. if (!i1->sFileName.compare(sPathName))
  246. {
  247. PRINTME(1, "found %s==%s", i1->sFileName.c_str(), sName.c_str());
  248. DWORD dwCrc32 = GetFileCRC32(sPathName.c_str());
  249. // assert(dwCrc32);
  250. //DWORD dwFileSize = f.nFileSizeLow;
  251. //if (i1->stSize!=dwFileSize)
  252. //{
  253. // PRINTME(1, "wrong size %u==%u", i1->stSize, dwFileSize);
  254. // HasHack = true;
  255. // PRINTME(0, "wrong size %u for %s", dwFileSize, sPathName.c_str());
  256. // return HasHack;
  257. //}
  258. //else if (i1->dwCRC32 != dwCrc32)
  259. //{
  260. // PRINTME(1, "wrong crc32 %u==%u", i1->dwCRC32, dwCrc32);
  261. // HasHack = true;
  262. // PRINTME(0, "wrong crc32 %u for %s", dwCrc32, sPathName.c_str());
  263. // return HasHack;
  264. //}
  265. }
  266. }
  267. // block ambiguous pyc/d files
  268. if (!isPyLibFound)
  269. {
  270. PRINTME(1, "not found %s", sName.c_str());
  271. #ifdef PYFORCE
  272. HasHack = true;
  273. PRINTME(0, "ambiguous file for %s", sPathName.c_str());
  274. return HasHack;
  275. #endif
  276. }
  277. PRINTME(1, "skipping file(%s) hack(%u) found(%u)", sName.c_str(), HasHack, isPyLibFound);
  278. }
  279. }
  280.  
  281. } while (FindNextFile(h, &f));
  282. FindClose(h);
  283. return HasHack;
  284. }
  285.  
  286. bool __CheckPyLibFiles()
  287. {
  288. PRINTME(1, "__CheckPyLibFiles processing "PYFOLD);
  289. if (checkPyLibDir(PYFOLD))
  290. return false;
  291. return true;
  292. }
  293. #endif
  294.  
  295. #ifdef ENABLE_MILES_CHECK
  296. #include <algorithm>
  297. #include "../EterBase/Filename.h"
  298. // #include "../EterBase/CRC32.h"
  299. #define PRINT_LEVEL 0
  300. #define PRINTME(level, ...) if(PRINT_LEVEL>=level) TraceError(__VA_ARGS__);
  301.  
  302. typedef struct MilesFiles_s
  303. {
  304. std::string sFileName;
  305. size_t stSize;
  306. DWORD dwCRC32;
  307. } MilesFiles_t;
  308.  
  309. typedef struct MilesExten_s
  310. {
  311. std::string ExtName;
  312. bool IsUni;
  313. } MilesExten_t;
  314.  
  315. MilesExten_t MilesExtenTable[] = {
  316. {"dll", false},
  317. {"asi", true},
  318. {"flt", true},
  319. {"m3d", true},
  320. {"mix", true},
  321. };
  322.  
  323. MilesFiles_t MilesFilesTable[] =
  324. {
  325. {"mss32.dll", 349696, 1817711331},
  326. {"mssa3d.m3d", 83456, 1812642892},
  327. {"mssds3d.m3d", 70656, 2704596484},
  328. {"mssdsp.flt", 93696, 3364819387},
  329. {"mssdx7.m3d", 80896, 236402185},
  330. {"msseax.m3d", 103424, 3195814903},
  331. {"mssmp3.asi", 125952, 1219814613},
  332. {"mssrsx.m3d", 354816, 550946743},
  333. {"msssoft.m3d", 67072, 4284421368},
  334. {"mssvoice.asi", 197120, 1407967464},
  335. };
  336.  
  337. bool checkMilesDir(const string szDirName)
  338. {
  339. bool HasHack = false;
  340.  
  341. char szDirNamePath[MAX_PATH];
  342. sprintf(szDirNamePath, "%s\\*", szDirName.c_str());
  343.  
  344. WIN32_FIND_DATA f;
  345. HANDLE h = FindFirstFile(szDirNamePath, &f);
  346.  
  347. if (h == INVALID_HANDLE_VALUE) { return HasHack; }
  348.  
  349. do
  350. {
  351. if (HasHack)
  352. break;
  353. const char * name = f.cFileName;
  354.  
  355. if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) { continue; }
  356.  
  357. if (f.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
  358. {
  359. // do nothing if it's a folder
  360. }
  361. else
  362. {
  363. // start processing file
  364. PRINTME(1, "starting %s", name);
  365. std::string sName(name);
  366. std::string sPathName(szDirName+"/"+name);
  367. PRINTME(1, "path %s", sPathName.c_str());
  368. // lower file name
  369. std::transform(sName.begin(), sName.end(), sName.begin(), ::tolower);
  370. // file or symlink; check for asi flt m3d mix exploit
  371. string sNameExt = CFileNameHelper::GetExtension(sName);
  372. PRINTME(1, "ext %s", sNameExt.c_str());
  373. // workaround instead of std::find
  374. bool isMilesFile = false, isMilesUnique = false;
  375. for (MilesExten_t *i1=std::begin(MilesExtenTable), *e1=std::end(MilesExtenTable); i1<e1; i1++)
  376. {
  377. PRINTME(1, "is %s ? %s", i1->ExtName.c_str(), sNameExt.c_str());
  378. if (!sNameExt.compare(0, i1->ExtName.length(), i1->ExtName))
  379. {
  380. isMilesFile = true;
  381. isMilesUnique = i1->IsUni;
  382. }
  383. }
  384. if (isMilesFile)
  385. {
  386. PRINTME(1, "verify %s -> %s", sName.c_str(), sNameExt.c_str());
  387. bool isMilesFound = false;
  388. for (MilesFiles_t *i1=std::begin(MilesFilesTable), *e1=std::end(MilesFilesTable); i1<e1; i1++)
  389. {
  390. if (!i1->sFileName.compare(sName))
  391. {
  392. PRINTME(1, "found %s==%s", i1->sFileName.c_str(), sName.c_str());
  393. DWORD dwCrc32 = GetFileCRC32(sPathName.c_str());
  394. // assert(dwCrc32);
  395. //DWORD dwFileSize = f.nFileSizeLow;
  396. //if (i1->stSize!=dwFileSize)
  397. //{
  398. // PRINTME(1, "wrong size %u==%u", i1->stSize, dwFileSize);
  399. // HasHack = true;
  400. // PRINTME(0, "wrong size %u for %s", dwFileSize, sPathName.c_str());
  401. // return HasHack;
  402. //}
  403. //if (i1->dwCRC32 != dwCrc32)
  404. //{
  405. // PRINTME(1, "wrong crc32 %u==%u", i1->dwCRC32, dwCrc32);
  406. // HasHack = true;
  407. // PRINTME(0, "wrong crc32 %u for %s", dwCrc32, sPathName.c_str());
  408. // return HasHack;
  409. //}
  410. //PRINTME(1, "right size %u==%u", i1->stSize, dwFileSize);
  411. PRINTME(1, "right crc32 %u==%u", i1->dwCRC32, dwCrc32);
  412. isMilesFound = true;
  413. break;
  414. }
  415. }
  416. // only mss32.dll is checked, and there's no need to check the others
  417. if (!isMilesFound && isMilesUnique)
  418. {
  419. PRINTME(1, "not found %s", sName.c_str());
  420. HasHack = true;
  421. PRINTME(0, "ambiguous file for %s", sPathName.c_str());
  422. return HasHack;
  423. }
  424. PRINTME(1, "skipping file(%s) hack(%u) found(%u) uni(%u)", sName.c_str(), HasHack, isMilesFound, isMilesUnique);
  425. }
  426. }
  427.  
  428. } while (FindNextFile(h, &f));
  429. FindClose(h);
  430. return HasHack;
  431. }
  432.  
  433. bool __CheckMilesFiles()
  434. {
  435. PRINTME(1, "__CheckMilesFiles processing . and .\\miles");
  436. if (checkMilesDir(".") || checkMilesDir(".\\miles"))
  437. return false;
  438. return true;
  439. }
  440. #endif
  441.  
  442. char gs_szErrorString[512] = "";
  443.  
  444. void ApplicationSetErrorString(const char* szErrorString)
  445. {
  446. strcpy(gs_szErrorString, szErrorString);
  447. }
  448.  
  449. bool CheckPythonLibraryFilenames()
  450. {
  451. for (int i = 0; *sc_apszPythonLibraryFilenames[i] != '\n'; ++i)
  452. {
  453. std::string stFilename = "lib\\";
  454. stFilename += sc_apszPythonLibraryFilenames[i];
  455.  
  456. if (_access(stFilename.c_str(), 0) != 0)
  457. {
  458. return false;
  459. }
  460.  
  461. MoveFile(stFilename.c_str(), stFilename.c_str());
  462. }
  463.  
  464. return true;
  465. }
  466.  
  467. struct ApplicationStringTable
  468. {
  469. HINSTANCE m_hInstance;
  470. std::map<DWORD, std::string> m_kMap_dwID_stLocale;
  471. } gs_kAppStrTable;
  472.  
  473. void ApplicationStringTable_Initialize(HINSTANCE hInstance)
  474. {
  475. gs_kAppStrTable.m_hInstance=hInstance;
  476. }
  477.  
  478. const std::string& ApplicationStringTable_GetString(DWORD dwID, LPCSTR szKey)
  479. {
  480. char szBuffer[512];
  481. char szIniFileName[256];
  482. char szLocale[256];
  483.  
  484. ::GetCurrentDirectory(sizeof(szIniFileName), szIniFileName);
  485. if(szIniFileName[lstrlen(szIniFileName)-1] != '\\')
  486. strcat(szIniFileName, "\\");
  487. strcat(szIniFileName, "metin2client.dat");
  488.  
  489. strcpy(szLocale, LocaleService_GetLocalePath());
  490. if(strnicmp(szLocale, "locale/", strlen("locale/")) == 0)
  491. strcpy(szLocale, LocaleService_GetLocalePath() + strlen("locale/"));
  492. ::GetPrivateProfileString(szLocale, szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
  493. if(szBuffer[0] == '\0')
  494. LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
  495. if(szBuffer[0] == '\0')
  496. ::GetPrivateProfileString("en", szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
  497. if(szBuffer[0] == '\0')
  498. strcpy(szBuffer, szKey);
  499.  
  500. std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
  501. rstLocale=szBuffer;
  502.  
  503. return rstLocale;
  504. }
  505.  
  506. const std::string& ApplicationStringTable_GetString(DWORD dwID)
  507. {
  508. char szBuffer[512];
  509.  
  510. LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
  511. std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
  512. rstLocale=szBuffer;
  513.  
  514. return rstLocale;
  515. }
  516.  
  517. const char* ApplicationStringTable_GetStringz(DWORD dwID, LPCSTR szKey)
  518. {
  519. return ApplicationStringTable_GetString(dwID, szKey).c_str();
  520. }
  521.  
  522. const char* ApplicationStringTable_GetStringz(DWORD dwID)
  523. {
  524. return ApplicationStringTable_GetString(dwID).c_str();
  525. }
  526.  
  527. ////////////////////////////////////////////
  528.  
  529. int Setup(LPSTR lpCmdLine); // Internal function forward
  530.  
  531. #ifdef INDEX_FILE_FROM_C
  532. static const char * indexFiles[] =
  533. {
  534. "update1",
  535. "update2",
  536. "update3",
  537. "etc",
  538. "locale_ro",
  539. "maps_empire",
  540. "monsters",
  541. "outdoor",
  542. "PC",
  543. "pc2",
  544. "Property",
  545. "resource",
  546. "root",
  547. "season1",
  548. "\n",
  549. };
  550. #endif
  551.  
  552. bool PackInitialize(const char * c_pszFolder)
  553. {
  554. NANOBEGIN
  555. string block_folder;
  556.  
  557. block_folder == "D:\\ymir work";
  558.  
  559. struct stat st;
  560. if( stat( "D:\\ymir work", & st ) == 0 )
  561. {
  562. LogBoxf("Something is wrong delete the file from D (ymir work)");
  563. return true;
  564. }
  565.  
  566. std::string stFolder(c_pszFolder);
  567. stFolder += "/";
  568.  
  569. #ifndef INDEX_FILE_FROM_C
  570. std::string stFileName(stFolder);
  571. stFileName += "root.eix";
  572.  
  573. CMappedFile file;
  574. LPCVOID pvData;
  575.  
  576. if (!file.Create(stFileName.c_str(), &pvData, 0, 0))
  577. {
  578. LogBoxf("FATAL ERROR! File not exist: %s", stFileName.c_str());
  579. TraceError("FATAL ERROR! File not exist: %s", stFileName.c_str());
  580. return true;
  581. }
  582.  
  583. CMemoryTextFileLoader TextLoader;
  584. TextLoader.Bind(file.Size(), pvData);
  585. #endif
  586. bool bPackFirst = TRUE;
  587.  
  588. #ifndef INDEX_FILE_FROM_C
  589. const std::string& strPackType = TextLoader.GetLineString(0);
  590.  
  591. if (strPackType.compare("FILE") && strPackType.compare("PACK") && strPackType.compare("THOR2_PATCH_FILES"))
  592. {
  593. TraceError("Pack/Index has invalid syntax. First line must be 'PACK' or 'FILE' or 'THOR2_PATCH_FILES'");
  594. return false;
  595. }
  596. #endif
  597.  
  598. #ifdef NDEBUG // @warme601 _DISTRIBUTE -> NDEBUG
  599. Tracef("Note: PackFirst mode enabled. [pack]\n");
  600.  
  601. //if (0 == strPackType.compare("FILE"))
  602. //{
  603. // bPackFirst = FALSE;
  604. // Tracef("알림: 파일 모드입니다.\n");
  605. //}
  606. //else
  607. //{
  608. // Tracef("알림: 팩 모드입니다.\n");
  609. //}
  610. #else
  611. bPackFirst = FALSE;
  612. Tracef("Note: PackFirst mode not enabled. [file]\n");
  613. #endif
  614.  
  615. CTextFileLoader::SetCacheMode();
  616. #if defined(USE_RELATIVE_PATH)
  617. CEterPackManager::Instance().SetRelativePathMode();
  618. #endif
  619. CEterPackManager::Instance().SetCacheMode();
  620. CEterPackManager::Instance().SetSearchMode(bPackFirst);
  621.  
  622. CSoundData::SetPackMode(); // Miles 파일 콜백을 셋팅
  623.  
  624. FILE *protect;
  625. std::string strPackName;
  626. std::string filename = "";
  627. char new_key = 'Z';
  628. int long long key_vegas = '@#$!';
  629.  
  630. for (int i = 0; *indexFiles[i] != '\n'; ++i)
  631. {
  632. const std::string & c_rstName = indexFiles[i];
  633. const std::string & c_rstFolder = indexFiles[i];
  634.  
  635. strPackName = stFolder + c_rstName;
  636.  
  637. filename.append(strPackName);
  638. filename.append(".eix");
  639.  
  640. if (strcmp(c_rstName.c_str(), "property"))
  641. {
  642. protect = fopen(filename.c_str(), "r+");
  643. if (protect) {
  644. fseek(protect, 3, SEEK_SET);
  645. fwrite(&new_key, 1, 1, protect);
  646. fclose(protect); }
  647. }
  648. CEterPackManager::Instance().RegisterPack(strPackName.c_str(), c_rstFolder.c_str());
  649.  
  650. if (strcmp(c_rstName.c_str(), "property") != 0)
  651. {
  652. protect = fopen(filename.c_str(), "r+");
  653. if (protect) {
  654. fseek(protect, 3, SEEK_SET);
  655. fwrite(&key_vegas, 1, 1, protect);
  656. fclose(protect);
  657. }
  658. }
  659. filename = "";
  660. }
  661.  
  662. protect = fopen("pack/root.eix", "r+");
  663. if (protect) {
  664. fseek(protect, 3, SEEK_SET);
  665. fwrite(&new_key, 1, 1, protect);
  666. fclose(protect);
  667. }
  668.  
  669. CEterPackManager::Instance().RegisterRootPack((stFolder + std::string("root")).c_str());
  670.  
  671. protect = fopen("pack/root.eix", "r+");
  672. if (protect) {
  673. fseek(protect, 3, SEEK_SET);
  674. fwrite(&key_vegas, 1, 1, protect);
  675. fclose(protect);
  676. }
  677. NANOEND
  678. return true;
  679. }
  680.  
  681. bool RunMainScript(CPythonLauncher& pyLauncher, const char* lpCmdLine)
  682. {
  683. initpack();
  684. initdbg();
  685. initime();
  686. initgrp();
  687. initgrpImage();
  688. initgrpText();
  689. initwndMgr();
  690. /////////////////////////////////////////////
  691. initudp();
  692. initapp();
  693. initsystemSetting();
  694. initchr();
  695. initchrmgr();
  696. initPlayer();
  697. initItem();
  698. initNonPlayer();
  699. initTrade();
  700. initChat();
  701. initTextTail();
  702. initnet();
  703. initMiniMap();
  704. initProfiler();
  705. initEvent();
  706. initeffect();
  707. initfly();
  708. initsnd();
  709. initeventmgr();
  710. initshop();
  711. initskill();
  712. initquest();
  713. initBackground();
  714. initMessenger();
  715. #ifdef ENABLE_CHANGELOOK_SYSTEM
  716. initChangeLook();
  717. #endif
  718. initsafebox();
  719. initguild();
  720. initServerStateChecker();
  721. #ifdef __USE_CYTHON__
  722. // don't add this line if you're implementing cython via .pyd:
  723. // initrootlibManager();
  724. #endif
  725. #ifdef __USE_EXTRA_CYTHON__
  726. // don't add this line if you're implementing cython via .pyd:
  727. // inituiscriptlibManager();
  728. #endif
  729.  
  730. NANOBEGIN
  731.  
  732. PyObject * builtins = PyImport_ImportModule("__builtin__");
  733. #ifdef NDEBUG // @warme601 _DISTRIBUTE -> NDEBUG
  734. PyModule_AddIntConstant(builtins, "__DEBUG__", 1);
  735. #else
  736. PyModule_AddIntConstant(builtins, "__DEBUG__", 0);
  737. #endif
  738. #ifdef __USE_CYTHON__
  739. PyModule_AddIntConstant(builtins, "__USE_CYTHON__", 1);
  740. #else
  741. PyModule_AddIntConstant(builtins, "__USE_CYTHON__", 0);
  742. #endif
  743. #ifdef __USE_EXTRA_CYTHON__
  744. PyModule_AddIntConstant(builtins, "__USE_EXTRA_CYTHON__", 1);
  745. #else
  746. PyModule_AddIntConstant(builtins, "__USE_EXTRA_CYTHON__", 0);
  747. #endif
  748.  
  749. // RegisterCommandLine
  750. {
  751. std::string stRegisterCmdLine;
  752.  
  753. const char * loginMark = "-cs";
  754. const char * loginMark_NonEncode = "-ncs";
  755. const char * seperator = " ";
  756.  
  757. std::string stCmdLine;
  758. const int CmdSize = 3;
  759. vector<std::string> stVec;
  760. SplitLine(lpCmdLine,seperator,&stVec);
  761. if (CmdSize == stVec.size() && stVec[0]==loginMark)
  762. {
  763. char buf[MAX_PATH]; //TODO 아래 함수 string 형태로 수정
  764. base64_decode(stVec[2].c_str(),buf);
  765. stVec[2] = buf;
  766. string_join(seperator,stVec,&stCmdLine);
  767. }
  768. else if (CmdSize <= stVec.size() && stVec[0]==loginMark_NonEncode)
  769. {
  770. stVec[0] = loginMark;
  771. string_join(" ",stVec,&stCmdLine);
  772. }
  773. else
  774. stCmdLine = lpCmdLine;
  775.  
  776. PyModule_AddStringConstant(builtins, "__COMMAND_LINE__", stCmdLine.c_str());
  777. }
  778. {
  779. vector<std::string> stVec;
  780. SplitLine(lpCmdLine," " ,&stVec);
  781.  
  782. if (stVec.size() != 0 && "--pause-before-create-window" == stVec[0])
  783. {
  784. #ifdef XTRAP_CLIENT_ENABLE
  785. if (!XTrap_CheckInit())
  786. return false;
  787. #endif
  788. system("pause");
  789. }
  790. #ifdef ENABLE_DAEMONPROTECTION
  791. DWORD dwCrc32, dwSize;
  792. //if (!((dwCrc32 = GetFileCRC32(DPDLL_FILENAME))==DPDLL_CRC32))
  793. //{
  794. // TraceError("dpdll wrong crc32 %d", dwCrc32);
  795. // return false;
  796. //}
  797. //if (!((dwSize = GetFileSize(DPDLL_FILENAME))==DPDLL_FILESIZE))
  798. //{
  799. // TraceError("dpdll wrong size %d", dwSize);
  800. // return false;
  801. //}
  802. if (!LoadLibraryA(DPDLL_FILENAME))
  803. {
  804. TraceError("dpdll not loaded");
  805. return false;
  806. }
  807. #endif
  808.  
  809. #ifdef __USE_CYTHON__
  810. if (!pyLauncher.RunLine("import rootlib\nrootlib.moduleImport('system')"))
  811. #else
  812. if (!pyLauncher.RunFile("system.py"))
  813. #endif
  814. {
  815. TraceError("RunMain Error");
  816. return false;
  817. }
  818. }
  819.  
  820. NANOEND
  821. return true;
  822. }
  823.  
  824. bool Main(HINSTANCE hInstance, LPSTR lpCmdLine)
  825. {
  826. #ifdef LOCALE_SERVICE_YMIR
  827. extern bool g_isScreenShotKey;
  828. g_isScreenShotKey = true;
  829. #endif
  830.  
  831. DWORD dwRandSeed=time(NULL)+DWORD(GetCurrentProcess());
  832. srandom(dwRandSeed);
  833. srand(random());
  834.  
  835. SetLogLevel(1);
  836.  
  837. #ifdef LOCALE_SERVICE_VIETNAM_MILD
  838. extern BOOL USE_VIETNAM_CONVERT_WEAPON_VNUM;
  839. USE_VIETNAM_CONVERT_WEAPON_VNUM = true;
  840. #endif
  841.  
  842. if (_access("perf_game_update.txt", 0)==0)
  843. {
  844. DeleteFile("perf_game_update.txt");
  845. }
  846.  
  847. if (_access("newpatch.exe", 0)==0)
  848. {
  849. system("patchupdater.exe");
  850. return false;
  851. }
  852. #ifndef __VTUNE__
  853. ilInit();
  854. #endif
  855. if (!Setup(lpCmdLine))
  856. return false;
  857.  
  858. #ifdef _DEBUG
  859. OpenConsoleWindow();
  860. OpenLogFile(true); // true == uses syserr.txt and log.txt
  861. #else
  862. OpenLogFile(false); // false == uses syserr.txt only
  863. #endif
  864.  
  865. static CLZO lzo;
  866. static CEterPackManager EterPackManager;
  867.  
  868. if (!PackInitialize("pack"))
  869. {
  870. LogBox("Pack Initialization failed. Check log.txt file..");
  871. return false;
  872. }
  873.  
  874. if(LocaleService_LoadGlobal(hInstance))
  875. SetDefaultCodePage(LocaleService_GetCodePage());
  876.  
  877. #ifdef ENABLE_PYLIB_CHECK
  878. if (!__CheckPyLibFiles())
  879. return false;
  880. #endif
  881. #ifdef ENABLE_MILES_CHECK
  882. if (!__CheckMilesFiles())
  883. return false;
  884. #endif
  885. CPythonApplication * app = new CPythonApplication;
  886.  
  887. app->Initialize(hInstance);
  888.  
  889. bool ret=false;
  890. {
  891. CPythonLauncher pyLauncher;
  892. CPythonExceptionSender pyExceptionSender;
  893. SetExceptionSender(&pyExceptionSender);
  894.  
  895. if (pyLauncher.Create())
  896. {
  897. ret=RunMainScript(pyLauncher, lpCmdLine); //게임 실행중엔 함수가 끝나지 않는다.
  898. }
  899.  
  900. //ProcessScanner_ReleaseQuitEvent();
  901.  
  902. //게임 종료시.
  903. app->Clear();
  904.  
  905. timeEndPeriod(1);
  906. pyLauncher.Clear();
  907. }
  908.  
  909. app->Destroy();
  910. delete app;
  911.  
  912. return ret;
  913. }
  914.  
  915. HANDLE CreateMetin2GameMutex()
  916. {
  917. SECURITY_ATTRIBUTES sa;
  918. ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
  919. sa.nLength = sizeof(sa);
  920. sa.lpSecurityDescriptor = NULL;
  921. sa.bInheritHandle = FALSE;
  922.  
  923. return CreateMutex(&sa, FALSE, "Metin2GameMutex");
  924. }
  925.  
  926. void DestroyMetin2GameMutex(HANDLE hMutex)
  927. {
  928. if (hMutex)
  929. {
  930. ReleaseMutex(hMutex);
  931. hMutex = NULL;
  932. }
  933. }
  934.  
  935. void __ErrorPythonLibraryIsNotExist()
  936. {
  937. LogBoxf("FATAL ERROR!! Python Library file not exist!");
  938. }
  939.  
  940. bool __IsTimeStampOption(LPSTR lpCmdLine)
  941. {
  942. const char* TIMESTAMP = "/timestamp";
  943. return (strncmp(lpCmdLine, TIMESTAMP, strlen(TIMESTAMP))==0);
  944. }
  945.  
  946. void __PrintTimeStamp()
  947. {
  948. #ifdef _DEBUG
  949. if (__IS_TEST_SERVER_MODE__)
  950. LogBoxf("METIN2 BINARY TEST DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  951. else
  952. LogBoxf("METIN2 BINARY DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  953.  
  954. #else
  955. if (__IS_TEST_SERVER_MODE__)
  956. LogBoxf("METIN2 BINARY TEST VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  957. else
  958. LogBoxf("METIN2 BINARY DISTRIBUTE VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  959. #endif
  960. }
  961.  
  962. bool __IsLocaleOption(LPSTR lpCmdLine)
  963. {
  964. return (strcmp(lpCmdLine, "--locale") == 0);
  965. }
  966.  
  967. bool __IsLocaleVersion(LPSTR lpCmdLine)
  968. {
  969. return (strcmp(lpCmdLine, "--perforce-revision") == 0);
  970. }
  971.  
  972. #ifdef ENABLE_CHECK_FILES_MD5
  973. void CheckMD5Filenames()
  974. {
  975. MD5 md5;
  976. for (int it = 0; it < _countof(ar_szMD5FileNames); it++)
  977. {
  978. if (strcmp(md5.digestFile(ar_szMD5FileNames[it][0]), ar_szMD5FileNames[it][1]))
  979. {
  980. char szBuf[512 + 1];
  981. snprintf(szBuf, sizeof(szBuf), "Fisierul %s a fost modificat, va rugam rulati autopatcherul.", ar_szMD5FileNames[it][0]);
  982. MessageBoxA(NULL, szBuf, "#Verificare Fisiere", NULL);
  983. exit(0);
  984. }
  985. }
  986. }
  987. #endif
  988.  
  989.  
  990. #ifdef USE_OPENID
  991. //2012.07.16 김용욱
  992. //일본 OpenID 지원. 인증키 인자 추가
  993. bool __IsOpenIDAuthKeyOption(LPSTR lpCmdLine)
  994. {
  995. return (strcmp(lpCmdLine, "--openid-authkey") == 0);
  996. }
  997.  
  998. bool __IsOpenIDTestOption(LPSTR lpCmdLine) //클라이언트에서 로그인이 가능하다.
  999. {
  1000. return (strcmp(lpCmdLine, "--openid-test") == 0);
  1001. }
  1002. #endif /* USE_OPENID */
  1003.  
  1004. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  1005. {
  1006. if (strstr(lpCmdLine, "--hackshield") != 0)
  1007. return 0;
  1008.  
  1009. if (strstr(lpCmdLine, "--pula") == 0)
  1010. {
  1011. MessageBox(NULL, "Clientul tau nu este la versiunea actuala.\nTrebuie sa rulezi autopatcherul pentru a putea juca.", "Surya2", MB_ICONSTOP);
  1012. return 0;
  1013. }
  1014.  
  1015. #ifdef ENABLE_CHECK_FILES_MD5
  1016. CheckMD5Filenames();
  1017. #endif//
  1018.  
  1019. #ifdef _DEBUG
  1020. _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF );
  1021. //_CrtSetBreakAlloc( 110247 );
  1022. #endif
  1023.  
  1024. ApplicationStringTable_Initialize(hInstance);
  1025.  
  1026. LocaleService_LoadConfig("locale.cfg");
  1027. SetDefaultCodePage(LocaleService_GetCodePage());
  1028.  
  1029. #ifdef XTRAP_CLIENT_ENABLE
  1030. if (!XTrap_Init())
  1031. return 0;
  1032. #endif
  1033.  
  1034. #ifdef USE_AHNLAB_HACKSHIELD
  1035. if (!HackShield_Init())
  1036. return 0;
  1037. #endif
  1038.  
  1039. #ifdef USE_NPROTECT_GAMEGUARD
  1040. if (!GameGuard_Init())
  1041. return 0;
  1042. #endif
  1043.  
  1044. //#if defined(CHECK_LATEST_DATA_FILES)
  1045. // if (!CheckLatestFiles())
  1046. // return 0;
  1047. //#endif
  1048. //
  1049. bool bQuit = false;
  1050. bool bAuthKeyChecked = false; //OpenID 버전에서 인증키가 들어왔는지 알기 위한 인자.
  1051. int nArgc = 0;
  1052. PCHAR* szArgv = CommandLineToArgv( lpCmdLine, &nArgc );
  1053.  
  1054. for( int i=0; i < nArgc; i++ ) {
  1055. if(szArgv[i] == 0)
  1056. continue;
  1057. if (__IsLocaleVersion(szArgv[i])) // #0000829: [M2EU] 버전 파일이 항상 생기지 않도록 수정
  1058. {
  1059. char szModuleName[MAX_PATH];
  1060. char szVersionPath[MAX_PATH];
  1061. GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
  1062. sprintf(szVersionPath, "%s.version", szModuleName);
  1063. FILE* fp = fopen(szVersionPath, "wt");
  1064. if (fp)
  1065. {
  1066. extern int METIN2_GET_VERSION();
  1067. fprintf(fp, "r%d\n", METIN2_GET_VERSION());
  1068. fclose(fp);
  1069. }
  1070. bQuit = true;
  1071. } else if (__IsLocaleOption(szArgv[i]))
  1072. {
  1073. FILE* fp=fopen("locale.txt", "wt");
  1074. fprintf(fp, "service[%s] code_page[%d]",
  1075. LocaleService_GetName(), LocaleService_GetCodePage());
  1076. fclose(fp);
  1077. bQuit = true;
  1078. } else if (__IsTimeStampOption(szArgv[i]))
  1079. {
  1080. __PrintTimeStamp();
  1081. bQuit = true;
  1082. } else if ((strcmp(szArgv[i], "--force-set-locale") == 0))
  1083. {
  1084. // locale 설정엔 인자가 두 개 더 필요함 (로케일 명칭, 데이터 경로)
  1085. if (nArgc <= i + 2)
  1086. {
  1087. MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1088. goto Clean;
  1089. }
  1090.  
  1091. const char* localeName = szArgv[++i];
  1092. const char* localePath = szArgv[++i];
  1093.  
  1094. LocaleService_ForceSetLocale(localeName, localePath);
  1095. }
  1096. #ifdef USE_OPENID
  1097. else if (__IsOpenIDAuthKeyOption(szArgv[i])) //2012.07.16 OpenID : 김용욱
  1098. {
  1099. // 인증키 설정엔 인자가 한 개 더 필요함 (인증키)
  1100. if (nArgc <= i + 1)
  1101. {
  1102. MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1103. goto Clean;
  1104. }
  1105.  
  1106. const char* authKey = szArgv[++i];
  1107.  
  1108. //ongoing (2012.07.16)
  1109. //인증키 저장하는 부분
  1110. LocaleService_SetOpenIDAuthKey(authKey);
  1111.  
  1112. bAuthKeyChecked = true;
  1113. }
  1114. else if (__IsOpenIDTestOption(szArgv[i]))
  1115. {
  1116. openid_test = 1;
  1117.  
  1118. }
  1119. #endif /* USE_OPENID */
  1120. }
  1121.  
  1122. #ifdef USE_OPENID
  1123. //OpenID
  1124. //OpenID 클라이언트의 경우인증키를 받아오지 않을 경우 (웹을 제외하고 실행 시) 클라이언트 종료.
  1125.  
  1126. if (false == bAuthKeyChecked && !openid_test)
  1127. {
  1128. MessageBox(NULL, "Invalid execution", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1129. goto Clean;
  1130. }
  1131. #endif /* USE_OPENID */
  1132.  
  1133.  
  1134. if(bQuit)
  1135. goto Clean;
  1136.  
  1137. #if defined(NEEDED_COMMAND_ARGUMENT)
  1138. // 옵션이 없으면 비정상 실행으로 간주, 프로그램 종료
  1139. if (strstr(lpCmdLine, NEEDED_COMMAND_ARGUMENT) == 0) {
  1140. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1141. goto Clean;
  1142. }
  1143. #endif
  1144.  
  1145. #if defined(NEEDED_COMMAND_CLIPBOARD)
  1146. {
  1147. CHAR szSecKey[256];
  1148. CPostIt cPostIt( "VOLUME1" );
  1149.  
  1150. if( cPostIt.Get( "SEC_KEY", szSecKey, sizeof(szSecKey) ) == FALSE ) {
  1151. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1152. goto Clean;
  1153. }
  1154. if( strstr(szSecKey, NEEDED_COMMAND_CLIPBOARD) == 0 ) {
  1155. MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1156. goto Clean;
  1157. }
  1158. cPostIt.Empty();
  1159. }
  1160. #endif
  1161.  
  1162. WebBrowser_Startup(hInstance);
  1163.  
  1164. //#ifndef ENABLE_PYLIB_CHECK
  1165. // if (!CheckPythonLibraryFilenames())
  1166. // {
  1167. // __ErrorPythonLibraryIsNotExist();
  1168. // goto Clean;
  1169. // }
  1170. //#endif
  1171.  
  1172. Main(hInstance, lpCmdLine);
  1173.  
  1174. #ifdef USE_NPROTECT_GAMEGUARD
  1175. GameGuard_NoticeMessage();
  1176. #endif
  1177.  
  1178. WebBrowser_Cleanup();
  1179.  
  1180. ::CoUninitialize();
  1181.  
  1182. if(gs_szErrorString[0])
  1183. MessageBox(NULL, gs_szErrorString, ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1184.  
  1185. Clean:
  1186. #ifdef USE_AHNLAB_HACKSHIELD
  1187. HackShield_Shutdown();
  1188. #endif
  1189. SAFE_FREE_GLOBAL(szArgv);
  1190.  
  1191. return 0;
  1192. }
  1193.  
  1194. //static void GrannyError(granny_log_message_type Type,
  1195. //granny_log_message_origin Origin,
  1196. //char const* File,
  1197. //granny_int32x Line,
  1198. //char const *Error,
  1199. //void *UserData)
  1200. //{
  1201. //TraceError("GRANNY: %s", Error);
  1202. //}
  1203.  
  1204. int Setup(LPSTR lpCmdLine)
  1205. {
  1206. /*
  1207. * 타이머 정밀도를 올린다.
  1208. */
  1209. TIMECAPS tc;
  1210. UINT wTimerRes;
  1211.  
  1212. if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
  1213. return 0;
  1214.  
  1215. wTimerRes = MINMAX(tc.wPeriodMin, 1, tc.wPeriodMax);
  1216. timeBeginPeriod(wTimerRes);
  1217.  
  1218. /*
  1219. * 그래니 에러 핸들링
  1220. */
  1221. //granny_log_callback Callback;
  1222. /// /Callback.Function = GrannyError;
  1223. // /Callback.UserData = 0;
  1224. //GrannySetLogCallback(&Callback);
  1225. return 1;
  1226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement