Developing Drivers with the Windows Driver Foundation (Pro Developer)

UMDF and KMDF drivers are installed in exactly the same way-a user typically is not even aware of the difference. However, significant differences in the installation process for the two types of driver occur without the user being aware, controlled largely by the driver package's INF.

This section discusses examples of typical UMDF and KMDF co-installer sections from the INFs for Fx2_Driver and Osrusbfx2.

UMDF Example: The Fx2_Driver INF

The example in Listing 20-4 contains the co-installer sections from the Fx2_Driver INF created for an x86 build of the driver. The sections and important directives are summarized after the example.

Listing 20-4: Fx2_Driver INF co-installer sections

[OsrUsb_Install.NT] CopyFiles=UMDriverCopy Include=WINUSB.INF; Import sections from WINUSB.INF Needs=WINUSB.NT; Run the CopyFiles & AddReg directives for WinUsb.INF [OsrUsb_Install.NT.hw] AddReg=OsrUsb_Device_AddReg [OsrUsb_Install.NT.Services] AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall AddService=WinUsb,0x000001f8,WinUsb_ServiceInstall [OsrUsb_Install.NT.Wdf] KmdfService=WINUSB, WinUsb_Install UmdfDispatcher=WinUsb UmdfService=WUDFOsrUsbFx2, WUDFOsrUsbFx2_Install UmdfServiceOrder=WUDFOsrUsbFx2 [OsrUsb_Install.NT.CoInstallers] AddReg=CoInstallers_AddReg CopyFiles=CoInstallers_CopyFiles [WinUsb_Install] KmdfLibraryVersion = 1.5 [WUDFOsrUsbFx2_Install] UmdfLibraryVersion=1.5.0 DriverCLSID = "{}" ServiceBinary = "%12%\UMDF\WUDFOsrUsbFx2.dll" [OsrUsb_Device_AddReg] HKR,,"LowerFilters",0x00010008,"WinUsb" ; FLG_ADDREG_TYPE_MULTI_SZ | FLG_ADDREG_APPEND [WUDFRD_ServiceInstall] DisplayName = %WudfRdDisplayName% ServiceType = 1 StartType = 3 ErrorControl = 1 ServiceBinary = %12%\WUDFRd.sys LoadOrderGroup = Base [WinUsb_ServiceInstall] DisplayName = %WinUsb_SvcDesc% ServiceType = 1 StartType = 3 ErrorControl = 1 ServiceBinary = %12%\WinUSB.sys [CoInstallers_AddReg] HKR,,CoInstallers32,0x00010000,"WudfUpdate_01005.dll","WdfCoInstaller01005.dll, WdfCoInstaller","WinUsbCoinstaller.dll" [CoInstallers_CopyFiles] WudfUpdate_01005.dll WdfCoInstaller01005.dll WinUsbCoinstaller.dll [DestinationDirs] UMDriverCopy=12,UMDF ; copy to driversMdf Coinstallers_CopyFiles=11 [UMDriverCopy] WUDFOsrUsbFx2.dll

Important 

The INF file produced by the Fx2_Driver sample in the version of the WDK released with Windows Vista cannot be used to install the driver on Windows XP. The following example has the correct directives. See "Developing Drivers with the Windows Driver Foundation" on the WHDC Web site for information about updates for this sample- online at http://go.microsoft.com/fwlink/?LinkId=80911.

This part of the INF has several sections. Most sections are used by all UMDF drivers, but several sections are related to installing the kernel-mode WinUSB service, which is required for UMDF USB drivers. Other types of drivers do not need those sections. The following list shows the key sections and their directives:

KMDF Example: The Osrusbfx2 INF

The example in Listing 20-5 shows the co-installer portion of the Osrusbfx2 INF. The sections and important directives are summarized after this example.

Listing 20-5: Osrusbfx2 INF co-installer sections

[DestinationDirs] Coinstaller_CopyFiles = 11 [osrusbfx2.Dev.NT.Coinstallers] AddReg=Coinstaller_AddReg CopyFiles=Coinstaller_CopyFiles [Coinstaller_CopyFiles] wdfcoinstaller01005.dll [SourceDisksFiles] wdfcoinstaller01005.dll=1 [Coinstaller_AddReg] HKR,,Coinstallers32,0x00010000, "wdfcoinstaller01005.dll,WdfCoinstaller" [osrusbfx2.Dev.NT.Wdf] KmdfService = osrusbfx2, osrusbfx2_wdfsect [osrusbfx2_wdfsect] KmdfLibraryVersion = 1.5

The following list describes the sections:

Категории