From 675a1145a8db870ac698b3899c455131bbf2cda1 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Mon, 1 Aug 2022 16:30:31 +0200 Subject: [PATCH] Add nullptr check for listimages --- src/Components/Modules/GSC/Script.cpp | 10 ++++----- src/Components/Modules/QuickPatch.cpp | 32 +++++++++++++++++++-------- src/Components/Modules/QuickPatch.hpp | 2 ++ src/Game/Structs.hpp | 6 +++++ 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/Components/Modules/GSC/Script.cpp b/src/Components/Modules/GSC/Script.cpp index 683e1ede..7c68140a 100644 --- a/src/Components/Modules/GSC/Script.cpp +++ b/src/Components/Modules/GSC/Script.cpp @@ -397,18 +397,16 @@ namespace Components { // execute our hook pushad - call Script::StoreScriptBaseProgramNum - popad // execute overwritten code caused by the jump hook - sub eax, ds:201A460h // gScrVarPub_programBuffer - add esp, 0Ch - mov ds : 1CFEEF8h, eax // gScrCompilePub_programLen + sub eax, ds:201A460h // gScrVarPub_programBuffer + add esp, 0Ch + mov ds:1CFEEF8h, eax // gScrCompilePub_programLen // jump back to the original code - push 426C3Bh + push 426C3Bh retn } } diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 14e4e909..f1757435 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -203,7 +203,7 @@ namespace Components } void QuickPatch::CL_KeyEvent_OnEscape() - { + { if (Game::Con_CancelAutoComplete()) return; @@ -212,11 +212,11 @@ namespace Components // Close console Game::Key_RemoveCatcher(0, ~Game::KEYCATCH_CONSOLE); - } + } __declspec(naked) void QuickPatch::CL_KeyEvent_ConsoleEscape_Stub() { - __asm + __asm { pushad call CL_KeyEvent_OnEscape @@ -228,6 +228,18 @@ namespace Components } } + void QuickPatch::R_AddImageToList_Hk(Game::XAssetHeader header, void* data) + { + auto* imageList = static_cast(data); + + assert(imageList->count < ARRAY_SIZE(imageList->image)); + + if (header.image->texture.basemap) + { + imageList->image[imageList->count++] = header.image; + } + } + Game::dvar_t* QuickPatch::Dvar_RegisterConMinicon(const char* dvarName, [[maybe_unused]] bool value, unsigned __int16 flags, const char* description) { #ifdef _DEBUG @@ -262,6 +274,8 @@ namespace Components Utils::Hook(0x4FA448, QuickPatch::Dvar_RegisterConMinicon, HOOK_CALL).install()->quick(); + Utils::Hook::Set(0x51FCDD, R_AddImageToList_Hk); + // protocol version (workaround for hacks) Utils::Hook::Set(0x4FB501, PROTOCOL); @@ -349,7 +363,7 @@ namespace Components // spawn upnp thread when UPNP_init returns Utils::Hook::Hook(0x47982B, []() { - std::thread([]() + std::thread([] { // check natpmpstate // state 4 is no more devices to query @@ -440,11 +454,11 @@ namespace Components Utils::Hook::Set(0x60BBD4, CLIENT_CONFIG); // Disable profile system -// Utils::Hook::Nop(0x60BEB1, 5); // GamerProfile_InitAllProfiles - Causes an error, when calling a harrier killstreak. -// Utils::Hook::Nop(0x60BEB8, 5); // GamerProfile_LogInProfile -// Utils::Hook::Nop(0x4059EA, 5); // GamerProfile_RegisterCommands - Utils::Hook::Nop(0x4059EF, 5); // GamerProfile_RegisterDvars - Utils::Hook::Nop(0x47DF9A, 5); // GamerProfile_UpdateSystemDvars +// Utils::Hook::Nop(0x60BEB1, 5); // GamerProfile_InitAllProfiles - Causes an error, when calling a harrier killstreak. +// Utils::Hook::Nop(0x60BEB8, 5); // GamerProfile_LogInProfile +// Utils::Hook::Nop(0x4059EA, 5); // GamerProfile_RegisterCommands + Utils::Hook::Nop(0x4059EF, 5); // GamerProfile_RegisterDvars + Utils::Hook::Nop(0x47DF9A, 5); // GamerProfile_UpdateSystemDvars Utils::Hook::Set(0x5AF0D0, 0xC3); // GamerProfile_SaveProfile Utils::Hook::Set(0x4E6870, 0xC3); // GamerProfile_UpdateSystemVarsFromProfile Utils::Hook::Set(0x4C37F0, 0xC3); // GamerProfile_UpdateProfileAndSaveIfNeeded diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index 52fa8c46..210c182e 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -28,6 +28,8 @@ namespace Components static void CL_KeyEvent_OnEscape(); static void CL_KeyEvent_ConsoleEscape_Stub(); + static void R_AddImageToList_Hk(Game::XAssetHeader header, void* data); + static Game::dvar_t* Dvar_RegisterConMinicon(const char* dvarName, bool value, unsigned __int16 flags, const char* description); }; } diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index af92e04d..971ecbd7 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -8787,6 +8787,12 @@ namespace Game LOCMSG_NOERR = 0x1, }; + struct ImageList + { + unsigned int count; + GfxImage* image[8192]; + }; + #pragma endregion #ifndef IDA