DOSMGR_Add_Device

include dosmgr.inc

mov     ebx, VMAdd
mov     eax, OFFSET32 Device_Header
VxDcall DOSMGR_Add_Device
jc      error_handler
 

Adds a device to the device list. Uses Flags.

VMAdd
Handle of the virtual machine to add device to. If this parameter is zero, the device is added to all virtual machines.
Device_Header
Address of device header. This address must be in low memory (less than 100000h).

The address of this device for the chain is computed as:

(eax >> 4) & 0FFFFh : (eax & 000Fh)
 

This service links the device into the list but does not call it. If the device needs to be initialized, the caller must do it. This service adds the device to the end of the device chain. Therefore, this service cannot be used to replace an existing device. This service applies to character devices only. Block devices cannot be added with this service.

All devices put on the list this way are removed when Windows exits, including any devices added by virtual mode code.

The only supported method to add a device globally is to use the service _Allocate_Global_V86_Data_Area to allocate memory to contain the device header, initialize it, then call this routine to add it to the list. Global devices must be added during the Device_Init message. They cannot be added later. Local devices must be added at the VM_Init, VM_Critical_Init or Sys_VM_Init message or they will be global because they will be part of the initial VM state.

If this device hooks an interrupt and it is a local device, the vector must be set in the appropriate virtual machine during the VM_Init, VM_Critical_Init or Sys_VM_Init message.

A global device can also work this way, hooking the vector in every virtual machine. This allows the global device to be removed before Windows exits. The other method for a global device is to hook the vector during the Device_Init message which makes the hook part of the initial virtual machine state. Such a hook must be removed during the Sys_Critical_Exit message, or the vector will point to a nonexistent device after Windows exits.