Help
chams party program detect
Español:
ayudenmen me aparece party program detect
Code:
#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