2014年6月29日 星期日

Windows Driver 1_Setting Environment to Remote Debug

In this article, I will discuss how to set up the environment on Host/Target Computer to remote debug the driver running on target computer.
(p.s Target Computer is a virtual computer to test your driver )

A. Environment
Host Computer : Windows7 SP1 x86
                         WDK (Windows Driver Kit)8.1
                         Visual Studio 2013
Target Computer : Windows7 SP1 x86 (Run on VMware Player)
                             Debug View
                             osrLoader

B. Settings on VS2013
      (1) [ Driver] menu-> Test->Computer Configuration
      (2) select [Add New Computer] button -> choose [Manually configure debuggers and do not provision], remember to give it a name!
         


      (3)  choose [Kernel Mode] and set the values as the picture shows->next->finish


      (4) finally you will get the settings as follow



C. Settings on VM
     (1) open [Virtual Machine Settings]
     (2) delete the Printer in order to let new serial port=1
     (3) [add] -> serial port -> choose [output to named pipe] as its serial port type -> in the Named pipe field enter "\\.\pipe\com_1" and choose [this end is the server],[the other end is an application ] -> finish
Your settings may look the same as follow, and remember to check out the [Yield CPU on poll]


D.  After those settings, turn on the target computer on VM (i.e your target computer=windows7)
     (1) use system manager's identity to open the command line and enter "bcdedit" to open the Windows Boot Manager (以系統管理員身分執行)


     (2) enter a command bcdedit  /copy  {current}  /d  "Windows 7 Kernel Debug Mode"
This command will copy current boot settings and give it a new name, i.e Windows 7 Kernel Debug Mode, and you will see 2 booting selections in boot manager.


       (3) press WIN+R and open "msconfig" service -> choose [boot] (開機) menu, you'll see Windows 7 Kenel Debug Mode in it. Select to boot it as a default selection.(設定成預設值) Now choose it and click 進階選項-> check out  the debug(偵錯) box, and select debug serial port(com1), finally select transmit rate to 115200 -> OK -> reboot your target computer.


E. Wow!!! Get ready to remote debug
     (1) Go back to VS2013 and click [Debugging Tools for Windows-Kernel Debugger]


     (2) select I know what I'm doing, continue debugging
   (3) then you can see your debugging progress in Debugger Immediate Window, if it keeps waiting to reconnect for too long, trying to  reboot your vm again and the connection will be success.


Hurray!!!!!  You can remote debug your driver on target computer right now!

[Reference]
1. http://blog.csdn.net/iceamber2012/article/details/18809813
2. http://blog.csdn.net/iceamber2012/article/details/17963649


沒有留言:

張貼留言

全國推廣動物認領養平台串聯貼紙

全國推廣動物認領養平台串聯貼紙