External Library

Parent Previous Next

External Library.

This group of library functions supports dynamic loading and freeing of additional DLL files (child-DLLs).


Using a child-DLL can be relevant in order to access extraordinary processing intensive functionality but is also applicable for a child-DLL containing GUI functionality etc.


Before loading an external DLL it can be advisable to import and validate the bytes of the DLL to verify the DLL has not been compromised or tampered with by a cracker.


Communicating With the DLL.

Loading and freeing a DLL is done using @DllLoad and @DllFree. Each loaded DLL is given a unique number when loaded (a handle) and is accessible from all running VMs.


The calling conventions stdcall and cdecl are applicable and can be applied individually for each DLL.


Communicating in bytecode with a loaded DLL is done based on only two simple functions:

The values are passed by reference (two-way passing).


Each of these two functions represents a simple argument signature to pass data back and forth - however these two interface functions are enough to transfer any kind of data, and it makes it very easy to implement the API of a child-DLL. The precise signature for each function is described on their respective pages.


Please note the first parameter specifies a function name which can identify an unlimited number of API functions in the child-DLL. Each of these API functions in the child-DLL just have to match one of the two argument signatures.


Memory Management.

It is always the VM DLL that owns and is responsible for the memory management of the passed values.


This is especially evident in case a blob must be returned from the child-DLL.

In that case it is necessary to:


It is imperative to understand, that the child-DLL is not allowed to change the length nor the memory address of the passed blob. The child-DLL is only allowed to update the value bytes. Otherwise unexpected results or errors may occur.