Almost exactly what I did. Except two facts:
1). in FreePascal VMT is not write-protected, so I didn't stumble to the problem until I ported my stuff to Delphi.
2). VirtualProtect I know, but what the hell does FlushInstructionCache(GetCurrentProcess, Code, SizeOf(Code^)); do? :shock: