Skip to content

feat: complete ShadowHook wrapper (~90% API coverage)#3

Merged
HanSoBored merged 8 commits intomasterfrom
feat/shadowhook-wrapper-complete
Apr 9, 2026
Merged

feat: complete ShadowHook wrapper (~90% API coverage)#3
HanSoBored merged 8 commits intomasterfrom
feat/shadowhook-wrapper-complete

Conversation

@HanSoBored
Copy link
Copy Markdown
Owner

@HanSoBored HanSoBored commented Apr 9, 2026

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 address
  • memkit_intercept_by_symbol() — intercept by library+symbol name
  • memkit_intercept_at_instr() — instruction-level interception with CPU context
  • memkit_intercept_with_callback() — async intercept
  • memkit_unintercept()
  • Proxy/stack: memkit_get_prev_func(), memkit_pop_stack(), memkit_allow_reentrant(), memkit_disallow_reentrant(), memkit_get_return_address()
  • Macros: 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()
  • All 46 MK_ERRNO_* constants

Records API (2 functions + 11 flags)

  • memkit_get_records(), memkit_dump_records_fd()
  • All 11 MK_RECORD_ITEM_* constants

Runtime 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_MODE

V2 Hook API (2 functions + 5 flags)

  • memkit_hook_v2(), memkit_hook_by_symbol_v2()
  • Per-hook mode/record flags

DL Callbacks (4 functions)

  • Register/unregister init and fini callbacks

Callback Variants (2 functions)

  • memkit_hook_with_callback(), memkit_hook_by_symbol_callback()

Build

✅ Clean build — 36 compilation units, 0 errors, 0 warnings

…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
@HanSoBored HanSoBored merged commit 8cf80c2 into master Apr 9, 2026
1 check passed
@HanSoBored HanSoBored deleted the feat/shadowhook-wrapper-complete branch April 9, 2026 04:51
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.

1 participant