Initialization

Dynamically loadable VxDs do not receive SYS_CRITICAL_INIT, DEVICE_INIT, or INIT_COMPLETE messages. Instead, their control procedure is sent a SYS_DYNAMIC_DEVICE_INIT message when the device is being initialized and a SYS_DYNAMIC_DEVICE_EXIT message when the VxD is being unloaded. (The control procedure has the option of rejecting either the load or the unload request.)

A VxD that processes all 5 of these messages can be both dynamically loadable and static.

When a dynamically loadable VxD receives the SYS_DYNAMIC_DEVICE_EXIT message it should release any resources and hooks it has acquired. No cleanup is performed by the services that unload the device. For example, if the VxD is using the Hook_V86_Int_Chain and Call_When_Idle VMM services, it should call the Unhook_V86_Int_Chain and Cancel_Call_When_Idle services when it receives SYS_DYNAMIC_DEVICE_EXIT.

If a VxD or its initialization module specifies zero for the Flags parameter of the VXDLDR_LoadDevice function it must handle its own initialization. In this case, it should use the VXDLDR_DevInitSucceeded or VXDLDR_DevInitFailed service to inform the system of the initialization's outcome. If the initialization succeeds, the initialization module should send the SYS_DYNAMIC_DEVICE_INIT message to the VxD. (If VXDLDR_INIT_DEVICE is specified for the Flags parameter, the system does this work for you.)

When creating a dynamically loadable VxD, the InitOrder parameter of the Declare_Virtual_Device macro specifies the position of the VxD in the VMM's internal list of loaded devices.