使用Windbg及VirtualPC調試第三方驅動的簡明步驟

來源:互聯網
上載者:User

使用Windbg及VirtualPC調試第三方驅動的簡明步驟(圖)

安全中國 www.anqn.com 更新時間:2009-1-3 0:25:18 責任編輯:流火
熱 點:

使用Windbg及VirtualPC調試第三方驅動的簡明步驟
1,配置VirtualPC
在VirtualPC中安裝好GuestOS後,在該GuestOS的設定頁面中找到COM1,然後參照圖中的資料進行設定
(文字描述:選中Named Pipe,然後輸入//./pipe/com_1)
2,配置GuestOS(當前指Win2k,XP,2003的配置方法)
在BOOT.ini中添加
multi(0)disk(0)rdisk(0)partition(1)/WINDOWS="Windows
Server 2003, Standard" /noexecute=optout /fastdetect /debug
/debugport=com1 /baudrate=115200
注意分區參數的設定,一般不需要變
3,配置Windbg
D:/Microsoft/windbg/windbg.exe
-y
D:/localSymbols;srv*D:/localSymbols*http://msdl.microsoft.com/download/symbols
-k com:pipe,port=//./pipe/com_1 -Q
在Windbg的捷徑中,設定[目標]為上面的資料(路徑請注意修改)
4,啟動OS,建立KD串連
啟動GuestOS,選擇調試選項並Enter,然後從剛設定好的WIndbg的Shortcut運行Windbg.
Windbg在與GuestOS串連後,會顯示相關的串連成功的資訊:

Connected to Windows Server 2003 3790 x86 compatible target, ptr64 FALSE
Kernel Debugger connection established.
Symbol search path is: D:/localSymbols;srv*D:/localSymbols*http://msdl.microsoft.com/download/symbols
Executable search path is:
Windows Server 2003 Kernel Version 3790 UP Free x86 compatible
Built by: 3790.srv03_sp1_rtm.050324-1447
Kernel base = 0x80800000 PsLoadedModuleList = 0x808a8e48
此時,可以按下Ctrl+Break鍵,中斷OS,這時如果沒有相關符號,Windbg會去M$的網站下載符號至D:/localSymbols,所以可能需要等一會兒.
中斷後,顯示KD>提示符
5,在DriveEntry上下斷點
如果你要調試的驅動是Boot,System Start類型,那麼你可在Windbg一旦與GuestOS建立KD Connection時,中斷OS,將下斷點,比如如果你的Driver的
名稱是:drvdbgee.sys,可以如此下斷:bu drvdbgee+EntryPoint(這個數字可以使用PE工具得到,比如PEID),bu $iment(drvdbgee),對於Windbg此時
也可能會去下載符號所以Prompt處會顯示"Busy"
6,載入Driver
手動載入Driver可以使用Kmdmanager.exe,Register->Run,然後在第5個下的斷點就會被命中.
7,Do what you want to do
......

附錄:
1,Windbg中使用BU下斷點時會遍曆整個Kernel Modules,然後去下載符號與BU中指定的名稱匹配,所以會比較慢,
通常情況下,可以不要設定srv*D:/localSymbols*http://msdl.microsoft.com/download/symbols,在你認為需要下載符號時下載
2,常用的指令和類型及資料
nt!KeServiceDescriptorTableShadow
nt!KeServiceDescriptorTable ( 命令 dds poi(nt!KeServiceDescriptorTable) ,可以查看SSDT表 )
win32k!W32pServiceTable (=nt!KeServiceDescriptorTableShadow+0x10 , 命令 dds win32k!W32pServiceTable,可以查看Win32K的函數表 )
_IMAGE_NT_HEADERS --PE頭
_UNICODE_STRING --Unicode string
_DRIVER_OBJECT --驅動對象

3,手動解析某個SSDT是否被HOOK,
dds poi(nt!KeServiceDescriptorTable)+0x4*0x80 ,其中0x4是SSDT入口項的大小,0x80是功能號,
如果沒有HOOK,則應顯示80827afc f8830300 nt!NtOpenProcess ,被HOOK的情況下顯示 80827afc f8830300 drvdbgee+0x1300
4,手動解析某個Win32k的SSDT是否被HOOK,
dds win32k!W32pServiceTable+0x4*(0x114C-0x1000) , 其中是0x114C是功能號,該功能的Stub通常來USER32和GDI32
5,其他常用指令:
d* 顯示資料,比如d, da, db, dc, dd
e 修改資料
bp 是下軟體斷點
u address 是從Address處反組譯碼
ba 下硬體訪問,寫入和執行斷點
? 是計算運算式,比如 ? 0x4*(0x114C-0x1000)
.reload 載入模組,在有些模組看不到的情況下使用
通常使用的 .reload /f 強制載入模組及符號(模組多時會相當慢) .reload /s 載入模組但是不載入符號
快速鍵F5->Run,F7->Run to cursor ,F10->Step over , F11->Step Into , SHIFT+F11 Step out

6,這個配置是與VMware相容的.

設定Pipe

配置Windbg

中斷OS

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.