diff options
| author | 2025-12-26 23:27:51 +0000 | |
|---|---|---|
| committer | 2026-02-16 19:11:24 +0000 | |
| commit | e7943fb834cbcaec585ed68e67b5f17ceda504f7 (patch) | |
| tree | 44f326d03e1a2f5284c1a5c3517ad7e78d323d2e | |
| parent | af370088fc178996a46ee508aaa1a2c46318bbf2 (diff) | |
| download | sst-e7943fb834cbcaec585ed68e67b5f17ceda504f7.tar.gz sst-e7943fb834cbcaec585ed68e67b5f17ceda504f7.zip | |
Optimise midpoint hook assembly in l4d1democompat
| -rw-r--r-- | src/l4d1democompat.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/l4d1democompat.c b/src/l4d1democompat.c index b6a16b3..a6d418f 100644 --- a/src/l4d1democompat.c +++ b/src/l4d1democompat.c @@ -80,19 +80,21 @@ __asm ( ".globl " ASM_MANGLE_STR("_l4d1democompat_midpoint_hook") "\n" ASM_MANGLE_STR("_l4d1democompat_midpoint_hook") ":\n" // like in con_.S, we have to assemble stuff manually here, annoyingly. - // push eax - ".byte 0x50\n" - // mov eax, [_l4d1democompat_thisproto] - ".byte 0xA1\n" + // note: ebx is safe to clobber here because we're hooking immediately after + // a call, ebx is caller-save, and also ebx is explicitly pushed before the + // call which means we know the code we're hooking obeys the calling conv. + // see also find_midpoint() below. + // mov ebx, [_l4d1democompat_thisproto] + ".byte 0x8B\n" + ".byte 0x1D\n" ".long " ASM_MANGLE_STR("_l4d1democompat_thisproto") "\n" - // mov eax, [eax] + // mov ebx, [ebx] ".byte 0x8B\n" - ".byte 0x00\n" - // mov [_l4d1democompat_demover], eax - ".byte 0xA3\n" + ".byte 0x1B\n" + // mov [_l4d1democompat_demover], ebx + ".byte 0x89\n" + ".byte 0x1D\n" ".long " ASM_MANGLE_STR("_l4d1democompat_demover") "\n" - // pop eax - ".byte 0x58\n" // and then we leave trampoline space immediately after; we can jump // straight back from here to the rest of the function! ".globl " ASM_MANGLE_STR("_l4d1democompat_midpoint_trampoline") "\n" |
