From 27d00215acf62b03ca3a7102bff0629fbf40bd4c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 24 Nov 2022 12:10:11 +0100 Subject: [PATCH] Use memalloc pool pointer directly --- r5dev/engine/cmodel_bsp.cpp | 8 ++++---- r5dev/rtech/rtech_game.cpp | 2 +- r5dev/rtech/rtech_game.h | 6 +++--- r5dev/tier0/tslist.h | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/r5dev/engine/cmodel_bsp.cpp b/r5dev/engine/cmodel_bsp.cpp index 35ee999f..addde464 100644 --- a/r5dev/engine/cmodel_bsp.cpp +++ b/r5dev/engine/cmodel_bsp.cpp @@ -323,12 +323,12 @@ void Mod_ProcessPakQueue() s_bLevelResourceInitialized = true; Mod_PreloadLevelPaks(g_pHostState->m_levelName); } - *(_DWORD*)v15 = g_pakLoadApi->LoadAsync(v17, g_pMallocPool.GetPtr(), 4, 0); + *(_DWORD*)v15 = g_pakLoadApi->LoadAsync(v17, g_pMallocPool, 4, 0); if (strcmp(v17, "common_mp.rpak") == 0 || strcmp(v17, "common_sp.rpak") == 0 || strcmp(v17, "common_pve.rpak") == 0) - RPakHandle_t pakHandle = g_pakLoadApi->LoadAsync("common_sdk.rpak", g_pMallocPool.GetPtr(), 4, 0); + RPakHandle_t pakHandle = g_pakLoadApi->LoadAsync("common_sdk.rpak", g_pMallocPool, 4, 0); if (strcmp(v17, "ui_mp.rpak") == 0) - RPakHandle_t pakHandle = g_pakLoadApi->LoadAsync("ui_sdk.rpak", g_pMallocPool.GetPtr(), 4, 0); + RPakHandle_t pakHandle = g_pakLoadApi->LoadAsync("ui_sdk.rpak", g_pMallocPool, 4, 0); LABEL_37: v21 = *(_DWORD*)v15; @@ -410,7 +410,7 @@ void Mod_PreloadLevelPaks(const char* pszLevelName) continue; snprintf(szPathBuffer, sizeof(szPathBuffer), "%s.rpak", pSubKey->GetName()); - RPakHandle_t nPakId = g_pakLoadApi->LoadAsync(szPathBuffer, g_pMallocPool.GetPtr(), 4, 0); + RPakHandle_t nPakId = g_pakLoadApi->LoadAsync(szPathBuffer, g_pMallocPool, 4, 0); if (nPakId == INVALID_PAK_HANDLE) Error(eDLL_T::ENGINE, NO_ERROR, "%s: unable to load pak '%s' results '%d'\n", __FUNCTION__, szPathBuffer, nPakId); diff --git a/r5dev/rtech/rtech_game.cpp b/r5dev/rtech/rtech_game.cpp index e38be79a..c6454cff 100644 --- a/r5dev/rtech/rtech_game.cpp +++ b/r5dev/rtech/rtech_game.cpp @@ -20,7 +20,7 @@ vector g_vLoadedPakHandle; // bUnk - // Output : pak file handle on success, INVALID_PAK_HANDLE on failure //----------------------------------------------------------------------------- -RPakHandle_t CPakFile::LoadAsync(const char* szPakFileName, uintptr_t pMalloc, int nIdx, bool bUnk) +RPakHandle_t CPakFile::LoadAsync(const char* szPakFileName, void* pMalloc, int nIdx, bool bUnk) { RPakHandle_t pakHandle = INVALID_PAK_HANDLE; #ifdef DEDICATED diff --git a/r5dev/rtech/rtech_game.h b/r5dev/rtech/rtech_game.h index 4894ab76..2248cbad 100644 --- a/r5dev/rtech/rtech_game.h +++ b/r5dev/rtech/rtech_game.h @@ -26,7 +26,7 @@ enum class ePakStatus : int /* ==== RTECH_GAME ====================================================================================================================================================== */ inline CMemory p_CPakFile_LoadAsync; -inline auto CPakFile_LoadAsync = p_CPakFile_LoadAsync.RCast(); +inline auto CPakFile_LoadAsync = p_CPakFile_LoadAsync.RCast(); inline CMemory p_CPakFile_LoadPak; inline auto CPakFile_LoadPak = p_CPakFile_LoadPak.RCast(); @@ -39,7 +39,7 @@ inline CMemory p_CPakFile_LoadPak_OpenFileOffset; class CPakFile { public: - static RPakHandle_t LoadAsync(const char* szPakFileName, uintptr_t pMalloc = g_pMallocPool.GetPtr(), int nIdx = NULL, bool bUnk = false); + static RPakHandle_t LoadAsync(const char* szPakFileName, void* pMalloc = g_pMallocPool, int nIdx = NULL, bool bUnk = false); static void UnloadPak(RPakHandle_t handle); }; extern CPakFile* g_pakLoadApi; @@ -73,7 +73,7 @@ class VRTechGame : public IDetour 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"); - CPakFile_LoadAsync = p_CPakFile_LoadAsync.RCast(); /*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"); CPakFile_UnloadPak = p_CPakFile_UnloadPak.RCast(); /*48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 30 8B C1*/ diff --git a/r5dev/tier0/tslist.h b/r5dev/tier0/tslist.h index 972ddc5a..16a88628 100644 --- a/r5dev/tier0/tslist.h +++ b/r5dev/tier0/tslist.h @@ -1,7 +1,7 @@ #ifndef TSLIST_H #define TSLIST_H -inline CMemory g_pMallocPool; +inline void* g_pMallocPool; void TSList_Attach(); void TSList_Detach(); @@ -10,7 +10,7 @@ class VTSListBase : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pMallocPool : {:#18x} |\n", g_pMallocPool.GetPtr()); + spdlog::debug("| VAR: g_pMallocPool : {:#18x} |\n", reinterpret_cast(g_pMallocPool)); spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { } @@ -19,11 +19,11 @@ class VTSListBase : public IDetour #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); + "xxxx?xxxx?xxxx?xxxxxxxxxxxx????xxxxx????").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); + "xxxx?xxxx?xxxx?xxxxxxxxxxxxx????x????x????xxxxxx").Offset(0x130).FindPatternSelf("48 8D 15 ?? ?? ?? 01", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); #endif } virtual void GetCon(void) const { }