Custom Engineering Spa USB Devices Driver



  1. How To Write Your First USB Client Driver (UMDF) - Windows ...
  2. See Full List On Custom.biz
  3. Custom Engineering Spa Usb Devices Driver Download
  4. Custom Engineering Spa Usb Devices Driver Windows 7
linuxreverse engineeringusb

This article explains the creation process of a Linux kernel device driver foran undocumented USB device. After having reverse-engineered the USBcommunication protocol, I present the architecture of the USB device driver. Inaddition to the kernel driver I introduce a simple user-space tool that can beused to control the device. Although I have to delve into the specifics of aparticular device, the process can be applied to other USB devices as well.

Introduction

Unlike the Arduino, they can appear to a PC as any sort of USB device. This means that you can create your own custom USB keyboard, joystick, MIDI device, etc and have the PC use standard drivers. The Teensy supports the Arduino IDE, or you can program in C and use LUFA (for USB support) directly. Here are some project links to help. This article explains the creation process of a Linux kernel device driver for an undocumented USB device. After having reverse-engineered the USB communication protocol, I present the architecture of the USB device driver. In addition to the kernel driver I introduce a simple user-space tool that can be used to control the device. A key driver for introducing the standard was to reduce e-waste by offering an interoperable charging standard that would allow manufacturers to offer one charger capable of powering a suite of portable devices. The key characteristics of USB PD 1.0 include a maximum 20 volts at 5 amps (100 W) (limited by international safety requirements); compatibility with existing USB 2.0/3.0 cables and connectors up to 7.5 watts (otherwise upgraded cables are required); and co-existence with USB BC 1.2.

Recently, I found a fancy device while searching eBay: the DreamCheeky USBmissile launcher. The manufacturer neitherprovides a Linux driver nor publishes the USB protocol specification. Only abinary Windows driver is available, turning the missile launcher into complete“black-box” for Linux users. What a challenge! Let’s get the damn gadgetworking under Linux.

To facilitate USB programming, the USB interface is accessible from user-spacewith libusb, a programming API concealinglow-level kernel interaction. The proper way to write a device driver for themissile launcher would hence be to leverage this API and ignore any kernelspecifics. Nevertheless, I wanted to get involved with kernel programming anddecided thus to write a kernel module despite the increased complexity andhigher effort.

The remainder of this article is structured as follows. After pointing to somerelated work, I give a quick USB overview. Thereafter, I present thereverse-engineering process to gather the unknown USB commands steering themissile launcher. To come up with a full-featured kernel device driver, Idescribe the kernel module architecture which incorporates the derived controlcommands. Finally, I demonstrate a simple tool in user-space that makes use ofthe driver.

Related Work

Apparently I have not been the only one who played with this gadget. However,none of the existing approaches I have encountered pursue the creation of aLinux device driver for the kernel. The LauncherLibrary provides a user-spacelibrary based on libusb. AHmissile is aGTK+ control tool; a ncurses application isavailable, too.Apple users get happy with the USB missile launcherNZ project. Moreover, the python implementationpymissile supports a missilelauncher of a different manufacturer. The author combined the missilelauncher with a webcam in order to to create an automated sentry guard reactingon motion. I will return to these funky ideas later.

USB Primer

The universal serial bus (USB) connects a host computer with numerousperipheral devices. It was designed to unify a wide range of slow and old buses(parallel, serial, and keyboard connections) into a single bus type. It istopologically not constructed as a bus, but rather as a tree of severalpoint-to-point links. The USB host controller periodically polls each device ifit has data to send. With this design, no device can send before it has not beenasked to do so, resulting in a plug-and-play-friendly architecture.

Linux supports two main types of drivers: host and device drivers. Let’s ignorethe host component and have a deeper look at the USB device. As shown on theright side, a USB device consists of one or more configurationswhich in turn have one ore more interfaces. These interfaces contain zero ormore endpoints which make up the basic form of USB communication. An endpointis always uni-directional, either from the host to the device (OUT endpoint)or from the device to the host (IN endpoint). There are four types ofendpoints and each transmits data in a different way:

  • Control
  • Interrupt
  • Bulk
  • Isochronous

Control endpoints are generally used to control the USB deviceasynchronously, i.e. sending commands to it or retrieving status informationabout it. Every device possesses a control “endpoint 0” which is used by the USBcore to initialize the device. Interrupt endpoints occur periodicallyand transfer small fixed-size data portions every time when the USB host asksthe device. They are commonly used by mice and keyboards as primary transportmethod. As bulk and isochronous endpoints are not relevant forour missile launcher, I skip their discussion. An excellent introduction from aprogramming perspective gives the Linux DeviceDrivers book. Below issome output from lsusb -v providing detailed information about the missilelauncher.

Driver

The output is structured and indented like a typical USB device. First, vendorand product ID uniquely identify this USB gadget. These IDs are used by the USBcore to decide which driver to give a device to. Moreover, hotplug scripts candecide which driver to load when a particular device is plugged in. Next, wecan read off the maximum power usage (100 mA) in the configuration section. Thesubordinate interface contains apparently one interrupt IN endpoint (besidesthe control endpoint 0) that can be accessed at address 0x81. Because it isan IN endpoint, it returns status information from the device. To handle theincoming data we first need to understand the missile launcher controlprotocol.

Reverse-Engineering the USB Protocol

The first step involves reverse-engineering (or “snooping”) the USBcommunication protocol spoken by the binary Windows driver. One approach wouldbe to consign the device in a VMware and capture the exchanged data on the hostsystem. But since several tools to analyze USB traffic already exist, the easiersolution is to rely on one of those. The most popular free application appearsto be SnoopyPro. Surprisingly I donot have Windows box at hand, so I had to install the binary driver togetherwith SnoopyPro in a VMware.

In order to capture all relevant USB data and intercept all device controlcommands, the missile launcher has to perform every possible action while beingmonitored: moving the two axes alone and together, shooting, and moving to thelimiting axes boundaries (which will trigger a notification that the axescannot be moved further in one direction). While analyzing the SnoopyProdump, one can easily discover the control commands sentto the missile launcher. As an example, the Figure below shows an 8 bytetransfer buffer. When moving the missile launcher to the right, the bufferholds 0x00000008. Moving the launcher up changes the buffer contents to0x00000001. It is apparently very easy to deduce the control bytes used tocontrol the missile launcher. Unless a “stop” command (0x00000000) is sent tothe device, it keeps the state of the last command. This means if the “down”command is issued, the device continues to turn until it receives a newcommand. If it is not possible to move further, the motor keeps up running andthe gears crack with a unbearable painful sound. Upon closer examination, theinterrupt IN endpoint buffer varies depending on the current device position.Whensoever an axis reaches its boundary (and creates the maddening sound), thedevice detects it and changes the interrupt buffer contents accordingly. Thismeans of notification can be leveraged by the kernel developer to implement aboundary checking mechanism sending a stop command as soon as the missilelauncher runs against a wall.

Here is an excerpt of the driver source showing the complete list of controlcommands that can be sent to the device.

The following bytes appear in the buffer of the interrupt IN endpoint (shown ascomment) and indicate that a boundary has been reached.

With all required control information in place, let’s now adopt the programmer’sperspective and delve into the land of kernel programming.

The Device Driver

Writing code for the kernel is an art by itself and I will only touch the tip ofthe iceberg. To get a deeper understanding I recommend the books Linux DeviceDrivers and Understanding the LinuxKernel.

As for many other disciplines the separation of mechanism and policy is afundamental paradigm a programmer should follow. The mechanism provides thecapabilities whereas the policy expresses rules how to use those capabilities.Different environments generally access the hardware in different ways. It ishence imperative to write policy-neutral code: a driver should make thehardware available without imposing constraints.

A nice feature of Linux is the ability to dynamically link object code to therunning kernel. That piece of object code is called a kernel module.Linux distinguishes between three basic device types that a module canimplement:

  • Character devices
  • Block devices
  • Network interfaces

A Character (char) device transfers a stream of bytes from and to theuser process. The module therefore implements system calls such asopen, close, read, write and ioctl.A char device looks like a file, except that file is “seekable” and most devicesoperate sequentially. Examples for char devices are the text console(/dev/console) and serial ports (/dev/ttyS0). Most simplehardware devices are driven by char drivers. Discussing block devicesand network interfaces goes beyond the scope of this article, pleaserefer to the specified literature for details.

Besides this classification, other orthogonal ways exist. As an example, USBdevices are implemented as USB modules but can show up as char devices (likeour missile launcher), block devices (USB sticks, say), or network interfaces(a USB Ethernet interface). Let us now look at the rough structure of a USBkernel module and then turn to particularities of the missile launcher.

Apart from some global variables, helper functions, and interrupt handlers,this is already the entire kernel module! But let’s start off step by step. TheUSB driver is represented by a struct usb_driver containing some functioncallbacks and variables identifying the USB driver. When the module is loadedvia the insmod program, the __init usb_ml_init(void) function is executedwhich registers the driver with the USB subsystem. When the module is unloaded,__exit usb_ml_exit(void) is called which deregisters the driver from the USBsubsystem. The __init and __exit tokens indicate that these functions areonly called at initialization and exit time. Having loaded the module, theprobe and disconnect function callbacks are set up. In the probe functioncallback, which is called when the device is being plugged in, the driverinitializes any local data structures used to manage the USB device. Forexample, it allocates memory for the struct usb_ml which contains run-timestatus information about the connected device. Here is an excerpt from thebeginning of the function:

You might have noted the use of goto statements in this code snippet. Whilegoto statements are generally consideredharmful, kernel programmers, however,employ goto statements to bundle error handling at a central place,eliminating complex, highly-indented logic. The probe function allocates memoryfor the internal device structure, initializes semaphores and spin-locks, andsets up endpoint information. Somewhat later in the function, the device isbeing registered. The device is now ready to be accessed from user space viasystem calls. I will discuss the simple user-space tool accessing the missilelauncher shortly. Yet before that, I present the communication primitives usedto send data to the device.

The Linux USB implementation uses a USB request block (URB) as “datacarrier” to communicate with USB devices. URBs are like data messages that aresent asynchronously from and to endpoints. Remember that the USB standardincludes four types of endpoints. Likewise, four different types of URBs exist,namely control, interrupt, bulk, and isochronous URBs. Once an URB has beenallocated and initialized by the driver, it is be submitted to the USB corewhich forwards it to the device. If the URB was successfully delivered to theUSB core, a completion handler is executed. Then the USB core returnscontrol to the device driver.

As our missile launcher features two endpoints (endpoint 0 and the interruptendpoint), we have to deal with both control and interrupt URBs. Thereverse-engineered commands are basically packed into an control URB and thensent out to the device. Also, we continuously receive status information fromthe periodic interrupt URBs. For example, to send simple data to the missilelauncher, the function usb_control_msg is used:

The command cmd is inserted into the buffer bufcontaining the data to be sent to the device. If the URB completes successfully,the corresponding handler is executed. It performs nothing fancy, except tellingthe driver that we launched a (yet uncorrected) command via the writesyscall:

We do not want the missile launcher hardware to be damaged by neither sendingimproper commands nor sending any commands when it reached an axis boundary.Ideally, whenever an axis boundary is reached (meaning that the missile launchercannot turn further in one direction), the device should stop the movement inthe particular direction. The completion handler of the interrupt URB turns outto be the right place to implement this idea:

The above code is used to set the correction_required variable which triggersa “correction” control URB: this URB contains simply the last command withoutthe harming bit. Remember that the URB callback functions run in interruptcontext and thus should not perform any memory allocations, hold semaphores,or cause anything putting the process to sleep. With this automatic correctionmechanism, the missile launcher is shielded from improper use. Again, it doesnot impose policy constraints, it protects only the device.

User-Space Control

For most folks fun starts in here. One doesn’t kick the bucket whendereferencing NULL-pointers and the good old libc is available, too. Afterhaving loaded the kernel module, the missile launcher is accessible via/dev/ml0. A second missile launcher would show up as /dev/ml1 and so on.Here is a very simple application to control the device:

This tool, let’s name it ml_control, allows the user to send data to thedevice via the write syscall. For example, the device moves three seconds upand left with ./ml_control -ul -t 3000, shoots with ./ml_control -f, orstop with ./ml_control -s. Consider the code as proof of concept, of coursemore sophisticated applications are imaginable.

How To Write Your First USB Client Driver (UMDF) - Windows ...

Just for fun, I mounted an external iSight camera on top of the missilelauncher. Like the author of pymissile suggests, creating anautomated sentry based on motion detection is a funky next step. Whenever amovement in the current view is detected, the missile launcher shouldautomatically align itself and fire a missile. Due to the lack of time, I couldnot pursue this project. Maybe someday, in the unlikely event of getting bored,I will return to this idea. Nevertheless, my friend Thorsten Röder quicklyhacked together a Qt GUI. It somehow resembles an early version of Quake…

Summary

In this article, I frame the creation of a USB device driver for the Linuxkernel. At first I reverse-engineer the unknown USB protocol by interceptingall USB traffic to and from the device with the Windows driver. Having capturedthe complete communication primitives, I explain how to build a USB kerneldriver. Finally, a proof-of-conecpt user-space tool is presented that lays thefoundation stone for further fancy ideas. Future work touches topics likeaugmenting the missile launcher with a video camera or mounting it on arbitrarydevices. The code from this article and a full implementation of the devicedriver is available at my github repository.

-->

In this topic you'll use the USB User-Mode Driver template provided with Microsoft Visual Studio 2019 to write a user-mode driver framework (UMDF)-based client driver. After building and installing the client driver, you'll view the client driver in Device Manager and view the driver output in a debugger.

Custom Engineering Spa USB Devices Driver

UMDF (referred to as the framework in this topic) is based on the component object model (COM). Every framework object must implement IUnknown and its methods, QueryInterface, AddRef, and Release, by default. The AddRef and Release methods manage the object's lifetime, so the client driver does not need to maintain the reference count. The QueryInterface method enables the client driver to get interface pointers to other framework objects in the Windows Driver Frameworks (WDF) object model. Framework objects perform complicated driver tasks and interact with Windows. Certain framework objects expose interfaces that enable a client driver to interact with the framework.

A UMDF-based client driver is implemented as an in-process COM server (DLL), and C++ is the preferred language for writing a client driver for a USB device. Typically, the client driver implements several interfaces exposed by the framework. This topic refers to a client driver-defined class that implements framework interfaces as a callback class. After these classes are instantiated, the resulting callback objects are partnered with particular framework objects. This partnership gives the client driver the opportunity to respond to device or system-related events that are reported by the framework. Whenever Windows notifies the framework about certain events, the framework invokes the client driver's callback, if one is available. Otherwise the framework proceeds with the default processing of the event. The template code defines driver, device, and queue callback classes.

For an explanation about the source code generated by the template, see Understanding the UMDF template code for USB client driver.

Prerequisites

See Full List On Custom.biz

For developing, debugging, and installing a user-mode driver, you need two computers:

  • A host computer running Windows 7 or a later version of the Windows operating system. The host computer is your development environment, where you write and debug your driver.
  • A target computer running the version of the operating system that you want to test your driver on, for example, Windows 10, version 1903. The target computer has the user-mode driver that you want to debug and one of the debuggers.

In some cases, where the host and target computers are running the same version of Windows, you can have just one computer running Windows 7 or a later version of the Windows. This topic assumes that you are using two computers for developing, debugging, and installing your user mode driver.

Before you begin, make sure that you meet the following requirements:

Software requirements

  • Your host computer has Visual Studio 2019.

  • Your host computer has the latest Windows Driver Kit (WDK) for Windows 10, version 1903.

    The kit include headers, libraries, tools, documentation, and the debugging tools required to develop, build, and debug a USB client driver. You can get the latest version of the WDK from How to Get the WDK.

  • Your host computer has the latest version of debugging tools for Windows. You can get the latest version from the WDK or you can Download and Install Debugging Tools for Windows.

  • If you are using two computers, you must configure the host and target computers for user-mode debugging. For more information, see Setting Up User-Mode Debugging in Visual Studio.

Hardware requirements

Get a USB device for which you will be writing the client driver. In most cases, you are provided with a USB device and its hardware specification. The specification describes device capabilities and the supported vendor commands. Use the specification to determine the functionality of the USB driver and the related design decisions.

If you are new to USB driver development, use the OSR USB FX2 learning kit to study USB samples included with the WDK. It contains the USB FX2 device and all the required hardware specifications to implement a client driver.

Recommended reading

  • Developing Drivers with Windows Driver Foundation, written by Penny Orwick and Guy Smith. For more information, see Developing Drivers with WDF.

Instructions

Step 1: Generate the UMDF driver code by using the Visual Studio 2019 USB driver template

For instructions about generating UMDF driver code, see Writing a UMDF driver based on a template.

For USB-specific code, select the following options in Visual Studio 2019

  1. In the New Project dialog box, in the search box at the top, type USB.
  2. n the middle pane, select User Mode Driver, USB (UMDF V2).
  3. lick Next.
  4. Enter a project name, choose a save location, and click Create.

The following screen shots show the New Project dialog box for the USB User-Mode Driver template.

This topic assumes that the name of the project is 'MyUSBDriver_UMDF_'. It contains the following files:

FilesDescription
Driver.h; Driver.cDeclares and defines a callback class that implements the IDriverEntry interface. The class defines methods that are invoked by the framework driver object. The main purpose of this class is to create a device object for the client driver.
Device.h; Device.cDeclares and defines a callback class that implements the IPnpCallbackHardware interface. The class defines methods that are invoked by the framework device object. The main purpose of this class is to handle events occurring as a result of Plug and Play (PnP) state changes. The class also allocates and initializes resources required by the client driver as long as it is loaded in the system.
IoQueue.h; IoQueue.cDeclares and defines a callback class that implements the IQueueCallbackDeviceIoControl interface. The class defines methods that are invoked by the framework queue object. The purpose of this class is to retrieve I/O requests that are queued in the framework.
Internal.hProvides common declarations shared by the client driver and user applications that communicate with the USB device. It also declares tracing functions and macros.
Dllsup.cppContains the implementation of the driver module's entry point.
<Project name>.infINF file that is required to install the client driver on the target computer.
Exports.defDEF file that exports the entry point function name of the driver module.

Step 2: Modify the INF file to add information about your device

Before you build the driver, you must modify the template INF file with information about your device, specifically the hardware ID string.

To provide the hardware ID string

  1. Attach your USB device to your host computer and let Windows enumerate the device.

  2. Open Device Manager and open properties for your device.

  3. On the Details tab, select Hardward Ids under Property.

    The hardware ID for the device is displayed in the list box. Select and hold (or right-click) and copy the hardware ID string.

  4. In Solution Explorer, expand Driver Files, and open the INF.

  5. Replace the following your hardware ID string.

    [Standard.NT$ARCH$]

    %DeviceName%=MyDevice_Install, USBVID_vvvv&PID_pppp

Notice the AddReg entries in the driver's information (INF) file.

[CoInstallers_AddReg] ;

HKR,CoInstallers32,0x00010008,'WudfCoinstaller.dll'

HKR,CoInstallers32,0x00010008,'WudfUpdate_01011.dll'

HKR,CoInstallers32,0x00010008,'WdfCoInstaller01011.dll,WdfCoInstaller'

