Calling functions from external DLLs
The built-in scripting language of VMProtect can be used to call functions from external DLLs. It is possible to call both standard Win32 API functions from standard Windows DLLs and custom functions from custom libraries. Before calling a function from a DLL, its prototype should be described in the body of the script. There are two ways to describe it – their examples are shown below.
Example: it is possible to describe the following function:
function A(B: Integer): Integer;
in two different forms:
function A(B: Integer): Integer; external '<dll_function_name>@<dll_file_name>';
This form shows that the function from the DLL should be called with the default call type (‘stdcall’). All standard Win32 API functions use ‘stdcall’. The same call type is very often used by many functions from custom DLLs.
function A(B: Integer): Integer; external '<dll_function_name>@<dll_file_name> <call_type>';
This form shows that the library function should be called with a special type of call. Possible call types: ‘stdcall’ (by default), ‘cdecl’, ‘pascal’ and ‘register’.