From 1376e1be8273ac72a4e42179d2bf5445341fc0dc Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 27 Dec 2022 23:10:51 +0100 Subject: [PATCH] Add temporary whitelist address for materialsystem crash case This is required as we still have a very hacky approach for running 'custom' BSP files. Even though we are pretty much ready to move over the proper approach, we haven't been able to update all files yet. This is kept in place but will have to be deprecated and removed among with the MaterialSystem hack before the next release. --- r5dev/materialsystem/cmaterialsystem.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/r5dev/materialsystem/cmaterialsystem.cpp b/r5dev/materialsystem/cmaterialsystem.cpp index d822951f..effdb399 100644 --- a/r5dev/materialsystem/cmaterialsystem.cpp +++ b/r5dev/materialsystem/cmaterialsystem.cpp @@ -5,9 +5,11 @@ //===========================================================================// #include "core/stdafx.h" #include "tier1/cvar.h" +#include "public/utility/crashhandler.h" #include "vpc/keyvalues.h" #include "rtech/rtech_utils.h" #include "engine/cmodel_bsp.h" +#include "bsplib/bsplib.h" #include "materialsystem/cmaterialglue.h" #include "materialsystem/cmaterialsystem.h" @@ -130,6 +132,16 @@ Vector2D CMaterialSystem::GetScreenSize(CMaterialSystem* pMatSys) /////////////////////////////////////////////////////////////////////////////// void CMaterialSystem_Attach() { + // TODO: This has to be removed!!! +#ifndef _DEBUG + vector find_IMI_ref = CMemory(IsMaterialInternal).FindAllCallReferences(reinterpret_cast(BuildPropStaticFrustumCullMap), 1000); + if (!find_IMI_ref.empty()) + { + void* imiRetAddr = find_IMI_ref.at(0).Offset(0x5).RCast(); + g_CrashHandler->AddToWhitelist(imiRetAddr); + } +#endif // !_DEBUG + #ifndef DEDICATED DetourAttach((LPVOID*)&v_StreamDB_Init, &StreamDB_Init); DetourAttach((LPVOID*)&v_DispatchDrawCall, &DispatchDrawCall);