From 2501c370449290fb9ba10e034d638e5f151589f8 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 1 Dec 2022 22:44:55 +0100 Subject: [PATCH 01/20] Globally convert all byte patterns to strings These get reconverted to masked byte patterns at runtime. With the signature map cache system, this will only happen when building the cache. --- r5dev/bsplib/bsplib.h | 10 ++-- r5dev/client/cdll_engine_int.h | 28 +++++------ r5dev/codecs/Miles/miles_impl.h | 4 +- r5dev/codecs/Miles/radshal_wasapi.h | 2 +- r5dev/common/netmessages.h | 2 +- r5dev/common/opcodes.cpp | 4 +- r5dev/common/opcodes.h | 60 ++++++++++++------------ r5dev/datacache/mdlcache.h | 24 +++++----- r5dev/ebisusdk/EbisuSDK.h | 6 +-- r5dev/engine/client/cl_ents_parse.h | 2 +- r5dev/engine/client/cl_main.h | 8 ++-- r5dev/engine/client/client.h | 14 +++--- r5dev/engine/client/clientstate.h | 12 ++--- r5dev/engine/cmodel_bsp.h | 14 +++--- r5dev/engine/common.h | 4 +- r5dev/engine/debugoverlay.h | 14 +++--- r5dev/engine/gl_matsysiface.h | 4 +- r5dev/engine/gl_rsurf.h | 8 ++-- r5dev/engine/gl_screen.h | 7 ++- r5dev/engine/host.h | 12 ++--- r5dev/engine/host_cmd.h | 18 +++---- r5dev/engine/host_state.h | 12 ++--- r5dev/engine/modelloader.h | 33 +++++++------ r5dev/engine/net.h | 16 +++---- r5dev/engine/net_chan.h | 4 +- r5dev/engine/server/server.h | 13 +++-- r5dev/engine/server/sv_main.h | 15 +++--- r5dev/engine/sys_dll.h | 2 +- r5dev/engine/sys_dll2.h | 19 ++++---- r5dev/engine/sys_engine.h | 4 +- r5dev/engine/sys_getmodes.h | 8 ++-- r5dev/engine/sys_mainwind.h | 4 +- r5dev/engine/sys_utils.h | 8 ++-- r5dev/engine/traceinit.h | 2 +- r5dev/filesystem/basefilesystem.h | 16 +++---- r5dev/filesystem/filesystem.h | 7 ++- r5dev/game/client/viewrender.h | 4 +- r5dev/game/server/ai_network.h | 5 +- r5dev/game/server/ai_networkmanager.h | 18 +++---- r5dev/game/server/detour_impl.h | 18 +++---- r5dev/game/server/fairfight_impl.h | 4 +- r5dev/game/server/gameinterface.h | 4 +- r5dev/game/shared/animation.h | 2 +- r5dev/inputsystem/inputsystem.h | 5 +- r5dev/launcher/IApplication.h | 14 +++--- r5dev/launcher/launcher.h | 4 +- r5dev/launcher/prx.h | 2 +- r5dev/materialsystem/cmaterialglue.h | 2 +- r5dev/materialsystem/cmaterialsystem.h | 15 +++--- r5dev/public/edict.h | 9 ++-- r5dev/public/idebugoverlay.h | 2 +- r5dev/rtech/rtech_game.h | 12 ++--- r5dev/rtech/rtech_utils.h | 16 +++---- r5dev/rtech/rui/rui.h | 6 +-- r5dev/rtech/stryder/stryder.h | 8 ++-- r5dev/server/persistence.h | 2 +- r5dev/server/vengineserver_impl.h | 10 ++-- r5dev/squirrel/sqapi.h | 26 +++++----- r5dev/squirrel/sqinit.h | 4 +- r5dev/squirrel/sqscript.h | 26 +++++----- r5dev/squirrel/sqstdaux.h | 6 +-- r5dev/squirrel/sqvm.h | 20 ++++---- r5dev/studiorender/studiorendercontext.h | 10 ++-- r5dev/tier0/commandline.h | 5 +- r5dev/tier0/jobthread.cpp | 10 ++-- r5dev/tier0/jobthread.h | 12 ++--- r5dev/tier0/memstd.h | 5 +- r5dev/tier0/platform_internal.h | 6 +-- r5dev/tier0/threadtools.h | 9 ++-- r5dev/tier0/tslist.h | 10 ++-- r5dev/tier1/IConVar.h | 8 ++-- r5dev/tier1/cmd.h | 12 ++--- r5dev/tier1/cvar.h | 5 +- r5dev/vgui/vgui_baseui_interface.h | 15 +++--- r5dev/vgui/vgui_fpspanel.h | 2 +- r5dev/vguimatsurface/MatSystemSurface.h | 13 ++--- r5dev/vpc/IAppSystem.h | 2 +- r5dev/vpc/interfaces.h | 3 +- r5dev/vpc/keyvalues.h | 32 ++++++------- r5dev/vphysics/QHull.h | 4 +- r5dev/vstdlib/callback.h | 4 +- r5dev/vstdlib/keyvaluessystem.h | 7 +-- r5dev/windows/id3dx.h | 2 +- 83 files changed, 402 insertions(+), 438 deletions(-) diff --git a/r5dev/bsplib/bsplib.h b/r5dev/bsplib/bsplib.h index c65c7df3..0ba9e83e 100644 --- a/r5dev/bsplib/bsplib.h +++ b/r5dev/bsplib/bsplib.h @@ -49,13 +49,13 @@ class VBspLib : public IDetour } virtual void GetFun(void) const { - p_BuildPropStaticFrustumCullMap = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x44\x89\x40\x18\x48\x89\x50\x10\x55"), "xxxxxxxxxxxx"); /*48 8B C4 44 89 40 18 48 89 50 10 55*/ + p_BuildPropStaticFrustumCullMap = g_GameDll.FindPatternSIMD("48 8B C4 44 89 40 18 48 89 50 10 55"); /*48 8B C4 44 89 40 18 48 89 50 10 55*/ v_BuildPropStaticFrustumCullMap = p_BuildPropStaticFrustumCullMap.RCast(); - //sub_1404365A0 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x83\xEC\x78\xF3\x41\x0F\x10\x48\x00"), "xxxxxxxxxxxx?").RCast(); - //sub_140270130 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x66\x0F\x6F\x15\x00\x00\x00\x00"), "xxxxxxxx????").RCast<__m128(*)(__m128*)>(); - //sub_14028F170 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x58\xF3\x41\x0F\x7E\x11"), "xxxxxxxxx").RCast(); - //sub_140257F20 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x49\x8B\xD9\x49\x8B\xF8\x48\x85\xD2"), "xxxx?xxxxxxxxxxxxxx").RCast<__int64(*)(void*, __int64, __m128i*, __int8*)>(); + //sub_1404365A0 = g_GameDll.FindPatternSIMD("48 8B C4 48 83 EC 78 F3 41 0F 10 48 ??").RCast(); + //sub_140270130 = g_GameDll.FindPatternSIMD("48 83 EC 28 66 0F 6F 15 ?? ?? ?? ??").RCast<__m128(*)(__m128*)>(); + //sub_14028F170 = g_GameDll.FindPatternSIMD("48 83 EC 58 F3 41 0F 7E 11").RCast(); + //sub_140257F20 = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 49 8B D9 49 8B F8 48 85 D2").RCast<__int64(*)(void*, __int64, __m128i*, __int8*)>(); } virtual void GetVar(void) const { diff --git a/r5dev/client/cdll_engine_int.h b/r5dev/client/cdll_engine_int.h index 7157eb74..8cf47f02 100644 --- a/r5dev/client/cdll_engine_int.h +++ b/r5dev/client/cdll_engine_int.h @@ -91,21 +91,21 @@ class VDll_Engine_Int : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CHLClient_LevelShutdown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x56\x41\x54\x41\x56\x48\x83\xEC\x28\x48\x8B\xF1"), "xxxxxxxxxxxxxx"); + p_CHLClient_LevelShutdown = g_GameDll.FindPatternSIMD("40 53 56 41 54 41 56 48 83 EC 28 48 8B F1"); #ifndef DEDICATED - p_CHLClient_PostInit = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\x3D\x00\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00"), "xxx?????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????"); - p_CHLClient_FrameStageNotify = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x38\x89\x15\x00\x00\x00\x00"), "xxxxxx????"); - p_CHLClient_GetAllClasses = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x89\x74\x24\x00"), "xxx????xxxxxxxxxxxxx?"); + p_CHLClient_PostInit = g_GameDll.FindPatternSIMD("48 83 3D ?? ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ??"); + p_CHLClient_FrameStageNotify = g_GameDll.FindPatternSIMD("48 83 EC 38 89 15 ?? ?? ?? ??"); + p_CHLClient_GetAllClasses = g_GameDll.FindPatternSIMD("48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 89 74 24 ??"); #endif // !DEDICATED #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CHLClient_LevelShutdown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xF9\x48\x8D\x0D\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxxx????"); + p_CHLClient_LevelShutdown = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 48 8D 0D ?? ?? ?? ??"); #ifndef DEDICATED - p_CHLClient_PostInit = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x48\x83\x3D\x00\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00"), "xxxxxxx?????xxx????"); - p_CHLClient_FrameStageNotify = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x89\x15\x00\x00\x00\x00"), "xxxxxx????"); - p_CHLClient_GetAllClasses = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00"), "xxx????xxxxxxxxxxxx????xxx????"); + p_CHLClient_PostInit = g_GameDll.FindPatternSIMD("48 83 EC 28 48 83 3D ?? ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ??"); + p_CHLClient_FrameStageNotify = g_GameDll.FindPatternSIMD("48 83 EC 28 89 15 ?? ?? ?? ??"); + p_CHLClient_GetAllClasses = g_GameDll.FindPatternSIMD("48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ??"); #endif // !DEDICATED #endif - p_CHLClient_HudProcessInput = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x0F\xB6\x0D\x00\x00\x00\x00\x88\x15\x00\x00\x00\x00"), "xxxxxxx????xx????"); + p_CHLClient_HudProcessInput = g_GameDll.FindPatternSIMD("48 83 EC 28 0F B6 0D ?? ?? ?? ?? 88 15 ?? ?? ?? ??"); #ifndef DEDICATED CHLClient_LevelShutdown = p_CHLClient_LevelShutdown.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 48 8D 0D ?? ?? ?? ??*/ CHLClient_PostInit = p_CHLClient_PostInit.RCast(); /*48 83 EC 28 48 83 3D ?? ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ??*/ @@ -116,13 +116,11 @@ class VDll_Engine_Int : public IDetour } virtual void GetVar(void) const { - gHLClient = g_GameDll.FindPatternSIMD(reinterpret_cast - ("\x48\x8D\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x30\x48\x8B\xF9"), - "xxx????xxxxxxxxxxxxx?xxxxxxxx").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + gHLClient = g_GameDll.FindPatternSIMD("48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 89 5C 24 ?? 57 48 83 EC 30 48 8B F9") + .ResolveRelativeAddressSelf(0x3, 0x7).RCast(); - g_pHLClient = g_GameDll.FindPatternSIMD(reinterpret_cast - ("\x41\x55\x48\x83\xEC\x00\x4C\x63\x91\x00\x00\x00\x00"), - "xxxxx?xxx????").FindPatternSelf("4C 8B", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pHLClient = g_GameDll.FindPatternSIMD("41 55 48 83 EC ?? 4C 63 91 ?? ?? ?? ??") + .FindPatternSelf("4C 8B", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/codecs/Miles/miles_impl.h b/r5dev/codecs/Miles/miles_impl.h index 5fd15e3d..07dbd741 100644 --- a/r5dev/codecs/Miles/miles_impl.h +++ b/r5dev/codecs/Miles/miles_impl.h @@ -28,11 +28,11 @@ class MilesCore : public IDetour } virtual void GetFun(void) const { - p_AIL_LogFunc = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\xDA\x48\x8D\x15\x00\x00\x00\x00"), "xxxxxxxxxxxx????"); + p_AIL_LogFunc = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B DA 48 8D 15 ?? ?? ?? ??"); v_AIL_LogFunc = p_AIL_LogFunc.RCast(); // 0x1409D1420 // 40 53 48 83 EC 20 48 8B DA 48 8D 15 ? ? ? ? // - p_Miles_Initialize = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\xFF\x0D\x00\x00\x00\x00\xC6\x05\x00\x00\x00\x00\x00"), "x????xx????xx?????").FollowNearCallSelf(); + p_Miles_Initialize = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? FF 0D ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ??").FollowNearCallSelf(); v_Miles_Initialize = p_Miles_Initialize.RCast(); // 0x14095A140 // E8 ? ? ? ? FF 0D ? ? ? ? C6 05 ? ? ? ? ? // diff --git a/r5dev/codecs/Miles/radshal_wasapi.h b/r5dev/codecs/Miles/radshal_wasapi.h index 29374b0c..8d38014a 100644 --- a/r5dev/codecs/Miles/radshal_wasapi.h +++ b/r5dev/codecs/Miles/radshal_wasapi.h @@ -13,7 +13,7 @@ class VRadShal : public IDetour } virtual void GetFun(void) const { - p_WASAPI_GetAudioDevice = g_RadAudioSystemDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x58\x20\x55\x56\x41\x54"), "xxxxxxxxxxx"); + p_WASAPI_GetAudioDevice = g_RadAudioSystemDll.FindPatternSIMD("48 8B C4 48 89 58 20 55 56 41 54"); // 0x18005AD10 // 48 8B C4 48 89 58 20 55 56 41 54 // } virtual void GetVar(void) const { } diff --git a/r5dev/common/netmessages.h b/r5dev/common/netmessages.h index 9d30c4d3..02ca6747 100644 --- a/r5dev/common/netmessages.h +++ b/r5dev/common/netmessages.h @@ -126,7 +126,7 @@ class HMM_Heartbeat : public IDetour } virtual void GetFun(void) const { - MM_Heartbeat__ToString = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x38\xE8\x00\x00\x00\x00\x3B\x05\x00\x00\x00\x00"), "xxxxx????xx????"); + MM_Heartbeat__ToString = g_GameDll.FindPatternSIMD("48 83 EC 38 E8 ?? ?? ?? ?? 3B 05 ?? ?? ?? ??"); // 48 83 EC 38 E8 ? ? ? ? 3B 05 ? ? ? ? } virtual void GetVar(void) const { } diff --git a/r5dev/common/opcodes.cpp b/r5dev/common/opcodes.cpp index 0ffdd67e..5a7b5e43 100644 --- a/r5dev/common/opcodes.cpp +++ b/r5dev/common/opcodes.cpp @@ -56,9 +56,7 @@ void Dedicated_Init() p_CHLClient_LevelShutdown.Patch({ 0xB8, 0x00, 0x00, 0x00, 0x00, 0xC3 }); // FUN --> RET | Return early in 'CHLClient::LevelShutdown()' during DLL shutdown. p_CHLClient_HudProcessInput.Patch({ 0xC3 }); // FUN --> RET | Return early in 'CHLClient::HudProcessInput()' to prevent infinite loop. - g_GameDll.FindPatternSIMD(reinterpret_cast( // MOV --> JMP | Skip virtual call during settings layout parsing (S0/S1/S2/S3). - "\x41\x85\xC8\x0F\x84"), "xxxxx").Offset(0x40).Patch({ 0xEB, 0x23 }); - + g_GameDll.FindPatternSIMD("41 85 C8 0F 84").Offset(0x40).Patch({ 0xEB, 0x23 }); // MOV --> JMP | Skip virtual call during settings layout parsing (S0/S1/S2/S3). } //------------------------------------------------------------------------- diff --git a/r5dev/common/opcodes.h b/r5dev/common/opcodes.h index f3b5b596..a8a481a0 100644 --- a/r5dev/common/opcodes.h +++ b/r5dev/common/opcodes.h @@ -123,94 +123,94 @@ class VOpcodes : public IDetour { #ifdef GAMEDLL_S3 /* -------------- OTHER ------------------------------------------------------------------------------------------------------------------------------------------------- */ - dst007 = /*0x14028F3B0*/ g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x44\x89\x40\x18\x48\x89\x50\x10\x55\x53\x56\x57\x41"), "xxxxxxxxxxxxxxxx"); - dst008 = /*0x140E3E110*/ g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x78\x48\x8B\x84\x24\x00\x00\x00\x00\x4D\x8B\xD8\x00"), "xxxxxxxx????xxx?"); + dst007 = /*0x14028F3B0*/ g_GameDll.FindPatternSIMD("48 8B C4 44 89 40 18 48 89 50 10 55 53 56 57 41"); + dst008 = /*0x140E3E110*/ g_GameDll.FindPatternSIMD("48 83 EC 78 48 8B 84 24 ?? ?? ?? ?? 4D 8B D8 ??"); /* -------------- ------- ----------------------------------------------------------------------------------------------------------------------------------------------- */ #endif // GAMEDLL_S3 //------------------------------------------------------------------------- - CShaderSystem__Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\xC6\x41\x10\x00"), "xxxx?xxxx?xxxxxxxxx"); + CShaderSystem__Init = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 C6 41 10 ??"); // 0x1403DF870 // 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 C6 41 10 00 // //------------------------------------------------------------------------- #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - CVGui__RunFrame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x56\x57\x48\x83\xEC\x20\x0F\xB6\x69\x5C"), "xxxx?xxxxxxxxxxx"); + CVGui__RunFrame = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 56 57 48 83 EC 20 0F B6 69 5C"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - CVGui__RunFrame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x57\x48\x83\xEC\x20\x48\x89\x5C\x24\x00\x48\x8B\xF9\x48\x89\x6C\x24\x00\x0F\xB6\x69\x5C"), "xxxxxxxxxx?xxxxxxx?xxxx"); + CVGui__RunFrame = g_GameDll.FindPatternSIMD("40 57 48 83 EC 20 48 89 5C 24 ?? 48 8B F9 48 89 6C 24 ?? 0F B6 69 5C"); #endif //------------------------------------------------------------------------- #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - CEngineVGui__Shutdown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x57\x41\x54\x48\x83\xEC\x38"), "xxxx?xxxxxxx"); + CEngineVGui__Shutdown = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 57 41 54 48 83 EC 38"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - CEngineVGui__Shutdown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x80\x3D\x00\x00\x00\x00\x00\x48\x8B\xD9"), "xxxx?xxxx?xxxxxxx?????xxx"); + CEngineVGui__Shutdown = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 80 3D ?? ?? ?? ?? ?? 48 8B D9"); #endif // 0x140282C90 // 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 80 3D ? ? ? ? ? 48 8B D9 // - CEngineVGui__ActivateGameUI = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\xF6\x81\x00\x00\x00\x00\x00\x48\x8B\xD9\x74\x08"), "xxxxxxxx?????xxxxx"); + CEngineVGui__ActivateGameUI = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 F6 81 ?? ?? ?? ?? ?? 48 8B D9 74 08"); // //------------------------------------------------------------------------- #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - CInputSystem__RunFrameIME = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x57\x41\x55"), "xxxxxx"); + CInputSystem__RunFrameIME = g_GameDll.FindPatternSIMD("48 8B C4 57 41 55"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - CInputSystem__RunFrameIME = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x57\x41\x54\x41\x55\x48\x83\xEC\x70"), "xxxxxxxxxx"); + CInputSystem__RunFrameIME = g_GameDll.FindPatternSIMD("40 57 41 54 41 55 48 83 EC 70"); #endif //------------------------------------------------------------------------- - Sys_InitGame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x41\x8B\xD8"), "xxxx?xxxx????xx?????xxx"); + Sys_InitGame = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 41 8B D8"); // 0x1402958D0 // 48 89 5C 24 ? 57 48 81 EC ? ? ? ? 80 3D ? ? ? ? ? 41 8B D8 // //------------------------------------------------------------------------- - gHost_Init_1 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x45\x33\xF6"), "xxxxxxxx????xxx"); // server Host_Init()? + gHost_Init_1 = g_GameDll.FindPatternSIMD("48 8B C4 41 56 48 81 EC ?? ?? ?? ?? 45 33 F6"); // server Host_Init()? // 0x140237B00 // 48 8B C4 41 56 48 81 EC ? ? ? ? 45 33 F6 // - gHost_Init_2 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x88\x4C\x24\x08\x53\x55\x56\x57\x48\x83\xEC\x68"), "xxxxxxxxxxxx"); // client Host_Init()? + gHost_Init_2 = g_GameDll.FindPatternSIMD("88 4C 24 08 53 55 56 57 48 83 EC 68"); // client Host_Init()? // 0x140236640 // 88 4C 24 08 53 55 56 57 48 83 EC 68 // //------------------------------------------------------------------------- - Host_Shutdown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x83\xEC\x00\x80\x3D\x00\x00\x00\x00\x00\x0F\x85\x00\x00\x00\x00\x8B\x15\x00\x00\x00\x00"), "xxxxxx?xx?????xx????xx????"); + Host_Shutdown = g_GameDll.FindPatternSIMD("48 8B C4 48 83 EC ?? 80 3D ?? ?? ?? ?? ?? 0F 85 ?? ?? ?? ?? 8B 15 ?? ?? ?? ??"); // 0x140239620 // 48 8B C4 48 83 EC ?? 80 3D ? ? ? ? ? 0F 85 ? ? ? ? 8B 15 ? ? ? ? // //------------------------------------------------------------------------- #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - Host_Disconnect = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x38\x48\x89\x7C\x24\x00\x0F\xB6\xF9"), "xxxxxxxx?xxx"); + Host_Disconnect = g_GameDll.FindPatternSIMD("48 83 EC 38 48 89 7C 24 ?? 0F B6 F9"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - Host_Disconnect = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x30\x0F\xB6\xD9"), "xxxxxxxxx"); + Host_Disconnect = g_GameDll.FindPatternSIMD("40 53 48 83 EC 30 0F B6 D9"); #endif // 0x14023CCA0 // 40 53 48 83 EC 30 0F B6 D9 // //------------------------------------------------------------------------- #ifndef CLIENT_DLL - Server_S2C_CONNECT_1 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x3B\x05\x00\x00\x00\x00\x74\x0C"), "xxx????xx"); + Server_S2C_CONNECT_1 = g_GameDll.FindPatternSIMD("48 3B 05 ?? ?? ?? ?? 74 0C"); #endif // !CLIENT_DLL //------------------------------------------------------------------------- - UpdateMaterialSystemConfig = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x80\x3D\x00\x00\x00\x00\x00\x0F\x84\x00\x00\x00\x00"), "xxxx?xxxxxxx?????xx????"); - UpdateCurrentVideoConfig = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x00\x41\x56\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00\x4C\x8B\xF1"), "xx?xxxxxx????xxx????xxx????xxx"); - HandleConfigFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x48\x81\xEC\x00\x00\x00\x00\x8B\xF1"), "xxxxx????xx"); - ResetPreviousGameState = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x44\x89\x3D\x00\x00\x00\x00\x00\x8B\x00\x24\x00"), "x????xxx?????x?x?").ResolveRelativeAddressSelf(0x1, 0x5); + UpdateMaterialSystemConfig = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 80 3D ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ??"); + UpdateCurrentVideoConfig = g_GameDll.FindPatternSIMD("40 55 ?? 41 56 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 4C 8B F1"); + HandleConfigFile = g_GameDll.FindPatternSIMD("40 56 48 81 EC ?? ?? ?? ?? 8B F1"); + ResetPreviousGameState = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 44 89 3D ?? ?? ?? ?? ?? 8B ?? 24 ??").ResolveRelativeAddressSelf(0x1, 0x5); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - LoadPlayerConfig = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x81\xEC\x00\x00\x00\x00\x48\x83\x3D\x00\x00\x00\x00\x00\x75\x0C"), "xxx????xxx?????xx"); + LoadPlayerConfig = g_GameDll.FindPatternSIMD("48 81 EC ?? ?? ?? ?? 48 83 3D ?? ?? ?? ?? ?? 75 0C"); #elif defined (GAMEDLL_S3) - LoadPlayerConfig = g_GameDll.FindPatternSIMD(reinterpret_cast("\x89\x4C\x24\x08\x48\x81\xEC\x00\x00\x00\x00\x48\x83\x3D\x00\x00\x00\x00\x00"), "xxxxxxx????xxx?????"); + LoadPlayerConfig = g_GameDll.FindPatternSIMD("89 4C 24 08 48 81 EC ?? ?? ?? ?? 48 83 3D ?? ?? ?? ?? ??"); #endif #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - GetEngineClientThread = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x65\x48\x8B\x04\x25\x00\x00\x00\x00\x48\x8B\xD9\xB9\x00\x00\x00\x00\x48\x8B\x10\x8B\x04\x11\x39\x05\x00\x00\x00\x00\x7F\x15"), "xxxxxxxxxxx????xxxx????xxxxxxxx????xx"); + GetEngineClientThread = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 65 48 8B 04 25 ?? ?? ?? ?? 48 8B D9 B9 ?? ?? ?? ?? 48 8B 10 8B 04 11 39 05 ?? ?? ?? ?? 7F 15"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - GetEngineClientThread = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x65\x48\x8B\x04\x25\x00\x00\x00\x00\x48\x8B\xD9\xB9\x00\x00\x00\x00\x48\x8B\x10\x8B\x04\x11\x39\x05\x00\x00\x00\x00\x7F\x21"), "xxxxxxxxxxx????xxxx????xxxxxxxx????xx"); + GetEngineClientThread = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 65 48 8B 04 25 ?? ?? ?? ?? 48 8B D9 B9 ?? ?? ?? ?? 48 8B 10 8B 04 11 39 05 ?? ?? ?? ?? 7F 21"); #endif #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - MatchMaking_Frame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x56\x41\x54\x41\x55\x48\x8D\xAC\x24\x00\x00\x00\x00"), "xxxxxxxxxxx????"); + MatchMaking_Frame = g_GameDll.FindPatternSIMD("40 55 56 41 54 41 55 48 8D AC 24 ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) - MatchMaking_Frame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x74\x24\x00\x55\x41\x54\x41\x57\x48\x8D\xAC\x24\x00\x00\x00\x00"), "xxxx?xxxxxxxxx????"); + MatchMaking_Frame = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 55 41 54 41 57 48 8D AC 24 ?? ?? ?? ??"); #elif defined (GAMEDLL_S3) - MatchMaking_Frame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x48\x8D\xA8\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x89\x78\x18"), "xxxxxxx????xxx????xxxx"); + MatchMaking_Frame = g_GameDll.FindPatternSIMD("48 8B C4 55 48 8D A8 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 89 78 18"); #endif - CWin32Surface_initStaticData = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\xE8\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\x48\x83\xC4\x28\xE9\x00\x00\x00\x00\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x33\xC9"), "xxxxx????xxx????xxxxx????xxxxxxxxx"); + CWin32Surface_initStaticData = g_GameDll.FindPatternSIMD("48 83 EC 28 E8 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 83 C4 28 E9 ?? ?? ?? ?? CC CC CC CC CC CC CC 33 C9"); // 48 83 EC 28 E8 ? ? ? ? 48 8D 0D ? ? ? ? 48 83 C4 28 E9 ? ? ? ? CC CC CC CC CC CC CC 33 C9 #if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1) - KeyboardLayout_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x33\xC9\xFF\x15\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00"), "xxxxxxxx????xxx????"); + KeyboardLayout_Init = g_GameDll.FindPatternSIMD("48 83 EC 28 33 C9 FF 15 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ??"); #endif //48 83 EC 28 33 C9 FF 15 ? ? ? ? 48 8D 0D ? ? ? ? } virtual void GetCon(void) const { } diff --git a/r5dev/datacache/mdlcache.h b/r5dev/datacache/mdlcache.h index 0c8e31fd..1da43644 100644 --- a/r5dev/datacache/mdlcache.h +++ b/r5dev/datacache/mdlcache.h @@ -132,49 +132,49 @@ class VMDLCache : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - p_CMDLCache__FindMDL = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x20\x4C\x8B\xF1\x0F\xB7\xDA"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxx"); + p_CMDLCache__FindMDL = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 20 4C 8B F1 0F B7 DA"); v_CMDLCache__FindMDL = p_CMDLCache__FindMDL.RCast(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC 20 4C 8B F1 0F B7 DA*/ - p_CMDLCache__GetStudioHDR = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xF1\x0F\xB7\xFA\x48\x8D\x0D\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxxxxxx????"); + p_CMDLCache__GetStudioHDR = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F1 0F B7 FA 48 8D 0D ?? ?? ?? ??"); v_CMDLCache__GetStudioHDR = p_CMDLCache__GetStudioHDR.RCast(); /*48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B F1 0F B7 FA 48 8D 0D ? ? ? ?*/ #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CMDLCache__GetHardwareData = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x48\x83\xEC\x20\x48\x89\x5C\x24\x00\x48\x8D\x0D\x00\x00\x00\x00"), "xxxxxxxxxx?xxx????"); + p_CMDLCache__GetHardwareData = g_GameDll.FindPatternSIMD("40 56 48 83 EC 20 48 89 5C 24 ?? 48 8D 0D ?? ?? ?? ??"); v_CMDLCache__GetHardwareData = p_CMDLCache__GetHardwareData.RCast(); /*40 56 48 83 EC 20 48 89 5C 24 ? 48 8D 0D ? ? ? ?*/ #else - p_CMDLCache__GetHardwareData = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x48\x8D\x0D\x00\x00\x00\x00\x0F\xB7\xDA\xFF\x15\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x14\x5B\x48\x8D\x0D\x00\x00\x00\x00\x48\x8B\x7C\xD0\x00\xFF\x15\x00\x00\x00\x00\x48\x8B\x1F"), "xxxx?xxxxxxxx????xxxxx????xxx????xxxxxxx????xxxx?xx????xxx"); + p_CMDLCache__GetHardwareData = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 8D 0D ?? ?? ?? ?? 0F B7 DA FF 15 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 8D 14 5B 48 8D 0D ?? ?? ?? ?? 48 8B 7C D0 ?? FF 15 ?? ?? ?? ?? 48 8B 1F"); v_CMDLCache__GetHardwareData = p_CMDLCache__GetHardwareData.RCast(); /*48 89 5C 24 ? 57 48 83 EC 20 48 8D 0D ? ? ? ? 0F B7 DA FF 15 ? ? ? ? 48 8B 05 ? ? ? ? 48 8D 14 5B 48 8D 0D ? ? ? ? 48 8B 7C D0 ? FF 15 ? ? ? ? 48 8B 1F*/ #endif #else - p_CMDLCache__FindMDL = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xF1\x0F\xB7\xEA"), "xxxx?xxxx?xxxx?xxxxxxxxxxx"); + p_CMDLCache__FindMDL = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F1 0F B7 EA"); v_CMDLCache__FindMDL = p_CMDLCache__FindMDL.RCast(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B F1 0F B7 EA*/ - p_CMDLCache__FindCachedMDL = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4D\x85\xC0\x74\x7A\x48\x89\x6C\x24\x00"), "xxxxxxxxx?"); + p_CMDLCache__FindCachedMDL = g_GameDll.FindPatternSIMD("4D 85 C0 74 7A 48 89 6C 24 ??"); v_CMDLCache__FindCachedMDL = p_CMDLCache__FindCachedMDL.RCast(); /*4D 85 C0 74 7A 48 89 6C 24 ?*/ - p_CMDLCache__FindUncachedMDL = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x20\x48\x8B\xE9\x0F\xB7\xFA"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxx"); + p_CMDLCache__FindUncachedMDL = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 20 48 8B E9 0F B7 FA"); v_CMDLCache__FindUncachedMDL = p_CMDLCache__FindUncachedMDL.RCast(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC 20 48 8B E9 0F B7 FA*/ - p_CMDLCache__GetStudioHDR = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8D\x0D\x00\x00\x00\x00\x0F\xB7\xDA\xFF\x15\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x14\x5B\x48\x8D\x0D\x00\x00\x00\x00\x48\x8B\x5C\xD0\x00\xFF\x15\x00\x00\x00\x00\x48\x8B\x03\x48\x8B\x48\x08"), "xxxxxxxxx????xxxxx????xxx????xxxxxxx????xxxx?xx????xxxxxxx"); + p_CMDLCache__GetStudioHDR = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8D 0D ?? ?? ?? ?? 0F B7 DA FF 15 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 8D 14 5B 48 8D 0D ?? ?? ?? ?? 48 8B 5C D0 ?? FF 15 ?? ?? ?? ?? 48 8B 03 48 8B 48 08"); v_CMDLCache__GetStudioHDR = p_CMDLCache__GetStudioHDR.RCast(); /*40 53 48 83 EC 20 48 8D 0D ? ? ? ? 0F B7 DA FF 15 ? ? ? ? 48 8B 05 ? ? ? ? 48 8D 14 5B 48 8D 0D ? ? ? ? 48 8B 5C D0 ? FF 15 ? ? ? ? 48 8B 03 48 8B 48 08*/ - p_CMDLCache__GetHardwareData = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x48\x8D\x0D\x00\x00\x00\x00\x0F\xB7\xDA\xFF\x15\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x14\x5B\x48\x8D\x0D\x00\x00\x00\x00\x48\x8B\x7C\xD0\x00\xFF\x15\x00\x00\x00\x00\x48\x8B\x1F"), "xxxx?xxxxxxxx????xxxxx????xxx????xxxxxxx????xxxx?xx????xxx"); + p_CMDLCache__GetHardwareData = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 8D 0D ?? ?? ?? ?? 0F B7 DA FF 15 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 8D 14 5B 48 8D 0D ?? ?? ?? ?? 48 8B 7C D0 ?? FF 15 ?? ?? ?? ?? 48 8B 1F"); v_CMDLCache__GetHardwareData = p_CMDLCache__GetHardwareData.RCast(); /*48 89 5C 24 ? 57 48 83 EC 20 48 8D 0D ? ? ? ? 0F B7 DA FF 15 ? ? ? ? 48 8B 05 ? ? ? ? 48 8D 14 5B 48 8D 0D ? ? ? ? 48 8B 7C D0 ? FF 15 ? ? ? ? 48 8B 1F*/ - p_CStudioHWDataRef__SetFlags = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x08\x4C\x8D\x14\x12"), "xxxxxxxx"); + p_CStudioHWDataRef__SetFlags = g_GameDll.FindPatternSIMD("48 83 EC 08 4C 8D 14 12"); v_CStudioHWDataRef__SetFlags = p_CStudioHWDataRef__SetFlags.RCast(); /*48 83 EC 08 4C 8D 14 12*/ #endif } virtual void GetVar(void) const { - m_MDLMutex = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\xBA\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\xFF\x15\x00\x00\x00\x00\x0F\xB6\x05\x00\x00\x00\x00"), "xxxxx????xxx????xx????xxx????") + m_MDLMutex = g_GameDll.FindPatternSIMD("48 83 EC 28 BA ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? FF 15 ?? ?? ?? ?? 0F B6 05 ?? ?? ?? ??") .FindPatternSelf("48 8D 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); m_MDLLock = p_CMDLCache__GetHardwareData.Offset(0x35).FindPatternSelf("48 8D 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); m_MDLDict = p_CMDLCache__FindMDL.FindPattern("48 8B 05").ResolveRelativeAddressSelf(0x3, 0x7).RCast*>(); - g_MDLCache = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x0D\x00\x00\x00\x00\x44\x0F\xB7\x82\x00\x00\x00\x00\x48\x8B\x01\x48\xFF\xA0\x30\x01\x00\x00"), "xxx????xxxx????xxxxxxxxxx") + g_MDLCache = g_GameDll.FindPatternSIMD("48 8B 0D ?? ?? ?? ?? 44 0F B7 82 ?? ?? ?? ?? 48 8B 01 48 FF A0 30 01 ?? ??") .ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } diff --git a/r5dev/ebisusdk/EbisuSDK.h b/r5dev/ebisusdk/EbisuSDK.h index 8ca7b356..165f076f 100644 --- a/r5dev/ebisusdk/EbisuSDK.h +++ b/r5dev/ebisusdk/EbisuSDK.h @@ -46,13 +46,13 @@ class VEbisuSDK : public IDetour } virtual void GetFun(void) const { - p_EbisuSDK_Tier0_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x80\x3D\x00\x00\x00\x00\x00\x0F\x85\x00\x02\x00\x00\x48\x89\x5C\x24\x20"), "xxxxxx????xxx?xxxxxxxx"); + p_EbisuSDK_Tier0_Init = g_GameDll.FindPatternSIMD("48 83 EC 28 80 3D ?? ?? ?? ?? ?? 0F 85 ?? 02 ?? ?? 48 89 5C 24 20"); EbisuSDK_Tier0_Init = p_EbisuSDK_Tier0_Init.RCast(); /*48 83 EC 28 80 3D ?? ?? ?? ?? 00 0F 85 ?? 02 00 00 48 89 5C 24 20*/ - p_EbisuSDK_CVar_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x57\x48\x83\xEC\x40\x83\x3D"), "xxxxxxxx"); + p_EbisuSDK_CVar_Init = g_GameDll.FindPatternSIMD("40 57 48 83 EC 40 83 3D"); EbisuSDK_CVar_Init = p_EbisuSDK_CVar_Init.RCast(); /*40 57 48 83 EC 40 83 3D*/ - p_EbisuSDK_SetState = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x0F\x84\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x74\x5B"), "xxx????xx?????xx????xx?????xx"); + p_EbisuSDK_SetState = g_GameDll.FindPatternSIMD("48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 74 5B"); EbisuSDK_SetState = p_EbisuSDK_SetState.RCast(); /*48 81 EC ? ? ? ? 80 3D ? ? ? ? ? 0F 84 ? ? ? ? 80 3D ? ? ? ? ? 74 5B*/ } virtual void GetVar(void) const diff --git a/r5dev/engine/client/cl_ents_parse.h b/r5dev/engine/client/cl_ents_parse.h index cba4ba0b..5e1fc492 100644 --- a/r5dev/engine/client/cl_ents_parse.h +++ b/r5dev/engine/client/cl_ents_parse.h @@ -15,7 +15,7 @@ class V_CL_Ents_Parse : public IDetour } virtual void GetFun(void) const { - p_CL_CopyExistingEntity = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x70\x4C\x63\x51\x28"), "xxxxxxxxxx"); + p_CL_CopyExistingEntity = g_GameDll.FindPatternSIMD("40 53 48 83 EC 70 4C 63 51 28"); v_CL_CopyExistingEntity = p_CL_CopyExistingEntity.RCast(); /*40 53 48 83 EC 70 4C 63 51 28*/ } virtual void GetVar(void) const { } diff --git a/r5dev/engine/client/cl_main.h b/r5dev/engine/client/cl_main.h index 697ed54c..caa5d5a6 100644 --- a/r5dev/engine/client/cl_main.h +++ b/r5dev/engine/client/cl_main.h @@ -22,11 +22,11 @@ class VCL_Main : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CL_ClearState = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x1D\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxx????xxx????"); - p_CL_EndMovie = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x83\xEC\x68\x80\x3D\x00\x00\x00\x00\x00"), "xxxxxxxxx?????"); + p_CL_ClearState = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B 1D ?? ?? ?? ??"); + p_CL_EndMovie = g_GameDll.FindPatternSIMD("48 8B C4 48 83 EC 68 80 3D ?? ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CL_ClearState = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x0D\x00\x00\x00\x00\x48\x8B\x01"), "xxxx?xxxx?xxxx????xxx????xxx"); - p_CL_EndMovie = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x80\x3D\x00\x00\x00\x00\x00\x74\x7B"), "xxxxxx?????xx"); + p_CL_ClearState = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48 8B 01"); + p_CL_EndMovie = g_GameDll.FindPatternSIMD("48 83 EC 28 80 3D ?? ?? ?? ?? ?? 74 7B"); #endif CL_ClearState = p_CL_ClearState.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48 8B 01*/ CL_EndMovie = p_CL_EndMovie.RCast(); /*48 83 EC 28 80 3D ?? ?? ?? ?? ?? 74 7B*/ diff --git a/r5dev/engine/client/client.h b/r5dev/engine/client/client.h index 775a91da..66cff761 100644 --- a/r5dev/engine/client/client.h +++ b/r5dev/engine/client/client.h @@ -128,17 +128,17 @@ class VClient : public IDetour } virtual void GetFun(void) const { - p_CClient_Connect = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x56\x57\x41\x56\x48\x83\xEC\x20\x41\x0F\xB6\xE9"), "xxxx?xxxx?xxxxxxxxxxxx"); + p_CClient_Connect = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 20 41 0F B6 E9"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - p_CClient_Disconnect = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x4C\x89\x40\x18\x4C\x89\x48\x20\x53\x56\x57\x48\x81\xEC\x00\x00\x00\x00\x83\xB9\x00\x00\x00\x00\x00\x49\x8B\xF8\x0F\xB6\xF2"), "xxxxxxxxxxxxxxxxx????xx?????xxxxxx"); + p_CClient_Disconnect = g_GameDll.FindPatternSIMD("48 8B C4 4C 89 40 18 4C 89 48 20 53 56 57 48 81 EC ?? ?? ?? ?? 83 B9 ?? ?? ?? ?? ?? 49 8B F8 0F B6 F2"); #else // !GAMEDLL_S0 || !GAMEDLL_S1 || !GAMEDLL_S2 - p_CClient_Disconnect = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x4C\x89\x40\x18\x4C\x89\x48\x20\x53\x56\x57\x48\x81\xEC\x00\x00\x00\x00\x83\xB9\x00\x00\x00\x00\x00\x49\x8B\xF8\x8B\xF2"), "xxxxxxxxxxxxxxxxx????xx?????xxxxx"); + p_CClient_Disconnect = g_GameDll.FindPatternSIMD("48 8B C4 4C 89 40 18 4C 89 48 20 53 56 57 48 81 EC ?? ?? ?? ?? 83 B9 ?? ?? ?? ?? ?? 49 8B F8 8B F2"); #endif - p_CClient_Clear = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x41\x56\x41\x57\x48\x83\xEC\x20\x48\x8B\xD9\x48\x89\x74"), "xxxxxxxxxxxxxxxx"); + p_CClient_Clear = g_GameDll.FindPatternSIMD("40 53 41 56 41 57 48 83 EC 20 48 8B D9 48 89 74"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CClient_ProcessStringCmd = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x4C\x8B\x42\x20"), "xxxxxxxx"); + p_CClient_ProcessStringCmd = g_GameDll.FindPatternSIMD("48 83 EC 28 4C 8B 42 20"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CClient_ProcessStringCmd = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x6C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x7A\x20"), "xxxx?xxxx????xxxx"); + p_CClient_ProcessStringCmd = g_GameDll.FindPatternSIMD("48 89 6C 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B 7A 20"); #endif // !GAMEDLL_S0 || !GAMEDLL_S1 v_CClient_Connect = p_CClient_Connect.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 20 41 0F B6 E9*/ @@ -148,7 +148,7 @@ class VClient : public IDetour } virtual void GetVar(void) const { - g_pClient = g_GameDll.FindPatternSIMD(reinterpret_cast("\x3B\x15\x00\x00\x00\x00\x7D\x33"), "xx????xx") + g_pClient = g_GameDll.FindPatternSIMD("3B 15 ?? ?? ?? ?? 7D 33") .FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } diff --git a/r5dev/engine/client/clientstate.h b/r5dev/engine/client/clientstate.h index f51b8881..91d54dcb 100644 --- a/r5dev/engine/client/clientstate.h +++ b/r5dev/engine/client/clientstate.h @@ -206,24 +206,24 @@ class VClientState : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CClientState__RunFrame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x83\xB9\x00\x00\x00\x00\x00"), "xxxx?xxxx????xx?????"); + p_CClientState__RunFrame = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 57 48 81 EC ?? ?? ?? ?? 83 B9 ?? ?? ?? ?? ??"); CClientState__RunFrame = p_CClientState__RunFrame.RCast(); - p_CClientState__Disconnect = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x57\x41\x56\x48\x83\xEC\x30\x0F\xB6\xEA"), "xxxx?xxxxxxxxxxx"); + p_CClientState__Disconnect = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 57 41 56 48 83 EC 30 0F B6 EA"); CClientState__Disconnect = p_CClientState__Disconnect.RCast(); /*48 89 5C 24 ?? 55 57 41 56 48 83 EC 30 0F B6 EA*/ #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CClientState__RunFrame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x81\xEC\x00\x00\x00\x00\x83\xB9\x00\x00\x00\x00\x00\x48\x8B\xD9\x7D\x0B"), "xxxxx????xx?????xxxxx"); + p_CClientState__RunFrame = g_GameDll.FindPatternSIMD("40 53 48 81 EC ?? ?? ?? ?? 83 B9 ?? ?? ?? ?? ?? 48 8B D9 7D 0B"); CClientState__RunFrame = p_CClientState__RunFrame.RCast(); - p_CClientState__Disconnect = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x57\x41\x54\x41\x55\x41\x57\x48\x83\xEC\x30\x44\x0F\xB6\xFA"), "xxxxxxxxxxxxxxxxx"); + p_CClientState__Disconnect = g_GameDll.FindPatternSIMD("40 56 57 41 54 41 55 41 57 48 83 EC 30 44 0F B6 FA"); CClientState__Disconnect = p_CClientState__Disconnect.RCast(); /*40 56 57 41 54 41 55 41 57 48 83 EC 30 44 0F B6 FA*/ #endif } virtual void GetVar(void) const { #ifndef DEDICATED - g_pClientState = g_GameDll.FindPatternSIMD(reinterpret_cast("\x0F\x84\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\x48\x83\xC4\x28"), "xx????xxx????xxxx").FindPatternSelf("48 8D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); /*0F 84 ? ? ? ? 48 8D 0D ? ? ? ? 48 83 C4 28*/ - g_pClientState_Shifted = g_GameDll.FindPatternSIMD(reinterpret_cast("\x80\x3D\x00\x00\x00\x00\x00\x74\x14\x66\x0F\x6E\x05\x00\x00\x00\x00"), "xx?????xxxxxx????").ResolveRelativeAddress(0x2, 0x7).RCast(); + g_pClientState = g_GameDll.FindPatternSIMD("0F 84 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 83 C4 28").FindPatternSelf("48 8D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); /*0F 84 ? ? ? ? 48 8D 0D ? ? ? ? 48 83 C4 28*/ + g_pClientState_Shifted = g_GameDll.FindPatternSIMD("80 3D ?? ?? ?? ?? ?? 74 14 66 0F 6E 05 ?? ?? ?? ??").ResolveRelativeAddress(0x2, 0x7).RCast(); #endif // DEDICATED } virtual void GetCon(void) const { } diff --git a/r5dev/engine/cmodel_bsp.h b/r5dev/engine/cmodel_bsp.h index a39a9baa..c374f641 100644 --- a/r5dev/engine/cmodel_bsp.h +++ b/r5dev/engine/cmodel_bsp.h @@ -66,21 +66,21 @@ class VModel_BSP : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_MOD_LoadPakForMap = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x81\xEC\x00\x00\x00\x00\x4C\x8B\xC1\x48\x8D\x15\x00\x00\x00\x00\x48\x8D\x4C\x24\x00\xE8\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00"), "xxx????xxxxxx????xxxx?x????xxx????"); + p_MOD_LoadPakForMap = g_GameDll.FindPatternSIMD("48 81 EC ?? ?? ?? ?? 4C 8B C1 48 8D 15 ?? ?? ?? ?? 48 8D 4C 24 ?? E8 ?? ?? ?? ?? 4C 8D 0D ?? ?? ?? ??"); v_MOD_LoadPakForMap = p_MOD_LoadPakForMap.RCast(); /*48 81 EC ? ? ? ? 4C 8B C1 48 8D 15 ? ? ? ? 48 8D 4C 24 ? E8 ? ? ? ? 4C 8D 0D ? ? ? ?*/ #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_Mod_LoadPakForMap = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x81\xEC\x00\x00\x00\x00\x0F\xB6\x05\x00\x00\x00\x00\x4C\x8D\x05\x00\x00\x00\x00\x84\xC0"), "xxx????xxx????xxx????xx"); + p_Mod_LoadPakForMap = g_GameDll.FindPatternSIMD("48 81 EC ?? ?? ?? ?? 0F B6 05 ?? ?? ?? ?? 4C 8D 05 ?? ?? ?? ?? 84 C0"); v_Mod_LoadPakForMap = p_Mod_LoadPakForMap.RCast(); /*48 81 EC ? ? ? ? 0F B6 05 ? ? ? ? 4C 8D 05 ? ? ? ? 84 C0*/ #endif - p_Mod_ProcessPakQueue = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x00\xF3\x0F\x10\x05\x00\x00\x00\x00\x32\xDB"), "xxxxx?xxxx????xx"); + p_Mod_ProcessPakQueue = g_GameDll.FindPatternSIMD("40 53 48 83 EC ?? F3 0F 10 05 ?? ?? ?? ?? 32 DB"); v_Mod_ProcessPakQueue = p_Mod_ProcessPakQueue.RCast(); /*40 53 48 83 EC ?? F3 0F 10 05 ? ? ? ? 32 DB*/ - sub_14045BAC0 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x4C\x89\x4C\x24\x00\x4C\x89\x44\x24\x00\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x60"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxx").RCast<__int64(*)(__int64(__fastcall* a1)(__int64, _DWORD*, __int64, _QWORD*), JobFifoLock_s* pFifoLock, __int64 a3, __int64 a4)>(); - sub_14045A1D0 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x4C\x24\x00\x4C\x89\x44\x24\x00\x48\x89\x54\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\x00"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxx?").RCast<__int64(*)(unsigned __int8(__fastcall* a1)(_QWORD), JobFifoLock_s* pFifoLock, __int64 a3, __int64 a4, volatile signed __int64* a5, char a6)>(); + sub_14045BAC0 = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 4C 89 4C 24 ?? 4C 89 44 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 60").RCast<__int64(*)(__int64(__fastcall* a1)(__int64, _DWORD*, __int64, _QWORD*), JobFifoLock_s* pFifoLock, __int64 a3, __int64 a4)>(); + sub_14045A1D0 = g_GameDll.FindPatternSIMD("4C 89 4C 24 ?? 4C 89 44 24 ?? 48 89 54 24 ?? 48 89 4C 24 ?? 55 53 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ??").RCast<__int64(*)(unsigned __int8(__fastcall* a1)(_QWORD), JobFifoLock_s* pFifoLock, __int64 a3, __int64 a4, volatile signed __int64* a5, char a6)>(); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - sub_140441220 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x48\x83\xEC\x20\x33\xED\x48\x39\x2D\x00\x00\x00\x00"), "xxxx?xxxxxxxxxx????").RCast(); + sub_140441220 = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 48 83 EC 20 33 ED 48 39 2D ?? ?? ?? ??").RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - sub_140441220 = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x33\xED\x48\x8D\x35\x00\x00\x00\x00\x48\x39\x2D\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxx????xxx????").RCast(); + sub_140441220 = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 33 ED 48 8D 35 ?? ?? ?? ?? 48 39 2D ?? ?? ?? ??").RCast(); #endif } virtual void GetVar(void) const diff --git a/r5dev/engine/common.h b/r5dev/engine/common.h index c60ffce3..6644ee43 100644 --- a/r5dev/engine/common.h +++ b/r5dev/engine/common.h @@ -18,8 +18,8 @@ class VCommon : public IDetour } virtual void GetFun(void) const { - p_COM_InitFilesystem = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9\x48\xC7\x44\x24\x00\x00\x00\x00\x00"), "xxxx?xxxx?xxxx????xxxxxxx?????"); - p_COM_ExplainDisconnection = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x50\x10\x4C\x89\x40\x18\x4C\x89\x48\x20\x48\x81\xEC\x00\x00\x00\x00"), "xxxxxxxxxxxxxxxxxx????"); + p_COM_InitFilesystem = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B F9 48 C7 44 24 ?? ?? ?? ?? ??"); + p_COM_ExplainDisconnection = g_GameDll.FindPatternSIMD("48 8B C4 48 89 50 10 4C 89 40 18 4C 89 48 20 48 81 EC ?? ?? ?? ??"); COM_InitFilesystem = p_COM_InitFilesystem.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B F9 48 C7 44 24 ?? ?? ?? ?? ??*/ COM_ExplainDisconnection = p_COM_ExplainDisconnection.RCast(); /*48 8B C4 48 89 50 10 4C 89 40 18 4C 89 48 20 48 81 EC ?? ?? ?? ??*/ diff --git a/r5dev/engine/debugoverlay.h b/r5dev/engine/debugoverlay.h index add82f8c..588c8f3c 100644 --- a/r5dev/engine/debugoverlay.h +++ b/r5dev/engine/debugoverlay.h @@ -200,15 +200,15 @@ class VDebugOverlay : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_DrawAllOverlays = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x48\x83\xEC\x50\x48\x8B\x05\x00\x00\x00\x00"), "xxxxxxxxx????"); - p_RenderBox = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x44\x89\x4C\x24\x00\x55\x41\x56"), "xxxx?xxxx?xxxx?xxxx?xxx"); + p_DrawAllOverlays = g_GameDll.FindPatternSIMD("40 55 48 83 EC 50 48 8B 05 ?? ?? ?? ??"); + p_RenderBox = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 44 89 4C 24 ?? 55 41 56"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_DrawAllOverlays = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x48\x83\xEC\x30\x48\x8B\x05\x00\x00\x00\x00\x0F\xB6\xE9"), "xxxxxxxxx????xxx"); - p_RenderBox = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x44\x89\x4C\x24\x00"), "xxxx?xxxx?xxxx?"); + p_DrawAllOverlays = g_GameDll.FindPatternSIMD("40 55 48 83 EC 30 48 8B 05 ?? ?? ?? ?? 0F B6 E9"); + p_RenderBox = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 44 89 4C 24 ??"); #endif - p_DestroyOverlay = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\xD9\x48\x8D\x0D\x00\x00\x00\x00\xFF\x15\x00\x00\x00\x00\x48\x63\x03"), "xxxxxxxxxxxx????xx????xxx"); - p_RenderWireframeSphere = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x41\x54\x41\x55\x48\x81\xEC\x00\x00\x00\x00"), "xxxxxxxxx????"); - p_RenderLine = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x74\x24\x00\x44\x89\x44\x24\x00\x57\x41\x56"), "xxxx?xxxx?xxx"); + p_DestroyOverlay = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B D9 48 8D 0D ?? ?? ?? ?? FF 15 ?? ?? ?? ?? 48 63 03"); + p_RenderWireframeSphere = g_GameDll.FindPatternSIMD("40 56 41 54 41 55 48 81 EC ?? ?? ?? ??"); + p_RenderLine = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 44 89 44 24 ?? 57 41 56"); v_DrawAllOverlays = p_DrawAllOverlays.RCast(); /*40 55 48 83 EC 30 48 8B 05 ?? ?? ?? ?? 0F B6 E9*/ v_DestroyOverlay = p_DestroyOverlay.RCast(); /*40 53 48 83 EC 20 48 8B D9 48 8D 0D ?? ?? ?? ?? FF 15 ?? ?? ?? ?? 48 63 03 */ diff --git a/r5dev/engine/gl_matsysiface.h b/r5dev/engine/gl_matsysiface.h index 1c7ec572..75aecc13 100644 --- a/r5dev/engine/gl_matsysiface.h +++ b/r5dev/engine/gl_matsysiface.h @@ -15,9 +15,7 @@ class VGL_MatSysIFace : public IDetour } virtual void GetFun(void) const { - p_InitMaterialSystem = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x83\xEC\x28\x48\x8B\x0D\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\x48\x8B\x01\xFF\x90\x00\x00\x00\x00\x48\x8B\x0D\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\x48\x8B\x01\xFF\x90\x00\x00\x00\x00"), - "xxxxxxx????xxx????xxxxx????xxx????xxx????xxxxx????"); + p_InitMaterialSystem = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 8D 15 ?? ?? ?? ?? 48 8B 01 FF 90 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48 8D 15 ?? ?? ?? ?? 48 8B 01 FF 90 ?? ?? ?? ??"); v_InitMaterialSystem = p_InitMaterialSystem.RCast(); } virtual void GetVar(void) const { } diff --git a/r5dev/engine/gl_rsurf.h b/r5dev/engine/gl_rsurf.h index e32e6eb6..9db7bb37 100644 --- a/r5dev/engine/gl_rsurf.h +++ b/r5dev/engine/gl_rsurf.h @@ -25,12 +25,12 @@ class VGL_RSurf : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - P_DrawWorldMeshes = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x48\x08\x53\x48\x83\xEC\x70"), "xxxxxxxxxxxx"); + P_DrawWorldMeshes = g_GameDll.FindPatternSIMD("48 8B C4 48 89 48 08 53 48 83 EC 70"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - P_DrawWorldMeshes = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x48\x08\x53\x57\x41\x55"), "xxxxxxxxxxx"); + P_DrawWorldMeshes = g_GameDll.FindPatternSIMD("48 8B C4 48 89 48 08 53 57 41 55"); #endif - P_DrawWorldMeshesDepthOnly = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x57\xB8\x00\x00\x00\x00"), "xxxx????"); - P_DrawWorldMeshesDepthAtTheEnd = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\x0D\x00\x00\x00\x00\x41\x8B\xF9"), "xxxx?xxxx?xxxxxxxx????xxx"); + P_DrawWorldMeshesDepthOnly = g_GameDll.FindPatternSIMD("40 56 57 B8 ?? ?? ?? ??"); + P_DrawWorldMeshesDepthAtTheEnd = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B 0D ?? ?? ?? ?? 41 8B F9"); V_DrawWorldMeshes = P_DrawWorldMeshes.RCast(); /*48 8B C4 48 89 48 08 53 57 41 55*/ V_DrawWorldMeshesDepthOnly = P_DrawWorldMeshesDepthOnly.RCast(); /*40 56 57 B8 ?? ?? ?? ??*/ diff --git a/r5dev/engine/gl_screen.h b/r5dev/engine/gl_screen.h index 45098583..d0438516 100644 --- a/r5dev/engine/gl_screen.h +++ b/r5dev/engine/gl_screen.h @@ -22,17 +22,16 @@ class VGL_Screen : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - SCR_BeginLoadingPlaque = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x0F\x29\x74\x24\x00\x48\x8B\xF9"), "xxxx?xxxx?xxxxxxxxx?xxx"); + SCR_BeginLoadingPlaque = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 0F 29 74 24 ?? 48 8B F9"); // 0x14022A4A0 // 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 30 0F 29 74 24 ? 48 8B F9 // #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - SCR_BeginLoadingPlaque = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x38\x0F\x29\x74\x24\x00\x48\x89\x5C\x24\x00"), "xxxxxxxx?xxxx?"); + SCR_BeginLoadingPlaque = g_GameDll.FindPatternSIMD("48 83 EC 38 0F 29 74 24 ?? 48 89 5C 24 ??"); // 0x14022A4A0 // 48 83 EC 38 0F 29 74 24 ? 48 89 5C 24 ? // #endif } virtual void GetVar(void) const { - scr_drawloading = g_GameDll.FindPatternSIMD(reinterpret_cast("\x0F\xB6\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x83\xEC\x28"), "xxx????xxxxxxxxxxxxx") - .ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + scr_drawloading = g_GameDll.FindPatternSIMD("0F B6 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 83 EC 28").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) scr_engineevent_loadingstarted = SCR_BeginLoadingPlaque.Offset(0x130).FindPatternSelf("C6 05 ?? ?? ?? ?? 01", CMemory::Direction::DOWN).ResolveRelativeAddress(0x2, 0x7).RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) diff --git a/r5dev/engine/host.h b/r5dev/engine/host.h index 6b8fc228..f7cab5fa 100644 --- a/r5dev/engine/host.h +++ b/r5dev/engine/host.h @@ -36,14 +36,14 @@ class VHost : public IDetour } virtual void GetFun(void) const { - p_Host_RunFrame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x58\x18\x48\x89\x70\x20\xF3\x0F\x11\x48\x00"), "xxxxxxxxxxxxxxx?"); + p_Host_RunFrame = g_GameDll.FindPatternSIMD("48 8B C4 48 89 58 18 48 89 70 20 F3 0F 11 48 ??"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_Host_RunFrame_Render = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\x1D\x00\x00\x00\x00\x33\xFF"), "xxxx?xxxxxxxx????xx"); + p_Host_RunFrame_Render = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 8B 1D ?? ?? ?? ?? 33 FF"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_Host_RunFrame_Render = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\x0D\x00\x00\x00\x00\x48\x85\xC9\x75\x34"), "xxxxxxxxx????xxxxx"); + p_Host_RunFrame_Render = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B 0D ?? ?? ?? ?? 48 85 C9 75 34"); #endif - p_Host_Error = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x48\x89\x54\x24\x00\x4C\x89\x44\x24\x00\x4C\x89\x4C\x24\x00\x53\x57\x48\x81\xEC\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxx?xxxxx????"); - p_VCR_EnterPausedState = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x65\x48\x8B\x04\x25\x00\x00\x00\x00\xBB\x00\x00\x00\x00\xC6\x05\x00\x00\x00\x00\x00"), "xxxxxxxxxxx????x????xx?????"); + p_Host_Error = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 48 89 54 24 ?? 4C 89 44 24 ?? 4C 89 4C 24 ?? 53 57 48 81 EC ?? ?? ?? ??"); + p_VCR_EnterPausedState = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 65 48 8B 04 25 ?? ?? ?? ?? BB ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ??"); v_Host_RunFrame = p_Host_RunFrame.RCast(); v_Host_RunFrame_Render = p_Host_Error.RCast(); @@ -52,7 +52,7 @@ class VHost : public IDetour } virtual void GetVar(void) const { - interval_per_tick = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x8B\xDC\x4D\x89\x4B\x20\x55\x56\x41\x54"), "xxxxxxxxxxx").FindPatternSelf("F3 0F 5E", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x4, 0x8).RCast(); + interval_per_tick = g_GameDll.FindPatternSIMD("4C 8B DC 4D 89 4B 20 55 56 41 54").FindPatternSelf("F3 0F 5E", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x4, 0x8).RCast(); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) g_bAbortServerSet = p_Host_Error.FindPattern("40 38 3D", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddress(3, 7).RCast(); host_abortserver = p_Host_Error.FindPattern("48 8D 0D", CMemory::Direction::DOWN, 512, 3).ResolveRelativeAddress(3, 7).RCast(); diff --git a/r5dev/engine/host_cmd.h b/r5dev/engine/host_cmd.h index 66dfae5f..05eff770 100644 --- a/r5dev/engine/host_cmd.h +++ b/r5dev/engine/host_cmd.h @@ -52,18 +52,18 @@ class VHostCmd : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_Host_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xD9\xFF\x15\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxxxx????xxxxx????"); - p_Host_NewGame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x56\x41\x54\x41\x57\x48\x81\xEC\x00\x00\x00\x00\xF2\x0F\x10\x05\x00\x00\x00\x00"), "xxxxxxxxxxx????xxxx????"); /*48 8B C4 56 41 54 41 57 48 81 EC ? ? ? ? F2 0F 10 05 ? ? ? ?*/ - p_Host_ChangeLevel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x56\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x49\x8B\xD8"), "xxxxxxxx????xxx"); - p_SetLaunchOptions = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x6C\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xE9\x48\x8B\x0D\x00\x00\x00\x00"), "xxxx?xxxxxxxxxxx????"); + p_Host_Init = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B D9 FF 15 ?? ?? ?? ??"); + p_Host_NewGame = g_GameDll.FindPatternSIMD("48 8B C4 56 41 54 41 57 48 81 EC ?? ?? ?? ?? F2 0F 10 05 ?? ?? ?? ??"); /*48 8B C4 56 41 54 41 57 48 81 EC ? ? ? ? F2 0F 10 05 ? ? ? ?*/ + p_Host_ChangeLevel = g_GameDll.FindPatternSIMD("40 53 56 41 56 48 81 EC ?? ?? ?? ?? 49 8B D8"); + p_SetLaunchOptions = g_GameDll.FindPatternSIMD("48 89 6C 24 ?? 57 48 83 EC 20 48 8B E9 48 8B 0D ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_Host_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xAC\x24\x00\x00\x00\x00\xB8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x2B\xE0\x48\x8B\xD9"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxx????x????x????xxxxxx"); - p_Host_NewGame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x00\x41\x54\x41\x55\x48\x81\xEC\x70\x04\x00\x00\xF2\x0F\x10\x05\x00\x00\x00\x0B"), "xxx?xxxxxxxxxxxxxxx???x"); - p_Host_ChangeLevel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x57\x41\x56\x48\x81\xEC\x00\x00\x00\x00"), "xxxxxxxx????"); - p_SetLaunchOptions = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\x1D\x00\x00\x00\x00\x48\x8B\xE9\x48\x85\xDB"), "xxxx?xxxx?xxxxxxxx????xxxxxx"); + p_Host_Init = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B D9"); + p_Host_NewGame = g_GameDll.FindPatternSIMD("48 8B C4 ?? 41 54 41 55 48 81 EC 70 04 ?? ?? F2 0F 10 05 ?? ?? ?? 0B"); + p_Host_ChangeLevel = g_GameDll.FindPatternSIMD("40 56 57 41 56 48 81 EC ?? ?? ?? ??"); + p_SetLaunchOptions = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 83 EC 20 48 8B 1D ?? ?? ?? ?? 48 8B E9 48 85 DB"); #endif #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2) - p_DFS_InitializeFeatureFlagDefinitions = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x53\x48\x8D\x68\xE8"), "xxxxxxxxx"); + p_DFS_InitializeFeatureFlagDefinitions = g_GameDll.FindPatternSIMD("48 8B C4 55 53 48 8D 68 E8"); v_DFS_InitializeFeatureFlagDefinitions = p_DFS_InitializeFeatureFlagDefinitions.RCast(); /*48 8B C4 55 53 48 8D 68 E8*/ #endif // !(GAMEDLL_S0) || !(GAMEDLL_S1) || !(GAMEDLL_S2) Host_Init = p_Host_Init.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B D9*/ diff --git a/r5dev/engine/host_state.h b/r5dev/engine/host_state.h index 5a4a0f15..fff6fcb0 100644 --- a/r5dev/engine/host_state.h +++ b/r5dev/engine/host_state.h @@ -82,16 +82,16 @@ class VHostState : public IDetour } virtual void GetFun(void) const { - p_CHostState_FrameUpdate = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x20\xF3\x0F\x11\x54\x24\x18"), "xxxxxxxxxxxxxxxx"); - p_CHostState_State_Run = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x58\x10\x48\x89\x70\x18\x48\x89\x78\x20\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xA8\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x0F\x29\x70\xC8\x45\x33\xE4"), "xxxxxxxxxxxxxxxxxxxxxxxxxxx????xxx????xxxxxxx"); + p_CHostState_FrameUpdate = g_GameDll.FindPatternSIMD("48 89 5C 24 08 48 89 6C 24 20 F3 0F 11 54 24 18"); + p_CHostState_State_Run = g_GameDll.FindPatternSIMD("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D A8 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 0F 29 70 C8 45 33 E4"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CHostState_State_GameShutDown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x56\x48\x83\xEC\x20\x8B\x05\x00\x00\x00\x00\x48\x8B\xF1"), "xxxx?xxxxxxx????xxx"); + p_CHostState_State_GameShutDown = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 56 48 83 EC 20 8B 05 ?? ?? ?? ?? 48 8B F1"); #elif defined (GAMEDLL_S2) - p_CHostState_State_GameShutDown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x8B\x05\x00\x00\x00\x00\x33\xFF\x48\x8B\xF1"), "xxxx?xxxx?xxxxxxx????xxxxx"); + p_CHostState_State_GameShutDown = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 8B 05 ?? ?? ?? ?? 33 FF 48 8B F1"); #elif defined (GAMEDLL_S3) - p_CHostState_State_GameShutDown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xD9\xE8\x00\x00\x00\x00\x48\x8B\x0D\x00\x00\x00\x00"), "xxxx?xxxxxxxxx????xxx????"); + p_CHostState_State_GameShutDown = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 8B D9 E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ??"); #endif - p_HostState_ChangeLevelMP = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xF9\x48\x8B\xF2\x8B\x0D\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxxxxx????"); + p_HostState_ChangeLevelMP = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 48 8B F2 8B 0D ?? ?? ?? ??"); CHostState_FrameUpdate = p_CHostState_FrameUpdate.RCast(); /*48 89 5C 24 08 48 89 6C 24 20 F3 0F 11 54 24 18*/ CHostState_State_Run = p_CHostState_State_Run.RCast(); /*48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D A8 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 0F 29 70 C8 45 33 E4*/ diff --git a/r5dev/engine/modelloader.h b/r5dev/engine/modelloader.h index db9b6842..27239220 100644 --- a/r5dev/engine/modelloader.h +++ b/r5dev/engine/modelloader.h @@ -98,23 +98,23 @@ class VModelLoader : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CModelLoader__FindModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x41\x55\x41\x56\x48\x8D\xAC\x24\x00\x00\x00\x00"), "xxxxxxxxxx????"); - p_CModelLoader__LoadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x57\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xFA"), "xxxxxxxx????xxx"); - p_CModelLoader__UnloadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x58\x18\x55\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xDA"), "xxxxxxxxxxx????xxx"); - p_CModelLoader__Studio_LoadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x56\x57\x41\x54\x41\x56\x48\x8D\xAC\x24\x00\x00\x00\x00"), "xxxx?xxxxxxxxxxx????"); - p_CModelLoader__Map_LoadModelGuts = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x54\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x41\x54\x41\x55\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\xFF\x05\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxx????xxx????xx????"); // BSP. - p_CModelLoader__Map_IsValid = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x53\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xDA"), "xxxxxxx????xxx"); - p_GetSpriteInfo = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x30\x4C\x8B\xAC\x24\x00\x00\x00\x00\xBE\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxxx????x????"); + p_CModelLoader__FindModel = g_GameDll.FindPatternSIMD("40 55 41 55 41 56 48 8D AC 24 ?? ?? ?? ??"); + p_CModelLoader__LoadModel = g_GameDll.FindPatternSIMD("40 53 57 41 56 48 81 EC ?? ?? ?? ?? 48 8B FA"); + p_CModelLoader__UnloadModel = g_GameDll.FindPatternSIMD("48 8B C4 48 89 58 18 55 48 81 EC ?? ?? ?? ?? 48 8B DA"); + p_CModelLoader__Studio_LoadModel = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 56 57 41 54 41 56 48 8D AC 24 ?? ?? ?? ??"); + p_CModelLoader__Map_LoadModelGuts = g_GameDll.FindPatternSIMD("48 89 54 24 ?? 48 89 4C 24 ?? 55 53 41 54 41 55 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? FF 05 ?? ?? ?? ??"); // BSP. + p_CModelLoader__Map_IsValid = g_GameDll.FindPatternSIMD("48 8B C4 53 48 81 EC ?? ?? ?? ?? 48 8B DA"); + p_GetSpriteInfo = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 54 41 55 41 56 41 57 48 83 EC 30 4C 8B AC 24 ?? ?? ?? ?? BE ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CModelLoader__FindModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x41\x57\x48\x83\xEC\x48\x80\x3A\x2A"), "xxxxxxxxxxx"); - p_CModelLoader__LoadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x57\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00"), "xxxxxxxx????xxx????"); - p_CModelLoader__UnloadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9\x33\xED"), "xxxx?xxxx?xxxx????xxxxx"); - p_CModelLoader__Studio_LoadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x56\x57\x41\x54\x41\x57\x48\x81\xEC\x00\x00\x00\x00"), "xxxx?xxxxxxxxxx????"); - p_CModelLoader__Map_LoadModelGuts = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x54\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x56\x57\x41\x54\x41\x55\x41\x57"), "xxxx?xxxx?xxxxxxxxxx"); // BSP. - p_CModelLoader__Map_IsValid = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xDA\x48\x85\xD2\x0F\x84\x00\x00\x00\x00\x80\x3A\x00\x0F\x84\x00\x00\x00\x00\x4C\x8B\xCA"), "xxxxx????xxxxxxxx????xxxxx????xxx"); - p_GetSpriteInfo = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x30\x4C\x8B\xBC\x24\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxxx????"); + p_CModelLoader__FindModel = g_GameDll.FindPatternSIMD("40 55 41 57 48 83 EC 48 80 3A 2A"); + p_CModelLoader__LoadModel = g_GameDll.FindPatternSIMD("40 53 57 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ??"); + p_CModelLoader__UnloadModel = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B F9 33 ED"); + p_CModelLoader__Studio_LoadModel = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 56 57 41 54 41 57 48 81 EC ?? ?? ?? ??"); + p_CModelLoader__Map_LoadModelGuts = g_GameDll.FindPatternSIMD("48 89 54 24 ?? 48 89 4C 24 ?? 55 53 56 57 41 54 41 55 41 57"); // BSP. + p_CModelLoader__Map_IsValid = g_GameDll.FindPatternSIMD("40 53 48 81 EC ?? ?? ?? ?? 48 8B DA 48 85 D2 0F 84 ?? ?? ?? ?? 80 3A ?? 0F 84 ?? ?? ?? ?? 4C 8B CA"); + p_GetSpriteInfo = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 54 41 55 41 56 41 57 48 83 EC 30 4C 8B BC 24 ?? ?? ?? ??"); #endif - p_BuildSpriteLoadName = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x4D\x8B\xF1\x48\x8B\xF2"), "xxxx?xxxx?xxxx?xxxx?xxxxx????xxxxxx"); + p_BuildSpriteLoadName = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 81 EC ?? ?? ?? ?? 4D 8B F1 48 8B F2"); CModelLoader__FindModel = p_CModelLoader__FindModel.RCast(); CModelLoader__LoadModel = p_CModelLoader__LoadModel.RCast(); @@ -128,8 +128,7 @@ class VModelLoader : public IDetour virtual void GetVar(void) const { g_pModelLoader = g_GameDll.FindPatternSIMD( - reinterpret_cast("\x48\x89\x4C\x24\x00\x53\x55\x56\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00"), - "xxxx?xxxxxxxxxxxxxx????").FindPatternSelf("48 ?? 0D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(3, 7).RCast(); + "48 89 4C 24 ?? 53 55 56 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ??").FindPatternSelf("48 ?? 0D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(3, 7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/engine/net.h b/r5dev/engine/net.h index ce6d1c40..da87af3d 100644 --- a/r5dev/engine/net.h +++ b/r5dev/engine/net.h @@ -70,16 +70,16 @@ class VNet : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - p_NET_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x41\x54\x41\x56\x41\x57\x48\x81\xEC\xC0\x01\x00"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - p_NET_Shutdown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x6C\x24\x18\x56\x57\x41\x56\x48\x83\xEC\x30\x83\xB9\xD8"), "xxxxxxxxxxxxxxxx"); + p_NET_Init = g_GameDll.FindPatternSIMD("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 48 89 7C 24 20 41 54 41 56 41 57 48 81 EC C0 01 ??"); + p_NET_Shutdown = g_GameDll.FindPatternSIMD("48 89 6C 24 18 56 57 41 56 48 83 EC 30 83 B9 D8"); #elif defined (GAMEDLL_S3) - p_NET_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x41\x54\x41\x56\x41\x57\x48\x81\xEC\xF0\x01\x00"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - p_NET_Shutdown = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x6C\x24\x18\x56\x57\x41\x56\x48\x83\xEC\x30\x83\xB9\xD0"), "xxxxxxxxxxxxxxxx"); + p_NET_Init = g_GameDll.FindPatternSIMD("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 48 89 7C 24 20 41 54 41 56 41 57 48 81 EC F0 01 ??"); + p_NET_Shutdown = g_GameDll.FindPatternSIMD("48 89 6C 24 18 56 57 41 56 48 83 EC 30 83 B9 D0"); #endif - p_NET_SetKey = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x48\x83\xEC\x20\x48\x8B\xF9\x41\xB8"), "xxxxxxxxxxxxxxxxxxxxxxxxx"); - p_NET_ReceiveDatagram = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xAC\x24\x50\xEB"), "xxxxxxxxxxxxxxxxxxxxxxxxx"); - p_NET_SendDatagram = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x41\x56\x41\x57\x48\x81\xEC\x00\x05\x00\x00"), "xxxxxxxxxxxxxxxxxxxxxxx?xxx"); - p_NET_PrintFunc = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x54\x24\x10\x4C\x89\x44\x24\x18\x4C\x89\x4C\x24\x20\xC3\x48"), "xxxxxxxxxxxxxxxxx"); + p_NET_SetKey = g_GameDll.FindPatternSIMD("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B F9 41 B8"); + p_NET_ReceiveDatagram = g_GameDll.FindPatternSIMD("48 89 74 24 18 48 89 7C 24 20 55 41 54 41 55 41 56 41 57 48 8D AC 24 50 EB"); + p_NET_SendDatagram = g_GameDll.FindPatternSIMD("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 81 EC ?? 05 ?? ??"); + p_NET_PrintFunc = g_GameDll.FindPatternSIMD("48 89 54 24 10 4C 89 44 24 18 4C 89 4C 24 20 C3 48"); v_NET_Init = p_NET_Init.RCast(); /*48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 48 89 7C 24 20 41 54 41 56 41 57 48 81 EC F0 01 00*/ v_NET_Shutdown = p_NET_Shutdown.RCast(); /*48 89 6C 24 18 56 57 41 56 48 83 EC 30 83 B9 D0*/ diff --git a/r5dev/engine/net_chan.h b/r5dev/engine/net_chan.h index 4ca19ec4..5710ec95 100644 --- a/r5dev/engine/net_chan.h +++ b/r5dev/engine/net_chan.h @@ -191,10 +191,10 @@ class VNetChannel : public IDetour } virtual void GetFun(void) const { - p_NetChan_Clear = g_GameDll.FindPatternSIMD(reinterpret_cast("\x88\x54\x24\x10\x53\x55\x57"), "xxxxxxx"); + p_NetChan_Clear = g_GameDll.FindPatternSIMD("88 54 24 10 53 55 57"); v_NetChan_Clear = p_NetChan_Clear.RCast(); /*88 54 24 10 53 55 57*/ - p_NetChan_ProcessMessages = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xFA"), "xxxx?xxxx?xxxx????xxx"); + p_NetChan_ProcessMessages = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B FA"); v_NetChan_ProcessMessages = p_NetChan_ProcessMessages.RCast();/*48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B FA*/ } virtual void GetVar(void) const { } diff --git a/r5dev/engine/server/server.h b/r5dev/engine/server/server.h index 9fcf3d72..aaefc07c 100644 --- a/r5dev/engine/server/server.h +++ b/r5dev/engine/server/server.h @@ -114,15 +114,15 @@ class VServer : public IDetour virtual void GetFun(void) const { #ifndef CLIENT_DLL - p_CServer_FrameJob = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x6C\x24\x00\x56\x41\x54\x41\x56"), "xxxx?xxxxx"); + p_CServer_FrameJob = g_GameDll.FindPatternSIMD("48 89 6C 24 ?? 56 41 54 41 56"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CServer_Authenticate = g_GameDll.FindPatternSIMD(reinterpret_cast("\x44\x89\x44\x24\x00\x55\x56\x57\x48\x8D\xAC\x24\x00\x00\x00\x00"), "xxxx?xxxxxxx????"); + p_CServer_Authenticate = g_GameDll.FindPatternSIMD("44 89 44 24 ?? 55 56 57 48 8D AC 24 ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) - p_CServer_Authenticate = g_GameDll.FindPatternSIMD(reinterpret_cast("\x44\x89\x44\x24\x00\x56\x57\x48\x81\xEC\x00\x00\x00\x00"), "xxxx?xxxxx????"); + p_CServer_Authenticate = g_GameDll.FindPatternSIMD("44 89 44 24 ?? 56 57 48 81 EC ?? ?? ?? ??"); #else - p_CServer_Authenticate = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x57\x41\x55\x41\x57\x48\x8D\xAC\x24\x00\x00\x00\x00"), "xxxxxxxxxxx????"); + p_CServer_Authenticate = g_GameDll.FindPatternSIMD("40 55 57 41 55 41 57 48 8D AC 24 ?? ?? ?? ??"); #endif - p_CServer_RejectConnection = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x4C\x24\x00\x53\x55\x56\x57\x48\x81\xEC\x00\x00\x00\x00\x49\x8B\xD9"), "xxxx?xxxxxxx????xxx"); + p_CServer_RejectConnection = g_GameDll.FindPatternSIMD("4C 89 4C 24 ?? 53 55 56 57 48 81 EC ?? ?? ?? ?? 49 8B D9"); v_CServer_FrameJob = p_CServer_FrameJob.RCast(); /*48 89 6C 24 ?? 56 41 54 41 56*/ v_CServer_ConnectClient = p_CServer_Authenticate.RCast(); /*40 55 57 41 55 41 57 48 8D AC 24 ?? ?? ?? ??*/ @@ -132,8 +132,7 @@ class VServer : public IDetour virtual void GetVar(void) const { #ifndef CLIENT_DLL - g_pServer = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x48\x0F\xBF\xD1"), "xxxx?xxxxxxxxx") - .FindPatternSelf("48 8D 3D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pServer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 0F BF D1").FindPatternSelf("48 8D 3D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #endif // !CLIENT_DLL } virtual void GetCon(void) const { } diff --git a/r5dev/engine/server/sv_main.h b/r5dev/engine/server/sv_main.h index d2c54ae5..0ff70d14 100644 --- a/r5dev/engine/server/sv_main.h +++ b/r5dev/engine/server/sv_main.h @@ -38,13 +38,13 @@ class HSV_Main : public IDetour } virtual void GetFun(void) const { - p_SV_InitGameDLL = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x81\xEC\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x0F\x85\x00\x00\x00\x00"), "xxx????x????xx?????xx????"); - p_SV_ShutdownGameDLL = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x80\x3D\x00\x00\x00\x00\x00\x0F\x84\x00\x00\x00\x00\x48\x8B\x0D\x00\x00\x00\x00\x48"), "xxxxxx?????xx????xxx????x"); - p_SV_CreateBaseline = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x48\x8B\x0D\x00\x00\x00\x00\x48\x85\xC9\x75\x07"), "xxxxxxx????xxxxx"); + p_SV_InitGameDLL = g_GameDll.FindPatternSIMD("48 81 EC ?? ?? ?? ?? E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 0F 85 ?? ?? ?? ??"); + p_SV_ShutdownGameDLL = g_GameDll.FindPatternSIMD("48 83 EC 28 80 3D ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48"); + p_SV_CreateBaseline = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 85 C9 75 07"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CGameServer__SpawnServer = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x55\x56\x57\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00"), "xxxxxxxxxxxxxx????"); + p_CGameServer__SpawnServer = g_GameDll.FindPatternSIMD("40 53 55 56 57 41 55 41 56 41 57 48 81 EC ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CGameServer__SpawnServer = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x53\x55\x56\x57\x41\x54\x41\x55\x41\x57"), "xxxxxxxxxxxxx"); + p_CGameServer__SpawnServer = g_GameDll.FindPatternSIMD("48 8B C4 53 55 56 57 41 54 41 55 41 57"); // 0x140312D80 // 48 8B C4 53 55 56 57 41 54 41 55 41 57 // #endif SV_InitGameDLL = p_SV_InitGameDLL.RCast(); @@ -54,9 +54,8 @@ class HSV_Main : public IDetour } virtual void GetVar(void) const { - s_bDedicated = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x89\x4C\x24\x00\x48\x89\x54\x24\x00\x4C\x89\x44\x24\x00\x4C\x89\x4C\x24\x00\x53\x57\xB8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x2B\xE0\x48\x8B\xD9\x48\x8D\xBC\x24\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x89\x7C\x24\x00\x48\x8D\x54\x24\x00\x33\xFF"), - "xxxx?xxxx?xxxx?xxxx?xxx????x????xxxxxxxxxx????x????xxxx?xxxx?xx").FindPatternSelf("40 38 3D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + s_bDedicated = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 48 89 54 24 ?? 4C 89 44 24 ?? 4C 89 4C 24 ?? 53 57 B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B D9 48 8D BC 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 89 7C 24 ?? 48 8D 54 24 ?? 33 FF") + .FindPatternSelf("40 38 3D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/engine/sys_dll.h b/r5dev/engine/sys_dll.h index 8f18549f..009640eb 100644 --- a/r5dev/engine/sys_dll.h +++ b/r5dev/engine/sys_dll.h @@ -24,7 +24,7 @@ class VSys_Dll : public IDetour } virtual void GetFun(void) const { - p_Sys_Error_Internal = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x48\x89\x74\x24\x10\x57\x48\x81\xEC\x30\x08\x00\x00\x48\x8B\xDA\x48\x8B\xF9\xE8\x00\x00\x00\xFF\x33\xF6\x48"), "xxxxxxxxxxxxxxxxxxxxxxxxx???xxxx"); + p_Sys_Error_Internal = g_GameDll.FindPatternSIMD("48 89 5C 24 08 48 89 74 24 10 57 48 81 EC 30 08 ?? ?? 48 8B DA 48 8B F9 E8 ?? ?? ?? FF 33 F6 48"); Sys_Error_Internal = p_Sys_Error_Internal.RCast(); /*48 89 5C 24 08 48 89 74 24 10 57 48 81 EC 30 08 00 00 48 8B DA 48 8B F9 E8 ?? ?? ?? FF 33 F6 48*/ } virtual void GetVar(void) const diff --git a/r5dev/engine/sys_dll2.h b/r5dev/engine/sys_dll2.h index 6a291072..35441755 100644 --- a/r5dev/engine/sys_dll2.h +++ b/r5dev/engine/sys_dll2.h @@ -86,19 +86,18 @@ class VSys_Dll2 : public IDetour } virtual void GetFun(void) const { - p_CEngineAPI_Connect = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\x48\x85\xC0\x48\x89\x15"), "xxxxxxx????xxx????xxxxxx"); + p_CEngineAPI_Connect = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 85 C0 48 89 15"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CEngineAPI_ModInit = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x4D\x8B\xF0"), "xxxx?xxxx?xxxx?xxxxxxxxxxxx????xxx"); - p_CEngineAPI_MainLoop = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x48\x81\xEC\x00\x00\x00\x00\x45\x33\xC9"), "xxxx?xxxx????xxx"); - p_PakFile_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x44\x88\x44\x24\x00\x56\x57\x41\x54\x41\x56\x41\x57\x48\x83\xEC\x20"), "xxxx?xxxx?xxxx?xxxxxxxxxxxx"); + p_CEngineAPI_ModInit = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 4D 8B F0"); + p_CEngineAPI_MainLoop = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 48 81 EC ?? ?? ?? ?? 45 33 C9"); + p_PakFile_Init = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 44 88 44 24 ?? 56 57 41 54 41 56 41 57 48 83 EC 20"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CEngineAPI_ModInit = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x4C\x24\x00\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x4D\x8B\xF8"), "xxxx?xxxx?xxxxxxxxxxxxxx????xxx"); - p_CEngineAPI_MainLoop = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x48\x8B\x15\x00\x00\x00\x00\x84\xC0\xB9\x00\x00\x00\x00"), "x????xxx????xxx????").FollowNearCallSelf(); - p_PakFile_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x44\x88\x44\x24\x00\x53\x55\x56\x57"), "xxxx?xxxx"); + p_CEngineAPI_ModInit = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 4C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 4D 8B F8"); + p_CEngineAPI_MainLoop = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8B 15 ?? ?? ?? ?? 84 C0 B9 ?? ?? ?? ??").FollowNearCallSelf(); + p_PakFile_Init = g_GameDll.FindPatternSIMD("44 88 44 24 ?? 53 55 56 57"); #endif - p_CEngineAPI_SetStartupInfo = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x48\x8B\xDA"), "xxxx??xxx????xx?????xxx"); - p_ResetMTVFTaskItem = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x48\x8B\x15\x00\x00\x00\x00\x48\x85\xD2\x0F\x84\x00\x00\x00\x00\x48\x8B\x0D\x00\x00\x00\x00\x48\x8B\x01\xFF\x90\x00\x00\x00\x00\x33\xC9\xE8\x00\x00\x00\x00\x0F\x28\x05\x00\x00\x00\x00\x0F\x28\x0D\x00\x00\x00\x00\x0F\x11\x05\x00\x00\x00\x00\x0F\x28\x05\x00\x00\x00\x00\x0F\x11\x0D\x00\x00\x00\x00\x0F\x28\x0D\x00\x00\x00\x00\x0F\x11\x05\x00\x00\x00\x00\x0F\x11\x0D\x00\x00\x00\x00\x48\xC7\x05\x00\x00\x00\x00\x00\x00\x00\x00\xFF\x15\x00\x00\x00\x00"), - "xxxxxxx????xxxxx????xxx????xxxxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????????xx????"); + p_CEngineAPI_SetStartupInfo = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? ?? 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 48 8B DA"); + p_ResetMTVFTaskItem = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 15 ?? ?? ?? ?? 48 85 D2 0F 84 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48 8B 01 FF 90 ?? ?? ?? ?? 33 C9 E8 ?? ?? ?? ?? 0F 28 05 ?? ?? ?? ?? 0F 28 0D ?? ?? ?? ?? 0F 11 05 ?? ?? ?? ?? 0F 28 05 ?? ?? ?? ?? 0F 11 0D ?? ?? ?? ?? 0F 28 0D ?? ?? ?? ?? 0F 11 05 ?? ?? ?? ?? 0F 11 0D ?? ?? ?? ?? 48 C7 05 ?? ?? ?? ?? ?? ?? ?? ?? FF 15 ?? ?? ?? ??"); CEngineAPI_Connect = p_CEngineAPI_Connect.RCast(); /*48 83 EC 28 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 85 C0 48 89 15 ?? ?? ?? ??*/ CEngineAPI_ModInit = p_CEngineAPI_ModInit.RCast(); /*48 89 5C 24 ?? 48 89 4C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 4D 8B F8*/ diff --git a/r5dev/engine/sys_engine.h b/r5dev/engine/sys_engine.h index b96bb1a3..17ef3428 100644 --- a/r5dev/engine/sys_engine.h +++ b/r5dev/engine/sys_engine.h @@ -37,9 +37,9 @@ class VEngine : public IDetour virtual void GetVar(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - g_pEngine = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x80\xB9\x00\x00\x00\x00\x00\x48\x8B\x15\x00\x00\x00\x00"), "xxxxxx?????xxx????").FindPatternSelf("48 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 300).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pEngine = g_GameDll.FindPatternSIMD("48 83 EC 28 80 B9 ?? ?? ?? ?? ?? 48 8B 15 ?? ?? ?? ??").FindPatternSelf("48 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 300).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - g_pEngine = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x80\xB9\x00\x00\x00\x00\x00\xBB\x00\x00\x00\x00"), "xxxxxxxx?????x????").FindPatternSelf("48 8B ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pEngine = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 80 B9 ?? ?? ?? ?? ?? BB ?? ?? ?? ??").FindPatternSelf("48 8B ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #endif } virtual void GetCon(void) const { } diff --git a/r5dev/engine/sys_getmodes.h b/r5dev/engine/sys_getmodes.h index d29ac17b..4bfbf825 100644 --- a/r5dev/engine/sys_getmodes.h +++ b/r5dev/engine/sys_getmodes.h @@ -24,11 +24,11 @@ class HVideoMode_Common : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CVideoMode_Common__CreateGameWindow = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x57\x48\x83\xEC\x38\x48\x8B\xF9\xE8\x00\x00\x00\x00"), "xxxxxxxxxxx????"); - p_CVideoMode_Common__CreateWindowClass = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x53\x57\x41\x56\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x4C\x8B\xF1"), "xxxxxxxxxx????xxx????xxx"); + p_CVideoMode_Common__CreateGameWindow = g_GameDll.FindPatternSIMD("40 56 57 48 83 EC 38 48 8B F9 E8 ?? ?? ?? ??"); + p_CVideoMode_Common__CreateWindowClass = g_GameDll.FindPatternSIMD("40 55 53 57 41 56 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 4C 8B F1"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CVideoMode_Common__CreateGameWindow = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x57\x48\x83\xEC\x28\x48\x8B\xF9\xE8\x00\x00\x00\x00\x48\x8B\xF0"), "xxxxxxxxxxx????xxx"); - p_CVideoMode_Common__CreateWindowClass = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x55\x53\x57\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9\xFF\x15\x00\x00\x00\x00"), "xxxxxxxx????xxx????xxxxx????"); + p_CVideoMode_Common__CreateGameWindow = g_GameDll.FindPatternSIMD("40 56 57 48 83 EC 28 48 8B F9 E8 ?? ?? ?? ?? 48 8B F0"); + p_CVideoMode_Common__CreateWindowClass = g_GameDll.FindPatternSIMD("40 55 53 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B F9 FF 15 ?? ?? ?? ??"); #endif CVideoMode_Common__CreateGameWindow = p_CVideoMode_Common__CreateGameWindow.RCast(); /*40 56 57 48 83 EC 28 48 8B F9 E8 ?? ?? ?? ?? 48 8B F0*/ CVideoMode_Common__CreateWindowClass = p_CVideoMode_Common__CreateWindowClass.RCast(); /*40 55 53 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B F9 FF 15 ?? ?? ?? ??*/ diff --git a/r5dev/engine/sys_mainwind.h b/r5dev/engine/sys_mainwind.h index 7775910f..eb1488aa 100644 --- a/r5dev/engine/sys_mainwind.h +++ b/r5dev/engine/sys_mainwind.h @@ -30,9 +30,9 @@ class VGame : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CGame__PlayStartupVideos = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x0F\x85\x00\x00\x00\x00\x48\x8B\x0D\x00\x00\x00\x00"), "xxxxxx????xx?????xx????xxx????"); + p_CGame__PlayStartupVideos = g_GameDll.FindPatternSIMD("48 8B C4 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 0F 85 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CGame__PlayStartupVideos = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x48\x8D\xA8\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00"), "xxxxxxx????xxx????xx?????"); + p_CGame__PlayStartupVideos = g_GameDll.FindPatternSIMD("48 8B C4 55 48 8D A8 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ??"); #endif v_CGame__PlayStartupVideos = p_CGame__PlayStartupVideos.RCast(); } diff --git a/r5dev/engine/sys_utils.h b/r5dev/engine/sys_utils.h index 33411771..771d130b 100644 --- a/r5dev/engine/sys_utils.h +++ b/r5dev/engine/sys_utils.h @@ -37,11 +37,11 @@ class VSys_Utils : public IDetour } virtual void GetFun(void) const { - p_Sys_Error = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x08\x48\x89\x54\x24\x10\x4C\x89\x44\x24\x18\x4C\x89\x4C\x24\x20\x53\x55\x41\x54\x41\x56\xB8\x58\x10\x00\x00\xE8"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - p_Sys_Warning = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x54\x24\x00\x4C\x89\x44\x24\x00\x4C\x89\x4C\x24\x00\x48\x83\xEC\x28\x4C\x8D\x44\x24\x00\xE8\x00\x00\x00\x00\x48\x83\xC4\x28\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x8B\x05\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxx?x????xxxxxxxxxxxxxxxxxxxxxxx?xxxx?xxxx?xx????"); - p_Sys_GetProcessUpTime = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x57\x48\x83\xEC\x30\x48\x8B\xF9\x8B\x0D\x00\x00\x00\x00"), "xxxxxxxxxxx????"); + p_Sys_Error = g_GameDll.FindPatternSIMD("48 89 4C 24 08 48 89 54 24 10 4C 89 44 24 18 4C 89 4C 24 20 53 55 41 54 41 56 B8 58 10 ?? ?? E8"); + p_Sys_Warning = g_GameDll.FindPatternSIMD("48 89 54 24 ?? 4C 89 44 24 ?? 4C 89 4C 24 ?? 48 83 EC 28 4C 8D 44 24 ?? E8 ?? ?? ?? ?? 48 83 C4 28 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC 48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 8B 05 ?? ?? ?? ??"); + p_Sys_GetProcessUpTime = g_GameDll.FindPatternSIMD("40 57 48 83 EC 30 48 8B F9 8B 0D ?? ?? ?? ??"); #ifndef DEDICATED - p_Con_NPrintf = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x48\x89\x54\x24\x00\x4C\x89\x44\x24\x00\x4C\x89\x4C\x24\x00\xC3"), "xxxx?xxxx?xxxx?xxxx?x"); + p_Con_NPrintf = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 48 89 54 24 ?? 4C 89 44 24 ?? 4C 89 4C 24 ?? C3"); #endif // !DEDICATED v_Sys_Error = p_Sys_Error.RCast(); /*48 89 4C 24 08 48 89 54 24 10 4C 89 44 24 18 4C 89 4C 24 20 53 55 41 54 41 56 B8 58 10 00 00 E8*/ v_Sys_Warning = p_Sys_Warning.RCast(); /*48 89 54 24 ?? 4C 89 44 24 ?? 4C 89 4C 24 ?? 48 83 EC 28 4C 8D 44 24 ?? E8 ?? ?? ?? ?? 48 83 C4 28 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC 48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 8B 05 ?? ?? ?? ??*/ diff --git a/r5dev/engine/traceinit.h b/r5dev/engine/traceinit.h index 82060eae..e8750b78 100644 --- a/r5dev/engine/traceinit.h +++ b/r5dev/engine/traceinit.h @@ -14,7 +14,7 @@ class VTraceInit : public IDetour } virtual void GetFun(void) const { - p_TRACEINIT = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\x05\x00\x00\x00\x00\x49\x8B\xF8\x48\x8B\xF2\x48\x85\xC0"), "xxxx?xxxx?xxxxxxxx????xxxxxxxxx"); + p_TRACEINIT = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B 05 ?? ?? ?? ?? 49 8B F8 48 8B F2 48 85 C0"); v_TRACEINIT = p_TRACEINIT.RCast(); /*48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B 05 ? ? ? ? 49 8B F8 48 8B F2 48 85 C0*/ } virtual void GetVar(void) const { } diff --git a/r5dev/filesystem/basefilesystem.h b/r5dev/filesystem/basefilesystem.h index 6ff7d78a..0f0da084 100644 --- a/r5dev/filesystem/basefilesystem.h +++ b/r5dev/filesystem/basefilesystem.h @@ -82,12 +82,12 @@ class VBaseFileSystem : public IDetour } virtual void GetFun(void) const { - p_CBaseFileSystem_Warning = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x4C\x24\x20\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48"), "xxxxxx??????????x"); - p_CBaseFileSystem_LoadFromVPK = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x49\x8B\xC0\x4C\x8D\x8C\x24\x00\x00\x00\x00"), "xxxx?xxxx????xxxxxxx????"); - p_CBaseFileSystem_LoadFromCache = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x49\x8B\xD8"), "xxxxx????xx?????xxx"); - p_CBaseFileSystem_MountVPKFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9\x4C\x8D\x05\x00\x00\x00\x00"), "xxxx?xxxx?xxxx????xxxxxx????"); - p_CBaseFileSystem_UnmountVPKFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xDA\x48\x8B\xF9\x48\x8B\xCB\x48\x8D\x15\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x85\xC0"), "xxxx?xxxxxxxxxxxxxxxxx????x????xxx"); - p_CBaseFileSystem_GetMountedVPKHandle = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x74\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9\x4C\x8D\x05\x00\x00\x00\x00"), "xxxx?xxxx????xxxxxx????"); + p_CBaseFileSystem_Warning = g_GameDll.FindPatternSIMD("4C 89 4C 24 20 C3 CC CC CC CC CC CC CC CC CC CC 48"); + p_CBaseFileSystem_LoadFromVPK = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 49 8B C0 4C 8D 8C 24 ?? ?? ?? ??"); + p_CBaseFileSystem_LoadFromCache = g_GameDll.FindPatternSIMD("40 53 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 49 8B D8"); + p_CBaseFileSystem_MountVPKFile = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B F9 4C 8D 05 ?? ?? ?? ??"); + p_CBaseFileSystem_UnmountVPKFile = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 8B DA 48 8B F9 48 8B CB 48 8D 15 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 85 C0"); + p_CBaseFileSystem_GetMountedVPKHandle = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B F9 4C 8D 05 ?? ?? ?? ??"); v_CBaseFileSystem_Warning = p_CBaseFileSystem_Warning.RCast(); /*4C 89 4C 24 20 C3 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 48*/ v_CBaseFileSystem_LoadFromVPK = p_CBaseFileSystem_LoadFromVPK.RCast(); /*48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 49 8B C0 4C 8D 8C 24 ?? ?? ?? ??*/ @@ -98,8 +98,8 @@ class VBaseFileSystem : public IDetour } virtual void GetVar(void) const { - g_pFileSystem = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\xE9\x00\x00\x00\x00"), - "xxx????xxx????xxx????xxx????xxx????x????").FindPattern("48 89", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pFileSystem = g_GameDll.FindPatternSIMD("48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? E9 ?? ?? ?? ??") + .FindPattern("48 89", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/filesystem/filesystem.h b/r5dev/filesystem/filesystem.h index 2a3e0c82..855fa4e0 100644 --- a/r5dev/filesystem/filesystem.h +++ b/r5dev/filesystem/filesystem.h @@ -46,11 +46,10 @@ class VFileSystem_Stdio : public IDetour virtual void GetFun(void) const { } virtual void GetVar(void) const { - g_pFullFileSystem = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x0D\x00\x00\x00\x00\x45\x33\xC0\x48\x83\xC1\x08\x48\x8B\x01"), - "xxx????xxxxxxxxxx").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pFullFileSystem = g_GameDll.FindPatternSIMD("48 8B 0D ?? ?? ?? ?? 45 33 C0 48 83 C1 08 48 8B 01").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); - g_pFileSystem_Stdio = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\xE9\x00\x00\x00\x00"), - "xxx????xxx????xxx????xxx????xxx????x????").FindPattern("48 89", CMemory::Direction::DOWN, 512, 1).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pFileSystem_Stdio = g_GameDll.FindPatternSIMD("48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? E9 ?? ?? ?? ??") + .FindPattern("48 89", CMemory::Direction::DOWN, 512, 1).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/game/client/viewrender.h b/r5dev/game/client/viewrender.h index b827b510..1ae468f7 100644 --- a/r5dev/game/client/viewrender.h +++ b/r5dev/game/client/viewrender.h @@ -45,12 +45,12 @@ class V_ViewRender : public IDetour } virtual void GetVar(void) const { - CMemory base = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\xF3\x0F\x10\x05\x00\x00\x00\x00\x00\x8B\x00"), "xxxx?xxxxxxxxx?????x?"); + CMemory base = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 57 48 83 EC 30 F3 0F 10 05 ?? ?? ?? ?? ?? 8B ??"); g_vecRenderOrigin = base.Offset(0x00).FindPatternSelf("F3 0F 10 05").ResolveRelativeAddressSelf(0x4, 0x8).RCast(); g_vecRenderAngles = base.Offset(0x30).FindPatternSelf("F3 0F 10 0D").ResolveRelativeAddressSelf(0x4, 0x8).RCast(); - g_pViewRender = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8D\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x8B\xC4"), "xxx????xxxxxxxxxxxxxx").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); /*48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC CC CC 48 8B C4*/ + g_pViewRender = g_GameDll.FindPatternSIMD("48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC CC CC 48 8B C4").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); /*48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC CC CC 48 8B C4*/ } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/game/server/ai_network.h b/r5dev/game/server/ai_network.h index 1a696a07..b4d111e6 100644 --- a/r5dev/game/server/ai_network.h +++ b/r5dev/game/server/ai_network.h @@ -62,13 +62,12 @@ class VAI_Network : public IDetour } virtual void GetFun(void) const { - p_CAI_Network__DebugConnectMsg = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x4C\x24\x00\x48\x83\xEC\x18"), "xxxx?xxxx"); + p_CAI_Network__DebugConnectMsg = g_GameDll.FindPatternSIMD("4C 89 4C 24 ?? 48 83 EC 18"); v_CAI_Network__DebugConnectMsg = p_CAI_Network__DebugConnectMsg.RCast(); /*4C 89 4C 24 ?? 48 83 EC 18*/ } virtual void GetVar(void) const { - g_pAINetwork = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x4C\x63\x91\x00\x00\x00\x00"), "xxxx?xxx????") - .FindPatternSelf("48 8B").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pAINetwork = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 4C 63 91 ?? ?? ?? ??").FindPatternSelf("48 8B").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/game/server/ai_networkmanager.h b/r5dev/game/server/ai_networkmanager.h index 83ad21b2..86849396 100644 --- a/r5dev/game/server/ai_networkmanager.h +++ b/r5dev/game/server/ai_networkmanager.h @@ -79,31 +79,31 @@ class VAI_NetworkManager : public IDetour } virtual void GetFun(void) const { - p_CAI_NetworkManager__ShouldRebuild = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\xD9\x48\x8B\x0D\x00\x00\x00\x00\x8B\x41\x6C"), "xxxxxxxxxxxx????xxx"); + p_CAI_NetworkManager__ShouldRebuild = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B D9 48 8B 0D ?? ?? ?? ?? 8B 41 6C"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CAI_NetworkManager__LoadNetworkGraph = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x44\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x57\x41\x54\x41\x55\x41\x56"), "xxxx?xxxx?xxxxxxxxx"); + p_CAI_NetworkManager__LoadNetworkGraph = g_GameDll.FindPatternSIMD("4C 89 44 24 ?? 48 89 4C 24 ?? 55 53 57 41 54 41 55 41 56"); CAI_NetworkManager__LoadNetworkGraph = p_CAI_NetworkManager__LoadNetworkGraph.RCast(); /*4C 89 44 24 ?? 48 89 4C 24 ?? 55 53 57 41 54 41 55 41 56*/ #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CAI_NetworkManager__LoadNetworkGraph = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x44\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xFA"), "xxxx?xxxx?xxxxxxxxxxxxxxxx?xxx????xxx"); + p_CAI_NetworkManager__LoadNetworkGraph = g_GameDll.FindPatternSIMD("4C 89 44 24 ?? 48 89 4C 24 ?? 55 53 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 48 8B FA"); CAI_NetworkManager__LoadNetworkGraph = p_CAI_NetworkManager__LoadNetworkGraph.RCast(); /*4C 89 44 24 ?? 48 89 4C 24 ?? 55 53 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 48 8B FA*/ #endif #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CAI_NetworkBuilder__Build = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x4C\x24\x00\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x30\x48\x63\xBA\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxx????"); + p_CAI_NetworkBuilder__Build = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 4C 24 ?? 57 41 54 41 55 41 56 41 57 48 83 EC 30 48 63 BA ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CAI_NetworkBuilder__Build = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x54\x24\x00\x48\x89\x4C\x24\x00\x53\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x38\x8B\xB2\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxxxxxxxxxx????"); + p_CAI_NetworkBuilder__Build = g_GameDll.FindPatternSIMD("48 89 54 24 ?? 48 89 4C 24 ?? 53 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 38 8B B2 ?? ?? ?? ??"); #endif CAI_NetworkManager__ShouldRebuild = p_CAI_NetworkManager__ShouldRebuild.RCast(); /*40 53 48 83 EC 20 48 8B D9 48 8B 0D ?? ?? ?? ?? 8B 41 6C*/ CAI_NetworkBuilder__Build = p_CAI_NetworkBuilder__Build.RCast(); /*48 89 54 24 ?? 48 89 4C 24 ?? 53 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 38 8B B2 ?? ?? ?? ??*/ } virtual void GetVar(void) const { - g_nAiNodeClusters = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x0F\xBF\x12"), "xxxx") + g_nAiNodeClusters = g_GameDll.FindPatternSIMD("4C 0F BF 12") .FindPatternSelf("83 3D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x2, 0x7).RCast(); - g_pppAiNodeClusters = g_GameDll.FindPatternSIMD(reinterpret_cast("\xF3\x0F\x10\x52\x00\x4C\x8B\xCA"), "xxxx?xxx") + g_pppAiNodeClusters = g_GameDll.FindPatternSIMD("F3 0F 10 52 ?? 4C 8B CA") .FindPatternSelf("48 8B 35", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); - g_nAiNodeClusterLinks = g_GameDll.FindPatternSIMD(reinterpret_cast("\x49\xFF\xC0\x48\x83\xC2\x04\x4D\x3B\xC2\x7C\xD4"), "xxxxxxxxxxxx") + g_nAiNodeClusterLinks = g_GameDll.FindPatternSIMD("49 FF C0 48 83 C2 04 4D 3B C2 7C D4") .FindPatternSelf("8B 3D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x2, 0x6).RCast(); - g_pppAiNodeClusterLinks = g_GameDll.FindPatternSIMD(reinterpret_cast("\xF3\x0F\x10\x52\x00\x4C\x8B\xCA"), "xxxx?xxx") + g_pppAiNodeClusterLinks = g_GameDll.FindPatternSIMD("F3 0F 10 52 ?? 4C 8B CA") .FindPatternSelf("4C 8B 1D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } diff --git a/r5dev/game/server/detour_impl.h b/r5dev/game/server/detour_impl.h index 73d10643..538fa2ed 100644 --- a/r5dev/game/server/detour_impl.h +++ b/r5dev/game/server/detour_impl.h @@ -71,15 +71,15 @@ class VRecast : public IDetour { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_Detour_LevelInit = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x45\x33\xF6\x48\x8D\x3D\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxxxx????xxxxxx????"); - p_Detour_FreeNavMesh = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x30\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00"), "xxxxxxxxxx?xxxx?"); + p_Detour_LevelInit = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 45 33 F6 48 8D 3D ?? ?? ?? ??"); + p_Detour_FreeNavMesh = g_GameDll.FindPatternSIMD("40 53 48 83 EC 30 48 89 6C 24 ?? 48 89 74 24 ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_Detour_LevelInit = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x45\x33\xE4"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxx????xxx????xxx"); - p_Detour_FreeNavMesh = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x30\x48\x89\x6C\x24\x00\x48\x8B\xD9"), "xxxxxxxxxx?xxx"); + p_Detour_LevelInit = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 45 33 E4"); + p_Detour_FreeNavMesh = g_GameDll.FindPatternSIMD("40 53 48 83 EC 30 48 89 6C 24 ?? 48 8B D9"); #endif - p_dtNavMesh__Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x44\x24\x00\x53\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x0F\x10\x11"), "xxxx?xxxxxx????xxx"); - p_dtNavMesh__addTile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x44\x89\x4C\x24\x00\x41\x55"), "xxxx?xx"); - p_dtNavMesh__isPolyReachable = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x49\x63\xF1"), "xxxx?xxxx?xxxx?xxxxx"); + p_dtNavMesh__Init = g_GameDll.FindPatternSIMD("4C 89 44 24 ?? 53 41 56 48 81 EC ?? ?? ?? ?? 0F 10 11"); + p_dtNavMesh__addTile = g_GameDll.FindPatternSIMD("44 89 4C 24 ?? 41 55"); + p_dtNavMesh__isPolyReachable = g_GameDll.FindPatternSIMD("48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 49 63 F1"); v_Detour_LevelInit = p_Detour_LevelInit.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 45 33 E4*/ v_Detour_FreeNavMesh = p_Detour_FreeNavMesh.RCast(); @@ -89,9 +89,9 @@ class VRecast : public IDetour } virtual void GetVar(void) const { - g_pNavMesh = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x54\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x02"), "xxxx?xxxx?xxxxxxxxxxxxxxxx?xxx????xxx") + g_pNavMesh = g_GameDll.FindPatternSIMD("48 89 54 24 ?? 48 89 4C 24 ?? 55 53 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 48 8B 02") .FindPatternSelf("48 8D 3D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); - g_pNavMeshQuery = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x56\x57\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x48\x63\xD9"), "xxxx?xxxx?xxxxxxx????xxx") + g_pNavMeshQuery = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 81 EC ?? ?? ?? ?? 48 63 D9") .FindPatternSelf("48 89 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } diff --git a/r5dev/game/server/fairfight_impl.h b/r5dev/game/server/fairfight_impl.h index cca9bbbe..76ddf6c9 100644 --- a/r5dev/game/server/fairfight_impl.h +++ b/r5dev/game/server/fairfight_impl.h @@ -16,9 +16,9 @@ class VFairFight : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - FairFight_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x57\x41\x57\x48\x83\xEC\x30\x8B\x81\x00\x00\x00\x00"), "xxxxxxxxxxx????"); + FairFight_Init = g_GameDll.FindPatternSIMD("40 53 57 41 57 48 83 EC 30 8B 81 ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - FairFight_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x8B\x81\xB0\x03\x00\x00\x48\x8B\xD9\xC6"), "xxxxxxxxxxxxxxxx"); + FairFight_Init = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 8B 81 B0 03 ?? ?? 48 8B D9 C6"); #endif // 0x140303AE0 // 40 53 48 83 EC 20 8B 81 ? ? ? ? 48 8B D9 C6 81 ? ? ? ? ? // } virtual void GetVar(void) const { } diff --git a/r5dev/game/server/gameinterface.h b/r5dev/game/server/gameinterface.h index 8dc11315..f747a0f1 100644 --- a/r5dev/game/server/gameinterface.h +++ b/r5dev/game/server/gameinterface.h @@ -42,7 +42,7 @@ class VServerGameDLL : public IDetour virtual void GetFun(void) const { #if defined(GAMEDLL_S3) - p_CServerGameDLL__OnReceivedSayTextMessage = g_GameDll.FindPatternSIMD(reinterpret_cast("\x85\xD2\x0F\x8E\x00\x00\x00\x00\x4C\x8B\xDC"), "xxxx????xxx"); + p_CServerGameDLL__OnReceivedSayTextMessage = g_GameDll.FindPatternSIMD("85 D2 0F 8E ?? ?? ?? ?? 4C 8B DC"); CServerGameDLL__OnReceivedSayTextMessage = p_CServerGameDLL__OnReceivedSayTextMessage.RCast(); #endif @@ -50,7 +50,7 @@ class VServerGameDLL : public IDetour virtual void GetVar(void) const { g_pServerGameDLL = p_SV_CreateBaseline.Offset(0x0).FindPatternSelf("48 8B", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).Deref().RCast(); - g_pServerGameClients = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x0F\xB7\x51\x14"), "xxxx?xxxx????xxxx"). + g_pServerGameClients = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 0F B7 51 14"). FindPatternSelf("48 8B 0D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } diff --git a/r5dev/game/shared/animation.h b/r5dev/game/shared/animation.h index 5602533b..7b496f47 100644 --- a/r5dev/game/shared/animation.h +++ b/r5dev/game/shared/animation.h @@ -16,7 +16,7 @@ class VAnimation : public IDetour } virtual void GetFun(void) const { - p_CStudioHdr__LookupSequence = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\xD9\x4C\x8B\xC2\x48\x8B\x89\x00\x00\x00\x00"), "xxxxxxxxxxxxxxx????"); + p_CStudioHdr__LookupSequence = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B D9 4C 8B C2 48 8B 89 ?? ?? ?? ??"); v_CStudioHdr__LookupSequence = p_CStudioHdr__LookupSequence.RCast(); /*40 53 48 83 EC 20 48 8B D9 4C 8B C2 48 8B 89 ?? ?? ?? ??*/ } virtual void GetVar(void) const { } diff --git a/r5dev/inputsystem/inputsystem.h b/r5dev/inputsystem/inputsystem.h index 7723dd01..1a2f1714 100644 --- a/r5dev/inputsystem/inputsystem.h +++ b/r5dev/inputsystem/inputsystem.h @@ -32,9 +32,8 @@ class VInputSystem : public IDetour virtual void GetFun(void) const { } virtual void GetVar(void) const { - g_pInputSystem = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x83\xEC\x28\x48\x8B\x0D\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x85\xC9\x74\x11"), - "xxxxxxx????xxx????xxx????xxxxx").FindPatternSelf("48 89 05", CMemory::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pInputSystem = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 85 C9 74 11") + .FindPatternSelf("48 89 05", CMemory::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/launcher/IApplication.h b/r5dev/launcher/IApplication.h index ca26813f..bc3d5c06 100644 --- a/r5dev/launcher/IApplication.h +++ b/r5dev/launcher/IApplication.h @@ -59,17 +59,17 @@ class VApplication : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CModAppSystemGroup_Main = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x80\xB9\x00\x00\x00\x00\x00\x48\x8B\x15\x00\x00\x00\x00"), "xxxxxx?????xxx????"); - p_CModAppSystemGroup_Create = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x60\x48\xC7\x40\x00\x00\x00\x00\x00\x48\x89\x58\x08"), "xxxxxxxxxxxxxxxxxxx?????xxxx"); + p_CModAppSystemGroup_Main = g_GameDll.FindPatternSIMD("48 83 EC 28 80 B9 ?? ?? ?? ?? ?? 48 8B 15 ?? ?? ?? ??"); + p_CModAppSystemGroup_Create = g_GameDll.FindPatternSIMD("48 8B C4 57 41 54 41 55 41 56 41 57 48 83 EC 60 48 C7 40 ?? ?? ?? ?? ?? 48 89 58 08"); - p_CSourceAppSystemGroup__Create = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xF9\xE8\x00\x00\x00\x00\x33\xC9"), "xxxx?xxxx?xxxx?xxxxxxxxx????xx"); + p_CSourceAppSystemGroup__Create = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 E8 ?? ?? ?? ?? 33 C9"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CModAppSystemGroup_Main = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x80\xB9\x00\x00\x00\x00\x00\xBB\x00\x00\x00\x00"), "xxxxxxxx?????x????"); - p_CModAppSystemGroup_Create = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC\x48\x83\xEC\x60"), "xxxxxxxxxxxxxxxxxxx"); + p_CModAppSystemGroup_Main = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 80 B9 ?? ?? ?? ?? ?? BB ?? ?? ?? ??"); + p_CModAppSystemGroup_Create = g_GameDll.FindPatternSIMD("48 8B C4 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60"); - p_CSourceAppSystemGroup__Create = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xF9\xE8\x00\x00\x00\x00\x33\xC9"), "xxxx?xxxx?xxxxxxxxx????xx"); + p_CSourceAppSystemGroup__Create = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 E8 ?? ?? ?? ?? 33 C9"); #endif - p_CSourceAppSystemGroup__PreInit = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x74\x24\x00\x55\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00"), "xxxx?xxxxx????xxx????xxx????"); + p_CSourceAppSystemGroup__PreInit = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 55 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ??"); CModAppSystemGroup_Main = p_CModAppSystemGroup_Main.RCast(); /*40 53 48 83 EC 20 80 B9 ?? ?? ?? ?? ?? BB ?? ?? ?? ??*/ CModAppSystemGroup_Create = p_CModAppSystemGroup_Create.RCast(); /*48 8B C4 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60*/ diff --git a/r5dev/launcher/launcher.h b/r5dev/launcher/launcher.h index e415404c..27d95d98 100644 --- a/r5dev/launcher/launcher.h +++ b/r5dev/launcher/launcher.h @@ -34,14 +34,14 @@ class VLauncher : public IDetour } virtual void GetFun(void) const { - p_WinMain = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x41\x8B\xD9\x49\x8B\xF8"), "xxxx?xxxx?xxxx?xxxxxxxxxxx"); + p_WinMain = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 41 8B D9 49 8B F8"); v_WinMain = p_WinMain.RCast(); p_LauncherMain = g_GameDll.GetExportedFunction("LauncherMain"); v_LauncherMain = p_LauncherMain.RCast(); #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) - p_RemoveSpuriousGameParameters = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x33\xED\x48\x8D\x3D\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxx????xxxxx????"); + p_RemoveSpuriousGameParameters = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 33 ED 48 8D 3D ?? ?? ?? ??"); v_RemoveSpuriousGameParameters = p_RemoveSpuriousGameParameters.RCast(); #endif // !GAMEDLL_S0 || !GAMEDLL_S1 } diff --git a/r5dev/launcher/prx.h b/r5dev/launcher/prx.h index 0b40074d..f9cde49e 100644 --- a/r5dev/launcher/prx.h +++ b/r5dev/launcher/prx.h @@ -17,7 +17,7 @@ class VPRX : public IDetour } virtual void GetFun(void) const { - p_exit_or_terminate_process = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x8B\xD9\xE8\x00\x00\x00\x00\x84\xC0"), "xxxxxxxxx????xx"); + p_exit_or_terminate_process = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 8B D9 E8 ?? ?? ?? ?? 84 C0"); v_exit_or_terminate_process = p_exit_or_terminate_process.RCast(); /*40 53 48 83 EC 20 8B D9 E8 ? ? ? ? 84 C0 */ } virtual void GetVar(void) const { } diff --git a/r5dev/materialsystem/cmaterialglue.h b/r5dev/materialsystem/cmaterialglue.h index 55981f75..0f42fe53 100644 --- a/r5dev/materialsystem/cmaterialglue.h +++ b/r5dev/materialsystem/cmaterialglue.h @@ -88,7 +88,7 @@ class VMaterialGlue : public IDetour virtual void GetFun(void) const { #ifndef DEDICATED - p_GetMaterialAtCrossHair = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x83\xEC\x58\x48\x83\x3D\x00\x00\x00\x00\x00"), "xxxxxxxxxx?????"); + p_GetMaterialAtCrossHair = g_GameDll.FindPatternSIMD("48 8B C4 48 83 EC 58 48 83 3D ?? ?? ?? ?? ??"); GetMaterialAtCrossHair = p_GetMaterialAtCrossHair.RCast(); /*48 8B C4 48 83 EC 58 48 83 3D ? ? ? ? ?*/ #endif // !DEDICATED } diff --git a/r5dev/materialsystem/cmaterialsystem.h b/r5dev/materialsystem/cmaterialsystem.h index 2e99f11d..8f77eeeb 100644 --- a/r5dev/materialsystem/cmaterialsystem.h +++ b/r5dev/materialsystem/cmaterialsystem.h @@ -66,22 +66,22 @@ class VMaterialSystem : public IDetour } virtual void GetFun(void) const { - p_CMaterialSystem__Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x70\x48\x83\x3D\x00\x00\x00\x00\x00"), "xxxx?xxxxxxxxxxxxxxxxxx?????"); + p_CMaterialSystem__Init = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 70 48 83 3D ?? ?? ?? ?? ??"); CMaterialSystem__Init = p_CMaterialSystem__Init.RCast(); /*48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 70 48 83 3D ?? ?? ?? ?? ??*/ #ifndef DEDICATED - p_CMaterialSystem__FindMaterialEx = g_GameDll.FindPatternSIMD(reinterpret_cast("\x44\x89\x4C\x24\x00\x44\x88\x44\x24\x00\x48\x89\x4C\x24\x00"), "xxxx?xxxx?xxxx?"); + p_CMaterialSystem__FindMaterialEx = g_GameDll.FindPatternSIMD("44 89 4C 24 ?? 44 88 44 24 ?? 48 89 4C 24 ??"); CMaterialSystem__FindMaterialEx = p_CMaterialSystem__FindMaterialEx.RCast(); /*44 89 4C 24 ?? 44 88 44 24 ?? 48 89 4C 24 ??*/ - p_CMaterialSystem_GetScreenSize = g_GameDll.FindPatternSIMD(reinterpret_cast("\x8B\x05\x00\x00\x00\x00\x89\x02\x8B\x05\x00\x00\x00\x00\x41\x89\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x8B\x05\x00\x00\x00\x00"), "xx????xxxx????xxxxxxxxxxxxxxxxxxxx????"); + p_CMaterialSystem_GetScreenSize = g_GameDll.FindPatternSIMD("8B 05 ?? ?? ?? ?? 89 02 8B 05 ?? ?? ?? ?? 41 89 ?? C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC 8B 05 ?? ?? ?? ??"); CMaterialSystem_GetScreenSize = p_CMaterialSystem_GetScreenSize.RCast(); /*8B 05 ? ? ? ? 89 02 8B 05 ? ? ? ? 41 89 00 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC 8B 05 ? ? ? ?*/ #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_DispatchDrawCall = g_GameDll.FindPatternSIMD(reinterpret_cast("\x44\x89\x4C\x24\x00\x44\x89\x44\x24\x00\x48\x89\x4C\x24\x00\x55\x53"), "xxxx?xxxx?xxxx?xx"); + p_DispatchDrawCall = g_GameDll.FindPatternSIMD("44 89 4C 24 ?? 44 89 44 24 ?? 48 89 4C 24 ?? 55 53"); v_DispatchDrawCall = p_DispatchDrawCall.RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_DispatchDrawCall = g_GameDll.FindPatternSIMD(reinterpret_cast("\x44\x89\x4C\x24\x00\x44\x89\x44\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x56"), "xxxx?xxxx?xxxx?xxx"); + p_DispatchDrawCall = g_GameDll.FindPatternSIMD("44 89 4C 24 ?? 44 89 44 24 ?? 48 89 4C 24 ?? 55 53 56"); v_DispatchDrawCall = p_DispatchDrawCall.RCast(); #endif - p_DrawStreamOverlay = g_GameDll.FindPatternSIMD(reinterpret_cast("\x41\x56\xB8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x2B\xE0\xC6\x02\x00"), "xxx????x????xxxxxx"); + p_DrawStreamOverlay = g_GameDll.FindPatternSIMD("41 56 B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 C6 02 ??"); v_DrawStreamOverlay = p_DrawStreamOverlay.RCast(); // 41 56 B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 C6 02 00 // #endif // !DEDICATED } @@ -94,8 +94,7 @@ class VMaterialSystem : public IDetour s_pRenderContext = p_DispatchDrawCall.FindPattern("48 8B ?? ?? ?? ?? 01").ResolveRelativeAddressSelf(0x3, 0x7); #endif // !DEDICATED - g_pMaterialSystem = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x8B\x0D\x00\x00\x00\x00\x48\x85\xC9\x74\x11\x48\x8B\x01\x48\x8D\x15\x00\x00\x00\x00"), "xxx????xxxxxxxxxxx????").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pMaterialSystem = g_GameDll.FindPatternSIMD("48 8B 0D ?? ?? ?? ?? 48 85 C9 74 11 48 8B 01 48 8D 15 ?? ?? ?? ??").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { diff --git a/r5dev/public/edict.h b/r5dev/public/edict.h index eb28ab51..06d10d5b 100644 --- a/r5dev/public/edict.h +++ b/r5dev/public/edict.h @@ -62,18 +62,15 @@ class VEdict : public IDetour virtual void GetVar(void) const { #ifndef CLIENT_DLL - g_ServerGlobalVariables = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x81\xEC\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x0F\x85\x00\x00\x00\x00"), "xxx????x????xx?????xx????") + g_ServerGlobalVariables = g_GameDll.FindPatternSIMD("48 81 EC ?? ?? ?? ?? E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 0F 85 ?? ?? ?? ??") .FindPatternSelf("48 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #endif // !CLIENT_DLL #ifndef DEDICATED #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - g_ClientGlobalVariables = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x8B\xC4\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x60\x48\xC7\x40\x00\x00\x00\x00\x00\x48\x89\x58\x08"), "xxxxxxxxxxxxxxxxxxx?????xxxx") + g_ClientGlobalVariables = g_GameDll.FindPatternSIMD("48 8B C4 57 41 54 41 55 41 56 41 57 48 83 EC 60 48 C7 40 ?? ?? ?? ?? ?? 48 89 58 08") .FindPatternSelf("4C 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 8000).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - g_ClientGlobalVariables = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x8B\xC4\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC\x48\x83\xEC\x60"), "xxxxxxxxxxxxxxxxxxx") + g_ClientGlobalVariables = g_GameDll.FindPatternSIMD("48 8B C4 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60") .FindPatternSelf("4C 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 8000).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #endif // GAME_DLL #endif // !DEDICATED diff --git a/r5dev/public/idebugoverlay.h b/r5dev/public/idebugoverlay.h index de312ec6..a37dcb8e 100644 --- a/r5dev/public/idebugoverlay.h +++ b/r5dev/public/idebugoverlay.h @@ -52,7 +52,7 @@ class VDebugOverlayBase : public IDetour virtual void GetFun(void) const { } virtual void GetVar(void) const { - g_pDebugOverlay = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8D\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x8D\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x83\xEC\x28\xF3\x0F\x10\x41\x00"), "xxx????xxxxxxxxxxxx????xxxxxxxxxxxxxxxxx?") + g_pDebugOverlay = g_GameDll.FindPatternSIMD("48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 83 EC 28 F3 0F 10 41 ??") .ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } diff --git a/r5dev/rtech/rtech_game.h b/r5dev/rtech/rtech_game.h index 2248cbad..202b6d85 100644 --- a/r5dev/rtech/rtech_game.h +++ b/r5dev/rtech/rtech_game.h @@ -62,26 +62,26 @@ class VRTechGame : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CPakFile_LoadPak = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x56\x41\x55\x48\x81\xEC\x00\x00\x00\x00\x4C\x8B\x69\x60"), "xxxx?xxxxxx????xxxx"); + p_CPakFile_LoadPak = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 56 41 55 48 81 EC ?? ?? ?? ?? 4C 8B 69 60"); CPakFile_LoadPak = p_CPakFile_LoadPak.RCast(); /*48 89 4C 24 ? 56 41 55 48 81 EC ? ? ? ? 4C 8B 69 60*/ #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CPakFile_LoadPak = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x56\x41\x55"), "xxxx?xxx"); /*48 89 4C 24 ? 56 41 55*/ + p_CPakFile_LoadPak = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 56 41 55"); /*48 89 4C 24 ? 56 41 55*/ CPakFile_LoadPak = p_CPakFile_LoadPak.RCast(); #endif #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - p_CPakFile_LoadAsync = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x40\x48\x89\x6C\x24\x00\x41\x8B\xE8"), "xxxxxxxxxx?xxx"); + p_CPakFile_LoadAsync = g_GameDll.FindPatternSIMD("40 53 48 83 EC 40 48 89 6C 24 ?? 41 8B E8"); CPakFile_LoadAsync = p_CPakFile_LoadAsync.RCast(); /*40 53 48 83 EC 40 48 89 6C 24 ? 41 8B E8*/ #elif defined (GAMEDLL_S3) - p_CPakFile_LoadAsync = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x40\x48\x89\x6C\x24\x00\x41\x0F\xB6\xE9"), "xxxxxxxxxx?xxxx"); + p_CPakFile_LoadAsync = g_GameDll.FindPatternSIMD("40 53 48 83 EC 40 48 89 6C 24 ?? 41 0F B6 E9"); CPakFile_LoadAsync = p_CPakFile_LoadAsync.RCast(); /*40 53 48 83 EC 40 48 89 6C 24 ? 41 0F B6 E9*/ #endif - p_CPakFile_UnloadPak = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x8B\xC1"), "xxxx?xxxx?xxxxxxx"); + p_CPakFile_UnloadPak = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 8B C1"); CPakFile_UnloadPak = p_CPakFile_UnloadPak.RCast(); /*48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 30 8B C1*/ } virtual void GetVar(void) const { } virtual void GetCon(void) const { - p_CPakFile_LoadPak_OpenFileOffset = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x7C\x24\x30\xC7\x44\x24\x28\x00\x00\x00\x40"), "xxxxxxxxxxxxx"); /*48 89 7C 24 30 C7 44 24 28 00 00 00 40*/ + p_CPakFile_LoadPak_OpenFileOffset = g_GameDll.FindPatternSIMD("48 89 7C 24 30 C7 44 24 28 ?? ?? ?? 40"); /*48 89 7C 24 30 C7 44 24 28 00 00 00 40*/ } virtual void Attach(void) const { } virtual void Detach(void) const { } diff --git a/r5dev/rtech/rtech_utils.h b/r5dev/rtech/rtech_utils.h index 32bf18f4..6b788687 100644 --- a/r5dev/rtech/rtech_utils.h +++ b/r5dev/rtech/rtech_utils.h @@ -399,26 +399,26 @@ class VPakFile : public IDetour { #if not defined DEDICATED #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_RTech_CreateDXTexture = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x48\x08\x53\x55\x41\x55"), "xxxxxxxxxxx"); + p_RTech_CreateDXTexture = g_GameDll.FindPatternSIMD("48 8B C4 48 89 48 08 53 55 41 55"); RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast(); /*48 8B C4 48 89 48 08 53 55 41 55*/ #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_RTech_CreateDXTexture = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x4C\x8B\xC7\x48\x8B\xD5\x48\x8B\xCB\x48\x83\xC4\x60"), "x????xxxxxxxxxxxxx").FollowNearCallSelf(); + p_RTech_CreateDXTexture = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 4C 8B C7 48 8B D5 48 8B CB 48 83 C4 60").FollowNearCallSelf(); RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast(); /*E8 ? ? ? ? 4C 8B C7 48 8B D5 48 8B CB 48 83 C4 60*/ #endif - p_GetStreamOverlay = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x80\x7C\x24\x00\x00\x0F\x84\x00\x00\x00\x00\x48\x89\x9C\x24\x00\x00\x00\x00"), "x????xxx??xx????xxxx????").FollowNearCallSelf(); + p_GetStreamOverlay = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 80 7C 24 ?? ?? 0F 84 ?? ?? ?? ?? 48 89 9C 24 ?? ?? ?? ??").FollowNearCallSelf(); GetStreamOverlay = p_GetStreamOverlay.RCast(); /*E8 ? ? ? ? 80 7C 24 ? ? 0F 84 ? ? ? ? 48 89 9C 24 ? ? ? ?*/ #endif // !DEDICATED - p_StreamDB_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x54\x41\x56\x41\x57\x48\x83\xEC\x40\x48\x8B\xE9"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxxx"); + p_StreamDB_Init = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 54 41 56 41 57 48 83 EC 40 48 8B E9"); v_StreamDB_Init = p_StreamDB_Init.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 54 41 56 41 57 48 83 EC 40 48 8B E9*/ - p_RTech_FindFreeSlotInFiles = g_GameDll.FindPatternSIMD(reinterpret_cast("\x44\x8B\x51\x0C\x4C\x8B\xC1"), "xxxxxxx"); + p_RTech_FindFreeSlotInFiles = g_GameDll.FindPatternSIMD("44 8B 51 0C 4C 8B C1"); RTech_FindFreeSlotInFiles = p_RTech_FindFreeSlotInFiles.RCast(); /*44 8B 51 0C 4C 8B C1*/ - p_RTech_OpenFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x89\x85\x08\x01\x00\x00"), "x????xxxxxx").FollowNearCallSelf(); + p_RTech_OpenFile = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 89 85 08 01 ?? ??").FollowNearCallSelf(); RTech_OpenFile = p_RTech_OpenFile.RCast(); /*E8 ? ? ? ? 89 85 08 01 00 00*/ #ifdef GAMEDLL_S3 - p_Pak_ProcessGuidRelationsForAsset = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x48\x8B\x86\x00\x00\x00\x00\x42\x8B\x0C\xB0"), "x????xxx????xxxx").FollowNearCallSelf(); + p_Pak_ProcessGuidRelationsForAsset = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8B 86 ?? ?? ?? ?? 42 8B 0C B0").FollowNearCallSelf(); RTech_Pak_ProcessGuidRelationsForAsset = p_Pak_ProcessGuidRelationsForAsset.RCast(); /*E8 ? ? ? ? 48 8B 86 ? ? ? ? 42 8B 0C B0*/ #endif } @@ -432,7 +432,7 @@ class VPakFile : public IDetour s_pFileArray = p_StreamDB_Init.Offset(0x70).FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddress(0x3, 0x7).RCast(); m_FileHandles = p_StreamDB_Init.Offset(0x70).FindPatternSelf("4C 8D", CMemory::Direction::DOWN, 512, 1).ResolveRelativeAddress(0x3, 0x7).RCast(); - g_pUnknownPakStruct = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8D\x1D\x00\x00\x00\x00\x45\x8D\x5A\x0E"), "xxx????xxxx").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); /*48 8D 1D ? ? ? ? 45 8D 5A 0E*/ + g_pUnknownPakStruct = g_GameDll.FindPatternSIMD("48 8D 1D ?? ?? ?? ?? 45 8D 5A 0E").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); /*48 8D 1D ? ? ? ? 45 8D 5A 0E*/ g_pPakFifoLock = p_JT_HelpWithAnything.Offset(0x155).FindPatternSelf("48 8D 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); g_pPakFifoLockWrapper = p_JT_HelpWithAnything.Offset(0x1BC).FindPatternSelf("48 8D 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); diff --git a/r5dev/rtech/rui/rui.h b/r5dev/rtech/rui/rui.h index 63ed01ff..9cc50d8a 100644 --- a/r5dev/rtech/rui/rui.h +++ b/r5dev/rtech/rui/rui.h @@ -25,13 +25,13 @@ class VRui : public IDetour } virtual void GetFun(void) const { - p_Rui_Draw = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x40\x4C\x8B\x5A\x18"), "xxxxxxxxxx"); + p_Rui_Draw = g_GameDll.FindPatternSIMD("40 53 48 83 EC 40 4C 8B 5A 18"); v_Rui_Draw = p_Rui_Draw.RCast(); /* 40 53 48 83 EC 40 4C 8B 5A 18 */ - p_Rui_LoadAsset = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\xEB\x03\x49\x8B\xC6\x48\x89\x86\x00\x00\x00\x00\x8B\x86\x00\x00\x00\x00"), "x????xxxxxxxx????xx????").FollowNearCallSelf(); + p_Rui_LoadAsset = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? EB 03 49 8B C6 48 89 86 ?? ?? ?? ?? 8B 86 ?? ?? ?? ??").FollowNearCallSelf(); v_Rui_LoadAsset = p_Rui_LoadAsset.RCast(); /*E8 ?? ?? ?? ?? EB 03 49 8B C6 48 89 86 ?? ?? ?? ?? 8B 86 ?? ?? ?? ??*/ - p_Rui_GetFontFace = g_GameDll.FindPatternSIMD(reinterpret_cast("\xF7\x05\x00\x00\x00\x00\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00\x74\x05\x49\x8B\xD1\xEB\x19\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\x48\x8B\x48\x58\x48\x85\xC9\x48\x0F\x45\xD1\xF7\x05\x00\x00\x00\x00\x00\x00\x00\x00\x75\x19\x48\x8B\x05\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00\x4C\x8B\x40\x58\x4D\x85\xC0\x4D\x0F\x45\xC8\x49\x8B\xC9\x48\xFF\x25\x00\x00\x00\x00"), "xx????????xxx????xxxxxxxxxx????xxx????xxxxxxxxxxxxx????????xxxxx????xxx????xxxxxxxxxxxxxxxxx????"); + p_Rui_GetFontFace = g_GameDll.FindPatternSIMD("F7 05 ?? ?? ?? ?? ?? ?? ?? ?? 4C 8D 0D ?? ?? ?? ?? 74 05 49 8B D1 EB 19 48 8B 05 ?? ?? ?? ?? 48 8D 15 ?? ?? ?? ?? 48 8B 48 58 48 85 C9 48 0F 45 D1 F7 05 ?? ?? ?? ?? ?? ?? ?? ?? 75 19 48 8B 05 ?? ?? ?? ?? 4C 8D 0D ?? ?? ?? ?? 4C 8B 40 58 4D 85 C0 4D 0F 45 C8 49 8B C9 48 FF 25 ?? ?? ?? ??"); v_Rui_GetFontFace = p_Rui_GetFontFace.RCast();/*F7 05 ? ? ? ? ? ? ? ? 4C 8D 0D ? ? ? ? 74 05 49 8B D1 EB 19 48 8B 05 ? ? ? ? 48 8D 15 ? ? ? ? 48 8B 48 58 48 85 C9 48 0F 45 D1 F7 05 ? ? ? ? ? ? ? ? 75 19 48 8B 05 ? ? ? ? 4C 8D 0D ? ? ? ? 4C 8B 40 58 4D 85 C0 4D 0F 45 C8 49 8B C9 48 FF 25 ? ? ? ?*/ } virtual void GetVar(void) const { } diff --git a/r5dev/rtech/stryder/stryder.h b/r5dev/rtech/stryder/stryder.h index 4a429241..b3cf29fd 100644 --- a/r5dev/rtech/stryder/stryder.h +++ b/r5dev/rtech/stryder/stryder.h @@ -19,11 +19,11 @@ class VStryder : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_Stryder_StitchRequest = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x53\x57\x41\x56\x48\x81\xEC\x20"), "xxxxxxxxxxx"); - p_Stryder_SendOfflineRequest = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x35\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x83\x65\xD0\xFC\x48\x8D\x4D\x80"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxx????xxx????xxx????xxx????xxxxxxxx"); + p_Stryder_StitchRequest = g_GameDll.FindPatternSIMD("48 8B C4 53 57 41 56 48 81 EC 20"); + p_Stryder_SendOfflineRequest = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 35 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 83 65 D0 FC 48 8D 4D 80"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_Stryder_StitchRequest = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x48\x83\xEC\x20\x48\x8B\xF9\xE8\xB4"), "xxxxxxxxxxxxxxxxxxxxxxxxx"); - p_Stryder_SendOfflineRequest = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x55\x57\x41\x56\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x35\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxx????xxx????xxx????"); + p_Stryder_StitchRequest = g_GameDll.FindPatternSIMD("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B F9 E8 B4"); + p_Stryder_SendOfflineRequest = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 55 57 41 56 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 35 ?? ?? ?? ??"); #endif Stryder_StitchRequest = p_Stryder_StitchRequest.RCast(); /*48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B F9 E8 B4*/ Stryder_SendOfflineRequest = p_Stryder_SendOfflineRequest.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 55 57 41 56 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 35 ?? ?? ?? ??*/ diff --git a/r5dev/server/persistence.h b/r5dev/server/persistence.h index b90b3088..736ff1c5 100644 --- a/r5dev/server/persistence.h +++ b/r5dev/server/persistence.h @@ -22,7 +22,7 @@ class VPersistence : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_Persistence_SetXP = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x33\xFF\x48\x8B\xF2\x3B\x0D\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxxxx????"); + p_Persistence_SetXP = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 33 FF 48 8B F2 3B 0D ?? ?? ?? ??"); v_Persistence_SetXP = p_Persistence_SetXP.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 33 FF 48 8B F2 3B 0D ?? ?? ?? ??*/ #endif } diff --git a/r5dev/server/vengineserver_impl.h b/r5dev/server/vengineserver_impl.h index afc744cc..8ffd7d86 100644 --- a/r5dev/server/vengineserver_impl.h +++ b/r5dev/server/vengineserver_impl.h @@ -68,11 +68,11 @@ class HVEngineServer : public IDetour } virtual void GetFun(void) const { - p_IVEngineServer__PersistenceAvailable = g_GameDll.FindPatternSIMD(reinterpret_cast("\x3B\x15\x00\x00\x00\x00\x7D\x33"), "xx????xx"); - p_IVEngineServer__IsDedicatedServer = g_GameDll.FindPatternSIMD(reinterpret_cast("\x0F\xB6\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x40\x53"), "xxx????xxxxxxxxxxxx????xxxxxxxxxxx"); - p_IVEngineServer__GetNumHumanPlayers = g_GameDll.FindPatternSIMD(reinterpret_cast("\x8B\x15\x00\x00\x00\x00\x33\xC0\x85\xD2\x7E\x24"), "xx????xxxxxx"); - p_IVEngineServer__GetNumFakeClients = g_GameDll.FindPatternSIMD(reinterpret_cast("\x8B\x05\x00\x00\x00\x00\x33\xC9\x85\xC0\x7E\x2D"), "xx????xxxxxx"); -// p_RunFrameServer = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x30\x0F\x29\x74\x24\x00\x48\x8D\x0D\x00\x00\x00\x00"), "xxxx?xxxxxxxxx?xxx????"); + p_IVEngineServer__PersistenceAvailable = g_GameDll.FindPatternSIMD("3B 15 ?? ?? ?? ?? 7D 33"); + p_IVEngineServer__IsDedicatedServer = g_GameDll.FindPatternSIMD("0F B6 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 40 53"); + p_IVEngineServer__GetNumHumanPlayers = g_GameDll.FindPatternSIMD("8B 15 ?? ?? ?? ?? 33 C0 85 D2 7E 24"); + p_IVEngineServer__GetNumFakeClients = g_GameDll.FindPatternSIMD("8B 05 ?? ?? ?? ?? 33 C9 85 C0 7E 2D"); +// p_RunFrameServer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 30 0F 29 74 24 ?? 48 8D 0D ?? ?? ?? ??"); IVEngineServer__PersistenceAvailable = p_IVEngineServer__PersistenceAvailable.RCast(); /*3B 15 ?? ?? ?? ?? 7D 33*/ IVEngineServer__IsDedicatedServer = p_IVEngineServer__IsDedicatedServer.RCast(); /*0F B6 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 40 53*/ diff --git a/r5dev/squirrel/sqapi.h b/r5dev/squirrel/sqapi.h index 8d2eba1c..bac7cb90 100644 --- a/r5dev/squirrel/sqapi.h +++ b/r5dev/squirrel/sqapi.h @@ -75,25 +75,25 @@ class VSqapi : public IDetour } virtual void GetFun(void) const { - p_sq_pushroottable = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x8B\x51\x00\x44\x8B\xC2"), "xxxxxx?xxx"); - p_sq_pushbool = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x38\x33\xC0\x48\xC7\x44\x24\x20\x08\x00\x00\x01\x48"), "xxxxxxxxxxxxxxxx"); + p_sq_pushroottable = g_GameDll.FindPatternSIMD("48 83 EC 28 8B 51 ?? 44 8B C2"); + p_sq_pushbool = g_GameDll.FindPatternSIMD("48 83 EC 38 33 C0 48 C7 44 24 20 08 ?? ?? 01 48"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - p_sq_pushstring = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x48\x83\xEC\x30\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x8C\x00"), "xxxxxxxxxxxxxxxx"); + p_sq_pushstring = g_GameDll.FindPatternSIMD("40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8C ??"); #elif defined (GAMEDLL_S3) - p_sq_pushstring = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x48\x83\xEC\x30\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x8F\x00"), "xxxxxxxxxxxxxxxx"); + p_sq_pushstring = g_GameDll.FindPatternSIMD("40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8F ??"); #endif - p_sq_pushinteger = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x38\x33\xC0\x48\xC7\x44\x24\x20\x02\x00\x00\x05\x48"), "xxxxxxxxxxxxxxxx"); - p_sq_newarray = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x30\x48\x8B\xD9\x48\xC7\x44\x24\x20\x40"), "xxxxxxxxxxxxxxxxxxx"); - p_sq_newtable = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x30\x48\x8B\xD9\x48\xC7\x44\x24\x20\x20"), "xxxxxxxxxxxxxxxxxxx"); - p_sq_newslot = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x30\x44\x8B\x49\x00\x48\x8B\xD9\x41\x8B\xC1"), "xxxxxxxxx?xxxxxx"); - p_sq_arrayappend = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x8B\x41\x00\x48\x8B\xD9\x2B\x41\x00\x83\xF8\x02\x7D"), "xxxxxxxx?xxxxx?xxxx"); + p_sq_pushinteger = g_GameDll.FindPatternSIMD("48 83 EC 38 33 C0 48 C7 44 24 20 02 ?? ?? 05 48"); + p_sq_newarray = g_GameDll.FindPatternSIMD("48 89 5C 24 08 57 48 83 EC 30 48 8B D9 48 C7 44 24 20 40"); + p_sq_newtable = g_GameDll.FindPatternSIMD("48 89 5C 24 08 57 48 83 EC 30 48 8B D9 48 C7 44 24 20 20"); + p_sq_newslot = g_GameDll.FindPatternSIMD("40 53 48 83 EC 30 44 8B 49 ?? 48 8B D9 41 8B C1"); + p_sq_arrayappend = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - p_sq_pushstructure = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x4C\x89\x4C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxx"); + p_sq_pushstructure = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 4C 89 4C 24 ?? 55 41 54 41 55 41 56 41 57 48 8B EC"); #elif defined (GAMEDLL_S3) - p_sq_pushstructure = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC\x48\x83\xEC\x60\x48\x8B\x59\x60"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxxxxxx"); + p_sq_pushstructure = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60 48 8B 59 60"); #endif - p_sq_compilebuffer = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x56\x41\x57\x48\x83\xEC\x50\x41\x8B\xE9\x49\x8B\xF8"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxx"); - p_sq_call = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x8B\xDC\x49\x89\x5B\x08\x49\x89\x6B\x10\x49\x89\x73\x18\x57\x48\x83\xEC\x50\x8B\xF2"), "xxxxxxxxxxxxxxxxxxxxxx"); + p_sq_compilebuffer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 56 41 57 48 83 EC 50 41 8B E9 49 8B F8"); + p_sq_call = g_GameDll.FindPatternSIMD("4C 8B DC 49 89 5B 08 49 89 6B 10 49 89 73 18 57 48 83 EC 50 8B F2"); v_sq_pushroottable = p_sq_pushroottable.RCast(); /*48 83 EC 28 8B 51 ?? 44 8B C2*/ v_sq_pushbool = p_sq_pushbool.RCast(); /*48 83 EC 38 33 C0 48 C7 44 24 20 08 00 00 01 48*/ diff --git a/r5dev/squirrel/sqinit.h b/r5dev/squirrel/sqinit.h index 1b4a2a32..85599e7d 100644 --- a/r5dev/squirrel/sqinit.h +++ b/r5dev/squirrel/sqinit.h @@ -79,8 +79,8 @@ class VSqInit : public IDetour } virtual void GetFun(void) const { - p_Script_Remote_BeginRegisteringFunctions = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x83\x3D\x00\x00\x00\x00\x00\x74\x10"), "xxxxxx?????xx"); - p_RestoreRemoteChecksumsFromSaveGame = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x41\x54\x48\x83\xEC\x40"), "xxxx?xxxxxx"); + p_Script_Remote_BeginRegisteringFunctions = g_GameDll.FindPatternSIMD("48 83 EC 28 83 3D ?? ?? ?? ?? ?? 74 10"); + p_RestoreRemoteChecksumsFromSaveGame = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 41 54 48 83 EC 40"); Script_Remote_BeginRegisteringFunctions = p_Script_Remote_BeginRegisteringFunctions.RCast(); /*48 83 EC 28 83 3D ?? ?? ?? ?? ?? 74 10*/ RestoreRemoteChecksumsFromSaveGame = p_RestoreRemoteChecksumsFromSaveGame.RCast(); /*48 89 4C 24 ?? 41 54 48 83 EC 40*/ diff --git a/r5dev/squirrel/sqscript.h b/r5dev/squirrel/sqscript.h index 83228a70..16bc937b 100644 --- a/r5dev/squirrel/sqscript.h +++ b/r5dev/squirrel/sqscript.h @@ -179,33 +179,33 @@ class VSquirrelVM : public IDetour } virtual void GetFun(void) const { - p_Script_RegisterConstant = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x4C\x8B"), "xxxx?xxxx?xxxx?xxxxxxx"); - p_Script_RegisterFunction = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x38\x45\x0F\xB6\xC8"), "xxxxxxxx"); + p_Script_RegisterConstant = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 4C 8B"); + p_Script_RegisterFunction = g_GameDll.FindPatternSIMD("48 83 EC 38 45 0F B6 C8"); #if !defined (CLIENT_DLL) - p_Script_InitializeSVGlobalStructs = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x48\x8B\x3D\x00\x00\x00\x00\x48\x8B\xF1"), "xxxx?xxxxxxxx????xxx"); + p_Script_InitializeSVGlobalStructs = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 57 48 83 EC 30 48 8B 3D ?? ?? ?? ?? 48 8B F1"); #endif // !CLIENT_DLL #if !defined (DEDICATED) - p_Script_InitializeCLGlobalStructs = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x30\x48\x63\xC2\x48\x8D\x3D\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxxxx????"); + p_Script_InitializeCLGlobalStructs = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 30 48 63 C2 48 8D 3D ?? ?? ?? ??"); #endif // !DEDICATED #if !defined (CLIENT_DLL) && defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_Script_CreateServerVM = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x50\x48\x8D\x0D\x00\x00\x00\x00"), "xxxxxxxxx????"); + p_Script_CreateServerVM = g_GameDll.FindPatternSIMD("40 53 48 83 EC 50 48 8D 0D ?? ?? ?? ??"); #elif !defined (CLIENT_DLL) && defined (GAMEDLL_S3) || defined (GAMEDLL_S2) - p_Script_CreateServerVM = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x56\x48\x83\xEC\x48\x48\x8D\x0D\x00\x00\x00\x00"), "xxxxxxxxxx????"); + p_Script_CreateServerVM = g_GameDll.FindPatternSIMD("40 53 56 48 83 EC 48 48 8D 0D ?? ?? ?? ??"); #endif #if !defined (DEDICATED) && defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - p_Script_CreateClientVM = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x58\x48\x83\x3D\x00\x00\x00\x00\x00\x74\x05"), "xxxxxxx?????xx"); + p_Script_CreateClientVM = g_GameDll.FindPatternSIMD("48 83 EC 58 48 83 3D ?? ?? ?? ?? ?? 74 05"); #elif !defined (DEDICATED) && defined (GAMEDLL_S3) - p_Script_CreateClientVM = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x41\x57\x48\x83\xEC\x68\x48\x83\x3D\x00\x00\x00\x00\x00"), "xxxxxxxxxxx?????"); + p_Script_CreateClientVM = g_GameDll.FindPatternSIMD("40 53 41 57 48 83 EC 68 48 83 3D ?? ?? ?? ?? ??"); #endif #if !defined (DEDICATED) - p_Script_CreateUIVM = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\x1D\x00\x00\x00\x00\xC6\x05\x00\x00\x00\x00\x00"), "xxxxxxxxx????xx?????"); + p_Script_CreateUIVM = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B 1D ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ??"); #endif // !DEDICATED - p_Script_DestroySignalEntryListHead = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x56\x57\x41\x56\x48\x83\xEC\x50\x44\x8B\x42\x78"), "xxxx?xxxx?xxxxxxxxxxxx"); - p_Script_LoadRson = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x8B\xDC\x49\x89\x5B\x08\x57\x48\x81\xEC\xA0\x00\x00\x00\x33"), "xxxxxxxxxxxxxxxx"); + p_Script_DestroySignalEntryListHead = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 50 44 8B 42 78"); + p_Script_LoadRson = g_GameDll.FindPatternSIMD("4C 8B DC 49 89 5B 08 57 48 81 EC A0 ?? ?? ?? 33"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_Script_LoadScript = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x10\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x48\x89\x4C\x24\x08\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + p_Script_LoadScript = g_GameDll.FindPatternSIMD("48 89 5C 24 10 48 89 74 24 18 48 89 7C 24 20 48 89 4C 24 08 55 41 54 41 55 41 56 41 57 48 8D 6C"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_Script_LoadScript = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x48\x08\x55\x41\x56\x48\x8D\x68"), "xxxxxxxxxxxxx"); + p_Script_LoadScript = g_GameDll.FindPatternSIMD("48 8B C4 48 89 48 08 55 41 56 48 8D 68"); #endif v_Script_RegisterConstant = p_Script_RegisterConstant.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 4C 8B*/ v_Script_RegisterFunction = p_Script_RegisterFunction.RCast(); /*48 83 EC 38 45 0F B6 C8*/ diff --git a/r5dev/squirrel/sqstdaux.h b/r5dev/squirrel/sqstdaux.h index c3adfe15..20d2b97d 100644 --- a/r5dev/squirrel/sqstdaux.h +++ b/r5dev/squirrel/sqstdaux.h @@ -25,13 +25,13 @@ class VSqStdAux : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_sqstd_aux_printerror = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x55\x56\x57\x41\x54\x41\x55\x41\x57\x48\x81\xEC\x00\x00\x00\x00"), "xxxxxxxxxxxxxx????"); + p_sqstd_aux_printerror = g_GameDll.FindPatternSIMD("40 53 55 56 57 41 54 41 55 41 57 48 81 EC ?? ?? ?? ??"); v_sqstd_aux_printerror = p_sqstd_aux_printerror.RCast(); /*40 53 55 56 57 41 54 41 55 41 57 48 81 EC ?? ?? ?? ??*/ #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_sqstd_aux_printerror = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\xFF\x05\x00\x00\x00\x00"), "xxxxxxxxxxxxxxx????xx????"); + p_sqstd_aux_printerror = g_GameDll.FindPatternSIMD("40 53 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? FF 05 ?? ?? ?? ??"); v_sqstd_aux_printerror = p_sqstd_aux_printerror.RCast(); /*40 53 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? FF 05 ?? ?? ?? ??*/ #endif - p_sqstd_aux_badlogic = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x48\x8B\xEC\x48\x83\xEC\x70\x41\x0F\x10\x00"), "xxxxxxxxxxxxxxx"); + p_sqstd_aux_badlogic = g_GameDll.FindPatternSIMD("48 8B C4 55 48 8B EC 48 83 EC 70 41 0F 10 ??"); v_sqstd_aux_badlogic = p_sqstd_aux_badlogic.RCast(); /*48 8B C4 55 48 8B EC 48 83 EC 70 41 0F 10 00*/ } virtual void GetVar(void) const { } diff --git a/r5dev/squirrel/sqvm.h b/r5dev/squirrel/sqvm.h index dee79603..a3303bf5 100644 --- a/r5dev/squirrel/sqvm.h +++ b/r5dev/squirrel/sqvm.h @@ -104,19 +104,19 @@ class HSQVM : public IDetour } virtual void GetFun(void) const { - p_SQVM_PrintFunc = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x50\x10\x4C\x89\x40\x18\x4C\x89\x48\x20\x53\x56\x57\x48\x81\xEC\x30\x08\x00\x00\x48\x8B\xDA\x48\x8D\x70\x18\x48\x8B\xF9\xE8\x00\x00\x00\xFF\x48\x89\x74\x24\x28\x48\x8D\x54\x24\x30\x33"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx???xxxxxxxxxxxx"); - p_SQVM_WarningFunc = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x4C\x24\x20\x44\x89\x44\x24\x18\x89\x54\x24\x10\x53\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x00\x48\x8B"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx?xx"); + p_SQVM_PrintFunc = g_GameDll.FindPatternSIMD("48 8B C4 48 89 50 10 4C 89 40 18 4C 89 48 20 53 56 57 48 81 EC 30 08 ?? ?? 48 8B DA 48 8D 70 18 48 8B F9 E8 ?? ?? ?? FF 48 89 74 24 28 48 8D 54 24 30 33"); + p_SQVM_WarningFunc = g_GameDll.FindPatternSIMD("4C 89 4C 24 20 44 89 44 24 18 89 54 24 10 53 55 56 57 41 54 41 55 41 56 41 57 48 83 EC ?? 48 8B"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_SQVM_GetErrorLine = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x83\x65\x90\xFC"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxx????xxx????xxxx"); - p_SQVM_LogicError = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x48\xF2\x0F\x10\x05\x00\x00\x00\x00"), "xxxxxxxx????"); + p_SQVM_GetErrorLine = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 83 65 90 FC"); + p_SQVM_LogicError = g_GameDll.FindPatternSIMD("48 83 EC 48 F2 0F 10 05 ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_SQVM_GetErrorLine = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x56\x48\x8D\xA8\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x83\x65\x90\xFC"), "xxxxxxxx????xxx????xxxx"); - p_SQVM_LogicError = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x38\xF2\x0F\x10\x05\x00\x00\x00\x00"), "xxxxxxxx????"); + p_SQVM_GetErrorLine = g_GameDll.FindPatternSIMD("48 8B C4 55 56 48 8D A8 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 83 65 90 FC"); + p_SQVM_LogicError = g_GameDll.FindPatternSIMD("48 83 EC 38 F2 0F 10 05 ?? ?? ?? ??"); #endif - p_SQVM_WarningCmd = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x30\x33\xDB\x48\x8D\x44\x24\x00\x4C\x8D\x4C\x24\x00"), "xxxxxxxxxxxx?xxxx?"); - p_SQVM_CompileError = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xD9\x4C\x8B\xF2"), "xxxx?xxxx?xxxx?xxxx?xxxxx????xxxxxx"); - p_SQVM_ScriptError = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE9\x00\x00\x00\x00\xF7\xD2"), "x????xx").FollowNearCallSelf(); - p_SQVM_RaiseError = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x54\x24\x00\x4C\x89\x44\x24\x00\x4C\x89\x4C\x24\x00\x53\x56\x57\x48\x83\xEC\x40"), "xxxx?xxxx?xxxx?xxxxxxx"); + p_SQVM_WarningCmd = g_GameDll.FindPatternSIMD("40 53 48 83 EC 30 33 DB 48 8D 44 24 ?? 4C 8D 4C 24 ??"); + p_SQVM_CompileError = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 81 EC ?? ?? ?? ?? 48 8B D9 4C 8B F2"); + p_SQVM_ScriptError = g_GameDll.FindPatternSIMD("E9 ?? ?? ?? ?? F7 D2").FollowNearCallSelf(); + p_SQVM_RaiseError = g_GameDll.FindPatternSIMD("48 89 54 24 ?? 4C 89 44 24 ?? 4C 89 4C 24 ?? 53 56 57 48 83 EC 40"); v_SQVM_PrintFunc = p_SQVM_PrintFunc.RCast(); /*48 8B C4 48 89 50 10 4C 89 40 18 4C 89 48 20 53 56 57 48 81 EC 30 08 00 00 48 8B DA 48 8D 70 18 48 8B F9 E8 ?? ?? ?? FF 48 89 74 24 28 48 8D 54 24 30 33*/ v_SQVM_WarningFunc = p_SQVM_WarningFunc.RCast(); /*4C 89 4C 24 20 44 89 44 24 18 89 54 24 10 53 55 56 57 41 54 41 55 41 56 41 57 48 83 EC ?? 48 8B*/ diff --git a/r5dev/studiorender/studiorendercontext.h b/r5dev/studiorender/studiorendercontext.h index 7abad12e..e0ea8517 100644 --- a/r5dev/studiorender/studiorendercontext.h +++ b/r5dev/studiorender/studiorendercontext.h @@ -18,17 +18,17 @@ class VStudioRenderContext : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S1) - CStudioRenderContext__LoadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x44\x24\x00\x53\x55\x56\x41\x54\x41\x57"), "xxxx?xxxxxxx"); + CStudioRenderContext__LoadModel = g_GameDll.FindPatternSIMD("4C 89 44 24 ?? 53 55 56 41 54 41 57"); #elif defined (GAMEDLL_S2) - CStudioRenderContext__LoadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x44\x24\x00\x48\x89\x54\x24\x00\x53\x57\x41\x55\x48\x81\xEC\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxx????"); + CStudioRenderContext__LoadModel = g_GameDll.FindPatternSIMD("4C 89 44 24 ?? 48 89 54 24 ?? 53 57 41 55 48 81 EC ?? ?? ?? ??"); #elif defined (GAMEDLL_S3) - CStudioRenderContext__LoadModel = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x44\x24\x00\x48\x89\x54\x24\x00\x48\x89\x4C\x24\x00\x53\x55\x56\x57\x48\x83\xEC\x78"), "xxxx?xxxx?xxxx?xxxxxxxx"); + CStudioRenderContext__LoadModel = g_GameDll.FindPatternSIMD("4C 89 44 24 ?? 48 89 54 24 ?? 48 89 4C 24 ?? 53 55 56 57 48 83 EC 78"); #endif// 0x1404554C0 // 4C 89 44 24 ? 48 89 54 24 ? 48 89 4C 24 ? 53 55 56 57 48 83 EC 78 // #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - CStudioRenderContext__LoadMaterials = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x44\x24\x00\x55\x56\x41\x57"), "xxxx?xxxx"); + CStudioRenderContext__LoadMaterials = g_GameDll.FindPatternSIMD("4C 89 44 24 ?? 55 56 41 57"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - CStudioRenderContext__LoadMaterials = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x4C\x89\x40\x18\x55\x56\x41\x55"), "xxxxxxxxxxx"); + CStudioRenderContext__LoadMaterials = g_GameDll.FindPatternSIMD("48 8B C4 4C 89 40 18 55 56 41 55"); #endif// 0x140456B50 // 48 8B C4 4C 89 40 18 55 56 41 55 // } virtual void GetVar(void) const { } diff --git a/r5dev/tier0/commandline.h b/r5dev/tier0/commandline.h index 1baf3268..8f9eacfa 100644 --- a/r5dev/tier0/commandline.h +++ b/r5dev/tier0/commandline.h @@ -30,9 +30,8 @@ class VCommandLine : public IDetour virtual void GetFun(void) const { } virtual void GetVar(void) const { - g_pCmdLine = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x40\x55\x48\x83\xEC\x20\x48\x8D\x6C\x24\x00\x48\x89\x5D\x10\x49\xC7\xC0\x00\x00\x00\x00"), - "xxxxxxxxxx?xxxxxxx????").FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 250).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pCmdLine = g_GameDll.FindPatternSIMD("40 55 48 83 EC 20 48 8D 6C 24 ?? 48 89 5D 10 49 C7 C0 ?? ?? ?? ??") + .FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 250).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/tier0/jobthread.cpp b/r5dev/tier0/jobthread.cpp index df225c42..1de1228d 100644 --- a/r5dev/tier0/jobthread.cpp +++ b/r5dev/tier0/jobthread.cpp @@ -9,13 +9,11 @@ void* HJT_HelpWithAnything(bool bShouldLoadPak) { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - static void* retaddr = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x8B\xC4\x56\x41\x54\x41\x57\x48\x81\xEC\x00\x00\x00\x00\xF2\x0F\x10\x05\x00\x00\x00\x00"), - "xxxxxxxxxxx????xxxx????").Offset(0x400).FindPatternSelf("48 8B ?? ?? ?? ?? 01", CMemory::Direction::DOWN).RCast(); + static void* retaddr = g_GameDll.FindPatternSIMD("48 8B C4 56 41 54 41 57 48 81 EC ?? ?? ?? ?? F2 0F 10 05 ?? ?? ?? ??") + .Offset(0x400).FindPatternSelf("48 8B ?? ?? ?? ?? 01", CMemory::Direction::DOWN).RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - static void* retaddr = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x8B\xC4\x00\x41\x54\x41\x55\x48\x81\xEC\x70\x04\x00\x00\xF2\x0F\x10\x05\x00\x00\x00\x0B"), - "xxx?xxxxxxxxxxxxxxx???x").Offset(0x4A0).FindPatternSelf("48 8B ?? ?? ?? ?? 01", CMemory::Direction::DOWN).RCast(); + static void* retaddr = g_GameDll.FindPatternSIMD("48 8B C4 ?? 41 54 41 55 48 81 EC 70 04 ?? ?? F2 0F 10 05 ?? ?? ?? 0B") + .Offset(0x4A0).FindPatternSelf("48 8B ?? ?? ?? ?? 01", CMemory::Direction::DOWN).RCast(); #endif void* results = JT_HelpWithAnything(bShouldLoadPak); diff --git a/r5dev/tier0/jobthread.h b/r5dev/tier0/jobthread.h index 01916043..e4c3b2a2 100644 --- a/r5dev/tier0/jobthread.h +++ b/r5dev/tier0/jobthread.h @@ -33,14 +33,14 @@ class VJobThread : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_JT_ParallelCall = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x58\x10\x48\x89\x70\x18\x55\x57\x41\x57"), "xxxxxxxxxxxxxxx"); - p_JT_HelpWithAnything = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x30\x80\x3D\x00\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxx?????"); + p_JT_ParallelCall = g_GameDll.FindPatternSIMD("48 8B C4 48 89 58 10 48 89 70 18 55 57 41 57"); + p_JT_HelpWithAnything = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 30 80 3D ?? ?? ?? ?? ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_JT_ParallelCall = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x48\x89\x58\x08\x48\x89\x78\x10\x55\x48\x8D\x68\xA1\x48\x81\xEC\x00\x00\x00\x00\x0F\x29\x70\xE8\x48\x8D\x1D\x00\x00\x00\x00"), "xxxxxxxxxxxxxxxxxxx????xxxxxxx????"); - p_JT_HelpWithAnything = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x80\x3D\x00\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxx?????"); + p_JT_ParallelCall = g_GameDll.FindPatternSIMD("48 8B C4 48 89 58 08 48 89 78 10 55 48 8D 68 A1 48 81 EC ?? ?? ?? ?? 0F 29 70 E8 48 8D 1D ?? ?? ?? ??"); + p_JT_HelpWithAnything = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 80 3D ?? ?? ?? ?? ??"); #endif - p_JT_AcquireFifoLock = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x08\x65\x48\x8B\x04\x25\x00\x00\x00\x00\x4C\x8B\xC1"), "xxxxxxxxx????xxx"); - p_JT_ReleaseFifoLock = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x44\x8B\x11"), "xxxxxxx"); + p_JT_AcquireFifoLock = g_GameDll.FindPatternSIMD("48 83 EC 08 65 48 8B 04 25 ?? ?? ?? ?? 4C 8B C1"); + p_JT_ReleaseFifoLock = g_GameDll.FindPatternSIMD("48 83 EC 28 44 8B 11"); JT_ParallelCall = p_JT_ParallelCall.RCast(); /*48 8B C4 48 89 58 08 48 89 78 10 55 48 8D 68 A1 48 81 EC ?? ?? ?? ?? 0F 29 70 E8 48 8D 1D ?? ?? ?? ??*/ JT_HelpWithAnything = p_JT_HelpWithAnything.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 80 3D ?? ?? ?? ?? ??*/ diff --git a/r5dev/tier0/memstd.h b/r5dev/tier0/memstd.h index e9a31ecd..76a3abec 100644 --- a/r5dev/tier0/memstd.h +++ b/r5dev/tier0/memstd.h @@ -61,13 +61,12 @@ class VMemStd : public IDetour } virtual void GetFun(void) const { - p_CreateGlobalMemAlloc = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\xBB\x00\x00\x00\x00\x33\xC0"), "xxxxxxx????xx"); + p_CreateGlobalMemAlloc = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 BB ?? ?? ?? ?? 33 C0"); v_CreateGlobalMemAlloc = p_CreateGlobalMemAlloc.RCast(); /*40 53 48 83 EC 20 BB ?? ?? ?? ?? 33 C0*/ } virtual void GetVar(void) const { - g_pMemAllocSingleton = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x41\x8B\xD8"), - "xxxx?xxxx????xxx").OffsetSelf(0x5A).FindPatternSelf("48 8B", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pMemAllocSingleton = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 41 8B D8").OffsetSelf(0x5A).FindPatternSelf("48 8B", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/tier0/platform_internal.h b/r5dev/tier0/platform_internal.h index 794df2c7..185ce982 100644 --- a/r5dev/tier0/platform_internal.h +++ b/r5dev/tier0/platform_internal.h @@ -20,15 +20,15 @@ class VPlatform : public IDetour } virtual void GetFun(void) const { - p_Plat_FloatTime = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x80\x3D\x00\x00\x00\x00\x00\x75\x05\xE8\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x74\x1D"), "xxxxxx?????xxx????xx?????xx"); - p_Plat_MSTime = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x80\x3D\x00\x00\x00\x00\x00\x75\x05\xE8\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x74\x2A"), "xxxxxx?????xxx????xx?????xx"); + p_Plat_FloatTime = g_GameDll.FindPatternSIMD("48 83 EC 28 80 3D ?? ?? ?? ?? ?? 75 05 E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 74 1D"); + p_Plat_MSTime = g_GameDll.FindPatternSIMD("48 83 EC 28 80 3D ?? ?? ?? ?? ?? 75 05 E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 74 2A"); v_Plat_FloatTime = p_Plat_FloatTime.RCast(); /*48 83 EC 28 80 3D ? ? ? ? ? 75 05 E8 ? ? ? ? 80 3D ? ? ? ? ? 74 1D*/ v_Plat_MSTime = p_Plat_MSTime.RCast(); /*48 83 EC 28 80 3D ? ? ? ? ? 75 05 E8 ? ? ? ? 80 3D ? ? ? ? ? 74 2A*/ } virtual void GetVar(void) const { - g_flErrorTimeStamp = g_GameDll.FindPatternSIMD(reinterpret_cast("\x0F\x57\xC0\xF2\x0F\x11\x05\x00\x00\x00\x00\xC3"), "xxxxxxx????x").FindPatternSelf("F2 0F").ResolveRelativeAddressSelf(0x4, 0x8).RCast(); + g_flErrorTimeStamp = g_GameDll.FindPatternSIMD("0F 57 C0 F2 0F 11 05 ?? ?? ?? ?? C3").FindPatternSelf("F2 0F").ResolveRelativeAddressSelf(0x4, 0x8).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/tier0/threadtools.h b/r5dev/tier0/threadtools.h index 28ba2594..ae41553a 100644 --- a/r5dev/tier0/threadtools.h +++ b/r5dev/tier0/threadtools.h @@ -255,9 +255,9 @@ class VThreadTools : public IDetour } virtual void GetFun(void) const { - p_MutexInternal_WaitForLock = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xD9\xFF\x15\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxx????"); - p_MutexInternal_ReleaseWaiter = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x8B\x41\x04\x48\x8B\xD9\x83\xE8\x01"), "xxxxxxxxxxxxxxx"); - p_DeclareCurrentThreadIsMainThread = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\xFF\x15\x00\x00\x00\x00\x89\x05\x00\x00\x00\x00\x48\x83\xC4\x28"), "xxxxxx????xx????xxxx"); + p_MutexInternal_WaitForLock = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B D9 FF 15 ?? ?? ?? ??"); + p_MutexInternal_ReleaseWaiter = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 8B 41 04 48 8B D9 83 E8 01"); + p_DeclareCurrentThreadIsMainThread = g_GameDll.FindPatternSIMD("48 83 EC 28 FF 15 ?? ?? ?? ?? 89 05 ?? ?? ?? ?? 48 83 C4 28"); v_MutexInternal_WaitForLock = p_MutexInternal_WaitForLock.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B D9 FF 15 ?? ?? ?? ??*/ v_MutexInternal_ReleaseWaiter = p_MutexInternal_ReleaseWaiter.RCast(); /*40 53 48 83 EC 20 8B 41 04 48 8B D9 83 E8 01*/ @@ -266,8 +266,7 @@ class VThreadTools : public IDetour virtual void GetVar(void) const { g_ThreadMainThreadID = p_DeclareCurrentThreadIsMainThread.FindPattern("89 05").ResolveRelativeAddressSelf(0x2, 0x6).RCast(); - g_ThreadServerFrameThreadID = g_GameDll.FindPatternSIMD(reinterpret_cast("\x83\x79\x00\x00\x75\x28\x8B"), "xx?xxxx") - .FindPatternSelf("8B 05").ResolveRelativeAddressSelf(0x2, 0x6).RCast(); + g_ThreadServerFrameThreadID = g_GameDll.FindPatternSIMD("83 79 ?? ?? 75 28 8B").FindPatternSelf("8B 05").ResolveRelativeAddressSelf(0x2, 0x6).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/tier0/tslist.h b/r5dev/tier0/tslist.h index 16a88628..86247862 100644 --- a/r5dev/tier0/tslist.h +++ b/r5dev/tier0/tslist.h @@ -17,13 +17,11 @@ class VTSListBase : public IDetour virtual void GetVar(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - g_pMallocPool = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xD9\xFF\x15\x00\x00\x00\x00"), - "xxxx?xxxx?xxxx?xxxxxxxxxxxx????xxxxx????").Offset(0x600).FindPatternSelf("48 8D 15 ?? ?? ?? 01", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pMallocPool = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B D9 FF 15 ?? ?? ?? ??") + .Offset(0x600).FindPatternSelf("48 8D 15 ?? ?? ?? 01", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - g_pMallocPool = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xAC\x24\x00\x00\x00\x00\xB8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x2B\xE0\x48\x8B\xD9"), - "xxxx?xxxx?xxxx?xxxxxxxxxxxxx????x????x????xxxxxx").Offset(0x130).FindPatternSelf("48 8D 15 ?? ?? ?? 01", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pMallocPool = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B D9") + .Offset(0x130).FindPatternSelf("48 8D 15 ?? ?? ?? 01", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #endif } virtual void GetCon(void) const { } diff --git a/r5dev/tier1/IConVar.h b/r5dev/tier1/IConVar.h index f5938c58..015ef401 100644 --- a/r5dev/tier1/IConVar.h +++ b/r5dev/tier1/IConVar.h @@ -126,13 +126,13 @@ class VConVar : public IDetour } virtual void GetFun(void) const { - p_ConVar_IsFlagSet = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x41\x48\x85\x50\x38"), "xxxxxxx"); + p_ConVar_IsFlagSet = g_GameDll.FindPatternSIMD("48 8B 41 48 85 50 38"); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_ConVar_Register = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x30\xF3\x0F\x10\x44\x24\x00"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxx?"); + p_ConVar_Register = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 30 F3 0F 10 44 24 ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_ConVar_Register = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x40\xF3\x0F\x10\x84\x24\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxx????"); + p_ConVar_Register = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 40 F3 0F 10 84 24 ?? ?? ?? ??"); #endif - p_ConVar_PrintDescription = g_GameDll.FindPatternSIMD(reinterpret_cast("\xB8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x2B\xE0\x48\x8B\x01\x48\x89\x9C\x24\x00\x00\x00\x00"), "x????x????xxxxxxxxxx????"); + p_ConVar_PrintDescription = g_GameDll.FindPatternSIMD("B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B 01 48 89 9C 24 ?? ?? ?? ??"); v_ConVar_IsFlagSet = p_ConVar_IsFlagSet.RCast(); /*48 8B 41 48 85 50 38*/ v_ConVar_Register = p_ConVar_Register.RCast(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 40 F3 0F 10 84 24 ? ? ? ?*/ diff --git a/r5dev/tier1/cmd.h b/r5dev/tier1/cmd.h index e93f2ee3..4479b563 100644 --- a/r5dev/tier1/cmd.h +++ b/r5dev/tier1/cmd.h @@ -204,12 +204,12 @@ class VConCommand : public IDetour } virtual void GetFun(void) const { - p_Cbuf_AddText = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x63\xD9\x41\x8B\xF8\x48\x8D\x0D\x00\x00\x00\x00\x48\x8B\xF2\xFF\x15\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x41\xB9\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxxxxxx????xxxxx????xxx????xx????"); - p_Cbuf_Execute = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\xFF\x15\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxx????"); - p_Cmd_ForwardToServer = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x44\x8B\x59\x04"), "xxxx?xxxx?xxxx?xxxx????xxxx"); - p_ConCommandBase_IsFlagSet = g_GameDll.FindPatternSIMD(reinterpret_cast("\x85\x51\x38\x0F\x95\xC0\xC3"), "xxxxxxx"); - p_NullSub = g_GameDll.FindPatternSIMD(reinterpret_cast("\xC2\x00\x00\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x40\x53\x48\x83\xEC\x20\x48\x8D\x05\x00\x00\x00\x00"), "xxxxxxxxxxxxxxxxxxxxxxxxx????"); - p_CallbackStub = g_GameDll.FindPatternSIMD(reinterpret_cast("\x33\xC0\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x80\x49\x68\x08"), "xxxxxxxxxxxxxxxxxxxx"); + p_Cbuf_AddText = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 63 D9 41 8B F8 48 8D 0D ?? ?? ?? ?? 48 8B F2 FF 15 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 41 B9 ?? ?? ?? ??"); + p_Cbuf_Execute = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 FF 15 ?? ?? ?? ??"); + p_Cmd_ForwardToServer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 44 8B 59 04"); + p_ConCommandBase_IsFlagSet = g_GameDll.FindPatternSIMD("85 51 38 0F 95 C0 C3"); + p_NullSub = g_GameDll.FindPatternSIMD("C2 ?? ?? CC CC CC CC CC CC CC CC CC CC CC CC CC 40 53 48 83 EC 20 48 8D 05 ?? ?? ?? ??"); + p_CallbackStub = g_GameDll.FindPatternSIMD("33 C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC 80 49 68 08"); Cbuf_AddText = p_Cbuf_AddText.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 63 D9 41 8B F8 48 8D 0D ?? ?? ?? ?? 48 8B F2 FF 15 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 41 B9 ?? ?? ?? ??*/ Cbuf_Execute = p_Cbuf_Execute.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 FF 15 ?? ?? ?? ??*/ diff --git a/r5dev/tier1/cvar.h b/r5dev/tier1/cvar.h index 62d35711..82446557 100644 --- a/r5dev/tier1/cvar.h +++ b/r5dev/tier1/cvar.h @@ -326,9 +326,8 @@ class VCVar : public IDetour virtual void GetFun(void) const { } virtual void GetVar(void) const { - g_pCVar = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x83\xEC\x28\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\x48\x85\xC0\x48\x89\x15"), - "xxxxxxx????xxx????xxxxxx").FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pCVar = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 85 C0 48 89 15") + .FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/vgui/vgui_baseui_interface.h b/r5dev/vgui/vgui_baseui_interface.h index 12dd5b02..01452e13 100644 --- a/r5dev/vgui/vgui_baseui_interface.h +++ b/r5dev/vgui/vgui_baseui_interface.h @@ -55,26 +55,25 @@ class VEngineVGui : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_CEngineVGui_Paint = g_GameDll.FindPatternSIMD(reinterpret_cast("\x89\x54\x24\x10\x55\x56\x41\x55\x48\x81\xEC\x00\x00\x00\x00"), "xxxxxxxxxxx????"); + p_CEngineVGui_Paint = g_GameDll.FindPatternSIMD("89 54 24 10 55 56 41 55 48 81 EC ?? ?? ?? ??"); CEngineVGui_Paint = p_CEngineVGui_Paint.RCast(); /*41 55 41 56 48 83 EC 78 44 8B EA*/ - p_CEngineVGui_RenderStart = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x53\x56\x57\x48\x81\xEC\x00\x00\x00\x00\x0F\x29\x70\xD8"), "xxxxxxxxx????xxxx"); + p_CEngineVGui_RenderStart = g_GameDll.FindPatternSIMD("48 8B C4 53 56 57 48 81 EC ?? ?? ?? ?? 0F 29 70 D8"); CEngineVGui_RenderStart = p_CEngineVGui_RenderStart.RCast(); /*48 8B C4 53 56 57 48 81 EC ?? ?? ?? ?? 0F 29 70 D8*/ #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_CEngineVGui_Paint = g_GameDll.FindPatternSIMD(reinterpret_cast("\x41\x55\x41\x56\x48\x83\xEC\x78\x44\x8B\xEA"), "xxxxxxxxxxx"); + p_CEngineVGui_Paint = g_GameDll.FindPatternSIMD("41 55 41 56 48 83 EC 78 44 8B EA"); CEngineVGui_Paint = p_CEngineVGui_Paint.RCast(); /*41 55 41 56 48 83 EC 78 44 8B EA*/ - p_CEngineVGui_RenderStart = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9"), "xxxxxx????xxx"); + p_CEngineVGui_RenderStart = g_GameDll.FindPatternSIMD("40 53 57 48 81 EC ?? ?? ?? ?? 48 8B F9"); CEngineVGui_RenderStart = p_CEngineVGui_RenderStart.RCast(); /*40 53 57 48 81 EC ?? ?? ?? ?? 48 8B F9*/ #endif - p_CEngineVGui_RenderEnd = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\x0D\x00\x00\x00\x00\xC6\x05\x00\x00\x00\x00\x00\x48\x8B\x01"), "xxxxxxxxx????xx?????xxx"); + p_CEngineVGui_RenderEnd = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B 0D ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ?? 48 8B 01"); CEngineVGui_RenderEnd = p_CEngineVGui_RenderEnd.RCast(); /*40 53 48 83 EC 20 48 8B 0D ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ?? 48 8B 01*/ } virtual void GetVar(void) const { - g_pEngineVGui = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x8B\xC4\x48\x89\x48\x08\x48\x89\x50\x10\x4C\x89\x40\x18\x4C\x89\x48\x20\x53\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xD9\x48\x8D\x78\x10\xE8\x00\x00\x00\x00\x48\x89\x7C\x24\x00\x48\x8D\x54\x24\x00\x33\xFF\x4C\x8B\xCB\x41\xB8\x00\x00\x00\x00\x48\x89\x7C\x24\x00\x48\x8B\x08\x48\x83\xC9\x01\xE8\x00\x00\x00\x00\x85\xC0\x48\x8D\x54\x24\x00"), - "xxxxxxxxxxxxxxxxxxxxxxxx????xxxxxxxx????xxxx?xxxx?xxxxxxx????xxxx?xxxxxxxx????xxxxxx?").FindPatternSelf("48 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pEngineVGui = g_GameDll.FindPatternSIMD("48 8B C4 48 89 48 08 48 89 50 10 4C 89 40 18 4C 89 48 20 53 57 48 81 EC ?? ?? ?? ?? 48 8B D9 48 8D 78 10 E8 ?? ?? ?? ?? 48 89 7C 24 ?? 48 8D 54 24 ?? 33 FF 4C 8B CB 41 B8 ?? ?? ?? ?? 48 89 7C 24 ?? 48 8B 08 48 83 C9 01 E8 ?? ?? ?? ?? 85 C0 48 8D 54 24 ??") + .FindPatternSelf("48 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/vgui/vgui_fpspanel.h b/r5dev/vgui/vgui_fpspanel.h index 25dc32cc..120df57d 100644 --- a/r5dev/vgui/vgui_fpspanel.h +++ b/r5dev/vgui/vgui_fpspanel.h @@ -18,7 +18,7 @@ class VFPSPanel : public IDetour } virtual void GetFun(void) const { - p_CFPSPanel_Paint = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x56\x41\x00\x48\x8D\xA8\x00\xFD\xFF\xFF\x48\x81\xEC\x80"), "xxxxxx?xxx?xxxxxxx"); + p_CFPSPanel_Paint = g_GameDll.FindPatternSIMD("48 8B C4 55 56 41 ?? 48 8D A8 ?? FD FF FF 48 81 EC 80"); CFPSPanel_Paint = p_CFPSPanel_Paint.RCast(); /*48 8B C4 55 56 41 ?? 48 8D A8 ?? FD FF FF 48 81 EC 80*/ } virtual void GetVar(void) const { } diff --git a/r5dev/vguimatsurface/MatSystemSurface.h b/r5dev/vguimatsurface/MatSystemSurface.h index 290c4180..238bba81 100644 --- a/r5dev/vguimatsurface/MatSystemSurface.h +++ b/r5dev/vguimatsurface/MatSystemSurface.h @@ -24,22 +24,19 @@ class VMatSystemSurface : public IDetour } virtual void GetFun(void) const { - p_CMatSystemSurface_DrawColoredText = g_GameDll.FindPatternSIMD(reinterpret_cast("\x4C\x8B\xDC\x48\x83\xEC\x68\x49\x8D\x43\x58\x0F\x57\xC0"), "xxxxxxxxxxxxxx"); + p_CMatSystemSurface_DrawColoredText = g_GameDll.FindPatternSIMD("4C 8B DC 48 83 EC 68 49 8D 43 58 0F 57 C0"); CMatSystemSurface_DrawColoredText = p_CMatSystemSurface_DrawColoredText.RCast(); /*4C 8B DC 48 83 EC 68 49 8D 43 58 0F 57 C0*/ } virtual void GetVar(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - g_pMatSystemSurface = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x83\x3D\x00\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00"), - "xxx?????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????").ResolveRelativeAddressSelf(0x3, 0x8).RCast(); + g_pMatSystemSurface = g_GameDll.FindPatternSIMD("48 83 3D ?? ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ??") + .ResolveRelativeAddressSelf(0x3, 0x8).RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - g_pMatSystemSurface = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x83\xEC\x28\x48\x83\x3D\x00\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00"), "xxxxxxx?????xxx????") + g_pMatSystemSurface = g_GameDll.FindPatternSIMD("48 83 EC 28 48 83 3D ?? ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ??") .FindPatternSelf("48 83 3D", CMemory::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x8).RCast(); #endif - g_pVGuiSurface = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x8B\x81\x00\x00\x00\x00"), "xxx????xxxxxxxxxxxx????xxxxxxxxxxx????") + g_pVGuiSurface = g_GameDll.FindPatternSIMD("48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 8B 81 ?? ?? ?? ??") .ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } diff --git a/r5dev/vpc/IAppSystem.h b/r5dev/vpc/IAppSystem.h index f8a4d5a2..d21bd672 100644 --- a/r5dev/vpc/IAppSystem.h +++ b/r5dev/vpc/IAppSystem.h @@ -14,7 +14,7 @@ class VAppSystem : public IDetour } virtual void GetFun(void) const { - //p_IAppSystem_LoadLibrary = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x48\x8B\x0D\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x85\xC9\x74\x11"), "xxxxxxx????xxx????xxx????xxxxx"); + //p_IAppSystem_LoadLibrary = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 85 C9 74 11"); //IAppSystem_LoadLibrary = p_IAppSystem_LoadLibrary.RCast(); /*48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 85 C9 74 11*/ } virtual void GetVar(void) const { } diff --git a/r5dev/vpc/interfaces.h b/r5dev/vpc/interfaces.h index b8bb8ca5..32bd57d0 100644 --- a/r5dev/vpc/interfaces.h +++ b/r5dev/vpc/interfaces.h @@ -108,8 +108,7 @@ class VFactory : public IDetour virtual void GetFun(void) const { } virtual void GetVar(void) const { - s_pInterfacesRegs = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE9\x00\x00\x00\x00\xCC\xCC\x89\x91\x00\x00\x00\x00"), "x????xxxx????") - .FollowNearCallSelf().FindPatternSelf("48 8B 1D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7); + s_pInterfacesRegs = g_GameDll.FindPatternSIMD("E9 ?? ?? ?? ?? CC CC 89 91 ?? ?? ?? ??").FollowNearCallSelf().FindPatternSelf("48 8B 1D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/vpc/keyvalues.h b/r5dev/vpc/keyvalues.h index 5fb18af2..ca66ec5a 100644 --- a/r5dev/vpc/keyvalues.h +++ b/r5dev/vpc/keyvalues.h @@ -208,19 +208,19 @@ class VKeyValues : public IDetour virtual void GetFun(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - p_KeyValues_FindKey = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x10\x48\x89\x6C\x24\x18\x48\x89\x74\x24\x20\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x20\x01\x00\x00\x45"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - p_KeyValues_GetCurrentPlaylist = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x0D\x00\x00\x00\x00\x48\x85\xC9\x75\x08\x48\x8D\x05\x00\x00\x00\x00"), "xxx????xxxxxxxx????"); - p_KeyValues_ReadKeyValuesFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x56\x57\x41\x54\x41\x57\x48\x8D\x6C\x24\x00"), "xxxx?xxxxxxxxxxx?"); - p_KeyValues_LoadFromFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x4C\x89\x4C\x24\x00\x4C\x89\x44\x24\x00\x48\x89\x4C\x24\x00\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\x00"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxxxxx?"); + p_KeyValues_FindKey = g_GameDll.FindPatternSIMD("48 89 5C 24 10 48 89 6C 24 18 48 89 74 24 20 57 41 54 41 55 41 56 41 57 48 81 EC 20 01 ?? ?? 45"); + p_KeyValues_GetCurrentPlaylist = g_GameDll.FindPatternSIMD("48 8B 0D ?? ?? ?? ?? 48 85 C9 75 08 48 8D 05 ?? ?? ?? ??"); + p_KeyValues_ReadKeyValuesFile = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 56 57 41 54 41 57 48 8D 6C 24 ??"); + p_KeyValues_LoadFromFile = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 4C 89 4C 24 ?? 4C 89 44 24 ?? 48 89 4C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ??"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - p_KeyValues_FindKey = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x57\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x45"), "xxxxxxxx????x"); - p_KeyValues_GetCurrentPlaylist = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x05\x00\x00\x00\x00\x48\x85\xC0\x75\x08\x48\x8D\x05\x00\x00\x00\x00\xC3\x0F\xB7\x50\x2A"), "xxx????xxxxxxxx????xxxxx"); - p_KeyValues_ReadKeyValuesFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x53\x57\x41\x54\x48\x8D\x68\xA1"), "xxxxxxxxxxxx"); - p_KeyValues_LoadFromFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x4C\x89\x4C\x24\x00\x48\x89\x4C\x24\x00\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C\x24\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxx?"); + p_KeyValues_FindKey = g_GameDll.FindPatternSIMD("40 56 57 41 57 48 81 EC ?? ?? ?? ?? 45"); + p_KeyValues_GetCurrentPlaylist = g_GameDll.FindPatternSIMD("48 8B 05 ?? ?? ?? ?? 48 85 C0 75 08 48 8D 05 ?? ?? ?? ?? C3 0F B7 50 2A"); + p_KeyValues_ReadKeyValuesFile = g_GameDll.FindPatternSIMD("48 8B C4 55 53 57 41 54 48 8D 68 A1"); + p_KeyValues_LoadFromFile = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 4C 89 4C 24 ?? 48 89 4C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ??"); #endif - p_KeyValues_LoadPlaylists = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x56\x57\x41\x56\x48\x83\xEC\x40\x48\x8B\xF1"), "xxxx?xxxx?xxxxxxxxxxx"); - p_KeyValues_ParsePlaylists = g_GameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x74\x0C"), "x????xx?????xx").FollowNearCallSelf(); - p_KeyValues_RecursiveSaveToFile = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x53\x00\x57\x41\x55\x41\x00\x48\x83"), "xxxx?xxxx?xx"); + p_KeyValues_LoadPlaylists = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 40 48 8B F1"); + p_KeyValues_ParsePlaylists = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 74 0C").FollowNearCallSelf(); + p_KeyValues_RecursiveSaveToFile = g_GameDll.FindPatternSIMD("48 8B C4 53 ?? 57 41 55 41 ?? 48 83"); KeyValues_FindKey = p_KeyValues_FindKey.RCast(); /*40 56 57 41 57 48 81 EC 30 01 00 00 45 0F B6 F8*/ KeyValues_LoadPlaylists = p_KeyValues_ParsePlaylists.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 40 48 8B F1*/ @@ -233,13 +233,11 @@ class VKeyValues : public IDetour virtual void GetVar(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - g_pPlaylistKeyValues = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x8B\xC4\x53\x57\x41\x56\x48\x81\xEC\x20"), - "xxxxxxxxxxx").FindPatternSelf("48 8B 2D", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pPlaylistKeyValues = g_GameDll.FindPatternSIMD("48 8B C4 53 57 41 56 48 81 EC 20") + .FindPatternSelf("48 8B 2D", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - g_pPlaylistKeyValues = g_GameDll.FindPatternSIMD(reinterpret_cast( - "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x48\x83\xEC\x20\x48\x8B\xF9\xE8\xB4"), - "xxxxxxxxxxxxxxxxxxxxxxxxx").FindPatternSelf("48 8B 0D", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pPlaylistKeyValues = g_GameDll.FindPatternSIMD("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B F9 E8 B4") + .FindPatternSelf("48 8B 0D", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #endif } virtual void GetCon(void) const { } diff --git a/r5dev/vphysics/QHull.h b/r5dev/vphysics/QHull.h index 8b13d11d..f9f81988 100644 --- a/r5dev/vphysics/QHull.h +++ b/r5dev/vphysics/QHull.h @@ -23,10 +23,10 @@ class VQHull : public IDetour } virtual void GetFun(void) const { - p_QHull_PrintFunc = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x08\x48\x89\x54\x24\x10\x4C\x89\x44\x24\x18\x4C\x89\x4C\x24\x20\x53\xB8\x40\x27\x00\x00\x00\x00\x00\x00\x00\x48"), "xxxxxxxxxxxxxxxxxxxxxxxxxx????xx"); + p_QHull_PrintFunc = g_GameDll.FindPatternSIMD("48 89 4C 24 08 48 89 54 24 10 4C 89 44 24 18 4C 89 4C 24 20 53 B8 40 27 ?? ?? ?? ?? ?? ?? ?? 48"); QHull_PrintFunc = p_QHull_PrintFunc.RCast(); /*48 89 4C 24 08 48 89 54 24 10 4C 89 44 24 18 4C 89 4C 24 20 53 B8 40 27 00 00 ?? ?? ?? ?? 00 48*/ - //p_speex_warning_int = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x54\x24\x10\x4C\x89\x44\x24\x18\x4C\x89\x4C\x24\x20\x53\x56\x57\x48\x83\xEC\x30\x48\x8B\xFA\x48\x8D\x74\x24\x60\x48\x8B"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + //p_speex_warning_int = g_GameDll.FindPatternSIMD("48 89 54 24 10 4C 89 44 24 18 4C 89 4C 24 20 53 56 57 48 83 EC 30 48 8B FA 48 8D 74 24 60 48 8B"); //speex_warning_int = p_speex_warning_int.RCast(); /*48 89 54 24 10 4C 89 44 24 18 4C 89 4C 24 20 53 56 57 48 83 EC 30 48 8B FA 48 8D 74 24 60 48 8B*/ } virtual void GetVar(void) const { } diff --git a/r5dev/vstdlib/callback.h b/r5dev/vstdlib/callback.h index 04455b16..5c00506c 100644 --- a/r5dev/vstdlib/callback.h +++ b/r5dev/vstdlib/callback.h @@ -80,8 +80,8 @@ class VCallback : public IDetour } virtual void GetFun(void) const { - p_SetupGamemode = g_GameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\xD9\x48\xC7\xC0\x00\x00\x00\x00"), "xxxxxxxxxxxx????"); - p_DownloadPlaylists_f = g_GameDll.FindPatternSIMD(reinterpret_cast("\x33\xC9\xC6\x05\x00\x00\x00\x00\x00\xE9\x00\x00\x00\x00"), "xxxx?????x????"); + p_SetupGamemode = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B D9 48 C7 C0 ?? ?? ?? ??"); + p_DownloadPlaylists_f = g_GameDll.FindPatternSIMD("33 C9 C6 05 ?? ?? ?? ?? ?? E9 ?? ?? ?? ??"); SetupGamemode = p_SetupGamemode.RCast(); /*40 53 48 83 EC 20 48 8B D9 48 C7 C0 ?? ?? ?? ??*/ _DownloadPlaylists_f = p_DownloadPlaylists_f.RCast(); /*33 C9 C6 05 ?? ?? ?? ?? ?? E9 ?? ?? ?? ??*/ diff --git a/r5dev/vstdlib/keyvaluessystem.h b/r5dev/vstdlib/keyvaluessystem.h index f84af7a8..57aad31b 100644 --- a/r5dev/vstdlib/keyvaluessystem.h +++ b/r5dev/vstdlib/keyvaluessystem.h @@ -50,13 +50,10 @@ class HKeyValuesSystem : public IDetour virtual void GetFun(void) const { } virtual void GetVar(void) const { - g_pKeyValuesSystem = g_GameDll.FindPatternSIMD( - reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x56\x57\x41\x56\x48\x83\xEC\x40\x48\x8B\xF1"), "xxxx?xxxx?xxxxxxxxxxx") + g_pKeyValuesSystem = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 40 48 8B F1") .FindPatternSelf("48 8D 0D ?? ?? ?? 01", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); - g_pKeyValuesMemPool = g_GameDll.FindPatternSIMD( - reinterpret_cast("\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x85\xD2"), "xxx????xxxxxxxxxxxx"). - ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pKeyValuesMemPool = g_GameDll.FindPatternSIMD("48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 85 D2").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/windows/id3dx.h b/r5dev/windows/id3dx.h index e0a1d12f..4f6df8ac 100644 --- a/r5dev/windows/id3dx.h +++ b/r5dev/windows/id3dx.h @@ -121,7 +121,7 @@ class VDXGI : public IDetour virtual void GetFun(void) const { } virtual void GetVar(void) const { - p_gGameDevice = g_GameDll.FindPatternSIMD(reinterpret_cast("\xD3\xEA\x48\x8B\x0D\x00\x00\x00\x00"), "xxxxx????").FindPatternSelf("48 8B").ResolveRelativeAddressSelf(0x3, 0x7); + p_gGameDevice = g_GameDll.FindPatternSIMD("D3 EA 48 8B 0D ?? ?? ?? ??").FindPatternSelf("48 8B").ResolveRelativeAddressSelf(0x3, 0x7); g_ppGameDevice = p_gGameDevice.RCast(); /*D3 EA 48 8B 0D ? ? ? ?*/ } virtual void GetCon(void) const { } From f999372f37cdc036528234deaa579d31669524da Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 1 Dec 2022 22:47:39 +0100 Subject: [PATCH 02/20] Work in progress signature cache map loading and parsing --- r5dev/core/init.cpp | 52 +++++ r5dev/core/stdafx.h | 2 + r5dev/protoc/sig_map.pb.cc | 278 +++++++++++++++++++++++++ r5dev/protoc/sig_map.pb.h | 287 ++++++++++++++++++++++++++ r5dev/public/utility/binstream.cpp | 44 ++-- r5dev/public/utility/binstream.h | 23 +-- r5dev/public/utility/module.cpp | 18 +- r5dev/public/utility/sigcache.cpp | 37 ++++ r5dev/public/utility/sigcache.h | 32 +++ r5dev/resource/protobuf/sig_map.proto | 7 + r5dev/vproj/gamesdk.vcxproj | 8 + r5dev/vproj/gamesdk.vcxproj.filters | 13 ++ 12 files changed, 761 insertions(+), 40 deletions(-) create mode 100644 r5dev/protoc/sig_map.pb.cc create mode 100644 r5dev/protoc/sig_map.pb.h create mode 100644 r5dev/public/utility/sigcache.cpp create mode 100644 r5dev/public/utility/sigcache.h create mode 100644 r5dev/resource/protobuf/sig_map.proto diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index 6aa1b579..14af50c5 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -112,6 +112,7 @@ #include "game/client/viewrender.h" #endif // !DEDICATED #include "public/edict.h" +#include "public/utility/binstream.h" #ifndef DEDICATED #include "public/idebugoverlay.h" #include "inputsystem/inputsystem.h" @@ -472,11 +473,60 @@ void CheckCPU() // Respawn's engine and our SDK utilize POPCNT, SSE3 and SSSE3 ( } } +#include "protoc/sig_map.pb.h" + +bool SigDB_Init() +{ + CIOStream sigDbStream("bin\\startup.smap", CIOStream::Mode_t::READ); + + if (!sigDbStream.IsReadable()) + { + return false; + } + if (!sigDbStream.GetSize() > sizeof(SigDBHeader_t)) + { + return false; + } + + SigDBHeader_t sigDbHeader; + sigDbHeader.m_nMagic = sigDbStream.Read(); + + if (sigDbHeader.m_nMagic != SIGDB_MAGIC) + { + return false; + } + + sigDbHeader.m_nVersion = sigDbStream.Read(); + if (sigDbHeader.m_nMagic != SIGDB_VERSION) + { + return false; + } + + sigDbHeader.m_FileTime = sigDbStream.Read(); + + vector vData; + size_t nSize = (static_cast(sigDbStream.GetSize()) - sizeof(SigDBHeader_t)); + + vData.resize(nSize); + uint8_t* pBuf = vData.data(); + sigDbStream.Read(pBuf, nSize); + + if (!g_SigCache.m_Cache.ParseFromArray(pBuf, nSize)) + { + return false; + } + + return true; +} + + void DetourInit() // Run the sigscan { bool bLogAdr = (strstr(GetCommandLineA(), "-sig_toconsole") != nullptr); bool bInitDivider = false; + g_SigCache.m_bInitialized = SigDB_Init(); + for (const IDetour* pDetour : vDetour) { pDetour->GetCon(); // Constants. @@ -493,6 +543,8 @@ void DetourInit() // Run the sigscan pDetour->GetAdr(); } } + + g_SigCache.WriteCache(); } void DetourAddress() // Test the sigscan results { diff --git a/r5dev/core/stdafx.h b/r5dev/core/stdafx.h index 0d5bd3cf..9b7a72ab 100644 --- a/r5dev/core/stdafx.h +++ b/r5dev/core/stdafx.h @@ -86,6 +86,7 @@ #include "public/utility/utility.h" #include "public/utility/memaddr.h" #include "public/utility/module.h" +#include "public/utility/sigcache.h" #include "public/utility/httplib.h" #include "public/utility/vdf_parser.h" @@ -107,6 +108,7 @@ inline CModule g_RadAudioSystemDll = CModule("mileswin64.dll"); #else // No DirectX and Miles imports. inline CModule g_GameDll = CModule("r5apex_ds.exe"); #endif // !DEDICATED +inline CSigCache g_SigCache; #define VAR_NAME(varName) #varName diff --git a/r5dev/protoc/sig_map.pb.cc b/r5dev/protoc/sig_map.pb.cc new file mode 100644 index 00000000..c93d85b3 --- /dev/null +++ b/r5dev/protoc/sig_map.pb.cc @@ -0,0 +1,278 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sig_map.proto + +#include "sig_map.pb.h" + +#include + +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include + +PROTOBUF_PRAGMA_INIT_SEG +constexpr SigMap_Pb_SMapEntry_DoNotUse::SigMap_Pb_SMapEntry_DoNotUse( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){} +struct SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal { + constexpr SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal() {} + union { + SigMap_Pb_SMapEntry_DoNotUse _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal _SigMap_Pb_SMapEntry_DoNotUse_default_instance_; +constexpr SigMap_Pb::SigMap_Pb( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : smap_(){} +struct SigMap_PbDefaultTypeInternal { + constexpr SigMap_PbDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~SigMap_PbDefaultTypeInternal() {} + union { + SigMap_Pb _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SigMap_PbDefaultTypeInternal _SigMap_Pb_default_instance_; + +// =================================================================== + +SigMap_Pb_SMapEntry_DoNotUse::SigMap_Pb_SMapEntry_DoNotUse() {} +SigMap_Pb_SMapEntry_DoNotUse::SigMap_Pb_SMapEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : SuperType(arena) {} +void SigMap_Pb_SMapEntry_DoNotUse::MergeFrom(const SigMap_Pb_SMapEntry_DoNotUse& other) { + MergeFromInternal(other); +} + +// =================================================================== + +class SigMap_Pb::_Internal { + public: +}; + +SigMap_Pb::SigMap_Pb(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned), + smap_(arena) { + SharedCtor(); + if (!is_message_owned) { + RegisterArenaDtor(arena); + } + // @@protoc_insertion_point(arena_constructor:SigMap_Pb) +} +SigMap_Pb::SigMap_Pb(const SigMap_Pb& from) + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + _internal_metadata_.MergeFrom(from._internal_metadata_); + smap_.MergeFrom(from.smap_); + // @@protoc_insertion_point(copy_constructor:SigMap_Pb) +} + +inline void SigMap_Pb::SharedCtor() { +} + +SigMap_Pb::~SigMap_Pb() { + // @@protoc_insertion_point(destructor:SigMap_Pb) + if (GetArenaForAllocation() != nullptr) return; + SharedDtor(); + _internal_metadata_.Delete(); +} + +inline void SigMap_Pb::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); +} + +void SigMap_Pb::ArenaDtor(void* object) { + SigMap_Pb* _this = reinterpret_cast< SigMap_Pb* >(object); + (void)_this; +} +void SigMap_Pb::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void SigMap_Pb::SetCachedSize(int size) const { + _cached_size_.Set(size); +} + +void SigMap_Pb::Clear() { +// @@protoc_insertion_point(message_clear_start:SigMap_Pb) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + smap_.Clear(); + _internal_metadata_.Clear(); +} + +const char* SigMap_Pb::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + switch (tag >> 3) { + // map sMap = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(&smap_, ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* SigMap_Pb::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:SigMap_Pb) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // map sMap = 1; + if (!this->_internal_smap().empty()) { + typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::const_pointer + ConstPtr; + typedef ConstPtr SortItem; + typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst Less; + struct Utf8Check { + static void Check(ConstPtr p) { + (void)p; + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + p->first.data(), static_cast(p->first.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "SigMap_Pb.SMapEntry.key"); + } + }; + + if (stream->IsSerializationDeterministic() && + this->_internal_smap().size() > 1) { + ::std::unique_ptr items( + new SortItem[this->_internal_smap().size()]); + typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::size_type size_type; + size_type n = 0; + for (::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::const_iterator + it = this->_internal_smap().begin(); + it != this->_internal_smap().end(); ++it, ++n) { + items[static_cast(n)] = SortItem(&*it); + } + ::std::sort(&items[0], &items[static_cast(n)], Less()); + for (size_type i = 0; i < n; i++) { + target = SigMap_Pb_SMapEntry_DoNotUse::Funcs::InternalSerialize(1, items[static_cast(i)]->first, items[static_cast(i)]->second, target, stream); + Utf8Check::Check(&(*items[static_cast(i)])); + } + } else { + for (::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::const_iterator + it = this->_internal_smap().begin(); + it != this->_internal_smap().end(); ++it) { + target = SigMap_Pb_SMapEntry_DoNotUse::Funcs::InternalSerialize(1, it->first, it->second, target, stream); + Utf8Check::Check(&(*it)); + } + } + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:SigMap_Pb) + return target; +} + +size_t SigMap_Pb::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:SigMap_Pb) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // map sMap = 1; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_smap_size()); + for (::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::const_iterator + it = this->_internal_smap().begin(); + it != this->_internal_smap().end(); ++it) { + total_size += SigMap_Pb_SMapEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void SigMap_Pb::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast( + &from)); +} + +void SigMap_Pb::MergeFrom(const SigMap_Pb& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:SigMap_Pb) + GOOGLE_DCHECK_NE(&from, this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + smap_.MergeFrom(from.smap_); + _internal_metadata_.MergeFrom(from._internal_metadata_); +} + +void SigMap_Pb::CopyFrom(const SigMap_Pb& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:SigMap_Pb) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool SigMap_Pb::IsInitialized() const { + return true; +} + +void SigMap_Pb::InternalSwap(SigMap_Pb* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + smap_.InternalSwap(&other->smap_); +} + +std::string SigMap_Pb::GetTypeName() const { + return "SigMap_Pb"; +} + + +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::SigMap_Pb_SMapEntry_DoNotUse* Arena::CreateMaybeMessage< ::SigMap_Pb_SMapEntry_DoNotUse >(Arena* arena) { + return Arena::CreateMessageInternal< ::SigMap_Pb_SMapEntry_DoNotUse >(arena); +} +template<> PROTOBUF_NOINLINE ::SigMap_Pb* Arena::CreateMaybeMessage< ::SigMap_Pb >(Arena* arena) { + return Arena::CreateMessageInternal< ::SigMap_Pb >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/r5dev/protoc/sig_map.pb.h b/r5dev/protoc/sig_map.pb.h new file mode 100644 index 00000000..f5c73082 --- /dev/null +++ b/r5dev/protoc/sig_map.pb.h @@ -0,0 +1,287 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sig_map.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_sig_5fmap_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_sig_5fmap_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3019000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_sig_5fmap_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_sig_5fmap_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[2] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const uint32_t offsets[]; +}; +class SigMap_Pb; +struct SigMap_PbDefaultTypeInternal; +extern SigMap_PbDefaultTypeInternal _SigMap_Pb_default_instance_; +class SigMap_Pb_SMapEntry_DoNotUse; +struct SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal; +extern SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal _SigMap_Pb_SMapEntry_DoNotUse_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template<> ::SigMap_Pb* Arena::CreateMaybeMessage<::SigMap_Pb>(Arena*); +template<> ::SigMap_Pb_SMapEntry_DoNotUse* Arena::CreateMaybeMessage<::SigMap_Pb_SMapEntry_DoNotUse>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + +// =================================================================== + +class SigMap_Pb_SMapEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntryLite { +public: + typedef ::PROTOBUF_NAMESPACE_ID::internal::MapEntryLite SuperType; + SigMap_Pb_SMapEntry_DoNotUse(); + explicit constexpr SigMap_Pb_SMapEntry_DoNotUse( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit SigMap_Pb_SMapEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void MergeFrom(const SigMap_Pb_SMapEntry_DoNotUse& other); + static const SigMap_Pb_SMapEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_SigMap_Pb_SMapEntry_DoNotUse_default_instance_); } + static bool ValidateKey(std::string* s) { + return ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(s->data(), static_cast(s->size()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "SigMap_Pb.SMapEntry.key"); + } + static bool ValidateValue(void*) { return true; } +}; + +// ------------------------------------------------------------------- + +class SigMap_Pb final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:SigMap_Pb) */ { + public: + inline SigMap_Pb() : SigMap_Pb(nullptr) {} + ~SigMap_Pb() override; + explicit constexpr SigMap_Pb(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + SigMap_Pb(const SigMap_Pb& from); + SigMap_Pb(SigMap_Pb&& from) noexcept + : SigMap_Pb() { + *this = ::std::move(from); + } + + inline SigMap_Pb& operator=(const SigMap_Pb& from) { + CopyFrom(from); + return *this; + } + inline SigMap_Pb& operator=(SigMap_Pb&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const SigMap_Pb& default_instance() { + return *internal_default_instance(); + } + static inline const SigMap_Pb* internal_default_instance() { + return reinterpret_cast( + &_SigMap_Pb_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(SigMap_Pb& a, SigMap_Pb& b) { + a.Swap(&b); + } + inline void Swap(SigMap_Pb* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SigMap_Pb* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + SigMap_Pb* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const SigMap_Pb& from); + void MergeFrom(const SigMap_Pb& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(SigMap_Pb* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "SigMap_Pb"; + } + protected: + explicit SigMap_Pb(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + + // accessors ------------------------------------------------------- + + enum : int { + kSMapFieldNumber = 1, + }; + // map sMap = 1; + int smap_size() const; + private: + int _internal_smap_size() const; + public: + void clear_smap(); + private: + const ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >& + _internal_smap() const; + ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >* + _internal_mutable_smap(); + public: + const ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >& + smap() const; + ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >* + mutable_smap(); + + // @@protoc_insertion_point(class_scope:SigMap_Pb) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::MapFieldLite< + SigMap_Pb_SMapEntry_DoNotUse, + std::string, uint64_t, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT64> smap_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_sig_5fmap_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// SigMap_Pb + +// map sMap = 1; +inline int SigMap_Pb::_internal_smap_size() const { + return smap_.size(); +} +inline int SigMap_Pb::smap_size() const { + return _internal_smap_size(); +} +inline void SigMap_Pb::clear_smap() { + smap_.Clear(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >& +SigMap_Pb::_internal_smap() const { + return smap_.GetMap(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >& +SigMap_Pb::smap() const { + // @@protoc_insertion_point(field_map:SigMap_Pb.sMap) + return _internal_smap(); +} +inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >* +SigMap_Pb::_internal_mutable_smap() { + return smap_.MutableMap(); +} +inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >* +SigMap_Pb::mutable_smap() { + // @@protoc_insertion_point(field_mutable_map:SigMap_Pb.sMap) + return _internal_mutable_smap(); +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_sig_5fmap_2eproto diff --git a/r5dev/public/utility/binstream.cpp b/r5dev/public/utility/binstream.cpp index a94c84dd..ebd6d80c 100644 --- a/r5dev/public/utility/binstream.cpp +++ b/r5dev/public/utility/binstream.cpp @@ -40,18 +40,16 @@ bool CIOStream::Open(const fs::path& fsFilePath, Mode_t eMode) { m_iStream.close(); } - m_iStream.open(fsFilePath, std::ios::binary | std::ios::in); + m_iStream.open(fsFilePath, std::ios::binary | std::ios::in || std::ios::ate); if (!m_iStream.is_open() || !m_iStream.good()) { m_eCurrentMode = Mode_t::NONE; return false; } - m_iStream.seekg(0, fstream::end); - m_vData.resize(m_iStream.tellg()); - m_iStream.seekg(0, fstream::beg); - m_iStream.read(reinterpret_cast(m_vData.data()), m_vData.size()); - m_iStream.seekg(0); - m_iStream.clear(); + + m_nSize = m_iStream.tellg(); + m_iStream.seekg(0, std::ios::beg); + return true; case Mode_t::WRITE: @@ -101,7 +99,7 @@ void CIOStream::Flush() //----------------------------------------------------------------------------- // Purpose: gets the position of the current character in the stream //----------------------------------------------------------------------------- -size_t CIOStream::GetPosition() +std::streampos CIOStream::GetPosition() { switch (m_eCurrentMode) { @@ -112,7 +110,7 @@ size_t CIOStream::GetPosition() return m_oStream.tellp(); break; default: - return static_cast(NULL); + return static_cast(NULL); } } @@ -120,7 +118,7 @@ size_t CIOStream::GetPosition() // Purpose: sets the position of the current character in the stream // Input : nOffset - //----------------------------------------------------------------------------- -void CIOStream::SetPosition(int64_t nOffset) +void CIOStream::SetPosition(std::streampos nOffset) { switch (m_eCurrentMode) { @@ -135,28 +133,20 @@ void CIOStream::SetPosition(int64_t nOffset) } } -//----------------------------------------------------------------------------- -// Purpose: returns the vector (ifstream only) -//----------------------------------------------------------------------------- -const vector& CIOStream::GetVector() const -{ - return m_vData; -} - //----------------------------------------------------------------------------- // Purpose: returns the data (ifstream only) //----------------------------------------------------------------------------- -const uint8_t* CIOStream::GetData() const +const std::filebuf* CIOStream::GetData() const { - return m_vData.data(); + return m_iStream.rdbuf(); } //----------------------------------------------------------------------------- // Purpose: returns the data size (ifstream only) //----------------------------------------------------------------------------- -const size_t CIOStream::GetSize() const +const std::streampos CIOStream::GetSize() const { - return m_vData.size(); + return m_nSize; } //----------------------------------------------------------------------------- @@ -211,16 +201,18 @@ bool CIOStream::IsEof() const //----------------------------------------------------------------------------- string CIOStream::ReadString() { + string result; + if (IsReadable()) { char c; - string result = ""; while (!m_iStream.eof() && (c = Read()) != '\0') result += c; return result; } - return ""; + + return result; } //----------------------------------------------------------------------------- @@ -233,8 +225,8 @@ void CIOStream::WriteString(string svInput) svInput += '\0'; // null-terminate the string. - char* szText = const_cast(svInput.c_str()); + const char* szText = svInput.c_str(); size_t nSize = svInput.size(); - m_oStream.write(reinterpret_cast(szText), nSize); + m_oStream.write(szText, nSize); } diff --git a/r5dev/public/utility/binstream.h b/r5dev/public/utility/binstream.h index a132689a..2c98a2c7 100644 --- a/r5dev/public/utility/binstream.h +++ b/r5dev/public/utility/binstream.h @@ -18,12 +18,11 @@ public: void Close(); void Flush(); - size_t GetPosition(); - void SetPosition(int64_t nOffset); + std::streampos GetPosition(); + void SetPosition(std::streampos nOffset); - const vector& GetVector() const; - const uint8_t* GetData() const; - const size_t GetSize() const; + const std::filebuf* GetData() const; + const std::streampos GetSize() const; bool IsReadable(); bool IsWritable() const; @@ -34,7 +33,7 @@ public: // Purpose: reads any value from the file //----------------------------------------------------------------------------- template - void Read(T& tValue) // Template functions have to be in the header! + void Read(T& tValue) { if (IsReadable()) m_iStream.read(reinterpret_cast(&tValue), sizeof(tValue)); @@ -44,7 +43,7 @@ public: // Purpose: reads any value from the file with specified size //----------------------------------------------------------------------------- template - void Read(T& tValue, size_t nSize) // Template functions have to be in the header! + void Read(T& tValue, size_t nSize) { if (IsReadable()) m_iStream.read(reinterpret_cast(&tValue), nSize); @@ -54,7 +53,7 @@ public: // Purpose: reads any value from the file and returns it //----------------------------------------------------------------------------- template - T Read() // Template functions have to be in the header! + T Read() { T value{}; if (!IsReadable()) @@ -69,7 +68,7 @@ public: // Purpose: writes any value to the file //----------------------------------------------------------------------------- template - void Write(T tValue) // Template functions have to be in the header! + void Write(T tValue) { if (!IsWritable()) return; @@ -81,7 +80,7 @@ public: // Purpose: writes any value to the file with specified size //----------------------------------------------------------------------------- template - void Write(T tValue, size_t nSize) // Template functions have to be in the header! + void Write(T tValue, size_t nSize) { if (!IsWritable()) return; @@ -92,8 +91,8 @@ public: private: + std::streampos m_nSize; // Size of ifstream. + Mode_t m_eCurrentMode; // Current active mode. ofstream m_oStream; // Output file stream. ifstream m_iStream; // Input file stream. - vector m_vData; // Data vector - Mode_t m_eCurrentMode; // Current active mode. }; diff --git a/r5dev/public/utility/module.cpp b/r5dev/public/utility/module.cpp index aecf66b9..fed6e942 100644 --- a/r5dev/public/utility/module.cpp +++ b/r5dev/public/utility/module.cpp @@ -46,6 +46,17 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c if (!m_ExecutableCode.IsSectionValid()) return CMemory(); + + //if (g_SigCache.m_bInitialized) // Get from cache instead. + //{ + // auto p = g_SigCache.m_Map.find(szPattern); + // if (p != g_SigCache.m_Map.end()) + // { + // return CMemory(p->second); + // } + //} + + uint64_t nBase = static_cast(m_ExecutableCode.m_pSectionBase); uint64_t nSize = static_cast(m_ExecutableCode.m_nSectionSize); @@ -55,12 +66,13 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c nSize = static_cast(moduleSection.m_nSectionSize); } + const size_t nMaskLen = strlen(szMask); const uint8_t* pData = reinterpret_cast(nBase); - const uint8_t* pEnd = pData + static_cast(nSize) - strlen(szMask); + const uint8_t* pEnd = pData + static_cast(nSize) - nMaskLen; int nOccurrenceCount = 0; int nMasks[64]; // 64*16 = enough masks for 1024 bytes. - const int iNumMasks = static_cast(ceil(static_cast(strlen(szMask)) / 16.f)); + const int iNumMasks = static_cast(ceil(static_cast(nMaskLen) / 16.f)); memset(nMasks, '\0', iNumMasks * sizeof(int)); for (intptr_t i = 0; i < iNumMasks; ++i) @@ -94,6 +106,7 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c { if (nOccurrenceCount == nOccurrence) { + g_SigCache.AddEntry(reinterpret_cast(szPattern), nMaskLen, reinterpret_cast(pData - nBase)); return static_cast(const_cast(pData)); } nOccurrenceCount++; @@ -106,6 +119,7 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c } if (nOccurrenceCount == nOccurrence) { + g_SigCache.AddEntry(reinterpret_cast(szPattern), nMaskLen, reinterpret_cast(pData - nBase)); return static_cast((&*(const_cast(pData)))); } nOccurrenceCount++; diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp new file mode 100644 index 00000000..26679966 --- /dev/null +++ b/r5dev/public/utility/sigcache.cpp @@ -0,0 +1,37 @@ +//===========================================================================// +// +// Purpose: Implementation of the CSigCache class. +// +//===========================================================================// +#include "core/stdafx.h" +#include "public/utility/binstream.h" +#include "sigcache.h" + +void CSigCache::AddEntry(const char* pszPattern, const size_t nMaskLen, const uint64_t nRVA) +{ + if (g_SigCache.m_bUseCache) + { + (*g_SigCache.m_Cache.mutable_smap())[string(pszPattern, nMaskLen)] = nRVA; + } +} + +void CSigCache::WriteCache() +{ + CIOStream writer("bin\\startup.smap", CIOStream::Mode_t::WRITE); + + if (!writer.IsWritable()) + { + // Error message.. + return; + } + + SigDBHeader_t header; + + header.m_nMagic = SIGDB_MAGIC; + header.m_nVersion = SIGDB_VERSION; + GetSystemTimeAsFileTime(&header.m_FileTime); + const string svBuffer = m_Cache.SerializeAsString(); + + writer.Write(header); + writer.Write(svBuffer.data(), svBuffer.size()); +} \ No newline at end of file diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h new file mode 100644 index 00000000..2849a9f8 --- /dev/null +++ b/r5dev/public/utility/sigcache.h @@ -0,0 +1,32 @@ +#ifndef SIGCACHE_H +#define SIGCACHE_H + +#include "protoc/sig_map.pb.h" + +#define SIGDB_MAGIC (('p'<<24)+('a'<<16)+('M'<<8)+'S') +#define SIGDB_VERSION 0x1 + +class CSigCache +{ +public: + + // Save + // Load + // Clear + + void AddEntry(const char* pszPattern, const size_t nMaskLen, const uint64_t nRVA); + void WriteCache(); + + SigMap_Pb m_Cache; + bool m_bInitialized; + bool m_bUseCache = true; +}; + +struct SigDBHeader_t +{ + int m_nMagic; + int m_nVersion; + FILETIME m_FileTime; +}; + +#endif // !SIGCACHE_H diff --git a/r5dev/resource/protobuf/sig_map.proto b/r5dev/resource/protobuf/sig_map.proto new file mode 100644 index 00000000..592ee64c --- /dev/null +++ b/r5dev/resource/protobuf/sig_map.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +option optimize_for = LITE_RUNTIME; + +message SigMap_Pb +{ + map sMap = 1; +} diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index ec7be348..7da687d3 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -99,6 +99,10 @@ NotUsing NotUsing + + NotUsing + NotUsing + NotUsing NotUsing @@ -107,6 +111,7 @@ + @@ -281,6 +286,7 @@ + @@ -329,6 +335,7 @@ + @@ -593,6 +600,7 @@ + 16.0 diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index 10ba1ce2..c0b39447 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -672,6 +672,12 @@ sdk\codecs\miles + + thirdparty\protobuf + + + sdk\public\utility + @@ -1937,6 +1943,12 @@ sdk\codecs\miles + + thirdparty\protobuf + + + sdk\public\utility + @@ -1950,5 +1962,6 @@ + \ No newline at end of file From 053f284029902f0d4cc3685abf8f90318f8794d0 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 00:25:28 +0100 Subject: [PATCH 03/20] Compute the file size properly --- r5dev/public/utility/binstream.cpp | 18 ++++++++++++++---- r5dev/public/utility/binstream.h | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/r5dev/public/utility/binstream.cpp b/r5dev/public/utility/binstream.cpp index ebd6d80c..5189f64e 100644 --- a/r5dev/public/utility/binstream.cpp +++ b/r5dev/public/utility/binstream.cpp @@ -40,16 +40,14 @@ bool CIOStream::Open(const fs::path& fsFilePath, Mode_t eMode) { m_iStream.close(); } - m_iStream.open(fsFilePath, std::ios::binary | std::ios::in || std::ios::ate); + m_iStream.open(fsFilePath, std::ios::binary | std::ios::in); if (!m_iStream.is_open() || !m_iStream.good()) { m_eCurrentMode = Mode_t::NONE; return false; } - m_nSize = m_iStream.tellg(); - m_iStream.seekg(0, std::ios::beg); - + ComputeFileSize(); return true; case Mode_t::WRITE: @@ -96,6 +94,18 @@ void CIOStream::Flush() m_oStream.flush(); } +//----------------------------------------------------------------------------- +// Purpose: computes the input file size +//----------------------------------------------------------------------------- +void CIOStream::ComputeFileSize() +{ + m_nSize = m_iStream.tellg(); + m_iStream.seekg(0, std::ios::end); + m_nSize = m_iStream.tellg() - m_nSize; + m_iStream.seekg(0, std::ios::beg); + m_iStream.clear(); +} + //----------------------------------------------------------------------------- // Purpose: gets the position of the current character in the stream //----------------------------------------------------------------------------- diff --git a/r5dev/public/utility/binstream.h b/r5dev/public/utility/binstream.h index 2c98a2c7..3cba8c46 100644 --- a/r5dev/public/utility/binstream.h +++ b/r5dev/public/utility/binstream.h @@ -18,6 +18,8 @@ public: void Close(); void Flush(); + void ComputeFileSize(); + std::streampos GetPosition(); void SetPosition(std::streampos nOffset); From 9c2b2b681a854f0c763c193d894d0aa5ba0046ce Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 00:28:01 +0100 Subject: [PATCH 04/20] Fix cache map load bug * Fix bug where the version wasn't read correctly during cache map load. * Pass address of array to CIOStream Read wrapper. --- r5dev/core/init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index 14af50c5..ed7793b2 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -497,7 +497,7 @@ bool SigDB_Init() } sigDbHeader.m_nVersion = sigDbStream.Read(); - if (sigDbHeader.m_nMagic != SIGDB_VERSION) + if (sigDbHeader.m_nVersion != SIGDB_VERSION) { return false; } @@ -509,7 +509,7 @@ bool SigDB_Init() vData.resize(nSize); uint8_t* pBuf = vData.data(); - sigDbStream.Read(pBuf, nSize); + sigDbStream.Read(*pBuf, nSize); if (!g_SigCache.m_Cache.ParseFromArray(pBuf, nSize)) { From 5513057f537bbb7a907bad522871c1a0e64fe9bd Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 00:28:29 +0100 Subject: [PATCH 05/20] Pass patterns by const string reference --- r5dev/public/utility/sigcache.cpp | 4 ++-- r5dev/public/utility/sigcache.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index 26679966..db7a9023 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -7,11 +7,11 @@ #include "public/utility/binstream.h" #include "sigcache.h" -void CSigCache::AddEntry(const char* pszPattern, const size_t nMaskLen, const uint64_t nRVA) +void CSigCache::AddEntry(const string& svPattern, const uint64_t nRVA) { if (g_SigCache.m_bUseCache) { - (*g_SigCache.m_Cache.mutable_smap())[string(pszPattern, nMaskLen)] = nRVA; + (*g_SigCache.m_Cache.mutable_smap())[svPattern] = nRVA; } } diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h index 2849a9f8..2f3b7c7c 100644 --- a/r5dev/public/utility/sigcache.h +++ b/r5dev/public/utility/sigcache.h @@ -14,7 +14,7 @@ public: // Load // Clear - void AddEntry(const char* pszPattern, const size_t nMaskLen, const uint64_t nRVA); + void AddEntry(const string& svPattern, const uint64_t nRVA); void WriteCache(); SigMap_Pb m_Cache; From 783b3dbb5a4a9d4dd988aefb3b29e66bcf845e6a Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 00:30:49 +0100 Subject: [PATCH 06/20] Initial working implementation of the Signature Cache Map. Init speeds have been reduced from 1.7 seconds (average) to 0.3 seconds (average) --- r5dev/public/utility/module.cpp | 37 ++++++++++++++++++++------------- r5dev/public/utility/module.h | 1 + 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/r5dev/public/utility/module.cpp b/r5dev/public/utility/module.cpp index fed6e942..f98ebbd4 100644 --- a/r5dev/public/utility/module.cpp +++ b/r5dev/public/utility/module.cpp @@ -46,17 +46,6 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c if (!m_ExecutableCode.IsSectionValid()) return CMemory(); - - //if (g_SigCache.m_bInitialized) // Get from cache instead. - //{ - // auto p = g_SigCache.m_Map.find(szPattern); - // if (p != g_SigCache.m_Map.end()) - // { - // return CMemory(p->second); - // } - //} - - uint64_t nBase = static_cast(m_ExecutableCode.m_pSectionBase); uint64_t nSize = static_cast(m_ExecutableCode.m_nSectionSize); @@ -106,7 +95,6 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c { if (nOccurrenceCount == nOccurrence) { - g_SigCache.AddEntry(reinterpret_cast(szPattern), nMaskLen, reinterpret_cast(pData - nBase)); return static_cast(const_cast(pData)); } nOccurrenceCount++; @@ -119,7 +107,6 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c } if (nOccurrenceCount == nOccurrence) { - g_SigCache.AddEntry(reinterpret_cast(szPattern), nMaskLen, reinterpret_cast(pData - nBase)); return static_cast((&*(const_cast(pData)))); } nOccurrenceCount++; @@ -137,8 +124,22 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c //----------------------------------------------------------------------------- CMemory CModule::FindPatternSIMD(const string& svPattern, const ModuleSections_t& moduleSection) const { + if (g_SigCache.m_bInitialized) // Get from cache instead. + { + google::protobuf::Map sMap = g_SigCache.m_Cache.smap(); + + auto p = sMap.find(svPattern); + if (p != sMap.end()) + { + return CMemory((GetModuleBase() + p->second)); + } + } + const pair patternInfo = PatternToMaskedBytes(svPattern); - return FindPatternSIMD(patternInfo.first.data(), patternInfo.second.c_str(), moduleSection); + CMemory memory = FindPatternSIMD(patternInfo.first.data(), patternInfo.second.c_str(), moduleSection); + + g_SigCache.AddEntry(svPattern, GetRVA(memory.GetPtr())); + return memory; } //----------------------------------------------------------------------------- @@ -351,3 +352,11 @@ string CModule::GetModuleName(void) const { return m_svModuleName; } + +//----------------------------------------------------------------------------- +// Purpose: returns the RVA of given address +//----------------------------------------------------------------------------- +uintptr_t CModule::GetRVA(const uintptr_t nAddress) const +{ + return (nAddress - GetModuleBase()); +} diff --git a/r5dev/public/utility/module.h b/r5dev/public/utility/module.h index ab2f67ed..e20b208f 100644 --- a/r5dev/public/utility/module.h +++ b/r5dev/public/utility/module.h @@ -33,6 +33,7 @@ public: uintptr_t GetModuleBase(void) const; DWORD GetModuleSize(void) const; string GetModuleName(void) const; + uintptr_t GetRVA(const uintptr_t nAddress) const; ModuleSections_t m_ExecutableCode; ModuleSections_t m_ExceptionTable; From 4cc3c28985ba20f8b5e07a253f27f13277f2a429 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 01:33:49 +0100 Subject: [PATCH 07/20] Deref VFTable pointer only once to obtain CShaderGlue::SetupShader Due to the new cache changes, the pointer should only be dereferenced once. --- r5dev/materialsystem/cshaderglue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r5dev/materialsystem/cshaderglue.h b/r5dev/materialsystem/cshaderglue.h index d7f8de69..d9e0cd62 100644 --- a/r5dev/materialsystem/cshaderglue.h +++ b/r5dev/materialsystem/cshaderglue.h @@ -49,7 +49,7 @@ class VShaderGlue : public IDetour } virtual void GetFun(void) const { - CShaderGlue_SetupShader = CShaderGlue_VTable.WalkVTable(4).Deref(2).RCast(); + CShaderGlue_SetupShader = CShaderGlue_VTable.WalkVTable(4).Deref().RCast(); } virtual void GetVar(void) const { } virtual void GetCon(void) const From de23c2adf8c18cc02fcadb9c5493213b6d754b3d Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:33:20 +0100 Subject: [PATCH 08/20] Add signature cache map files to all projects --- r5dev/vproj/clientsdk.vcxproj | 7 +++++++ r5dev/vproj/clientsdk.vcxproj.filters | 12 ++++++++++++ r5dev/vproj/dedicated.vcxproj | 7 +++++++ r5dev/vproj/dedicated.vcxproj.filters | 12 ++++++++++++ r5dev/vproj/gamesdk.vcxproj | 1 - r5dev/vproj/gamesdk.vcxproj.filters | 1 - 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/r5dev/vproj/clientsdk.vcxproj b/r5dev/vproj/clientsdk.vcxproj index e1310094..6883ca1d 100644 --- a/r5dev/vproj/clientsdk.vcxproj +++ b/r5dev/vproj/clientsdk.vcxproj @@ -90,6 +90,10 @@ NotUsing NotUsing + + NotUsing + NotUsing + NotUsing NotUsing @@ -98,6 +102,7 @@ + @@ -254,6 +259,7 @@ + @@ -299,6 +305,7 @@ + diff --git a/r5dev/vproj/clientsdk.vcxproj.filters b/r5dev/vproj/clientsdk.vcxproj.filters index 66315198..ac310c7f 100644 --- a/r5dev/vproj/clientsdk.vcxproj.filters +++ b/r5dev/vproj/clientsdk.vcxproj.filters @@ -630,6 +630,12 @@ sdk\codecs\miles + + thirdparty\protobuf + + + sdk\public\utility + @@ -1838,6 +1844,12 @@ sdk\codecs\miles + + thirdparty\protobuf + + + sdk\public\utility + diff --git a/r5dev/vproj/dedicated.vcxproj b/r5dev/vproj/dedicated.vcxproj index 4dd31609..f41e1912 100644 --- a/r5dev/vproj/dedicated.vcxproj +++ b/r5dev/vproj/dedicated.vcxproj @@ -213,6 +213,7 @@ + @@ -242,6 +243,7 @@ + @@ -547,6 +549,10 @@ NotUsing NotUsing + + NotUsing + NotUsing + NotUsing NotUsing @@ -555,6 +561,7 @@ + diff --git a/r5dev/vproj/dedicated.vcxproj.filters b/r5dev/vproj/dedicated.vcxproj.filters index 25a9de74..471ea9f9 100644 --- a/r5dev/vproj/dedicated.vcxproj.filters +++ b/r5dev/vproj/dedicated.vcxproj.filters @@ -1269,6 +1269,12 @@ sdk\public + + thirdparty\protobuf + + + sdk\public\utility + @@ -1595,6 +1601,12 @@ sdk\tier1 + + thirdparty\protobuf + + + sdk\public\utility + diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index 7da687d3..2c394233 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -600,7 +600,6 @@ - 16.0 diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index c0b39447..ea865544 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -1962,6 +1962,5 @@ - \ No newline at end of file From c3eba484723475a11cb4df93c7906e959ecd25c2 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:37:41 +0100 Subject: [PATCH 09/20] Implement signature cache further into the CModule class Init speeds have been reduced from 1.7 sec (average) to 0.06 sec (average) --- r5dev/public/utility/module.cpp | 49 +++++++++++++++++++++++-------- r5dev/public/utility/sigcache.cpp | 31 +++++++++++++++++++ r5dev/public/utility/sigcache.h | 1 + 3 files changed, 69 insertions(+), 12 deletions(-) diff --git a/r5dev/public/utility/module.cpp b/r5dev/public/utility/module.cpp index f98ebbd4..cd757698 100644 --- a/r5dev/public/utility/module.cpp +++ b/r5dev/public/utility/module.cpp @@ -118,21 +118,17 @@ CMemory CModule::FindPatternSIMD(const uint8_t* szPattern, const char* szMask, c //----------------------------------------------------------------------------- -// Purpose: find array of bytes in process memory using SIMD instructions -// Input : *svPattern +// Purpose: find a string pattern in process memory using SIMD instructions +// Input : &svPattern +// &moduleSection // Output : CMemory //----------------------------------------------------------------------------- CMemory CModule::FindPatternSIMD(const string& svPattern, const ModuleSections_t& moduleSection) const { - if (g_SigCache.m_bInitialized) // Get from cache instead. + uint64_t nRVA; + if (g_SigCache.FindEntry(svPattern, nRVA)) { - google::protobuf::Map sMap = g_SigCache.m_Cache.smap(); - - auto p = sMap.find(svPattern); - if (p != sMap.end()) - { - return CMemory((GetModuleBase() + p->second)); - } + return CMemory(nRVA + GetModuleBase()); } const pair patternInfo = PatternToMaskedBytes(svPattern); @@ -193,6 +189,14 @@ CMemory CModule::FindString(const string& svString, const ptrdiff_t nOccurrence, if (!m_ExecutableCode.IsSectionValid()) return CMemory(); + uint64_t nRVA; + string svPackedString = svString + std::to_string(nOccurrence); + + if (g_SigCache.FindEntry(svPackedString, nRVA)) + { + return CMemory(nRVA + GetModuleBase()); + } + const CMemory stringAddress = FindStringReadOnly(svString, bNullTerminator); // Get Address for the string in the .rdata section. if (!stringAddress) @@ -201,6 +205,7 @@ CMemory CModule::FindString(const string& svString, const ptrdiff_t nOccurrence, uint8_t* pLatestOccurrence = nullptr; uint8_t* pTextStart = reinterpret_cast(m_ExecutableCode.m_pSectionBase); // Get the start of the .text section. ptrdiff_t dOccurrencesFound = 0; + CMemory resultAddress; for (size_t i = 0ull; i < m_ExecutableCode.m_nSectionSize - 0x5; i++) { @@ -216,13 +221,22 @@ CMemory CModule::FindString(const string& svString, const ptrdiff_t nOccurrence, { dOccurrencesFound++; if (nOccurrence == dOccurrencesFound) - return CMemory(&pTextStart[i]); + { + resultAddress = CMemory(&pTextStart[i]); + g_SigCache.AddEntry(svPackedString, GetRVA(resultAddress.GetPtr())); + + return resultAddress; + } pLatestOccurrence = &pTextStart[i]; // Stash latest occurrence. } } } - return CMemory(pLatestOccurrence); + + resultAddress = CMemory(pLatestOccurrence); + + g_SigCache.AddEntry(svPackedString, GetRVA(resultAddress.GetPtr())); + return resultAddress; } //----------------------------------------------------------------------------- @@ -285,6 +299,14 @@ CMemory CModule::GetExportedFunction(const string& svFunctionName) const //----------------------------------------------------------------------------- CMemory CModule::GetVirtualMethodTable(const string& svTableName, const uint32_t nRefIndex) { + uint64_t nRVA; // Packed together as we can have multiple VFTable searches, but with different ref indexes. + string svPackedTableName = svTableName + std::to_string(nRefIndex); + + if (g_SigCache.FindEntry(svPackedTableName, nRVA)) + { + return CMemory(nRVA + GetModuleBase()); + } + const auto tableNameInfo = StringToMaskedBytes(svTableName, false); CMemory rttiTypeDescriptor = FindPatternSIMD(tableNameInfo.first.data(), tableNameInfo.second.c_str(), { ".data", m_RunTimeData.m_pSectionBase, m_RunTimeData.m_nSectionSize }).OffsetSelf(-0x10); if (!rttiTypeDescriptor) @@ -307,6 +329,9 @@ CMemory CModule::GetVirtualMethodTable(const string& svTableName, const uint32_t continue; } + CMemory vfTable = FindPatternSIMD(reinterpret_cast(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8); + + g_SigCache.AddEntry(svPackedTableName, GetRVA(vfTable.GetPtr())); return FindPatternSIMD(reinterpret_cast(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8); } diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index db7a9023..2eef7a54 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -7,6 +7,11 @@ #include "public/utility/binstream.h" #include "sigcache.h" +//----------------------------------------------------------------------------- +// Purpose: creates a pair of a pattern (key) and relative virtual address (value) +// Input : &svPattern - +// nRVA - +//----------------------------------------------------------------------------- void CSigCache::AddEntry(const string& svPattern, const uint64_t nRVA) { if (g_SigCache.m_bUseCache) @@ -15,6 +20,32 @@ void CSigCache::AddEntry(const string& svPattern, const uint64_t nRVA) } } +//----------------------------------------------------------------------------- +// Purpose: finds a pattern key in the cache map and sets its value to nRVA +// Input : &svPattern - +// &nRVA - +// Output : true if key is found, false otherwise +//----------------------------------------------------------------------------- +bool CSigCache::FindEntry(const string& svPattern, uint64_t& nRVA) const +{ + if (g_SigCache.m_bInitialized) + { + google::protobuf::Map sMap = g_SigCache.m_Cache.smap(); + auto p = sMap.find(svPattern); + + if (p != sMap.end()) + { + nRVA = p->second; + return true; + } + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: writes the cache map to the disk +//----------------------------------------------------------------------------- void CSigCache::WriteCache() { CIOStream writer("bin\\startup.smap", CIOStream::Mode_t::WRITE); diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h index 2f3b7c7c..b658fc00 100644 --- a/r5dev/public/utility/sigcache.h +++ b/r5dev/public/utility/sigcache.h @@ -15,6 +15,7 @@ public: // Clear void AddEntry(const string& svPattern, const uint64_t nRVA); + bool FindEntry(const string& svPattern, uint64_t& nRVA) const; void WriteCache(); SigMap_Pb m_Cache; From 81fbf9ded76cb5dced029058832fda72e7a01a4c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:10:53 +0100 Subject: [PATCH 10/20] Finish signature cache map implementation in CModule --- r5dev/public/utility/module.cpp | 17 +++++++++++++---- r5dev/public/utility/module.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/r5dev/public/utility/module.cpp b/r5dev/public/utility/module.cpp index cd757698..de9edafd 100644 --- a/r5dev/public/utility/module.cpp +++ b/r5dev/public/utility/module.cpp @@ -149,6 +149,12 @@ CMemory CModule::FindStringReadOnly(const string& svString, bool bNullTerminator if (!m_ReadOnlyData.IsSectionValid()) return CMemory(); + uint64_t nRVA; + if (g_SigCache.FindEntry(svString, nRVA)) + { + return CMemory(nRVA + GetModuleBase()); + } + const vector vBytes = StringToBytes(svString, bNullTerminator); // Convert our string to a byte array. const pair bytesInfo = std::make_pair(vBytes.size(), vBytes.data()); // Get the size and data of our bytes. @@ -171,7 +177,10 @@ CMemory CModule::FindStringReadOnly(const string& svString, bool bNullTerminator if (bFound) { - return CMemory(&pBase[i]); + CMemory result = CMemory(&pBase[i]); + g_SigCache.AddEntry(svString, GetRVA(result.GetPtr())); + + return result; } } @@ -234,8 +243,8 @@ CMemory CModule::FindString(const string& svString, const ptrdiff_t nOccurrence, } resultAddress = CMemory(pLatestOccurrence); - g_SigCache.AddEntry(svPackedString, GetRVA(resultAddress.GetPtr())); + return resultAddress; } @@ -330,9 +339,9 @@ CMemory CModule::GetVirtualMethodTable(const string& svTableName, const uint32_t } CMemory vfTable = FindPatternSIMD(reinterpret_cast(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8); - g_SigCache.AddEntry(svPackedTableName, GetRVA(vfTable.GetPtr())); - return FindPatternSIMD(reinterpret_cast(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8); + + return vfTable; } return CMemory(); diff --git a/r5dev/public/utility/module.h b/r5dev/public/utility/module.h index e20b208f..d685b62e 100644 --- a/r5dev/public/utility/module.h +++ b/r5dev/public/utility/module.h @@ -22,7 +22,6 @@ public: CModule(void) = default; CModule(const string& moduleName); - CMemory FindPatternSIMD(const uint8_t* szPattern, const char* szMask, const ModuleSections_t& moduleSection = {}, const uint32_t nOccurrence = 0) const; CMemory FindPatternSIMD(const string& svPattern, const ModuleSections_t& moduleSection = {}) const; CMemory FindString(const string& string, const ptrdiff_t occurrence = 1, bool nullTerminator = false) const; CMemory FindStringReadOnly(const string& svString, bool nullTerminator) const; @@ -41,6 +40,8 @@ public: ModuleSections_t m_ReadOnlyData; private: + CMemory FindPatternSIMD(const uint8_t* szPattern, const char* szMask, const ModuleSections_t& moduleSection = {}, const uint32_t nOccurrence = 0) const; + string m_svModuleName; uintptr_t m_pModuleBase{}; DWORD m_nModuleSize{}; From b90d6f929c62e15b00e4f49f06da7c346f1f314c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:12:13 +0100 Subject: [PATCH 11/20] Finish Signature Cache Map implementation * Fixed bug where the system still added entries after we are initialized (file has already been written to the disk). * Moved loading logic to CSigCache class. * Dedicated and Host/Client now have their own cache files. --- r5dev/core/init.cpp | 62 ++++-------------------- r5dev/public/utility/sigcache.cpp | 78 ++++++++++++++++++++++++++----- r5dev/public/utility/sigcache.h | 16 ++++--- 3 files changed, 84 insertions(+), 72 deletions(-) diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index ed7793b2..a7c10db9 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -258,11 +258,6 @@ void Systems_Init() spdlog::info("+-------------------------------------------------------------+\n"); ConVar::Init(); - -#ifdef DEDICATED - Dedicated_Init(); -#endif // DEDICATED - SpdLog_PostInit(); std::thread fixed(&CEngineSDK::FixedFrame, g_EngineSDK); @@ -473,59 +468,12 @@ void CheckCPU() // Respawn's engine and our SDK utilize POPCNT, SSE3 and SSSE3 ( } } -#include "protoc/sig_map.pb.h" - -bool SigDB_Init() -{ - CIOStream sigDbStream("bin\\startup.smap", CIOStream::Mode_t::READ); - - if (!sigDbStream.IsReadable()) - { - return false; - } - if (!sigDbStream.GetSize() > sizeof(SigDBHeader_t)) - { - return false; - } - - SigDBHeader_t sigDbHeader; - sigDbHeader.m_nMagic = sigDbStream.Read(); - - if (sigDbHeader.m_nMagic != SIGDB_MAGIC) - { - return false; - } - - sigDbHeader.m_nVersion = sigDbStream.Read(); - if (sigDbHeader.m_nVersion != SIGDB_VERSION) - { - return false; - } - - sigDbHeader.m_FileTime = sigDbStream.Read(); - - vector vData; - size_t nSize = (static_cast(sigDbStream.GetSize()) - sizeof(SigDBHeader_t)); - - vData.resize(nSize); - uint8_t* pBuf = vData.data(); - sigDbStream.Read(*pBuf, nSize); - - if (!g_SigCache.m_Cache.ParseFromArray(pBuf, nSize)) - { - return false; - } - - return true; -} - - void DetourInit() // Run the sigscan { bool bLogAdr = (strstr(GetCommandLineA(), "-sig_toconsole") != nullptr); bool bInitDivider = false; - g_SigCache.m_bInitialized = SigDB_Init(); + g_SigCache.LoadCache(SIGDB_FILE); for (const IDetour* pDetour : vDetour) { @@ -544,8 +492,14 @@ void DetourInit() // Run the sigscan } } - g_SigCache.WriteCache(); +#ifdef DEDICATED + // Must be performed after detour init as we patch instructions which alters the function signatures. + Dedicated_Init(); +#endif // DEDICATED + + g_SigCache.WriteCache(SIGDB_FILE); } + void DetourAddress() // Test the sigscan results { spdlog::debug("+----------------------------------------------------------------+\n"); diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index 2eef7a54..7e0793ee 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -14,10 +14,8 @@ //----------------------------------------------------------------------------- void CSigCache::AddEntry(const string& svPattern, const uint64_t nRVA) { - if (g_SigCache.m_bUseCache) - { - (*g_SigCache.m_Cache.mutable_smap())[svPattern] = nRVA; - } + Assert(!m_bInitialized); + (*m_Cache.mutable_smap())[svPattern] = nRVA; } //----------------------------------------------------------------------------- @@ -28,9 +26,9 @@ void CSigCache::AddEntry(const string& svPattern, const uint64_t nRVA) //----------------------------------------------------------------------------- bool CSigCache::FindEntry(const string& svPattern, uint64_t& nRVA) const { - if (g_SigCache.m_bInitialized) + if (m_bInitialized) { - google::protobuf::Map sMap = g_SigCache.m_Cache.smap(); + google::protobuf::Map sMap = m_Cache.smap(); auto p = sMap.find(svPattern); if (p != sMap.end()) @@ -44,16 +42,72 @@ bool CSigCache::FindEntry(const string& svPattern, uint64_t& nRVA) const } //----------------------------------------------------------------------------- -// Purpose: writes the cache map to the disk +// Purpose: loads the cache map from the disk +// Output : true on success, false otherwise //----------------------------------------------------------------------------- -void CSigCache::WriteCache() +bool CSigCache::LoadCache(const string& svCacheFile) { - CIOStream writer("bin\\startup.smap", CIOStream::Mode_t::WRITE); + Assert(!m_bInitialized); // Recursive load. + CIOStream reader(svCacheFile, CIOStream::Mode_t::READ); + if (!reader.IsReadable()) + { + return false; + } + if (!reader.GetSize() > sizeof(SigDBHeader_t)) + { + return false; + } + + SigDBHeader_t sigDbHeader; + sigDbHeader.m_nMagic = reader.Read(); + + if (sigDbHeader.m_nMagic != SIGDB_MAGIC) + { + return false; + } + + sigDbHeader.m_nVersion = reader.Read(); + if (sigDbHeader.m_nVersion != SIGDB_VERSION) + { + return false; + } + + sigDbHeader.m_FileTime = reader.Read(); + + vector vData; + size_t nSize = (static_cast(reader.GetSize()) - sizeof(SigDBHeader_t)); + + vData.resize(nSize); + uint8_t* pBuf = vData.data(); + reader.Read(*pBuf, nSize); + + if (!m_Cache.ParseFromArray(pBuf, nSize)) + { + return false; + } + + m_bInitialized = true; + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: writes the cache map to the disk +// Output : true on success, false otherwise +//----------------------------------------------------------------------------- +bool CSigCache::WriteCache(const string& svCacheFile) +{ + if (m_bInitialized) + { + // Only write when we don't have anything valid on the disk. + return false; + } + + CIOStream writer(svCacheFile, CIOStream::Mode_t::WRITE); if (!writer.IsWritable()) { // Error message.. - return; + return false; } SigDBHeader_t header; @@ -65,4 +119,6 @@ void CSigCache::WriteCache() writer.Write(header); writer.Write(svBuffer.data(), svBuffer.size()); -} \ No newline at end of file + + return true; +} diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h index b658fc00..38a639b7 100644 --- a/r5dev/public/utility/sigcache.h +++ b/r5dev/public/utility/sigcache.h @@ -6,21 +6,23 @@ #define SIGDB_MAGIC (('p'<<24)+('a'<<16)+('M'<<8)+'S') #define SIGDB_VERSION 0x1 +#ifdef DEDICATED +#define SIGDB_FILE "cfg\\server\\startup.bin" +#else +#define SIGDB_FILE "cfg\\client\\startup.bin" +#endif + class CSigCache { public: - - // Save - // Load - // Clear - void AddEntry(const string& svPattern, const uint64_t nRVA); bool FindEntry(const string& svPattern, uint64_t& nRVA) const; - void WriteCache(); + + bool LoadCache(const string& svCacheFile); + bool WriteCache(const string& svCacheFile); SigMap_Pb m_Cache; bool m_bInitialized; - bool m_bUseCache = true; }; struct SigDBHeader_t From 75ae4d2bcf00303f36a0c475887e369fd441891c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 21:54:34 +0100 Subject: [PATCH 12/20] Fix crash when loggers are used before detour init 'v_Plat_FloatTime' is only initialized during detour init. Using the loggers before will cause a crash. Code now logs 0.0 when v_Plat_FloatTime is nullptr. Showing 0.0 at this stage is correct as the game dll isn't initialized by then. --- r5dev/tier0/platform.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r5dev/tier0/platform.cpp b/r5dev/tier0/platform.cpp index 6e1d7433..443e6f60 100644 --- a/r5dev/tier0/platform.cpp +++ b/r5dev/tier0/platform.cpp @@ -26,7 +26,7 @@ uint64_t Plat_MSTime() const char* Plat_GetProcessUpTime() { static char szBuf[4096]; - sprintf_s(szBuf, sizeof(szBuf), "[%.3f] ", Plat_FloatTime()); + sprintf_s(szBuf, sizeof(szBuf), "[%.3f] ", v_Plat_FloatTime ? Plat_FloatTime() : 0.0); return szBuf; } @@ -38,5 +38,5 @@ const char* Plat_GetProcessUpTime() //----------------------------------------------------------------------------- void Plat_GetProcessUpTime(char* szBuf, size_t nSize) { - sprintf_s(szBuf, nSize, "[%.3f] ", Plat_FloatTime()); + sprintf_s(szBuf, nSize, "[%.3f] ", v_Plat_FloatTime ? Plat_FloatTime() : 0.0); } \ No newline at end of file From 5903b40f960965bec5846bdba6d180e09fe3dde6 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 22:14:46 +0100 Subject: [PATCH 13/20] Implement LZHAM compression for the signature cache map --- r5dev/public/utility/sigcache.cpp | 115 +++++++++++++++++++++++++----- r5dev/public/utility/sigcache.h | 21 +++++- 2 files changed, 115 insertions(+), 21 deletions(-) diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index 7e0793ee..27ee0318 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -5,7 +5,7 @@ //===========================================================================// #include "core/stdafx.h" #include "public/utility/binstream.h" -#include "sigcache.h" +#include "public/utility/sigcache.h" //----------------------------------------------------------------------------- // Purpose: creates a pair of a pattern (key) and relative virtual address (value) @@ -59,30 +59,44 @@ bool CSigCache::LoadCache(const string& svCacheFile) return false; } - SigDBHeader_t sigDbHeader; - sigDbHeader.m_nMagic = reader.Read(); + SigDBHeader_t header; + header.m_nMagic = reader.Read(); - if (sigDbHeader.m_nMagic != SIGDB_MAGIC) + if (header.m_nMagic != SIGDB_MAGIC) { return false; } - sigDbHeader.m_nVersion = reader.Read(); - if (sigDbHeader.m_nVersion != SIGDB_VERSION) + header.m_nMajorVersion = reader.Read(); + if (header.m_nMajorVersion != SIGDB_MAJOR_VERSION) { return false; } - sigDbHeader.m_FileTime = reader.Read(); + header.m_nMinorVersion = reader.Read(); + if (header.m_nMinorVersion != SIGDB_MINOR_VERSION) + { + return false; + } - vector vData; - size_t nSize = (static_cast(reader.GetSize()) - sizeof(SigDBHeader_t)); + header.m_nBlobSizeMem = reader.Read(); + header.m_nBlobSizeDisk = reader.Read(); + header.m_nBlobHash = reader.Read(); - vData.resize(nSize); - uint8_t* pBuf = vData.data(); - reader.Read(*pBuf, nSize); + uint32_t nCrc32; - if (!m_Cache.ParseFromArray(pBuf, nSize)) + std::unique_ptr pSrcBuf(new uint8_t[header.m_nBlobSizeDisk]); + std::unique_ptr pDstBuf(new uint8_t[header.m_nBlobSizeMem]); + + reader.Read(*pSrcBuf.get(), header.m_nBlobSizeDisk); + DecompressBlob(header.m_nBlobSizeDisk, header.m_nBlobSizeMem, nCrc32, pSrcBuf.get(), pDstBuf.get()); + + if (header.m_nBlobHash != nCrc32) + { + return false; + } + + if (!m_Cache.ParseFromArray(pDstBuf.get(), header.m_nBlobSizeMem)) { return false; } @@ -106,19 +120,84 @@ bool CSigCache::WriteCache(const string& svCacheFile) CIOStream writer(svCacheFile, CIOStream::Mode_t::WRITE); if (!writer.IsWritable()) { - // Error message.. + Error(eDLL_T::COMMON, NO_ERROR, "Failed to write cache file: (read-only?)\n"); return false; } SigDBHeader_t header; - header.m_nMagic = SIGDB_MAGIC; - header.m_nVersion = SIGDB_VERSION; - GetSystemTimeAsFileTime(&header.m_FileTime); + header.m_nMajorVersion = SIGDB_MAJOR_VERSION; + header.m_nMinorVersion = SIGDB_MINOR_VERSION; + const string svBuffer = m_Cache.SerializeAsString(); + std::unique_ptr pBuffer(new uint8_t[svBuffer.size()]); + + header.m_nBlobSizeMem = svBuffer.size(); + uint64_t nCompSize = svBuffer.size(); + + if (!CompressBlob(svBuffer.size(), nCompSize, header.m_nBlobHash, reinterpret_cast(svBuffer.data()), pBuffer.get())) + { + return false; + } + + header.m_nBlobSizeDisk = nCompSize; writer.Write(header); - writer.Write(svBuffer.data(), svBuffer.size()); + writer.Write(pBuffer.get(), nCompSize); + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: decompresses the blob containing the signature map +// Input : nSrcLen - +// &nDstSize - +// &nCrc32 - +// *pSrcBuf - +// *pDstBuf - +// Output : true on success, false otherwise +//----------------------------------------------------------------------------- +bool CSigCache::DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const +{ + lzham_decompress_params lzDecompParams{}; + lzDecompParams.m_dict_size_log2 = SIGDB_DICT_SIZE; + lzDecompParams.m_decompress_flags = lzham_decompress_flags::LZHAM_DECOMP_FLAG_OUTPUT_UNBUFFERED | lzham_decompress_flags::LZHAM_DECOMP_FLAG_COMPUTE_CRC32; + lzDecompParams.m_struct_size = sizeof(lzham_decompress_params); + + lzham_decompress_status_t lzDecompStatus = lzham_decompress_memory(&lzDecompParams, pDstBuf, &nDstLen, pSrcBuf, nSrcLen, NULL, &nCrc32); + + if (lzDecompStatus != lzham_decompress_status_t::LZHAM_DECOMP_STATUS_SUCCESS) + { + Error(eDLL_T::COMMON, NO_ERROR, "Failed to decompress blob: status = %08x\n", lzDecompStatus); + return false; + } + + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: compresses the blob containing the signature map +// Input : nSrcLen - +// &nDstSize - +// &nCrc32 - +// *pSrcBuf - +// *pDstBuf - +// Output : true on success, false otherwise +//----------------------------------------------------------------------------- +bool CSigCache::CompressBlob(size_t nSrcLen, size_t& nDstSize, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const +{ + lzham_compress_params lzCompParams{}; + lzCompParams.m_dict_size_log2 = SIGDB_DICT_SIZE; + lzCompParams.m_level = lzham_compress_level::LZHAM_COMP_LEVEL_FASTEST; + lzCompParams.m_compress_flags = lzham_compress_flags::LZHAM_COMP_FLAG_DETERMINISTIC_PARSING; + + lzham_compress_status_t lzCompStatus = lzham_compress_memory(&lzCompParams, pDstBuf, &nDstSize, pSrcBuf, nSrcLen, NULL, &nCrc32); + + if (lzCompStatus != lzham_compress_status_t::LZHAM_COMP_STATUS_SUCCESS) + { + Warning(eDLL_T::COMMON, NO_ERROR, "Failed to compress blob: status = %08x\n", lzCompStatus); + return false; + } return true; } diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h index 38a639b7..db5a189b 100644 --- a/r5dev/public/utility/sigcache.h +++ b/r5dev/public/utility/sigcache.h @@ -4,7 +4,10 @@ #include "protoc/sig_map.pb.h" #define SIGDB_MAGIC (('p'<<24)+('a'<<16)+('M'<<8)+'S') -#define SIGDB_VERSION 0x1 +#define SIGDB_DICT_SIZE 20 + +#define SIGDB_MAJOR_VERSION 0x1 // Increment when library changes are made. +#define SIGDB_MINOR_VERSION 0x1 // Increment when SDK updates are released. #ifdef DEDICATED #define SIGDB_FILE "cfg\\server\\startup.bin" @@ -15,21 +18,33 @@ class CSigCache { public: + CSigCache() { m_bInitialized = false; }; + ~CSigCache() {}; + void AddEntry(const string& svPattern, const uint64_t nRVA); bool FindEntry(const string& svPattern, uint64_t& nRVA) const; bool LoadCache(const string& svCacheFile); bool WriteCache(const string& svCacheFile); +private: + bool CompressBlob(size_t nSrcLen, size_t& nDstSize, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; + bool DecompressBlob(size_t nSrcLen, size_t& nDstSize, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; + SigMap_Pb m_Cache; bool m_bInitialized; }; +#pragma pack(push, 1) struct SigDBHeader_t { int m_nMagic; - int m_nVersion; - FILETIME m_FileTime; + uint16_t m_nMajorVersion; + uint16_t m_nMinorVersion; + uint64_t m_nBlobSizeMem; + uint64_t m_nBlobSizeDisk; + uint32_t m_nBlobHash; }; +#pragma pack(pop) #endif // !SIGCACHE_H From 5695e3016c60a018c7495e864c106b78372defd4 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 2 Dec 2022 22:31:42 +0100 Subject: [PATCH 14/20] CIOStream: use stf::fstream instead --- r5dev/public/utility/binstream.cpp | 77 ++++++++++++++++-------------- r5dev/public/utility/binstream.h | 15 +++--- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/r5dev/public/utility/binstream.cpp b/r5dev/public/utility/binstream.cpp index 5189f64e..d6030a26 100644 --- a/r5dev/public/utility/binstream.cpp +++ b/r5dev/public/utility/binstream.cpp @@ -18,15 +18,16 @@ CIOStream::CIOStream(const fs::path& svFileFullPath, Mode_t eMode) //----------------------------------------------------------------------------- CIOStream::~CIOStream() { - if (m_oStream.is_open()) - m_oStream.close(); - if (m_iStream.is_open()) - m_iStream.close(); + if (m_Stream.is_open()) + m_Stream.close(); + if (m_Stream.is_open()) + m_Stream.close(); } //----------------------------------------------------------------------------- // Purpose: opens the file in specified mode -// Input : fileFullPath - mode +// Input : fsFilePath - +// eMode - // Output : true if operation is successful //----------------------------------------------------------------------------- bool CIOStream::Open(const fs::path& fsFilePath, Mode_t eMode) @@ -36,12 +37,12 @@ bool CIOStream::Open(const fs::path& fsFilePath, Mode_t eMode) switch (m_eCurrentMode) { case Mode_t::READ: - if (m_iStream.is_open()) + if (m_Stream.is_open()) { - m_iStream.close(); + m_Stream.close(); } - m_iStream.open(fsFilePath, std::ios::binary | std::ios::in); - if (!m_iStream.is_open() || !m_iStream.good()) + m_Stream.open(fsFilePath, std::ios::binary | std::ios::in); + if (!m_Stream.is_open() || !m_Stream.good()) { m_eCurrentMode = Mode_t::NONE; return false; @@ -51,12 +52,12 @@ bool CIOStream::Open(const fs::path& fsFilePath, Mode_t eMode) return true; case Mode_t::WRITE: - if (m_oStream.is_open()) + if (m_Stream.is_open()) { - m_oStream.close(); + m_Stream.close(); } - m_oStream.open(fsFilePath, std::ios::binary | std::ios::out); - if (!m_oStream.is_open() || !m_oStream.good()) + m_Stream.open(fsFilePath, std::ios::binary | std::ios::out); + if (!m_Stream.is_open() || !m_Stream.good()) { m_eCurrentMode = Mode_t::NONE; return false; @@ -77,10 +78,10 @@ void CIOStream::Close() switch (m_eCurrentMode) { case Mode_t::READ: - m_iStream.close(); + m_Stream.close(); return; case Mode_t::WRITE: - m_oStream.close(); + m_Stream.close(); return; } } @@ -91,7 +92,7 @@ void CIOStream::Close() void CIOStream::Flush() { if (IsWritable()) - m_oStream.flush(); + m_Stream.flush(); } //----------------------------------------------------------------------------- @@ -99,25 +100,26 @@ void CIOStream::Flush() //----------------------------------------------------------------------------- void CIOStream::ComputeFileSize() { - m_nSize = m_iStream.tellg(); - m_iStream.seekg(0, std::ios::end); - m_nSize = m_iStream.tellg() - m_nSize; - m_iStream.seekg(0, std::ios::beg); - m_iStream.clear(); + m_nSize = m_Stream.tellg(); + m_Stream.seekg(0, std::ios::end); + m_nSize = m_Stream.tellg() - m_nSize; + m_Stream.seekg(0, std::ios::beg); + m_Stream.clear(); } //----------------------------------------------------------------------------- // Purpose: gets the position of the current character in the stream +// Output : std::streampos //----------------------------------------------------------------------------- std::streampos CIOStream::GetPosition() { switch (m_eCurrentMode) { case Mode_t::READ: - return m_iStream.tellg(); + return m_Stream.tellg(); break; case Mode_t::WRITE: - return m_oStream.tellp(); + return m_Stream.tellp(); break; default: return static_cast(NULL); @@ -133,10 +135,10 @@ void CIOStream::SetPosition(std::streampos nOffset) switch (m_eCurrentMode) { case Mode_t::READ: - m_iStream.seekg(nOffset); + m_Stream.seekg(nOffset); break; case Mode_t::WRITE: - m_oStream.seekp(nOffset); + m_Stream.seekp(nOffset); break; default: break; @@ -145,14 +147,16 @@ void CIOStream::SetPosition(std::streampos nOffset) //----------------------------------------------------------------------------- // Purpose: returns the data (ifstream only) +// Output : std::filebuf* //----------------------------------------------------------------------------- const std::filebuf* CIOStream::GetData() const { - return m_iStream.rdbuf(); + return m_Stream.rdbuf(); } //----------------------------------------------------------------------------- // Purpose: returns the data size (ifstream only) +// Output : std::streampos //----------------------------------------------------------------------------- const std::streampos CIOStream::GetSize() const { @@ -168,12 +172,12 @@ bool CIOStream::IsReadable() if (m_eCurrentMode != Mode_t::READ) return false; - if (!m_iStream) + if (!m_Stream) return false; - if (m_iStream.eof()) + if (m_Stream.eof()) { - m_iStream.close(); + m_Stream.close(); m_eCurrentMode = Mode_t::NONE; return false; } @@ -190,7 +194,7 @@ bool CIOStream::IsWritable() const if (m_eCurrentMode != Mode_t::WRITE) return false; - if (!m_oStream) + if (!m_Stream) return false; return true; @@ -202,7 +206,7 @@ bool CIOStream::IsWritable() const //----------------------------------------------------------------------------- bool CIOStream::IsEof() const { - return m_iStream.eof(); + return m_Stream.eof(); } //----------------------------------------------------------------------------- @@ -216,7 +220,7 @@ string CIOStream::ReadString() if (IsReadable()) { char c; - while (!m_iStream.eof() && (c = Read()) != '\0') + while (!m_Stream.eof() && (c = Read()) != '\0') result += c; return result; @@ -227,16 +231,15 @@ string CIOStream::ReadString() //----------------------------------------------------------------------------- // Purpose: writes a string to the file +// Input : &svInput - //----------------------------------------------------------------------------- -void CIOStream::WriteString(string svInput) +void CIOStream::WriteString(const string& svInput) { if (!IsWritable()) return; - svInput += '\0'; // null-terminate the string. - const char* szText = svInput.c_str(); - size_t nSize = svInput.size(); + size_t nSize = svInput.size() + 1; // '+1' for the null terminator. - m_oStream.write(szText, nSize); + m_Stream.write(szText, nSize); } diff --git a/r5dev/public/utility/binstream.h b/r5dev/public/utility/binstream.h index 3cba8c46..2ada2644 100644 --- a/r5dev/public/utility/binstream.h +++ b/r5dev/public/utility/binstream.h @@ -38,7 +38,7 @@ public: void Read(T& tValue) { if (IsReadable()) - m_iStream.read(reinterpret_cast(&tValue), sizeof(tValue)); + m_Stream.read(reinterpret_cast(&tValue), sizeof(tValue)); } //----------------------------------------------------------------------------- @@ -48,7 +48,7 @@ public: void Read(T& tValue, size_t nSize) { if (IsReadable()) - m_iStream.read(reinterpret_cast(&tValue), nSize); + m_Stream.read(reinterpret_cast(&tValue), nSize); } //----------------------------------------------------------------------------- @@ -61,7 +61,7 @@ public: if (!IsReadable()) return value; - m_iStream.read(reinterpret_cast(&value), sizeof(value)); + m_Stream.read(reinterpret_cast(&value), sizeof(value)); return value; } string ReadString(); @@ -75,7 +75,7 @@ public: if (!IsWritable()) return; - m_oStream.write(reinterpret_cast(&tValue), sizeof(tValue)); + m_Stream.write(reinterpret_cast(&tValue), sizeof(tValue)); } //----------------------------------------------------------------------------- @@ -87,14 +87,13 @@ public: if (!IsWritable()) return; - m_oStream.write(reinterpret_cast(tValue), nSize); + m_Stream.write(reinterpret_cast(tValue), nSize); } - void WriteString(string svInput); + void WriteString(const string& svInput); private: std::streampos m_nSize; // Size of ifstream. Mode_t m_eCurrentMode; // Current active mode. - ofstream m_oStream; // Output file stream. - ifstream m_iStream; // Input file stream. + fstream m_Stream; // I/O file stream. }; From a9e518e2e65ddb9c2fba94b956b433321737b628 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 3 Dec 2022 00:08:48 +0100 Subject: [PATCH 15/20] Fix PluginSDK compile errors --- r5dev/public/utility/module.cpp | 96 +++++++++++++++++---------------- r5dev/public/utility/module.h | 2 + 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/r5dev/public/utility/module.cpp b/r5dev/public/utility/module.cpp index de9edafd..555f2601 100644 --- a/r5dev/public/utility/module.cpp +++ b/r5dev/public/utility/module.cpp @@ -35,6 +35,7 @@ CModule::CModule(const string& svModuleName) : m_svModuleName(svModuleName) m_ReadOnlyData = GetSectionByName(".rdata"); } +#ifndef PLUGINSDK //----------------------------------------------------------------------------- // Purpose: find array of bytes in process memory using SIMD instructions // Input : *szPattern - @@ -248,6 +249,54 @@ CMemory CModule::FindString(const string& svString, const ptrdiff_t nOccurrence, return resultAddress; } +//----------------------------------------------------------------------------- +// Purpose: get address of a virtual method table by rtti type descriptor name. +// Input : *svTableName - +// nRefIndex - +// Output : CMemory +//----------------------------------------------------------------------------- +CMemory CModule::GetVirtualMethodTable(const string& svTableName, const uint32_t nRefIndex) +{ + uint64_t nRVA; // Packed together as we can have multiple VFTable searches, but with different ref indexes. + string svPackedTableName = svTableName + std::to_string(nRefIndex); + + if (g_SigCache.FindEntry(svPackedTableName, nRVA)) + { + return CMemory(nRVA + GetModuleBase()); + } + + const auto tableNameInfo = StringToMaskedBytes(svTableName, false); + CMemory rttiTypeDescriptor = FindPatternSIMD(tableNameInfo.first.data(), tableNameInfo.second.c_str(), { ".data", m_RunTimeData.m_pSectionBase, m_RunTimeData.m_nSectionSize }).OffsetSelf(-0x10); + if (!rttiTypeDescriptor) + return CMemory(); + + uintptr_t scanStart = m_ReadOnlyData.m_pSectionBase; // Get the start address of our scan. + + const uintptr_t scanEnd = (m_ReadOnlyData.m_pSectionBase + m_ReadOnlyData.m_nSectionSize) - 0x4; // Calculate the end of our scan. + const uintptr_t rttiTDRva = rttiTypeDescriptor.GetPtr() - m_pModuleBase; // The RTTI gets referenced by a 4-Byte RVA address. We need to scan for that address. + while (scanStart < scanEnd) + { + CMemory reference = FindPatternSIMD(reinterpret_cast(&rttiTDRva), "xxxx", { ".rdata", scanStart, m_ReadOnlyData.m_nSectionSize }, nRefIndex); + if (!reference) + break; + + CMemory referenceOffset = reference.Offset(-0xC); + if (referenceOffset.GetValue() != 1) // Check if we got a RTTI Object Locator for this reference by checking if -0xC is 1, which is the 'signature' field which is always 1 on x64. + { + scanStart = reference.Offset(0x4).GetPtr(); // Set location to current reference + 0x4 so we avoid pushing it back again into the vector. + continue; + } + + CMemory vfTable = FindPatternSIMD(reinterpret_cast(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8); + g_SigCache.AddEntry(svPackedTableName, GetRVA(vfTable.GetPtr())); + + return vfTable; + } + + return CMemory(); +} +#endif // !PLUGINSDK + //----------------------------------------------------------------------------- // Purpose: get address of exported function in this module // Input : *svFunctionName - @@ -300,53 +349,6 @@ CMemory CModule::GetExportedFunction(const string& svFunctionName) const return CMemory(); } -//----------------------------------------------------------------------------- -// Purpose: get address of a virtual method table by rtti type descriptor name. -// Input : *svTableName - -// nRefIndex - -// Output : CMemory -//----------------------------------------------------------------------------- -CMemory CModule::GetVirtualMethodTable(const string& svTableName, const uint32_t nRefIndex) -{ - uint64_t nRVA; // Packed together as we can have multiple VFTable searches, but with different ref indexes. - string svPackedTableName = svTableName + std::to_string(nRefIndex); - - if (g_SigCache.FindEntry(svPackedTableName, nRVA)) - { - return CMemory(nRVA + GetModuleBase()); - } - - const auto tableNameInfo = StringToMaskedBytes(svTableName, false); - CMemory rttiTypeDescriptor = FindPatternSIMD(tableNameInfo.first.data(), tableNameInfo.second.c_str(), { ".data", m_RunTimeData.m_pSectionBase, m_RunTimeData.m_nSectionSize }).OffsetSelf(-0x10); - if (!rttiTypeDescriptor) - return CMemory(); - - uintptr_t scanStart = m_ReadOnlyData.m_pSectionBase; // Get the start address of our scan. - - const uintptr_t scanEnd = (m_ReadOnlyData.m_pSectionBase + m_ReadOnlyData.m_nSectionSize) - 0x4; // Calculate the end of our scan. - const uintptr_t rttiTDRva = rttiTypeDescriptor.GetPtr() - m_pModuleBase; // The RTTI gets referenced by a 4-Byte RVA address. We need to scan for that address. - while (scanStart < scanEnd) - { - CMemory reference = FindPatternSIMD(reinterpret_cast(&rttiTDRva), "xxxx", { ".rdata", scanStart, m_ReadOnlyData.m_nSectionSize }, nRefIndex); - if (!reference) - break; - - CMemory referenceOffset = reference.Offset(-0xC); - if (referenceOffset.GetValue() != 1) // Check if we got a RTTI Object Locator for this reference by checking if -0xC is 1, which is the 'signature' field which is always 1 on x64. - { - scanStart = reference.Offset(0x4).GetPtr(); // Set location to current reference + 0x4 so we avoid pushing it back again into the vector. - continue; - } - - CMemory vfTable = FindPatternSIMD(reinterpret_cast(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8); - g_SigCache.AddEntry(svPackedTableName, GetRVA(vfTable.GetPtr())); - - return vfTable; - } - - return CMemory(); -} - //----------------------------------------------------------------------------- // Purpose: get the module section by name (example: '.rdata', '.text') // Input : *svModuleName - diff --git a/r5dev/public/utility/module.h b/r5dev/public/utility/module.h index d685b62e..710917f2 100644 --- a/r5dev/public/utility/module.h +++ b/r5dev/public/utility/module.h @@ -22,11 +22,13 @@ public: CModule(void) = default; CModule(const string& moduleName); +#ifndef PLUGINSDK CMemory FindPatternSIMD(const string& svPattern, const ModuleSections_t& moduleSection = {}) const; CMemory FindString(const string& string, const ptrdiff_t occurrence = 1, bool nullTerminator = false) const; CMemory FindStringReadOnly(const string& svString, bool nullTerminator) const; CMemory GetVirtualMethodTable(const string& svTableName, const uint32_t nRefIndex = 0); +#endif // !PLUGINSDK CMemory GetExportedFunction(const string& svFunctionName) const; ModuleSections_t GetSectionByName(const string& svSectionName) const; uintptr_t GetModuleBase(void) const; From e26679f19904809fbf223b035d518c1e433ef986 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 3 Dec 2022 17:27:54 +0100 Subject: [PATCH 16/20] Use 'Error' instead when SMap compression failed --- r5dev/public/utility/sigcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index 27ee0318..829d5039 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -195,7 +195,7 @@ bool CSigCache::CompressBlob(size_t nSrcLen, size_t& nDstSize, uint32_t& nCrc32, if (lzCompStatus != lzham_compress_status_t::LZHAM_COMP_STATUS_SUCCESS) { - Warning(eDLL_T::COMMON, NO_ERROR, "Failed to compress blob: status = %08x\n", lzCompStatus); + Error(eDLL_T::COMMON, NO_ERROR, "Failed to compress blob: status = %08x\n", lzCompStatus); return false; } From 10a0a4116297a2b8cee15c63b9e13610b434dfa1 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 3 Dec 2022 17:40:05 +0100 Subject: [PATCH 17/20] Rename to maintain consistency --- r5dev/public/utility/sigcache.cpp | 8 ++++---- r5dev/public/utility/sigcache.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index 829d5039..06b2d8e0 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -151,7 +151,7 @@ bool CSigCache::WriteCache(const string& svCacheFile) //----------------------------------------------------------------------------- // Purpose: decompresses the blob containing the signature map // Input : nSrcLen - -// &nDstSize - +// &nDstLen - // &nCrc32 - // *pSrcBuf - // *pDstBuf - @@ -178,20 +178,20 @@ bool CSigCache::DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32 //----------------------------------------------------------------------------- // Purpose: compresses the blob containing the signature map // Input : nSrcLen - -// &nDstSize - +// &nDstLen - // &nCrc32 - // *pSrcBuf - // *pDstBuf - // Output : true on success, false otherwise //----------------------------------------------------------------------------- -bool CSigCache::CompressBlob(size_t nSrcLen, size_t& nDstSize, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const +bool CSigCache::CompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const { lzham_compress_params lzCompParams{}; lzCompParams.m_dict_size_log2 = SIGDB_DICT_SIZE; lzCompParams.m_level = lzham_compress_level::LZHAM_COMP_LEVEL_FASTEST; lzCompParams.m_compress_flags = lzham_compress_flags::LZHAM_COMP_FLAG_DETERMINISTIC_PARSING; - lzham_compress_status_t lzCompStatus = lzham_compress_memory(&lzCompParams, pDstBuf, &nDstSize, pSrcBuf, nSrcLen, NULL, &nCrc32); + lzham_compress_status_t lzCompStatus = lzham_compress_memory(&lzCompParams, pDstBuf, &nDstLen, pSrcBuf, nSrcLen, NULL, &nCrc32); if (lzCompStatus != lzham_compress_status_t::LZHAM_COMP_STATUS_SUCCESS) { diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h index db5a189b..5f2c3878 100644 --- a/r5dev/public/utility/sigcache.h +++ b/r5dev/public/utility/sigcache.h @@ -28,8 +28,8 @@ public: bool WriteCache(const string& svCacheFile); private: - bool CompressBlob(size_t nSrcLen, size_t& nDstSize, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; - bool DecompressBlob(size_t nSrcLen, size_t& nDstSize, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; + bool CompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; + bool DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; SigMap_Pb m_Cache; bool m_bInitialized; From 55b90781ee6213198edc6fc6f977b70d4ef1b948 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 4 Dec 2022 01:33:10 +0100 Subject: [PATCH 18/20] Remove experimental CRC implementation in LZHAM This implementation was done to calculate buffer CRC on the go, as that was what the VPK file system uses for the file crc's. But it later turned out to be unnecessary, and was never reverted. --- r5dev/public/utility/sigcache.cpp | 24 ++++----- r5dev/public/utility/sigcache.h | 6 +-- r5dev/thirdparty/lzham/include/lzham.h | 43 +++++----------- r5dev/thirdparty/lzham/lzham_api.cpp | 14 ++--- r5dev/thirdparty/lzham/lzhamcomp/lzham_comp.h | 4 +- .../lzham/lzhamcomp/lzham_lzcomp.cpp | 21 +++----- .../lzham/lzhamcomp/lzham_lzcomp_internal.cpp | 7 --- .../lzham/lzhamcomp/lzham_lzcomp_internal.h | 2 - .../lzham/lzhamdecomp/lzham_decomp.h | 6 +-- .../lzham/lzhamdecomp/lzham_lzdecomp.cpp | 46 +++-------------- r5dev/vpklib/packedstore.cpp | 51 ++++--------------- r5dev/vpklib/packedstore.h | 8 +-- 12 files changed, 65 insertions(+), 167 deletions(-) diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index 06b2d8e0..f7c5b838 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -81,17 +81,17 @@ bool CSigCache::LoadCache(const string& svCacheFile) header.m_nBlobSizeMem = reader.Read(); header.m_nBlobSizeDisk = reader.Read(); - header.m_nBlobHash = reader.Read(); + header.m_nBlobChecksum = reader.Read(); - uint32_t nCrc32; + uint32_t nAdler32; std::unique_ptr pSrcBuf(new uint8_t[header.m_nBlobSizeDisk]); std::unique_ptr pDstBuf(new uint8_t[header.m_nBlobSizeMem]); reader.Read(*pSrcBuf.get(), header.m_nBlobSizeDisk); - DecompressBlob(header.m_nBlobSizeDisk, header.m_nBlobSizeMem, nCrc32, pSrcBuf.get(), pDstBuf.get()); + DecompressBlob(header.m_nBlobSizeDisk, header.m_nBlobSizeMem, nAdler32, pSrcBuf.get(), pDstBuf.get()); - if (header.m_nBlobHash != nCrc32) + if (header.m_nBlobChecksum != nAdler32) { return false; } @@ -135,7 +135,7 @@ bool CSigCache::WriteCache(const string& svCacheFile) header.m_nBlobSizeMem = svBuffer.size(); uint64_t nCompSize = svBuffer.size(); - if (!CompressBlob(svBuffer.size(), nCompSize, header.m_nBlobHash, reinterpret_cast(svBuffer.data()), pBuffer.get())) + if (!CompressBlob(svBuffer.size(), nCompSize, header.m_nBlobChecksum, reinterpret_cast(svBuffer.data()), pBuffer.get())) { return false; } @@ -152,19 +152,19 @@ bool CSigCache::WriteCache(const string& svCacheFile) // Purpose: decompresses the blob containing the signature map // Input : nSrcLen - // &nDstLen - -// &nCrc32 - +// &nAdler - // *pSrcBuf - // *pDstBuf - // Output : true on success, false otherwise //----------------------------------------------------------------------------- -bool CSigCache::DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const +bool CSigCache::DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const { lzham_decompress_params lzDecompParams{}; lzDecompParams.m_dict_size_log2 = SIGDB_DICT_SIZE; - lzDecompParams.m_decompress_flags = lzham_decompress_flags::LZHAM_DECOMP_FLAG_OUTPUT_UNBUFFERED | lzham_decompress_flags::LZHAM_DECOMP_FLAG_COMPUTE_CRC32; + lzDecompParams.m_decompress_flags = lzham_decompress_flags::LZHAM_DECOMP_FLAG_OUTPUT_UNBUFFERED | lzham_decompress_flags::LZHAM_DECOMP_FLAG_COMPUTE_ADLER32; lzDecompParams.m_struct_size = sizeof(lzham_decompress_params); - lzham_decompress_status_t lzDecompStatus = lzham_decompress_memory(&lzDecompParams, pDstBuf, &nDstLen, pSrcBuf, nSrcLen, NULL, &nCrc32); + lzham_decompress_status_t lzDecompStatus = lzham_decompress_memory(&lzDecompParams, pDstBuf, &nDstLen, pSrcBuf, nSrcLen, &nAdler); if (lzDecompStatus != lzham_decompress_status_t::LZHAM_DECOMP_STATUS_SUCCESS) { @@ -179,19 +179,19 @@ bool CSigCache::DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32 // Purpose: compresses the blob containing the signature map // Input : nSrcLen - // &nDstLen - -// &nCrc32 - +// &nAdler - // *pSrcBuf - // *pDstBuf - // Output : true on success, false otherwise //----------------------------------------------------------------------------- -bool CSigCache::CompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const +bool CSigCache::CompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const { lzham_compress_params lzCompParams{}; lzCompParams.m_dict_size_log2 = SIGDB_DICT_SIZE; lzCompParams.m_level = lzham_compress_level::LZHAM_COMP_LEVEL_FASTEST; lzCompParams.m_compress_flags = lzham_compress_flags::LZHAM_COMP_FLAG_DETERMINISTIC_PARSING; - lzham_compress_status_t lzCompStatus = lzham_compress_memory(&lzCompParams, pDstBuf, &nDstLen, pSrcBuf, nSrcLen, NULL, &nCrc32); + lzham_compress_status_t lzCompStatus = lzham_compress_memory(&lzCompParams, pDstBuf, &nDstLen, pSrcBuf, nSrcLen, &nAdler); if (lzCompStatus != lzham_compress_status_t::LZHAM_COMP_STATUS_SUCCESS) { diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h index 5f2c3878..cd9adb1f 100644 --- a/r5dev/public/utility/sigcache.h +++ b/r5dev/public/utility/sigcache.h @@ -28,8 +28,8 @@ public: bool WriteCache(const string& svCacheFile); private: - bool CompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; - bool DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nCrc32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; + bool CompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; + bool DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; SigMap_Pb m_Cache; bool m_bInitialized; @@ -43,7 +43,7 @@ struct SigDBHeader_t uint16_t m_nMinorVersion; uint64_t m_nBlobSizeMem; uint64_t m_nBlobSizeDisk; - uint32_t m_nBlobHash; + uint32_t m_nBlobChecksum; }; #pragma pack(pop) diff --git a/r5dev/thirdparty/lzham/include/lzham.h b/r5dev/thirdparty/lzham/include/lzham.h index 0e04dfc7..b8d4fc0d 100644 --- a/r5dev/thirdparty/lzham/include/lzham.h +++ b/r5dev/thirdparty/lzham/include/lzham.h @@ -146,12 +146,6 @@ extern "C" { const void *m_pSeed_bytes; // for delta compression (optional) - pointer to seed bytes buffer, must be at least m_num_seed_bytes long } lzham_compress_params; - typedef struct - { - lzham_uint32 adler32; - lzham_uint32 crc32; - } lzham_compress_checksums; - // Initializes a compressor. Returns a pointer to the compressor's internal state, or NULL on failure. // pParams cannot be NULL. Be sure to initialize the pParams->m_struct_size member to sizeof(lzham_compress_params) (along with the other members to reasonable values) before calling this function. // TODO: With large dictionaries this function could take a while (due to memory allocation). I need to add a reinit() API for compression (decompression already has one). @@ -160,8 +154,8 @@ extern "C" { LZHAM_DLL_EXPORT lzham_compress_state_ptr LZHAM_CDECL lzham_compress_reinit(lzham_compress_state_ptr pState); // Deinitializes a compressor, releasing all allocated memory. - // returns adler32 and crc32 of source data (valid only on success). - LZHAM_DLL_EXPORT lzham_compress_checksums LZHAM_CDECL lzham_compress_deinit(lzham_compress_state_ptr pState); + // returns adler32 of source data (valid only on success). + LZHAM_DLL_EXPORT lzham_uint32 LZHAM_CDECL lzham_compress_deinit(lzham_compress_state_ptr pState); // Compresses an arbitrarily sized block of data, writing as much available compressed data as possible to the output buffer. // This method may be called as many times as needed, but for best perf. try not to call it with tiny buffers. @@ -198,8 +192,7 @@ extern "C" { size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, - lzham_uint32 *pAdler32, - lzham_uint32 *pCrc32); + lzham_uint32 *pAdler32); // Decompression typedef enum @@ -230,7 +223,6 @@ extern "C" { LZHAM_DECOMP_STATUS_FAILED_EXPECTED_MORE_RAW_BYTES, LZHAM_DECOMP_STATUS_FAILED_BAD_CODE, LZHAM_DECOMP_STATUS_FAILED_ADLER32, - LZHAM_DECOMP_STATUS_FAILED_CRC32, LZHAM_DECOMP_STATUS_FAILED_BAD_RAW_BLOCK, LZHAM_DECOMP_STATUS_FAILED_BAD_COMP_BLOCK_SYNC_CHECK, LZHAM_DECOMP_STATUS_FAILED_BAD_ZLIB_HEADER, @@ -247,7 +239,6 @@ extern "C" { LZHAM_DECOMP_FLAG_NONE = 0, LZHAM_DECOMP_FLAG_OUTPUT_UNBUFFERED = 1 << 0, LZHAM_DECOMP_FLAG_COMPUTE_ADLER32 = 1 << 1, - LZHAM_DECOMP_FLAG_COMPUTE_CRC32 = 1 << 2, LZHAM_DECOMP_FLAG_READ_ZLIB_STREAM = 1 << 3, } lzham_decompress_flags; @@ -265,12 +256,6 @@ extern "C" { const void *m_pSeed_bytes; // for delta compression (optional) - pointer to seed bytes buffer, must be at least m_num_seed_bytes long } lzham_decompress_params; - typedef struct - { - lzham_uint32 adler32; - lzham_uint32 crc32; - } lzham_decompress_checksums; - // Initializes a decompressor. // pParams cannot be NULL. Be sure to initialize the pParams->m_struct_size member to sizeof(lzham_decompress_params) (along with the other members to reasonable values) before calling this function. // Note: With large dictionaries this function could take a while (due to memory allocation). To serially decompress multiple streams, it's faster to init a compressor once and @@ -282,7 +267,7 @@ extern "C" { // Deinitializes a decompressor. // returns adler32 of decompressed data if compute_adler32 was true, otherwise it returns the adler32 from the compressed stream. - LZHAM_DLL_EXPORT lzham_decompress_checksums LZHAM_CDECL lzham_decompress_deinit(lzham_decompress_state_ptr pState); + LZHAM_DLL_EXPORT lzham_uint32 LZHAM_CDECL lzham_decompress_deinit(lzham_decompress_state_ptr pState); // Decompresses an arbitrarily sized block of compressed data, writing as much available decompressed data as possible to the output buffer. // This method is implemented as a coroutine so it may be called as many times as needed. However, for best perf. try not to call it with tiny buffers. @@ -311,8 +296,7 @@ extern "C" { size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, - lzham_uint32 *pAdler32, - lzham_uint32 *pCrc32); + lzham_uint32 *pAdler32); // ------------------- zlib-style API Definitions. @@ -328,11 +312,11 @@ extern "C" { #define LZHAM_Z_ADLER32_INIT (1) // lzham_adler32() returns the initial adler-32 value to use when called with ptr==NULL. - LZHAM_DLL_EXPORT lzham_z_ulong lzham_z_adler32(lzham_z_ulong adler, const unsigned char *ptr, size_t buf_len); + LZHAM_DLL_EXPORT lzham_z_ulong lzham_z_adler32(lzham_z_ulong adler, const lzham_uint8 *ptr, size_t buf_len); #define LZHAM_Z_CRC32_INIT (0) - // lzham_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. - LZHAM_DLL_EXPORT lzham_z_ulong lzham_z_crc32(lzham_z_ulong crc, const unsigned char *ptr, size_t buf_len); + // lzham_crc32() returns the initial crc-32 value to use when called with ptr==NULL. + LZHAM_DLL_EXPORT lzham_z_ulong lzham_z_crc32(lzham_z_ulong crc, const lzham_uint8 *ptr, size_t buf_len); // Compression strategies. enum @@ -437,8 +421,7 @@ extern "C" { void *opaque; // heap alloc function user pointer int data_type; // data_type (unused) - lzham_z_ulong adler32; // adler32 of the source or uncompressed data - lzham_z_ulong crc32; // crc32 of the source or uncompressed data + lzham_z_ulong adler32; // adler32 of the source or uncompressed data lzham_z_ulong reserved; // not used } lzham_z_stream; @@ -618,16 +601,16 @@ extern "C" { typedef lzham_compress_state_ptr (LZHAM_CDECL *lzham_compress_init_func)(const lzham_compress_params *pParams); typedef lzham_compress_state_ptr (LZHAM_CDECL *lzham_compress_reinit_func)(lzham_compress_state_ptr pState); - typedef lzham_compress_checksums (LZHAM_CDECL *lzham_compress_deinit_func)(lzham_compress_state_ptr pState); + typedef lzham_uint32 (LZHAM_CDECL *lzham_compress_deinit_func)(lzham_compress_state_ptr pState); typedef lzham_compress_status_t (LZHAM_CDECL *lzham_compress_func)(lzham_compress_state_ptr pState, const lzham_uint8 *pIn_buf, size_t *pIn_buf_size, lzham_uint8 *pOut_buf, size_t *pOut_buf_size, lzham_bool no_more_input_bytes_flag); typedef lzham_compress_status_t (LZHAM_CDECL *lzham_compress2_func)(lzham_compress_state_ptr pState, const lzham_uint8 *pIn_buf, size_t *pIn_buf_size, lzham_uint8 *pOut_buf, size_t *pOut_buf_size, lzham_flush_t flush_type); - typedef lzham_compress_status_t (LZHAM_CDECL *lzham_compress_memory_func)(const lzham_compress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32, lzham_uint32* pCrc32); + typedef lzham_compress_status_t (LZHAM_CDECL *lzham_compress_memory_func)(const lzham_compress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32); typedef lzham_decompress_state_ptr (LZHAM_CDECL *lzham_decompress_init_func)(const lzham_decompress_params *pParams); typedef lzham_decompress_state_ptr (LZHAM_CDECL *lzham_decompress_reinit_func)(lzham_compress_state_ptr pState, const lzham_decompress_params *pParams); - typedef lzham_decompress_checksums (LZHAM_CDECL *lzham_decompress_deinit_func)(lzham_decompress_state_ptr pState); + typedef lzham_uint32 (LZHAM_CDECL *lzham_decompress_deinit_func)(lzham_decompress_state_ptr pState); typedef lzham_decompress_status_t (LZHAM_CDECL *lzham_decompress_func)(lzham_decompress_state_ptr pState, const lzham_uint8 *pIn_buf, size_t *pIn_buf_size, lzham_uint8 *pOut_buf, size_t *pOut_buf_size, lzham_bool no_more_input_bytes_flag); - typedef lzham_decompress_status_t (LZHAM_CDECL *lzham_decompress_memory_func)(const lzham_decompress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32, lzham_uint32 *pCrc32); + typedef lzham_decompress_status_t (LZHAM_CDECL *lzham_decompress_memory_func)(const lzham_decompress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32); typedef const char *(LZHAM_CDECL *lzham_z_version_func)(void); typedef int (LZHAM_CDECL *lzham_z_deflateInit_func)(lzham_z_streamp pStream, int level); diff --git a/r5dev/thirdparty/lzham/lzham_api.cpp b/r5dev/thirdparty/lzham/lzham_api.cpp index 9672d735..fb94aba9 100644 --- a/r5dev/thirdparty/lzham/lzham_api.cpp +++ b/r5dev/thirdparty/lzham/lzham_api.cpp @@ -24,7 +24,7 @@ extern "C" LZHAM_DLL_EXPORT lzham_decompress_state_ptr lzham_decompress_reinit(l return lzham::lzham_lib_decompress_reinit(p, pParams); } -extern "C" LZHAM_DLL_EXPORT lzham_decompress_checksums lzham_decompress_deinit(lzham_decompress_state_ptr p) +extern "C" LZHAM_DLL_EXPORT lzham_uint32 lzham_decompress_deinit(lzham_decompress_state_ptr p) { return lzham::lzham_lib_decompress_deinit(p); } @@ -38,9 +38,9 @@ extern "C" LZHAM_DLL_EXPORT lzham_decompress_status_t lzham_decompress( return lzham::lzham_lib_decompress(p, pIn_buf, pIn_buf_size, pOut_buf, pOut_buf_size, no_more_input_bytes_flag); } -extern "C" LZHAM_DLL_EXPORT lzham_decompress_status_t lzham_decompress_memory(const lzham_decompress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32, lzham_uint32 *pCrc32) +extern "C" LZHAM_DLL_EXPORT lzham_decompress_status_t lzham_decompress_memory(const lzham_decompress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32) { - return lzham::lzham_lib_decompress_memory(pParams, pDst_buf, pDst_len, pSrc_buf, src_len, pAdler32, pCrc32); + return lzham::lzham_lib_decompress_memory(pParams, pDst_buf, pDst_len, pSrc_buf, src_len, pAdler32); } extern "C" LZHAM_DLL_EXPORT lzham_compress_state_ptr lzham_compress_init(const lzham_compress_params *pParams) @@ -53,7 +53,7 @@ extern "C" LZHAM_DLL_EXPORT lzham_compress_state_ptr lzham_compress_reinit(lzham return lzham::lzham_lib_compress_reinit(p); } -extern "C" LZHAM_DLL_EXPORT lzham_compress_checksums lzham_compress_deinit(lzham_compress_state_ptr p) +extern "C" LZHAM_DLL_EXPORT lzham_uint32 lzham_compress_deinit(lzham_compress_state_ptr p) { return lzham::lzham_lib_compress_deinit(p); } @@ -76,9 +76,9 @@ extern "C" LZHAM_DLL_EXPORT lzham_compress_status_t lzham_compress2( return lzham::lzham_lib_compress2(p, pIn_buf, pIn_buf_size, pOut_buf, pOut_buf_size, flush_type); } -extern "C" LZHAM_DLL_EXPORT lzham_compress_status_t lzham_compress_memory(const lzham_compress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32, lzham_uint32 * pCrc32) +extern "C" LZHAM_DLL_EXPORT lzham_compress_status_t lzham_compress_memory(const lzham_compress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32) { - return lzham::lzham_lib_compress_memory(pParams, pDst_buf, pDst_len, pSrc_buf, src_len, pAdler32, pCrc32); + return lzham::lzham_lib_compress_memory(pParams, pDst_buf, pDst_len, pSrc_buf, src_len, pAdler32); } // ----------------- zlib-style API's @@ -88,7 +88,7 @@ extern "C" LZHAM_DLL_EXPORT const char *lzham_z_version(void) return LZHAM_Z_VERSION; } -extern "C" lzham_z_ulong LZHAM_DLL_EXPORT lzham_z_adler32(lzham_z_ulong adler, const unsigned char *ptr, size_t buf_len) +extern "C" lzham_z_ulong LZHAM_DLL_EXPORT lzham_z_adler32(lzham_z_ulong adler, const lzham_uint8 *ptr, size_t buf_len) { return lzham::lzham_lib_z_adler32(adler, ptr, buf_len); } diff --git a/r5dev/thirdparty/lzham/lzhamcomp/lzham_comp.h b/r5dev/thirdparty/lzham/lzhamcomp/lzham_comp.h index 68dd1e72..60eb37b3 100644 --- a/r5dev/thirdparty/lzham/lzhamcomp/lzham_comp.h +++ b/r5dev/thirdparty/lzham/lzhamcomp/lzham_comp.h @@ -9,7 +9,7 @@ namespace lzham lzham_compress_state_ptr LZHAM_CDECL lzham_lib_compress_reinit(lzham_compress_state_ptr p); - lzham_compress_checksums LZHAM_CDECL lzham_lib_compress_deinit(lzham_compress_state_ptr p); + lzham_uint32 LZHAM_CDECL lzham_lib_compress_deinit(lzham_compress_state_ptr p); lzham_compress_status_t LZHAM_CDECL lzham_lib_compress( lzham_compress_state_ptr p, @@ -23,7 +23,7 @@ namespace lzham lzham_uint8 *pOut_buf, size_t *pOut_buf_size, lzham_flush_t flush_type); - lzham_compress_status_t LZHAM_CDECL lzham_lib_compress_memory(const lzham_compress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32, lzham_uint32* pCrc32); + lzham_compress_status_t LZHAM_CDECL lzham_lib_compress_memory(const lzham_compress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32); int lzham_lib_z_deflateInit(lzham_z_streamp pStream, int level); int lzham_lib_z_deflateInit2(lzham_z_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy); diff --git a/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp.cpp b/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp.cpp index f8eab13b..b72cf9e1 100644 --- a/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp.cpp +++ b/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp.cpp @@ -150,18 +150,16 @@ namespace lzham return pState; } - lzham_compress_checksums LZHAM_CDECL lzham_lib_compress_deinit(lzham_compress_state_ptr p) + lzham_uint32 LZHAM_CDECL lzham_lib_compress_deinit(lzham_compress_state_ptr p) { - lzham_compress_checksums checksums{}; lzham_compress_state *pState = static_cast(p); if (!pState) - return checksums; + return 0; - checksums.adler32 = pState->m_compressor.get_src_adler32(); - checksums.crc32 = pState->m_compressor.get_src_crc32(); + uint32 adler32 = pState->m_compressor.get_src_adler32(); lzham_delete(pState); - return checksums; + return adler32; } lzham_compress_status_t LZHAM_CDECL lzham_lib_compress( @@ -296,7 +294,7 @@ namespace lzham return pState->m_status; } - lzham_compress_status_t LZHAM_CDECL lzham_lib_compress_memory(const lzham_compress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32, lzham_uint32 *pCrc32) + lzham_compress_status_t LZHAM_CDECL lzham_lib_compress_memory(const lzham_compress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32) { if ((!pParams) || (!pDst_len)) return LZHAM_COMP_STATUS_INVALID_PARAMETER; @@ -368,8 +366,6 @@ namespace lzham if (pAdler32) *pAdler32 = pCompressor->get_src_adler32(); - if (pCrc32) - *pCrc32 = pCompressor->get_src_crc32(); if (comp_data.size() == dst_buf_size) { @@ -523,7 +519,6 @@ namespace lzham pStream->total_out += (uint)out_bytes; pStream->adler32 = pState->m_compressor.get_src_adler32(); - pStream->crc32 = pState->m_compressor.get_src_crc32(); if (status >= LZHAM_COMP_STATUS_FIRST_FAILURE_CODE) { @@ -555,11 +550,7 @@ namespace lzham lzham_compress_state_ptr pComp = (lzham_compress_state_ptr)pStream->state; if (pComp) { - lzham_compress_checksums checksums = lzham_lib_compress_deinit(pComp); - - pStream->adler32 = checksums.adler32; - pStream->crc32 = checksums.crc32; - + pStream->adler32 = lzham_lib_compress_deinit(pComp); pStream->state = NULL; } diff --git a/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp_internal.cpp b/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp_internal.cpp index c2b4c61a..da90d372 100644 --- a/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp_internal.cpp +++ b/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp_internal.cpp @@ -69,7 +69,6 @@ namespace lzham lzcompressor::lzcompressor() : m_src_size(-1), m_src_adler32(0), - m_src_crc32(0), m_step(0), m_block_start_dict_ofs(0), m_block_index(0), @@ -298,7 +297,6 @@ namespace lzham m_codec.clear(); m_src_size = -1; m_src_adler32 = cInitAdler32; - m_src_crc32 = cInitCRC32; m_block_buf.clear(); m_comp_buf.clear(); @@ -341,7 +339,6 @@ namespace lzham m_stats.clear(); m_src_size = 0; m_src_adler32 = cInitAdler32; - m_src_crc32 = cInitCRC32; m_block_buf.try_resize(0); m_comp_buf.try_resize(0); @@ -572,9 +569,6 @@ namespace lzham if (!m_codec.encode_bits(m_src_adler32, 32)) return false; - if (!m_codec.encode_bits(m_src_crc32, 32)) - return false; - if (!m_codec.stop_encoding(true)) return false; @@ -1547,7 +1541,6 @@ namespace lzham m_start_of_block_state = m_state; m_src_adler32 = adler32(pBuf, buf_len, m_src_adler32); - m_src_crc32 = crc32(pBuf, buf_len, m_src_crc32); m_block_start_dict_ofs = m_accel.get_lookahead_pos() & (m_accel.get_max_dict_size() - 1); diff --git a/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp_internal.h b/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp_internal.h index b2991570..c8c60446 100644 --- a/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp_internal.h +++ b/r5dev/thirdparty/lzham/lzhamcomp/lzham_lzcomp_internal.h @@ -91,7 +91,6 @@ namespace lzham byte_vec& get_compressed_data() { return m_comp_buf; } uint32 get_src_adler32() const { return m_src_adler32; } - uint32 get_src_crc32() const { return m_src_crc32; } private: class state; @@ -346,7 +345,6 @@ namespace lzham int64 m_src_size; uint32 m_src_adler32; - uint32 m_src_crc32; search_accelerator m_accel; diff --git a/r5dev/thirdparty/lzham/lzhamdecomp/lzham_decomp.h b/r5dev/thirdparty/lzham/lzhamdecomp/lzham_decomp.h index 39f97a5c..08c7d7c9 100644 --- a/r5dev/thirdparty/lzham/lzhamdecomp/lzham_decomp.h +++ b/r5dev/thirdparty/lzham/lzhamdecomp/lzham_decomp.h @@ -11,7 +11,7 @@ namespace lzham lzham_decompress_state_ptr LZHAM_CDECL lzham_lib_decompress_reinit(lzham_decompress_state_ptr pState, const lzham_decompress_params *pParams); - lzham_decompress_checksums LZHAM_CDECL lzham_lib_decompress_deinit(lzham_decompress_state_ptr pState); + lzham_uint32 LZHAM_CDECL lzham_lib_decompress_deinit(lzham_decompress_state_ptr pState); lzham_decompress_status_t LZHAM_CDECL lzham_lib_decompress( lzham_decompress_state_ptr pState, @@ -21,7 +21,7 @@ namespace lzham lzham_decompress_status_t LZHAM_CDECL lzham_lib_decompress_memory(const lzham_decompress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, - const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32, lzham_uint32* pCrc32); + const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32); int LZHAM_CDECL lzham_lib_z_inflateInit2(lzham_z_streamp pStream, int window_bits); int LZHAM_CDECL lzham_lib_z_inflateInit(lzham_z_streamp pStream); @@ -31,7 +31,7 @@ namespace lzham int LZHAM_CDECL lzham_lib_z_uncompress(unsigned char *pDest, lzham_z_ulong *pDest_len, const unsigned char *pSource, lzham_z_ulong source_len); const char * LZHAM_CDECL lzham_lib_z_error(int err); - lzham_z_ulong LZHAM_CDECL lzham_lib_z_adler32(lzham_z_ulong adler, const lzham_uint8*ptr, size_t buf_len); + lzham_z_ulong LZHAM_CDECL lzham_lib_z_adler32(lzham_z_ulong adler, const lzham_uint8 *ptr, size_t buf_len); lzham_z_ulong LZHAM_CDECL lzham_lib_z_crc32(lzham_z_ulong crc, const lzham_uint8 *ptr, size_t buf_len); } // namespace lzham diff --git a/r5dev/thirdparty/lzham/lzhamdecomp/lzham_lzdecomp.cpp b/r5dev/thirdparty/lzham/lzhamdecomp/lzham_lzdecomp.cpp index bc07b4a7..c921aedc 100644 --- a/r5dev/thirdparty/lzham/lzhamdecomp/lzham_lzdecomp.cpp +++ b/r5dev/thirdparty/lzham/lzhamdecomp/lzham_lzdecomp.cpp @@ -43,7 +43,6 @@ namespace lzham uint8 *m_pRaw_decomp_buf; uint8 *m_pDecomp_buf; uint32 m_decomp_adler32; - uint32 m_decomp_crc32; const uint8 *m_pIn_buf; size_t *m_pIn_buf_size; @@ -105,7 +104,6 @@ namespace lzham uint m_seed_bytes_to_ignore_when_flushing; uint m_file_src_file_adler32; - uint m_file_src_file_crc32; uint m_rep_lit0; uint m_match_len; @@ -193,7 +191,6 @@ namespace lzham size_t bytes_to_copy = LZHAM_MIN((size_t)(m_flush_n - copy_ofs), cBytesToMemCpyPerIteration); \ LZHAM_MEMCPY(m_pOut_buf + copy_ofs, m_pFlush_src + copy_ofs, bytes_to_copy); \ m_decomp_adler32 = adler32(m_pFlush_src + copy_ofs, bytes_to_copy, m_decomp_adler32); \ - m_decomp_crc32 = crc32(m_pFlush_src + copy_ofs, bytes_to_copy, m_decomp_crc32); \ copy_ofs += bytes_to_copy; \ } \ } \ @@ -239,7 +236,6 @@ namespace lzham m_pOrig_out_buf = NULL; m_orig_out_buf_size = 0; m_decomp_adler32 = cInitAdler32; - m_decomp_crc32 = cInitCRC32; m_seed_bytes_to_ignore_when_flushing = 0; m_z_last_status = LZHAM_DECOMP_STATUS_NOT_FINISHED; @@ -1142,23 +1138,6 @@ namespace lzham { m_decomp_adler32 = m_file_src_file_adler32; } - if (m_params.m_decompress_flags & LZHAM_DECOMP_FLAG_COMPUTE_CRC32) - { - if (unbuffered) - { - m_decomp_crc32 = crc32(pDst, dst_ofs, cInitCRC32); - } - - //if (m_file_src_file_crc32 != m_decomp_crc32) - //{ - // printf("m_file_src_file_crc32 %zX\n", m_file_src_file_crc32); - // m_status = LZHAM_DECOMP_STATUS_FAILED_CRC32; - //} - } - else - { - m_decomp_crc32 = m_file_src_file_crc32; - } } LZHAM_SYMBOL_CODEC_DECODE_END(codec); @@ -1273,20 +1252,18 @@ namespace lzham return pState; } - lzham_decompress_checksums LZHAM_CDECL lzham_lib_decompress_deinit(lzham_decompress_state_ptr p) + lzham_uint32 LZHAM_CDECL lzham_lib_decompress_deinit(lzham_decompress_state_ptr p) { - lzham_decompress_checksums checksums{}; lzham_decompressor *pState = static_cast(p); if (!pState) - return checksums; + return 0; - checksums.adler32 = pState->m_decomp_adler32; - checksums.crc32 = pState->m_decomp_crc32; + uint32 adler32 = pState->m_decomp_adler32; lzham_free(pState->m_pRaw_decomp_buf); lzham_delete(pState); - return checksums; + return adler32; } lzham_decompress_status_t LZHAM_CDECL lzham_lib_decompress( @@ -1343,7 +1320,7 @@ namespace lzham return status; } - lzham_decompress_status_t LZHAM_CDECL lzham_lib_decompress_memory(const lzham_decompress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32, lzham_uint32 *pCrc32) + lzham_decompress_status_t LZHAM_CDECL lzham_lib_decompress_memory(const lzham_decompress_params *pParams, lzham_uint8* pDst_buf, size_t *pDst_len, const lzham_uint8* pSrc_buf, size_t src_len, lzham_uint32 *pAdler32) { if (!pParams) return LZHAM_DECOMP_STATUS_INVALID_PARAMETER; @@ -1356,13 +1333,10 @@ namespace lzham return LZHAM_DECOMP_STATUS_FAILED_INITIALIZING; lzham_decompress_status_t status = lzham_lib_decompress(pState, pSrc_buf, &src_len, pDst_buf, pDst_len, true); - lzham_decompress_checksums checksums = lzham_lib_decompress_deinit(pState); + lzham_uint32 adler32 = lzham_lib_decompress_deinit(pState); if (pAdler32) - *pAdler32 = checksums.adler32; - if (pCrc32) - *pCrc32 = checksums.crc32; - + *pAdler32 = adler32; return status; } @@ -1468,7 +1442,6 @@ namespace lzham pStream->avail_in -= (uint)in_bytes; pStream->total_in += (uint)in_bytes; pStream->adler32 = pDecomp->m_decomp_adler32; - pStream->crc32 = pDecomp->m_decomp_crc32; pStream->next_out += (uint)out_bytes; pStream->avail_out -= (uint)out_bytes; @@ -1510,10 +1483,7 @@ namespace lzham lzham_decompress_state_ptr pState = static_cast(pStream->state); if (pState) { - lzham_decompress_checksums checksums = lzham_lib_decompress_deinit(pState); - - pStream->adler32 = checksums.adler32; - pStream->crc32 = checksums.crc32; + pStream->adler32 = lzham_lib_decompress_deinit(pState); pStream->state = NULL; } diff --git a/r5dev/vpklib/packedstore.cpp b/r5dev/vpklib/packedstore.cpp index 9fec5c92..7da7a869 100644 --- a/r5dev/vpklib/packedstore.cpp +++ b/r5dev/vpklib/packedstore.cpp @@ -47,7 +47,7 @@ void CPackedStore::InitLzDecompParams(void) { /*| PARAMETERS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/ m_lzDecompParams.m_dict_size_log2 = VPK_DICT_SIZE; - m_lzDecompParams.m_decompress_flags = lzham_decompress_flags::LZHAM_DECOMP_FLAG_OUTPUT_UNBUFFERED | lzham_decompress_flags::LZHAM_DECOMP_FLAG_COMPUTE_CRC32; + m_lzDecompParams.m_decompress_flags = lzham_decompress_flags::LZHAM_DECOMP_FLAG_OUTPUT_UNBUFFERED; m_lzDecompParams.m_struct_size = sizeof(lzham_decompress_params); } @@ -317,40 +317,12 @@ void CPackedStore::BuildManifest(const vector& vBlock, const st FileSystem()->WriteFile(svPathOut.c_str(), "GAME", uBuf); } -//----------------------------------------------------------------------------- -// Purpose: validates extraction result with precomputed ADLER32 hash -// Input : &svAssetPath - -//----------------------------------------------------------------------------- -void CPackedStore::ValidateAdler32PostDecomp(const string& svAssetPath) -{ - FileHandle_t hAsset = FileSystem()->Open(svAssetPath.c_str(), "rb", "GAME"); - if (!hAsset) - { - Error(eDLL_T::FS, NO_ERROR, "%s - Unable to open '%s' (insufficient rights?)\n", __FUNCTION__, svAssetPath.c_str()); - return; - } - uint32_t nLen = FileSystem()->Size(hAsset); - uint8_t* pBuf = MemAllocSingleton()->Alloc(nLen); - - FileSystem()->Read(pBuf, nLen, hAsset); - FileSystem()->Close(hAsset); - - m_nAdler32 = adler32::update(NULL, pBuf, nLen); - MemAllocSingleton()->Free(pBuf); - - if (m_nAdler32 != m_nAdler32_Internal) - { - Warning(eDLL_T::FS, "Computed checksum '0x%lX' doesn't match expected checksum '0x%lX'. File may be corrupt!\n", m_nAdler32, m_nAdler32_Internal); - m_nAdler32 = NULL; - m_nAdler32_Internal = NULL; - } -} - //----------------------------------------------------------------------------- // Purpose: validates extraction result with precomputed CRC32 hash // Input : &svAssetPath - +// : nFileCRC - //----------------------------------------------------------------------------- -void CPackedStore::ValidateCRC32PostDecomp(const string& svAssetPath) +void CPackedStore::ValidateCRC32PostDecomp(const string& svAssetPath, const uint32_t nFileCRC) { FileHandle_t hAsset = FileSystem()->Open(svAssetPath.c_str(), "rb", "GAME"); if (!hAsset) @@ -364,14 +336,13 @@ void CPackedStore::ValidateCRC32PostDecomp(const string& svAssetPath) FileSystem()->Read(pBuf, nLen, hAsset); FileSystem()->Close(hAsset); - m_nCrc32 = crc32::update(NULL, pBuf, nLen); + uint32_t nCrc32 = crc32::update(NULL, pBuf, nLen); MemAllocSingleton()->Free(pBuf); - if (m_nCrc32 != m_nCrc32_Internal) + if (nCrc32 != nFileCRC) { - Warning(eDLL_T::FS, "Computed checksum '0x%lX' doesn't match expected checksum '0x%lX'. File may be corrupt!\n", m_nCrc32, m_nCrc32_Internal); - m_nCrc32 = NULL; - m_nCrc32_Internal = NULL; + Warning(eDLL_T::FS, "Computed checksum '0x%lX' doesn't match expected checksum '0x%lX'. File may be corrupt!\n", nCrc32, nFileCRC); + nCrc32 = NULL; } } @@ -463,7 +434,7 @@ void CPackedStore::PackWorkspace(const VPKPair_t& vPair, const string& svWorkspa if (vEntryValue.m_bUseCompression) { m_lzCompStatus = lzham_compress_memory(&m_lzCompParams, s_EntryBuf, &vDescriptor.m_nCompressedSize, s_EntryBuf, - vDescriptor.m_nUncompressedSize, &m_nAdler32_Internal, &m_nCrc32_Internal); + vDescriptor.m_nUncompressedSize, nullptr); if (m_lzCompStatus != lzham_compress_status_t::LZHAM_COMP_STATUS_SUCCESS) { @@ -562,7 +533,7 @@ void CPackedStore::UnpackWorkspace(const VPKDir_t& vDirectory, const string& svW break; // Corrupt or invalid chunk descriptor. m_lzDecompStatus = lzham_decompress_memory(&m_lzDecompParams, s_DecompBuf, - &nDstLen, s_EntryBuf, vChunk.m_nCompressedSize, &m_nAdler32_Internal, &m_nCrc32_Internal); + &nDstLen, s_EntryBuf, vChunk.m_nCompressedSize, nullptr); if (m_lzDecompStatus != lzham_decompress_status_t::LZHAM_DECOMP_STATUS_SUCCESS) { @@ -584,9 +555,7 @@ void CPackedStore::UnpackWorkspace(const VPKDir_t& vDirectory, const string& svW if (m_nChunkCount == vEntryBlock.m_vFragments.size()) // Only validate after last entry in block had been written. { m_nChunkCount = NULL; - m_nCrc32_Internal = vEntryBlock.m_nFileCRC; - - ValidateCRC32PostDecomp(svFilePath); + ValidateCRC32PostDecomp(svFilePath, vEntryBlock.m_nFileCRC); } } } diff --git a/r5dev/vpklib/packedstore.h b/r5dev/vpklib/packedstore.h index 79b233e1..620fbc5f 100644 --- a/r5dev/vpklib/packedstore.h +++ b/r5dev/vpklib/packedstore.h @@ -156,16 +156,10 @@ public: void PackWorkspace(const VPKPair_t& vPair, const string& svWorkspace, const string& svBuildPath, bool bManifestOnly); void UnpackWorkspace(const VPKDir_t& vDirectory, const string& svWorkspace = ""); - - void ValidateAdler32PostDecomp(const string& svAssetPath); - void ValidateCRC32PostDecomp(const string& svAssetPath); + void ValidateCRC32PostDecomp(const string& svAssetPath, const uint32_t nFileCRC); private: size_t m_nChunkCount; // The number of fragments for this asset. - lzham_uint32 m_nAdler32_Internal; // Internal operation Adler32 file checksum. - lzham_uint32 m_nAdler32; // Pre/post operation Adler32 file checksum. - lzham_uint32 m_nCrc32_Internal; // Internal operation Crc32 file checksum. - lzham_uint32 m_nCrc32; // Pre/post operation Crc32 file checksum. lzham_compress_params m_lzCompParams; // LZham decompression parameters. lzham_compress_status_t m_lzCompStatus; // LZham compression status. lzham_decompress_params m_lzDecompParams; // LZham decompression parameters. From e9e323f9d4493514c2d214e0cfc7998b775c2a88 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 4 Dec 2022 14:16:12 +0100 Subject: [PATCH 19/20] Add option to disable cache map * Add '-nosmap' command line parameter to disable signature caching. * Invalidate the cache map after initialization. * Add const qualifiers where possible. --- r5dev/core/init.cpp | 6 ++- r5dev/public/utility/sigcache.cpp | 65 ++++++++++++++++++++++++++----- r5dev/public/utility/sigcache.h | 14 +++++-- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index a7c10db9..a4bfab2e 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -470,9 +470,12 @@ void CheckCPU() // Respawn's engine and our SDK utilize POPCNT, SSE3 and SSSE3 ( void DetourInit() // Run the sigscan { - bool bLogAdr = (strstr(GetCommandLineA(), "-sig_toconsole") != nullptr); + LPSTR pCommandLine = GetCommandLineA(); + + bool bLogAdr = (strstr(pCommandLine, "-sig_toconsole") != nullptr); bool bInitDivider = false; + g_SigCache.SetDisabled((strstr(pCommandLine, "-nosmap") != nullptr)); g_SigCache.LoadCache(SIGDB_FILE); for (const IDetour* pDetour : vDetour) @@ -498,6 +501,7 @@ void DetourInit() // Run the sigscan #endif // DEDICATED g_SigCache.WriteCache(SIGDB_FILE); + g_SigCache.InvalidateMap(); } void DetourAddress() // Test the sigscan results diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index f7c5b838..235c4142 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -1,19 +1,59 @@ //===========================================================================// // // Purpose: Implementation of the CSigCache class. -// +// //===========================================================================// +// sigcache.cpp +// +// The system creates a static cache file on the disk, who's blob contains a +// map of string signatures and its precomputed relative virtual address. +// +// This file gets loaded and parsed during DLL init. If the file is absent or +// outdated/corrupt, the system will generate a new cache file if enabled. +// +// By caching the relative virtual addresses, we can drop a significant amount +// of time initializing the DLL by parsing the precomputed data instead of +// searching for each signature in the memory region of the target executable. +// +/////////////////////////////////////////////////////////////////////////////// #include "core/stdafx.h" #include "public/utility/binstream.h" #include "public/utility/sigcache.h" //----------------------------------------------------------------------------- -// Purpose: creates a pair of a pattern (key) and relative virtual address (value) -// Input : &svPattern - -// nRVA - +// Purpose: whether or not to disable the caching of signatures +// Input : bDisabled - (true = disabled) +//----------------------------------------------------------------------------- +void CSigCache::SetDisabled(const bool bDisabled) +{ + m_bDisabled = bDisabled; +} + +//----------------------------------------------------------------------------- +// Purpose: clears the signature cache memory +//----------------------------------------------------------------------------- +void CSigCache::InvalidateMap() +{ + if (m_bDisabled) + { + return; + } + + (*m_Cache.mutable_smap()).clear(); +} + +//----------------------------------------------------------------------------- +// Purpose: creates a map of a pattern and relative virtual address +// Input : &svPattern - (key) +// nRVA - (value) //----------------------------------------------------------------------------- void CSigCache::AddEntry(const string& svPattern, const uint64_t nRVA) { + if (m_bDisabled) + { + return; + } + Assert(!m_bInitialized); (*m_Cache.mutable_smap())[svPattern] = nRVA; } @@ -26,7 +66,7 @@ void CSigCache::AddEntry(const string& svPattern, const uint64_t nRVA) //----------------------------------------------------------------------------- bool CSigCache::FindEntry(const string& svPattern, uint64_t& nRVA) const { - if (m_bInitialized) + if (!m_bDisabled && m_bInitialized) { google::protobuf::Map sMap = m_Cache.smap(); auto p = sMap.find(svPattern); @@ -48,8 +88,13 @@ bool CSigCache::FindEntry(const string& svPattern, uint64_t& nRVA) const bool CSigCache::LoadCache(const string& svCacheFile) { Assert(!m_bInitialized); // Recursive load. - CIOStream reader(svCacheFile, CIOStream::Mode_t::READ); + if (m_bDisabled) + { + return false; + } + + CIOStream reader(svCacheFile, CIOStream::Mode_t::READ); if (!reader.IsReadable()) { return false; @@ -109,9 +154,9 @@ bool CSigCache::LoadCache(const string& svCacheFile) // Purpose: writes the cache map to the disk // Output : true on success, false otherwise //----------------------------------------------------------------------------- -bool CSigCache::WriteCache(const string& svCacheFile) +bool CSigCache::WriteCache(const string& svCacheFile) const { - if (m_bInitialized) + if (m_bDisabled || m_bInitialized) { // Only write when we don't have anything valid on the disk. return false; @@ -157,7 +202,7 @@ bool CSigCache::WriteCache(const string& svCacheFile) // *pDstBuf - // Output : true on success, false otherwise //----------------------------------------------------------------------------- -bool CSigCache::DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const +bool CSigCache::DecompressBlob(const size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const { lzham_decompress_params lzDecompParams{}; lzDecompParams.m_dict_size_log2 = SIGDB_DICT_SIZE; @@ -184,7 +229,7 @@ bool CSigCache::DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler // *pDstBuf - // Output : true on success, false otherwise //----------------------------------------------------------------------------- -bool CSigCache::CompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const +bool CSigCache::CompressBlob(const size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const { lzham_compress_params lzCompParams{}; lzCompParams.m_dict_size_log2 = SIGDB_DICT_SIZE; diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h index cd9adb1f..b42d4988 100644 --- a/r5dev/public/utility/sigcache.h +++ b/r5dev/public/utility/sigcache.h @@ -18,21 +18,27 @@ class CSigCache { public: - CSigCache() { m_bInitialized = false; }; + CSigCache() + : m_bInitialized(false) + , m_bDisabled(false) {}; ~CSigCache() {}; + void SetDisabled(const bool bDisabled); + void InvalidateMap(); + void AddEntry(const string& svPattern, const uint64_t nRVA); bool FindEntry(const string& svPattern, uint64_t& nRVA) const; bool LoadCache(const string& svCacheFile); - bool WriteCache(const string& svCacheFile); + bool WriteCache(const string& svCacheFile) const; private: - bool CompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; - bool DecompressBlob(size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; + bool CompressBlob(const size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; + bool DecompressBlob(const size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; SigMap_Pb m_Cache; bool m_bInitialized; + bool m_bDisabled; }; #pragma pack(push, 1) From 29b0bc389eafd38d9c04b2a8891092820c317e17 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 4 Dec 2022 14:17:14 +0100 Subject: [PATCH 20/20] Light CPackedStore cleanup --- r5dev/vpklib/packedstore.cpp | 14 ++++++++------ r5dev/vpklib/packedstore.h | 6 ++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/r5dev/vpklib/packedstore.cpp b/r5dev/vpklib/packedstore.cpp index 7da7a869..c814f97d 100644 --- a/r5dev/vpklib/packedstore.cpp +++ b/r5dev/vpklib/packedstore.cpp @@ -433,13 +433,13 @@ void CPackedStore::PackWorkspace(const VPKPair_t& vPair, const string& svWorkspa if (vEntryValue.m_bUseCompression) { - m_lzCompStatus = lzham_compress_memory(&m_lzCompParams, s_EntryBuf, &vDescriptor.m_nCompressedSize, s_EntryBuf, + lzham_compress_status_t lzCompStatus = lzham_compress_memory(&m_lzCompParams, s_EntryBuf, &vDescriptor.m_nCompressedSize, s_EntryBuf, vDescriptor.m_nUncompressedSize, nullptr); - if (m_lzCompStatus != lzham_compress_status_t::LZHAM_COMP_STATUS_SUCCESS) + if (lzCompStatus != lzham_compress_status_t::LZHAM_COMP_STATUS_SUCCESS) { Warning(eDLL_T::FS, "Status '%d' for chunk '%zu' within entry '%zu' in block '%hu' (chunk packed without compression)\n", - m_lzCompStatus, j, i, vEntryBlocks[i].m_iPackFileIndex); + lzCompStatus, j, i, vEntryBlocks[i].m_iPackFileIndex); vDescriptor.m_nCompressedSize = vDescriptor.m_nUncompressedSize; } @@ -532,13 +532,13 @@ void CPackedStore::UnpackWorkspace(const VPKDir_t& vDirectory, const string& svW if (vChunk.m_nCompressedSize > nDstLen) break; // Corrupt or invalid chunk descriptor. - m_lzDecompStatus = lzham_decompress_memory(&m_lzDecompParams, s_DecompBuf, + lzham_decompress_status_t lzDecompStatus = lzham_decompress_memory(&m_lzDecompParams, s_DecompBuf, &nDstLen, s_EntryBuf, vChunk.m_nCompressedSize, nullptr); - if (m_lzDecompStatus != lzham_decompress_status_t::LZHAM_DECOMP_STATUS_SUCCESS) + if (lzDecompStatus != lzham_decompress_status_t::LZHAM_DECOMP_STATUS_SUCCESS) { Error(eDLL_T::FS, NO_ERROR, "Status '%d' for chunk '%zu' within entry '%zu' in block '%hu' (chunk not decompressed)\n", - m_lzDecompStatus, m_nChunkCount, i, vEntryBlock.m_iPackFileIndex); + lzDecompStatus, m_nChunkCount, i, vEntryBlock.m_iPackFileIndex); } else // If successfully decompressed, write to file. { @@ -674,6 +674,8 @@ VPKChunkDescriptor_t::VPKChunkDescriptor_t(uint32_t nLoadFlags, uint16_t nTextur m_nCompressedSize = nCompressedSize; m_nUncompressedSize = nUncompressedSize; + + m_bIsCompressed = (m_nCompressedSize != m_nUncompressedSize); } //----------------------------------------------------------------------------- diff --git a/r5dev/vpklib/packedstore.h b/r5dev/vpklib/packedstore.h index 620fbc5f..662e421e 100644 --- a/r5dev/vpklib/packedstore.h +++ b/r5dev/vpklib/packedstore.h @@ -68,7 +68,6 @@ struct VPKChunkDescriptor_t uint64_t m_nUncompressedSize; // Uncompressed size of chunk. bool m_bIsCompressed = false; - VPKChunkDescriptor_t(){}; VPKChunkDescriptor_t(FileHandle_t hDirectoryFile); VPKChunkDescriptor_t(uint32_t nLoadFlags, uint16_t nTextureFlags, uint64_t nPackFileOffset, uint64_t nCompressedSize, uint64_t nUncompressedSize); }; @@ -115,6 +114,7 @@ struct VPKDir_t { m_vHeader.m_nHeaderMarker = VPK_HEADER_MARKER; m_vHeader.m_nMajorVersion = VPK_MAJOR_VERSION; m_vHeader.m_nMinorVersion = VPK_MINOR_VERSION; m_vHeader.m_nDirectorySize = NULL, m_vHeader.m_nSignatureSize = NULL; + m_nPackFileCount = NULL; }; VPKDir_t(const string& svDirectoryFile); VPKDir_t(const string& svDirectoryFile, bool bSanitizeName); @@ -160,10 +160,8 @@ public: private: size_t m_nChunkCount; // The number of fragments for this asset. - lzham_compress_params m_lzCompParams; // LZham decompression parameters. - lzham_compress_status_t m_lzCompStatus; // LZham compression status. + lzham_compress_params m_lzCompParams; // LZham compression parameters. lzham_decompress_params m_lzDecompParams; // LZham decompression parameters. - lzham_decompress_status_t m_lzDecompStatus; // LZham decompression status. std::unordered_map m_mChunkHashMap; }; ///////////////////////////////////////////////////////////////////////////////