Function GetCR0: NativeUInt; assembler; register;
asm
// CR0 is not accessible in user mode (this function will cause exception).
// If anyone have any idea on how to read CR0 from normal program, let me know.
{$IFDEF x64}
DB $0F, $20, $C0 // MOV RAX, CR0 (problems in FPC before 3.0)
{$ELSE}
MOV EAX, CR0
{$ENDIF}
end;
As far as using this (since it uses a privileged register), have you considered setting up a Linux distribution, install Free Pascal, write a test rig, then sudo the program? Or in the alternative, compile it and a test rig on Windows, then run it using "run as Administrator"?
Skip the last one, running as Administrator doesn't work either. I just tried it. Oh well.