Detours
Detours copied to clipboard
Fix detour_does_code_end_function for ARM64
It incorrectly returned FALSE for br <reg> instructions.
The bug caused Detours to override follow-up instructions after a function end, instead of failing, for example:
00007ffc`29e4b910 c9e6dab0 adrp x9, 00007FFBDFB24000
00007ffc`29e4b914 20011fd6 br x9
00007ffc`29e4b918 ; Unrelated instruction or data
The previous check ((Opcode & 0xfffffc1f) == 0xd65f0000) only matched ret <reg> instructions, despite the incorrect comment.
ARM64 instruction references: