Dedicated server inaccessible memory fix

The approach could likely be performed better, however this is a multithreaded operation and isn't very easy to debug. So far this allowed the server to start and change to every level. The root cause has to be identified when the server is stable
This commit is contained in:
Amos 2021-12-27 03:15:25 +01:00
parent a87eee1818
commit 0107656b1b
3 changed files with 27 additions and 1 deletions

View File

@ -5,6 +5,22 @@
* _opcodes.cpp
*-----------------------------------------------------------------------------*/
// TODO: Move to RTech::..
void HRTech_UnloadAsset(int64_t a1, int64_t a2)
{
// Return early if address is out of scope.
if (a2 <= 0x0000000000 || a2 >= 0xFFFFFFFFFF)
{
return;
}
return RTech_UnloadAsset(a1, a2);
}
void Opcodes_Hook()
{
DetourAttach((LPVOID*)&RTech_UnloadAsset, &HRTech_UnloadAsset);
}
#ifdef DEDICATED
void Dedicated_Init()
{
@ -174,7 +190,7 @@ void Dedicated_Init()
// RUNTIME BLOCK
//-------------------------------------------------------------------------
ADDRESS t0 = 0x00000001401D71E0;
t0.Patch({ 0xC3 });
//t0.Patch({ 0xC3 }); // RPak unload?
ADDRESS t1 = 0x0000000140456B50;
t1.Offset(0x292).Patch({ 0xE9, 0xEE, 0x00, 0x00, 0x00 });
ADDRESS t2 = 0x0000000140238DA0;

View File

@ -7,6 +7,9 @@ void Dedicated_Init();
void RuntimePtc_Init();
void RuntimePtc_Toggle();
// TEMP
void Opcodes_Hook();
namespace
{
///* -------------- ORIGIN ------------------------------------------------------------------------------------------------------------------------------------------------ */
@ -98,6 +101,10 @@ namespace
}
// TODO: Move to RTech::..
ADDRESS p_RTech_UnloadAsset = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x83\xEC\x28\x48\x85\xD2\x74\x40\x48\x8B\x05\x00\x00\x00\x00", "xxxxxxxxxxxx????");
void (*RTech_UnloadAsset)(int64_t a1, int64_t a2) = (void (*)(int64_t, int64_t))p_RTech_UnloadAsset.GetPtr(); /*48 83 EC 28 48 85 D2 74 40 48 8B 05 ? ? ? ?*/
void PrintOAddress() // Test the sigscan results
{
std::cout << "+--------------------------------------------------------+" << std::endl;

View File

@ -63,6 +63,9 @@ void Systems_Init()
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
// TEMP
Opcodes_Hook();
// Hook functions
IApplication_Attach();
CBaseClient_Attach();