Try these functions to get the address of UStrClr
and HandleFinally
:
function GetUStrClrAddress: Pointer;
asm
{$IFDEF CPUX64}
mov rcx, offset System.@UStrClr;
mov @Result, rcx;
{$ELSE}
mov @Result, offset System.@UStrClr;
{$ENDIF}
end;
function GetHandleFinallyAddress: Pointer;
asm
{$IFDEF CPUX64}
mov rcx, offset System.@HandleFinally;
mov @Result, rcx;
{$ELSE}
mov @Result, offset System.@HandleFinally;
{$ENDIF}
end;
Edit:
@ArnaudBouchez also suggests some further optimization. By directly putting the value into the function return register, the function is a little faster.
function GetUStrClrAddress: Pointer;
asm
{$ifdef CPU64}
mov rax,offset System.@UStrClr
{$else}
mov eax,offset System.@UStrClr
{$endif}
end;
Further reading of the assembler use in Delphi could be found here (and the use of the OFFSET
keyword), Assembly Expressions, Expression Classes
.