DataCache: rework datacache invalid data handling

This is a more reliable solution as pretty much all code patch in CMDLCache checks the ptr for NULL, but none of them do for 0xDEADFEEDDEADFEED (probably a debug only thing that somehow made it into this build). Patched out so the engine could deal with it properly. Anything interesting already gets logged from the SDK so we won't miss out on anything patching this out.
This commit is contained in:
Kawe Mazidjatari 2024-01-07 11:45:03 +01:00
parent c54777d370
commit 5b5effa964

View File

@ -44,17 +44,14 @@
// screen. This satisfies the required memory size to render all 120 player models (active players on server). // screen. This satisfies the required memory size to render all 120 player models (active players on server).
0xE6530: "mov r8d, 200000h" 0xE6530: "mov r8d, 200000h"
// This patch prevents a crash in 'CMDLCache::GetStudioHardwareForLODRange()' when attempting to dereference // This patch assigns the model and anim cache pointers to NULL instead of 0xDEADFEEDDEADFEED,
// an invalid studiocache handle (0xDEADFEEDDEADFEED). An inline assembly patch was easier to implement than // if the asset failed to load. The 0xDEADFEEDDEADFEED (DC_INVALID_HANDLE) assignment was most
// rebuilding the function. // likely done to catch errors in the asset loading system, since the pointer test won't fail
0x1E6EFD: "jmp 0x000000014129518A" // Jump to codecave. // while the pointer is invalid, this cause a hard crash. We however don't want this as this
// NOTE: stored in RCX as past this code block, this register was only written to before any reads!!! // would cause issues loading BSP's with missing assets (the SDK handles the errors properly
0x129458A: "mov rcx, 0xDEADFEEDDEADFEED" // Store 'DC_INVALID_HANDLE' immediate in register. // and also logs what was failed to load).
0x1294594: "cmp rax, rcx" // Compare RAX (studiocache pointer) to 'DC_INVALID_HANDLE'. 0x1E3CB6: "xor rax, rax" // NULL RAX instead of mov'ing '0xDEADFEEDDEADFEED' to cache ptr in 'Pak_UpdateModelAsset()'
0x1294597: "je 0x00000001401E7B0E" // If pointer equals, jump and skip all studiocache dereference operations. 0x1E3EE2: "xor rax, rax" // NULL RAX instead of mov'ing '0xDEADFEEDDEADFEED' to cache ptr in 'Pak_UpdateAnimRigAsset()'
0x129459D: "mov rax, qword ptr ds:[rax+0x8]" // Recovered instructions overwritten by long jump to codecave.
0x12945A1: "inc ebx" // Recovered instructions overwritten by long jump to codecave.
0x12945A3: "jmp 0x00000001401E7B03" // Jump back to original code; use studiocache pointer.
///////////////////////////// /////////////////////////////
///////////////////////////// /////////////////////////////