Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "StdAfx.h"
- #include "PythonApplication.h"
- #include "ProcessScanner.h"
- #include "PythonExceptionSender.h"
- #include "resource.h"
- #include "Version.h"
- #include <windowsx.h>
- #include <windows.h>
- #include <assert.h>
- #include <tlhelp32.h>
- #include <imagehlp.h>
- #include <psapi.h>
- #include <process.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <commdlg.h>
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <stdlib.h>
- #ifdef _DEBUG
- #include <crtdbg.h>
- #endif
- #include "../eterPack/EterPackManager.h"
- #include "../eterLib/Util.h"
- #include "../CWebBrowser/CWebBrowser.h"
- #include "../eterBase/CPostIt.h"
- #include "CheckLatestFiles.h"
- #include "Hackshield.h"
- #include "NProtectGameGuard.h"
- #include "WiseLogicXTrap.h"
- extern "C" {
- extern int _fltused;
- volatile int _AVOID_FLOATING_POINT_LIBRARY_BUG = _fltused;
- };
- #pragma comment(linker, "/NODEFAULTLIB:libci.lib")
- #pragma comment( lib, "version.lib" )
- #pragma comment( lib, "python27.lib" )
- #pragma comment( lib, "imagehlp.lib" )
- #pragma comment( lib, "devil.lib" )
- #pragma comment( lib, "granny2.lib" )
- #pragma comment( lib, "mss32.lib" )
- #pragma comment( lib, "winmm.lib" )
- #pragma comment( lib, "imm32.lib" )
- #pragma comment( lib, "oldnames.lib" )
- #pragma comment( lib, "SpeedTreeRT.lib" )
- #pragma comment( lib, "dinput8.lib" )
- #pragma comment( lib, "dxguid.lib" )
- #pragma comment( lib, "ws2_32.lib" )
- #pragma comment( lib, "strmiids.lib" )
- #pragma comment( lib, "ddraw.lib" )
- #pragma comment( lib, "dmoguids.lib" )
- #pragma comment( lib, "psapi.lib")
- #pragma comment( lib, "imagehlp.lib")
- #pragma comment( lib, "comdlg32.lib")
- //#pragma comment( lib, "wsock32.lib" )
- #include <stdlib.h>
- #include <cryptopp/cryptoppLibLink.h>
- #define JUMP_TO_OFFSET(_BaseOffset, _TargetOffset) ((LONG)(_TargetOffset) - (LONG)(_BaseOffset) - 5)
- #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
- #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
- #define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005L)
- #define SystemHandleInformation 16
- //APPLICATION TITLE OF CLIENT
- #define APP_TITLE "METIN2" //CHANGE THIS WITH THE TITLE THAT YOU WANT (REMEMBER TO CHANGE IT IN Locale.cpp)
- //ARGUMENT TO START ONLY WITH PATCHER
- #define ARGUMENT_ENABLE 0 //TYPE 1 TO ENABLE
- #define ARGUMENT_STRING "__metin2__"
- //HACKSHIELD ERRORS LOG
- #define ERRORLOG_ENABLE 1 //TYPE 0 TO DISABLE
- //ERRORS MESSAGE
- #define PACK_ERROR_TITLE "*** PACK ***"
- #define LIB_ERROR_TITLE "*** LIB ***"
- #define MILES_ERROR_TITLE "*** MILES ***"
- #define FILE_CORRUPTED "\nFile Name Corrupted: "
- #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."
- #define ERROR_HACKSHIELD_DECRYPT_CONFIG_FILE "HackShield.Config.Error.txt"
- #define ERROR_HACKSHIELD_DECRYPT "[HackShield] Errore while decrypting this text: "
- #define HACKSHIELD_MSGBOX_TITLE "Hackshield"
- // #define HACKSHIELD_FILE "Hackshield.Error.txt"
- #define HACKSHIELD_FILE "syserr.txt"
- #define HACKSHIELD_GENERAL_MESSAGE "[HackShield] Our system detect a file or application dangerous: "
- #define YMIRWORK_PATH_INJECTION_ERROR "You must delete or rename the folder 'ymir work' on the path 'D:/' to open the game correctly."
- #define KERNEL_MODE_ERROR "You can't launch the game in Kernel-Mode. This game can be launched only in User-Mode."
- #define PRODAMAGE_HACK_FOUND_ERROR "You can't use ProDamageHack, exit from the game."
- #define LALAKER_HACK_FOUND_ERROR "You can't use Lalaker1, exit from the game."
- #define M2BOB_FOUND_ERROR "You can't use M2Bob, exit from the game."
- #define INJECTOR_GADGET_FOUND_ERROR "You can't use InjectorGadget, exit from the game."
- #define BOT_EXP_FOUND_ERROR "You can't use Exp-Bot, exit from the game."
- #define SMARTSNIFF_FOUND_ERROR "You can't use SmartSniff, exit from the game."
- #define OLLYDBG_FOUND_ERROR "You can't use OllyDbg, exit from the game."
- #define WINDBG_FOUND_ERROR "You can't use WinDbg, exit from the game"
- #define PROCESS_EXPLORER_FOUND_ERROR "You can't use Process Explorer, exit from the game."
- #define CHEAT_ENGINE_FOUND_ERROR "You can't use Cheat Engine, exit from the game."
- bool __IS_TEST_SERVER_MODE__=false;
- int error = 0;
- inline long crc(std::string Filename) {
- FILE *f;
- if ((f = fopen(Filename.c_str(), "rb")) == NULL) return 0;
- unsigned long size;
- fseek(f, 0, SEEK_END);
- size = ftell(f);
- fseek(f, 0, SEEK_SET);
- unsigned char *File = new (std::nothrow) unsigned char[size];
- fread(File, 1, size, f);
- fclose(f);
- unsigned long crc[256];
- for (unsigned int i = 0; i <= 0xFF; i++) {
- unsigned long coso = 0;
- unsigned long I = i;
- for (unsigned int b = 1; b<9; b++) {
- if (I & 1) coso |= 1 << (8 - b);
- I >>= 1;
- }
- crc[i] = coso << 24;
- for (unsigned int c = 0; c<8; c++) crc[i] = (crc[i] << 1) ^ (crc[i] & (1 << 31) ? 0x04c11db7 : 0);
- unsigned long coso2 = 0;
- unsigned long Ii = crc[i];
- for (unsigned int d = 1; d<33; d++) {
- if (Ii & 1) coso2 |= 1 << (32 - d);
- Ii >>= 1;
- }
- crc[i] = coso2;
- }
- unsigned long Crc = 0xffffffff;
- for (unsigned int i = 0; i<size; i++) Crc = (Crc >> 8) ^ crc[(Crc & 0xFF) ^ File[i]];
- delete[] File;
- return Crc ^ 0xffffffff;
- }
- inline std::string FromHex(const std::string& in) {
- std::string output;
- if ((in.length() % 2) != 0) {
- FILE *f = fopen(ERROR_HACKSHIELD_DECRYPT_CONFIG_FILE, "w");
- fputs(ERROR_HACKSHIELD_DECRYPT, f);
- fputs(in.c_str(), f);
- fputs("\n", f);
- fclose(f);
- exit(-1);
- return "";
- }
- size_t cnt = in.length() / 2;
- for (size_t i = 0; cnt > i; ++i) {
- unsigned long int s = 0;
- std::stringstream ss;
- ss << std::hex << in.substr(i * 2, 2);
- ss >> s;
- output.push_back(static_cast<unsigned char>(s));
- }
- return output;
- }
- inline std::string UltimateCipher(std::string Str) {
- char Key[3] = { 'A', 'B', 'C' };
- std::string Encrypted = Str;
- for (unsigned int i = 0; i<Str.size(); i++) Encrypted[i] = Str[i] ^ Key[i % (sizeof(Key) / sizeof(char))];
- return Encrypted;
- }
- inline std::string UltimateDecrypt(std::string MyString) {
- return UltimateCipher(FromHex(MyString));
- }
- void Pack_Error(const char *err)
- {
- error++;
- MessageBoxA(NULL, std::string(std::string(CLIENT_ERROR) + std::string(FILE_CORRUPTED) + std::string(err)).c_str(), PACK_ERROR_TITLE, NULL);
- exit(0);
- }
- void Lib_Error(const char *err)
- {
- if (strstr(err, "copy_reg.pyc") == NULL) {
- error++;
- MessageBoxA(NULL, std::string(std::string(CLIENT_ERROR) + std::string(FILE_CORRUPTED) + std::string(err)).c_str(), LIB_ERROR_TITLE, NULL);
- exit(0);
- }
- }
- void Miles_Error(const char *err)
- {
- error++;
- MessageBoxA(NULL, std::string(std::string(CLIENT_ERROR) + std::string(FILE_CORRUPTED) + std::string(err)).c_str(), MILES_ERROR_TITLE, NULL);
- exit(0);
- }
- void CheckPack()
- {
- if (crc(UltimateDecrypt("2c2b2f24316c2c313072706d252e2f").c_str()) != 1817711331) Miles_Error(UltimateDecrypt("2c2b2f24316c2c313072706d252e2f").c_str()); //miles/mss32.dll
- if (crc(UltimateDecrypt("2c2b2f24316c2c31302071276f2f7025").c_str()) != 1812642892) Miles_Error(UltimateDecrypt("2c2b2f24316c2c31302071276f2f7025").c_str()); //miles/mssa3d.m3d
- if (crc(UltimateDecrypt("2c2b2f24316c2c3130253170256c2e7226").c_str()) != -1590370812) Miles_Error(UltimateDecrypt("2c2b2f24316c2c3130253170256c2e7226").c_str()); //miles/mssds3d.m3d
- if (crc(UltimateDecrypt("2c2b2f24316c2c31302531336f242f35").c_str()) != -930147909) Miles_Error(UltimateDecrypt("2c2b2f24316c2c31302531336f242f35").c_str()); //miles/mssdsp.flt
- if (crc(UltimateDecrypt("2c2b2f24316c2c3130253a746f2f7025").c_str()) != 236402185) Miles_Error(UltimateDecrypt("2c2b2f24316c2c3130253a746f2f7025").c_str()); //miles/mssdx7.m3d
- if (crc(UltimateDecrypt("2c2b2f24316c2c313024233b6f2f7025").c_str()) != -1099152393) Miles_Error(UltimateDecrypt("2c2b2f24316c2c313024233b6f2f7025").c_str()); //miles/msseax.m3d
- if (crc(UltimateDecrypt("2c2b2f24316c2c31302c32706f233028").c_str()) != 1219814613) Miles_Error(UltimateDecrypt("2c2b2f24316c2c31302c32706f233028").c_str()); //miles/mssmp3.asi
- if (crc(UltimateDecrypt("2c2b2f24316c2c313033313b6f2f7025").c_str()) != 550946743) Miles_Error(UltimateDecrypt("2c2b2f24316c2c313033313b6f2f7025").c_str()); //miles/mssrsx.m3d
- if (crc(UltimateDecrypt("2c2b2f24316c2c3130322d25356c2e7226").c_str()) != -10545928) Miles_Error(UltimateDecrypt("2c2b2f24316c2c3130322d25356c2e7226").c_str()); //miles/msssoft.m3d
- if (crc(UltimateDecrypt("2c2b2f24316c2c3130372d2a22276d20312a").c_str()) != 1407967464) Miles_Error(UltimateDecrypt("2c2b2f24316c2c3130372d2a22276d20312a").c_str()); //miles/mssvoice.asi
- }
- bool LibCheck = false; //CHECK LIB FOLDER OF THE CLIENT
- bool YmirWorkFolderCheck = true; //CHECK YMIR WORK PATH INJECTION ON 'D:\'
- std::string WhiteList[] = {
- APP_TITLE,
- UltimateDecrypt("022d2e312337162b2d252d34"),
- UltimateDecrypt("0d0d04"),
- UltimateDecrypt("0c010a61212c2c2f222f266329232d252e2a2f2563362b2d252d34"),
- UltimateDecrypt("0923202a112b28272f25626e610626352720352b2c2f"),
- UltimateDecrypt("0d233a24302625620b282627242c63162b2d252d34"),
- UltimateDecrypt("0e0010610d33242c040d620772066315272e31620724342a222763162b2d252d34"),
- UltimateDecrypt("060d0c03180c610c2635352c3329630434262f363061112a2f2963162b2d252d34"),
- UltimateDecrypt("05272520372f35620a0c07"),
- UltimateDecrypt("0c110015040a0c0763140b"),
- UltimateDecrypt("050b062c152a2f"),
- UltimateDecrypt("0021372834260c2d35282763162b2d252d34"),
- UltimateDecrypt("0c2b20332d302e243761142a3237222d62006a696313372d352b2e24620f28203120303a"),
- UltimateDecrypt("06060a6a6214282c272e35"),
- UltimateDecrypt("1212060406212836630f2737362d312a620637272d353163122b2d2a6214282c272e35"),
- UltimateDecrypt("022d2e312d2d242c37162b2d252d34"),
- UltimateDecrypt("092b2d35152d25"),
- UltimateDecrypt("092b2d35152d25"),
- UltimateDecrypt("122d13181d1608"),
- UltimateDecrypt("101313282c3a282c1608152d25"),
- UltimateDecrypt("3236223527012030"),
- UltimateDecrypt("06121a1e170a"),
- UltimateDecrypt("112b2d382b2d313737140b"),
- UltimateDecrypt("122d14031d1608"),
- UltimateDecrypt("0c000a2c27"),
- UltimateDecrypt("10131434202a140b142f26"),
- UltimateDecrypt("13011c080c1314161c140b"),
- UltimateDecrypt("282c333436012030"),
- UltimateDecrypt("1774160f0b10110b0e"),
- UltimateDecrypt("160c1318170a"),
- UltimateDecrypt("202b0203013031"),
- UltimateDecrypt("03232a25371c080f16080f0413"),
- UltimateDecrypt("03232a2537202f1d160812312e3a3a"),
- UltimateDecrypt("03232a25371318012f203130"),
- UltimateDecrypt("11232f2c0b2d313737140b"),
- UltimateDecrypt("05041608"),
- UltimateDecrypt("0a170d0d170d1e170a"),
- UltimateDecrypt("122d242e371c1511051e170a"),
- };
- typedef LONG NTSTATUS;
- typedef VOID *POBJECT;
- typedef PVOID CONNECTION_CONTEXT;
- typedef struct _SYSTEM_HANDLE {
- ULONG uIdProcess;
- UCHAR ObjectType;
- UCHAR Flags;
- USHORT Handle;
- POBJECT pObject;
- ACCESS_MASK GrantedAccess;
- } SYSTEM_HANDLE, *PSYSTEM_HANDLE;
- typedef struct _SYSTEM_HANDLE_INFORMATION {
- ULONG uCount;
- SYSTEM_HANDLE Handles[1];
- } SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
- typedef struct _UNICODE_STRING {
- USHORT Length;
- USHORT MaximumLength;
- PWSTR Buffer;
- } UNICODE_STRING;
- typedef UNICODE_STRING *PUNICODE_STRING;
- typedef UNICODE_STRING *POBJECT_NAME_INFORMATION;
- typedef enum _OBJECT_INFORMATION_CLASS{
- ObjectBasicInformation,
- ObjectNameInformation,
- ObjectTypeInformation,
- ObjectAllTypesInformation,
- ObjectHandleInformation
- } OBJECT_INFORMATION_CLASS;
- typedef UNICODE_STRING OBJECT_NAME_INFORMATION;
- typedef enum _THREAD_INFORMATION_CLASS2 {
- ThreadBasicInformation,
- ThreadTimes,
- ThreadPriority,
- ThreadBasePriority,
- ThreadAffinityMask,
- ThreadImpersonationToken,
- ThreadDescriptorTableEntry,
- ThreadEnableAlignmentFaultFixup,
- ThreadEventPair,
- ThreadQuerySetWin32StartAddress,
- ThreadZeroTlsCell,
- ThreadPerformanceCount,
- ThreadAmILastThread,
- ThreadIdealProcessor,
- ThreadPriorityBoost,
- ThreadSetTlsArrayAddress,
- ThreadIsIoPending,
- ThreadHideFromDebugger
- } THREAD_INFORMATION_CLASS2, *PTHREAD_INFORMATION_CLASS2;
- void __fastcall Frankie_Hook(PVOID TargetFunction, PVOID Trampoline, PVOID DetouredFunction, DWORD CP_SIZE);
- typedef const UNICODE_STRING *PCUNICODE_STRING;
- typedef int (WINAPI *WINSTATERMINATEPROC)(HANDLE hServer, DWORD dwProcessId, UINT uExitCode);
- typedef NTSTATUS(WINAPI *NtQueryInformationThreadT)(HANDLE, ULONG, PVOID, ULONG, PULONG);
- typedef NTSTATUS(WINAPI *tNTQSI)(DWORD SystemInformationClass, PVOID SystemInformation, DWORD SystemInformationLength, PDWORD ReturnLength);
- typedef NTSTATUS(WINAPI *tNTQO)(HANDLE ObjectHandle, OBJECT_INFORMATION_CLASS ObjectInformationClass, PVOID ObjectInformation, DWORD Length, PDWORD ResultLength);
- void WINAPI NewDebugRemoteBreakin(void);
- void WINAPI CheckThread(void);
- PVOID pLoadLibraryA;
- PVOID pLoadLibraryW;
- PVOID pLdrLoadDll;
- PVOID pHookLdrLoadDll;
- HMODULE hKernel32;
- HMODULE hNtdll;
- HMODULE hWinsta;
- HANDLE WindowThread = NULL;
- HANDLE GuardHandle1 = NULL;
- HANDLE GuardHandle2 = NULL;
- extern bool BobFound = false;
- inline void Anti_Debugger()
- {
- DWORD oldProtect;
- HMODULE hNtdll = GetModuleHandle(UltimateDecrypt("2f36272d2e6d252e2f").c_str());
- PVOID NewDebuggerRemoteBreakin = NewDebugRemoteBreakin;
- BYTE Buffer[5] = { 0xE9, 0x00, 0x00, 0x00, 0x00 };
- PVOID DebugRemoteBreakin = GetProcAddress(hNtdll, UltimateDecrypt("052024142b11242f2c3527013327222a2b2d").c_str());
- if (!DebugRemoteBreakin) { exit(0); return; }
- else{
- *(LONG*)(Buffer + 1) = JUMP_TO_OFFSET(DebugRemoteBreakin, NewDebuggerRemoteBreakin);
- VirtualProtect(DebugRemoteBreakin, 5, PAGE_EXECUTE_READWRITE, &oldProtect);
- RtlMoveMemory(DebugRemoteBreakin, Buffer, 5);
- VirtualProtect(DebugRemoteBreakin, 5, oldProtect, &oldProtect);
- }
- }
- void WINAPI NewDebugRemoteBreakin(void)
- {
- hWinsta = LoadLibraryA(UltimateDecrypt("362b2d3236226f262f2d").c_str());
- WINSTATERMINATEPROC WinStationTerminateProcess = (WINSTATERMINATEPROC)GetProcAddress(hWinsta, UltimateDecrypt("162b2d123622352b2c2f1626332f2a2f23372412312e21263231").c_str());
- WinStationTerminateProcess(NULL, GetCurrentProcessId(), DBG_TERMINATE_PROCESS);
- ExitProcess(DBG_TERMINATE_PROCESS);
- }
- __declspec(naked) NTSTATUS HookLdrLoadDll()
- {
- __asm
- {
- PUSHAD
- CALL CheckThread
- POPAD
- JMP pHookLdrLoadDll
- }
- }
- void __fastcall Frankie_Hook(PVOID TargetFunction, PVOID Trampoline, PVOID DetouredFunction, DWORD CP_SIZE)
- {
- DWORD OldProtect;
- VirtualProtect(TargetFunction, CP_SIZE, PAGE_EXECUTE_READWRITE, &OldProtect);
- RtlMoveMemory(Trampoline, TargetFunction, CP_SIZE);
- LPBYTE JmpOffset = (LPBYTE)Trampoline + CP_SIZE;
- *JmpOffset = (BYTE)0xE9;
- *(PLONG)(JmpOffset + 1) = JUMP_TO_OFFSET(JmpOffset, (LPBYTE)TargetFunction + CP_SIZE);
- JmpOffset = (LPBYTE)TargetFunction;
- *JmpOffset = (BYTE)0xE9;
- *(PLONG)(JmpOffset + 1) = JUMP_TO_OFFSET(JmpOffset, DetouredFunction);
- VirtualProtect(TargetFunction, CP_SIZE, OldProtect, &OldProtect);
- }
- inline void CloseProcess()
- {
- Sleep(4000);
- exit(0);
- }
- inline void CloseApp(const char *Name)
- {
- CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(CloseProcess), NULL, NULL, NULL);
- MessageBoxA(NULL, Name, HACKSHIELD_MSGBOX_TITLE, NULL);
- exit(0);
- }
- void WINAPI CheckThread()
- {
- PVOID addr;
- ULONG tid = GetCurrentThreadId();
- if (tid == NULL) return;
- NtQueryInformationThreadT NtQueryInfThread;
- NtQueryInfThread = (NtQueryInformationThreadT)GetProcAddress(hNtdll, UltimateDecrypt("0f3612342731380b2d272d312c2337282d2d152a31242327").c_str());
- if (!NtQueryInfThread) return;
- HANDLE h = OpenThread(THREAD_QUERY_INFORMATION, FALSE, tid);
- if (!h) return;
- NTSTATUS s = NtQueryInfThread(h, ThreadQuerySetWin32StartAddress, &addr, sizeof(addr), NULL);
- CloseHandle(h);
- if (addr == (PVOID)pLoadLibraryA || addr == (PVOID)pLoadLibraryW) ExitThread(0);
- }
- inline void Anti_DLLInjection()
- {
- hNtdll = GetModuleHandle(UltimateDecrypt("2f36272d2e6d252e2f").c_str());
- if (!hNtdll) { exit(0); return; }
- hKernel32 = GetModuleHandleA(UltimateDecrypt("2a27312f272f72706d252e2f").c_str());
- if (!hKernel32) { exit(0); return; }
- pLoadLibraryA = GetProcAddress(hKernel32, UltimateDecrypt("0d2d22250e2a233022333b02").c_str());
- if (!pLoadLibraryA) { exit(0); return; }
- pLoadLibraryW = GetProcAddress(hKernel32, UltimateDecrypt("0d2d22250e2a233022333b14").c_str());
- if (!pLoadLibraryW) { exit(0); return; }
- pLdrLoadDll = GetProcAddress(hNtdll, UltimateDecrypt("0d26310d2d2225062f2d").c_str());
- if (!pLdrLoadDll) { exit(0); return; }
- pHookLdrLoadDll = VirtualAlloc(NULL, 10, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- Frankie_Hook(pLdrLoadDll, pHookLdrLoadDll, HookLdrLoadDll, 5);
- }
- template <typename T>
- inline std::string ToString(T val)
- {
- std::stringstream stream;
- stream << val;
- return stream.str();
- }
- inline void Report(std::string Application)
- {
- if (ERRORLOG_ENABLE) {
- FILE *f = fopen(HACKSHIELD_FILE, "w");
- fputs(std::string(HACKSHIELD_GENERAL_MESSAGE + Application + "\n").c_str(), f);
- fclose(f);
- }
- exit(0);
- }
- inline void ErrorPythonPathInjector()
- {
- std::string FakeString = "D:\\ymir work\\*";
- CloseApp(YMIRWORK_PATH_INJECTION_ERROR);
- }
- struct Frankie{ DWORD pid; }Pids;
- inline bool InWhiteList(std::string Element)
- {
- for (int i = 0; i < sizeof(WhiteList) / sizeof(WhiteList[0]); i++) {
- if (Element.length() < 2) return true;
- if (Element.find(WhiteList[i]) != std::string::npos) return true;
- }
- return false;
- }
- BOOL CALLBACK WindowList(HWND hnd, LPARAM lParam)
- {
- Frankie *Struct = (Frankie*)lParam;
- DWORD pID;
- GetWindowThreadProcessId(hnd, &pID);
- if (pID == Struct->pid) {
- char Win[200];
- char Class[200];
- GetWindowTextA(hnd, Win, 200);
- GetClassNameA(hnd, Class, 200);
- if (!InWhiteList(std::string(Win)) && strcmp(Class, UltimateDecrypt("352d2c2d362a31311c222e2232317073").c_str()) != 0) {
- Report(std::string(Win));
- }
- }
- return TRUE;
- }
- inline std::string GetProcessPathName(DWORD processID)
- {
- char szProcessName[200];
- HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
- if (NULL != hProcess) {
- HMODULE hMod;
- DWORD cbNeeded;
- if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
- GetModuleFileNameExA(hProcess, hMod, szProcessName, 200);
- return std::string(szProcessName);
- }
- }
- CloseHandle(hProcess);
- return "";
- }
- inline std::vector<std::string> split(const std::string &text, char sep) {
- std::vector<std::string> tokens;
- std::size_t start = 0, end = 0;
- while ((end = text.find(sep, start)) != std::string::npos) {
- if (end != start) {
- tokens.push_back(text.substr(start, end - start));
- }
- start = end + 1;
- }
- if (end != start) {
- tokens.push_back(text.substr(start));
- }
- return tokens;
- }
- inline bool file_exists(const std::string& name) {
- if (FILE *file = fopen(name.c_str(), "r")) {
- fclose(file);
- return true;
- }
- else return false;
- }
- inline bool dirExists(const std::string& dirName_in)
- {
- DWORD ftyp = GetFileAttributesA(dirName_in.c_str());
- if (ftyp == INVALID_FILE_ATTRIBUTES)
- return false;
- if (ftyp & FILE_ATTRIBUTE_DIRECTORY) return true;
- return false;
- }
- inline void Symbols()
- {
- HMODULE Modules[1024];
- DWORD Mod;
- if (EnumProcessModules(GetCurrentProcess(), Modules, sizeof(Modules), &Mod)) {
- for (unsigned int i = 0; i<Mod / sizeof(HMODULE); i++) {
- char ModuleName[200];
- if (GetModuleFileNameExA(GetCurrentProcess(), Modules[i], ModuleName, 200)) {
- if (GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d202603082c2a352b222d2b3924").c_str()) != NULL &&
- GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d202603072b2d202e2a3b27").c_str()) != NULL &&
- GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d362b2d252d34010b2d28362a202e2a3b27").c_str()) != NULL &&
- GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d362b2d252d3401042a2f232f283826").c_str()) != NULL &&
- GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("150f26352a2c250b2e312e262c272d352337282d2d082c37243020243237").c_str()) != NULL &&
- GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e1d1c02121325272134250b2e2d28").c_str()) != NULL &&
- GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e03270c232a2f").c_str()) != NULL &&
- GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e042c332f0e202b2d").c_str()) != NULL) {
- Report(PRODAMAGE_HACK_FOUND_ERROR);
- }
- }
- }
- }
- DWORD aProcesses[1024], cbNeeded, cProcesses;
- if (EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded)) {
- cProcesses = cbNeeded / sizeof(DWORD);
- for (unsigned int i = 0; i<cProcesses; i++) {
- if (aProcesses[i] != 0) {
- std::vector<std::string> Process = split(GetProcessPathName(aProcesses[i]), '\\');
- std::string Path;
- for (unsigned int a = 0; a < (Process.size() - 1); a++) {
- Path.append(Process[a]);
- Path.append("\\");
- }
- std::string Folder1 = Path + UltimateDecrypt("12273137273132");
- std::string Folder2 = Path + UltimateDecrypt("11302c272b2f2431");
- std::string Folder3 = Path + UltimateDecrypt("2d2d24282c6d222424");
- if (dirExists(Folder1) == true && dirExists(Folder2) == true && file_exists(Folder3) == true) Report(LALAKER_HACK_FOUND_ERROR);
- }
- }
- }
- }
- inline void GameGuard()
- {
- C:
- if (WaitForSingleObject(WindowThread, 1000) != WAIT_TIMEOUT) exit(0);
- if (WaitForSingleObject(GuardHandle1, 1000) != WAIT_TIMEOUT) exit(0);
- if (WaitForSingleObject(GuardHandle2, 1000) != WAIT_TIMEOUT) exit(0);
- ResumeThread(WindowThread);
- ResumeThread(GuardHandle1);
- ResumeThread(GuardHandle2);
- Sleep(1000);
- goto C;
- }
- inline void BlockYmirWork()
- {
- if (GetSystemMetrics(SM_CLEANBOOT) != 0) CloseApp(KERNEL_MODE_ERROR);
- if (YmirWorkFolderCheck) {
- WIN32_FIND_DATAA Check;
- std::string Path(std::string(UltimateDecrypt("05")) + std::string(UltimateDecrypt("7b1e1f")) + std::string(UltimateDecrypt("382f2a33")) + std::string(UltimateDecrypt("61352c33291f1d68")));
- HANDLE check = FindFirstFileA(Path.c_str(), &Check);
- if (check != INVALID_HANDLE_VALUE) {
- FindClose(check);
- ErrorPythonPathInjector();
- }
- }
- }
- inline bool CheckBotExp(){
- char wname[200];
- HWND w = FindWindowA(UltimateDecrypt("0037372e0a2c35292638").c_str(), NULL);
- GetWindowTextA(w, wname, 200);
- return file_exists(wname);
- }
- inline bool CheckInjectorGadget(){
- if (FindWindowA(UltimateDecrypt("363a14282c272e350d13").c_str(), NULL)) return true; else return false;
- }
- inline void DetectFiles()
- {
- Restart:
- Pids.pid = GetCurrentProcessId();
- EnumWindows(WindowList, (LPARAM)&Pids);
- if (BobFound) Report(M2BOB_FOUND_ERROR);
- if (CheckInjectorGadget()) Report(INJECTOR_GADGET_FOUND_ERROR);
- if (CheckBotExp()) Report(BOT_EXP_FOUND_ERROR);
- if (FindWindowA(UltimateDecrypt("122f223336102f2b2527").c_str(), NULL)) Report(SMARTSNIFF_FOUND_ERROR);
- if (FindWindowA(UltimateDecrypt("0e0e0f18060106").c_str(), NULL)) Report(OLLYDBG_FOUND_ERROR);
- if (FindWindowA(UltimateDecrypt("162b2d0520240730222c27002d233032").c_str(), NULL)) Report(WINDBG_FOUND_ERROR);
- if (FindWindowA(NULL, UltimateDecrypt("0a27312f272f610626352720352b35246235706c776f73637b7863123b3035272e610b272d276311302c22273032").c_str())) Report(PROCESS_EXPLORER_FOUND_ERROR);
- if (FindWindowA(NULL, UltimateDecrypt("0030376b0f2c6b2c2638").c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("020a70757563720c04700c70")) + std::string(" 9.9")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.3")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.4")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.5")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.6")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.7")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.8")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.9")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.0")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.1")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.2")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.3")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.4")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.5")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.6")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.7")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.8")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.9")).c_str())) Report(CHEAT_ENGINE_FOUND_ERROR);
- if (FindWindowA(NULL, UltimateDecrypt("113b0f2e232724306337736d716c71616a1338362b2e2c63736c74616463113b37292d2d61706d736b").c_str())) Report(INJECTOR_GADGET_FOUND_ERROR);
- if (FindWindowA(NULL, UltimateDecrypt("043a3733272e24620a2f282622362c336235726c756f7363233b632c2330352731707172").c_str())) Report(INJECTOR_GADGET_FOUND_ERROR);
- if (LibCheck) {
- WIN32_FIND_DATAA Lib;
- HANDLE Lis = FindFirstFileA(UltimateDecrypt("2d2b211d1e69").c_str(), &Lib);
- if (!(Lib.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- if (_stricmp(Lib.cFileName, UltimateDecrypt("1e1d2534363633271c1e6c333821").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("222d33381d3124256d313b20").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("353b3324316d313b20").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("2d2b2d242122222a266f323a22").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("2f363320362b6f323a22").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("2e316d313b20").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("322b37246c333821").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("323622356c333821").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("323631282c246f323a22").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("14312633062a22366d313b20").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("3530222227212021286f323a22").c_str()) != 0) {
- std::string File(Lib.cFileName);
- 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) {
- Report(File.c_str());
- }
- }
- }
- while (FindNextFileA(Lis, &Lib)) {
- if (!(Lib.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- if (_stricmp(Lib.cFileName, UltimateDecrypt("1e1d2534363633271c1e6c333821").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("222d33381d3124256d313b20").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("353b3324316d313b20").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("2d2b2d242122222a266f323a22").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("2f363320362b6f323a22").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("2e316d313b20").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("322b37246c333821").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("323622356c333821").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("323631282c246f323a22").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("14312633062a22366d313b20").c_str()) != 0 &&
- _stricmp(Lib.cFileName, UltimateDecrypt("3530222227212021286f323a22").c_str()) != 0) {
- std::string File(Lib.cFileName);
- 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) {
- Report(File.c_str());
- }
- }
- }
- }
- FindClose(Lis);
- }
- WIN32_FIND_DATAA Miles;
- HANDLE Mil = FindFirstFileA(UltimateDecrypt("2c2b2f24311f1d68").c_str(), &Miles);
- if (!(Miles.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- if (_stricmp(Miles.cFileName, UltimateDecrypt("2c31302071276f2f7025").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253170256c2e7226").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253a746f2f7025").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c313024233b6f2f7025").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302c32706f233028").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c313033313b6f2f7025").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130322d25356c2e7226").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130372d2a22276d20312a").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302531336f242f35").c_str()) != 0) {
- std::string File(Miles.cFileName);
- 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) {
- Report(File.c_str());
- }
- }
- }
- while (FindNextFileA(Mil, &Miles)) {
- if (!(Miles.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- if (_stricmp(Miles.cFileName, UltimateDecrypt("2c31302071276f2f7025").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253170256c2e7226").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253a746f2f7025").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c313024233b6f2f7025").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302c32706f233028").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c313033313b6f2f7025").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130322d25356c2e7226").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130372d2a22276d20312a").c_str()) != 0
- && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302531336f242f35").c_str()) != 0) {
- std::string File(Miles.cFileName);
- 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) {
- Report(File.c_str());
- }
- }
- }
- }
- FindClose(Mil);
- WIN32_FIND_DATAA Current;
- HANDLE Cur = FindFirstFileA("*", &Current);
- if (!(Current.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- std::string FileC(Current.cFileName);
- 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) {
- Report(FileC.c_str());
- }
- 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) {
- Report(FileC.c_str());
- }
- }
- while (FindNextFileA(Cur, &Current)) {
- if (!(Current.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- std::string FileC(Current.cFileName);
- 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) {
- Report(FileC.c_str());
- }
- 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) {
- Report(FileC.c_str());
- }
- }
- }
- FindClose(Cur);
- BlockYmirWork();
- Symbols();
- Sleep(2000);
- goto Restart;
- }
- extern DWORD tid1 = 0;
- extern DWORD tid2 = 0;
- extern DWORD tid3 = 0;
- inline void Protection()
- {
- if (ARGUMENT_ENABLE) if (strstr(GetCommandLineA(), ARGUMENT_STRING) == NULL) exit(0);
- CheckPack();
- BlockYmirWork();
- Anti_DLLInjection();
- Anti_Debugger();
- WindowThread = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(DetectFiles), NULL, NULL, &tid1);
- GuardHandle1 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, &tid2);
- GuardHandle2 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, &tid3);
- }
- extern bool SetDefaultCodePage(DWORD codePage);
- #ifdef USE_OPENID
- extern int openid_test;
- #endif
- static const char * sc_apszPythonLibraryFilenames[] =
- {
- "UserDict.pyc",
- "__future__.pyc",
- "copy_reg.pyc",
- "linecache.pyc",
- "ntpath.pyc",
- "os.pyc",
- "site.pyc",
- "stat.pyc",
- "string.pyc",
- "traceback.pyc",
- "types.pyc",
- "\n",
- };
- char gs_szErrorString[512] = "";
- void ApplicationSetErrorString(const char* szErrorString)
- {
- strcpy(gs_szErrorString, szErrorString);
- }
- bool CheckPythonLibraryFilenames()
- {
- for (int i = 0; *sc_apszPythonLibraryFilenames[i] != '\n'; ++i)
- {
- std::string stFilename = "lib\\";
- stFilename += sc_apszPythonLibraryFilenames[i];
- if (_access(stFilename.c_str(), 0) != 0)
- {
- return false;
- }
- MoveFile(stFilename.c_str(), stFilename.c_str());
- }
- return true;
- }
- struct ApplicationStringTable
- {
- HINSTANCE m_hInstance;
- std::map<DWORD, std::string> m_kMap_dwID_stLocale;
- } gs_kAppStrTable;
- void ApplicationStringTable_Initialize(HINSTANCE hInstance)
- {
- gs_kAppStrTable.m_hInstance=hInstance;
- }
- const std::string& ApplicationStringTable_GetString(DWORD dwID, LPCSTR szKey)
- {
- char szBuffer[512];
- char szIniFileName[256];
- char szLocale[256];
- ::GetCurrentDirectory(sizeof(szIniFileName), szIniFileName);
- if(szIniFileName[lstrlen(szIniFileName)-1] != '\\')
- strcat(szIniFileName, "\\");
- strcat(szIniFileName, "metin2client.dat");
- strcpy(szLocale, LocaleService_GetLocalePath());
- if(strnicmp(szLocale, "locale/", strlen("locale/")) == 0)
- strcpy(szLocale, LocaleService_GetLocalePath() + strlen("locale/"));
- ::GetPrivateProfileString(szLocale, szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
- if(szBuffer[0] == '\0')
- LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
- if(szBuffer[0] == '\0')
- ::GetPrivateProfileString("en", szKey, NULL, szBuffer, sizeof(szBuffer)-1, szIniFileName);
- if(szBuffer[0] == '\0')
- strcpy(szBuffer, szKey);
- std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
- rstLocale=szBuffer;
- return rstLocale;
- }
- const std::string& ApplicationStringTable_GetString(DWORD dwID)
- {
- char szBuffer[512];
- LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer)-1);
- std::string& rstLocale=gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
- rstLocale=szBuffer;
- return rstLocale;
- }
- const char* ApplicationStringTable_GetStringz(DWORD dwID, LPCSTR szKey)
- {
- return ApplicationStringTable_GetString(dwID, szKey).c_str();
- }
- const char* ApplicationStringTable_GetStringz(DWORD dwID)
- {
- return ApplicationStringTable_GetString(dwID).c_str();
- }
- ////////////////////////////////////////////
- int Setup(LPSTR lpCmdLine); // Internal function forward
- bool PackInitialize(const char * c_pszFolder)
- {
- NANOBEGIN
- if (_access(c_pszFolder, 0) != 0)
- return true;
- std::string stFolder(c_pszFolder);
- stFolder += "/";
- std::string stFileName(stFolder);
- stFileName += "Index";
- CMappedFile file;
- LPCVOID pvData;
- if (!file.Create(stFileName.c_str(), &pvData, 0, 0))
- {
- LogBoxf("FATAL ERROR! File not exist: %s", stFileName.c_str());
- TraceError("FATAL ERROR! File not exist: %s", stFileName.c_str());
- return true;
- }
- CMemoryTextFileLoader TextLoader;
- TextLoader.Bind(file.Size(), pvData);
- bool bPackFirst = TRUE;
- const std::string& strPackType = TextLoader.GetLineString(0);
- if (strPackType.compare("FILE") && strPackType.compare("PACK"))
- {
- TraceError("Pack/Index has invalid syntax. First line must be 'PACK' or 'FILE'");
- return false;
- }
- #ifdef _DISTRIBUTE
- Tracef("알림: 팩 모드입니다.\n");
- //if (0 == strPackType.compare("FILE"))
- //{
- // bPackFirst = FALSE;
- // Tracef("알림: 파일 모드입니다.\n");
- //}
- //else
- //{
- // Tracef("알림: 팩 모드입니다.\n");
- //}
- #else
- bPackFirst = FALSE;
- Tracef("알림: 파일 모드입니다.\n");
- #endif
- CTextFileLoader::SetCacheMode();
- #if defined(USE_RELATIVE_PATH)
- CEterPackManager::Instance().SetRelativePathMode();
- #endif
- CEterPackManager::Instance().SetCacheMode();
- CEterPackManager::Instance().SetSearchMode(bPackFirst);
- CSoundData::SetPackMode(); // Miles 파일 콜백을 셋팅
- std::string strPackName, strTexCachePackName;
- for (DWORD i = 1; i < TextLoader.GetLineCount() - 1; i += 2)
- {
- const std::string & c_rstFolder = TextLoader.GetLineString(i);
- const std::string & c_rstName = TextLoader.GetLineString(i + 1);
- strPackName = stFolder + c_rstName;
- strTexCachePackName = strPackName + "_texcache";
- CEterPackManager::Instance().RegisterPack(strPackName.c_str(), c_rstFolder.c_str());
- CEterPackManager::Instance().RegisterPack(strTexCachePackName.c_str(), c_rstFolder.c_str());
- }
- FILE* fp = fopen("root.cfg", "rt");
- char rootName[256];
- if (fp)
- {
- char line[256];
- if (fgets(line, sizeof(line)-1, fp))
- {
- line[sizeof(line)-1] = '\0';
- sscanf(line, "%s", rootName);
- }
- fclose(fp);
- }
- CEterPackManager::Instance().RegisterRootPack((stFolder + std::string(rootName)).c_str());
- NANOEND
- return true;
- }
- bool RunMainScript(CPythonLauncher& pyLauncher, const char* lpCmdLine)
- {
- initpack();
- initdbg();
- initime();
- initgrp();
- initgrpImage();
- initgrpText();
- initwndMgr();
- /////////////////////////////////////////////
- initudp();
- initapp();
- initsystem();
- initchr();
- initchrmgr();
- initPlayer();
- initItem();
- initNonPlayer();
- initTrade();
- initChat();
- initTextTail();
- initnet();
- initMiniMap();
- initProfiler();
- initEvent();
- initeffect();
- initfly();
- initsnd();
- initeventmgr();
- initshop();
- initskill();
- initskillpet();
- initskillbaby();
- initquest();
- initBackground();
- initMessenger();
- initsafebox();
- initguild();
- initServerStateChecker();
- NANOBEGIN
- // RegisterDebugFlag
- {
- std::string stRegisterDebugFlag;
- #ifdef _DISTRIBUTE
- stRegisterDebugFlag ="__DEBUG__ = 0";
- #else
- stRegisterDebugFlag ="__DEBUG__ = 1";
- #endif
- if (!pyLauncher.RunLine(stRegisterDebugFlag.c_str()))
- {
- TraceError("RegisterDebugFlag Error");
- return false;
- }
- }
- // RegisterCommandLine
- {
- std::string stRegisterCmdLine;
- const char * loginMark = "-cs";
- const char * loginMark_NonEncode = "-ncs";
- const char * seperator = " ";
- std::string stCmdLine;
- const int CmdSize = 3;
- vector<std::string> stVec;
- SplitLine(lpCmdLine,seperator,&stVec);
- if (CmdSize == stVec.size() && stVec[0]==loginMark)
- {
- char buf[MAX_PATH]; //TODO 아래 함수 string 형태로 수정
- base64_decode(stVec[2].c_str(),buf);
- stVec[2] = buf;
- string_join(seperator,stVec,&stCmdLine);
- }
- else if (CmdSize <= stVec.size() && stVec[0]==loginMark_NonEncode)
- {
- stVec[0] = loginMark;
- string_join(" ",stVec,&stCmdLine);
- }
- else
- stCmdLine = lpCmdLine;
- stRegisterCmdLine ="__COMMAND_LINE__ = ";
- stRegisterCmdLine+='"';
- stRegisterCmdLine+=stCmdLine;
- stRegisterCmdLine+='"';
- const CHAR* c_szRegisterCmdLine=stRegisterCmdLine.c_str();
- if (!pyLauncher.RunLine(c_szRegisterCmdLine))
- {
- TraceError("RegisterCommandLine Error");
- return false;
- }
- }
- {
- vector<std::string> stVec;
- SplitLine(lpCmdLine," " ,&stVec);
- if (stVec.size() != 0 && "--pause-before-create-window" == stVec[0])
- {
- #ifdef XTRAP_CLIENT_ENABLE
- if (!XTrap_CheckInit())
- return false;
- #endif
- system("pause");
- }
- if (!pyLauncher.RunFile("system.py"))
- {
- TraceError("RunMain Error");
- return false;
- }
- }
- NANOEND
- return true;
- }
- bool Main(HINSTANCE hInstance, LPSTR lpCmdLine)
- {
- #ifdef LOCALE_SERVICE_YMIR
- extern bool g_isScreenShotKey;
- g_isScreenShotKey = true;
- #endif
- DWORD dwRandSeed=time(NULL)+DWORD(GetCurrentProcess());
- srandom(dwRandSeed);
- srand(random());
- SetLogLevel(1);
- #ifdef LOCALE_SERVICE_VIETNAM_MILD
- extern BOOL USE_VIETNAM_CONVERT_WEAPON_VNUM;
- USE_VIETNAM_CONVERT_WEAPON_VNUM = true;
- #endif
- if (_access("perf_game_update.txt", 0)==0)
- {
- DeleteFile("perf_game_update.txt");
- }
- if (_access("newpatch.exe", 0)==0)
- {
- system("patchupdater.exe");
- return false;
- }
- #ifndef __VTUNE__
- ilInit();
- #endif
- if (!Setup(lpCmdLine))
- return false;
- #ifdef _DEBUG
- OpenConsoleWindow();
- OpenLogFile(true); // true == uses syserr.txt and log.txt
- #else
- OpenLogFile(true); // false == uses syserr.txt only
- #endif
- static CLZO lzo;
- static CEterPackManager EterPackManager;
- if (!PackInitialize("pack"))
- {
- LogBox("Pack Initialization failed. Check log.txt file..");
- return false;
- }
- if(LocaleService_LoadGlobal(hInstance))
- SetDefaultCodePage(LocaleService_GetCodePage());
- CPythonApplication * app = new CPythonApplication;
- app->Initialize(hInstance);
- bool ret=false;
- {
- CPythonLauncher pyLauncher;
- CPythonExceptionSender pyExceptionSender;
- SetExceptionSender(&pyExceptionSender);
- if (pyLauncher.Create())
- {
- ret=RunMainScript(pyLauncher, lpCmdLine); //게임 실행중엔 함수가 끝나지 않는다.
- }
- //ProcessScanner_ReleaseQuitEvent();
- //게임 종료시.
- app->Clear();
- timeEndPeriod(1);
- pyLauncher.Clear();
- }
- app->Destroy();
- delete app;
- return ret;
- }
- HANDLE CreateMetin2GameMutex()
- {
- SECURITY_ATTRIBUTES sa;
- ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
- sa.nLength = sizeof(sa);
- sa.lpSecurityDescriptor = NULL;
- sa.bInheritHandle = FALSE;
- return CreateMutex(&sa, FALSE, "Metin2GameMutex");
- }
- void DestroyMetin2GameMutex(HANDLE hMutex)
- {
- if (hMutex)
- {
- ReleaseMutex(hMutex);
- hMutex = NULL;
- }
- }
- void __ErrorPythonLibraryIsNotExist()
- {
- LogBoxf("FATAL ERROR!! Python Library file not exist!");
- }
- bool __IsTimeStampOption(LPSTR lpCmdLine)
- {
- const char* TIMESTAMP = "/timestamp";
- return (strncmp(lpCmdLine, TIMESTAMP, strlen(TIMESTAMP))==0);
- }
- void __PrintTimeStamp()
- {
- #ifdef _DEBUG
- if (__IS_TEST_SERVER_MODE__)
- LogBoxf("METIN2 BINARY TEST DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
- else
- LogBoxf("METIN2 BINARY DEBUG VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
- #else
- if (__IS_TEST_SERVER_MODE__)
- LogBoxf("METIN2 BINARY TEST VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
- else
- LogBoxf("METIN2 BINARY DISTRIBUTE VERSION %s ( MS C++ %d Compiled )", __TIMESTAMP__, _MSC_VER);
- #endif
- }
- bool __IsLocaleOption(LPSTR lpCmdLine)
- {
- return (strcmp(lpCmdLine, "--locale") == 0);
- }
- bool __IsLocaleVersion(LPSTR lpCmdLine)
- {
- return (strcmp(lpCmdLine, "--perforce-revision") == 0);
- }
- #ifdef USE_OPENID
- //2012.07.16 김용욱
- //일본 OpenID 지원. 인증키 인자 추가
- bool __IsOpenIDAuthKeyOption(LPSTR lpCmdLine)
- {
- return (strcmp(lpCmdLine, "--openid-authkey") == 0);
- }
- bool __IsOpenIDTestOption(LPSTR lpCmdLine) //클라이언트에서 로그인이 가능하다.
- {
- return (strcmp(lpCmdLine, "--openid-test") == 0);
- }
- #endif /* USE_OPENID */
- int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- if (strstr(lpCmdLine, "--hackshield") != 0)
- return 0;
- #ifdef _DEBUG
- _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF );
- //_CrtSetBreakAlloc( 110247 );
- #endif
- ApplicationStringTable_Initialize(hInstance);
- Protection();
- LocaleService_LoadConfig("locale.cfg");
- SetDefaultCodePage(LocaleService_GetCodePage());
- #ifdef XTRAP_CLIENT_ENABLE
- if (!XTrap_Init())
- return 0;
- #endif
- #ifdef USE_AHNLAB_HACKSHIELD
- //if (!HackShield_Init())
- // return 0;
- #endif
- #ifdef USE_NPROTECT_GAMEGUARD
- if (!GameGuard_Init())
- return 0;
- #endif
- #if defined(CHECK_LATEST_DATA_FILES)
- if (!CheckLatestFiles())
- return 0;
- #endif
- bool bQuit = false;
- bool bAuthKeyChecked = false; //OpenID 버전에서 인증키가 들어왔는지 알기 위한 인자.
- int nArgc = 0;
- PCHAR* szArgv = CommandLineToArgv( lpCmdLine, &nArgc );
- for( int i=0; i < nArgc; i++ ) {
- if(szArgv[i] == 0)
- continue;
- if (__IsLocaleVersion(szArgv[i])) // #0000829: [M2EU] 버전 파일이 항상 생기지 않도록 수정
- {
- char szModuleName[MAX_PATH];
- char szVersionPath[MAX_PATH];
- GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
- sprintf(szVersionPath, "%s.version", szModuleName);
- FILE* fp = fopen(szVersionPath, "wt");
- if (fp)
- {
- extern int METIN2_GET_VERSION();
- fprintf(fp, "r%d\n", METIN2_GET_VERSION());
- fclose(fp);
- }
- bQuit = true;
- } else if (__IsLocaleOption(szArgv[i]))
- {
- FILE* fp=fopen("locale.txt", "wt");
- fprintf(fp, "service[%s] code_page[%d]",
- LocaleService_GetName(), LocaleService_GetCodePage());
- fclose(fp);
- bQuit = true;
- } else if (__IsTimeStampOption(szArgv[i]))
- {
- __PrintTimeStamp();
- bQuit = true;
- } else if ((strcmp(szArgv[i], "--force-set-locale") == 0))
- {
- // locale 설정엔 인자가 두 개 더 필요함 (로케일 명칭, 데이터 경로)
- if (nArgc <= i + 2)
- {
- MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
- goto Clean;
- }
- const char* localeName = szArgv[++i];
- const char* localePath = szArgv[++i];
- LocaleService_ForceSetLocale(localeName, localePath);
- }
- #ifdef USE_OPENID
- else if (__IsOpenIDAuthKeyOption(szArgv[i])) //2012.07.16 OpenID : 김용욱
- {
- // 인증키 설정엔 인자가 한 개 더 필요함 (인증키)
- if (nArgc <= i + 1)
- {
- MessageBox(NULL, "Invalid arguments", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
- goto Clean;
- }
- const char* authKey = szArgv[++i];
- //ongoing (2012.07.16)
- //인증키 저장하는 부분
- LocaleService_SetOpenIDAuthKey(authKey);
- bAuthKeyChecked = true;
- }
- else if (__IsOpenIDTestOption(szArgv[i]))
- {
- openid_test = 1;
- }
- #endif /* USE_OPENID */
- }
- #ifdef USE_OPENID
- //OpenID
- //OpenID 클라이언트의 경우인증키를 받아오지 않을 경우 (웹을 제외하고 실행 시) 클라이언트 종료.
- if (false == bAuthKeyChecked && !openid_test)
- {
- MessageBox(NULL, "Invalid execution", ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
- goto Clean;
- }
- #endif /* USE_OPENID */
- if(bQuit)
- goto Clean;
- #if defined(NEEDED_COMMAND_ARGUMENT)
- // 옵션이 없으면 비정상 실행으로 간주, 프로그램 종료
- if (strstr(lpCmdLine, NEEDED_COMMAND_ARGUMENT) == 0) {
- MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
- goto Clean;
- }
- #endif
- #if defined(NEEDED_COMMAND_CLIPBOARD)
- {
- CHAR szSecKey[256];
- CPostIt cPostIt( "VOLUME1" );
- if( cPostIt.Get( "SEC_KEY", szSecKey, sizeof(szSecKey) ) == FALSE ) {
- MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
- goto Clean;
- }
- if( strstr(szSecKey, NEEDED_COMMAND_CLIPBOARD) == 0 ) {
- MessageBox(NULL, ApplicationStringTable_GetStringz(IDS_ERR_MUST_LAUNCH_FROM_PATCHER, "ERR_MUST_LAUNCH_FROM_PATCHER"), ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
- goto Clean;
- }
- cPostIt.Empty();
- }
- #endif
- WebBrowser_Startup(hInstance);
- if (!CheckPythonLibraryFilenames())
- {
- __ErrorPythonLibraryIsNotExist();
- goto Clean;
- }
- Main(hInstance, lpCmdLine);
- #ifdef USE_NPROTECT_GAMEGUARD
- GameGuard_NoticeMessage();
- #endif
- WebBrowser_Cleanup();
- ::CoUninitialize();
- if(gs_szErrorString[0])
- MessageBox(NULL, gs_szErrorString, ApplicationStringTable_GetStringz(IDS_APP_NAME, "APP_NAME"), MB_ICONSTOP);
- Clean:
- #ifdef USE_AHNLAB_HACKSHIELD
- HackShield_Shutdown();
- #endif
- SAFE_FREE_GLOBAL(szArgv);
- return 0;
- }
- static void GrannyError(granny_log_message_type Type,
- granny_log_message_origin Origin,
- char const* File,
- granny_int32x Line,
- char const * Error,
- void * UserData)
- {
- Tracef("GRANNY: %s\n", Error);
- }
- int Setup(LPSTR lpCmdLine)
- {
- /*
- * 타이머 정밀도를 올린다.
- */
- TIMECAPS tc;
- UINT wTimerRes;
- if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
- return 0;
- wTimerRes = MINMAX(tc.wPeriodMin, 1, tc.wPeriodMax);
- timeBeginPeriod(wTimerRes);
- /*
- * 그래니 에러 핸들링
- */
- granny_log_callback Callback;
- Callback.Function = GrannyError;
- Callback.UserData = 0;
- GrannySetLogCallback(&Callback);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement