Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. bool OpenH1Z1()
  2. {
  3. Globals* g = Globals::get();
  4. if (g->g_hGame)
  5. {
  6. CloseHandle(g->g_hGame);
  7. g->g_hGame = nullptr;
  8. }
  9.  
  10. g->g_hGame = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, g->g_PID);
  11.  
  12. if (INVALID_HANDLE(g->g_hGame))
  13. return false;
  14.  
  15. PHDL_IO phdlio;
  16. phdlio.access = PROCESS_ALL_ACCESS;
  17. phdlio.handle = (ULONGLONG)g->g_hGame;
  18. phdlio.pid = GetCurrentProcessId();
  19.  
  20. if (kb_PromoteHandle(&phdlio) != 0)
  21. return false;
  22.  
  23. return true;
  24. }
  25.  
  26. DWORD ReadMemory(PVOID64 target_ptr, size_t size, PVOID local_buffer)
  27. {
  28. Globals* g = Globals::get();
  29. ULONGLONG bytes;
  30.  
  31. if (INVALID_HANDLE(g->g_hGame))
  32. return -1;
  33.  
  34. #ifdef _WIN64
  35. return ReadProcessMemory(g->g_hGame, target_ptr, local_buffer, size, &bytes);
  36. #else
  37. return g->NtReadVirtualMemory(g->g_hGame, (UINT64)target_ptr, local_buffer, size, &bytes);
  38. #endif
  39. }
  40.  
  41. PVOID64 ReadPtr(PVOID64 target_ptr, PDWORD read_status)
  42. {
  43.  
  44. char local_buffer[sizeof(PVOID64)];
  45. ZeroMemory(local_buffer, sizeof(local_buffer));
  46. DWORD read = ReadMemory(target_ptr, sizeof(local_buffer), local_buffer);
  47. if (read_status)
  48. {
  49. *read_status = read;
  50. }
  51. return (*(PVOID64*)(local_buffer));
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement