Advertisement
Guest User

Teilerfolg...

a guest
May 25th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. #include <windows.h>
  2. #include <TlHelp32.h>
  3. #include <iostream>
  4. #include <tchar.h>
  5.  
  6. using namespace std;
  7.  
  8. DWORD dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *lpszModuleName)
  9. {
  10.     HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessIdentifier);
  11.     DWORD dwModuleBaseAddress = 0;
  12.     if (hSnapshot != INVALID_HANDLE_VALUE)
  13.     {
  14.         MODULEENTRY32 ModuleEntry32 = { 0 };
  15.         ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
  16.         if (Module32First(hSnapshot, &ModuleEntry32))
  17.         {
  18.             do
  19.             {
  20.                 if (_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0)
  21.                 {
  22.                     dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
  23.                     break;
  24.                 }
  25.             } while (Module32Next(hSnapshot, &ModuleEntry32));
  26.         }
  27.         CloseHandle(hSnapshot);
  28.     }
  29.     return dwModuleBaseAddress;
  30. }
  31.  
  32. int main()
  33. {
  34.     HWND window = FindWindow(0, _T("Guild Wars 2"));
  35.     if (window == 0){
  36.         printf("Window not found!\n");
  37.         char f;
  38.         cin >> f;
  39.         return 0;
  40.     }
  41.  
  42.     DWORD pID = 0;
  43.     GetWindowThreadProcessId(window, &pID);
  44.  
  45.     DWORD baseAddr = dwGetModuleBaseAddress(pID, _T("Gw2.exe"));
  46.     DWORD staticOffset = 0x1430654;
  47.  
  48.     HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
  49.  
  50.     DWORD value;
  51.     DWORD numBytesRead;
  52.     ReadProcessMemory(handle, (LPCVOID)(baseAddr + staticOffset), &value, sizeof(DWORD), &numBytesRead);
  53.     value += 0x16c;
  54.     ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
  55.     value += 0x54c;
  56.     ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
  57.     value += 0x0;
  58.     ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
  59.     value += 0x48;
  60.     ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
  61.     value += 8;
  62.     ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
  63.  
  64.     CloseHandle(handle);
  65.    
  66.     cout << (float)value << endl;
  67.     cin.get();
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement