Skip to content

Instantly share code, notes, and snippets.

@xacnio
Last active April 19, 2022 14:28
Show Gist options
  • Save xacnio/a9263420cd40b684b11faa9c5aeae7b0 to your computer and use it in GitHub Desktop.
Save xacnio/a9263420cd40b684b11faa9c5aeae7b0 to your computer and use it in GitHub Desktop.
C++ Read Memory By Process on Windows
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