本文主要記錄個人安裝VMware+Windgb+Win7核心驅動調試的筆記。
一、安裝環境
- 主機:Windows Vista Bussiness
- 虛擬機器:VMware 7
- GUestOS: Win7
- Windbg: 6.11
二、虛擬機器設定
- 開啟相應 vmware 虛擬機器上的 “Virtaul Machine Settings“
- “Hardware ”選項中 ----> 點擊“Add" 添加一個串口裝置 SeriallPort .
- "Next",在 "Serial Port" 裡選中 “Output to named pipe"
- "next",然後如下設定:
- 確定之後,回到如下介面,在右腳"Virtual Machine Settings" 頁面時,在“I/O Mode” 裡選中“Yield CPU on poll“
- Ok之後就設定完畢了。
三、Windbg設定
:
Windbg
安裝之後,設定一個案頭捷徑,然後,右鍵->屬性,在Target中的引號後面添加如下:-b -k com:pipe,port=\\.\pipe\com_1,resets=0
或者是: -b -k com:port=\\.\pipe\com_1,baud=115200,pipe 【二者似乎皆可】
四、GuestOS設定
Vista和XP不同, 沒有boot.ini檔案, 需要用bcdedit進行啟動設定。
- 在administrator許可權下, 進入command line模式, 鍵入bcdedit命令, 會出現以下介面:
- 然後, 設定連接埠COM1, baudrate為115200 (除COM1外, 也可以用1394或USB. 1394用起來比COM口快多了, 當然前提是你需要有1394卡及其驅動. 很噁心的是Vista不再支援1394的檔案傳輸通訊協定, 但是用windbg雙機調試還是可以的)
命令為:
bcdedit /dbgsettings {serial [baudrate:value][debugport:value] | 1394 [channel:value] | usb }
- 接著, 我們需要複製一個開機選項, 以進入OS的debug模式
命令為:
bcdedit /copy {current} /d DebugEnty
DebugPoint為選項名稱, 名字可以自己定義. 然後複製得到的ID號.
- 接著增加一個新的選項到引導菜單
bcdedit /displayorder {current} {ID}
這裡的{ID}的ID值是剛產生的ID值.
- 啟用DEBUG : bcdedit /debug {ID} ON
這裡的{ID} 的ID值還是剛才的ID值.
- 命令執行成功後, 重新啟動機器.或者更簡單的圖形介面設定:在msconfig介面中,選Boot,再選Advanced options,在選擇Debug、Debug port、Baud rate都打上鉤。如果所示:
- 選擇DebugEntry[debug]作為等入口。啟動後,開啟windbg.可以看到類似如下的資訊:Xml代碼
- Microsoft (R) Windows Debugger Version 6.11.0001.404 X86
- Copyright (c) Microsoft Corporation. All rights reserved.
-
- Opened \\.\pipe\com_1
- Waiting to reconnect...
- Connected to Windows 7 7600 x86 compatible target at (Thu Dec 10 17:46:36.928 2009 (GMT+8)), ptr64 FALSE
- Kernel Debugger connection established. (Initial Breakpoint requested)
- Symbol search path is: *** Invalid ***
- ****************************************************************************
- * Symbol loading may be unreliable without a symbol search path. *
- * Use .symfix to have the debugger choose a symbol path. *
- * After setting your symbol path, use .reload to refresh symbol locations. *
- ****************************************************************************
- Executable search path is:
- *********************************************************************
- * Symbols can not be loaded because symbol path is not initialized. *
- * *
- * The Symbol Path can be set by: *
- * using the _NT_SYMBOL_PATH environment variable. *
- * using the -y <symbol_path> argument when starting the debugger. *
- * using .sympath and .sympath+ *
- *********************************************************************
- *** ERROR: Symbol file could not be found. Defaulted to export symbols for ntkrpamp.exe -
- Windows 7 Kernel Version 7600 MP (1 procs) Free x86 compatible
- Product: WinNt, suite: TerminalServer SingleUserTS
- Built by: 7600.16385.x86fre.win7_rtm.090713-1255
- Machine Name:
- Kernel base = 0x83e0f000 PsLoadedModuleList = 0x83f57810
- Debug session time: Thu Dec 10 17:46:32.658 2009 (GMT+8)
- System Uptime: 0 days 0:06:18.429
- 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!DbgBreakPointWithStatus+0x4:
- 83e7a394 cc int 3
五、操作方式提示
我發現,如果在GuestOs -win7啟動過程中,如果開啟了windbg之後,整個系統就像死機,不動了。估計是windbg啟動後設定了斷點做調試,試試按F5,或者go這樣就可以恢複原來的狀態。
原文地址:http://yexin218.iteye.com/blog/545187