IOCTL

SUMMARY

This sample demonstrates the usage of four different types of IOCTLs (METHOD_IN_DIRECT, METHOD_OUT_DIRECT, METHOD_NEITHER, and METHOD_BUFFERED) supported by Windows, and how the user input & output buffer specified in the DeviceControl function is handled by the I/O subsystem and the driver in each case.

The sample consists of a legacy device driver and a Win32 console mode test application. The test application opens a handle to the device exposed by the driver and and makes all four different DeviceIoControl calls one after another. To understand how the IRP fields are set the I/O manager, you should run the checked build versoin of the driver and see the debug output.

This driver will work on Windows 2000, Windows XP and Windows Server 2003 operating systems. The build instructions given here applies to Windows 2000/XP/Server 2003 build environments. This has sample hasn't been tested on Windows 9x systems so it may or may not work.

This sample driver is not a PnP driver. This is a minimal driver meant to demonstrate an OS feature. Neither it nor its sample programs are intended for use in a production environment. Rather, they are intended for educational purposes and as a skeleton driver.

BUILDING THE SAMPLE

Click the Free Build Environment or Checked Build Environment icon under Development Kits program group to set basic environment variables.

Change to the directory containing the sample source code, such as CD Src\General\ioctl.

Run build -ceZ, or use the macro BLD. This command invokes the Microsoft make routines to build the components. If the build succeeds, you will find the driver, sioctl.sys, and the test application, ioctlapp.exe, in the i386 subdirectory of the %TARGETPATH% directory specified in the Sources file. If it fails you can find errors and warnings in the buildxxx.err and buildxxx.err respectively, where xxx is eithr chk or fre depending on the build environment.

TESTING

To test this driver, copy the test app, ioctlapp.exe, and the driver to the same directory, and run the application. The application will automatically load the driver if it's not already loaded and interact with the driver. When you exit the app, the driver will be stopped, unloaded and removed.

RESOURCES

For information about driver and hardware development, see http://www.microsoft.com/whdc.

For the latest release of the Windows NT device driver kit, see http://www.microsoft.com/whdc/devtools/ddk/default.mspx.

CODE TOUR

File Manifest

File		Description

Ioctl.htm	Sample Tour documentation for this sample (this file).
Sources		Generic file that lists source files and all the build options.
Sioctl.c	Source file of the sample driver.
Sioctl.h	Header file for defining ioctls; included by driver and the test application.
Sioctl.ini	.Ini file for setting up the registry to load the driver.
Testapp.c	Source file of the test application.
Sioctl.rc	Resource file that specify information such as file type, version, etc.
Makefile	This file merely indirects to the real makefile that is shared by all the driver components of the Windows NT DDK.
 

Top of page

© 1998 Microsoft Corporation