Skip to content

Commit

Permalink
updated Patch class
Browse files Browse the repository at this point in the history
  • Loading branch information
Crspy committed Aug 18, 2018
1 parent a41cdc2 commit 084ad9d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions shared/Patch.cpp
Expand Up @@ -89,3 +89,32 @@ void plugin::patch::ReplaceFunction(int address, void *func, bool vp) {
void plugin::patch::ReplaceFunctionCall(int address, void *func, bool vp) {
RedirectCall(address, func, vp);
}

void plugin::patch::SetRaw(int address, void* value, size_t size, bool vp) {
injector::WriteMemoryRaw(GetGlobalAddress(address), value, size, vp);
}

void plugin::patch::GetRaw(int address,void* ret, size_t size, bool vp) {

injector::ReadMemoryRaw(GetGlobalAddress(address), ret, size, vp);
}

void plugin::patch::RedirectShortJump(int address, void* dest, bool vp) {

int GlobalAddress = GetGlobalAddress(address);
injector::WriteMemory<uint8_t>(GlobalAddress, 0xEB, vp);
if (dest)
injector::MakeRelativeOffset(GlobalAddress + 1, dest, 1, vp);
}

void plugin::patch::PutRetn(int address, unsigned short BytesToPop, bool vp) {
injector::MakeRET(GetGlobalAddress(address), BytesToPop, vp);
}

void plugin::patch::PutRetn0(int address,unsigned short BytesToPop, bool vp) {

int GlobalAddress = GetGlobalAddress(address);
injector::WriteMemory(GlobalAddress, 0x33, vp); // xor eax, eax
injector::WriteMemory(GlobalAddress + 1, 0xC0, vp);
injector::MakeRET(GlobalAddress + 2, BytesToPop, vp);
}
5 changes: 5 additions & 0 deletions shared/Patch.h
Expand Up @@ -33,6 +33,11 @@ class patch {
static unsigned int GetUInt(int address, bool vp = true);
static float GetFloat(int address, bool vp = true);
static void *GetPointer(int address, bool vp = true);
static void SetRaw(int address, void* value, size_t size, bool vp = true);
static void GetRaw(int address, void* ret, size_t size, bool vp = true);
static void RedirectShortJump(int address, void* dest = nullptr, bool vp = true);
static void PutRetn(int address, unsigned short BytesToPop = 0, bool vp = true);
static void PutRetn0(int address, unsigned short BytesToPop = 0, bool vp = true);

template <typename T>
static void Set(int address, T value, bool vp = true) {
Expand Down

0 comments on commit 084ad9d

Please sign in to comment.