madCodeHook version 2.1d, delphi 6 sp1
I tried to recompile madCodeHook with optimization switched off.
When I run program I got AV in procedure cmpxchg8b.
The line mov ebp, [esp+$20] assumes that there is no stack frame in cmpxchg8b procedure but when optimization switched off Delphi adds stack frame for this procedure and code execution generates AV.
The solution is to switch optimization on for this procedure.
Sorry if it was reported before and already fixed.