Jul 28, 2010

Reading the book Chapter 1 WDK

Reason not choosing WDM:

..
Chapter 1 - Windows Driver Foundation (WDF) provides a driver model that makes it easier to learn and easier to implement robust Windows drivers. WDF largely supersedes WDM and is designed to enable developers to focus on the requirements of their hardware rather than the complexities of the operating system. ...

Chapter 2 - ...
Windows kernel. WDM provides great flexibility, but software developers have found implementing drivers with WDM to be a challenging task. However, it is important to have at least a basic understanding of WDM:...

  • User-mode programs are not trusted by the Windows core operating system. They run in a restricted environment that prevents them from compromising other applications or the core operating system.

  • Kernel-mode programsincluding driversare trusted components of the Windows core operating system. They operate with relatively few restrictions and some corresponding risks.

  • ...

    Device Objects and the Device Stack

    When a kernel subsystem sends an I/O request to a device, one or more drivers process the request. Each driver has an associated device object to represent the driver's participation in the processing of I/O requests for that device. The device object is a data structure that includes pointers to the driver's dispatch functions, which allow the I/O manager to communicate with the driver.

    The device objects are arranged in a device stack, with a separate stack for each device. Typically, "device stack" refers to the stack of device objects, plus the associated drivers. However, a device stack is associated with a single device, whereas a set of drivers can service multiple device stacks. The set of drivers is sometimes referred to as a "driver stack."

    A device stack is constructed from the following components:

    • Bus driver and physical device object The bottom of the stack is a physical device object (PDO), which is associated with a bus driver. Devices are usually attached to a standard hardware bus such as PCI or USB. A bus driver typically manages several pieces of hardware that are attached to the physical bus.

      For example, when the bus driver is installed, it enumerates the devices attached to the bus and requests resources for those devices. The PnP manager uses that information to assign resources to each device. Each device has its own PDO. The PnP manager identifies the drivers for each device and constructs an appropriate device stack on top of each PDO.

    • Function driver and functional device object The core of the device stack is the functional device object (FDO), which is associated with a function driver. The function driver translates the Windows abstraction of a device into the actual commands that are required to transfer data to and from a real device. It provides an "upper edge"—also called a device interface—for applications and services to interact with and usually controls how the device responds to changes in Plug and Play or power state. The function driver's "lower edge" handles communication with the device or other drivers such as a lower filter driver or the bus driver.

    • Filter drivers and filter device objects Device stacks can have multiple filter device objects (filter DOs), which can be placed above or below the FDO. Each filter DO is associated with a filter driver. Filter drivers are optional, but often present. They are the typical way by which third-party vendors can add value to a device stack. The usual purpose of a filter driver is to modify some of the I/O requests as they pass through the device stack, much like an audio filter modifies an audio stream.

      For example, filter drivers can be used to encrypt or decrypt read and write requests. Filter drivers can also be used for purposes that do not require modification of I/O requests, such as tracking requests and reporting the information back to a monitoring application.

    The three types of device objects differ in detail, but they work in much the same way to allow the system to process I/O requests. See "Kernel Objects and Data Structures" and "The Windows I/O Model" later in this chapter for a discussion about how a device stack handles I/O requests.





    No comments:

    Post a Comment