## The IOCTL Sample

The IOCTL Sample accompanies Chapter 9 and illustrates how to perform I/O Control operations.

The sample includes two components:

- IOCTL.SYS (SYS subdirectory) is a WDM driver for a non-existent hardware device.
- TEST.EXE (TEST subdirectory) is a Win32 console program that tests IOCTL.SYS.

### Building IOCTL

To build IOCTL.SYS, follow the general instructions for building a WDM sample. The Microsoft Visual C++ project file is named IOCTL.DSP in the SYS subdirectory.

To build TEST.EXE, follow the general instructions for building user-mode programs. The Microsoft Visual C++ project file is named TEST.DSP in the TEST subdirectory.

### Testing IOCTL

Install IOCTL.SYS. Follow the general instructions for using FastInst in Windows XP or Windows 98/Me. The INF file is named SYS\IOCTL.INF.

Now open a command prompt and execute TEST.EXE from the TEST\DEBUG subdirectory. TEST will issue three I/O Control operations that IOCTL services, and it will print the results.

### What to look for

The file control.cpp contains the dispatch routine for IRP_MJ_DEVICE_CONTROL and illustrates the basics of handling simple control operations.