Skip to content

SourceHook: hook manager generator for Linux x86_64 - #4

Open
cmer81 wants to merge 21 commits into
1.12-devfrom
feat/sourcehook-linux64
Open

cmer81 wants to merge 21 commits into
1.12-devfrom
feat/sourcehook-linux64

Conversation

@cmer81

@cmer81 cmer81 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

SourceHook: hook manager generator for Linux x86_64

Why

SourceMod's DHooks virtual hooks go through IHookManagerAutoGen::MakeHookMan, which on Linux x86_64 had no working generator. Without it DHooks can't run on 64-bit Linux servers (CS:S, TF2, DoD:S, HL2:DM). We need it to move our CS:S servers to x64.

What

  • Brings in rtldg's unfinished linux64hooks work (x64 linux sourcehook hookmangen alliedmodders/metamod-source#212, closed when upstream moved to KHook). Authorship is kept on all 18 commits. It's rebased on the current 1.12-dev (cb47755, the 1.12.0-git1228 build), and the only conflict was the xor → xorreg rename done upstream.
  • Our fixes on top:
    • removes a breakpoint() (int3) that was left at the start of every generated hook function and made the server stop with SIGTRAP on the first hooked call;
    • System V PushParameters reloaded every saved argument register, including the original this, but never loaded v_this. Delegates were therefore called with the hooked entity as this and crashed in ISHDelegate::Call. It now loads v_this into the this register, after the hidden return pointer when there is one, like the MSVC path.
    • the Vector (12-byte object) return path read xmm0/xmm1 from the v_retptr slot itself rather than from the value it points to, so callers got the pointer's bytes. It now dereferences it, like the generic path below.

Testing

  • Built linux x86_64 (css) with clang 18.
  • Tested on a CS:S x64 dedicated server (build 11003710, same binaries as our production x64 server) with bots and the DHooks branch from srcdslab/sourcemod:
    • virtual hooks with pointer/vector/object params: Teleport is caught and the teleport really happens;
    • OnTakeDamage pre-hook changes the damage through SetObjectVar and the change applies in game (20 → 10 HP);
    • the post-hook reads the return value;
    • Weapon_ShootPosition returns a Vector: the post-hook reads it and a pre-hook supercede reaches the caller;
    • GetPlayerMaxSpeed returns a float and is superseded;
    • AcceptInput passes variant_t by hidden reference.
  • No crash.

Companion PR: srcdslab/sourcemod#9 (DHooks Linux x86_64).

rtldg and others added 20 commits March 1, 2025 13:33
(cherry picked from commit 57929ca)
(cherry picked from commit ca591ee)
(cherry picked from commit 1b5aeba)
(cherry picked from commit 7a7137c)
(cherry picked from commit 34c664a)
…copy a ton of notes from System V docs

(cherry picked from commit 4a8b72b)
(cherry picked from commit d2b821e)
(cherry picked from commit b329d65)
(cherry picked from commit a884302)
(cherry picked from commit 2e7ae46)
(cherry picked from commit 13b3a8e)
(cherry picked from commit e20a0cf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

x86_64 CS:S x86_64 (64-bit srcds) support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants