Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. #include "stdafx.h" // Precompiled header
  2.  
  3. #include <Windows.h> // Allows window editing; setting text, etc
  4. #include <iostream>
  5. #include <TlHelp32.h>
  6. #include <conio.h>
  7.  
  8. using namespace std; // Allows use of std::
  9.  
  10. __int64 GetModuleBaseAddress(LPCWSTR szProcessName, LPCWSTR szModuleName)
  11. {
  12. HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  13. PROCESSENTRY32 pe32;
  14.  
  15. if (hSnap == INVALID_HANDLE_VALUE)
  16. {
  17. return 0;
  18. }
  19. pe32.dwSize = sizeof(PROCESSENTRY32);
  20. if (Process32First(hSnap, &pe32) == 0)
  21. {
  22. CloseHandle(hSnap);
  23. return 0;
  24. }
  25.  
  26. do
  27. {
  28. if (lstrcmp(pe32.szExeFile, szProcessName) == 0)
  29. {
  30. int PID;
  31. PID = pe32.th32ProcessID;
  32.  
  33. HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID);
  34. MODULEENTRY32 xModule;
  35.  
  36. if (hSnap == INVALID_HANDLE_VALUE)
  37. {
  38. return 0;
  39. }
  40. xModule.dwSize = sizeof(MODULEENTRY32);
  41. if (Module32First(hSnap, &xModule) == 0)
  42. {
  43. CloseHandle(hSnap);
  44. return 0;
  45. }
  46.  
  47. do
  48. {
  49. if (lstrcmp(xModule.szModule, szModuleName) == 0)
  50. {
  51. CloseHandle(hSnap);
  52. return (__int64)xModule.modBaseAddr;
  53. }
  54. } while (Module32Next(hSnap, &xModule));
  55. CloseHandle(hSnap);
  56. return 0;
  57. }
  58. } while (Process32Next(hSnap, &pe32));
  59. CloseHandle(hSnap);
  60. return 0;
  61. }
  62.  
  63. int Main()
  64. {
  65.  
  66. wchar_t* WindowName = (L"Grand Theft Auto V");
  67. wchar_t* GameTitle = (L"GTA5.exe");
  68.  
  69. HWND WindowHandle = FindWindow(NULL, WindowName);
  70. __int64 BaseAddress = GetModuleBaseAddress(GameTitle, GameTitle);
  71.  
  72. DWORD ProcessID;
  73. GetWindowThreadProcessId(WindowHandle, &ProcessID);
  74.  
  75. HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, ProcessID);
  76.  
  77. std::cout << "[sucess]: GTAV.exe has been found!" << std::endl;
  78.  
  79. for (;;)
  80. {
  81. if (GetAsyncKeyState(VK_NUMPAD1))
  82. {
  83. Sleep(250);
  84.  
  85. float Health = 200;
  86. __int64 pPlayerInformationAddress = 0;
  87.  
  88. DWORD SocialClubPlayerInformation = 0x01ED6D88;
  89. DWORD HealthOffset = 0x280;
  90.  
  91. ReadProcessMemory(pHandle, (void*)(BaseAddress + SocialClubPlayerInformation), &pPlayerInformationAddress, sizeof(pPlayerInformationAddress), NULL);
  92. ReadProcessMemory(pHandle, (void*)(pPlayerInformationAddress + HealthOffset), &Health, sizeof(Health), NULL);
  93.  
  94. std::cout << Health << std::endl;
  95. }
  96. }
  97.  
  98. Sleep(1);
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement