Skip to content

Implement IAT hooking examples and documentation updates#7

Merged
AlienDwarf merged 13 commits into
mainfrom
hook-chaining
Mar 13, 2026
Merged

Implement IAT hooking examples and documentation updates#7
AlienDwarf merged 13 commits into
mainfrom
hook-chaining

Conversation

@AlienDwarf
Copy link
Copy Markdown
Owner

New Example Programs:

  • IAT and Inline Hooking Examples:

    • Added iat_messagebox.rs and iat_sleep.rs to demonstrate Import Address Table (IAT) hooking, including detouring Windows API functions like MessageBoxA and Sleep. These examples show how to intercept and modify imported function calls at runtime. [1] [2]
    • Added inline_sleep.rs to demonstrate inline function hooking, modifying the behavior of the Sleep function directly.
  • Advanced Hooking Patterns:

    • Added managed_gateway_chain.rs to demonstrate chaining multiple hooks (managed gateways) on a function, showing how hooks can be layered and unhooked in sequence.
    • Added transaction_two_hooks.rs to illustrate attaching multiple hooks in a single transaction, and safely managing their lifetimes.

IAT Hook Implementation Refactoring:

  • Safer Memory Operations:

    • Replaced the use of set_thunk_function with write_thunk_function_slot, which writes directly to the IAT entry using pointer operations. This change is made for both x86 and x86_64 architectures, improving safety and clarity. [1] [2]
    • Updated the retrieval of the original function pointer to use the slot pointer directly, ensuring correct pointer semantics.
  • Minor Documentation Improvement:

    • Added a comment suggesting the use of Option<> for storing hooks in simple_hook.rs.

@AlienDwarf AlienDwarf merged commit 16ef870 into main Mar 13, 2026
2 checks passed
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