-
-
Save anonymous/a413289ca0eb3e7515e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <TlHelp32.h> | |
#include <iostream> | |
#include <TCHAR.H> | |
using namespace std; | |
DWORD dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *lpszModuleName) | |
{ | |
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessIdentifier); | |
DWORD dwModuleBaseAddress = 0; | |
if(hSnapshot != INVALID_HANDLE_VALUE) | |
{ | |
MODULEENTRY32 ModuleEntry32 = {0}; | |
ModuleEntry32.dwSize = sizeof(MODULEENTRY32); | |
if(Module32First(hSnapshot, &ModuleEntry32)) | |
{ | |
do | |
{ | |
if(_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0) | |
{ | |
dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr; | |
break; | |
} | |
} | |
while(Module32Next(hSnapshot, &ModuleEntry32)); | |
} | |
CloseHandle(hSnapshot); | |
} | |
return dwModuleBaseAddress; | |
} | |
int main() | |
{ | |
HWND window = FindWindow(0, _T("FTL")); | |
if( window == 0 ){ | |
cout << "Window not found!\n"; | |
char f; | |
cin >> f; | |
return 0; | |
} | |
DWORD pID = 0; | |
GetWindowThreadProcessId(window, &pID); | |
DWORD baseAddr = dwGetModuleBaseAddress(pID, _T("FTLGame.exe")); | |
DWORD staticOffset = 0x002E79BC; | |
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID); | |
DWORD value; | |
DWORD numBytesRead; | |
ReadProcessMemory(handle, (LPCVOID)(baseAddr+staticOffset), &value, sizeof(DWORD), &numBytesRead);; | |
CloseHandle(handle); | |
cout << "Found value: " << hex << value; | |
char f; | |
cin >> f; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment