Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h" // Precompiled header
- #include <Windows.h> // Allows window editing; setting text, etc
- #include <iostream>
- #include <TlHelp32.h>
- #include <conio.h>
- using namespace std; // Allows use of std::
- __int64 GetModuleBaseAddress(LPCWSTR szProcessName, LPCWSTR szModuleName)
- {
- HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- PROCESSENTRY32 pe32;
- if (hSnap == INVALID_HANDLE_VALUE)
- {
- return 0;
- }
- pe32.dwSize = sizeof(PROCESSENTRY32);
- if (Process32First(hSnap, &pe32) == 0)
- {
- CloseHandle(hSnap);
- return 0;
- }
- do
- {
- if (lstrcmp(pe32.szExeFile, szProcessName) == 0)
- {
- int PID;
- PID = pe32.th32ProcessID;
- HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID);
- MODULEENTRY32 xModule;
- if (hSnap == INVALID_HANDLE_VALUE)
- {
- return 0;
- }
- xModule.dwSize = sizeof(MODULEENTRY32);
- if (Module32First(hSnap, &xModule) == 0)
- {
- CloseHandle(hSnap);
- return 0;
- }
- do
- {
- if (lstrcmp(xModule.szModule, szModuleName) == 0)
- {
- CloseHandle(hSnap);
- return (__int64)xModule.modBaseAddr;
- }
- } while (Module32Next(hSnap, &xModule));
- CloseHandle(hSnap);
- return 0;
- }
- } while (Process32Next(hSnap, &pe32));
- CloseHandle(hSnap);
- return 0;
- }
- int Main()
- {
- wchar_t* WindowName = (L"Grand Theft Auto V");
- wchar_t* GameTitle = (L"GTA5.exe");
- HWND WindowHandle = FindWindow(NULL, WindowName);
- __int64 BaseAddress = GetModuleBaseAddress(GameTitle, GameTitle);
- DWORD ProcessID;
- GetWindowThreadProcessId(WindowHandle, &ProcessID);
- HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, ProcessID);
- std::cout << "[sucess]: GTAV.exe has been found!" << std::endl;
- for (;;)
- {
- if (GetAsyncKeyState(VK_NUMPAD1))
- {
- Sleep(250);
- float Health = 200;
- __int64 pPlayerInformationAddress = 0;
- DWORD SocialClubPlayerInformation = 0x01ED6D88;
- DWORD HealthOffset = 0x280;
- ReadProcessMemory(pHandle, (void*)(BaseAddress + SocialClubPlayerInformation), &pPlayerInformationAddress, sizeof(pPlayerInformationAddress), NULL);
- ReadProcessMemory(pHandle, (void*)(pPlayerInformationAddress + HealthOffset), &Health, sizeof(Health), NULL);
- std::cout << Health << std::endl;
- }
- }
- Sleep(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement