天天看點

Windbg核心調試之一: Vista Boot Config設定

Windbg進行核心調試,需要一些基本的技巧和設定,在這個系列文章中,我将使用Windbg過程中所遇到的一些問題和經驗記錄下來,算是對Kernel調試的一個總結,同時也是學習Windows系統核心的另一種過程。

很多人說Windbg不如SoftIce好用, 但是我使用過程中還是覺得Windbg能更好的反映系統狀态, 而且相比SoftIce, Windbg更穩定(雖然它的部分操作略顯複雜), 下面介紹Windbg的Kernel模式調試第一部分: 雙機連接配接設定.

Vista和XP不同, 沒有boot.ini檔案, 需要用bcdedit進行啟動設定。(關于啟動資料配置編輯器BCD的具體設定, 參見另一篇文章: (From MS)Vista: 啟動配置資料編輯器(BCD))

在administrator權限下, 進入command line模式,  鍵入bcdedit指令, 會出現以下界面:

Windbg核心調試之一: Vista Boot Config設定

然後, 設定端口COM1, baudrate為115200 (除COM1外, 也可以用1394或USB. 1394用起來比COM口快多了, 當然前提是你需要有1394卡及其驅動. 很惡心的是Vista不再支援1394的檔案傳輸協定, 但是用windbg雙機調試還是可以的)

指令為:

bcdedit /dbgsettings {serial [baudrate:value][debugport:value] | 1394 [channel:value] | usb }

Windbg核心調試之一: Vista Boot Config設定

接着, 我們需要複制一個開機選項, 以進入OS的debug模式

bcdedit /copy {current} /d DebugPoint

DebugPoint為選項名稱, 名字可以自己定義. 然後複制得到的ID号. 

Windbg核心調試之一: Vista Boot Config設定

接着增加一個新的選項到引導菜單

bcdedit /displayorder {current} {ID}

這裡的{ID}的ID值是剛生成的ID值.

Windbg核心調試之一: Vista Boot Config設定

激活DEBUG : bcdedit /debug {ID} ON

這裡的{ID} 的ID值還是剛才的ID值.

Windbg核心調試之一: Vista Boot Config設定

指令執行成功後, 重新啟動機器.

選擇DebugPoint登入,開啟Windbg

連接配接成功, 則顯示如下:

Microsoft (R) Windows Debugger  Version 6.6.0007.5

Copyright (c) Microsoft Corporation. All rights reserved.

Opened \\.\pipe\com_1

Waiting to reconnect...

Connected to Windows Vista 6000 x86 compatible target, ptr64 FALSE

Kernel Debugger connection established.

Symbol search path is: symsrv*symsrv.dll*F:\symbols*http://msdl.microsoft.com/download/symbols

Executable search path is: 

Windows Vista Kernel Version 6000 MP (1 procs) Free x86 compatible

Built by: 6000.16386.x86fre.vista_rtm.061101-2205

Kernel base = 0x81800000 PsLoadedModuleList = 0x81911db0

System Uptime: not available

Break instruction exception - code 80000003 (first chance)

*******************************************************************************

*                                                                             

*   You are seeing this message because you pressed either                    

*       CTRL+C (if you run kd.exe) or,                                        

*       CTRL+BREAK (if you run WinDBG),                                       

*   on your debugger machine's keyboard.                                      

*                   THIS IS NOT A BUG OR A SYSTEM CRASH                       

* If you did not intend to break into the debugger, press the "g" key, then   

* press the "Enter" key now.  This message might immediately reappear.  If it 

* does, press "g" and "Enter" again.                                          

nt!RtlpBreakWithStatusInstruction:

81881760 cc              int     3

總結: 雖然利用VMware虛拟機能更友善的設定雙機的調試環境, 而且這種模拟環境也是大多數人使用的(友善), 但是如果有雙機條件的話,  還是希望大家能夠使用兩台機器, 因為用虛拟機進行Kernel調試, 真不是一般的慢! 基本就等于當機. 即時你的主機記憶體2G, 分給VMware1G, 還是會相當卡(Kerenl模式與User模式不同).

繼續閱讀