Building a Virtual Device

You build a virtual device by doing the following:

1. Create the virtual device source files and assemble the sources using MASM.EXE, the 32-bit flat-model assembler.

2. Create a module definition file (.DEF) and link the object files using LINK.EXE, the 32-bit flat model linker. By convention, the resulting executable file should have the same filename as the virtual device, but with the filename extension .VXD.

3. Create a debugging symbol file for the executable file using MAPSYM.EXE.

A virtual device is not compatible with Windows dynamic-link libraries. Windows-based applications cannot load and use virtual devices directly. However, Win32-based applications can use the CreateFile and DeviceIoControl functions to load and interact with dynamically-loadable VxDs.

The module definition file for a virtual device has the following form:


LIBRARY  VSAMPLED

DESCRIPTION 'VSAMPLED Device  (Version 4.0)'

EXETYPE  DEV386

SEGMENTS
             _LTEXT PRELOAD NONDISCARDABLE
             _LDATA PRELOAD NONDISCARDABLE
             _ITEXT CLASS 'ICODE' DISCARDABLE
             _IDATA CLASS 'ICODE' DISCARDABLE
             _TEXT  CLASS 'PCODE' NONDISCARDABLE
             _DATA  CLASS 'PCODE' NONDISCARDABLE

EXPORTS
             VSAMPLED_DDB  @1

The LIBRARY statement must specify the name of the virtual device, as given in the device description block (DBB) and the EXPORTS statement must specify the name of the DBB. In all cases, the export ordinal for the DDB is 1.