Add nullptr check for listimages

This commit is contained in:
Diavolo 2022-08-01 16:30:31 +02:00
parent 088b8ac045
commit 675a1145a8
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
4 changed files with 35 additions and 15 deletions

View File

@ -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
}
}

View File

@ -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<Game::ImageList*>(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<void(*)(Game::XAssetHeader, void*)>(0x51FCDD, R_AddImageToList_Hk);
// protocol version (workaround for hacks)
Utils::Hook::Set<int>(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<const char*>(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<BYTE>(0x5AF0D0, 0xC3); // GamerProfile_SaveProfile
Utils::Hook::Set<BYTE>(0x4E6870, 0xC3); // GamerProfile_UpdateSystemVarsFromProfile
Utils::Hook::Set<BYTE>(0x4C37F0, 0xC3); // GamerProfile_UpdateProfileAndSaveIfNeeded

View File

@ -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);
};
}

View File

@ -8787,6 +8787,12 @@ namespace Game
LOCMSG_NOERR = 0x1,
};
struct ImageList
{
unsigned int count;
GfxImage* image[8192];
};
#pragma endregion
#ifndef IDA