Skip to content

Conversation

@Kenzzer
Copy link
Owner

@Kenzzer Kenzzer commented Oct 17, 2025

Currently when detouring a virtual function, KHook simply opens the vtable and read the function at the given entry index and uses that as its identifier for the function to detour. This is all well and good, until you consider vtables with duplicate entries (due to compiler optimizations). This means that under some cases the virtual hook callbacks are going to be erroneously invoked for unrelated virtual function calls.

In order to solve the above problem KHook now no longer considers the function address inside the vtable as its identifier, instead the vtable pointer along with the index are used as the unique identifier, furthermore the address present in the vtable is no longer detour'd now KHook directly injects the address of the hook, thereby ensuring that all virtual hooks are now unique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants