Consolidate the duplicated VtableHook into one shared copy

audio_hook.cpp carried its own VtableHook class identical to the shared
hook/src/vtable_hook.hpp -- two copies of the same delicate vtable-swap unhook
logic to keep in sync. Drop the audio copy and use the shared one (it's in
namespace coop::hook, so the in-file references resolve to it), leaving a short
note on why WASAPI methods are vtable-swapped rather than inline-hooked. Update
the shared header's comment to name both users (audio + DirectInput).

Last item from the review pass -- the Roadmap's Current-work section is now empty
(done work lives in git history); only Future work remains. Validated by
audio_hook_test (the vtable swap still hooks GetService/GetBuffer/ReleaseBuffer
end to end).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 02:28:05 +02:00
parent 5b2334f6e6
commit e4aafa08db
3 changed files with 8 additions and 73 deletions

View File

@@ -5,8 +5,8 @@
// mishandles -> the original runs with garbage args and faults. Swapping the vtable entry leaves
// the original code untouched, so it runs with a pristine stack regardless of prologue shape.
// Every instance of a COM coclass shares one vtable, so a single swap intercepts all of them.
// See the project's stdcall-x86 note. (audio_hook.cpp has its own equivalent; this is the shared
// copy for the input-side COM hooks.)
// See the project's stdcall-x86 note. Shared by the audio render-hook (audio_hook.cpp) and the
// input-side DirectInput hook (mkb_hook.cpp).
#pragma once
#include <windows.h>