Windows Driver Frameworks

Windows Driver Frameworks(Windows驱动程序框架,簡稱WDF,前称Windows Driver Foundation),是微軟公司所提供的驅動程式開發技術的集合,包括Kernel-Mode Driver Framework(核心模式驅動程式架構,KMDF)、User-Mode Driver Framework(使用者模式驅動程式架構,UMDF)以及PREfast plug-in for Drivers(PFD),目的是要改善目前Windows平台的驅動程式品質,可支援Windows 2000、Windows XP、Windows Server 2003、Windows Vista、Windows Server 2008和Windows 7,以及更新的作業系統上之最新驅動程式架構。WDF架構提供了非同步輸入輸出、分層式驅動程式、隨插即用(PNP)、電源管理(Power Management),以及Windows管理規範(Windows Management Instrumentation,WMI)等功能。

User-Mode Driver Framework

用户模式驱动程序框架(User-Mode Driver Framework)是内核模式驱动程序框架(Kernel-Mode Driver Framework)的子集合,提供即插即用(PNP)、电源管理(Power Manager)、异步输入输出等功能。

Kernel-Mode Driver Framework

Kernel-Mode Driver Framework(核心模式驅動程式架構,簡稱KMDF),是美國微軟公司推出的視窗驅動程式基礎(Windows Driver Foundation)之一,建構Windows XP與Windows Server 2003的核心模式(Kernel-Mode)驅動程式所需的基本功能,包括對隨插即用(PNP)、電源管理(Power Manager)、I/O佇列、直接記憶體存取(DMA)、Windows Management Instrumentation(WMI)和同步處理等的完整支援。KMDF的設計並不能用來取代WDM,它提供「Skeletal WDM」(一個骨架)建置來替代WDM;目前,KMDF並不支援匯流排篩選驅動程式(Bus Filter Driver)。

PREfast

PREfast(Prefast.exe)是靜態的原始碼分析工具(static source code analysis tool),可偵測原始程式碼中不易用一般編譯器找到的特定類型錯誤,目前已整合至Visual Studio 2005 Team Suite中,使用時只要設定‘Enable Code Analysis For C/C++’為Yes即可。

PREfast的工作

  • 變數未初始化
 void init() {
     int a;
     int b;
     b = a;
 }
  • 運算元優先權的問題
 void priority() {
     int a = 1;
     int b = 1;
     int c = 1;
     if(a & b == c)
        return ;
 }
  • 記憶體溢位問題
 void overrun() {
      char buf[100];
     char buf2[200];
     int  i = 100;
 
     sprintf(buf, "size%d" , i);
     strcpy(buf, buf2);
 }

Kernel-Mode Code Signing

微軟提供測試時期的類別簽章認證,可以讓使用者產生所需要的CER檔與CAT檔。

首先,使用文字編輯器建立一個 .cdf 檔案,包含要加入目錄的檔案及其屬性的清單。

 [CatalogHeader]
 Name=Good.cat
 PublicVersion=0x0000001
 EncodingType=0x00010001
 CATATTR1=0x10010001:OSAttr:2:6.0
 
 [CatalogFiles]
 ...
  • 產生一個cer檔
 makecert -pe -ss PrivateCertStore -n CN=Contoso.com(Test) ContosoTest.cer

makecert.exe 可制作cer格式的证书,即X.509证书。

  • 產生一個cat檔
 MakeCat -v Good.cdf
 Signability.exe /auto /cat /driver:package_directory /os:512
  • 產生cat檔簽證
 SignTool sign /v /ac CrossCertificateFile /s SPCCertificateStore /n SPCSubjectName /t
 http://timestamp.verisign.com/scripts/timestamp.dll Good.cat
  • 安裝簽證過的cat檔

使用CryptCATAdminAddCatalog API

  • 驗證
 Signtool verify /kp /c tstamd64.cat toaster.sys

相關條目

  • Windows Driver Model
  • KMDF
  • UMDF

外部連結

  • Kernel-Mode Code Signing Walkthrough (页面存档备份,存于互联网档案馆
  • Windows Driver Foundation Homepage
  • Windows Driver Kit
  • [1] OSR Online, including many articles about WDF, KMDF, and Windows driver development.
  • Introducing Windows Driver Framework,written by well-known Windows driver developer, Walter Oney.
  • Building and deploying a basic WDF Kernel Mode Driver,CodeProject
  • Developing a WDF USB Kernel Mode Driver for the OSR USB FX2,CodeProject
圖形介面
音樂與音效
多媒體
Web
資料存取
網路
通訊
  • 訊息API英语Messaging Application Programming Interface
  • 電話API
  • WCF
管理
元件與模型
函式庫
驱动程序
安全性
.NET
软件工廠
  • EFx Factory英语EFx Factory
  • Enterprise Library英语Microsoft Enterprise Library
  • 複合使用者介面英语Composite UI Application Block
  • CCF英语Microsoft Customer Care Framework
  • CSF英语Microsoft Connected Services Framework
行程間通訊
可協助性
  • Active Accessibility英语Microsoft Active Accessibility
  • 使用者介面自動化英语Microsoft UI Automation
文字與多語系支援
  • DirectWrite
  • 文本服务框架英语Text Services Framework
  • 文本对象模型英语Text Object Model
  • 输入法编辑器
  • 語言介面套件英语Language Interface Pack
  • 多語系使用者介面英语Multilingual User Interface
  • Uniscribe
遊戲開發