Every virtual device must declare a name, a version number, an initialization order, and a device control procedure. Many virtual devices also declare a device identifier and API procedures. Virtual devices typically use the Declare_Virtual_Device macro to make these declarations as in the following example:
Declare_Virtual_Device VSAMPLED, 3,10, VSAMPLED_Control, \
VSAMPLED_Device_ID, VSAMPLED_Init_Order, \
VSAMPLED_V86_API_Handler, \
VSAMPLED_PM_API_Handler
This example declares the sample virtual device, VSAMPLED, version 3.1.
The device control procedure, which must be defined in the same source file,
is named VSAMPLED_Control. The symbols VSAMPLED_Device_ID and VSAMPLED_Init_Order specify the nonstandard virtual device identifier and
initialization order. This virtual device supports both V86-mode and protected-mode API procedures.
The VMM uses the information declared by this macro to initialize the virtual device, send system control messages to it, and allow MS-DOS applications, device drivers, and TSRs to call it. To grant access of this information to the VMM, the macro creates a device descriptor block (DDB) and stores it in the protected-mode data segment. (The DDB has the same format as a VxD_Desc_Block structure.) The macro creates a label for the DDB, which must be explicitly exported when the virtual device is linked. In the previous example, the name for the DBB is VSAMPLED_DBB.