Advertisement
dram

Untitled

May 6th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1.  
  2. DWORD dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *lpszModuleName)
  3. {
  4. HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessIdentifier);
  5. DWORD dwModuleBaseAddress = 0;
  6. if(hSnapshot != INVALID_HANDLE_VALUE)
  7. {
  8. MODULEENTRY32 ModuleEntry32 = {0};
  9. ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
  10. if(Module32First(hSnapshot, &ModuleEntry32))
  11. {
  12. do
  13. {
  14. if(_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0)
  15. {
  16. dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
  17. break;
  18. }
  19. }
  20. while(Module32Next(hSnapshot, &ModuleEntry32));
  21. }
  22. CloseHandle(hSnapshot);
  23. }
  24. return dwModuleBaseAddress;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement