mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-07-15 05:24:33 +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
|
#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);
|
bool SanitizeFileName(char *ret, int buffer_length);
|
||||||
|
|
||||||
//! Initializes all hooks for the engine.
|
// bool memPatch(void* address, void* payload, unsigned int payloadSize);
|
||||||
void initializeHooks(void);
|
bool memPatch(unsigned int address, void* payload, unsigned int payloadSize);
|
||||||
} // End NameSpace DX
|
} // End NameSpace DX
|
||||||
|
|
@ -189,8 +189,28 @@ namespace DX
|
||||||
return was_dirty;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
#v4.0:v100
|
#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\|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,5 @@
|
||||||
#include <LinkerAPI.h>
|
#include <LinkerAPI.h>
|
||||||
|
|
||||||
// Mod Loader Implementation
|
// Mod Loader Implementation
|
||||||
|
void serverProcessReplacement(unsigned int timeDelta);
|
||||||
bool conLoadMod(Linker::SimObject *obj,S32 argc, const char* argv[]);
|
bool conLoadMod(Linker::SimObject *obj,S32 argc, const char* argv[]);
|
||||||
|
|
@ -23,6 +23,8 @@ void serverProcessReplacement(unsigned int timeDelta)
|
||||||
currentCallables->mServerProcessPointer(timeDelta);
|
currentCallables->mServerProcessPointer(timeDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Con::errorf(0, "Bla -bla blallaaa");
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov ecx,serverthisptr
|
mov ecx,serverthisptr
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,36 @@ const char* congetInterpreterAddr(Linker::SimObject *obj, S32 argc, const char *
|
||||||
sprintf(test2,"B8%08XFFE0",endian(spr));
|
sprintf(test2,"B8%08XFFE0",endian(spr));
|
||||||
return test2;
|
return test2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initializeHooks()
|
||||||
|
{
|
||||||
|
// Replicates:
|
||||||
|
// memPatch("5BBBDC",getServPAddr());
|
||||||
|
// sprintf(test2,"B8 FFD089EC5DC3",endian(spr));
|
||||||
|
unsigned char serverProcessBytes[] = {
|
||||||
|
0xB8,
|
||||||
|
|
||||||
|
// Replacement processs
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
|
||||||
|
// Other code
|
||||||
|
0xFF,
|
||||||
|
0xD0,
|
||||||
|
0x89,
|
||||||
|
0xEC,
|
||||||
|
0x5D,
|
||||||
|
0xC3
|
||||||
|
};
|
||||||
|
|
||||||
|
// Write in the process address
|
||||||
|
unsigned int* serverProcessOffset = reinterpret_cast<unsigned int*>(&serverProcessBytes[1]);
|
||||||
|
*serverProcessOffset = reinterpret_cast<unsigned int>(*serverProcessReplacement);
|
||||||
|
|
||||||
|
DX::memPatch(0x5BBBDC, serverProcessBytes, sizeof(serverProcessBytes));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class CImmCompoundEffect
|
class CImmCompoundEffect
|
||||||
|
|
@ -106,7 +136,7 @@ class CImmDevice
|
||||||
lpinitT2DLL(); // The function was loaded, call TribesNext and move on to postTN Startup
|
lpinitT2DLL(); // The function was loaded, call TribesNext and move on to postTN Startup
|
||||||
|
|
||||||
// Initialize all engine hooks
|
// Initialize all engine hooks
|
||||||
DX::initializeHooks();
|
initializeHooks();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue