Home » Support » User Manual » Using scripts » Events

Events

The built-in scripting language is an effective tool for automatically creating protected applications with VMProtect. Procedures and functions necessary to create the protected file in various steps are called through events processed by the VMProtect kernel. While creating scripts, custom event handlers can be set for 5 events that the protector kernel calls in the following order:

>procedure OnBeforeCompilation;

This event is triggered when the list of protected objects is being created. You can use the OnBeforeCompilation handler to add new procedure to the project and also edit or remove those already existing.

procedure OnBeforeSaveFile;

This event is triggered before all objects created as a result of compilation are saved to the output file. You can use the OnBeforeSaveFile event handler to edit both the file itself and some of its properties (for example, the list of resources, list of exported functions, section names, etc) that will be later automatically written to the output file.

procedure OnBeforePackFile;

This event is triggered before the protected file is packed. You can use OnBeforePackFile to make changes in the file that will be packed. This event is triggered only if the "Pack output file" option is used.

procedure OnAfterSaveFile;

This event is triggered after all objects created as a result of compilation are saved to the output file. This event handler can be used to add new data to the output file or change the data already saved to it.

procedure OnAfterCompilation;

This event is triggered after all objects included in the project are compiled. In this step the compiled file can be accessed and anything necessary done with it (for example, an electronic signature can be added (certificate)).

While writing handlers, custom procedures and functions can be created. Events names are displayed in bold in the script editor.