feat: complete ShadowHook wrapper (~90% API coverage)#3
Merged
HanSoBored merged 8 commits intomasterfrom Apr 9, 2026
Merged
Conversation
…k wrapper - Add memkit_errno(), memkit_strerror(), memkit_version(), memkit_init_errno() - Add memkit_hook_with_callback() and memkit_hook_by_symbol_callback() - Fix errno sign: ShadowHook returns positive error codes
- Add memkit_intercept() — intercept by function address - Add memkit_intercept_by_symbol() — intercept by library+symbol name - Add memkit_intercept_at_instr() — instruction-level interception - Add memkit_intercept_with_callback() — async intercept with completion callback - Add memkit_unintercept() - Add proxy/stack management: memkit_get_prev_func(), memkit_pop_stack(), memkit_allow_reentrant(), memkit_disallow_reentrant(), memkit_get_return_address() - Add MemKitCpuContext, MemKitVReg, MemKitInterceptor typedefs
- Add memkit_get_records() — retrieve operation records as CSV - Add memkit_dump_records_fd() — dump records to file descriptor - Add 11 MK_RECORD_ITEM_* constants
- Add memkit_get_mode() — current hook mode - Add memkit_set_debuggable()/get_debuggable() - Add memkit_set_recordable()/get_recordable() - Add memkit_set_disable()/get_disable() - Add MK_IS_SHARED_MODE, MK_IS_UNIQUE_MODE, MK_IS_MULTI_MODE macros
- Add memkit_hook_v2() — hook by symbol name with mode/record flags - Add memkit_hook_by_symbol_v2() — alias for V2 API - Add MK_HOOK_DEFAULT, MK_HOOK_WITH_SHARED_MODE, MK_HOOK_WITH_UNIQUE_MODE, MK_HOOK_WITH_MULTI_MODE, MK_HOOK_RECORD flags
- Add memkit_register_dl_init_callback()/unregister - Add memkit_register_dl_fini_callback()/unregister - Add MemKitDlInfo, MemKitDlInitCallback, MemKitDlFiniCallback typedefs
…d config Header (memkit.h): - Add 46 MK_ERRNO_* error constants - Add MK_MODE_SHARED, MK_MODE_UNIQUE, MK_MODE_MULTI constants - Add MemKitHooked, MemKitIntercepted, MemKitInterceptor callback types - Add MemKitCpuContext, MemKitVReg, MemKitDlInfo typedefs - Add 6 proxy/stack management macros (MEMKIT_CALL_PREV, MEMKIT_POP_STACK, etc.) - Declare 27 new wrapper functions across all API groups - Add MK_INTERCEPT_* and MK_RECORD_ITEM_* flag constants Build system: - Add intercept.c, records.c, runtime_config.c, hooking_flags.c, dl_callbacks.c to CMakeLists.txt and Makefile
- Expand Hooking Functions section with all new API groups (V2, Intercept, Records, Runtime Config, DL Callbacks, Proxy/Stack) - Add V2 Hook API, Intercept API, Records API, Runtime Configuration, and DL Callbacks sections with practical examples - Update Error Handling to use MK_ERRNO_* constants and memkit_strerror() - Expand ShadowHook Macros with MEMKIT_CALL_PREV, MEMKIT_POP_STACK, etc. - Add new source files to Project Structure (intercept.c, records.c, runtime_config.c, hooking_flags.c, dl_callbacks.c) - Expand ShadowHook Modes table with V2 flags, intercept flags, runtime config, and DL callbacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete the ShadowHook wrapper from ~9% → ~90% API coverage, adding 32 new exported functions across 7 API groups.
What's New
Intercept API (5 functions + proxy management)
memkit_intercept()— intercept by function addressmemkit_intercept_by_symbol()— intercept by library+symbol namememkit_intercept_at_instr()— instruction-level interception with CPU contextmemkit_intercept_with_callback()— async interceptmemkit_unintercept()memkit_get_prev_func(),memkit_pop_stack(),memkit_allow_reentrant(),memkit_disallow_reentrant(),memkit_get_return_address()MEMKIT_CALL_PREV(),MEMKIT_POP_STACK(),MEMKIT_ALLOW_REENTRANT(),MEMKIT_DISALLOW_REENTRANT(),MEMKIT_RETURN_ADDRESS()Error Handling (4 functions + 46 constants)
memkit_errno(),memkit_strerror(),memkit_version(),memkit_init_errno()MK_ERRNO_*constantsRecords API (2 functions + 11 flags)
memkit_get_records(),memkit_dump_records_fd()MK_RECORD_ITEM_*constantsRuntime Config (7 functions + 3 macros)
memkit_get_mode(),memkit_set/get_debuggable(),memkit_set/get_recordable(),memkit_set/get_disable()MK_IS_SHARED_MODE,MK_IS_UNIQUE_MODE,MK_IS_MULTI_MODEV2 Hook API (2 functions + 5 flags)
memkit_hook_v2(),memkit_hook_by_symbol_v2()DL Callbacks (4 functions)
Callback Variants (2 functions)
memkit_hook_with_callback(),memkit_hook_by_symbol_callback()Build
✅ Clean build — 36 compilation units, 0 errors, 0 warnings