For Delphi, SecureEngine® macros appear as an external include file that will inserted with a parameter directive, {$I 
filename}. The included file will insert a special sequence of assembly code right after the {$I filename} directive. That
sequence of assembly code will be detected and replaced by SecureEngine® in the protection phase.


These include files are already defined in the "Themida include" directory and you can copy them to your application directory or
provide the full path to your Themida installation directory where they are located.



In the following we present a real example of how to use SecureEngine® macros in your Delphi application.


function TfmMain.GetCRC32(FileName: string): string;

begin
{$I VM_Start.inc}

BuildCRCTable;

CRC := $FFFFFFFF;
AssignFile(F, FileName);

FileMode := 0;

Reset(F);
{$I VM_End.inc}

GetMem(Buffer, SizeOf(B));

{$I CodeReplace_Start.inc} // the following block of code is protected with a "CodeReplace" macro

repeat

FillChar(b, SizeOf(b), 0);

BlockRead(F, b, SizeOf(b), e);

for i := 0 to (e-1) do

CRC := RecountCRC(b[i], CRC);

until (e < 255) or (IOresult <> 0);

{$I CodeReplace_End.inc} // end of "CodeReplace" macro



{$I VM_Start.inc}

FreeMem(Buffer, SizeOf(B));

CloseFile(F);

CRC := Not CRC;

Result := '$' + HextL(CRC);



{$I VM_End.inc}




end;