Public paste
Undefined
By: Guest | Date: Jan 9 2009 21:31 | Format: None | Expires: never | Size: 736 B | Hits: 783

  1. int ReadMem(char *window, int dAddr)
  2. {
  3.         int buffer;
  4.         //DWORD prevProtection;
  5.         HWND hWnd = FindWindow(0, window);
  6.         if (!hWnd) MessageBox(0, "Error finding window", 0, MB_OK);
  7.         DWORD proc_id;
  8.         GetWindowThreadProcessId(hWnd, &proc_id);
  9.         HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id);
  10.        
  11.         //VirtualProtectEx(hProcess, (LPVOID)dAddr, 4, PAGE_EXECUTE_READWRITE, &prevProtection);
  12.         //VirtualUnlock((LPVOID)dAddr, 2);
  13.         if (!ReadProcessMemory(hProcess, (LPCVOID)dAddr, &buffer, 2, NULL))
  14.                 MessageBox(0, "Error doing memory reading", 0, MB_OK);
  15.         //VirtualProtectEx(hProcess, (LPVOID)dAddr, 4, prevProtection, &prevProtection);
  16.        
  17.         return buffer;
  18. }