使用内核模式驱动程序

时间:2016-02-18 06:37:30

标签: kernel driver wdk wdm wdf

我使用的是Windows7主机,我安装了Vusual Studio 2013和WDK 8.1 我还使用Virtual Box安装了Windows 10虚拟机。

我从模板创建新的KMDF驱动程序并尝试调试它。

我配置了目标机器(使用win10虚拟),驱动程序已成功部署,但调试器仍处于非活动状态。这是Debugger Inmmediate Window中的日志:

-----------------------------------------------------------------------
-----------------------------------------------------------------------
                  Starting New Debugger Session         
-----------------------------------------------------------------------
-----------------------------------------------------------------------

Microsoft (R) Windows Debugger Version 6.3.9600.17336 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

SM72UC\User (npipe WinIDE_01D16A27752C70A4) connected at Thu Feb 18 11:36:27 2016

Microsoft (R) Windows Debugger Version 6.3.9600.17336 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

Opened \\.\pipe\com1
Waiting to reconnect...
[11:36:28:242]: Removing any existing files from the remote driver folder
[11:36:28:771]: Removing any existing files from test execution folder

te.exe "%SystemDrive%\DriverTest\Run\DriverTestTasks.dll" /select:"@Name='DriverTestTasks::_DriverRemoval'" /p:"InfFile=KMDFTest.inf" /p:"Debug=1" /p:"ImportDriver=1" /p:"RemoveDriver=1" /p:"HardwareId=Root\KMDFTest" /p:"CertificateFile=KMDFTestPackage.cer" /p:"PackageGuid={A23BA0FC-7265-4E3C-B99F-1E7A04AD970D}" /rebootStateFile:%SystemDrive%\DriverTest\Logs\DriverTestReboot.xml /enableWttLogging /wttDeviceString:$LogFile:file="%SystemDrive%\DriverTest\Logs\Driver_Removal_(x64)_(possible_reboot)_00009.wtl",writemode=append,encoding=unicode,nofscache=true,EnableLvl="WexStartTest|WexEndTest|WexXml|WexProperty|WexCreateContext|WexCloseContext|*" /runas:Elevated
[11:36:52:104]: Result Summary: Total=1, Passed=1, Failed=0, Blocked=0, Warned=0, Skipped=0
[11:36:52:705]: Removing any existing files from test execution folder

te.exe "%SystemDrive%\DriverTest\Run\DriverTestTasks.dll" /select:"@Name='DriverTestTasks::_DriverPreparation'" /p:"InfFile=KMDFTest.inf" /p:"Debug=1" /p:"ImportDriver=1" /p:"RemoveDriver=1" /p:"HardwareId=Root\KMDFTest" /p:"CertificateFile=KMDFTestPackage.cer" /p:"PackageGuid={A23BA0FC-7265-4E3C-B99F-1E7A04AD970D}" /rebootStateFile:%SystemDrive%\DriverTest\Logs\DriverTestReboot.xml /enableWttLogging /wttDeviceString:$LogFile:file="%SystemDrive%\DriverTest\Logs\Driver_Preparation_(x64)_(possible_reboot)_00009.wtl",writemode=append,encoding=unicode,nofscache=true,EnableLvl="WexStartTest|WexEndTest|WexXml|WexProperty|WexCreateContext|WexCloseContext|*" /runas:Elevated
[11:36:58:137]: Result Summary: Total=1, Passed=1, Failed=0, Blocked=0, Warned=0, Skipped=0
[11:36:58:792]: Removing any existing files from test execution folder

te.exe "%SystemDrive%\DriverTest\Run\DriverTestTasks.dll" /select:"@Name='DriverTestTasks::_RunProcess'" /p:"BinaryPath=%SystemDrive%\DriverTest\devcon.exe" /p:"Arguments=-f install %SystemDrive%\DriverTest\Drivers\KMDFTest.inf Root\KMDFTest" /p:"ExitCodes=0" /p:"WorkingFolder=%SystemDrive%\DriverTest\Drivers" /p:"LogOutput=1" /rebootStateFile:%SystemDrive%\DriverTest\Logs\DriverTestReboot.xml /enableWttLogging /wttDeviceString:$LogFile:file="%SystemDrive%\DriverTest\Logs\Driver_Install_(x64)_(possible_reboot)_00003.wtl",writemode=append,encoding=unicode,nofscache=true,EnableLvl="WexStartTest|WexEndTest|WexXml|WexProperty|WexCreateContext|WexCloseContext|*" /runas:Elevated
[11:37:22:743]: Result Summary: Total=1, Passed=1, Failed=0, Blocked=0, Warned=0, Skipped=0
[11:37:23:235]: Removing any existing files from test execution folder

te.exe "%SystemDrive%\DriverTest\Run\DriverTestTasks.dll" /select:"@Name='DriverTestTasks::_DriverPostInstall'" /rebootStateFile:%SystemDrive%\DriverTest\Logs\DriverTestReboot.xml /enableWttLogging /wttDeviceString:$LogFile:file="%SystemDrive%\DriverTest\Logs\Driver_Post_Install_Actions_(x64)_(possible_reboot)_00009.wtl",writemode=append,encoding=unicode,nofscache=true,EnableLvl="WexStartTest|WexEndTest|WexXml|WexProperty|WexCreateContext|WexCloseContext|*" /runas:Elevated
[11:37:25:227]: Result Summary: Total=1, Passed=1, Failed=0, Blocked=0, Warned=0, Skipped=0
[11:37:25:775]: Driver Installation summary:
[11:37:25:781]:   Driver Removal (x64) (possible reboot): Pass
[11:37:25:784]:   Driver Preparation (x64) (possible reboot): Pass
[11:37:25:785]:   Driver Install (x64) (possible reboot): Pass
[11:37:25:787]:   Driver Post Install Actions (x64) (possible reboot): Pass

在此调试器卡住之后,控制台处于非活动状态并向我显示文本“Debuggee正在运行...”我没有在DriverEntry函数中到达我的断点,没有看到来自内核和驱动程序的任何调试消息。

我也尝试过netwok设置进行调试,但结果相同。

有什么不对?

是否存在VirtualBox问题?或者这是因为我尝试在win10上调试win7驱动程序?

1 个答案:

答案 0 :(得分:0)

等待重新连接...意味着调试器等待目标机器应答。虽然目标机器没有运行任何事情。你需要打破它。在WinDBG中按Ctrl + C,在Visual Studio中按Break图标。