Skip to content

Instantly share code, notes, and snippets.

@divinity76
Forked from xophiix/GetModuleBaseAddress.cpp
Last active February 2, 2016 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/883dbdca511f39bc25b2 to your computer and use it in GitHub Desktop.
Save divinity76/883dbdca511f39bc25b2 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <Tlhelp32.h.>
using namespace std;
int main()
{
HANDLE h= CreateToolhelp32Snapshot(8, 780);
if (h == INVALID_HANDLE_VALUE) {
throw std::runtime_error("CreateToolhelp32Snapshot failed, returning INVALID_HANDLE_VALUE");
}
MODULEENTRY32 me;
bool ret = Module32First(h, &me);
while (ret)
{
printf("%p\t\%s\n", me.modBaseAddr, me.szModule);
ret = Module32Next(h, &me);
}
CloseHandle(h);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment