Jul 30, 2010

WDM Confirmed

Today task: Skim read some chapters:

Chapter of I/O request packet
Chapter of USB driver
Chapter of HID device

Downloaded WDK Driver Development Kit from windows.

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.





    Jul 26, 2010

    Borrow a book from the public library

    The book titled "Programming The Microsoft Windows Driver Model" was borrowed from the Tuen Mun Public library.

    Here is the detail information for the book:

    Title: Programming The Microsoft Windows Driver Model, Second Edition
    Author: Walter Oney
    Library Code: 510.7834 ONE
    ISBN:0-7356-1803-8

    Finished reading till page 39, the first chapter and a quarter of the second chapter.
    This book showed how to code a driver in windows with the WDM. WDM model is differently implemented in Windows XP and Windows 98/ME platform. Going to search if WDM behaves differently in Windows 7 or Vista also from google.

    WDM from Wikipedia:

    Indeed, apart from using WDM, WinUSB API, WDK are also available for our project. However, there is some limits using this API. Detail please refer to the Wikipedia or GMAIL account.

    Also an E-book is available from CUHK library:
    Name:


    Jul 14, 2010

    The Second Meeting

    1. Figured out how to get Foreground running process by Polling method. (Searched msdn library for a long time to find the right function. HWND is the basic element in windows OS and it specifies everything about a single window in the OS.) Here is the code:

    HWND window;
    char name[MAX_PATH];
    while(1)
    {
    window =
    GetForegroundWindow();
    GetWindowText(window,name,sizeof(name));
    strcat(name
    , "\n");
    printf("%s\n",name);
    Sleep(1000);
    }
    //end of test



    Some definition:

    GetForegroundWindow Function
    Retrieves a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.

    Syntax
    HWND
    WINAPI GetForegroundWindow(void);
    ParametersThis function has no parameters.

    Return Value
    HWND
    The return value is a handle to the foreground
    window. The foreground window can be NULL in certain circumstances, such as when a window is losing activation.

    Source: http://msdn.microsoft.com/en-us/library/ms633505(VS.85).aspx



    2. Better to find another efficient way other than Polling to detect the Foreground Process. Also have to get the process name from the handel.


    3. Agree to write the device driver first on a linux device, and next to the Android device using their SDK suite


    4. Start exploring WinUSB API, to find if it will be possible to write the USB device driver on Windows using this API


    5. Next Meeting date: August 5, 2010