Skip to content

Commit

Permalink
Fix entity input functions crashing on invocation
Browse files Browse the repository at this point in the history
- In x64, there's a tendency for jmp calls to be used to go to another function instead of using call. There's probably some stack fuckery going on here since call pushes the return address on the stack. However, since we don't need to use the stack, we can substitute this with a simple jmp reg call instead, which also fixes the crash.
  • Loading branch information
KitRifty committed Feb 11, 2024
1 parent 1b3954b commit 81e3042
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions extension/idatamapcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,11 @@ void IEntityDataMapInputFuncDelegate::Alloc()
// (IEntityDataMapInputFuncDelegate* pDelegate, CBaseEntity* pEntity, inputdata_t &data)
// this::(inputdata_t &)
// RDI, RSI, RDX, RCX, R8, R9
0x48, 0x89, 0xF2, // mov RDX, RSI - 3rd arg
0x48, 0x89, 0xFE, // mov RSI, RDI
0x48, 0xBF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // mov rdi, thisAddr
0x48, 0xB9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // mov r9, callFuncAddr
0x41, 0xFF, 0xD1, // call r9
0xC3 // ret
0x48, 0x89, 0xF2, // mov RDX, RSI - 3rd arg
0x48, 0x89, 0xFE, // mov RSI, RDI
0x48, 0xBF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // movabs rdi, thisAddr
0x49, 0xB9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // movabs r9, callFuncAddr
0x41, 0xFF, 0xE1 // jmp r9
#endif
#else
#ifdef WIN32
Expand Down

0 comments on commit 81e3042

Please sign in to comment.