diff --git a/Option.h b/Option.h index 7726dad..dd37263 100644 --- a/Option.h +++ b/Option.h @@ -3,21 +3,17 @@ class Option { public: - bool exit; + bool exit = false; int SCREEN_WIDTH; int SCREEN_HEIGHT; void GetDesktopResolution(int& horizontal, int& vertical); - bool bMenu; - bool bGodMode; + bool bMenu = true; + bool bGodMode = false; // Constructor Option() { - this->exit = false; - this->bMenu = true; - this->bGodMode = false; - GetDesktopResolution(this->SCREEN_WIDTH, this->SCREEN_HEIGHT); } }; diff --git a/main.cpp b/main.cpp index f9965fa..414e934 100644 --- a/main.cpp +++ b/main.cpp @@ -45,10 +45,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // Get Handle to target Process hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, procId); - // Module base address - addr->moduleBase = proc->GetModuleBaseAddress64(procId); + // Proc base address + addr->moduleBase = (uintptr_t)proc->GetModuleBaseAddress64(procId); - addr->unityPlayer = proc->getDllModule((LPSTR)"UnityPlayer.dll"); + addr->unityPlayer = (uintptr_t)proc->GetDllModule(L"UnityPlayer.dll", procId); } else { @@ -112,10 +112,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine MSG msg; // Main loop - while (!(GetAsyncKeyState(VK_END))) + while ((!(GetAsyncKeyState(VK_END))) && !option->exit) { - //if (exit) break; - // Check to see if any messages are waiting in the queue while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { diff --git a/proc.cpp b/proc.cpp index 8399288..9534f72 100644 --- a/proc.cpp +++ b/proc.cpp @@ -71,9 +71,32 @@ DWORD_PTR Proc::GetModuleBaseAddress64(DWORD processID) return baseAddress; } -DWORD Proc::getDllModule(LPSTR lpDllName) +DWORD Proc::GetDllModule(const wchar_t* module, DWORD procId) { - // to do with msdn process32first + HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, procId); + + if (hSnap == INVALID_HANDLE_VALUE) + { + return 0; + } + + MODULEENTRY32 modEntry; + modEntry.dwSize = sizeof(MODULEENTRY32); + + if (!Module32First(hSnap, &modEntry)) + { + return 0; + } + + if (!_wcsicmp(modEntry.szModule, module)) + return (DWORD)modEntry.modBaseAddr; + + while (Module32Next(hSnap, &modEntry)) + { + if (!_wcsicmp(modEntry.szModule, module)) + return (DWORD)modEntry.modBaseAddr; + } + } Proc* proc = new Proc(); \ No newline at end of file diff --git a/proc.h b/proc.h index e2c1482..28358f7 100644 --- a/proc.h +++ b/proc.h @@ -8,7 +8,7 @@ class Proc DWORD GetProcId(const wchar_t* procName); DWORD_PTR GetModuleBaseAddress64(DWORD processID); - DWORD getDllModule(LPSTR lpDllName); + DWORD GetDllModule(const wchar_t* module, DWORD procId); Proc() { this->hProcess = 0;