IT tutorials
 
Windows
 

Windows 7 : Programming Drivers for the Kernel Mode Driver Framework (part 1)

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
11/30/2013 8:20:44 PM
1. Differences between KMDF and WDM Samples

The KMDF samples are based on the similarly named Windows Driver Model (WDM) samples that are provided in the Windows Driver Kit (WDK). With a few exceptions, the corresponding drivers support similar features. If you are experienced with WDM, you might find useful a comparison of the KMDF and WDM samples.

The primary difference between the samples is that the KMDF samples are much shorter and less complex. The reason is that KMDF implements most of the details of WMD, so that you can avoid writing many lines of code that perform common tasks and implement common features required in all drivers. Instead, you define callbacks for the conditions and events that your driver must handle.

For example, KMDF driver, like WDM drivers, support Plug and Play and power management for their devices. WDM drivers typically include thousands of lines of code to ensure that they handle every possible state and minor I/O request packet (IRP) code; drivers often require code to handle IRPs that they don’t even support. A KMDF driver, however, includes code to handle only those features and requests that its device supports. All other Plug and Play and power requests are handled by WDF in a default manner. These defaults make possible the incremental development of KMDF drivers. You can implement a skeletal set of features, test the implementation, and then incrementally add code to support additional features or perform more complicated tasks.

In a practical sense, the most significant difference between KMDF and WDM drivers is the number and complexity of the required functions. For an example of this difference, compare the simplest form of the WDM Toaster sample (src/general/toaster/func/Incomplete1 in the WDK installation directory) with the simplest KMDF Toaster sample (src/kmdf/toaster/func/simple in the WDF installation directory).

Both drivers support basic Plug and Play, power, and WMI requests. The KMDF sample also includes stub functions to handle read, write, and IOCTL requests. However, the KMDF sample contains many fewer lines of code than the WDM sample. Table 1 compares the functions in these two drivers.

Table 1. Comparison of a KMDF Simple Toaster and WDM incomplete1 Toaster Samples
WDM FunctionEquivalent KMDF FunctionComments
DriverEntryDriverEntryFunction has same prototype. KMDF driver creates WDF driver object.
ToasterAddDeviceToasterEvtDeviceAddKMDF driver creates a default queue for I/O requests.
ToasterUnloadNoneKMDF driver uses defaults.
ToasterDispatchPnPNoneKMDF driver uses defaults.
ToasterSendIrpSynchronouslyNoneWDM driver passes IRPs down the stack to be completed synchronously. KMDF driver uses defaults.
ToasterDispatchPnPCompleteNoneKMDF driver uses defaults.
ToasterDispatchPowerNoneKMDF driver uses defaults.
Toaster System ControlNoneWDM function passes WMI IRPs to the next lower driver. KMDF driver uses defaults.
NoneToasterEvtIoReadWDM function handles and completes read request. KMDF function is a stub.
NoneToasterEvtIoWriteWDM function handles and completes write requests. KMDF function is a stub.
NoneToasterEvtIoDeviceControlWDM function handles and completes device I/O control request. KMDF function is a stub.

2. Macros Used in KMDF Samples

Many of the KMDF samples use two macros that might be unfamiliar:

  • PAGED_CODE

  • UNREFERENCED_PARAMETER

The PAGED_CODE macro causes the driver to assert if the function is called at IRQL DISPATCH_LEVEL or higher. The macro is defined in ntddk.h and takes no arguments. It works only in a checked build.

The UNREFERENCED_PARAMETER is defined in the standard WDK header file ntdef.h, which is included by ntddk.h. It disables compiler warnings about unreferenced parameters. It can be used in any Kernel Mode Driver.

 
Others
 
- Windows Server 2008 : Creating and Running a PowerShell Script - Testing for the Existence of a File, Creating Output as HTML
- Windows Server 2008 : Creating and Running a PowerShell Script - Running PowerShell Scripts, Logging Processes with a get-process Script
- Windows Server 2008 : Creating and Running a PowerShell Script - Creating and Modifying the Global PowerShell Profile
- Windows Server 2008 : Creating and Running a PowerShell Script - Creating a PowerShell Profile
- Windows Server 2008 : Creating and Running a PowerShell Script - Setting the Security Context
- Windows 8 : Cloud Connections - Office 2013
- Windows 8 : Cloud Connections - SkyDrive (part 3) - To access SkyDrive from a browser
- Windows 8 : Cloud Connections - SkyDrive (part 2) - To open SkyDrive inside Windows Explorer
- Windows 8 : Cloud Connections - SkyDrive (part 1) - To add a file to the tile-based SkyDrive app
- Windows 8 : Cloud Connections - Windows Essentials (part 2) - To install Windows Essentials
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us