Last active
April 19, 2022 14:28
-
-
Save xacnio/a9263420cd40b684b11faa9c5aeae7b0 to your computer and use it in GitHub Desktop.
C++ Read Memory By Process on Windows
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
HWND hwndMyWindow; | |
hwndMyWindow = FindWindowEx(NULL, NULL, "ConsoleWindowClass", NULL); | |
if (hwndMyWindow != NULL) | |
{ | |
DWORD procID; | |
GetWindowThreadProcessId(hwndMyWindow, &procID); | |
if (procID != NULL) | |
{ | |
HANDLE hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, procID); | |
if (hProcess) | |
{ | |
HMODULE hMods[1024]; | |
DWORD cbNeeded; | |
if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded) && cbNeeded > 0) | |
{ | |
void* fadadress = (void*)(hMods[0] + 0x0A76B); // base address + offset | |
char test[13]; | |
ReadProcessMemory(hProcess, (LPVOID)fadadress, &test, sizeof(test), NULL); | |
printf("%s", test); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment