本文简要介绍主机windbg和虚拟主机之间的远程调试设置,包括com远程调试和网络远程调试两种方法,其中windbg运行于主机之中。
两种方法并不难,步骤都分为2部分,即虚拟机的设置、主机中windbg和虚拟机软件的设置。其中主要是虚拟机设置,主机的设置非常简单,除非特别指出,以下命令都是在虚拟机上执行。
(一)COM远程调试
To setup and start driver without digital signature on 64 bit windows,run below commands in VM cmd.exe with administrator priority(在虚拟机中,使用管理员权限,在cmd中执行如下命令,打开调试功能):
bcdedit /bootdebug ON
bcdedit /debug ON
同样的,关闭功能命令如下:
bcdedit /bootdebug off
bcdedit /debug off
在虚拟机中,使用管理员权限,在cmd中执行如下命令,关闭数字签名验证功能:
bcdedit /set testsigning on
bcdedit /set nointegritychecks on
bcdedit.exe -set loadoptions DDISABLE_INTEGRITY_CHECKS
相应的,虚拟机中,管理员权限下执行如下命令,打开数字签名验证功能:
bcdedit -set loadoptions ENABLE_INTEGRITY_CHECKS
bcdedit /set testsigning off
bcdedit /set nointegritychecks off
在虚拟机中,使用管理员权限,在cmd中执行如下命令,打开com端口远程调试功能:
bcdedit /dbgsettings serial debugport:1 baudrate:115200
在主机中需要如下命令执行windbg:
"C:\Program Files\Debugging Tools for Windows (x64)\windbg.exe" -b -k com:pipe,port=\\.\pipe\com1,baud=115200,reconnect -y
其中:
“C:\Program Files\Debugging Tools for Windows (x64)\windbg.exe” 是安装程序,加引号的作用是因为全路径中有空格。
\.\pipe\com1代表虚拟机中com端口的设备名称。
虚拟机的具体参数设置可以自行百度。在virtual box中,windows7系统的设置如下所示:
(二)网络远程调试
由于串口调试太慢,只有11.2kb,实际操作中往往慢到无法忍受,在windows10以及以后的系统中,可以在虚拟机中执行如下命令打开网络调试功能:
在虚拟主机中开启网络调试(只支持windows10以及以后的版本):
bcdedit /dbgsettings net hostip:192.168.101.130 port:50000 key:1.2.3.4
其中192.168.101.130是windbg所在的主机ip地址,key是用来标识多个连接的健。
主机中的windbg启动后,在"File"->"kernel debug"中,key一栏中输入命令中的key值:1.2.3.4后,即可连接到虚拟机。
vs中注释快捷键:
```c
ctrl + /
ctrl + u