[Windows] 用 DDK 7.1 來編譯 Windows 程式

[Windows] 用 DDK 7.1 來編譯 Windows 程式

同樣是為了 Inside Windows Debugging 的讀書會,

上次安裝了 Windows SDK,不過發現原來還要安裝 DDK (Driver Development Kit),

才能編譯書上附的一些程式碼… 就順便記錄一下步驟吧~

 

1. 下載 DDK 7.1

到 Windows Driver Kit Version 7.1.0 這邊下載,

抓回來的是一個 GRMWDK_EN_7600_1.ISO,大約有六百多 MB~

 

2. 安裝 DDK

用 WinCDEmu 之類的軟體將 ISO 檔掛載起來,執行 KitSetup.exe~

這邊要特別注意不要用 SMB 的方式遠端掛載 ISO 檔,這樣安裝會失敗:

2015-12-14 23_44_35

 

設定安裝路徑:

2015-12-14 23_44_41

 

看一下 License agreement…

2015-12-14 23_54_53

 

一下子就可以裝好了:

2015-12-15 00_08_30  

 

3. 初始化 DDK 

到 DDK 的 bin 目錄下,執行 setenv.bat 做初始化設定:

C:WinDDK7600.16385.1bin>setenv.bat C:WinDDK7600.16385.1
Launching OACR monitor
Starting dirs creation...Completed.

 

4. 使用 DDK 編譯程式 

以 Inside Windows Debugging 的 sample code 為例,

進到程式的目錄裡後,執行 build 就能編譯那個程式:

C:BookCodechapter_02HelloWorld>build
BUILD: Compile and Link for x86
BUILD: Computing Include file dependencies:
BUILD: Start time: Tue Dec 15 00:16:07 2015
BUILD: Examining c:bookcodechapter_02helloworld directory for files to compile.
BUILD: Saving c:winddk7600.16385.1build.dat...
BUILD: Compiling and Linking c:bookcodechapter_02helloworld directory
Configuring OACR for 'root:x86fre' - <OACR on>
Dec 15 00:16:18 oacr.dll  OACR version change (from build '0' to '30122')
Compiling - main.cpp
Linking Executable - .objbookcodechapter_02helloworldobjfre_win7_x86i386h
elloworld.exe
BUILD: Finish time: Tue Dec 15 00:16:20 2015
BUILD: Done
3 files compiled - 38 LPS
1 executable built

 

甚至可以執行 bcz 這個指令,一次將子目錄的所有程式都編譯好

(這個 bcz 指令是個用 doskey 作出來的巨集指令,相當於 build -cZMg)

C:BookCode>bcz
BUILD: Compile and Link for x86
BUILD: Start time: Tue Dec 15 00:16:32 2015
BUILD: Examining c:bookcode directory tree for files to compile.
BUILD: Compiling c:bookcodechapter_07breakondllload directory
Configuring OACR for 'root:x86fre' - <OACR on>
Compiling - chapter_07breakondllloadmain.cpp
......
Compiling - toolsdllhostmain.cpp
Linking Executable - toolsdllhost.objbookcodetoolsdllhostobjfre_win7_x86
i386host.exe
BUILD: Finish time: Tue Dec 15 00:16:53 2015
BUILD: Done
111 files compiled
6 libraries built
37 executables built

 

(本頁面已被瀏覽過 2,695 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料