mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-02-19 14:43:38 +00:00
Implement a mempatch function and create a ServerProcess patch with it
This commit is contained in:
parent
cb9895a38e
commit
da08659d72
7 changed files with 59 additions and 6 deletions
|
|
@ -1,2 +1,2 @@
|
|||
#v4.0:v100
|
||||
Release|Win32|C:\Documents and Settings\NobodyBla\Desktop\T2AI\T2-CPP-master\|
|
||||
Release|Win32|C:\Documents and Settings\NobodyBla\Desktop\T2AI\T2-CPP\|
|
||||
|
|
|
|||
|
|
@ -57,6 +57,6 @@ namespace DX
|
|||
|
||||
bool SanitizeFileName(char *ret, int buffer_length);
|
||||
|
||||
//! Initializes all hooks for the engine.
|
||||
void initializeHooks(void);
|
||||
// bool memPatch(void* address, void* payload, unsigned int payloadSize);
|
||||
bool memPatch(unsigned int address, void* payload, unsigned int payloadSize);
|
||||
} // End NameSpace DX
|
||||
|
|
@ -189,8 +189,28 @@ namespace DX
|
|||
return was_dirty;
|
||||
}
|
||||
|
||||
void initializeHooks(void)
|
||||
bool memPatch(void* address, void* payload, unsigned int payloadSize)
|
||||
{
|
||||
DWORD oldProtect;
|
||||
bool success = VirtualProtect(address, payloadSize, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
// Come on Microsoft... why can't anything you make actually be good.
|
||||
// NOTE: This memcpy invocation was crashing the linker...
|
||||
//memcpy(address, payload, payloadSize);
|
||||
|
||||
unsigned char* destination = reinterpret_cast<unsigned char*>(address);
|
||||
unsigned char* sourceData = reinterpret_cast<unsigned char*>(payload);
|
||||
for (unsigned int iteration = 0; iteration < payloadSize; ++iteration)
|
||||
destination[iteration] = sourceData[iteration];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool memPatch(unsigned int address, void* payload, unsigned int payloadSize)
|
||||
{
|
||||
return memPatch(reinterpret_cast<void*>(address), payload, payloadSize);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue