Summary of KMDF and WDM Equivalents
September 7, 2006
Abstract
This paper provides information that is useful in porting drivers from the Microsoft® Windows® Driver Model (WDM) to the kernel-mode driver
framework (KMDF) for the Microsoft Windows family of operating systems. It includes tables that show how KMDF objects, methods, and event
callback functions correspond to WDM objects and functions. Readers of this paper should also see the companion paper titled Porting a Driver
from WDM to KMDF, which provides additional information about porting.
This information applies for the following operating systems:
Microsoft Windows Vista™
Microsoft Windows Server® 2003
Microsoft Windows XP
Microsoft Windows 2000
The current version of this paper is maintained on the Web at:
http://www.microsoft.com/whdc/driver/wdf/WDF_Port.mspx
Contents
Introduction .............................................................................................................................3
KMDF and WDM Object Types ...............................................................................................3
WDM Driver Routines and Corresponding KMDF Event Callbacks ........................................4
KMDF Methods and WDM Equivalents ...................................................................................6
WDM Equivalents for KMDF Buffer Pointers .........................................................................18
Buffers for IRP_MJ_READ Requests ...............................................................................19
Buffers for IRP_MJ_WRITE Requests .............................................................................19
Buffers for IRP_MJ_DEVICE_CONTROL Requests ........................................................20
Buffers for METHOD_NEITHER Requests ......................................................................20
WDM IRPs and KMDF Event Callback Functions .................................................................21
KMDF Callbacks for IRP_MJ_PNP ..................................................................................22
KMDF Callbacks for IRP_MJ_POWER ............................................................................24
Resources .............................................................................................................................25
Summary of KMDF and WDM Equivalents - 2
Disclaimer
This is a preliminary document and may be changed substantially prior to final commercial release of the software described herein.
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond
to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented
after the date of publication.
This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS
DOCUMENT.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or
introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express
written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in
any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.
Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious, and no
association with any real company, organization, product, domain name, email address, logo, person, place or event is intended or should be inferred.
© 2006 Microsoft Corporation. All rights reserved.
Microsoft, Windows, Windows NT, Windows Server, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other
countries.
The names of actual companies and products mentioned herein may be the trademarks of their respective owners.
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Summary of KMDF and WDM Equivalents - 3
Introduction
This paper provides tables that compare kernel-mode driver framework (KMDF) objects and methods with the corresponding Microsoft®
Windows® Driver Mode (WDM) objects and functions. The tables list:
KMDF and WDM object types
WDM driver-defined routines and equivalent KMDF event callback functions
KMDF methods and the WDM functions that perform the equivalent operation
WDM equivalents for KMDF buffer pointers
KMDF callbacks that correspond to the WDM IRP codes
A companion to this paper titled Porting a Driver from WDM to KMDF outlines a strategy for porting and describes differences between the two
driver models in greater detail. It is listed in the “Resources” section at the end of this paper.
KMDF and WDM Object Types
Table 1 shows how KMDF object types correspond to WDM objects and concepts.
Table 1. KMDF and WDM Object Types
KMDF object type
WDFCHILDLIST
WDFCMRESLIST
WDFCOLLECTION
WDFDEVICE
WDFDMAENABLER
WDFDMATRANSACTION
WDFDPC
WDFDRIVER
WDFFILEOBJECT
WDFINTERRUPT
WDFIORESLIST
WDFIORESREQLIST
WDFIOTARGET
Corresponding WDM object type
DEVICE_RELATIONS for BusRelations
CM_RESOURCE_LIST
None (most closely related to LIST_ENTRY
and its related functions)
PVOID returned by
AllocateCommonBuffer
DEVICE_OBJECT
DMA_ADAPTER
None
KDPC
DRIVER_OBJECT
DEVICE_OBJECT
PKINTERRUPT
IO_RESOURCE_LIST
IO_RESOURCE_REQUIREMENTS_LIST
DEVICE_OBJECT
WDFKEY
HANDLE returned by ZwCreateKey or
WDFCOMMONBUFFER
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Description of KMDF object
List of the child devices that are enumerated by a parent device
Resource list that describes the hardware resources allocated to a device
Group of framework objects
Shared memory buffer used for direct memory access (DMA)
Device object
DMA adapter object
A DMA transaction, including callback methods
Deferred procedure call (DPC) object
Driver object
Device object that is the target of a create, cleanup, or close request
Interrupt object
Resource range list that represents a possible logical configuration for a device
Resource requirements list for a device that specifies one or more resource lists
Target of an I/O request that a KMDF driver sends; framework calls ZwCreateFile
when the driver opens the target
Registry access
Summary of KMDF and WDM Equivalents - 4
KMDF object type
WDFOBJECT
WDFQUEUE
Corresponding WDM object type
ZwOpenKey
PAGED_LOOKASIDE_LIST or
NPAGED_LOOKASIDE_LIST
None; accessed through a PVOID returned
by memory allocation functions
None
IO_CSQ
WDFREQUEST
IRP
WDFSPINLOCK
WDFSTRING
WDFTIMER
WDFUSBDEVICE
KSPIN_LOCK
UNICODE_STRING
KTIMER
Attached DEVICE_OBJECT for a USBenumerated stack
USB_INTERFACE_DESCRIPTOR
WDFLOOKASIDE
WDFMEMORY
WDFUSBINTERFACE
WDFUSBPIPE
WDFWAITLOCK
WDFWMIINSTANCE
WDFWMIPROVIDER
WDFWORKITEM
USBD_PIPE_HANDLE
KEVENT, KeEnterCriticalRegion,
KeLeaveCriticalRegion
None; accessed through parameters to
driver-defined DpWmiXxx callback functions
None; accessed through parameters to
driver-defined DpWmiXxx callback functions
IO_WORKITEM
Description of KMDF object
Paged or nonpaged lookaside list
Memory allocated from kernel-mode paged or nonpaged pool; WDFMEMORY is
reference counted
Generic object
Cancel-safe I/O request packet (IRP) queue; WDFQUEUE supports state
management, dispatching, serialization of I/O requests, and synchronization with Plug
and Play
I/O request packet for create, read, write, device I/O control, or internal device I/O
control request
Spin lock
Reference-counted Unicode string
Timer object
Collection of all the WDFUSBINTERFACE objects for a device, which manages the
configuration for the device
Collection of all the settings on a specific USB interface number and a collection of all
the currently selected WDFUSBPIPE objects for the current setting
USB pipe that is the target of I/O requests
Kernel dispatcher object (a PASSIVE_LEVEL lock)
An instance of a Windows Management Instrumentation (WMI) data block. The KMDF
object encapsulates the WMI GUID and instance index.
WMI data block
Work item to be processed in a system worker thread at IRQL PASSIVE_LEVEL
WDM Driver Routines and Corresponding KMDF Event Callbacks
Table 2 lists the standard required and optional WDM driver routines with the KMDF equivalents. For some WDM routines, no KMDF equivalent is
listed. Instead, the table specifies “None” or “Not supported”:
"None" means that KMDF does not define a corresponding routine, typically because the KMDF architecture does not require such a routine.
In this case, the table indicates how a driver can perform the same task.
"Not supported" means that KMDF does not support this feature and drivers cannot use it.
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Summary of KMDF and WDM Equivalents - 5
Table 2. WDM Driver Routines and KMDF Equivalents
WDM driver routine
AdapterControl
AdapterListControl
AddDevice
BugCheckCallback
BugCheckDumpIoCallback
BugCheckSecondaryDumpDataCallback
Cancel
ControllerControl
CsqAcquireLock
CsqCompleteCanceledIrp
CsqInsertIrp
CsqInsertIrpEx
CsqPeekNextIrp
CsqReleaseLock
CsqRemoveIrp
CustomDpc
CustomThreadedDpc
CustomTimerDpc
DispatchCleanup
DispatchClose
DispatchCreate
DispatchCreateClose
DispatchDeviceControl
DispatchFlushBuffers
DispatchInternalDeviceControl
DispatchPnP
DispatchPower
DispatchQueryInformation
DispatchRead
DispatchSetInformation
DispatchShutdown
DispatchSystemControl
DispatchWrite
DpcForIsr
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
KMDF equivalent
EvtProgramDma
EvtProgramDma
EvtDriverDeviceAdd
None; use WDM routines
None; use WDM routines
None; use WDM routines
EvtRequestCancel or EvtIoCanceledOnQueue
Not supported
None; framework supplies lock
EvtRequestCancel
WdfRequestForwardToIoQueue and WdfRequestRequeue
WdfRequestForwardToIoQueue and WdfRequestRequeue
WdfIoQueueFindRequest
None; framework supplies lock
WdfIoQueueRetrieveNextRequest, WdfIoQueueRetrieveFoundRequest, and
WdfIoQueueRetrieveRequestByFileObject
EvtDpcFunc
None; driver should queue a work item from EvtDpcFunc
EvtTimerFunc
EvtFileCleanup
EvtFileClose
EvtDeviceFileCreate or EvtIoDefault
See DispatchCreate and DispatchClose
EvtIoDeviceControl or EvtIoDefault
None; use EvtDeviceWdmIrpPreprocess
EvtIoInternalDeviceControl or EvtIoDefault
Many
Many
None; use EvtDeviceWdmIrpPreprocess
EvtIoRead or EvtIoDefault
None; use EvtDeviceWdmIrpPreprocess
EvtDeviceShutdownNotification (control device objects only)
EvtWmiXxx
EvtIoWrite or EvtIoDefault
EvtInterruptDpc
Summary of KMDF and WDM Equivalents - 6
WDM driver routine
DllInitialize
DllUnload
DriverEntry
InterruptMessageService
InterruptService
IoCompletion
IoTimer
RegistryCallback
Reinitialize
StartIo
SynchCritSection
Unload
ExWorkItem
IoWorkItem
KMDF equivalent
Not supported
Not supported
DriverEntry
EvtInterruptIsr
EvtInterruptIsr
CompletionRoutine
EvtTimerFunc
None; use WDM routines
Not supported
EvtIoRead, EvtIoWrite, EvtIoDeviceControl, EvtIoInternalDeviceControl, or EvtIoDefault with the queue dispatch
type WdfIoQueueDispatchSequential
EvtInterruptSynchronize or
WdfInterruptAcquireLock followed by WdfInterruptReleaseLock
EvtDriverUnload, EvtCleanupCallback on the WDFDRIVER object
EvtWorkItem
EvtWorkItem
KMDF Methods and WDM Equivalents
Table 3 lists all the KMDF methods along with the WDM functions (and in some cases, pseudocode sequences) that perform the same task.
Table 3. KMDF Methods and WDM Equivalents
KMDF method
WdfCollectionCreate
WdfCollectionGetCount
WdfCollectionAdd
WdfCollectionRemove
WdfCollectionRemoveItem
WdfCollectionGetItem
WdfCollectionGetFirstItem
WdfCollectionGetLastItem
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
Create and manipulate a list:
LIST_ENTRY
InitializeListHead
InsertHeadList
RemoveEntryList
IsListEmpty
Summary of KMDF and WDM Equivalents - 7
KMDF method
WdfChildListAddOrUpdateChildDescriptionAsPresent
WdfChildListBeginIteration
WdfChildListBeginScan
WdfChildListUpdateAllChildDescriptionsAsPresent
WdfChildListUpdateChildDescriptionAsMissing
WdfChildListEndIteration
WdfChildListEndScan
WdfFdoAddStaticChild
WdfPdoMarkMissing
WdfChildListGetDevice
WdfChildListRequestChildEject
WdfChildListRetrieveAddressDescription
WdfChildListRetrieveNextDevice
WdfChildListRetrievePdo
WdfChildListCreate
WdfCmResourceListAppendDescriptor
WdfCmResourceListGetCount
WdfCmResourceListGetDescriptor
WdfCmResourceListInsertDescriptor
WdfCmResourceListRemove
WdfCmResourceListRemoveByDescriptor
WdfCommonBufferCreate
WdfCommonBufferCreateWithConfig
WdfCommonBufferGetAlignedLogicalAddress
WdfCommonBufferGetAlignedVirtualAddress
WdfCommonBufferGetLength
WdfControlDeviceInitAllocate
WdfControlDeviceInitSetShutdownNotification
WdfControlFinishInitializing
WdfDeviceAddDependentUsageDeviceObject
WdfDeviceAddQueryInterface
WdfDeviceAddRemovalRelationsPhysicalDevice
WdfDeviceAllocAndQueryProperty
WdfDeviceAssignMofResourceName
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
In a bus driver, enumerate children and create child physical device objects (PDOs):
IoInvalidateDeviceRelations (BusRelations)
Respond to IRP_MN_QUERY_DEVICE_RELATIONS (BusRelations)
IoCreateDevice for a child PDO
None
IoRequestDeviceEject
None
None
None
None
Add CM_PARTIAL_RESOURCE_DESCRIPTOR to the end of a
CM_PARTIAL_RESOURCE_LIST
PCM_PARTIAL_RESOURCE_LIST->Count
CM_PARTIAL_RESOURCE_DESCRIPTOR
Add CM_PARTIAL_RESOURCE_DESCRIPTOR to CM_PARTIAL_RESOURCE_LIST
Remove CM_PARTIAL_RESOURCE_DESCRIPTOR from CM_PARTIAL_RESOURCE_LIST
Remove CM_PARTIAL_RESOURCE_DESCRIPTOR from CM_PARTIAL_RESOURCE_LIST
AllocateCommonBuffer
AllocateCommonBuffer
LogicalAddress (PPHYSICAL_ADDRESS) returned by AllocateCommonBuffer
Return value (PVOID) of AllocateCommonBuffer
Length (ULONG) passed to AllocateCommonBuffer
IoCreateDevice for a non-PnP (legacy Microsoft NT® 4.0-style) device object
IoRegisterShutdownNotification
Clear DO_DEVICE_INITIALIZING flag in DEVICE_OBJECT -> Flags for control device object
Affects IRP_MN_DEVICE_USAGE_NOTIFICATION for devices that support special files and
depend on other devices
Provide custom IRP_MN_QUERY_INTERFACE handling
IRP_MN_QUERY_DEVICE_RELATIONS (RemovalRelations)
IoGetDeviceProperty
Supply MofResourceName value returned by DpWmiQueryRegInfo
Summary of KMDF and WDM Equivalents - 8
KMDF method
WdfDeviceAssignS0IdleSettings
WdfDeviceAssignSxWakeSettings
WdfDeviceClearRemovalRelationsDevices
WdfDeviceConfigureRequestDispatching
WdfDeviceCreate
WdfDeviceCreateDeviceInterface
WdfDeviceCreateSymbolicLink
WdfDeviceEnqueueRequest
WdfDeviceGetAlignmentRequirement
WdfDeviceGetCharacteristics
WdfDeviceGetDefaultQueue
WdfDeviceGetDevicePnpState
WdfDeviceGetDevicePowerPolicyState
WdfDeviceGetDevicePowerState
WdfDeviceGetDeviceState
WdfDeviceGetDriver
WdfDeviceGetFileObject
WdfDeviceGetIoTarget
WdfDeviceIndicateWakeStatus
WdfDeviceInitAssignName
WdfDeviceInitAssignSDDLString
WdfDeviceInitAssignWdmIrpPreprocessCallback
WdfDeviceInitFree
WdfDeviceInitRegisterPnpStateChangeCallback
WdfDeviceInitRegisterPowerPolicyStateChangeCallback
WdfDeviceInitRegisterPowerStateChangeCallback
WdfDeviceInitSetCharacteristics
WdfDeviceInitSetDeviceClass
WdfDeviceInitSetDeviceType
WdfDeviceInitSetExclusive
WdfDeviceInitSetFileObjectConfig
WdfDeviceInitSetIoInCallerContextCallback
WdfDeviceInitSetIoType
WdfDeviceInitSetPnpPowerEventCallbacks
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
PoRegisterDeviceForIdleDetection with automatic I/O queue state management
Request IRP_MN_WAIT_WAKE while the machine is in low power
IRP_MN_QUERY_DEVICE_RELATIONS (RemovalRelations)
None
IoCreateDevice
IoRegisterDeviceInterface
IoCreateSymbolicLink
None
Return DeviceObject-> AlignmentRequirement
Return DeviceObject->Characteristics
None
None
None
None
None
None
None
PDEVICE_OBJECT used for IoCallDriver to next lower driver
Supply status to complete IRP_MN_WAIT_WAKE request
Supply DeviceName parameter for IoCreateDevice and IoCreateDeviceSecure
Supply DefaultSDDLString parameter for IoCreateDeviceSecure
None
None
None
None
None
Set DeviceObject->Characteristics
Supply DeviceClassGuid parameter for IoCreateDeviceSecure
Supply DeviceType parameter for IoCreateDevice and IoCreateDeviceSecure
Sets Exclusive parameter for IoCreateDevice and IoCreateDeviceSecure
Set dispatch routines for IRP_MJ_CREATE, IRP_MJ_CLEANUP, and IRP_MJ_CLOSE
None
Set METHOD_BUFFERED, METHOD_IN_DIRECT, METHOD_OUT_DIRECT, or
METHOD_NEITHER in DriverObject ->Flags
Provide callback functions to handle some aspects of IRP_MJ_PNP and IRP_MJ_POWER
requests
Summary of KMDF and WDM Equivalents - 9
KMDF method
WdfDeviceInitSetPowerInrush
WdfDeviceInitSetPowerNotPageable
WdfDeviceInitSetPowerPageable
WdfDeviceInitSetPowerPolicyEventCallbacks
WdfDeviceInitSetPowerPolicyOwnership
WdfDeviceInitSetRequestAttributes
WdfDeviceMiniportCreate
WdfDeviceOpenRegistryKey
WdfDeviceQueryProperty
WdfDeviceRemoveRemovalRelationsPhysicalDevice
WdfDeviceResumeIdle
WdfDeviceRetrieveDeviceInterfaceString
WdfDeviceRetrieveDeviceName
WdfDeviceSetAlignmentRequirement
WdfDeviceSetBusInformationForChildren
WdfDeviceSetCharacteristics
WdfDeviceSetDeviceInterfaceState
WdfDeviceSetDeviceState
WdfDeviceSetFailed
WdfDeviceSetPnpCapabilities
WdfDeviceSetPowerCapabilities
WdfDeviceSetSpecialFileSupport
WdfDeviceSetStaticStopRemove
WdfDeviceStopIdle
WdfDeviceWdmDispatchPreprocessedIrp
WdfDeviceWdmGetAttachedDevice
WdfDeviceWdmGetDeviceObject
WdfDeviceWdmGetPhysicalDevice
WdfDmaEnablerCreate
WdfDmaEnablerGetFragmentLength
WdfDmaEnablerGetMaximumLength
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
Set DO_POWER_INRUSH in DriverObject->Flags
Clear DO_POWER_PAGABLE in DriverObject->Flags
Set DO_POWER_PAGABLE in DriverObject->Flags
None
None
None
None
IoOpenDeviceRegistryKey
IoGetDeviceProperty
IRP_MN_QUERY_DEVICE_RELATIONS (RemovalRelations)
PoRegisterDeviceForIdleDetection with automatic I/O queue state management
Get SymbolicLinkName parameter returned by IoRegisterDeviceInterface
Get DeviceName parameter for IoCreateDevice and IoCreateDeviceSecure
Set DeviceObject -> AlignmentRequirement
Supply PNP_BUS_INFORMATION returned by IRP_MN_QUERY_BUS_INFORMATION
Set DeviceObject->Characteristics
IoSetDeviceInterfaceState
The sequence:
IoInvalidateDeviceState
IRP_MN_QUERY_PNP_DEVICE_STATE
The sequence:
IoInvalidateDeviceState
IRP_MN_QUERY_PNP_DEVICE_STATE (PNP_DEVICE_FAILED)
Set Plug and Play capabilities in response to IRP_MN_QUERY_CAPABILITIES
Set power capabilities in response to IRP_MN_QUERY_CAPABILITIES
Set special file support in response to IRP_MN_DEVICE_USAGE_NOTIFICATION
Supply information used to respond to IRP_MN_QUERY_REMOVE_DEVICE and
IRP_MN_QUERY_STOP_DEVICE
PoSetDeviceBusy
None
PDEVICE_OBJECT for next-lower device object
PDEVICE_OBJECT for current device object
PDEVICE_OBJECT for underlying PDO
IoGetDmaAdapter
Maximum length of a single DMA transfer, used in calculating NumberOfMapRegisters
PDEVICE_DESCRIPTION -> MaximumLength
Summary of KMDF and WDM Equivalents - 10
KMDF method
WdfDmaEnablerGetMaximumScatterGatherElements
WdfDmaEnablerSetMaximumScatterGatherElements
WdfDmaEnablerWdmGetDmaAdapter
WDM equivalent
None
None
PDMA_ADAPTER
WdfDmaTransactionCreate
WdfDmaTransactionDmaCompleted
WdfDmaTransactionDmaCompletedFinal
WdfDmaTransactionDmaCompletedWithLength
WdfDmaTransactionExecute
None
PutScatterGatherList or FlushAdapterBuffers
PutScatterGatherList or FlushAdapterBuffers
PutScatterGatherList or FlushAdapterBuffers
For busmaster DMA, depends on Windows version:
BuildScatterGatherList on Windows XP and later releases
GetScatterGatherList on Windows 2000
For packet-based DMA, the sequence:
AllocateAdapterChannel
KeFlushIoBuffers
MapTransfer
None
None
None
CalculateScatterGatherList
CalculateScatterGatherList
PutScatterGatherList or FlushAdapterBuffers
None
KeInitializeDpc
KeInsertQueueDpc
KeRemoveQueueDpc
None
Return KDPC
Initialize DriverObject->Dispatch
Registry path passed to DriverEntry
None
None
None
None
None
PDRIVER_OBJECT
None
None
WdfDmaTransactionGetBytesTransferred
WdfDmaTransactionGetCurrentDmaTransferLength
WdfDmaTransactionGetRequest
WdfDmaTransactionInitialize
WdfDmaTransactionInitializeUsingRequest
WdfDmaTransactionRelease
WdfDmaTransactionSetMaximumLength
WdfDpcCreate
WdfDpcEnqueue
WdfDpcCancel
WdfDpcGetParentObject
WdfDpcWdmGetDpc
WdfDriverCreate
WdfDriverGetRegistryPath
WdfDriverIsVersionAvailable
WdfDriverMiniportUnload
WdfDriverOpenParametersRegistryKey
WdfDriverRegisterTraceInfo
WdfDriverRetrieveVersionString
WdfDriverWdmGetDriverObject
WdfFdoAddStaticChild
WdfFdoGetDefaultChildList
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Summary of KMDF and WDM Equivalents - 11
KMDF method
WdfFdoInitAllocAndQueryProperty
WdfFdoInitOpenRegistryKey
WdfFdoInitQueryProperty
WdfFdoInitSetDefaultChildListConfig
WdfFdoInitSetEventCallbacks
WdfFdoInitSetFilter
WdfFdoInitWdmGetPhysicalDevice
WdfFdoLockStaticChildListForIteration
WdfFdoQueryForInterface
WdfFdoRetrieveNextStaticChild
WdfFdoUnlockStaticChildListFromIteration
WdfFileObjectGetDevice
WdfFileObjectGetFileName
WdfFileObjectGetFlags
WdfFileObjectWdmGetFileObject
WdfInterruptAcquireLock
WdfInterruptCreate
WdfInterruptDisable
WdfInterruptEnable
WdfInterruptGetDevice
WdfInterruptGetInfo
WdfInterruptQueueDpcForIsr
WdfInterruptReleaseLock
WdfInterruptSetPolicy
WdfInterruptSynchronize
WdfInterruptWdmGetInterrupt
WdfIoQueueCreate
WdfIoQueueDrain
WdfIoQueueDrainSynchronously
WdfIoQueueFindRequest
WdfIoQueueGetDevice
WdfIoQueueGetState
WdfIoQueuePurge
WdfIoQueuePurgeSynchronously
WdfIoQueueReadyNotify
WdfIoQueueRetrieveFoundRequest
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
IoGetDeviceProperty
IoOpenDeviceRegistryKey
IoGetDeviceProperty
None
None
None
PDEVICE_OBJECT for the PDO
None
Send IRP_MJ_PNP (IRP_MN_QUERY_INTERFACE) to the top of the current stack
None
None
None
PFILE_OBJECT->FileName
PFILE_OBJECT->Flags
PFILE_OBJECT
KeAcquireInterruptSpinLock
IoConnectInterrupt or IoConnectInterruptEx
None
None
None
Return information from CM_PARTIAL_RESOURCE_LIST
KeInsertQueueDpc
KeReleaseInterruptSpinLock
Set information in IO_RESOURCE_DESCRIPTOR for interrupt
KeSynchronizeExecution
PKINTERRUPT
Any of the following queuing mechanisms:
KeInitializeDeviceQueue (PKDEVICE_QUEUE)
IoCsqInitialize (PIO_CSQ)
Tail.Overlay.ListEntry
Summary of KMDF and WDM Equivalents - 12
KMDF method
WdfIoQueueRetrieveNextRequest
WdfIoQueueRetrieveRequestByFileObject
WdfIoQueueStop
WdfIoQueueStopSynchronously
WdfIoResourceListAppendDescriptor
WdfIoResourceListCreate
WdfIoResourceListGetCount
WdfIoResourceListGetDescriptor
WdfIoResourceListInsertDescriptor
WdfIoResourceListRemove
WdfIoResourceListRemoveByDescriptor
WdfIoResourceListUpdateDescriptor
WdfIoResourceRequirementsListAppendIoResList
WdfIoResourceRequirementsListGetCount
WdfIoResourceRequirementsListGetIoResList
WdfIoResourceRequirementsListInsertIoResList
WdfIoResourceRequirementsListRemove
WdfIoResourceRequirementsListRemoveByIoResList
WdfIoResourceRequirementsListSetInterfaceType
WdfIoResourceRequirementsListSetSlotNumber
WdfIoTargetAllocAndQueryTargetProperty
WdfIoTargetClose
WDM equivalent
WdfIoTargetCloseForQueryRemove
WdfIoTargetCreate
WdfIoTargetFormatRequestForInternalIoctl
WdfIoTargetFormatRequestForInternalIoctlOthers
WdfIoTargetFormatRequestForIoctl
WdfIoTargetFormatRequestForRead
WdfIoTargetFormatRequestForWrite
WdfIoTargetGetDevice
WdfIoTargetGetState
WdfIoTargetOpen
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Append IO_RESOURCE_DESCRIPTOR to IO_RESOURCE_LIST
None
PIO_RESOURCE_LIST->Count
Get IO_RESOURCE_DESCRIPTOR from IO_RESOURCE_LIST
Insert IO_RESOURCE_DESCRIPTOR into IO_RESOURCE_LIST
Remove IO_RESOURCE_DESCRIPTOR from IO_RESOURCE_LIST
Remove IO_RESOURCE_DESCRIPTOR from IO_RESOURCE_LIST
Update _IO_RESOURCE_DESCRIPTOR
Append IO_RESOURCE_LIST to IO_RESOURCE_REQUIREMENTS_LIST
PIO_RESOURCE_REQUIREMENTS_LIST-> AlternativeLists
None
Insert IO_RESOURCE_LIST into IO_RESOURCE_REQUIREMENTS_LIST
None
Remove IO_RESOURCE_LIST from IO_RESOURCE_REQUIREMENTS_LIST
PIO_RESOURCE_REQUIREMENTS_LIST->InterfaceType
PIO_RESOURCE_REQUIREMENTS_LIST->SlotNumber
IoGetDeviceProperty on target device PDO
The sequence:
ObDereferenceObject (PFILE_OBJECT) or ZwClose
GUID_TARGET_DEVICE_REMOVE_COMPLETE event
The sequence:
ObDereferenceObject (PFILE_OBJECT) or ZwClose
GUID_TARGET_DEVICE_QUERY_REMOVE event
None
IoAllocateIrp or
IoBuildAsynchronousFsdRequest
None
None
The sequence:
Summary of KMDF and WDM Equivalents - 13
KMDF method
WdfIoTargetQueryForInterface
WdfIoTargetQueryTargetProperty
WdfIoTargetSendInternalIoctlOthersSynchronously
WdfIoTargetSendInternalIoctlSynchronously
WdfIoTargetSendIoctlSynchronously
WdfIoTargetSendReadSynchronously
WdfIoTargetSendWriteSynchronously
WdfIoTargetStart
WdfIoTargetStop
WdfIoTargetWdmGetTargetDeviceObject
WdfIoTargetWdmGetTargetFileHandle
WdfIoTargetWdmGetTargetFileObject
WdfIoTargetWdmGetTargetPhysicalDevice
WdfLookasideListCreate
WdfMemoryAssignBuffer
WdfMemoryCopyFromBuffer
WdfMemoryCopyToBuffer
WdfMemoryCreate
WdfMemoryCreateFromLookaside
WdfMemoryCreatePreallocated
WdfMemoryGetBuffer
WdfObjectAcquireLock
WdfObjectAllocateContext
WdfObjectContextGetObject
WdfObjectCreate
WdfObjectDereferenceActual
WdfObjectGetTypedContext
WdfObjectReferenceActual
WdfObjectReleaseLock
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
ZwCreateFile
IoRegisterPlugPlayNotification for EventCategoryTargetDeviceChange
IoGetDeviceObjectPointer
Handle GUID_DEVICE_INTERFACE_ARRIVAL and
GUID_TARGET_DEVICE_REMOVE_CANCELLED
Send IRP_MJ_PNP for IRP_MN_QUERY_INTERFACE to the top of the target device’s stack
IoGetDeviceProperty on target device PDO
The sequence:
IoBuildDeviceIoControlRequest or IoBuildSynchronousFsdRequest
status = IoCallDriver();
If (status == STATUS_PENDING) {
KeWaitForSingleObject();
}
None
None
PDEVICE_OBJECT for target device
HANDLE returned by ZwCreateFile for target device
PFILE_OBJECT represented by handle returned by ZwCreateFile
PDEVICE_OBJECT for target device PDO
ExInitializeNPagedLookasideList and ExInitializePagedLookasideList
None
RtlCopyMemory with bounds checking
RtlCopyMemory with bounds checking
ExAllocatePool and ExAllocatePoolWithTag
ExAllocateFromNPagedLookasideList and ExAllocateFromPagedLookasideList
None
None
Either KeAcquireSpinlock or KeWaitForMutexObject/KeWaitForSingleObject (PRKMUTEX),
depending on the object execution level
ExAllocatePool
None
ExAllocatePool
None
None
None
None
Summary of KMDF and WDM Equivalents - 14
KMDF method
WdfPdoAddEjectionRelationsPhysicalDevice
WdfPdoClearEjectionRelationsDevices
WdfPdoGetParent
WdfPdoInitAddCompatibleID
WdfPdoInitAddDeviceText
WdfPdoInitAddHardwareID
WdfPdoInitAllocate
WdfPdoInitAssignDeviceID
WdfPdoInitAssignInstanceID
WdfPdoInitAssignRawDevice
WdfPdoInitSetDefaultLocale
WdfPdoInitSetEventCallbacks
WdfPdoRemoveEjectionRelationsPhysicalDevice
WdfPdoRequestEject
WdfPdoRetrieveAddressDescription
WdfPdoRetrieveIdentificationDescription
WdfPdoUpdateAddressDescription
WdfRegistryAssignMemory
WdfRegistryAssignMultiString
WdfRegistryAssignString
WdfRegistryAssignULong
WdfRegistryAssignUnicodeString
WdfRegistryAssignValue
WdfRegistryClose
WdfRegistryCreateKey
WdfRegistryOpenKey
WdfRegistryQueryMemory
WdfRegistryQueryMultiString
WdfRegistryQueryString
WdfRegistryQueryULong
WdfRegistryQueryUnicodeString
WdfRegistryQueryValue
WdfRegistryRemoveKey
WdfRegistryRemoveValue
WdfRegistryWdmGetHandle
WdfRequestAllocateTimer
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
Add ejection relations for IRP_MN_QUERY_DEVICE_RELATIONS (EjectionRelations)
Remove ejection relations for IRP_MN_QUERY_DEVICE_RELATIONS (EjectionRelations)
None
Add compatible ID in response to IRP_MN_QUERY_ID for BusQueryCompatibleIDs
IRP_MN_QUERY_DEVICE_TEXT
Add hardware ID in response to IRP_MN_QUERY_ID for BusQueryHardwareIDs
IoCreateDevice for a PDO
Supply device ID in response to IRP_MN_QUERY_ID for BusQueryDeviceID
Supply instance ID in response to IRP_MN_QUERY_ID for BusQueryInstanceID
Set PDEVICE_CAPABILITIES->RawDeviceOK
Set Parameters.QueryDeviceText.LocaleId for IRP_MN_QUERY_DEVICE_TEXT
None
Remove ejections relations for IRP_MN_QUERY_DEVICE_RELATIONS (EjectionRelations)
IoRequestDeviceEject
None
None
None
ZwSetValueKey for any type
ZwSetValueKey for REG_MULTI_SZ
ZwSetValueKey for REG_SZ
ZwSetValueKey for REG_DWORD
ZwSetValueKey for UNCODE_STRING
ZwSetValueKey for any type
ZwClose
ZwCreateKey
ZwOpenKey
ZwQueryValueKey for any type
ZwQueryValueKey for REG_MULTI_SZ
ZwQueryValueKey for REG_SZ
ZwQueryValueKey for REG_DWORD
ZwQueryValueKey for REG_SZ
ZwQueryValueKey for any type
ZwDeleteKey
ZwDeleteValueKey
Handle returned by ZwCreateKey or ZwOpenKey
The sequence:
Summary of KMDF and WDM Equivalents - 15
KMDF method
WdfRequestCancelSentRequest
WdfRequestChangeTarget
WdfRequestComplete
WdfRequestCompleteWithInformation
WdfRequestCompleteWithPriorityBoost
WdfRequestCreate
WdfRequestCreateFromIrp
WdfRequestFormatRequestUsingCurrentType
WdfRequestForwardToIoQueue
WdfRequestGetCompletionParams
WdfRequestGetFileObject
WdfRequestGetInformation
WdfRequestGetIoQueue
WdfRequestGetParameters
WdfRequestGetRequestorMode
WdfRequestGetStatus
WdfRequestIsCanceled
WdfRequestIsFrom32BitProcess
WdfRequestMarkCancelable
WdfRequestProbeAndLockUserBufferForRead
WdfRequestProbeAndLockUserBufferForWrite
WdfRequestRequeue
WdfRequestRetrieveInputBuffer
WdfRequestRetrieveInputMemory
WdfRequestRetrieveInputWdmMdl
WdfRequestRetrieveOutputBuffer
WdfRequestRetrieveOutputMemory
WdfRequestRetrieveOutputWdmMdl
WdfRequestRetrieveUnsafeUserInputBuffer
WdfRequestRetrieveUnsafeUserOutputBuffer
WdfRequestReuse
WdfRequestSend
WdfRequestSetCompletionRoutine
WdfRequestSetInformation
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
KeInitializeDpc
KeInitializeTimerEx to cancel an I/O request after a certain time period elapses
IoCancelIrp
None
IoCompleteRequest
IoCompleteRequest
IoCompleteRequest
IoAllocateIrp
None
IoCopyCurrentIrpStackLocationToNext
None
Value of PIO_STACK_LOCATION in IoCompletion routine
IoGetCurrentIrpStackLocation->FileObject
Irp->IoStatus.Information
None
IoGetCurrentIrpStackLocation
Irp->RequestorMode
Irp->IoStatus.Status
Irp->Cancel
IoIs32bitProcess
IoSetCancelRoutine
ProbeForRead
ProbeForWrite
None
For details, see “WDM Equivalents for KMDF Buffer Pointers,” later in this paper.
For details, see “Buffers for METHOD_NEITHER Requests,” later in this paper.
IoReuseIrp
IoCallDriver
IoSetCompletionRoutine
Supply Irp->IoStatus.Information
Summary of KMDF and WDM Equivalents - 16
KMDF method
WdfRequestStopAcknowledge
WdfRequestUnmarkCancelable
WdfRequestWdmGetIrp
WdfSpinLockRelease
WdfSpinLockAcquire
WdfSpinLockCreate
WdfStringCreate
WdfStringGetUnicodeString
WdfTimerGetParentObject
WdfTimerCreate
WdfTimerStart
WdfTimerStop
WdfUsbInterfaceGetConfiguredPipe
WdfUsbInterfaceGetConfiguredSettingIndex
WdfUsbInterfaceGetDescriptor
WdfUsbInterfaceGetEndpointInformation
WdfUsbInterfaceGetInterfaceNumber
WdfUsbInterfaceGetNumConfiguredPipes
WdfUsbInterfaceGetNumEndpoints
WdfUsbInterfaceGetNumSettings
WdfUsbInterfaceSelectSetting
WdfUsbTargetDeviceAllocAndQueryString
WdfUsbTargetDeviceCreate
WdfUsbTargetDeviceCyclePortSynchronously
WdfUsbTargetDeviceFormatRequestForControlTransfer
WdfUsbTargetDeviceFormatRequestForCyclePort
WdfUsbTargetDeviceFormatRequestForString
WdfUsbTargetDeviceFormatRequestForUrb
WdfUsbTargetDeviceGetDeviceDescriptor
WdfUsbTargetDeviceGetInterface
WdfUsbTargetDeviceGetNumInterfaces
WdfUsbTargetDeviceIsConnectedSynchronous
WdfUsbTargetDeviceQueryString
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
None
IoSetCancelRoutine with CancelRoutine set to NULL
PIRP
KeReleaseSpinLock
KeAcquireSpinLock
KeInitializeSpinLock
None
None
None
The sequence:
KeInitializeTimer
KeInitializeDpc
KeSetTimerEx
KeCancelTimer, then wait for the TimerDpc to run to completion
None
None
PUSB_INTERFACE_DESCRIPTOR
PUSB_ENDPOINT_DESCRIPTOR
PUSBD_INTERFACE_INFORMATION -> InterfaceNumber
PUSBD_INTERFACE_INFORMATION -> NumberOfPipes
PUSB_INTERFACE_DESCRIPTOR -> bNumEndpoints
Number of interfaces in the configuration descriptor that has the same InterfaceNumber
URB_FUNCTION_SELECT_INTERFACE
UsbBuildGetDescriptorRequest for DescriptorType USB_STRING_DESCRIPTOR_TYPE
Retrieve USB configuration descriptor and USB device descriptor
Send IOCTL_INTERNAL_USB_CYCLE_PORT
Set up _URB_HEADER for URB_FUNCTION_CONTROL_TRANSFER
Send IOCTL_INTERNAL_USB_CYCLE_PORT
Allocate a PURB to retrieve a USB_STRING_DESCRIPTOR
Allocate a PURB to send asynchronous I/O
None
USBD_ParseConfigurationDescriptorEx
USBD_ParseConfigurationDescriptorEx in a loop
Send IOCTL_INTERNAL_USB_GET_PORT_STATUS and check for
USBD_PORT_CONNECTED status
UsbBuildGetDescriptorRequest for USB_STRING_DESCRIPTOR_TYPE
Summary of KMDF and WDM Equivalents - 17
KMDF method
WdfUsbTargetDeviceResetPortSynchronously
WdfUsbTargetDeviceRetrieveConfigDescriptor
WdfUsbTargetDeviceRetrieveCurrentFrameNumber
WdfUsbTargetDeviceRetrieveInformation
WdfUsbTargetDeviceSelectConfig
WdfUsbTargetDeviceSendControlTransferSynchronously
WdfUsbTargetDeviceSendUrbSynchronously
WdfUsbTargetDeviceWdmGetConfigurationHandle
WdfUsbTargetPipeAbortSynchronously
WdfUsbTargetPipeConfigContinuousReader
WdfUsbTargetPipeFormatRequestForAbort
WdfUsbTargetPipeFormatRequestForRead
WdfUsbTargetPipeFormatRequestForReset
WdfUsbTargetPipeFormatRequestForUrb
WdfUsbTargetPipeFormatRequestForWrite
WdfUsbTargetPipeGetInformation
WdfUsbTargetPipeGetType
WdfUsbTargetPipeIsInEndpoint
WdfUsbTargetPipeIsOutEndpoint
WdfUsbTargetPipeReadSynchronously
WdfUsbTargetPipeResetSynchronously
WdfUsbTargetPipeSendUrbSynchronously
WdfUsbTargetPipeSetNoMaximumPacketSizeCheck
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
WDM equivalent
Send IOCTL_INTERNAL_USB_RESET_PORT
UsbBuildGetDescriptorRequest for USB_CONFIGURATION_DESCRIPTOR_TYPE
PUSB_BUSIFFN_QUERY_BUS_TIME
The sequence:
PUSB_BUSIFFN_GETUSBDI_VERSION
UsbBuildGetStatusRequest (GET_STATUS_FROM_DEVICE) for a
USB_CONFIGURATION_DESCRIPTOR
IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_GET_STATUS_FROM_DEVICE
PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_SELECT_CONFIGURATION
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_CONTROL_TRANSFER
Send IOCTL_INTERNAL_USB_SUBMIT_URB
URB_SELECT_CONFIGURATION -> ConfigurationHandle
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_ABORT_PIPE
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_ABORT_PIPE
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
Send IOCTL_INTERNAL_USB_RESET_PORT
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set by driver
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
USBD_PIPE_INFORMATION
PUSBD_PIPE_INFORMATION -> PipeType
USB_ENDPOINT_DIRECTION_IN
USB_ENDPOINT_DIRECTION_OUT
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_RESET_PIPE
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set by driver
None
Summary of KMDF and WDM Equivalents - 18
KMDF method
WdfUsbTargetPipeWdmGetPipeHandle
WdfUsbTargetPipeWriteSynchronously
WdfVerifierDbgBreakPoint
WdfVerifierKeBugCheck
WdfWaitLockAcquire
WdfWaitLockCreate
WdfWaitLockRelease
WdfWdmDeviceGetWdfDeviceHandle
WdfWdmDriverGetWdfDriverHandle
WdfWmiInstanceCreate
WdfWmiInstanceDeregister
WdfWmiInstanceGetDevice
WdfWmiInstanceGetProvider
WdfWmiInstanceRegister
WdfWmiProviderCreate
WdfWmiProviderGetDevice
WdfWmiProviderGetTracingHandle
WdfWmiProviderIsEnabled
WdfWmiInstanceFireEvent
WdfWorkItemCreate
WdfWorkItemEnqueue
WdfWorkItemFlush
WdfWorkItemGetParentObject
WDM equivalent
PUSBD_PIPE_INFORMATION -> PipeHandle
Send IOCTL_INTERNAL_USB_SUBMIT_URB with UrbHeader.Function set to
URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
DbgBreakPoint
KeBugCheck
The sequence:
KeEnterCriticalRegion
KeWaitForSingleObject
KeInitializeEvent
The sequence:
KeSetEvent
KeLeaveCriticalRegion
None
None
IoWmiRegistrationControl with Action parameter set to WMIREG_ACTION_REGISTER;
Handle IRP_MJ_SYSTEM_CONTROL requests for any of the following minor IRP codes:
IRP_MN_CHANGE_SINGLE_INSTANCE
IRP_MN_CHANGE_SINGLE_ITEM
IRP_MN_DISABLE_COLLECTION
IRP_MN_DISABLE_EVENTS
IRP_MN_ENABLE_COLLECTION
IRP_MN_ENABLE_EVENTS
IRP_MN_EXECUTE_METHOD
IRP_MN_QUERY_ALL_DATA
IRP_MN_QUERY_SINGLE_INSTANCE
IRP_MN_REGINFO
IRP_MN_REGINFO_EX
IoWmiWriteEvent
IoAllocateWorkItem
IoQueueWorkItem
KeWaitForSingleObject
None
WDM Equivalents for KMDF Buffer Pointers
KMDF supplies the following methods for retrieving I/O buffers for buffered and direct I/O:
WdfRequestRetrieveOutputBuffer
WdfRequestRetrieveOutputWdmMdl
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Summary of KMDF and WDM Equivalents - 19
WdfRequestRetrieveOuputMemory
WdfRequestRetrieveInputBuffer
WdfRequestRetrieveInputWdmMdl
WdfRequestRetrieveInputMemory
The following tables describe what the retrieval methods return for IRP_MJ_READ, IRP_MJ_WRITE, and IRP_MJ_DEVICE_CONTROL requests
for buffered and direct I/O. Requests for neither I/O require special handling because the driver must retrieve the buffers while running in the
context of the requesting user-mode process.
Buffers for IRP_MJ_READ Requests
To retrieve a buffer for a read request, a KMDF driver calls one of the WdfRequestRetrieveOutputXxx methods. The buffer that each of these
methods returns varies, depending on whether the driver performs buffered or direct I/O. Table 4 describes the pointer that is returned by each
method in WDM terms.
Table 4. WDM Equivalents for Buffer Pointers in Read Requests
Function
WdfRequestRetrieveOutputBuffer
WdfRequestRetrieveOutputWdmMdl
WdfRequestRetrieveOuputMemory
Buffered I/O
Irp->AssociatedIrp.SystemBuffer
Builds a memory descriptor list (MDL) for Irp->
AssociatedIrp.SystemBuffer and returns the MDL.
Returns a WDFMEMORY object. Call
WdfMemoryGetBuffer on this object to get
Irp-> AssociatedIrp.SystemBuffer.
Direct I/O
MmGetSystemAddressForMdlSafe (Irp->MdlAddress)
Irp->MdlAddress
Returns a WDFMEMORY object. Call
WdfMemoryGetBuffer on this object to get
MmGetSystemAddressForMdlSafe (Irp->MdlAddress).
Buffers for IRP_MJ_WRITE Requests
To retrieve a buffer for a write request, a KMDF driver calls one of the WdfRequestRetrieveInputXxx methods. The buffer that each of these
methods returns varies, depending on whether the driver performs buffered or direct I/O. Table 5 describes the pointer that is returned by each
method in WDM terms.
Table 5. WDM Equivalents for Buffer Pointers in Write Requests
Function
WdfRequestRetrieveInputBuffer
WdfRequestRetrieveInputWdmMdl
WdfRequestRetrieveInputMemory
Buffered I/O
Irp->AssociatedIrp.SystemBuffer
Builds an MDL for
Irp->AssociatedIrp.SystemBuffer and returns the MDL.
Returns a WDFMEMORY object. Call
WdfMemoryGetBuffer on this object to get
Irp-> AssociatedIrp.SystemBuffer.
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Direct I/O
MmGetSystemAddressForMdlSafe (Irp->MdlAddress)
Irp->MdlAddress
Returns a WDFMEMORY object. Call
WdfMemoryGetBuffer on this object to get
MmGetSystemAddressForMdlSafe (Irp->MdlAddress).
Summary of KMDF and WDM Equivalents - 20
Buffers for IRP_MJ_DEVICE_CONTROL Requests
To retrieve a buffer for a device I/O control request, a KMDF driver calls either WdfRequestRetrieveInputXxx or
WdfRequestRetrieveOutputXxx methods. The buffer that each of these methods returns varies, depending on whether the driver performs
buffered or direct I/O, as Table 6 shows.
Table 6. WDM Equivalents for Buffer Pointers in IOCTL Requests
Function
WdfRequestRetrieveInputBuffer
WdfRequestRetrieveInputWdmMdl
WdfRequestRetrieveInputMemory
WdfRequestRetrieveOutputBuffer
WdfRequestRetrieveOutputWdmMdl
WdfRequestRetrieveOutputMemory
Buffered I/O
Irp->AssociatedIrp.SystemBuffer
Builds an MDL for Irp-> AssociatedIrp.SystemBuffer
and returns the MDL.
Returns a WDFMEMORY object. Call
WdfMemoryGetBuffer on this object to get Irp->
AssociatedIrp.SystemBuffer
Irp->AssociatedIrp.SystemBuffer
Builds an MDL for
Irp-> AssociatedIrp.SystemBuffer and returns the MDL.
Returns a WDFMEMORY object. Call
WdfMemoryGetBuffer on this object to get Irp->
AssociatedIrp.SystemBuffer.
Direct I/O
MmGetSystemAddressForMdlSafe (Irp->MdlAddress)
Builds an MDL for Irp-> AssociatedIrp.SystemBuffer
and returns the MDL.
Returns a WDFMEMORY object. Call
WdfMemoryGetBuffer on this object to get
Irp-> AssociatedIrp.SystemBuffer
MmGetSystemAddressForMdlSafe (Irp->MdlAddress)
Irp->MdlAddress
Returns a WDFMEMORY object. Call
WdfMemoryGetBuffer on this object to get
MmGetSystemAddressForMdlSafe (Irp->MdlAddress)
Buffers for METHOD_NEITHER Requests
To perform METHOD_NEITHER I/O, a KMDF driver implements the EvtIoInCallerContext event callback function. The framework invokes this
function in the context of the thread that issued the I/O request. To retrieve the buffers, the driver calls:
WdfRequestRetrieveUnsafeUserInputBuffer to get a buffer for a write request.
WdfRequestRetrieveUnsafeUserOutputBuffer to get a buffer for a read request.
WdfRequestProbeAndLockUserBufferForRead to lock the user-mode buffer for reading.
WdfRequestProbeAndLockUserBufferForWrite to lock the user-mode buffer for writing.
For IRP_MJ_INTERNAL_DEVICE_CONTROL requests, which originate in kernel mode, a KMDF driver is not required to implement
EvtIoInCallerContext or to use WdfRetrieveUnsafeXxx and WdfRequestProbeAndLockUserBufferForXxx. Instead, the driver should call
WdfRequestRetrieveInputBuffer and WdfRequestRetrieveOutputBuffer to get the input and output buffers.
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Summary of KMDF and WDM Equivalents - 21
Table 7 lists what the buffer-retrieval methods return, in terms of the underlying IRP, for read, write, and device I/O control requests.
Table 7. WDM Equivalents for Buffer Pointers in METHOD_NEITHER I/O Requests
Request type
IRP_MJ_READ
IRP_MJ_WRITE
IRP_MJ_DEVICE_ CONTROL
IRP_MJ_INTERNAL_DEVICE_CONTROL
WdfRequestRetrieveUnsafeUserInputBuffer
STATUS_INVALID_DEVICE_REQUEST
Irp->UserBuffer
irpStack->Parameters.DeviceIoControl.Type3InputBuffer
Use WdfRequestRetrieveInputBuffer, which returns
irpStack->Parameters.DeviceIoControl.Type3InputBuffer
WdfRequestRetrieveUnsafeUserOutputBuffer
Irp->UserBuffer
STATUS_INVALID_DEVICE_REQUEST
Irp->UserBuffer
Use WdfRequestRetrieveOutputBuffer, which
returns Irp->UserBuffer
WDM IRPs and KMDF Event Callback Functions
KMDF supports a subset of Windows IRPs. Table 8 lists the major WDM IRP types and the corresponding KMDF event callback functions.
Table 8. WDM Major IRP Codes and KMDF Event Callback Functions
Major IRP code
IRP_MJ_CLEANUP
IRP_MJ_CLOSE
IRP_MJ_CREATE
IRP_MJ_CREATE_MAILSLOT
IRP_MJ_DEVICE_CHANGE
IRP_MJ_DEVICE_CONTROL
IRP_MJ_DIRECTORY_CONTROL
IRP_MJ_FILE_SYSTEM_CONTROL
IRP_MJ_FLUSH_BUFFERS
IRP_MJ_INTERNAL_DEVICE_CONTROL
IRP_MJ_LOCK_CONTROL
IRP_MJ_PNP
IRP_MJ_POWER
IRP_MJ_QUERY_EA
IRP_MJ_QUERY_INFORMATION
IRP_MJ_QUERY_QUOTA
IRP_MJ_QUERY_SECURITY
IRP_MJ_QUERY_VOLUME_INFORMATION
IRP_MJ_READ
IRP_MJ_SET_EA
IRP_MJ_SET_INFORMATION
IRP_MJ_SET_QUOTA
IRP_MJ_SET_SECURITY
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
KMDF event callback function
EvtFileCleanup
EvtFileClose
EvtDeviceFileCreate or EvtIoDefault
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
EvtIoDeviceControl or EvtIoDefault
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
EvtIoInternalDeviceControl or EvtIoDefault
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
Many; see “KMDF Callbacks for IRP_MJ_PNP,” later in this paper
Many; see “KMDF Callbacks for IRP_MJ_POWER,” later in this paper
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
EvtIoRead or EvtIoDefault
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
Summary of KMDF and WDM Equivalents - 22
Major IRP code
IRP_MJ_SET_VOLUME_INFORMATION
IRP_MJ_SHUTDOWN
IRP_MJ_SYSTEM_CONTROL
IRP_MJ_WRITE
KMDF event callback function
No direct support in KMDF; implement EvtDeviceWdmIrpPreprocess
For control device objects: EvtDeviceShutdownNotification
For all Plug and Play device objects: Not supported; implement EvtDeviceWdmIrpPreprocess
Create WDFWMIPROVIDER and WDFWMIINSTANCE objects and implement EvtWmiXxx callbacks
EvtIoWrite or EvtIoDefault
KMDF Callbacks for IRP_MJ_PNP
Table 9 lists, in order of execution, the KMDF callbacks that correspond to the minor IRP codes for IRP_MJ_PNP. The arrows indicate whether a
WDM FDO handles the IRP as it travels up or down the stack.
Note: In a KMDF driver, Plug and Play and power are integrated operations and the driver does not receive the individual minor IRP_MJ_PNP or
IRP_MJ_POWER requests. Instead, the framework calls a core set of callbacks at power up and a corresponding set at power down, and calls
additional callbacks before and after this core set as appropriate for each individual Plug and Play request. For comprehensive diagrams that
show the power-up and power-down sequences, see the companion paper, Porting a WDM Driver to KMDF.
Table 9. IRP_MJ_PNP Requests and Corresponding KMDF Callbacks
IRP_MJ_PNP minor code
↓IRP_MN_CANCEL_REMOVE_DEVICE
↓IRP_MN_CANCEL_STOP_DEVICE
↑IRP_MN_DEVICE_USAGE_NOTIFICATION
↓IRP_MN_EJECT
↓IRP_MN_FILTER_RESOURCE_REQUIREMENTS
↑IRP_MN_FILTER_RESOURCE_REQUIREMENTS
IRP_MN_QUERY_BUS_INFORMATION
IRP_MN_QUERY_CAPABILITIES
↓IRP_MN_QUERY_DEVICE_RELATIONS
(bus, removal, and ejection relations)
IRP_MN_QUERY_DEVICE_TEXT
IRP_MN_QUERY_ID
↓IRP_MN_QUERY_INTERFACE
IRP_MN_QUERY_PNP_DEVICE_STATE
↓IRP_MN_QUERY_REMOVE_DEVICE
↓IRP_MN_QUERY_RESOURCE_REQUIREMENTS
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
KMDF callbacks
None
None
EvtDeviceUsageNotification
EvtDeviceEject
EvtDeviceFilterRemoveResourceRequirements
EvtDeviceFilterAddResourceRequirements
None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so
that the framework can respond to this query on its own without notifying the driver.
None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so
that the framework can respond to this query on its own without notifying the driver.
EvtDeviceRelationsQuery
None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so
that the framework can respond to this query on its own without notifying the driver.
None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so
that the framework can respond to this query on its own without notifying the driver.
EvtDeviceProcessQueryInterfaceRequest
None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so
that the framework can respond to this query on its own without notifying the driver.
EvtDeviceQueryRemove
EvtDeviceResourceRequirementsQuery
Summary of KMDF and WDM Equivalents - 23
IRP_MJ_PNP minor code
↓IRP_MN_QUERY_RESOURCES
↓IRP_MN_QUERY_STOP_DEVICE
IRP_MN_READ_CONFIG
↓IRP_MN_REMOVE_DEVICE
↓IRP_MN_SET_LOCK
↑IRP_MN_START_DEVICE
KMDF callbacks
EvtDeviceResourcesQuery
EvtDeviceQueryStop
None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so
that the framework can respond to this query on its own without notifying the driver.
After IRP_MN_QUERY_REMOVE_DEVICE:
EvtDeviceSelfManagedIoSuspend
EvtIoStop (WdfRequestStopActionSuspend)
EvtDmaEnablerSelfManagedIoStop
EvtDmaEnablerDisable
EvtDmaEnablerFlush
EvtDeviceD0ExitPreInterruptsDisabled
EvtInterruptDisable
EvtDeviceD0Exit (WdfPowerDeviceD3Final)
EvtReleaseHardware
EvtIoStop (WdfRequestStopActionPurge) for power managed queues
EvtDeviceSelfManagedIoFlush
EvtIoStop (WdfRequestStopActionPurge) for non-power managed queues
EvtDeviceSelfManagedIoCleanup
EvtCleanupCallback for WDFDEVICE
EvtDestroyCallback for WDFDEVICE
After IRP_MN_SURPRISE_REMOVAL:
EvtIoStop (WdfRequestStopActionPurge) for non-power managed queues
EvtDeviceSelfManagedIoCleanup
EvtCleanupCallback for WDFDEVICE
EvtDestroyCallback for WDFDEVICE
EvtDeviceSetLock
After enumeration:
EvtDeviceRemoveAddedResources
EvtPrepareHardware
EvtDeviceD0Entry
EvtInterruptEnable
EvtDeviceD0EntryPostInterruptsEnabled
EvtDmaEnablerFill
EvtDmaEnablerEnable
EvtDmaEnablerSelfManagedIoStart
EvtDeviceArmWakeFromS0 or EvtDeviceArmWakeFromSx
EvtDeviceSelfManagedIoInit
After IRP_MN_STOP_DEVICE:
EvtDeviceRemoveAddedResources
EvtPrepareHardware
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Summary of KMDF and WDM Equivalents - 24
IRP_MJ_PNP minor code
KMDF callbacks
EvtDeviceD0Entry
EvtInterruptEnable
EvtDeviceD0EntryPostInterruptsEnabled
EvtDmaEnablerFill
EvtDmaEnablerEnable
EvtDmaEnablerSelfManagedIoStart
EvtDeviceArmWakeFromS0 or EvtDeviceArmWakeFromSx
EvtIoResume
EvtDeviceSelfManagedIoRestart
↓IRP_MN_STOP_DEVICE
↓IRP_MN_SURPRISE_REMOVAL
EvtReleaseHardware
EvtDeviceSurpriseRemoval
EvtDeviceSelfManagedIoSuspend
EvtIoStop (WdfRequestStopActionSuspend)
EvtDmaEnablerSelfManagedIoStop
EvtDmaEnablerDisable
EvtDmaEnablerFlush
EvtDeviceD0ExitPreInterruptsDisabled
EvtInterruptDisable
EvtDeviceD0Exit (WdfPowerDeviceD3Final)
EvtReleaseHardware
EvtIoStop (WdfRequestStopActionPurge) for power managed queues
EvtDeviceSelfManagedIoFlush
None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so
that the framework can respond to these queries on its own without notifying the driver.
IRP_MN_WRITE_CONFIG
KMDF Callbacks for IRP_MJ_POWER
Table 10 lists, in order of execution, the KMDF callbacks that correspond to the minor IRP codes for IRP_MJ_POWER. The arrows indicate
whether a WDM FDO handles the IRP as it travels up or down the stack.
Note: In a KMDF driver, Plug and Play and power are integrated operations and the driver does not receive the individual minor IRP_MJ_PNP or
IRP_MJ_POWER requests. Instead, the framework calls a core set of callbacks at power up and a corresponding set at power down, and calls
additional callbacks before and after this core set as appropriate for each individual Plug and Play request. For comprehensive diagrams that
show the power-up and power-down sequences, see the companion paper, Porting a WDM Driver to KMDF.
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Summary of KMDF and WDM Equivalents - 25
Table 10. IRP_MJ_POWER Requests and Corresponding KMDF Callbacks
IRP_MJ_POWER minor code
↓IRP_MN_SET_POWER for D1, D2, or D3 (power down)
↑IRP_MN_SET_POWER for D0
(power up)
↓IRP_MN_SET_POWER for Sx
↑IRP_MN_SET_POWER for Sx
IRP_MN_POWER_SEQUENCE
↓IRP_MN_WAIT_WAKE
↑IRP_MN_WAIT_WAKE
Framework callbacks
EvtDeviceSelfManagedIoSuspend
EvtIoStop (WdfRequestStopActionSuspend)
EvtDeviceArmWakeFromS0 or EvtDeviceArmWakeFromSx
EvtDmaEnablerSelfManagedIoStop
EvtDmaEnablerDisable
EvtDmaEnablerFlush
EvtDeviceD0ExitPreInterruptsDisabled
EvtInterruptDisable
EvtDeviceD0Exit
EvtDeviceD0Entry
EvtInterruptEnable
EvtDeviceD0EntryPostInterruptsEnabled
EvtDmaEnablerFill
EvtDmaEnablerEnable
EvtDmaEnablerSelfManagedIoStart
EvtIoResume
EvtDeviceSelfManagedIoRestart
None
None
None
EvtDeviceEnableWakeAtBus
EvtDeviceDisableWakeAtBus
Resources
Windows Driver Foundation (WDF) on the WHDC Web site
http://www.microsoft.com/whdc/driver/wdf/default.mspx
Current White Papers
Porting a Driver from WDM to KMDF
http://www.microsoft.com/whdc/driver/wdf/WDF_Port.mspx
Architecture of the Kernel-Mode Driver Framework
http://www.microsoft.com/whdc/driver/wdf/kmdf-arch.mspx
Sample Drivers for the Kernel-Mode Driver Framework
http://www.microsoft.com/whdc/driver/wdf/KMDF-samp.mspx
Introduction to Plug and Play and Power Management in the Windows Driver Foundation
http://www.microsoft.com/whdc/driver/wdf/WDF_pnpPower.mspx
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
Summary of KMDF and WDM Equivalents - 26
DMA Support in Windows Drivers
http://www.microsoft.com/whdc/driver/kernel/dma.mspx
I/O Request Flow in WDF Kernel-Mode Drivers
http://www.microsoft.com/whdc/driver/wdf/ioreq_flow.mspx
Windows Driver Kit (WDK)
Kernel-Mode Driver Framework Design Guide
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/kmdf_d/hh/KMDF_d/Ch0_DFArchOverview_2f03cf4c-72b3-4af5-ad000ea37c69bbbf.xml.asp
Kernel-Mode Driver Framework Reference
http://msdn.microsoft.com/library/en-us/KMDF_r/hh/KMDF_r/DFRef_da43cbdb-35fa-4c6f-b288-5bca10785390.xml.asp
September 7, 2006
© 2006 Microsoft Corporation. All rights reserved.
© Copyright 2025 Paperzz