I get annoyed when I see simple memory writing made this complex... You can easily change the value of a pointer without defining any variables but the base addy and the offset. It is a waste of time to declare other ints and floats when you can write to a value with a single line of code. I'll just use stamina as an example and make up random addresses. Here is an example of how to do this the efficient way. I will also add the hotkeys and show how to make an efficient loop to keep the hack running:
Code:
#define Playerpointer 0x12345678
#define StaminaOffset 0x284
bool staminaon = false;
void Stamina()
{
while(1)
{
if(staminaon == true)
{
*(float*)(*(*DWORD*)Playerpointer + StaminaOffset) = 100;
Sleep(100); //Avoid lag
}
}
}
void Hotkeys()
{
while(1)
{
if(GetAsyncKeyState(VK_NUMPAD1))
{
if(staminaon == false)
{
staminaon = true;
MessageBox(0, "Stamina Activated", "DLL Hack", MB_OK);
}
else
{
staminaon = false;
MessageBox(0, "Stamina Deactivated", "DLL Hack", MB_OK);
}
}
Sleep(100); //Avoid lag
}
}
BOOL APIENTRY DllMain(HINSTANCE hDll, DWORD callReason, LPVOID lpReserved)
{
DisableThreadLibraryCalls(hDll);
switch(callReason)
{
case(DLL_PROCESS_ATTACH):
{
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&Stamina, 0, 0, 0);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&Hotkeys, 0, 0, 0);
}
case(DLL_PROCESS_DETACH):
{
FreeLibrary(hDll);
break;
}
}
return 1;
}
Please excuse any errors, I just wrote this from memory. The basic idea is actually this line:
Code:
*(float*)(*(DWORD*)Playerpointer + StaminaOffset) = 100;
The float at the beginning is showing that the type of the value is float, the DWORD is just showing that it is 4 byte (which an offset always is) and the 100 is just the value to set it to.