在 INF 檔案中指定反映器
從Windows 11開始,將反映器 (WUDFRd.sys) 新增至核心模式裝置堆疊的建議方式是參考 UMDF 驅動程式 INF 檔案中的系統提供的 WudfRd.inf 檔案。
注意
WudfRd.inf 僅包含Windows 11和更新版本。
在Windows 10和更早版本上,若要新增反映器 (WUDFRd.sys) ,UMDF 驅動程式的INF 檔案必須在 INF DDInstall.Services 區段以及 service-install-section 中包含AddService 指示詞。 雖然此方法仍可在Windows 11和更新版本上運作,但不建議這麼做。
在這兩種方法中,反映器可以是上層篩選準則、較低篩選或裝置的服務,視使用者模式堆疊的組態而定。
參考 WudfRd.inf (Windows 11及更新版本)
您可以在 echoum.inx找到使用此技術的範例 INF。 或者,請使用下列其中一個程式碼片段。
若要將 WudfRd 服務安裝為裝置的函式驅動程式:
[DDInstall]
Include=WUDFRD.inf
Needs=WUDFRD.NT
; also include any existing DDInstall directives
[DDInstall.HW]
Include=WUDFRD.inf
Needs=WUDFRD.NT.HW
; also include any existing DDInstall.HW directives
[DDInstall.Services]
Include=WUDFRD.inf
Needs=WUDFRD.NT.Services
; also include any existing any DDInstall.Services directives
若要將 WudfRd 服務安裝為上限篩選驅動程式:
[DDInstall]
Include=WUDFRD.inf
Needs=WUDFRD_UpperFilter.NT
; also include any existing DDInstall directives
[DDInstall.HW]
Include=WUDFRD.inf
Needs=WUDFRD_UpperFilter.NT.HW
; also include any existing DDInstall.HW directives
[DDInstall.Services]
Include=WUDFRD.inf
Needs=WUDFRD_UpperFilter.NT.Services
; also include any existing any DDInstall.Services directives
[DDInstall.Filters]
Include=WUDFRD.inf
Needs=WUDFRD_UpperFilter.NT.Filters
若要將 WudfRd 服務安裝為較低的篩選驅動程式:
[DDInstall]
Include=WUDFRD.inf
Needs=WUDFRD_LowerFilter.NT
; also include any existing DDInstall directives
[DDInstall.HW]
Include=WUDFRD.inf
Needs=WUDFRD_LowerFilter.NT.HW
; also include any existing DDInstall.HW directives
[DDInstall.Services]
Include=WUDFRD.inf
Needs=WUDFRD_LowerFilter.NT.Services
; also include any existing any DDInstall.Services directives
[DDInstall.Filters]
Include=WUDFRD.inf
Needs=WUDFRD_LowerFilter.NT.Filters
使用 AddService 指示詞 (Windows 10和先前的)
下列程式碼範例示範 UMDF 函式驅動程式的 INF 檔案如何新增反映器。
[Skeleton_Install.Services]
AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall
在此範例中,驅動程式會將 0x2 (SPSVCINST_ASSOCSERVICE) 旗標 (ORed 指定到上述 flags 參數中,) 將反映器指派為核心模式裝置堆疊中的函式驅動程式。
AddService指示詞也會設定0x000001f8旗標,以防止覆寫服務的任何預先存在組態。 如需這些旗標的詳細資訊,請參閱AddService 指示詞的flags參數。
下列程式碼範例取自 WUDFVhidmini 範例,會顯示 UMDF 篩選驅動程式的 AddService 指示詞。
[hidumdf.win8.NT.Services]
AddService=WUDFRd,0x000001f8,WUDFRD_ServiceInstall
AddService=mshidumdf, 0x000001fa, mshidumdf.AddService
[WudfVhidmini_AddReg]
HKR,,"LowerFilters",0x00010008,"WUDFRd" ; FLG_ADDREG_TYPE_MULTI_SZ | FLG_ADDREG_APPEND
在此情況下,mshidumdf 服務會與裝置堆疊的 FDO 相關聯,而反映器是較低的篩選準則。
提供 service-install-section
AddService指示詞會參考類似下列程式碼範例的 service-install-section。 ServiceType專案指定 1 或 0x00000001,表示 INF 會安裝一或多個裝置的支援。 StartType專案會指定何時啟動驅動程式。 ErrorControl專案會指定驅動程式所提供的錯誤控制項層級。 ServiceBinary專案會指定服務之二進位 (反映器) 的路徑。
[WUDFRD_ServiceInstall]
DisplayName = "Windows Driver Frameworks - User-mode Driver Framework Reflector"
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\WUDFRd.sys