Quantcast

Jump to content

» «
Photo

GTA SA C++ Health

3 replies to this topic
DatPawn
  • DatPawn

    Player Hater

  • Members
  • Joined: 30 Mar 2014
  • Germany

#1

Posted 30 March 2014 - 11:11 AM Edited by DatPawn, 30 March 2014 - 11:11 AM.

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;

//Memory
DWORD pid; //Process ID
HWND hwnd; //handle

int 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?


Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#2

Posted 30 March 2014 - 11:13 AM

Sounds like you're trying to cheat?

DatPawn
  • DatPawn

    Player Hater

  • Members
  • Joined: 30 Mar 2014
  • Germany

#3

Posted 30 March 2014 - 11:16 AM

Sounds like you're trying to cheat?

No, I will read my Health from GTA:SA. (SAMP)


Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#4

Posted 30 March 2014 - 11:19 AM Edited by Silent, 30 March 2014 - 11:19 AM.

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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users