Compartir a través de


Map Between Console Functions and Driver Functions (Compact 2013)

3/26/2014

Because calls that are made from the console application are routed through Device Manager, it is important to understand how application calls and driver functions correspond to one another.

The following table shows the driver functions that are invoked by Device Manager when core function calls are made from the console application.

Core function

Driver function

ActivateDeviceEx (or ActivateDevice)

DLLMain

xxx_Init

CreateFile

xxx_Open

WriteFile

xxx_Write

ReadFile

xxx_Read

SetFilePointer

xxx_Seek

DeviceIoControl

xxx_IOControl

NA

xxx_Cancel

CloseHandle

xxx_PreClose

xxx_Close

DeactivateDevice

xxx_PreDeinit

xxx_Deinit

NA

xxx_PowerDown

NA

xxx_PowerUp

Notice that calling ActivateDeviceEx, CloseHandle, or DeactivateDevice from the console application causes Device Manager to make more than one call to the driver. When debugging for the first time, you might set breakpoints on each of these driver functions in order to trace the code.

In the preceding table, the driver functions are listed in the order that they are called. For example, when you call ActivateDeviceEx, DLLMain is called followed by xxx_Init.

When ActivateDeviceEx is called, Device Manager also calls xxx_Open, xxx_IOControl, xxx_PreClose, and xxx_Close. This function sequence gives Device Manager an early opportunity to query the device driver for power capabilities. If the device is turned off prior to other calls being made to the driver, Device Manager can make appropriate power management calls to the driver.

Note

Microsoft recommends that you use the xxx_IOControl function instead of xxx_PowerUp and xxx_PowerDown to implement power management functionality, including suspend and resume functionality.

For more information about the relationship between driver functions and Device Manager, see Plan Your Device Driver.

See Also

Concepts

Test Your Driver by Using a Console Application