Sample USBSCN9X kernel mode driver

[This is preliminary documentation and subject to change.]

SUMMARY

This sample shows how to write a Windows Image Acquisition (WIA) kernel mode USB class driver to support scan for composite USB devices on Windows 98, Windows 98 SE and Windows ME. This code should not be used for non-composite USB devices, nor should it be used in Windows 2000, Windows XP and beyond.

BUILDING THE SAMPLE

To build the sample, follow these steps:

1.      In the Start menu, select "Windows Server 2003 Free Build Environment" or "Windows Server 2003 Checked Build Environment" under "Windows DDK" to open a command window and set basic environment variables needed to build drivers.

2.      Change to the directory containing the sample driver source code, src\wdm\wia\usbscn9x.

3.      Execute the "build" command.

4.      After the build completes, a driver named Usbscn9x.sys will be located in an object subdirectory.

Note: Use a unique filename for the binary. For example, "MyCoScn.sys", where "MyCo" was the first four letters of your company's name"

 

Building for Windows 98 and Windows 98 SE

  1. Build and link with the Windows 98 DDK .lib files. You will need to modify TARGETLIBS parameter in SOURCES file to specify proper directory.
  2. Make sure pde->bEnabledForWakeup never be true. Comment out a line calling USGetDeviceCapability() in USPnp function so it wonft ask device to see if itfs remote-wakable.
  3. When building in Windows 98 DDK the following three functions cannot be used and will need to be commented out, as they are not declared in wdm.h and not defined in wdm.lib.

o       IoQueueWorkItem, IoAllocateWorkItem and IoFreeWorkItem.

 

 Building for Me

1.      Build from Windows Server 2003 DDK. This is because some identifiers in ioctl.c are only declared there, such as IOCTL_SET_TIMEOUT, USBSCAN_TIMEOUT and PUSBSCAN_TIMEOUT. 

 

CODE TOUR

File Manifest

Files            Description
------------     -----------------------------------------------------
debug.c          Utility function for debug.
debug.h          Header for debug utility.
ioctl.c          Functions to handle DeviceIoControl.
Makefile         Used for building the driver--do not modify.
ocrw.c           Functions to handle Open, Close, Read and Write.
power.c          Functions to handle power IRPs.
private.h        Header for driver functions.
Sources          Controls building of driver
usbd_api.h       Macro to create certain type of URB.
usbscn9x.c       Main implementation of usbscn9x.
usbscn9x.def     Linker command file.
usbscn9x.htm     This readme.
usbscn9x.rc      Main resource file.
 

RESOURCES

WIA information: http://www.microsoft.com/hwdev/wia

DDK information: http://www.microsoft.com/ddk/