Returns ERROR_INVALID_BLOCK on large functions with __chkstk on it.
Author: 0Camus0Created Aug 24, 2022Updated Jul 20, 2026
Labelsbug
Latest version as for today(Version 4.0.1).
Trying to hook to a large function, looking at the disassembly:
9: void function()
10: {
00007FF6E296E010 B8 C8 6C 00 00 mov eax,6CC8h
00007FF6E296E015 E8 A3 3B FE FF call __chkstk (07FF6E2951BBDh)
00007FF6E296E01A 48 2B E0 sub rsp,rax I have the same project built at home and the __chkstk is not there, deours hook without issues. At another PC with the same compiler, it builds adding that instruction and detour fails to hook.
I assume the block is too small thanks to that call to __chkstk. I think it should be supported, but still, please let me know if this is an issue or if it's expected.
Building with VS2022 target x64, compiler options: /MD /Zi /O2 /Ob1 /DNDEBUG
Thanks.
Source: microsoft/Detours