Skip to content

Support hooking ARM64EC target functions - #388

Open
RatinCN wants to merge 1 commit into
microsoft:mainfrom
RatinCN:fix/arm64ec_support
Open

Support hooking ARM64EC target functions#388
RatinCN wants to merge 1 commit into
microsoft:mainfrom
RatinCN:fix/arm64ec_support

Conversation

@RatinCN

@RatinCN RatinCN commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Hi, Detours maintainers,

I'm the maintainer of KNSoft.SlimDetours, a leading fork of Detours with several important stability and compatibility improvements.

I first implemented ARM64EC compatibility in KNSoft.SlimDetours:

This PR ports that implementation back to Detours.

Summary

  • ARM64EC builds detect whether each hook target uses x64 or ARM64EC code and use the corresponding instruction, trampoline, and patch handling.
  • ARM64EC trampolines are allocated as EC code when required.
  • x64 builds return ERROR_NOT_SUPPORTED when the hook target uses ARM64EC code.

Validation

Tested before and after this change on the same native ARM64 machine running Windows on ARM64.

Test Before This PR
Official unit tests: x86 Pass: 17 test cases, 132 assertions Pass: 17 test cases, 132 assertions
Official unit tests: x64 Pass: 17 test cases, 132 assertions Pass: 17 test cases, 132 assertions
Official unit tests: ARM64EC Pass: 17 test cases, 132 assertions Pass: 17 test cases, 132 assertions
Official unit tests: ARM64 Pass: 17 test cases, 132 assertions Pass: 17 test cases, 132 assertions
samples/commem: x64 Crash (STATUS_ILLEGAL_INSTRUCTION) ERROR_NOT_SUPPORTED; no crash
samples/commem: ARM64EC Crash (STATUS_ILLEGAL_INSTRUCTION) Pass

The ARM64EC build was also verified with both x64 and ARM64EC hook targets, including attach, trampoline invocation, detour invocation, detach, and restoration of the original function.

The previous commem crash is also reported in #292.

Acknowledgements

Porting the ARM64EC compatibility work from KNSoft.SlimDetours to Detours was assisted by OpenAI Codex.

Related to #292.

@RatinCN
RatinCN marked this pull request as ready for review August 5, 2026 17:36
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