Quote:
Originally Posted by hero9910
addys
#define MEM_STAMINA1 0x823FA0 //
#define MEM_STAMINA2 0x823FA4 //
#define MEM_STAMINA3 0x823FA8 //
#define MEM_STAMINA4 0x823FAC //
#define MEM_STAMINA5 0x823FB0 //
funktion
Code:
//Stamina
if (stamina==1)
{
DWORD dwPlayerPtr = *(DWORD*)ADR_PLAYERPOINTER;
if (dwPlayerPtr != 0)
{
*(float*)MEM_STAMINA1 = 1000;
*(float*)MEM_STAMINA2 = 1000;
*(float*)MEM_STAMINA3 = 0;
*(float*)MEM_STAMINA4 = 0;
*(float*)MEM_STAMINA5 = 0;
}
}
if (stamina==0)
{
DWORD dwPlayerPtr = *(DWORD*)ADR_PLAYERPOINTER;
if (dwPlayerPtr != 0)
{
*(float*)MEM_STAMINA1 = 60;
*(float*)MEM_STAMINA2 = 60;
*(float*)MEM_STAMINA3 = 0;
*(float*)MEM_STAMINA4 = 0;
*(float*)MEM_STAMINA5 = 0;
}
}
|
if(nStamina)
{
Stamina1Patch.Patch();
Stamina2Patch.Patch();
Stamina3Patch.Patch();
Stamina4Patch.Patch();
Stamina5Patch.Patch();
}
else
{
Stamina1Patch.Restore();
Stamina2Patch.Restore();
Stamina3Patch.Restore();
Stamina4Patch.Restore();
Stamina5Patch.Restore();
}
cMemPatch<float>Stamina1Patch(ADR_STAMINA1,1000);
cMemPatch<double>Stamina2Patch(ADR_STAMINA2,1000);
cMemPatch<double>Stamina3Patch(ADR_STAMINA3,0);
cMemPatch<float>Stamina4Patch(ADR_STAMINA4,0);
cMemPatch<float>Stamina5Patch(ADR_STAMINA5,0);
#define ADR_STAMINA1 0x823FA0
#define ADR_STAMINA2 0x823FA4
#define ADR_STAMINA3 0x823FA8
#define ADR_STAMINA4 0x823FAC
#define ADR_STAMINA5 0x823FB0
MemPatch:
#pragma once
#ifndef __CMEMORYPATCH_H__
#define __CMEMORYPATCH_H__
#include <windows.h>
template <typename T>
class cMemPatch
{
private:
unsigned long Address;
T OffValue;
T OnValue;
int PatchStatus;
int OffValueSaved;
enum PATCHSTATUS
{
NORMAL,
PATCHED
};
bool SaveOffValue(void);
public:
cMemPatch(void);
cMemPatch(unsigned long ADR, T VAL);
void Patch(void);
void Restore(void);
};
template <typename T>
cMemPatch<T>::cMemPatch(void)
{
}
template <typename T>
cMemPatch<T>::cMemPatch(unsigned long ADR, T VAL)
{
this->Address = ADR;
this->OnValue = VAL;
this->PatchStatus = NORMAL;
this->OffValueSaved = false;
}
template <typename T>
void cMemPatch<T>::Patch()
{
if (this->PatchStatus == NORMAL)
{
if (this->OffValueSaved == false)
{
if (!this->SaveOffValue())
return;
}
else
{
//*(T*)(this->Address) = this->OnValue;
unsigned long size;
VirtualProtect((void*)this->Address, sizeof(this->OnValue), PAGE_READWRITE, &size);
memcpy((void*)this->Address, &this->OnValue , sizeof(this->OnValue));
VirtualProtect((void*)this->Address, sizeof(this->OnValue), size, 0);
this->PatchStatus = PATCHED;
}
}
}
template <typename T>
void cMemPatch<T>::Restore()
{
if (this->PatchStatus == PATCHED)
{
*(T*)(this->Address) = this->OffValue;
this->PatchStatus = NORMAL;
}
}
template <typename T>
bool cMemPatch<T>::SaveOffValue()
{
if (IsBadReadPtr((void*)(this->Address), sizeof(T)))
return false;
else
{
this->OffValue = *(T*)(this->Address);
this->OffValueSaved = true;
return true;
}
}
#endif