diff --git a/r5dev/common/opcodes.cpp b/r5dev/common/opcodes.cpp index 77d7a77d..65d71602 100644 --- a/r5dev/common/opcodes.cpp +++ b/r5dev/common/opcodes.cpp @@ -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; diff --git a/r5dev/common/opcodes.h b/r5dev/common/opcodes.h index 538102d9..195278bc 100644 --- a/r5dev/common/opcodes.h +++ b/r5dev/common/opcodes.h @@ -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; diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index 7c7bdad1..5ffee716 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -63,6 +63,9 @@ void Systems_Init() DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); + // TEMP + Opcodes_Hook(); + // Hook functions IApplication_Attach(); CBaseClient_Attach();