部署驱动程序&网络内核调试
部署驱动程序
1.虚拟机运行 WDK Test Target Setup x64-x64_en-us.msi
2.虚拟机管理员CMD一些命令
tree /f /a >DriverTest.doc
bcdedit /set testsigning on
bcdedit /dbgsettings NET hostip:172.16.34.89 port:50005
bcdedit /dbgsettings NET hostip:<主机IP> port:50005 key:24328ycc9zfrq.2pdv256vomdoo.14xg0dd4b0s5c.3ltu13f2xjjhc
bcdedit /dbgsettings
bcdedit /enum {current}
bcdedit /debug on
3.获取网卡PCI信息 Windows PowerShell
列出所有网卡的友好名和 Location 信息
Get-PnpDevice -Class Net |
ForEach-Object {
$iid = $_.InstanceId
$loc = (Get-PnpDeviceProperty -InstanceId $iid -KeyName 'DEVPKEY_Device_LocationInfo' -ErrorAction SilentlyContinue).Data
if (-not $loc) { $loc = (Get-PnpDeviceProperty -InstanceId $iid -KeyName 'DEVPKEY_Device_LocationPaths' -ErrorAction SilentlyContinue).Data }
[PSCustomObject]@{
Name = $_.FriendlyName
InstanceId = $iid
Location = $loc
}
} | Format-Table -AutoSize
查看完整位置字符串
Get-PnpDeviceProperty -InstanceId 'PCI\VEN_8086&DEV_10D3&SUBSYS_07D015AD&REV_00\000C29FFFFE890F700' -KeyName 'DEVPKEY_Device_LocationInfo'
4.Visual Studio 2022
Windows Debugger - User Mode
TCP; 50005
Windows Debugger - Kernel Mode
Network; 50005; 24328ycc9zfrq.2pdv256vomdoo.14xg0dd4b0s5c.3ltu13f2xjjhc; 主机IP; 3.0.0
生成解决方案 -> 部署解决方案
5.devcon.exe
复制C:\Program Files (x86)\Windows Kits\10\Tools\10.0.26100.0\x64\devcon.exe
到C:\DriverTest\Drivers\devcon.exe
6.虚拟机管理员CMD
导航到文件夹:cd C:\DriverTest\Drivers
安装:C:\DriverTest\devcon install kmdfhelloworld.inf root\kmdfhelloworld
安装:devcon install kmdfhelloworld.inf root\kmdfhelloworld
卸载:C:\DriverTest\devcon remove root\kmdfhelloworld
卸载:devcon remove root\kmdfhelloworld
查看驱动是否加载成功:sc query kmdfhelloworld
显示:
SERVICE_NAME: kmdfhelloworld
TYPE : 1 KERNEL_DRIVER
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
网络内核调试
1.虚拟机 -> 编辑 -> 虚拟网络编辑器 - >NET设置 -> 添加
主机端口 类型 虚拟机IP地址 描述 50005 TCP 192.168.80.128:50005
2.测试联通性
主机 Windows PowerShell
ping 192.168.80.128 -n 4
Test-NetConnection -ComputerName 192.168.80.128 -Port 50005 -InformationLevel Detailed
tracert 192.168.80.128
关闭虚拟机防火墙netsh advfirewall set allprofiles state off
虚拟机 Windows PowerShell
ping <主机IP> -n 4
Test-NetConnection -ComputerName <主机IP> -Port 50005 -InformationLevel Detailed
tracert <主机IP>
3.虚拟机管理员CMD一些命令
tree /f /a >DriverTest.doc
bcdedit /set testsigning on
bcdedit /dbgsettings NET hostip:172.16.34.89 port:50005
bcdedit /dbgsettings NET hostip:<主机IP> port:50005 key:24328ycc9zfrq.2pdv256vomdoo.14xg0dd4b0s5c.3ltu13f2xjjhc
bcdedit /dbgsettings
bcdedit /enum {current}
bcdedit /debug on
4.获取网卡PCI信息 Windows PowerShell
列出所有网卡的友好名和 Location 信息
Get-PnpDevice -Class Net |
ForEach-Object {
$iid = $_.InstanceId
$loc = (Get-PnpDeviceProperty -InstanceId $iid -KeyName 'DEVPKEY_Device_LocationInfo' -ErrorAction SilentlyContinue).Data
if (-not $loc) { $loc = (Get-PnpDeviceProperty -InstanceId $iid -KeyName 'DEVPKEY_Device_LocationPaths' -ErrorAction SilentlyContinue).Data }
[PSCustomObject]@{
Name = $_.FriendlyName
InstanceId = $iid
Location = $loc
}
} | Format-Table -AutoSize
查看完整位置字符串
Get-PnpDeviceProperty -InstanceId 'PCI\VEN_8086&DEV_10D3&SUBSYS_07D015AD&REV_00\000C29FFFFE890F700' -KeyName 'DEVPKEY_Device_LocationInfo'
5.Visual Studio 2022
Windows Debugger - User Mode
TCP; 50005
Windows Debugger - Kernel Mode
Network; 50005; 24328ycc9zfrq.2pdv256vomdoo.14xg0dd4b0s5c.3ltu13f2xjjhc; 主机IP; 3.0.0
6.主机管理员CMD
cd "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64"
WinDbg.exe -k net:port=50005,key=24328ycc9zfrq.2pdv256vomdoo.14xg0dd4b0s5c.3ltu13f2xjjhc
7.此时,可以试验调试程序,方法是在 kd> 提示符处输入命令。 例如,可以尝试使用以下命令:
lm
.sympath
.reload
x KmdfHelloWorld!*
原始资料地址:
教程:编写 Hello World Windows 驱动程序(内核模式驱动程序框架)
WinDbg 入门(用户模式)
开始使用 WinDbg(内核模式)
调试环境
如有侵权联系删除 仅供学习交流使用