Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 51.07 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. #include <windowsx.h>
  8. #include <windows.h>
  9. #include <assert.h>
  10. #include <tlhelp32.h>
  11. #include <imagehlp.h>
  12. #include <psapi.h>
  13. #include <process.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <commdlg.h>
  18. #include <iostream>
  19. #include <sstream>
  20. #include <string>
  21. #include <vector>
  22. #include <stdlib.h>
  23.  
  24. #ifdef _DEBUG
  25. #include <crtdbg.h>
  26. #endif
  27.  
  28. #include "../eterPack/EterPackManager.h"
  29. #include "../eterLib/Util.h"
  30. #include "../CWebBrowser/CWebBrowser.h"
  31. #include "../eterBase/CPostIt.h"
  32.  
  33. #include "CheckLatestFiles.h"
  34.  
  35. #include "Hackshield.h"
  36. #include "NProtectGameGuard.h"
  37. #include "WiseLogicXTrap.h"
  38.  
  39. extern "C" {  
  40. extern int _fltused;  
  41. volatile int _AVOID_FLOATING_POINT_LIBRARY_BUG = _fltused;  
  42. };  
  43.  
  44. #pragma comment(linker, "/NODEFAULTLIB:libci.lib")
  45.  
  46. #pragma comment( lib, "version.lib" )
  47. #pragma comment( lib, "python27.lib" )
  48. #pragma comment( lib, "imagehlp.lib" )
  49. #pragma comment( lib, "devil.lib" )
  50. #pragma comment( lib, "granny2.lib" )
  51. #pragma comment( lib, "mss32.lib" )
  52. #pragma comment( lib, "winmm.lib" )
  53. #pragma comment( lib, "imm32.lib" )
  54. #pragma comment( lib, "oldnames.lib" )
  55. #pragma comment( lib, "SpeedTreeRT.lib" )
  56. #pragma comment( lib, "dinput8.lib" )
  57. #pragma comment( lib, "dxguid.lib" )
  58. #pragma comment( lib, "ws2_32.lib" )
  59. #pragma comment( lib, "strmiids.lib" )
  60. #pragma comment( lib, "ddraw.lib" )
  61. #pragma comment( lib, "dmoguids.lib" )
  62. #pragma comment( lib, "psapi.lib")
  63. #pragma comment( lib, "imagehlp.lib")
  64. #pragma comment( lib, "comdlg32.lib")
  65. //#pragma comment( lib, "wsock32.lib" )
  66. #include <stdlib.h>
  67. #include <cryptopp/cryptoppLibLink.h>
  68.  
  69. #define JUMP_TO_OFFSET(_BaseOffset, _TargetOffset) ((LONG)(_TargetOffset) - (LONG)(_BaseOffset) - 5)
  70. #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
  71. #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
  72. #define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005L)
  73. #define SystemHandleInformation 16
  74. //APPLICATION TITLE OF CLIENT
  75. #define APP_TITLE "METIN2" //CHANGE THIS WITH THE TITLE THAT YOU WANT (REMEMBER TO CHANGE IT IN Locale.cpp)
  76. //ARGUMENT TO START ONLY WITH PATCHER
  77. #define ARGUMENT_ENABLE 0 //TYPE 1 TO ENABLE
  78. #define ARGUMENT_STRING "__metin2__"
  79. //HACKSHIELD ERRORS LOG
  80. #define ERRORLOG_ENABLE 1 //TYPE 0 TO DISABLE
  81. //ERRORS MESSAGE
  82.  
  83. #define PACK_ERROR_TITLE "*** PACK ***"
  84. #define LIB_ERROR_TITLE "*** LIB ***"
  85. #define MILES_ERROR_TITLE "*** MILES ***"
  86. #define FILE_CORRUPTED "\nFile Name Corrupted: "
  87. #define CLIENT_ERROR "Some files are corrupted.\nI can't start the client.\nTry to update the client with the patcher or re-extract the full client."
  88. #define ERROR_HACKSHIELD_DECRYPT_CONFIG_FILE "HackShield.Config.Error.txt"
  89. #define ERROR_HACKSHIELD_DECRYPT "[HackShield] Errore while decrypting this text: "
  90. #define HACKSHIELD_MSGBOX_TITLE "Hackshield"
  91. // #define HACKSHIELD_FILE "Hackshield.Error.txt"
  92. #define HACKSHIELD_FILE "syserr.txt"
  93. #define HACKSHIELD_GENERAL_MESSAGE "[HackShield] Our system detect a file or application dangerous: "
  94. #define YMIRWORK_PATH_INJECTION_ERROR "You must delete or rename the folder 'ymir work' on the path 'D:/' to open the game correctly."
  95. #define KERNEL_MODE_ERROR "You can't launch the game in Kernel-Mode. This game can be launched only in User-Mode."
  96. #define PRODAMAGE_HACK_FOUND_ERROR "You can't use ProDamageHack, exit from the game."
  97. #define LALAKER_HACK_FOUND_ERROR "You can't use Lalaker1, exit from the game."
  98. #define M2BOB_FOUND_ERROR "You can't use M2Bob, exit from the game."
  99. #define INJECTOR_GADGET_FOUND_ERROR "You can't use InjectorGadget, exit from the game."
  100. #define BOT_EXP_FOUND_ERROR "You can't use Exp-Bot, exit from the game."
  101. #define SMARTSNIFF_FOUND_ERROR "You can't use SmartSniff, exit from the game."
  102. #define OLLYDBG_FOUND_ERROR "You can't use OllyDbg, exit from the game."
  103. #define WINDBG_FOUND_ERROR "You can't use WinDbg, exit from the game"
  104. #define PROCESS_EXPLORER_FOUND_ERROR "You can't use Process Explorer, exit from the game."
  105. #define CHEAT_ENGINE_FOUND_ERROR "You can't use Cheat Engine, exit from the game."
  106.  
  107.  
  108. bool __IS_TEST_SERVER_MODE__=false;
  109.  
  110.  
  111. int error = 0;
  112.  
  113. inline long crc(std::string Filename) {
  114.     FILE *f;
  115.     if ((f = fopen(Filename.c_str(), "rb")) == NULL) return 0;
  116.     unsigned long size;
  117.     fseek(f, 0, SEEK_END);
  118.     size = ftell(f);
  119.     fseek(f, 0, SEEK_SET);
  120.     unsigned char *File = new (std::nothrow) unsigned char[size];
  121.     fread(File, 1, size, f);
  122.     fclose(f);
  123.     unsigned long crc[256];
  124.     for (unsigned int i = 0; i <= 0xFF; i++) {
  125.         unsigned long coso = 0;
  126.         unsigned long I = i;
  127.         for (unsigned int b = 1; b<9; b++) {
  128.             if (I & 1) coso |= 1 << (8 - b);
  129.             I >>= 1;
  130.         }
  131.         crc[i] = coso << 24;
  132.         for (unsigned int c = 0; c<8; c++) crc[i] = (crc[i] << 1) ^ (crc[i] & (1 << 31) ? 0x04c11db7 : 0);
  133.         unsigned long coso2 = 0;
  134.         unsigned long Ii = crc[i];
  135.         for (unsigned int d = 1; d<33; d++) {
  136.             if (Ii & 1) coso2 |= 1 << (32 - d);
  137.             Ii >>= 1;
  138.         }
  139.         crc[i] = coso2;
  140.     }
  141.     unsigned long Crc = 0xffffffff;
  142.     for (unsigned int i = 0; i<size; i++) Crc = (Crc >> 8) ^ crc[(Crc & 0xFF) ^ File[i]];
  143.     delete[] File;
  144.     return Crc ^ 0xffffffff;
  145. }
  146.  
  147.  
  148. inline std::string FromHex(const std::string& in) {
  149.     std::string output;
  150.     if ((in.length() % 2) != 0) {
  151.         FILE *f = fopen(ERROR_HACKSHIELD_DECRYPT_CONFIG_FILE, "w");
  152.         fputs(ERROR_HACKSHIELD_DECRYPT, f);
  153.         fputs(in.c_str(), f);
  154.         fputs("\n", f);
  155.         fclose(f);
  156.         exit(-1);
  157.         return "";
  158.     }
  159.     size_t cnt = in.length() / 2;
  160.     for (size_t i = 0; cnt > i; ++i) {
  161.         unsigned long int s = 0;
  162.         std::stringstream ss;
  163.         ss << std::hex << in.substr(i * 2, 2);
  164.         ss >> s;
  165.         output.push_back(static_cast<unsigned char>(s));
  166.     }
  167.     return output;
  168. }
  169. inline std::string UltimateCipher(std::string Str) {
  170.     char Key[3] = { 'A', 'B', 'C' };
  171.     std::string Encrypted = Str;
  172.     for (unsigned int i = 0; i<Str.size(); i++) Encrypted[i] = Str[i] ^ Key[i % (sizeof(Key) / sizeof(char))];
  173.     return Encrypted;
  174. }
  175. inline std::string UltimateDecrypt(std::string MyString) {
  176.     return UltimateCipher(FromHex(MyString));
  177. }
  178.  
  179. void Pack_Error(const char *err)
  180. {
  181.     error++;
  182.     MessageBoxA(NULL, std::string(std::string(CLIENT_ERROR) + std::string(FILE_CORRUPTED) + std::string(err)).c_str(), PACK_ERROR_TITLE, NULL);
  183.     exit(0);
  184. }
  185.  
  186. void Lib_Error(const char *err)
  187. {
  188.     if (strstr(err, "copy_reg.pyc") == NULL) {
  189.         error++;
  190.         MessageBoxA(NULL, std::string(std::string(CLIENT_ERROR) + std::string(FILE_CORRUPTED) + std::string(err)).c_str(), LIB_ERROR_TITLE, NULL);
  191.         exit(0);
  192.     }
  193. }
  194.  
  195. void Miles_Error(const char *err)
  196. {
  197.     error++;
  198.     MessageBoxA(NULL, std::string(std::string(CLIENT_ERROR) + std::string(FILE_CORRUPTED) + std::string(err)).c_str(), MILES_ERROR_TITLE, NULL);
  199.     exit(0);
  200. }
  201.  
  202. void CheckPack()
  203. {
  204.     if (crc(UltimateDecrypt("2c2b2f24316c2c313072706d252e2f").c_str()) != 1817711331) Miles_Error(UltimateDecrypt("2c2b2f24316c2c313072706d252e2f").c_str()); //miles/mss32.dll
  205.     if (crc(UltimateDecrypt("2c2b2f24316c2c31302071276f2f7025").c_str()) != 1812642892) Miles_Error(UltimateDecrypt("2c2b2f24316c2c31302071276f2f7025").c_str()); //miles/mssa3d.m3d
  206.     if (crc(UltimateDecrypt("2c2b2f24316c2c3130253170256c2e7226").c_str()) != -1590370812) Miles_Error(UltimateDecrypt("2c2b2f24316c2c3130253170256c2e7226").c_str()); //miles/mssds3d.m3d
  207.     if (crc(UltimateDecrypt("2c2b2f24316c2c31302531336f242f35").c_str()) != -930147909) Miles_Error(UltimateDecrypt("2c2b2f24316c2c31302531336f242f35").c_str()); //miles/mssdsp.flt
  208.     if (crc(UltimateDecrypt("2c2b2f24316c2c3130253a746f2f7025").c_str()) != 236402185) Miles_Error(UltimateDecrypt("2c2b2f24316c2c3130253a746f2f7025").c_str()); //miles/mssdx7.m3d
  209.     if (crc(UltimateDecrypt("2c2b2f24316c2c313024233b6f2f7025").c_str()) != -1099152393) Miles_Error(UltimateDecrypt("2c2b2f24316c2c313024233b6f2f7025").c_str()); //miles/msseax.m3d
  210.     if (crc(UltimateDecrypt("2c2b2f24316c2c31302c32706f233028").c_str()) != 1219814613) Miles_Error(UltimateDecrypt("2c2b2f24316c2c31302c32706f233028").c_str()); //miles/mssmp3.asi
  211.     if (crc(UltimateDecrypt("2c2b2f24316c2c313033313b6f2f7025").c_str()) != 550946743) Miles_Error(UltimateDecrypt("2c2b2f24316c2c313033313b6f2f7025").c_str()); //miles/mssrsx.m3d
  212.     if (crc(UltimateDecrypt("2c2b2f24316c2c3130322d25356c2e7226").c_str()) != -10545928) Miles_Error(UltimateDecrypt("2c2b2f24316c2c3130322d25356c2e7226").c_str()); //miles/msssoft.m3d
  213.     if (crc(UltimateDecrypt("2c2b2f24316c2c3130372d2a22276d20312a").c_str()) != 1407967464) Miles_Error(UltimateDecrypt("2c2b2f24316c2c3130372d2a22276d20312a").c_str()); //miles/mssvoice.asi
  214. }
  215.  
  216. bool LibCheck = false; //CHECK LIB FOLDER OF THE CLIENT
  217. bool YmirWorkFolderCheck = true; //CHECK YMIR WORK PATH INJECTION ON 'D:\'
  218.  
  219. std::string WhiteList[] = {
  220.     APP_TITLE,
  221.     UltimateDecrypt("022d2e312337162b2d252d34"),
  222.     UltimateDecrypt("0d0d04"),
  223.     UltimateDecrypt("0c010a61212c2c2f222f266329232d252e2a2f2563362b2d252d34"),
  224.     UltimateDecrypt("0923202a112b28272f25626e610626352720352b2c2f"),
  225.     UltimateDecrypt("0d233a24302625620b282627242c63162b2d252d34"),
  226.     UltimateDecrypt("0e0010610d33242c040d620772066315272e31620724342a222763162b2d252d34"),
  227.     UltimateDecrypt("060d0c03180c610c2635352c3329630434262f363061112a2f2963162b2d252d34"),
  228.     UltimateDecrypt("05272520372f35620a0c07"),
  229.     UltimateDecrypt("0c110015040a0c0763140b"),
  230.     UltimateDecrypt("050b062c152a2f"),
  231.     UltimateDecrypt("0021372834260c2d35282763162b2d252d34"),
  232.     UltimateDecrypt("0c2b20332d302e243761142a3237222d62006a696313372d352b2e24620f28203120303a"),
  233.     UltimateDecrypt("06060a6a6214282c272e35"),
  234.     UltimateDecrypt("1212060406212836630f2737362d312a620637272d353163122b2d2a6214282c272e35"),
  235.     UltimateDecrypt("022d2e312d2d242c37162b2d252d34"),
  236.     UltimateDecrypt("092b2d35152d25"),
  237.     UltimateDecrypt("092b2d35152d25"),
  238.     UltimateDecrypt("122d13181d1608"),
  239.     UltimateDecrypt("101313282c3a282c1608152d25"),
  240.     UltimateDecrypt("3236223527012030"),
  241.     UltimateDecrypt("06121a1e170a"),
  242.     UltimateDecrypt("112b2d382b2d313737140b"),
  243.     UltimateDecrypt("122d14031d1608"),
  244.     UltimateDecrypt("0c000a2c27"),
  245.     UltimateDecrypt("10131434202a140b142f26"),
  246.     UltimateDecrypt("13011c080c1314161c140b"),
  247.     UltimateDecrypt("282c333436012030"),
  248.     UltimateDecrypt("1774160f0b10110b0e"),
  249.     UltimateDecrypt("160c1318170a"),
  250.     UltimateDecrypt("202b0203013031"),
  251.     UltimateDecrypt("03232a25371c080f16080f0413"),
  252.     UltimateDecrypt("03232a2537202f1d160812312e3a3a"),
  253.     UltimateDecrypt("03232a25371318012f203130"),
  254.     UltimateDecrypt("11232f2c0b2d313737140b"),
  255.     UltimateDecrypt("05041608"),
  256.     UltimateDecrypt("0a170d0d170d1e170a"),
  257.     UltimateDecrypt("122d242e371c1511051e170a"),
  258. };
  259.  
  260. typedef LONG NTSTATUS;
  261. typedef VOID *POBJECT;
  262. typedef PVOID CONNECTION_CONTEXT;
  263.  
  264. typedef struct _SYSTEM_HANDLE {
  265.     ULONG uIdProcess;
  266.     UCHAR ObjectType;
  267.     UCHAR Flags;
  268.     USHORT Handle;
  269.     POBJECT pObject;
  270.     ACCESS_MASK GrantedAccess;
  271. } SYSTEM_HANDLE, *PSYSTEM_HANDLE;
  272. typedef struct _SYSTEM_HANDLE_INFORMATION {
  273.     ULONG uCount;
  274.     SYSTEM_HANDLE Handles[1];
  275. } SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
  276. typedef struct _UNICODE_STRING {
  277.     USHORT Length;
  278.     USHORT MaximumLength;
  279.     PWSTR  Buffer;
  280. } UNICODE_STRING;
  281. typedef UNICODE_STRING *PUNICODE_STRING;
  282. typedef UNICODE_STRING *POBJECT_NAME_INFORMATION;
  283. typedef enum _OBJECT_INFORMATION_CLASS{
  284.     ObjectBasicInformation,
  285.     ObjectNameInformation,
  286.     ObjectTypeInformation,
  287.     ObjectAllTypesInformation,
  288.     ObjectHandleInformation
  289. } OBJECT_INFORMATION_CLASS;
  290. typedef UNICODE_STRING OBJECT_NAME_INFORMATION;
  291. typedef enum _THREAD_INFORMATION_CLASS2 {
  292.     ThreadBasicInformation,
  293.     ThreadTimes,
  294.     ThreadPriority,
  295.     ThreadBasePriority,
  296.     ThreadAffinityMask,
  297.     ThreadImpersonationToken,
  298.     ThreadDescriptorTableEntry,
  299.     ThreadEnableAlignmentFaultFixup,
  300.     ThreadEventPair,
  301.     ThreadQuerySetWin32StartAddress,
  302.     ThreadZeroTlsCell,
  303.     ThreadPerformanceCount,
  304.     ThreadAmILastThread,
  305.     ThreadIdealProcessor,
  306.     ThreadPriorityBoost,
  307.     ThreadSetTlsArrayAddress,
  308.     ThreadIsIoPending,
  309.     ThreadHideFromDebugger
  310. } THREAD_INFORMATION_CLASS2, *PTHREAD_INFORMATION_CLASS2;
  311.  
  312. void __fastcall Frankie_Hook(PVOID TargetFunction, PVOID Trampoline, PVOID DetouredFunction, DWORD CP_SIZE);
  313. typedef const UNICODE_STRING *PCUNICODE_STRING;
  314. typedef int (WINAPI *WINSTATERMINATEPROC)(HANDLE hServer, DWORD dwProcessId, UINT uExitCode);
  315. typedef NTSTATUS(WINAPI *NtQueryInformationThreadT)(HANDLE, ULONG, PVOID, ULONG, PULONG);
  316. typedef NTSTATUS(WINAPI *tNTQSI)(DWORD SystemInformationClass, PVOID SystemInformation, DWORD SystemInformationLength, PDWORD ReturnLength);
  317. typedef NTSTATUS(WINAPI *tNTQO)(HANDLE ObjectHandle, OBJECT_INFORMATION_CLASS ObjectInformationClass, PVOID ObjectInformation, DWORD Length, PDWORD ResultLength);
  318. void WINAPI NewDebugRemoteBreakin(void);
  319. void WINAPI CheckThread(void);
  320.  
  321. PVOID pLoadLibraryA;
  322. PVOID pLoadLibraryW;
  323. PVOID pLdrLoadDll;
  324. PVOID pHookLdrLoadDll;
  325. HMODULE hKernel32;
  326. HMODULE hNtdll;
  327. HMODULE hWinsta;
  328. HANDLE WindowThread = NULL;
  329. HANDLE GuardHandle1 = NULL;
  330. HANDLE GuardHandle2 = NULL;
  331. extern bool BobFound = false;
  332.  
  333. inline void Anti_Debugger()
  334. {
  335.     DWORD oldProtect;
  336.     HMODULE hNtdll = GetModuleHandle(UltimateDecrypt("2f36272d2e6d252e2f").c_str());
  337.     PVOID NewDebuggerRemoteBreakin = NewDebugRemoteBreakin;
  338.     BYTE Buffer[5] = { 0xE9, 0x00, 0x00, 0x00, 0x00 };
  339.     PVOID DebugRemoteBreakin = GetProcAddress(hNtdll, UltimateDecrypt("052024142b11242f2c3527013327222a2b2d").c_str());
  340.     if (!DebugRemoteBreakin) { exit(0); return; }
  341.     else{
  342.         *(LONG*)(Buffer + 1) = JUMP_TO_OFFSET(DebugRemoteBreakin, NewDebuggerRemoteBreakin);
  343.         VirtualProtect(DebugRemoteBreakin, 5, PAGE_EXECUTE_READWRITE, &oldProtect);
  344.         RtlMoveMemory(DebugRemoteBreakin, Buffer, 5);
  345.         VirtualProtect(DebugRemoteBreakin, 5, oldProtect, &oldProtect);
  346.     }
  347. }
  348. void WINAPI NewDebugRemoteBreakin(void)
  349. {
  350.     hWinsta = LoadLibraryA(UltimateDecrypt("362b2d3236226f262f2d").c_str());
  351.     WINSTATERMINATEPROC WinStationTerminateProcess = (WINSTATERMINATEPROC)GetProcAddress(hWinsta, UltimateDecrypt("162b2d123622352b2c2f1626332f2a2f23372412312e21263231").c_str());
  352.     WinStationTerminateProcess(NULL, GetCurrentProcessId(), DBG_TERMINATE_PROCESS);
  353.     ExitProcess(DBG_TERMINATE_PROCESS);
  354. }
  355. __declspec(naked) NTSTATUS HookLdrLoadDll()
  356. {
  357.     __asm
  358.     {
  359.         PUSHAD
  360.             CALL CheckThread
  361.             POPAD
  362.             JMP pHookLdrLoadDll
  363.     }
  364. }
  365. void __fastcall Frankie_Hook(PVOID TargetFunction, PVOID Trampoline, PVOID DetouredFunction, DWORD CP_SIZE)
  366. {
  367.     DWORD OldProtect;
  368.     VirtualProtect(TargetFunction, CP_SIZE, PAGE_EXECUTE_READWRITE, &OldProtect);
  369.     RtlMoveMemory(Trampoline, TargetFunction, CP_SIZE);
  370.     LPBYTE JmpOffset = (LPBYTE)Trampoline + CP_SIZE;
  371.     *JmpOffset = (BYTE)0xE9;
  372.     *(PLONG)(JmpOffset + 1) = JUMP_TO_OFFSET(JmpOffset, (LPBYTE)TargetFunction + CP_SIZE);
  373.     JmpOffset = (LPBYTE)TargetFunction;
  374.     *JmpOffset = (BYTE)0xE9;
  375.     *(PLONG)(JmpOffset + 1) = JUMP_TO_OFFSET(JmpOffset, DetouredFunction);
  376.     VirtualProtect(TargetFunction, CP_SIZE, OldProtect, &OldProtect);
  377. }
  378. inline void CloseProcess()
  379. {
  380.     Sleep(4000);
  381.     exit(0);
  382. }
  383. inline void CloseApp(const char *Name)
  384. {
  385.     CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(CloseProcess), NULL, NULL, NULL);
  386.     MessageBoxA(NULL, Name, HACKSHIELD_MSGBOX_TITLE, NULL);
  387.     exit(0);
  388. }
  389. void WINAPI CheckThread()
  390. {
  391.     PVOID addr;
  392.     ULONG tid = GetCurrentThreadId();
  393.     if (tid == NULL) return;
  394.     NtQueryInformationThreadT NtQueryInfThread;
  395.     NtQueryInfThread = (NtQueryInformationThreadT)GetProcAddress(hNtdll, UltimateDecrypt("0f3612342731380b2d272d312c2337282d2d152a31242327").c_str());
  396.     if (!NtQueryInfThread) return;
  397.     HANDLE h = OpenThread(THREAD_QUERY_INFORMATION, FALSE, tid);
  398.     if (!h) return;
  399.     NTSTATUS s = NtQueryInfThread(h, ThreadQuerySetWin32StartAddress, &addr, sizeof(addr), NULL);
  400.     CloseHandle(h);
  401.     if (addr == (PVOID)pLoadLibraryA || addr == (PVOID)pLoadLibraryW) ExitThread(0);
  402. }
  403. inline void Anti_DLLInjection()
  404. {
  405.     hNtdll = GetModuleHandle(UltimateDecrypt("2f36272d2e6d252e2f").c_str());
  406.     if (!hNtdll) { exit(0); return; }
  407.     hKernel32 = GetModuleHandleA(UltimateDecrypt("2a27312f272f72706d252e2f").c_str());
  408.     if (!hKernel32) { exit(0); return; }
  409.     pLoadLibraryA = GetProcAddress(hKernel32, UltimateDecrypt("0d2d22250e2a233022333b02").c_str());
  410.     if (!pLoadLibraryA) { exit(0); return; }
  411.     pLoadLibraryW = GetProcAddress(hKernel32, UltimateDecrypt("0d2d22250e2a233022333b14").c_str());
  412.     if (!pLoadLibraryW) { exit(0); return; }
  413.     pLdrLoadDll = GetProcAddress(hNtdll, UltimateDecrypt("0d26310d2d2225062f2d").c_str());
  414.     if (!pLdrLoadDll) { exit(0); return; }
  415.     pHookLdrLoadDll = VirtualAlloc(NULL, 10, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  416.     Frankie_Hook(pLdrLoadDll, pHookLdrLoadDll, HookLdrLoadDll, 5);
  417. }
  418. template <typename T>
  419. inline std::string ToString(T val)
  420. {
  421.     std::stringstream stream;
  422.     stream << val;
  423.     return stream.str();
  424. }
  425. inline void Report(std::string Application)
  426. {
  427.     if (ERRORLOG_ENABLE) {
  428.         FILE *f = fopen(HACKSHIELD_FILE, "w");
  429.         fputs(std::string(HACKSHIELD_GENERAL_MESSAGE + Application + "\n").c_str(), f);
  430.         fclose(f);
  431.     }
  432.     exit(0);
  433. }
  434. inline void ErrorPythonPathInjector()
  435. {
  436.     std::string FakeString = "D:\\ymir work\\*";
  437.     CloseApp(YMIRWORK_PATH_INJECTION_ERROR);
  438. }
  439. struct Frankie{ DWORD pid; }Pids;
  440. inline bool InWhiteList(std::string Element)
  441. {
  442.     for (int i = 0; i < sizeof(WhiteList) / sizeof(WhiteList[0]); i++) {
  443.         if (Element.length() < 2) return true;
  444.         if (Element.find(WhiteList[i]) != std::string::npos) return true;
  445.     }
  446.     return false;
  447. }
  448. BOOL CALLBACK WindowList(HWND hnd, LPARAM lParam)
  449. {
  450.     Frankie *Struct = (Frankie*)lParam;
  451.     DWORD pID;
  452.     GetWindowThreadProcessId(hnd, &pID);
  453.     if (pID == Struct->pid) {
  454.         char Win[200];
  455.         char Class[200];
  456.         GetWindowTextA(hnd, Win, 200);
  457.         GetClassNameA(hnd, Class, 200);
  458.         if (!InWhiteList(std::string(Win)) && strcmp(Class, UltimateDecrypt("352d2c2d362a31311c222e2232317073").c_str()) != 0) {
  459.             Report(std::string(Win));
  460.         }
  461.     }
  462.     return TRUE;
  463. }
  464. inline std::string GetProcessPathName(DWORD processID)
  465. {
  466.     char szProcessName[200];
  467.     HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
  468.     if (NULL != hProcess) {
  469.         HMODULE hMod;
  470.         DWORD cbNeeded;
  471.         if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
  472.             GetModuleFileNameExA(hProcess, hMod, szProcessName, 200);
  473.             return std::string(szProcessName);
  474.         }
  475.     }
  476.     CloseHandle(hProcess);
  477.     return "";
  478. }
  479. inline std::vector<std::string> split(const std::string &text, char sep) {
  480.     std::vector<std::string> tokens;
  481.     std::size_t start = 0, end = 0;
  482.     while ((end = text.find(sep, start)) != std::string::npos) {
  483.         if (end != start) {
  484.             tokens.push_back(text.substr(start, end - start));
  485.         }
  486.         start = end + 1;
  487.     }
  488.     if (end != start) {
  489.         tokens.push_back(text.substr(start));
  490.     }
  491.     return tokens;
  492. }
  493. inline bool file_exists(const std::string& name) {
  494.     if (FILE *file = fopen(name.c_str(), "r")) {
  495.         fclose(file);
  496.         return true;
  497.     }
  498.     else return false;
  499. }
  500. inline bool dirExists(const std::string& dirName_in)
  501. {
  502.     DWORD ftyp = GetFileAttributesA(dirName_in.c_str());
  503.     if (ftyp == INVALID_FILE_ATTRIBUTES)
  504.         return false;
  505.     if (ftyp & FILE_ATTRIBUTE_DIRECTORY) return true;
  506.     return false;
  507. }
  508. inline void Symbols()
  509. {
  510.     HMODULE Modules[1024];
  511.     DWORD Mod;
  512.     if (EnumProcessModules(GetCurrentProcess(), Modules, sizeof(Modules), &Mod)) {
  513.         for (unsigned int i = 0; i<Mod / sizeof(HMODULE); i++) {
  514.             char ModuleName[200];
  515.             if (GetModuleFileNameExA(GetCurrentProcess(), Modules[i], ModuleName, 200)) {
  516.                 if (GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d202603082c2a352b222d2b3924").c_str()) != NULL &&
  517.                     GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d202603072b2d202e2a3b27").c_str()) != NULL &&
  518.                     GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d362b2d252d34010b2d28362a202e2a3b27").c_str()) != NULL &&
  519.                     GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d362b2d252d3401042a2f232f283826").c_str()) != NULL &&
  520.                     GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("150f26352a2c250b2e312e262c272d352337282d2d082c37243020243237").c_str()) != NULL &&
  521.                     GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e1d1c02121325272134250b2e2d28").c_str()) != NULL &&
  522.                     GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e03270c232a2f").c_str()) != NULL &&
  523.                     GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e042c332f0e202b2d").c_str()) != NULL) {
  524.                     Report(PRODAMAGE_HACK_FOUND_ERROR);
  525.                 }
  526.             }
  527.         }
  528.     }
  529.     DWORD aProcesses[1024], cbNeeded, cProcesses;
  530.     if (EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded)) {
  531.         cProcesses = cbNeeded / sizeof(DWORD);
  532.         for (unsigned int i = 0; i<cProcesses; i++) {
  533.             if (aProcesses[i] != 0) {
  534.                 std::vector<std::string> Process = split(GetProcessPathName(aProcesses[i]), '\\');
  535.                 std::string Path;
  536.                 for (unsigned int a = 0; a < (Process.size() - 1); a++) {
  537.                     Path.append(Process[a]);
  538.                     Path.append("\\");
  539.                 }
  540.                 std::string Folder1 = Path + UltimateDecrypt("12273137273132");
  541.                 std::string Folder2 = Path + UltimateDecrypt("11302c272b2f2431");
  542.                 std::string Folder3 = Path + UltimateDecrypt("2d2d24282c6d222424");
  543.                 if (dirExists(Folder1) == true && dirExists(Folder2) == true && file_exists(Folder3) == true) Report(LALAKER_HACK_FOUND_ERROR);
  544.             }
  545.         }
  546.     }
  547.  
  548. }
  549. inline void GameGuard()
  550. {
  551. C:
  552.     if (WaitForSingleObject(WindowThread, 1000) != WAIT_TIMEOUT) exit(0);
  553.     if (WaitForSingleObject(GuardHandle1, 1000) != WAIT_TIMEOUT) exit(0);
  554.     if (WaitForSingleObject(GuardHandle2, 1000) != WAIT_TIMEOUT) exit(0);
  555.     ResumeThread(WindowThread);
  556.     ResumeThread(GuardHandle1);
  557.     ResumeThread(GuardHandle2);
  558.     Sleep(1000);
  559.     goto C;
  560. }
  561. inline void BlockYmirWork()
  562. {
  563.     if (GetSystemMetrics(SM_CLEANBOOT) != 0) CloseApp(KERNEL_MODE_ERROR);
  564.     if (YmirWorkFolderCheck) {
  565.         WIN32_FIND_DATAA Check;
  566.         std::string Path(std::string(UltimateDecrypt("05")) + std::string(UltimateDecrypt("7b1e1f")) + std::string(UltimateDecrypt("382f2a33")) + std::string(UltimateDecrypt("61352c33291f1d68")));
  567.         HANDLE check = FindFirstFileA(Path.c_str(), &Check);
  568.         if (check != INVALID_HANDLE_VALUE) {
  569.             FindClose(check);
  570.             ErrorPythonPathInjector();
  571.         }
  572.     }
  573. }
  574. inline bool CheckBotExp(){
  575.     char wname[200];
  576.     HWND w = FindWindowA(UltimateDecrypt("0037372e0a2c35292638").c_str(), NULL);
  577.     GetWindowTextA(w, wname, 200);
  578.     return file_exists(wname);
  579. }
  580. inline bool CheckInjectorGadget(){
  581.     if (FindWindowA(UltimateDecrypt("363a14282c272e350d13").c_str(), NULL)) return true; else return false;
  582. }
  583. inline void DetectFiles()
  584. {
  585. Restart:
  586.     Pids.pid = GetCurrentProcessId();
  587.     EnumWindows(WindowList, (LPARAM)&Pids);
  588.     if (BobFound) Report(M2BOB_FOUND_ERROR);
  589.     if (CheckInjectorGadget()) Report(INJECTOR_GADGET_FOUND_ERROR);
  590.     if (CheckBotExp()) Report(BOT_EXP_FOUND_ERROR);
  591.     if (FindWindowA(UltimateDecrypt("122f223336102f2b2527").c_str(), NULL)) Report(SMARTSNIFF_FOUND_ERROR);
  592.     if (FindWindowA(UltimateDecrypt("0e0e0f18060106").c_str(), NULL)) Report(OLLYDBG_FOUND_ERROR);
  593.     if (FindWindowA(UltimateDecrypt("162b2d0520240730222c27002d233032").c_str(), NULL)) Report(WINDBG_FOUND_ERROR);
  594.     if (FindWindowA(NULL, UltimateDecrypt("0a27312f272f610626352720352b35246235706c776f73637b7863123b3035272e610b272d276311302c22273032").c_str())) Report(PROCESS_EXPLORER_FOUND_ERROR);
  595.     if (FindWindowA(NULL, UltimateDecrypt("0030376b0f2c6b2c2638").c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  596.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("020a70757563720c04700c70")) + std::string(" 9.9")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  597.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.3")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  598.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.4")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  599.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.5")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  600.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.6")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  601.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.7")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  602.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.8")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  603.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.9")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  604.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.0")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  605.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.1")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  606.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.2")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  607.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.3")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  608.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.4")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  609.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.5")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  610.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.6")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  611.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.7")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  612.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.8")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  613.     if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.9")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
  614.     if (FindWindowA(NULL, UltimateDecrypt("113b0f2e232724306337736d716c71616a1338362b2e2c63736c74616463113b37292d2d61706d736b").c_str())) Report(INJECTOR_GADGET_FOUND_ERROR);
  615.     if (FindWindowA(NULL, UltimateDecrypt("043a3733272e24620a2f282622362c336235726c756f7363233b632c2330352731707172").c_str())) Report(INJECTOR_GADGET_FOUND_ERROR);
  616.     if (LibCheck) {
  617.         WIN32_FIND_DATAA Lib;
  618.         HANDLE Lis = FindFirstFileA(UltimateDecrypt("2d2b211d1e69").c_str(), &Lib);
  619.         if (!(Lib.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  620.             if (_stricmp(Lib.cFileName, UltimateDecrypt("1e1d2534363633271c1e6c333821").c_str()) != 0 &&
  621.                 _stricmp(Lib.cFileName, UltimateDecrypt("222d33381d3124256d313b20").c_str()) != 0 &&
  622.                 _stricmp(Lib.cFileName, UltimateDecrypt("353b3324316d313b20").c_str()) != 0 &&
  623.                 _stricmp(Lib.cFileName, UltimateDecrypt("2d2b2d242122222a266f323a22").c_str()) != 0 &&
  624.                 _stricmp(Lib.cFileName, UltimateDecrypt("2f363320362b6f323a22").c_str()) != 0 &&
  625.                 _stricmp(Lib.cFileName, UltimateDecrypt("2e316d313b20").c_str()) != 0 &&
  626.                 _stricmp(Lib.cFileName, UltimateDecrypt("322b37246c333821").c_str()) != 0 &&
  627.                 _stricmp(Lib.cFileName, UltimateDecrypt("323622356c333821").c_str()) != 0 &&
  628.                 _stricmp(Lib.cFileName, UltimateDecrypt("323631282c246f323a22").c_str()) != 0 &&
  629.                 _stricmp(Lib.cFileName, UltimateDecrypt("14312633062a22366d313b20").c_str()) != 0 &&
  630.                 _stricmp(Lib.cFileName, UltimateDecrypt("3530222227212021286f323a22").c_str()) != 0) {
  631.                 std::string File(Lib.cFileName);
  632.                 if (File.find(UltimateDecrypt("6f323a").c_str()) != std::string::npos || File.find(UltimateDecrypt("6f323a22").c_str()) != std::string::npos || File.find(UltimateDecrypt("6f323a25").c_str()) != std::string::npos) {
  633.                     Report(File.c_str());
  634.                 }
  635.             }
  636.         }
  637.         while (FindNextFileA(Lis, &Lib)) {
  638.             if (!(Lib.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  639.                 if (_stricmp(Lib.cFileName, UltimateDecrypt("1e1d2534363633271c1e6c333821").c_str()) != 0 &&
  640.                     _stricmp(Lib.cFileName, UltimateDecrypt("222d33381d3124256d313b20").c_str()) != 0 &&
  641.                     _stricmp(Lib.cFileName, UltimateDecrypt("353b3324316d313b20").c_str()) != 0 &&
  642.                     _stricmp(Lib.cFileName, UltimateDecrypt("2d2b2d242122222a266f323a22").c_str()) != 0 &&
  643.                     _stricmp(Lib.cFileName, UltimateDecrypt("2f363320362b6f323a22").c_str()) != 0 &&
  644.                     _stricmp(Lib.cFileName, UltimateDecrypt("2e316d313b20").c_str()) != 0 &&
  645.                     _stricmp(Lib.cFileName, UltimateDecrypt("322b37246c333821").c_str()) != 0 &&
  646.                     _stricmp(Lib.cFileName, UltimateDecrypt("323622356c333821").c_str()) != 0 &&
  647.                     _stricmp(Lib.cFileName, UltimateDecrypt("323631282c246f323a22").c_str()) != 0 &&
  648.                     _stricmp(Lib.cFileName, UltimateDecrypt("14312633062a22366d313b20").c_str()) != 0 &&
  649.                     _stricmp(Lib.cFileName, UltimateDecrypt("3530222227212021286f323a22").c_str()) != 0) {
  650.                     std::string File(Lib.cFileName);
  651.                     if (File.find(UltimateDecrypt("6f323a").c_str()) != std::string::npos || File.find(UltimateDecrypt("6f323a22").c_str()) != std::string::npos || File.find(UltimateDecrypt("6f323a25").c_str()) != std::string::npos) {
  652.                         Report(File.c_str());
  653.                     }
  654.                 }
  655.             }
  656.         }
  657.         FindClose(Lis);
  658.     }
  659.     WIN32_FIND_DATAA Miles;
  660.     HANDLE Mil = FindFirstFileA(UltimateDecrypt("2c2b2f24311f1d68").c_str(), &Miles);
  661.     if (!(Miles.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  662.         if (_stricmp(Miles.cFileName, UltimateDecrypt("2c31302071276f2f7025").c_str()) != 0
  663.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253170256c2e7226").c_str()) != 0
  664.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253a746f2f7025").c_str()) != 0
  665.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c313024233b6f2f7025").c_str()) != 0
  666.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302c32706f233028").c_str()) != 0
  667.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c313033313b6f2f7025").c_str()) != 0
  668.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130322d25356c2e7226").c_str()) != 0
  669.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130372d2a22276d20312a").c_str()) != 0
  670.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302531336f242f35").c_str()) != 0) {
  671.             std::string File(Miles.cFileName);
  672.             if (File.find(std::string(std::string(".a") + std::string("s") + std::string("i")).c_str()) != std::string::npos || File.find(std::string(std::string(".m") + std::string("3") + std::string("d")).c_str()) != std::string::npos || File.find(std::string(std::string(".f") + std::string("l") + std::string("t")).c_str()) != std::string::npos || File.find(std::string(std::string(".m") + std::string("i") + std::string("x")).c_str()) != std::string::npos) {
  673.                 Report(File.c_str());
  674.             }
  675.         }
  676.     }
  677.     while (FindNextFileA(Mil, &Miles)) {
  678.         if (!(Miles.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  679.             if (_stricmp(Miles.cFileName, UltimateDecrypt("2c31302071276f2f7025").c_str()) != 0
  680.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253170256c2e7226").c_str()) != 0
  681.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253a746f2f7025").c_str()) != 0
  682.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c313024233b6f2f7025").c_str()) != 0
  683.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302c32706f233028").c_str()) != 0
  684.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c313033313b6f2f7025").c_str()) != 0
  685.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130322d25356c2e7226").c_str()) != 0
  686.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130372d2a22276d20312a").c_str()) != 0
  687.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302531336f242f35").c_str()) != 0) {
  688.                 std::string File(Miles.cFileName);
  689.                 if (File.find(std::string(std::string(".a") + std::string("s") + std::string("i")).c_str()) != std::string::npos || File.find(std::string(std::string(".m") + std::string("3") + std::string("d")).c_str()) != std::string::npos || File.find(std::string(std::string(".f") + std::string("l") + std::string("t")).c_str()) != std::string::npos || File.find(std::string(std::string(".m") + std::string("i") + std::string("x")).c_str()) != std::string::npos) {
  690.                     Report(File.c_str());
  691.                 }
  692.             }
  693.         }
  694.     }
  695.     FindClose(Mil);
  696.     WIN32_FIND_DATAA Current;
  697.     HANDLE Cur = FindFirstFileA("*", &Current);
  698.     if (!(Current.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  699.         std::string FileC(Current.cFileName);
  700.         if (FileC.find(std::string(std::string(".a") + std::string("s") + std::string("i")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".m") + std::string("3") + std::string("d")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".f") + std::string("l") + std::string("t")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".m") + std::string("i") + std::string("x")).c_str()) != std::string::npos || FileC.compare(std::string(std::string("lo") + std::string("ginin") + std::string("fo.p") + std::string("y")).c_str()) == 0) {
  701.             Report(FileC.c_str());
  702.         }
  703.         if (FileC.find(UltimateDecrypt("6f323a").c_str()) != std::string::npos || FileC.find(UltimateDecrypt("6f323a22").c_str()) != std::string::npos || FileC.find(UltimateDecrypt("6f323a25").c_str()) != std::string::npos) {
  704.             Report(FileC.c_str());
  705.         }
  706.     }
  707.     while (FindNextFileA(Cur, &Current)) {
  708.         if (!(Current.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  709.             std::string FileC(Current.cFileName);
  710.             if (FileC.find(std::string(std::string(".a") + std::string("s") + std::string("i")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".m") + std::string("3") + std::string("d")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".f") + std::string("l") + std::string("t")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".m") + std::string("i") + std::string("x")).c_str()) != std::string::npos || FileC.compare(std::string(std::string("lo") + std::string("ginin") + std::string("fo.p") + std::string("y")).c_str()) == 0) {
  711.                 Report(FileC.c_str());
  712.             }
  713.             if (FileC.find(UltimateDecrypt("6f323a").c_str()) != std::string::npos || FileC.find(UltimateDecrypt("6f323a22").c_str()) != std::string::npos || FileC.find(UltimateDecrypt("6f323a25").c_str()) != std::string::npos) {
  714.                 Report(FileC.c_str());
  715.             }
  716.         }
  717.     }
  718.     FindClose(Cur);
  719.     BlockYmirWork();
  720.     Symbols();
  721.     Sleep(2000);
  722.     goto Restart;
  723. }
  724. extern DWORD tid1 = 0;
  725. extern DWORD tid2 = 0;
  726. extern DWORD tid3 = 0;
  727. inline void Protection()
  728. {
  729.     if (ARGUMENT_ENABLE) if (strstr(GetCommandLineA(), ARGUMENT_STRING) == NULL) exit(0);
  730.     CheckPack();
  731.     BlockYmirWork();
  732.     Anti_DLLInjection();
  733.     Anti_Debugger();
  734.     WindowThread = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(DetectFiles), NULL, NULL, &tid1);
  735.     GuardHandle1 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, &tid2);
  736.     GuardHandle2 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, &tid3);
  737. }
  738.  
  739.  
  740. extern bool SetDefaultCodePage(DWORD codePage);
  741.  
  742. #ifdef USE_OPENID
  743. extern int openid_test;
  744. #endif
  745.  
  746. static const char * sc_apszPythonLibraryFilenames[] =
  747. {
  748.     "UserDict.pyc",
  749.     "__future__.pyc",
  750.     "copy_reg.pyc",
  751.     "linecache.pyc",
  752.     "ntpath.pyc",
  753.     "os.pyc",
  754.     "site.pyc",
  755.     "stat.pyc",
  756.     "string.pyc",
  757.     "traceback.pyc",
  758.     "types.pyc",
  759.     "\n",
  760. };
  761.  
  762. char gs_szErrorString[512] = "";
  763.  
  764. void ApplicationSetErrorString(const char* szErrorString)
  765. {
  766.     strcpy(gs_szErrorString, szErrorString);
  767. }
  768.  
  769. bool CheckPythonLibraryFilenames()
  770. {
  771.     for (int i = 0; *sc_apszPythonLibraryFilenames[i] != '\n'; ++i)
  772.     {
  773.         std::string stFilename = "lib\\";
  774.         stFilename += sc_apszPythonLibraryFilenames[i];
  775.  
  776.         if (_access(stFilename.c_str(), 0) != 0)
  777.         {
  778.             return false;
  779.         }
  780.  
  781.         MoveFile(stFilename.c_str(), stFilename.c_str());
  782.     }
  783.  
  784.     return true;
  785. }
  786.  
  787. struct ApplicationStringTable
  788. {
  789.     HINSTANCE m_hInstance;
  790.     std::map<DWORD, std::string> m_kMap_dwID_stLocale;
  791. } gs_kAppStrTable;
  792.  
  793. void ApplicationStringTable_Initialize(HINSTANCE hInstance)
  794. {
  795.     gs_kAppStrTable.m_hInstance=hInstance;
  796. }
  797.  
  798. const std::string& ApplicationStringTable_GetString(DWORD dwID, LPCSTR szKey)
  799. {
  800.     char szBuffer[512];
  801.     char szIniFileName[256];
  802.     char szLocale[256];
  803.  
  804.     ::GetCurrentDirectory(sizeof(szIniFileName), szIniFileName);
  805.     if(szIniFileName[lstrlen(szIniFileName)-1] != '\\')
  806.         strcat(szIniFileName, "\\");
  807.     strcat(szIniFileName, "metin2client.dat");
  808.  
  809.     strcpy(szLocale, LocaleService_GetLocalePath());
  810.     if(strnicmp(szLocale, "locale/", strlen("locale/")) == 0)
  811.         strcpy(szLocale, LocaleService_GetLocalePath() + strlen("locale/"));
  812.     ::GetPrivateProfileString(szLocale, szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
  813.     if(szBuffer[0] == '\0')
  814.         LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
  815.     if(szBuffer[0] == '\0')
  816.         ::GetPrivateProfileString("en", szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
  817.     if(szBuffer[0] == '\0')
  818.         strcpy(szBuffer, szKey);
  819.  
  820.     std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
  821.     rstLocale=szBuffer;
  822.  
  823.     return rstLocale;
  824. }
  825.  
  826. const std::string& ApplicationStringTable_GetString(DWORD dwID)
  827. {
  828.     char szBuffer[512];
  829.  
  830.     LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
  831.     std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
  832.     rstLocale=szBuffer;
  833.  
  834.     return rstLocale;
  835. }
  836.  
  837. const char* ApplicationStringTable_GetStringz(DWORD dwID, LPCSTR szKey)
  838. {
  839.     return ApplicationStringTable_GetString(dwID, szKey).c_str();
  840. }
  841.  
  842. const char* ApplicationStringTable_GetStringz(DWORD dwID)
  843. {
  844.     return ApplicationStringTable_GetString(dwID).c_str();
  845. }
  846.  
  847. ////////////////////////////////////////////
  848.  
  849. int Setup(LPSTR lpCmdLine); // Internal function forward
  850.  
  851. bool PackInitialize(const char * c_pszFolder)
  852. {
  853.     NANOBEGIN
  854.     if (_access(c_pszFolder, 0) != 0)
  855.         return true;
  856.  
  857.     std::string stFolder(c_pszFolder);
  858.     stFolder += "/";
  859.  
  860.     std::string stFileName(stFolder);
  861.     stFileName += "Index";
  862.  
  863.     CMappedFile file;
  864.     LPCVOID pvData;
  865.  
  866.     if (!file.Create(stFileName.c_str(), &pvData, 0, 0))
  867.     {
  868.         LogBoxf("FATAL ERROR! File not exist: %s", stFileName.c_str());
  869.         TraceError("FATAL ERROR! File not exist: %s", stFileName.c_str());
  870.         return true;
  871.     }
  872.  
  873.     CMemoryTextFileLoader TextLoader;
  874.     TextLoader.Bind(file.Size(), pvData);
  875.  
  876.     bool bPackFirst = TRUE;
  877.  
  878.     const std::string& strPackType = TextLoader.GetLineString(0);
  879.  
  880.     if (strPackType.compare("FILE") && strPackType.compare("PACK"))
  881.     {
  882.         TraceError("Pack/Index has invalid syntax. First line must be 'PACK' or 'FILE'");
  883.         return false;
  884.     }
  885.  
  886. #ifdef _DISTRIBUTE
  887.     Tracef("알림: 팩 모드입니다.\n");
  888.    
  889.     //if (0 == strPackType.compare("FILE"))
  890.     //{
  891.     //  bPackFirst = FALSE;
  892.     //  Tracef("알림: 파일 모드입니다.\n");
  893.     //}
  894.     //else
  895.     //{
  896.     //  Tracef("알림: 팩 모드입니다.\n");
  897.     //}
  898. #else
  899.     bPackFirst = FALSE;
  900.     Tracef("알림: 파일 모드입니다.\n");
  901. #endif
  902.  
  903.     CTextFileLoader::SetCacheMode();
  904. #if defined(USE_RELATIVE_PATH)
  905.     CEterPackManager::Instance().SetRelativePathMode();
  906. #endif
  907.     CEterPackManager::Instance().SetCacheMode();
  908.     CEterPackManager::Instance().SetSearchMode(bPackFirst);
  909.  
  910.     CSoundData::SetPackMode(); // Miles 파일 콜백을 셋팅
  911.  
  912.     std::string strPackName, strTexCachePackName;
  913.     for (DWORD i = 1; i < TextLoader.GetLineCount() - 1; i += 2)
  914.     {
  915.         const std::string & c_rstFolder = TextLoader.GetLineString(i);
  916.         const std::string & c_rstName = TextLoader.GetLineString(i + 1);
  917.  
  918.         strPackName = stFolder + c_rstName;
  919.         strTexCachePackName = strPackName + "_texcache";
  920.  
  921.         CEterPackManager::Instance().RegisterPack(strPackName.c_str(), c_rstFolder.c_str());
  922.         CEterPackManager::Instance().RegisterPack(strTexCachePackName.c_str(), c_rstFolder.c_str());
  923.     }
  924.    
  925.     FILE* fp = fopen("root.cfg", "rt");
  926.  
  927.     char    rootName[256];
  928.     if (fp)
  929.     {      
  930.         char    line[256];         
  931.        
  932.         if (fgets(line, sizeof(line)-1, fp))
  933.         {
  934.             line[sizeof(line)-1] = '\0';
  935.             sscanf(line, "%s", rootName);
  936.  
  937.         }          
  938.         fclose(fp);
  939.     }
  940.  
  941.     CEterPackManager::Instance().RegisterRootPack((stFolder + std::string(rootName)).c_str());
  942.     NANOEND
  943.     return true;
  944. }
  945.  
  946. bool RunMainScript(CPythonLauncher& pyLauncher, const char* lpCmdLine)
  947. {
  948.     initpack();
  949.     initdbg();
  950.     initime();
  951.     initgrp();
  952.     initgrpImage();
  953.     initgrpText();
  954.     initwndMgr();
  955.     /////////////////////////////////////////////
  956.     initudp();
  957.     initapp();
  958.     initsystem();
  959.     initchr();
  960.     initchrmgr();
  961.     initPlayer();
  962.     initItem();
  963.     initNonPlayer();
  964.     initTrade();
  965.     initChat();
  966.     initTextTail();
  967.     initnet();
  968.     initMiniMap();
  969.     initProfiler();
  970.     initEvent();
  971.     initeffect();
  972.     initfly();
  973.     initsnd();
  974.     initeventmgr();
  975.     initshop();
  976.     initskill();
  977.     initskillpet();
  978.     initskillbaby();
  979.     initquest();
  980.     initBackground();
  981.     initMessenger();
  982.     initsafebox();
  983.     initguild();
  984.     initServerStateChecker();
  985.  
  986.     NANOBEGIN
  987.  
  988.     // RegisterDebugFlag
  989.     {
  990.         std::string stRegisterDebugFlag;
  991.  
  992. #ifdef _DISTRIBUTE
  993.         stRegisterDebugFlag ="__DEBUG__ = 0";
  994. #else
  995.         stRegisterDebugFlag ="__DEBUG__ = 1";
  996. #endif
  997.  
  998.         if (!pyLauncher.RunLine(stRegisterDebugFlag.c_str()))
  999.         {
  1000.             TraceError("RegisterDebugFlag Error");
  1001.             return false;
  1002.         }
  1003.     }
  1004.  
  1005.     // RegisterCommandLine
  1006.     {
  1007.         std::string stRegisterCmdLine;
  1008.  
  1009.         const char * loginMark = "-cs";
  1010.         const char * loginMark_NonEncode = "-ncs";
  1011.         const char * seperator = " ";
  1012.  
  1013.         std::string stCmdLine;
  1014.         const int CmdSize = 3;
  1015.         vector<std::string> stVec;
  1016.         SplitLine(lpCmdLine,seperator,&stVec);
  1017.         if (CmdSize == stVec.size() && stVec[0]==loginMark)
  1018.         {
  1019.             char buf[MAX_PATH]; //TODO 아래 함수 string 형태로 수정
  1020.             base64_decode(stVec[2].c_str(),buf);
  1021.             stVec[2] = buf;
  1022.             string_join(seperator,stVec,&stCmdLine);
  1023.         }
  1024.         else if (CmdSize <= stVec.size() && stVec[0]==loginMark_NonEncode)
  1025.         {
  1026.             stVec[0] = loginMark;
  1027.             string_join(" ",stVec,&stCmdLine);
  1028.         }
  1029.         else
  1030.             stCmdLine = lpCmdLine;
  1031.  
  1032.         stRegisterCmdLine ="__COMMAND_LINE__ = ";
  1033.         stRegisterCmdLine+='"';
  1034.         stRegisterCmdLine+=stCmdLine;
  1035.         stRegisterCmdLine+='"';
  1036.  
  1037.         const CHAR* c_szRegisterCmdLine=stRegisterCmdLine.c_str();
  1038.         if (!pyLauncher.RunLine(c_szRegisterCmdLine))
  1039.         {
  1040.             TraceError("RegisterCommandLine Error");
  1041.             return false;
  1042.         }
  1043.     }
  1044.     {
  1045.         vector<std::string> stVec;
  1046.         SplitLine(lpCmdLine," " ,&stVec);
  1047.  
  1048.         if (stVec.size() != 0 && "--pause-before-create-window" == stVec[0])
  1049.         {
  1050. #ifdef XTRAP_CLIENT_ENABLE
  1051.             if (!XTrap_CheckInit())
  1052.                 return false;
  1053. #endif
  1054.             system("pause");
  1055.         }
  1056.         if (!pyLauncher.RunFile("system.py"))
  1057.         {
  1058.             TraceError("RunMain Error");
  1059.             return false;
  1060.         }
  1061.     }
  1062.  
  1063.     NANOEND
  1064.     return true;
  1065. }
  1066.  
  1067. bool Main(HINSTANCE hInstance, LPSTR lpCmdLine)
  1068. {
  1069. #ifdef LOCALE_SERVICE_YMIR
  1070.     extern bool g_isScreenShotKey;
  1071.     g_isScreenShotKey = true;
  1072. #endif
  1073.  
  1074.     DWORD dwRandSeed=time(NULL)+DWORD(GetCurrentProcess());
  1075.     srandom(dwRandSeed);
  1076.     srand(random());
  1077.  
  1078.     SetLogLevel(1);
  1079.  
  1080. #ifdef LOCALE_SERVICE_VIETNAM_MILD
  1081.     extern BOOL USE_VIETNAM_CONVERT_WEAPON_VNUM;
  1082.     USE_VIETNAM_CONVERT_WEAPON_VNUM = true;
  1083. #endif
  1084.  
  1085.     if (_access("perf_game_update.txt", 0)==0)
  1086.     {
  1087.         DeleteFile("perf_game_update.txt");
  1088.     }
  1089.  
  1090.     if (_access("newpatch.exe", 0)==0)
  1091.     {      
  1092.         system("patchupdater.exe");
  1093.         return false;
  1094.     }
  1095. #ifndef __VTUNE__
  1096.     ilInit();
  1097. #endif
  1098.     if (!Setup(lpCmdLine))
  1099.         return false;
  1100.  
  1101. #ifdef _DEBUG
  1102.     OpenConsoleWindow();
  1103.     OpenLogFile(true); // true == uses syserr.txt and log.txt
  1104. #else
  1105.     OpenLogFile(true); // false == uses syserr.txt only
  1106. #endif
  1107.  
  1108.     static CLZO             lzo;
  1109.     static CEterPackManager EterPackManager;
  1110.  
  1111.     if (!PackInitialize("pack"))
  1112.     {
  1113.         LogBox("Pack Initialization failed. Check log.txt file..");
  1114.         return false;
  1115.     }
  1116.  
  1117.     if(LocaleService_LoadGlobal(hInstance))
  1118.         SetDefaultCodePage(LocaleService_GetCodePage());
  1119.  
  1120.     CPythonApplication * app = new CPythonApplication;
  1121.  
  1122.     app->Initialize(hInstance);
  1123.  
  1124.     bool ret=false;
  1125.     {
  1126.         CPythonLauncher pyLauncher;
  1127.         CPythonExceptionSender pyExceptionSender;
  1128.         SetExceptionSender(&pyExceptionSender);
  1129.  
  1130.         if (pyLauncher.Create())
  1131.         {
  1132.             ret=RunMainScript(pyLauncher, lpCmdLine);   //게임 실행중엔 함수가 끝나지 않는다.
  1133.         }
  1134.  
  1135.         //ProcessScanner_ReleaseQuitEvent();
  1136.        
  1137.         //게임 종료시.
  1138.         app->Clear();
  1139.  
  1140.         timeEndPeriod(1);
  1141.         pyLauncher.Clear();
  1142.     }
  1143.  
  1144.     app->Destroy();
  1145.     delete app;
  1146.    
  1147.     return ret;
  1148. }
  1149.  
  1150. HANDLE CreateMetin2GameMutex()
  1151. {
  1152.     SECURITY_ATTRIBUTES sa;
  1153.     ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
  1154.     sa.nLength              = sizeof(sa);
  1155.     sa.lpSecurityDescriptor = NULL;
  1156.     sa.bInheritHandle       = FALSE;
  1157.  
  1158.     return CreateMutex(&sa, FALSE, "Metin2GameMutex");
  1159. }
  1160.  
  1161. void DestroyMetin2GameMutex(HANDLE hMutex)
  1162. {
  1163.     if (hMutex)
  1164.     {
  1165.         ReleaseMutex(hMutex);
  1166.         hMutex = NULL;
  1167.     }
  1168. }
  1169.  
  1170. void __ErrorPythonLibraryIsNotExist()
  1171. {
  1172.     LogBoxf("FATAL ERROR!! Python Library file not exist!");
  1173. }
  1174.  
  1175. bool __IsTimeStampOption(LPSTR lpCmdLine)
  1176. {
  1177.     const char* TIMESTAMP = "/timestamp";
  1178.     return (strncmp(lpCmdLine, TIMESTAMP, strlen(TIMESTAMP))==0);
  1179. }
  1180.  
  1181. void __PrintTimeStamp()
  1182. {
  1183. #ifdef  _DEBUG
  1184.     if (__IS_TEST_SERVER_MODE__)
  1185.         LogBoxf("METIN2 BINARY TEST DEBUG VERSION %s  ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  1186.     else
  1187.         LogBoxf("METIN2 BINARY DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  1188.    
  1189. #else
  1190.     if (__IS_TEST_SERVER_MODE__)
  1191.         LogBoxf("METIN2 BINARY TEST VERSION %s  ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
  1192.     else
  1193.         LogBoxf("METIN2 BINARY DISTRIBUTE VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);        
  1194. #endif         
  1195. }
  1196.  
  1197. bool __IsLocaleOption(LPSTR lpCmdLine)
  1198. {
  1199.     return (strcmp(lpCmdLine, "--locale") == 0);
  1200. }
  1201.  
  1202. bool __IsLocaleVersion(LPSTR lpCmdLine)
  1203. {
  1204.     return (strcmp(lpCmdLine, "--perforce-revision") == 0);
  1205. }
  1206.  
  1207. #ifdef USE_OPENID
  1208. //2012.07.16 김용욱
  1209. //일본 OpenID 지원. 인증키 인자 추가
  1210. bool __IsOpenIDAuthKeyOption(LPSTR lpCmdLine)
  1211. {
  1212.     return (strcmp(lpCmdLine, "--openid-authkey") == 0);
  1213. }
  1214.  
  1215. bool __IsOpenIDTestOption(LPSTR lpCmdLine) //클라이언트에서 로그인이 가능하다.
  1216. {
  1217.     return (strcmp(lpCmdLine, "--openid-test") == 0);
  1218. }
  1219. #endif /* USE_OPENID */
  1220.  
  1221. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  1222. {
  1223.     if (strstr(lpCmdLine, "--hackshield") != 0)
  1224.         return 0;
  1225.  
  1226. #ifdef _DEBUG
  1227.     _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF );
  1228.     //_CrtSetBreakAlloc( 110247 );
  1229. #endif
  1230.  
  1231.     ApplicationStringTable_Initialize(hInstance);
  1232.  
  1233.     Protection();
  1234.     LocaleService_LoadConfig("locale.cfg");
  1235.     SetDefaultCodePage(LocaleService_GetCodePage());   
  1236.  
  1237. #ifdef XTRAP_CLIENT_ENABLE
  1238.     if (!XTrap_Init())
  1239.         return 0;
  1240. #endif
  1241.  
  1242. #ifdef USE_AHNLAB_HACKSHIELD
  1243.     //if (!HackShield_Init())
  1244.     //  return 0;
  1245. #endif
  1246.  
  1247. #ifdef USE_NPROTECT_GAMEGUARD
  1248.     if (!GameGuard_Init())
  1249.         return 0;
  1250. #endif
  1251.  
  1252. #if defined(CHECK_LATEST_DATA_FILES)
  1253.     if (!CheckLatestFiles())
  1254.         return 0;
  1255. #endif
  1256.  
  1257.     bool bQuit = false;
  1258.     bool bAuthKeyChecked = false;   //OpenID 버전에서 인증키가 들어왔는지 알기 위한 인자.
  1259.     int nArgc = 0;
  1260.     PCHAR* szArgv = CommandLineToArgv( lpCmdLine, &nArgc );
  1261.  
  1262.     for( int i=0; i < nArgc; i++ ) {
  1263.         if(szArgv[i] == 0)
  1264.             continue;
  1265.         if (__IsLocaleVersion(szArgv[i])) // #0000829: [M2EU] 버전 파일이 항상 생기지 않도록 수정
  1266.         {
  1267.             char szModuleName[MAX_PATH];
  1268.             char szVersionPath[MAX_PATH];
  1269.             GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
  1270.             sprintf(szVersionPath, "%s.version", szModuleName);
  1271.             FILE* fp = fopen(szVersionPath, "wt");
  1272.             if (fp)
  1273.             {
  1274.                 extern int METIN2_GET_VERSION();
  1275.                 fprintf(fp, "r%d\n", METIN2_GET_VERSION());
  1276.                 fclose(fp);
  1277.             }
  1278.             bQuit = true;
  1279.         } else if (__IsLocaleOption(szArgv[i]))
  1280.         {
  1281.             FILE* fp=fopen("locale.txt", "wt");
  1282.             fprintf(fp, "service[%s] code_page[%d]",
  1283.                 LocaleService_GetName(), LocaleService_GetCodePage());
  1284.             fclose(fp);
  1285.             bQuit = true;
  1286.         } else if (__IsTimeStampOption(szArgv[i]))
  1287.         {
  1288.             __PrintTimeStamp();
  1289.             bQuit = true;
  1290.         } else if ((strcmp(szArgv[i], "--force-set-locale") == 0))
  1291.         {
  1292.             // locale 설정엔 인자가 두 개 더 필요함 (로케일 명칭, 데이터 경로)
  1293.             if (nArgc <= i + 2)
  1294.             {
  1295.                 MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1296.                 goto Clean;
  1297.             }
  1298.  
  1299.             const char* localeName = szArgv[++i];
  1300.             const char* localePath = szArgv[++i];
  1301.  
  1302.             LocaleService_ForceSetLocale(localeName, localePath);
  1303.         }
  1304. #ifdef USE_OPENID
  1305.         else if (__IsOpenIDAuthKeyOption(szArgv[i]))    //2012.07.16 OpenID : 김용욱
  1306.         {
  1307.             // 인증키 설정엔 인자가 한 개 더 필요함 (인증키)
  1308.             if (nArgc <= i + 1)
  1309.             {
  1310.                 MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1311.                 goto Clean;
  1312.             }
  1313.  
  1314.             const char* authKey = szArgv[++i];
  1315.  
  1316.             //ongoing (2012.07.16)
  1317.             //인증키 저장하는 부분
  1318.             LocaleService_SetOpenIDAuthKey(authKey);
  1319.  
  1320.             bAuthKeyChecked = true;
  1321.         }
  1322.         else if (__IsOpenIDTestOption(szArgv[i]))
  1323.         {
  1324.             openid_test = 1;
  1325.  
  1326.         }
  1327. #endif /* USE_OPENID */
  1328.     }
  1329.  
  1330. #ifdef USE_OPENID
  1331.     //OpenID
  1332.     //OpenID 클라이언트의 경우인증키를 받아오지 않을 경우 (웹을 제외하고 실행 시) 클라이언트 종료.
  1333.    
  1334.     if (false == bAuthKeyChecked && !openid_test)
  1335.     {
  1336.         MessageBox(NULL, "Invalid execution", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1337.         goto Clean;
  1338.     }
  1339. #endif /* USE_OPENID */
  1340.  
  1341.  
  1342.     if(bQuit)
  1343.         goto Clean;
  1344.  
  1345. #if defined(NEEDED_COMMAND_ARGUMENT)
  1346.     // 옵션이 없으면 비정상 실행으로 간주, 프로그램 종료
  1347.     if (strstr(lpCmdLine, NEEDED_COMMAND_ARGUMENT) == 0) {
  1348.         MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1349.             goto Clean;
  1350.     }
  1351. #endif
  1352.  
  1353. #if defined(NEEDED_COMMAND_CLIPBOARD)
  1354.     {
  1355.         CHAR szSecKey[256];
  1356.         CPostIt cPostIt( "VOLUME1" );
  1357.  
  1358.         if( cPostIt.Get( "SEC_KEY", szSecKey, sizeof(szSecKey) ) == FALSE ) {
  1359.             MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1360.             goto Clean;
  1361.         }
  1362.         if( strstr(szSecKey, NEEDED_COMMAND_CLIPBOARD) == 0 ) {
  1363.             MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1364.             goto Clean;
  1365.         }
  1366.         cPostIt.Empty();
  1367.     }
  1368. #endif
  1369.  
  1370.     WebBrowser_Startup(hInstance);
  1371.  
  1372.     if (!CheckPythonLibraryFilenames())
  1373.     {
  1374.         __ErrorPythonLibraryIsNotExist();
  1375.         goto Clean;
  1376.     }
  1377.  
  1378.     Main(hInstance, lpCmdLine);
  1379.  
  1380. #ifdef USE_NPROTECT_GAMEGUARD
  1381.     GameGuard_NoticeMessage();
  1382. #endif
  1383.  
  1384.     WebBrowser_Cleanup();
  1385.  
  1386.     ::CoUninitialize();
  1387.  
  1388.     if(gs_szErrorString[0])
  1389.         MessageBox(NULL, gs_szErrorString, ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
  1390.  
  1391. Clean:
  1392. #ifdef USE_AHNLAB_HACKSHIELD
  1393.     HackShield_Shutdown();
  1394. #endif
  1395.     SAFE_FREE_GLOBAL(szArgv);
  1396.  
  1397.     return 0;
  1398. }
  1399.  
  1400. static void GrannyError(granny_log_message_type Type,
  1401.             granny_log_message_origin Origin,
  1402.             char const*  File,
  1403.             granny_int32x Line,
  1404.             char const * Error,
  1405.             void * UserData)
  1406. {
  1407.     Tracef("GRANNY: %s\n", Error);
  1408. }
  1409.  
  1410. int Setup(LPSTR lpCmdLine)
  1411. {
  1412.     /*
  1413.      *  타이머 정밀도를 올린다.
  1414.      */
  1415.     TIMECAPS tc;
  1416.     UINT wTimerRes;
  1417.  
  1418.     if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
  1419.         return 0;
  1420.  
  1421.     wTimerRes = MINMAX(tc.wPeriodMin, 1, tc.wPeriodMax);
  1422.     timeBeginPeriod(wTimerRes);
  1423.  
  1424.     /*
  1425.      *  그래니 에러 핸들링
  1426.      */
  1427.  
  1428.     granny_log_callback Callback;
  1429.     Callback.Function = GrannyError;
  1430.     Callback.UserData = 0;
  1431.     GrannySetLogCallback(&Callback);
  1432.     return 1;
  1433. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement