1, 安裝WDK,啟動編譯環境,Checked用於調試相當於VC中的Debug,Free用於發布和正式使用相當於VC中的Release。
注*配置命令列視窗的寬度 - 1,註冊表 “HKEY_CURRENT_USER/Console/ScreenBufferSize” 或者2,CMD視窗 “屬性->布局->螢幕緩衝區大小”
*查看環境變數 - 命令列輸入“SET”, 沒有參數
2, 設定檔說明 makefile, Sources 和 dirs
makefile:
# makefile<br />#<br /># DO NOT EDIT THIS FILE!!! Edit ./sources. If you want to add a new source<br /># file to this component. This file merely indirects to the real make file<br /># that is shared by all the driver components of the Windows NT DDK<br />#<br />!INCLUDE $(NTMAKEENV)/makefile.def
注 * NTMAKEENV 可以在環境變數中找到, eg: NTMAKEENV=C:/WinDDK/7600.16385.1/bin
Sources:
TARGETNAME=HelloDDK<br />TARGETTYPE=DRIVER<br />TARGETPATH=OBJ<br />INCLUDES=$(BASEDIR)/inc;/<br /> $(BASEDIR)/inc/ddk;/<br />SOURCES=Driver.cpp/
注 *TARGETTYPE=DRIVER 表示編譯驅動程式, TARGETTYPE=PROGRAM 表示編譯Win32程式
SOURCES 中只需要包含.c/.cpp檔案,不要包含標頭檔
dirs:
D:/WinDDK/7600.16385.1/src>type dirs<br />DIRS= /<br /> 1394 /<br /> audio /<br /> AVStream /<br /> biometrics /<br /> bth /<br /> filesys /<br /> general /<br /> hid /<br /> input /<br /> ir /<br /> mmedia /<br /> network /<br /> print /<br /> sd /<br /> SensorsAndLocation /<br /> serial /<br /> setup /<br /> sideshow /<br /> smartcrd /<br /> storage /<br /> swtuner /<br /> test /<br /> usb /<br /> video /<br /> videocap /<br /> wia /<br /> wmi /<br /> wpd
注 *此檔案表示需要依次編譯的目錄
3, 使用 build.exe 編譯代碼
4, Virtual PC
Settings
COM1 - Named Pipe - //./pipe/com_1
Windows XP SP3, boot.ini
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)/WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)/WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
multi(0)disk(0)rdisk(0)partition(1)/WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect /debug /debugport=com1 /baudrate=115200
注 * 紅色字型表示的串口編號要一致
5, WinDBG
捷徑 - target
eg:C:/WinDDK/7600.16385.1/Debuggers/windbg.exe -y C:/localSymbols;srv*C:/localSymbols*http://msdl.microsoft.com/download/symbols -k com:pipe,port=//./pipe/com_1 -Q
注 * 藍色字型表示的具名管道名稱要一致