Skip to content

Fix trap transaction cleanup and error propagation - #135

Open
tkhquang wants to merge 1 commit into
cursey:mainfrom
tkhquang:fix/trap-transaction-status
Open

tkhquang wants to merge 1 commit into
cursey:mainfrom
tkhquang:fix/trap-transaction-status

Conversation

@tkhquang

Copy link
Copy Markdown

Summary

  • make trap_threads return protection/query failures to inline-hook callers
  • scope Windows execution-trap records to one patch transaction
  • restore acquired protections and preserve hook state when enable or disable fails
  • add inaccessible-target coverage for enable and disable

Rationale

The Windows trap manager currently retains each target page for the process lifetime. If that virtual address is later recycled, an unrelated execute fault on the page is resumed without changing context and repeats indefinitely. The protection transaction also ignores query/protection failures, allowing enable or disable to report success when no patch was applied.

The patch keeps the same-page retry behavior only while a transaction has deliberately removed execute permission, then removes the trap record before returning on every path.

Validation

The native SafetyHook suites pass with MinGW and MSVC. The downstream DetourModKit regression suite also covers recycled-address trap cleanup and failed enable/disable state under MinGW Debug/Release, MSVC Debug/Release, and MSVC ASan.

@tkhquang
tkhquang force-pushed the fix/trap-transaction-status branch from 597432e to 45b1060 Compare July 16, 2026 00:04
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