Develop and Build Drives by Visual C++ IDE
Step 0. Requirement DDK Visual C++ 6.0 or Visual C++ .NET
Step 1. Set Environment Variable 設定環境變數 DDKROOT DDKROOT = WINDDK所在的路徑
Step 2. Mkdir DriverEnv 建立目錄 DriverEnv(名稱隨意)作為開發驅動程式的大本營
Step 3. MakeDrvr.bat 在DrivrEnv目錄下建立一個批次檔MakeDrvr.bat,內容如下: @echo off if "%1"=="" goto usage if "%3"=="" goto usage if not exist %1\bin\setenv.bat goto usage call %1\bin\setenv %1 %4 %2 cd %3 build -b -w %5 %6 %7 %8 %9 goto exit :usage echo usage MakeDrvr DDK_Dir Driver_Drive Driver_Dir fre/chk [build_options] echo eg MakeDrvr %%DDKROOT%% E: DriverEnv\DriverBuildSample chk -cef :exit
Step 4. New Makefile Project
Step 5. Modify Project Setting [專案] [屬性] 開啟專案的屬性頁
Step 5. Modify Project Setting 先修改 Win32 Debug 的 Project Setting
Step 5. Modify Project Setting 在建置命令列(Build Command Line)一欄填入: MakeDrvr %DDKROOT% E: $(SolutionDir) chk -cef
Step 5. Modify Project Setting 在建置命令列(Build Command Line)一欄填入: MakeDrvr %DDKROOT% E: $(SolutionDir) chk -cef WINDDK所在的PATH,即Step 1所設的環境變數
Step 5. Modify Project Setting 在建置命令列(Build Command Line)一欄填入: MakeDrvr %DDKROOT% E: $(SolutionDir) chk -cef 欲建置的Driver檔案所在的磁碟機
Step 5. Modify Project Setting 在建置命令列(Build Command Line)一欄填入: MakeDrvr %DDKROOT% E: $(SolutionDir) chk -cef 欲建置的Driver檔案所在的資料夾完整路徑
Step 5. Modify Project Setting 在建置命令列(Build Command Line)一欄填入: MakeDrvr %DDKROOT% E: $(SolutionDir) chk -cef 欲建置的Driver版本為FREE/CHECKED BUILD
Step 5. Modify Project Setting 在建置命令列(Build Command Line)一欄填入: MakeDrvr %DDKROOT% E: $(SolutionDir) chk -cef BUILD Options,參考DDK文件中有關Build Utility的部分
Step 5. Modify Project Setting 在重建命令列(Rebuild all options)一欄填入: -nmake /a
Step 5. Modify Project Setting 在輸出(output file)一欄填與sources文件中的 TARGETNAME相同的設定值
Step 6. Add Source Files 可以新建立檔案或加入以存在的檔案(可將HELLOWDM的檔案引入以供測試)
Step 7. makefile 將makefile檔放入專案目錄中,makefile的內容如下: # # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source # file to this component. This file merely indirects to the real make file # that is shared by all the driver components of the Windows NT DDK !INCLUDE $(NTMAKEENV)\makefile.def
Step 8. sources file 將sources檔加入專案目錄中,其內容為: TARGETNAME=HELLOWDM TARGETPATH=obj TARGETTYPE=DRIVER SOURCES= HelloWdm.cpp
Step 9. MakeDrvr 因為MakeDrvr.bat在DriverEnv目錄下,所以應該把DriverEnv加到 VC的可執行檔設定中
Step 10. Build Driver
Step 10. Build Driver