HKR,CoInstallers32,0x00010008,'WinUsbCoinstaller2.dll'

  • WudfCoinstaller.dll (configuration co-installer)
  • WUDFUpdate_<version>.dll (redistributable co-installer)
  • Wdfcoinstaller<version>.dll (co-installers for KMDF)
  • Winusbcoinstaller2.dll ((co-installers for Winusb.sys)
  • MyUSBDriver_UMDF_.dll (client driver module)

If your INF AddReg directive references the UMDF redistributable co-installer (WUDFUpdate_<version>.dll ), you must not make a reference to the configuration co-installer (WUDFCoInstaller.dll). Referencing both co-installers in the INF will lead to installation errors.

All UMDF-based USB client drivers require two Microsoft-provided drivers: the reflector and WinUSB.

  • Reflector—If your driver gets loaded successfully, the reflector is loaded as the top-most driver in the kernel-mode stack. The reflector must be the top driver in the kernel mode stack. To meet this requirement, the template's INF file specifies the reflector as a service and WinUSB as a lower-filter driver in the INF:

    [MyDevice_Install.NT.Services]

    AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall ; flag 0x2 sets this as the service for the device

    AddService=WinUsb,0x000001f8,WinUsb_ServiceInstall ; this service is installed because its a filter.

  • WinUSB—The installation package must contain coinstallers for Winusb.sys because for the client driver, WinUSB is the gateway to the kernel-mode USB driver stack. Another component that gets loaded is a user-mode DLL, named WinUsb.dll, in the client driver's host process (Wudfhost.exe). Winusb.dll exposes WinUSB Functions that simplify the communication process between the client driver and WinUSB.

Step 3: Build the USB client driver code

To build your driver

  1. Open the driver project or solution in Visual Studio 2019.
  2. Right-click the solution in the Solution Explorer and select Configuration Manager.
  3. From the Configuration Manager, select your Active Solution Configuration (for example, Debug or Release) and your Active Solution Platform (for example, Win32) that correspond to the type of build you are interested in.
  4. Verify that your device interface GUID is accurate throughout the project.
    • The device interface GUID is defined in Trace.h and is referenced from MyUSBDriverUMDFCreateDevice in Device.c. When you create your project with the name 'MyUSBDriver_UMDF_', Visual Studio 2019 defines the device interface GUID with the name GUID_DEVINTERFACE_MyUSBDriver_UMDF_ but calls WdfDeviceCreateDeviceInterface with the incorrect parameter 'GUID_DEVINTERFACE_MyUSBDriverUMDF'. Replace the incorrect parameter with the name defined in Trace.h to ensure that the driver builds properly.
  5. From the Build menu, click Build Solution.

For more information, see Building a Driver.

Step 4: Configure a computer for testing and debugging

To test and debug a driver, you run the debugger on the host computer and the driver on the target computer. So far, you have used Visual Studio on the host computer to build a driver. Next you need to configure a target computer. To configure a target computer, follow the instructions in Provision a computer for driver deployment and testing.

Step 5: Enable tracing for kernel debugging

The template code contains several trace messages (TraceEvents) that can help you track function calls. All functions in the source code contain trace messages that mark the entry and exit of a routine. For errors, the trace message contains the error code and a meaningful string. Because WPP tracing is enabled for your driver project, the PDB symbol file created during the build process contains trace message formatting instructions. If you configure the host and target computers for WPP tracing, your driver can send trace messages to a file or the debugger.

To configure your host computer for WPP tracing

  1. Create trace message format (TMF) files by extracting trace message formatting instructions from the PDB symbol file.

    You can use Tracepdb.exe to create TMF files. The tool is located in the <install folder>Windows Kits10bin<architecture> folder of the WDK. The following command creates TMF files for the driver project.

    tracepdb -f [PDBFiles] -p [TMFDirectory]

    The -f option specifies the location and the name of the PDB symbol file. The -p option specifies the location for the TMF files that are created by Tracepdb. For more information, see Tracepdb Commands.

    At the specified location you'll see three files (one per .c file in the project). They are given GUID file names.

  2. In the debugger, type the following commands:

These commands:

  • Load the Wmitrace.dll extension.
  • Verfies that the debugger extension is loaded.
  • Adds the location of the TMF files to the debugger extension's search path.

The output resembles this:

To configure your target computer for WPP tracing

  1. Make sure you have the Tracelog tool on your target computer. The tool is located in the <install_folder>Windows Kits10Tools<arch> folder of the WDK. For more information, see Tracelog Command Syntax.
  2. Open a Command Window and run as administrator.
  3. Type the following command:

The command starts a trace session named MyTrace.

The guid argument specifies the GUID of the trace provider, which is the client driver. You can get the GUID from Trace.h in the Visual Studio 2019 project. As another option, you can type the following command and specify the GUID in a .guid file. The file contains the GUID in hyphen format:

You can stop the trace session by typing the following command:

Step 6: Deploy the driver on the target computer

  1. In the Solution Explorer window, select and hold (or right-click) the <project name>Package , and choose Properties.
  2. In the left pane, navigate to Configuration Properties > Driver Install > Deployment.
  3. Check Enable deployment, and check Import into driver store.
  4. For Remote Computer Name, specify the name of the target computer.
  5. Select Install and Verify.
  6. Select Ok.
  7. On the Debug menu, choose Start Debugging, or press F5 on the keyboard.

Note

Do not specify the hardware ID of your device under Hardware ID Driver Update. The hardware ID must be specified only in your driver's information (INF) file.

Step 7: View the driver in Device Manager

  1. Enter the following command to open Device Manager.

    devmgmt

  2. Verify that Device Manager shows the following node.

    USB Device

    MyUSBDriver_UMDF_Device

Custom Engineering Spa Usb Devices Driver Download

Step 8: View the output in the debugger

Verify that trace messages appear in the Debugger Immediate Window on the host computer.

The output should be similar to the following:

Custom Engineering Spa Usb Devices Driver Windows 7

Remarks

Let’s take a look at how the framework and the client driver work together to interact with Windows and handle requests sent to the USB device. This illustration shows the modules loaded in the system for a UMDF -based USB client driver.

USB Drivers Downloads & Updates | USB Driver Fix and Updates ...

The purpose of each module is described here:

  • Application—a user-mode process that issues I/O requests to communicate with the USB device.
  • I/O Manager—a Windows component that creates I/O request packets (IRPs) to represent the received application requests, and forwards them to the top of the kernel-mode device stack for the target device.
  • Reflector—a Microsoft-provided kernel-mode driver installed at the top of the kernel-mode device stack (WUDFRd.sys). The reflector redirects IRPs received from the I/O manager to the client driver host process. Upon receiving the request, the framework and the client driver handle the request.
  • Host process —the process in which the user-mode driver runs (Wudfhost.exe). It also hosts the framework and the I/O dispatcher.
  • Client driver—the user-mode function driver for the USB device.
  • UMDF—the framework module that handles most interactions with Windows on the behalf of the client driver. It exposes the user-mode device driver interfaces (DDIs) that the client driver can use to perform common driver tasks.
  • Dispatcher—mechanism that runs in the host process; determines how to forward a request to the kernel mode after it has been processed by user-mode drivers and has reached the bottom of the user-mode stack. In the illustration, the dispatcher forwards the request to the user-mode DLL, Winusb.dll.
  • Winusb.dll—a Microsoft-provided user-mode DLL that exposes WinUSB Functions that simplify the communication process between the client driver and WinUSB (Winusb.sys, loaded in kernel mode).
  • Winusb.sys—a Microsoft-provided driver that is required by all UMDF client drivers for USB devices. The driver must be installed below the reflector and acts as the gateway to the USB driver stack in the kernel-mode. For more information, see WinUSB.
  • USB driver stack—a set of drivers, provided by Microsoft, that handle protocol-level communication with the USB device. For more information, see USB host-side drivers in Windows.

Whenever an application makes a request for the USB driver stack, the Windows I/O manager sends the request to the reflector, which directs it to client driver in user mode. The client driver handles the request by calling specific UMDF methods, which internally call WinUSB Functions to send the request to WinUSB. Upon receiving the request, WinUSB either processes the request or forwards it to the USB driver stack.

Related topics

Understanding the UMDF template code for USB client driver
How to enable USB selective suspend and system wake in the UMDF driver for a USB device
Getting started with USB client driver development