Last active
May 7, 2020 18:10
-
-
Save mxmssh/955b0ec6c3a47401d72cf4fdb6d27e4e to your computer and use it in GitHub Desktop.
Snippet #1
This file contains hidden or 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
void GetModuleBaseAddresses(DWORD procId) | |
{ | |
uintptr_t modBaseAddr = 0; | |
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId); | |
if (hSnap != INVALID_HANDLE_VALUE) | |
{ | |
MODULEENTRY32 modEntry; | |
modEntry.dwSize = sizeof(modEntry); | |
if (Module32First(hSnap, &modEntry)) | |
{ | |
do | |
{ | |
#ifndef _WIN64 | |
printf("Module %s base address is 0x%x\n", modEntry.szModule, modEntry.modBaseAddr); | |
#else | |
printf("Module %s base address is 0x%llx\n", modEntry.szModule, modEntry.modBaseAddr); | |
#endif | |
} while (Module32Next(hSnap, &modEntry)); | |
} | |
} | |
CloseHandle(hSnap); | |
} | |
int main() | |
{ | |
GetModuleBaseAddresses(GetCurrentProcessId()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment