Home » Support » User Manual » Using scripts » Classes

Classes

The scripting language built into VMProtect is an object-oriented language and is similar to Object Pascal in many ways. The scripting language includes both standard classes providing the basic functionality and specialized classes providing access to the application protection features. Below you can see the hierarchy of all available classes:

TObject

This basic class is a parent for all classes in the language.

TObject = class
  constructor Create;
  procedure Free;
end;
constructor TObject.Create;

The Create constructor is used to create an instance of the TObject class or its children.

procedure TObject.Free;

The Free method is a safe method to free resources and destroy an object.

TPersistent

This class provides the method of copying the content of one object (source) into another (self) and the target object remains the same. This peculiarity does not allow the simple assignation of object variables, but requires a separate method.

TPersistent = class(TObject)
  procedure Assign(Source: TPersistent);
end;
procedure TPersistent.Assign(Source: TPersistent);

The Assign method allows the duplication of an object, which involves assigning values to an object that include all properties of another object.

TStrings

This class provides the set of methods and properties necessary for working with strings and string sets.

TStrings = class(TPersistent)
  function Add(const S: String): Integer;
  procedure Append(const S: String);
  procedure AddStrings(Strings: TStrings);
  procedure Clear;
  procedure Delete(Index: Integer);
  function IndexOf(const S: String): Integer;
  procedure Insert(Index: Integer; const S: String);
  procedure LoadFromFile(const FileName: String);
  procedure SaveToFile(const FileName: String);
  property Count: Integer; read;
  property Text: String; read write;
  property CommaText: String; read write;
  property Strings[Index: Integer]: String; read write;
  property Objects[Index: Integer]: TObject; read write;
end;
function TStrings.Add(const S: String): Integer;

Adds a string to the set and returns its index.

procedure TStrings.Append(const S: String);

Adds a string to the end of the string set.

procedure TStrings.AddStrings(Strings: TStrings);

Adds a new set to the current string set.

procedure TStrings.Clear;

Clears the data set and frees the memory allocated to it.

procedure TStrings.Delete(Index: Integer);

Destroys the set item with the index and frees the memory allocated to it.

function TStrings.IndexOf(const S: String): Integer;

Retuns the index of the string S. If there is no string S in the set, it returns -1.

procedure TStrings.Insert(Index: Integer; const S: String);

Inserts the string S into the set and assigns the Index index to it.

procedure TStrings.LoadFromFile(const FileName: String);

Loads a set of strings from a file.

procedure TStrings.SaveToFile(const FileName: String);

Saves the string set to a file.

property TStrings.Count: Integer; read;

Returns the number of strings in the set.

property TStrings.Text: String; read write;

Returns the string set as one long string with end-of-line delimiters between separate strings in the set.

property TStrings.CommaText: String; read write;

Used to set or get the entire string set as one string with quotation marks and commas.

property TStrings.Strings[Index: Integer]: String; read write;

Allows access to the string with the Index index.

property TStrings.Objects[Index: Integer]: TObject; read write;

Allows access to the object connected with the string with the Index index.

TStringList

TDuplicates = (dupIgnore, dupAccept, dupError);
TNotifyEvent = procedure(Sender: TObject);

TStringList = class(TStrings)
  function Find(const S: String; var Index: Integer): Boolean;
  procedure Sort;
  property Duplicates: TDuplicates; read write;
  property Sorted: Boolean; read write;
  property OnChange: TNotifyEvent; read write;
  property OnChanging: TNotifyEvent; read write;
end;
function TStringList.Find(const S: String; var Index: Integer): Boolean;

Searches the set for the string S and, if found, returns its index in the index parameter. The output value of the function indicates whether the search is successful.

procedure TStringList.Sort;

Sorts strings in the set according to the specified rules.

property TStringList.Duplicates: TDuplicates; read write;

This property allows control (if possible) of the set, to achieve two or more identical strings.

property TStringList.Sorted: Boolean; read write;

Defines if it is necessary to sort strings alphabetically.

property TStringList.OnChange: TNotifyEvent; read write;

Defines how to react to modifications in the string set. The event occurs after the last modification.

property TStringList.OnChanging: TNotifyEvent; read write;

Defines how to react to modifications in the string set. The event occurs before the next modification.

TStream

This basic class provides the execution of the basic stream operations irrelative to the actual media.

TStream = class(TObject)
  function Read(Buffer: AnsiString; Count: Longint): Longint;
  function Write(Buffer: AnsiString; Count: Longint): Longint;
  function Seek(Offset: Longint; Origin: Word): Longint;
  procedure ReadBuffer(Buffer: AnsiString; Count: Longint);
  procedure WriteBuffer(Buffer: AnsiString; Count: Longint);
  function CopyFrom(Source: TStream; Count: Longint): Longint;
  property Position: Longint; read write;
  property Size: Longint; read write;
end;
function TStream.Read(Buffer: AnsiString; Count: Longint): Longint;

Reads bytes from the Count stream to the Buffer buffer. Returns the number of copied bytes.

function TStream.Write(Buffer: AnsiString; Count: Longint): Longint;

Writes bytes from the Buffer buffer to the Count stream. Returns the number of copied bytes.

function TStream.Seek(Offset: Longint; Origin: Word): Longint;

This abstract class is overridden when dealing with children. Offsets the current position in the actual media for Offset bytes depending on the Origin condition:

  • soFromBeginning – the offset must be positive and counted from the beginning of the stream
  • soFromCurrent – the offset relative to the current position in the stream
  • soFromEnd – the offset must be negative and counted from the end of the stream
procedure TStream.ReadBuffer(Buffer: AnsiString; Count: Longint);

Reads bytes from the Count stream to the Buffer buffer. Returns the number of copied bytes.

procedure TStream.WriteBuffer(Buffer: AnsiString; Count: Longint);

Writes bytes from the Buffer buffer to the Count stream. Returns the number of copied bytes.

function TStream.CopyFrom(Source: TStream; Count: Longint): Longint;

Copies count bytes from the Source stream starting from the current position. Returns the number of copied bytes.

property TStream.Position: Longint; read write;

Determines the current position in the stream.

property TStream.Size: Longint; read write;

Determines the size of the stream in bytes.

THandleStream

The THandleStream class encapsulates the stream connected to the physical media via a handle.

THandleStream = class(TStream)
  constructor Create(AHandle: Integer);
  property Handle: Integer; read;
end;
constructor THandleStream.Create(AHandle: Integer);

The create constructor is used to create an instance of the class. The value of the handle is sent in the constructor parameter.

property THandleStream.Handle: Integer; read;

Determines the value of the handle.

TFileStream

This class is used to work with a file via streams.

TFileStream = class(THandleStream)
  constructor Create(const FileName: String; Mode: Word);
end;
constructor TFileStream.Create(const FileName: String; Mode: Word);

The FileName parameter defines the file name. The mode parameter defines the type of operations and access rights applied to this object:

  • fmCreate – create a new file. If the file exists, it is only opened for reading;
  • fmOpenRead – open for reading;
  • fmOpenWrite – open for writing;
  • fmOpenReadWrite – open for reading/writing;
  • fmShareCompat – multi-user access mode;
  • fmShareExclusive – exclusive mode. No application can read or modify the open file;
  • fmShareDenyWrite – forbid writing for other users and applications;
  • fmShareDenyRead – forbid reading for other users and applications;
  • fmShareDenyNone – forbid sharing the resource.

TIniFile

This class is used to work with ini files.

TIniFile = class(TObject)
  constructor Create(const FileName: String);
  function SectionExists(const Section: String): Boolean;
  function ReadString(const Section, Ident, Default: String): String;
  procedure WriteString(const Section, Ident, Value: String);
  function ReadInteger(const Section, Ident: String; Default: Longint): Longint;
  procedure WriteInteger(const Section, Ident: String; Value: Longint);
  function ReadBool(const Section, Ident: String; Default: Boolean): Boolean;
  procedure WriteBool(const Section, Ident: String; Value: Boolean);
  function ReadDate(const Section, Name: String; Default: TDateTime): TDateTime;
  function ReadDateTime(const Section, Name: String; Default: TDateTime): TDateTime;
  function ReadFloat(const Section, Name: String; Default: Double): Double;
  function ReadTime(const Section, Name: String; Default: TDateTime): TDateTime;
  procedure WriteDate(const Section, Name: String; Value: TDateTime);
  procedure WriteDateTime(const Section, Name: String; Value: TDateTime);
  procedure WriteFloat(const Section, Name: String; Value: Double);
  procedure WriteTime(const Section, Name: String; Value: TDateTime);
  procedure ReadSection(const Section: String; Strings: TStrings);
  procedure ReadSections(Strings: TStrings);
  procedure ReadSectionValues(const Section: String; Strings: TStrings);
  procedure EraseSection(const Section: String);
  procedure DeleteKey(const Section, Ident: String);
  procedure UpdateFile;
  function ValueExists(const Section, Ident: String): Boolean;
  property FileName: String read;
end;
constructor TIniFile.Create(const FileName: String);

Creates an instance of the TIniFile class associated with the FileName file.

function TIniFile.SectionExists(const Section: String): Boolean;

Checks whether there is a section named Section in the ini file and returns True if the section exists.

function TIniFile.ReadString(const Section, Ident, Default: String): String;

Reads the Ident parameter of the Section section from the ini file. If there is no such parameter, it returns Default.

procedure TIniFile.WriteString(const Section, Ident, Value: String);

Assigns the Values value to the Ident string parameter of the Section section in the ini file.

function TIniFile.ReadInteger(const Section, Ident: String; Default: Longint): Longint;

Reads the Ident integer parameter of the Section section from the ini file. If there is no such parameter, it returns Default.

procedure TIniFile.WriteInteger(const Section, Ident: String; Value: Longint);

Assigns the Values value to the Ident integer parameter of the Section section in the ini file.

function TIniFile.ReadBool(const Section, Ident: String; Default: Boolean): Boolean;

Reads the Ident logical parameter of the Section section from the ini file. If there is no such parameter, it returns Default.

procedure TIniFile.WriteBool(const Section, Ident: String; Value: Boolean);

Assigns the Values value to the Ident logical parameter of the Section section in the ini file.

function TIniFile.ReadDate(const Section, Name: String; Default: TDateTime): TDateTime;

Reads the date from the Name parameter located in the Section section of the ini file. If there is no such parameter, it returns Default.

function TIniFile.ReadDateTime(const Section, Name: String; Default: TDateTime): TDateTime;

Reads the date and time from the Name parameter located in the Section section of the ini file. If there is no such parameter, it returns Default.

function TIniFile.ReadFloat(const Section, Name: String; Default: Double): Double;

Reads the Name real-valued parameter of the Section section from the ini file. If there is no such parameter, it returns Default.

function TIniFile.ReadTime(const Section, Name: String; Default: TDateTime): TDateTime;

Reads the time from the Name parameter located in the Section section of the ini file. If there is no such parameter, it returns Default.

procedure TIniFile.WriteDate(const Section, Name: String; Value: TDateTime);

Writes the date to the Name parameter located in the Section section of the ini file.

procedure TIniFile.WriteDateTime(const Section, Name: String; Value: TDateTime);

Writes the date and time to the Name parameter located in the Section section of the ini file.

procedure TIniFile.WriteFloat(const Section, Name: String; Value: Double);

Assigns the Values value to the Name real-valued parameter of the Section section in the ini file.

procedure TIniFile.WriteTime(const Section, Name: String; Value: TDateTime);

Writes the time to the Name parameter located in the Section section of the ini file. If there is no such parameter, it returns Default.

procedure TIniFile.ReadSection(const Section: String; Strings: TStrings);

Reads the Section section from the ini file to the Strings variable.

procedure TIniFile.ReadSections(Strings: TStrings);

Reads all sections from the ini file to the Strings variable.

procedure TIniFile.ReadSectionValues(const Section: String; Strings: TStrings);

Reads the values of parameters in the Section section from the ini file to the Strings variable.

procedure TIniFile.EraseSection(const Section: String);

Deletes the Section section from the ini file.

procedure TIniFile.DeleteKey(const Section, Ident: String);

Deletes the Ident parameter of the Section section in the ini file.

procedure TIniFile.UpdateFile;

Saves the values of parameters from the ini file located in the clipboard to the disk. The function makes sense only in Windows 97 because Windows NT systems do not use cache in their work with ini files.

function TIniFile.ValueExists(const Section, Ident: String): Boolean;

Checks whether the Ident parameter of the Section section exists in the ini file and returns True if the parameter exists.

property TIniFile.FileName: String read;

Returns the name of the file associated with the instance of the TIniFile class.

TVMObject

The basic class that is a parent for all specialized classes in VMProtect.

TVMObject = class(TObject)
  constructor Create(AOwner: TVMObject);
  procedure Assign(SourceObject: TVMObject);
  property Owner: TVMObject; read;
end;
constructor TVMObject.Create(AOwner: TVMObject);

Creates an instance of the TVMObject class specifying AOwner that will be the owner of the created object.

procedure TVMObject.Assign(SourceObject: TVMObject);

The Assign method allows the duplication of an object, which involves assigning values to an object the include all properties of another object.

property TVMObject.Owner: TVMObject; read;

Provides access to the object owner.

TVMObjectList

This abstract class is used to work with a list of objects.

TVMObjectList = class(TVMObject)
  procedure Clear;
  procedure Delete(Index: Integer);
  property Count: Longint; read;
end;
procedure TVMObjectList.Clear;

Clears the object list and frees the memory allocated to it.

procedure TVMObjectList.Delete(Index: Integer);

Destroys the list item with the Index index and frees the memory allocated to it.

property TVMObjectList.Count: Longint; read;

Returns the number of objects in the list.

TPESection

This class is used to work with the PE section of the file.

TPESection = class(TVMObject)
  property Name: String; read write;
  property PhysicalOffset: Longint; read;
  property PhysicalSize: Longint; read;
  property RVA: Longint; read;
  property VirtualSize: Longint; read;
  property Flags: Longint; read;
  property IncludedInPacking: Boolean; read write;
end;
property TPESection.Name: String; read write;

Determines the name of the section.

property TPESection.PhysicalOffset: Longint; read;

Determines the physical offset of the section in the file.

property TPESection.PhysicalSize: Longint; read;

Determines the physical size of the section in the file.

property TPESection.RVA: Longint; read;

Determines the relative address of the section.

property TPESection.VirtualSize: Longint; read;

Determines the virtual size of the section.

property TPESection.Flags: Longint; read;

Determines the properties of the section using a set of bits:

  • IMAGE_SCN_CNT_CODE – the section contains executable code;
  • IMAGE_SCN_CNT_INITIALIZED_DATA – the section contains initialized data;
  • IMAGE_SCN_CNT_UNINITIALIZED_DATA – the section contains uninitialized data;
  • IMAGE_SCN_MEM_DISCARDABLE – the section may be unloaded from memory after the application is started;
  • IMAGE_SCN_MEM_NOT_CACHED – the section is not cached;
  • IMAGE_SCN_MEM_NOT_PAGED – the sections is not paged;
  • IMAGE_SCN_MEM_SHARED – the section is shared for various processes;
  • IMAGE_SCN_MEM_EXECUTE – the code in the section can be executed;
  • IMAGE_SCN_MEM_READ – the data in the section can be read;
  • IMAGE_SCN_MEM_WRITE – the data in the section can be modified.
property TPESection.IncludedInPacking: Boolean; read write;

Allows the specification of whether this section will be packed when the entire file is packed. Its value is True by default.

TPESections

This class is used to work with a list of PE sections of the file.

TPESections = class(TVMObjectList)
  function IndexOfName(const Name: String): Integer;
  property Items[Index: Integer]: TPESection; read; default;
end;
function TPESections.IndexOfName(const Name: String): Integer;

Returns the index of the section by its name. If there is no section named Name, it returns -1.

property TPESections.Items[Index: Integer]: TPESection; read; default;

Allows access to the section with the Index index.

TMapRecord

This class is used to work with an object in the program.

TObjectType = (otCode, otData, otExport, otMarker, otVBMarker,
  otAPIMarker, otImport, otString, otUnknown);

TMapRecord = class(TVMObject)
  property Address: Int64; read;
  property Name: String; read;
  property CodeType: TObjectType; read;
  property SegmentName: String; read;
end;
property TMapRecord.Address: Int64; read;

Determines the object address.

property TMapRecord.Name: String; read;

Determines the object name.

property TMapRecord.CodeType: TObjectType; read;

Determines the object type:

  • otCode – the object is a function/procedure;
  • otData – the object is data;
  • otExport – the object is an exported function;
  • otMarker, otVBMarker, otAPIMarker – the object is a marker;
  • otImport – the object is an imported function;
  • otString – the object is a string constant.
property TMapRecord.SegmentName: String; read;

Gets the name of segment, containg the address of the object.

TMapRecords

This class is used to work with a list of objects in the program. It is a list of objects from the list of names available in the MAP file, the list of imported/exported functions, the list of found markers.

TMapRecords = class(TVMObjectList)
  function IndexOfAddress(Address: Int64): Integer;
  function IndexOfName(const Name: String): Integer;
  property Items[Index: Integer]: TMapRecord; read; default;
end;
function TMapRecords.IndexOfAddress(Address: Int64): Integer;

Returns the index of the object with the Address address. If the object with the Address address is not found, it returns -1.

function TMapRecords.IndexOfName(const Name: String): Integer;

Returns the index of the object with the Name name. If the object with the Name name is not found, it returns -1.

property TMapRecords.Items[Index: Integer]: TMapRecord; read; default;

Allows access to the program object with the Index index.

TPEDirectory

This class is used to work with the PE directory of the file.

TPEDirectory = class(TVMObject)
  function IsEmpty: Boolean;
  procedure Clear;
  property Name: String; read;
  property RVA: Longint; read;
  property Size: Longint; read;
end;
function TPEDirectory.IsEmpty: Boolean

If RVA or Size equal 0, it returns True. Otherwise it returns False.

procedure TPEDirectory.Clear;

Cleans RVA and Size.

property TPEDirectory.Name: String; read;

Determines the directory name.

property TPEDirectory.RVA: Longint; read;

Determines the relative address of the directory.

property TPEDirectory.Size: Longint; read;

Determines the directory size.

TPEDirectories

This class is used to work with PE directories of the file.

TPEDirectoryType = (dtExportTable, dtImportTable, dtResourceTable,
  dtExceptionTable, dtSecurityTable, dtFixupTable, dtDebugTable,
  dtImageDescription, dtMachineSpecific, dtThreadLocalStorage,
  dtLoadConfig, dtBoundImport, dtIAT, dtDelayImportDescription,
  dtCOMRuntimeHeader);

TPEDirectories = class(TVMObject)
  property Items[Index: TPEDirectoryType]: TPEDirectory; read; default;
end;
property Items[Index: TPEDirectoryType]: TPEDirectory; read; default;

Allows access to the directory with the Index index.

TPEExportRecord

The class is used to work with the description of an exported function.

TPEExportRecord = class(TVMObject)
  property Address: Int64; read;
  property Ordinal: Word; read;
  property Name: String; read;
  property ForwardName: String; read;
end;
property TPEExportRecord.Address: Int64; read;

Determines the address of the exported function.

property TPEExportRecord.Ordinal: Word; read;

Determines the ordinal of the exported function.

property TPEExportRecord.Name: String; read;

Determines the name of the exported function.

property TPEExportRecord.ForwardName: String; read;

Determines the name of the exported function located in another library.

TPEExportRecords

This class is used to work with a list of exported functions.

TPEExportRecords = class(TVMObjectList)
  procedure Add(Address: Int64; Ordinal: Word; const Name: String);
  function IndexOfName(const Name: String): Integer;
  function IndexOfOrdinal(const Ordinal: Word): Integer;
  property DLLName: String; read write;
  property Items[Index: Integer]: TPEExportRecord; read; default;
end;
procedure TPEExportRecords.Add(Address: Int64; Ordinal: Word; const Name: String);

Adds a new exported function with the Address address, the Ordinal ordinal and the Name name.

function TPEExportRecords.IndexOfName(const Name: String): Integer;

Returns the index of the exported function by its name. If there is no exported function named Name, it returns -1.

function TPEExportRecords.IndexOfOrdinal(const Ordinal: Word): Integer;

Returns the index of the exported function by its ordinal. If there is no exported function with the Ordinal ordinal, it returns -1.

property TPEExportRecords.DLLName: String; read write;

Allows access to the DLL name.

property TPEExportRecords.Items[Index: Integer]: TPEExportRecord; read; default;

Allows access to the exported function with the Index index.

TPEResourceRecord

TResourceType = (rtUnknown, rtCursor, rtBitmap, rtIcon, rtMenu,
rtDialog, rtStringTable, rtFontDir, rtFont, rtAccelerators,
  rtRCData, rtMessageTable, rtGroupCursor, rtGroupIcon, rtVersion,
  rtDlgInclude, rtPlugPlay, rtVXD, rtAniCursor, rtAniIcon,
  rtManifest);

TPEResourceRecord = class(TVMObjectList)
  function IndexOfName(const Name: String): Integer;
  property Name: String; read;
  property ResType: TResourceType; read;
  property Items[Index: Integer]: TPEResourceRecord; read; default;
end;

TPEResourceRecords

TPEResourceRecords = class(TPEResourceRecord)
  function IndexOfResType(ResType: TResourceType): Integer;
end;

TPEFile

This class is used to work with a PE file.

TPEFile = class(TVMObject)
  function Read(var Buffer: AnsiString; Count: Longint): Longint;
  function Write(const Buffer: AnsiString; Count: Longint): Longint;
  property ImageBase: Int64; read;
  property MapRecords: TMapRecords; read;
  property Directories: TPEDirectories; read;
  property Sections: TPESections; read;
  property ExportRecords: TPEExportRecords; read;
  property ResourceRecords: TPEResourceRecords; read;
  property Address: Int64; read write;
  property Position: Longint; read write;
  property Size: Longint; read;
  property Handle: Integer; read;
  property EntryPoint: Int64; read write;
end;
function TPEFile.Read(var Buffer: AnsiString; Count: Longint): Longint;

Reads bytes from the Count stream to the Buffer buffer. Returns the number of copied bytes.

function TPEFile.Write(const Buffer: AnsiString; Count: Longint): Longint;

Writes bytes from the Buffer buffer to the Count stream. Returns the number of copied bytes.

property TPEFile.ImageBase: Int64; read;

Determines the initial address for loading the file.

property TPEFile.MapRecords: TMapRecords; read;

Allows access to the basic address that will be used to load the file.

property TPEFile.Directories: TPEDirectories; read;

Allows access to the file directories.

property TPEFile.Sections: TPESections; read;

Allows access to the file sections.

property TPEFile.ExportRecords: TPEExportRecords; read;

Allows access to the list of exported functions.

property TPEFile.ResourceRecords: TPEResourceRecords; read;

Allows access to the file resources.

property TPEFile.Address: Int64; read write;

Determines the current address in the file.

property TPEFile.Position: Longint; read write;

Determines the current position in the file.

property TPEFile.Size: Longint; read;

Determines the physical size of the file.

property TPEFile.Handle: Integer; read;

Determines the physical size of the file.

property TPEFile.EntryPoint: Int64; read write;

Determines the address of the entry point in the file.

TExtAddresses

This class is used to work with a list of addresses.

TExtAddresses = class(TVMObjectList)
  procedure Add(Address: Int64);
  function IndexOf(Address: Int64): Integer;
  property Items[Index: Integer]: Int64; read; default;
end;
procedure TExtAddresses.Add(Address: Int64);

Adds a new address to the list.

function TExtAddresses.IndexOf(Address: Int64): Integer;

Returns the index of the address by its value. If the address with the Address value is not found, it returns -1.

property TExtAddresses.Items[Index: Integer]: Int64; read; default;

Allows access to the address with the Index index.

TIntelRecord

This class is used to work with a CPU instruction.

TCommandType = (cmUnknown, cmPush, cmPop, cmMov, cmAdd, cmXor,
  cmTest, cmLea, cmRetF, cmRet, cmSsh, cmCall, cmJmp, cmFstsw,
  cmFsqrt, cmFchs, cmFstcw, cmFldcw, cmFild, cmFist, cmFistp,
  cmFld, cmFstp, cmFst, cmFadd, cmFsub, cmFsubr, cmFisub,
  cmFisubr, cmFdiv, cmFcomp, cmFmul, cmRepe, cmRepne, cmRep, cmDB,
  cmDD, cmDQ, cmMovs, cmCmps, cmScas, cmMovzx, cmMovsx, cmInc,
  cmDec, cmLes, cmLds, cmLfs, cmLgs, cmLss, cmXadd, cmBswap,
  cmJmpWithFlag, cmAnd, cmSub, cmStos, cmLods, cmNop, cmXchg,
  cmPushf, cmPopf, cmSahf, cmLahf, cmShl, cmShr, cmSal, cmSar,
  cmRcl, cmRcr, cmRol, cmRor, cmShld, cmShrd, cmLoope, cmLoopne,
  cmLoop, cmJCXZ, cmIn, cmIns, cmOut, cmOuts, cmWait, cmCbw,
  cmCwde, cmCdqe, cmCwd, cmCdq, cmCqo, cmClc, cmStc, cmCli,
  cmSti, cmCld, cmStd, cmNot, cmNeg, cmDiv, cmImul, cmIdiv,
  cmMul, cmOr, cmAdc, cmCmp, cmSbb, cmPusha, cmPopa, cmClflush,
  cmPause, cmBound, cmArpl, cmDaa, cmDas, cmAaa, cmAam, cmAad,
  cmAas, cmEnter, cmLeave, cmInt, cmInto, cmIret, cmSetCC,
  cmCmov, cmAddpd, cmAddps, cmAddsd, cmAddss, cmAndpd, cmAndps,
  cmAndnpd, cmAndnps, cmCmppd, cmCmpps, cmCmpsd, cmCmpss,
  cmComisd, cmComiss, cmCvtdq2ps, cmCvtpd2dq, cmCvtdq2pd,
  cmCvtpd2pi, cmCvtps2pi, cmCvtpd2ps, cmCvtps2pd, cmCvtpi2pd,
  cmCvtpi2ps, cmCvtps2dq, cmCvtsd2si, cmCvtss2si, cmCvtsd2ss,
  cmCvtss2sd, cmCvttpd2pi, cmCvttps2pi, cmCvttpd2dq, cmCvttps2dq,
  cmCvttsd2si, cmCvttss2si, cmDivpd, cmDivps, cmDivsd, cmDivss,
  cmMaxpd, cmMaxps, cmMaxsd, cmMaxss, cmMinpd, cmMinps, cmMinsd,
  cmMinss, cmMulpd, cmMulps, cmMulsd, cmMulss, cmOrpd, cmOrps,
  cmMovd, cmMovq, cmMovntq, cmMovapd, cmMovaps, cmMovdqa,
  cmMovdqu, cmMovdq2q, cmMovq2dq, cmMovhlps, cmMovhpd, cmMovhps,
  cmMovlhps, cmMovlpd, cmMovlps, cmMovmskpd, cmMovmskps, cmMovnti,
  cmMovntpd, cmMovntps, cmMovsd, cmMovss, cmMovupd, cmMovups,
  cmPmovmskb, cmPsadbw, cmPshufw, cmPshufd, cmPshuflw, cmPshufhw,
  cmPsubb, cmPsubw, cmPsubd, cmPsubq, cmPsubsb, cmPsubsw,
  cmPsubusb, cmPsubusw, cmPaddb, cmPaddw, cmPaddd, cmPaddq,
  cmPaddsb, cmPaddsw, cmPaddusb, cmPaddusw, cmPavgb, cmPavgw,
  cmPinstrw, cmPextrw, cmPmaxsw, cmPmaxub, cmPminsw, cmPminub,
  cmPmulhuw, cmPmulhw, cmPmullw, cmPmuludq, cmPsllw, cmPslld,
  cmPsllq, cmPslldq, cmPsraw, cmPsrad, cmPsrlw, cmPsrld, cmPsrlq,
  cmPsrldq, cmPunpcklbw, cmPunpcklwd, cmPunpckldq, cmPunpcklqdq,
  cmPunpckhqdq, cmPackusdw, cmPcmpgtb, cmPcmpgtw, cmPcmpgtd,
  cmPcmpeqb, cmPcmpeqw, cmPcmpeqd, cmEmms, cmPacksswb, cmPackuswb,
  cmPunpckhbw, cmPunpckhwd, cmPunpckhdq, cmPackssdw, cmPand,
  cmPandn, cmPor, cmPxor, cmPmaddwd, cmRcpps, cmRcpss, cmRqrtps,
  cmRqrtss, cmShufps, cmShufpd, cmSqrtpd, cmSqrtps, cmSqrtsd,
  cmSqrtss, cmSubpd, cmSubps, cmSubsd, cmSubss, cmUcomisd,
  cmUcomiss, cmUnpckhpd, cmUnpckhps, cmUnpcklpd, cmUnpcklps,
  cmXorpd, cmXorps, cmBt, cmBts, cmBtr, cmBtc, cmXlat, cmCpuid,
  cmRsm, cmBsf, cmBsr, cmCmpxchg, cmCmpxchg8b,
  cmHlt, cmCmc, cmLgdt, cmSgdt, cmLidt, cmSidt, cmSmsw, cmLmsw,
  cmInvlpg, cmLar, cmLsl, cmCtls, cmInvd, cmWbinvd, cmUd2,
  cmWrmsr, cmRdtsc, cmRdmsr, cmRdpmc, cmFcom, cmFdivr, cmFiadd,
  cmFimul, cmFicom, cmFicomp, cmFidiv, cmFidivr, cmFaddp, cmFmulp,
  cmFsubp, cmFsubrp, cmFdivp, cmFdivrp, cmFbld, cmFbstp, cmFfree,
  cmFrstor, cmFsave, cmFucom, cmFucomp, cmFldenv, cmFstenvm,
  cmFxch, cmFabs, cmFxam, cmFld1, cmFldl2t, cmFldl2e, cmFldpi,
  cmFldlg2, cmFldln2, cmFldz, cmFyl2x, cmFptan, cmFpatan,
  cmFxtract, cmFprem1, cmFdecstp, cmFincstp, cmFprem, cmFyl2xp1,
  cmFsincos, cmFrndint, cmFscale, cmFsin, cmFcos, cmFtst,
  cmFstenv, cmF2xm1, cmFnop, cmFinit, cmFclex, cmFcompp,
  cmSysenter, cmSysexit, cmSldt, cmStr, cmLldt, cmLtr, cmVerr,
  cmVerw, cmSfence, cmLfence, cmMfence, cmPrefetchnta, cmPrefetcht0,
  cmPrefetcht1, cmPrefetcht2, cmPrefetch, cmPrefetchw, cmFxrstor,
  cmFxsave, cmStmxcsr, cmFcmov, cmFucomi, cmFcomi, cmFucomip,
  cmFcomip, cmFucompp);

TOperandType = (otNone, otValue, otRegistr, otMemory, otSegmentRegistr,
  otControlRegistr, otDebugRegistr, otFloatValue, otHiPartRegistr, otBaseRegistr,
  otMMXRegistr, otXMMRegistr);

TOperandTypes = set of TOperandType;

TOperandSize = (osByte, osWord, osDWord, osQWord, osTByte, osOWord);

TOperand = record
  OperandSize: TOperandSize;
  OperandType: TOperandTypes;
  Registr: Byte;
  BaseRegistr: Byte;
  Scale: Byte;
  Value: Int64;
  ValueSize: TOperandSize;
  AddressSize: TOperandSize;
  FixupIndex: Integer;
end;

TIntelRecord = class(TVMObject)
  procedure ReadFromFile(File: TPEFile; var Address: Int64);
  property Address: Int64; read;
  property CommandText: String; read;
  property CommandType: TCommandType; read;
  property Dump[Index: Integer]: Byte; read;
  property DumpLength: Longint; read;
  property Operands[Index: Integer]: TOperand; read;
end;
procedure TIntelRecord.ReadFromFile(File: TPEFile; var Address: Int64);

Disassembles the instruction with the Address address.

property TIntelRecord.Address: Int64; read;

Determines the instruction address.

property TIntelRecord.CommandText: String; read;

Determines the instruction mnemonic.

property TIntelRecord.CommandType: TCommandType; read;

Determines the instruction type.

property TIntelRecord.Dump[Index: Integer]: Byte; read;

Allows access to the byte array determining the instruction representation.

property TIntelRecord.DumpLength: Longint; read;

Determines the size of the byte array.

property TIntelRecord.Operands[Index: Integer]: TOperand; read;

Gets an operand by the index.

TVMProcedure

This class is used to work with a code block (a list of CPU instructions).

TCompilationType = (ctVirtualization, ctMutation, ctUltra);

TCompilationOption = (coUseProjectOptions,coCheckCRC,coEncryptRegs,coEncryptValues,coUseKey);
TCompilationOptions = set of TCompilationOption;

TVMProcedure = class(TVMObjectList)
  function IndexOfAddress(Address: Int64): Integer;
  property Address: Int64; read;
  property BreakAddress: Int64; read write;
  property Name: String; read;
  property CodeType: TObjectType; read;
  property CompilationType: TCompilationType; read write;
  property CompilationOptions: TCompilationOptions; read write;
  property ExtAddresses: TExtAddresses; read;
  property IncludedInCompilation: Boolean; read write;
  property Records[Index: Integer]: TIntelRecord; read;
  property SELicense: Byte; read write;
  property SEVersion: Byte; read write;
  property InputSize: Longint; read;
  property OutputSize: Longint; read;
end;
function TVMProcedure.IndexOfAddress(Address: Int64): Integer;

Returns the index of the instruction with the Address address. If the instruction with the Address address is not found, it returns -1.

property TVMProcedure.Address: Int64; read;

Determines the initial address of the code block.

property TVMProcedure.BreakAddress: Int64; read write;

Determines the final address of the code block.

property TVMProcedure.Name: String; read;

Determines the name of the code block.

property TVMProcedure.CodeType: TObjectType; read;

Determines the type of the code block.

property TVMProcedure.CompilationType: TCompilationType; read write;

Determines the compilation type:

  • ctVirtualization – virtualization;
  • ctMutation – mutation;
  • ctUltra – ultra (mutation + virtualization).
property TVMProcedure.CompilationOptions: TCompilationOptions; read write;

Determines the compilation type:

  • coUseProjectOptions – use the project options;
  • coCheckCRC – control the integrity of VM objects;
  • coEncryptRegs – encrypt registers at VM output;
  • coEncryptValues – hide constants;
  • coUseKey – use the key (available only in SenseLock Edition).
property TVMProcedure.ExtAddresses: TExtAddresses; read;

Allows access to the list of external addresses.

property TVMProcedure.IncludedInCompilation: Boolean; read write;

Allows the specification whether the code block is included in the compilation.

property TVMProcedure.Records[Index: Integer]: TIntelRecord; read;

Allows access to the instruction with the Index index.

property TVMProcedure.SELicense: Byte; read write;

Allows determining the license number if the code is locked to the key (available only in SenseLock Edition).

property TVMProcedure.SEVersion: Byte; read write;

Allows determining the version number if the code is locked to the key (available only in SenseLock Edition).

property TVMProcedure.InputSize: Longint; read;

Returns the size of procedure before compilation (in bytes).

property TVMProcedure.OutputSize: Longint; read;

Returns the size of procedure after compilation (in bytes).

TWatermark

This class is used to work with a watermark.

TWatermark = class(TVMObject)
  property Enabled: Boolean; read write;
  property Name: String; read write;
  property Value: String; read write;
  property UseCount: Longint; read write;
end;
property TWatermark.Enabled: Boolean; read write;

Allows the specification of whether the watermark can be used in protected files. Its value is True by default.

property TWatermark.Name: String; read write;

Determines the watermark name.

property TWatermark.Value: String; read write;

Determines the watermark value.

property TWatermark.UseCount: Longint; read write;

Determines how many times the watermark has been used in protected files.

TWatermarks

This class is used to work with a list of watermarks.

TWatermarks = class(TVMObjectList)
  function Add(const Name, Value: String): TWatermark;
  function IndexOfName(const Name: string): Integer;
  function IndexOfValue(const Value: string): Integer;
  function CreateWatermarkValue: String;
  property Items[Index: Integer]: TWatermark; read; default;
end;
function TWatermarks.Add(const Name, Value: String): TWatermark;

Adds a new watermark named Name and with the Value value.

function TWatermarks.IndexOfName(const Name: string): Integer;

Returns the index of the watermark by its name. If there is no watermark named Name, it returns -1.

function TWatermarks.IndexOfValue(const Value: string): Integer;

Returns the index of the watermark by its value. If there is no watermark with the Value value, it returns -1.

function TWatermarks.CreateWatermarkValue: String;

Returns the unique value of the watermark.

property TWatermarks.Items[Index: Integer]: TWatermark; read; default;

Allows access to the watermark with the Index index.

TInternalDll

This class is used to work with bundled DLL file.

TInternalDll = class(TVMObject)
  property Name: String; read write;
  property FileName: String; read write;
  property LoadAtStart: Booleam; read write;
end;
property TInternalDll.Name: String; read write;

Defines a name of bundled DLL.

property TInternalDll.FileName: String; read write;

Defines a file name of bundled DLL.

property TInternalDll.LoadAtStart: Boolean; read write;

Defines whether the bundled DLL should be automatically loaded at application startup.

TInternalDlls

This class is used to work with the list of bundled DLLs.

TInternalDlls = class(TVMObjectList)
  function Add(const Name, FileName: String; LoadAtStart: Boolean): TInternalDll;
  property Items[Index: Integer]: TInternalDll; read; default;
end;
function TInternalDlls.Add(const Name, FileName: String; LoadAtStart: Boolean): TInternalDll;

Adds new bundled DLL with the name “Name”.

property TInternalDlls.Items[Index: Integer]: TInternalDll; read; default;

Gets a bundled DLL by the index.

TLicense

This class is used to work with license.

TLicense = class(TVMObject)
  property Date: TDate; read write;
  property CustomerName: String; read write;
  property CustomerEmail: String; read write;
  property OrderRef: String; read write;
  property Comments: String; read write;
  property SerialNumber: String; read;
  property Blocked: Boolean; read write;
end;
property TLicense.Date: TDate; read write;

Defines a date of the given license.

property TLicense.CustomerName: String; read write;

Defines a license owner.

property TLicense.CustomerEmail: String; read write;

Defines an email of the license owner.

property TLicense.OrderRef: String; read write;

Finds the order for the given license.

property TLicense.Comments: String; read write;

Defines a comments for the given license.

property TLicense.SerialNumber: String; read;

Defines a serial number.

property TLicense.Blocked: Boolean; read write;

Checks whether the license is blocked.

TLicenseManager

This class is used to work with the list of licenses.

TLicenseManager = class(TVMObjectList)
  function ImportLicense(const SerialNumber: String): TLicense;
  procedure Save;
  property Items[Index: Integer]: TLicense; read; default;
end;
function TLicenseManager.ImportLicense(const SerialNumber: String): TLicense;

Imports license information from the given serial number. Returns nil if the serial number is invalid.

procedure TLicenseManager.Save;

Saves licensing parameters and licenses to a file.

property TLicenseManager.Items[Index: Integer]: TLicense; read; default;

Gets a license by Index.

TVMProtector

This is the main class of the VMProtect kernel.

TMessageType = (mtDebuggerFound, mtVMToolsFound, mtFileCorrupted, mtSerialNumberRequired);

TVMProtector = class(TVMObjectList)
  function AddByAddress(Address: Int64; CompilationType: TCompilationType;
    IncludedInCompilation: Boolean): TVMProcedure;
  function AddByName(const Name: String; CompilationType: TCompilationType;
    IncludedInCompilation: Boolean): TVMProcedure;
  function IndexOfAddress(Address: Int64): Integer;
  function IndexOfName(const Name: String): Integer;
  property InputFile: TPEFile; read;
  property InputFileName: String; read;
  property OutputFile: TPEFile; read;
  property OutputFileName: String; read write;
  property Procedures[Index: Integer]: TVMProcedure; read;
  property WatermarkValue: String; read write;
  property VMExecutorCount: Longint; read write;
  property VMSectionName: String; read write;
  property SEMasterPassword: String; read write;
  property SEUserPIN: String; read write;
  property SEKeyID: Int64; read write;
  property SELicense: Byte; read write;
  property SEVersion: Byte; read write;
  property InternalDlls: TInternalDlls; read;
end;
function TVMProtector.AddByAddress(Address: Int64; CompilationType: TCompilationType;
  IncludedInCompilation: Boolean): TVMProcedure;

Adds a new code block with the Address address, the CompilationType compilation type and the IncludedInCompilation property.

function TVMProtector.AddByName(const Name: String; CompilationType: TCompilationType;
  IncludedInCompilation: Boolean): TVMProcedure;

Adds a new code block with the Name name, the CompilationType compilation type and the IncludedInCompilation property.

function TVMProtector.IndexOfAddress(Address: Int64): Integer;

Returns the index of the code block by its address. If there is no code block with the Address address, it returns -1.

function TVMProtector.IndexOfName(const Name: String): Integer;

Returns the index of the code block by its name. If there is no code block named Name, it returns -1.

property TVMProtector.InputFile: TPEFile; read;

Allows access to the protected file.

property TVMProtector.InputFileName: String; read;

Allows access to the name of the protected file.

property TVMProtector.OutputFile: TPEFile; read;

Allows access to the output file.

property TVMProtector.OutputFileName: String; read write;

Allows access to the name of the output file.

property TVMProtector.Procedures[Index: Integer]: TVMProcedure; read;

Allows access to the code block with the Index index.

property TVMProtector.WatermarkValue: String; read write;

Allows the specification of the watermark value.

property TVMProtector.VMExecutorCount: Longint; read write;

Allows the specification of the number of virtual machines.

property TVMProtector.VMSectionName: String; read write;

Allows the specification of the names of VM sections.

property TVMProtector.SEMasterPassword: String; read write;

Allows the specification of the master key password (available only in SenseLock Edition).

property TVMProtector.SEUserPIN: String; read write;

Allows the specification of the user PIN (available only in SenseLock Edition).

property TVMProtector.SEKeyID: Int64; read write;

Allows the specification of the key identifier (available only in SenseLock Edition).

property TVMProtector.SELicense: Byte; read write;

Allows the specification of the license number if common licensing options are used for protected blocks of the code (available only in SenseLock Edition).

property TVMProtector.SEVersion: Byte; read write;

Allows the specification of the version number if common licensing options are used for protected blocks of the code (available only in SenseLock Edition).

property TVMProtector.InternalDlls:TInternalDlls; read;

Gets a list of bundled DLL (Ultimate version only).

property TVMProtector.Messages[Index: TMessageType]: String; read write;

Allows to read and modify the messages, shown at:

property TVMProtector.LicenseManager:TLicenseManager; read;

Gets a license manager (available only in Ultimate).