Skip to content

Recognize REX-prefixed indirect JMP thunks#379

Open
RatinCN wants to merge 1 commit into
microsoft:mainfrom
RatinCN:fix/rex-prefixed-indirect-jmp-thunks
Open

Recognize REX-prefixed indirect JMP thunks#379
RatinCN wants to merge 1 commit into
microsoft:mainfrom
RatinCN:fix/rex-prefixed-indirect-jmp-thunks

Conversation

@RatinCN
Copy link
Copy Markdown
Contributor

@RatinCN RatinCN commented May 26, 2026

This PR fixes issue #293. I fixed this in my SlimDetours commit 57e0a24, and now create this PR to Detours.

Decode x64 import-style FF /4 indirect JMP thunks with an optional single-byte REX prefix before the opcode, so valid forms such as 48 FF 25 disp32 and other 40..4F FF 25 disp32 encodings are handled consistently.

Reuse the shared decoder in detour_skip_jmp, detour_find_jmp_bounds, and detour_does_code_end_function so thunk skipping, trampoline bounds, and function-end detection agree. Leave the x86 path unchanged.

Keep the HPAT OS-patch probe unchanged: it still matches the exact unprefixed FF 25 disp32 stub generated by the OS, instead of broadening that special-case path to REX-prefixed forms.

Decode x64 import-style FF /4 indirect JMP thunks with an optional single-byte REX prefix before the opcode, so valid forms such as 48 FF 25 disp32 and other 40..4F FF 25 disp32 encodings are handled consistently.

Reuse the shared decoder in detour_skip_jmp, detour_find_jmp_bounds, and detour_does_code_end_function so thunk skipping, trampoline bounds, and function-end detection agree. Leave the x86 path unchanged.

Keep the HPAT OS-patch probe unchanged: it still matches the exact unprefixed FF 25 disp32 stub generated by the OS, instead of broadening that special-case path to REX-prefixed forms.
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