Jump to content

GTA SA C++ Health


DatPawn

Recommended Posts

Hello, I will read the Health from my DLL.

 

My DLL:

#include <iostream>#include <windows.h>using namespace std;extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);DWORD PlayerPointer = 0xB6F5F0;DWORD HealthOffset = 0x540;//MemoryDWORD pid; //Process IDHWND hwnd; //handleint checkGTAProcess(){	hwnd = FindWindow(NULL, L"GTA:SA:MP");	if (!hwnd)	{		return -1;	}	else {		return 1;	}};extern "C" __declspec(dllexport) float samp_health(){	if (checkGTAProcess() == -1) return -1;	float value;	hwnd = FindWindow(NULL, L"GTA:SA:MP");	GetWindowThreadProcessId(hwnd, &pid);	HANDLE open = OpenProcess(PROCESS_VM_READ, false, pid);	ReadProcessMemory(open, (LPVOID)(PlayerPointer + HealthOffset), &value, sizeof(value), NULL);	CloseHandle(open);	return value;}

Everytime I get 0.0000.

 

Why?

Edited by DatPawn
Link to comment
Share on other sites

Sounds like you're trying to cheat?

Link to comment
Share on other sites

0xB6F5F0 holds a pointer to CPed and you're treating it as if there was a CPed struct at that address.

Edited by Silent
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.