WinDbg 可以连接到远程运行的调试对象的标准输入吗 [英] can WinDbg connect to stdin of a debuggee which is running remotely

查看:17
本文介绍了WinDbg 可以连接到远程运行的调试对象的标准输入吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难使用 WinDbg 控制我的应用程序,我已经发布了我的问题 此处 并离开了这种方法,因为我无法找出如何实现这一目标的方法.现在我正在研究在断点被击中后的方法,我想分支我的应用程序执行并提示运行调试器的用户输入.

I'm having a hard time to control my application using WinDbg, I had already posted my question here and left that approach as I'm not able figure out a way on how to achieve that. Now I'm working on the approach that after breakpoint is hit, I would like to branch out my application execution and prompt input from user who is running the debugger.

DWORD dwRand = 0;
volatile bool bDebug = false;
if (!bDebug)
{
    dwRand = Rand(minValue, maxValue);
}
else
{
    cout << "\n Enter dwRand: ";
    cin >> dwRand;
}
return dwRand;

所以我的想法是设置 bDebug 并从用户那里获取输入,这样我就可以继续执行其他线程并等待用户输入.我找到了这些链接1 2 3 正在解释该技术,但我想附加到一个进程已经在远程运行.我尝试使用 WinDbg 命令选项,但这对我来说并不是解决方案.有人可以建议我如何实现这一目标.

So my idea is to set the bDebug and get the input from user so I can continue other threads execution and waiting for user input. I found these links1 2 3 are explaining the technique but I would like to attach to a process which is already running remotely. I tried with WinDbg command options but that did not turn out to be solution for me. Can somebody suggest me on how to achieve this.

推荐答案

上面的伪代码没有表达你的意图.

The Pseudo code above does not convey your intent.

我不知道为什么您需要内核调试连接来远程调试可执行文件(参考查询中的链接)

I am not sure why you require a kernel debugging connection to remote debug an executable (reference the link in your query)

如果您想调试在远程机器上运行的可执行文件,您可以使用远程调试连接会话进行连接.

if you want to debug an executable running in a remote machine that you can connect to use remote debugging connection session.

下面列举的示例设置使用远程调试会话调试在远程机器上运行的 calc.exe

a sample setup enumerated below debugs calc.exe running in a remote machine using remote debugging session

主机-----------------物理机 xp sp3 32 位
目标--------------虚拟机 xp sp3 32 位
网络--------------环回适配器

Host-----------------physical machine xp sp3 32 bit
target---------------virtual machine xp sp3 32 bit
network--------------Loop back Adapter

C:\>net view | grep -i xp & echo kd wont connect target not booted with /DEBUG
\\XPSP3VM
kd wont connect target not booted with /DEBUG

C:\>kd -k com:pipe,port=\\.\pipe\debugPipe,resets=0,reconnect
Opened \\.\pipe\debugPipe
Waiting to reconnect...
^B   <---------force exit
"lets run windbg -server npipe:pipe=\\.\pipe\debugPipe -v calc.exe 
in the target machine and connect to it with cdb -server:xxxx from host

C:\>cdb -remote npipe:server=xpsp3vm,pipe=\\.\pipe\debugPipe
Connected to server with 'npipe:server=xpsp3vm,pipe=\\.\pipe\debugPipe'

CommandLine: calc.exe  (mapped shared folder in host)
Symbol search path is: srv*z:\*http://msdl.microsoft.com/download/symbols

7c90120e cc              int     3
\Admin (npipe \\.\pipe\debugPipe) connected at Wed Jul 22 11:49:41 2015
0:000> .echo "yay we are remote debucking now"
yay we are remote debucking now
0:000> lm m calc*
start    end        module name
01000000 0101f000   calc       (deferred)
.clients
\Admin (npipe \\.\pipe\debugPipe), last active Wed Jul 22 11:54:19 2015
HostMachine\HostUser, last active Wed Jul 22 11:44:06 2015
0:000> kb
ChildEBP RetAddr  Args to Child
0007fb1c 7c9402ed 7ffde000 7ffdf000 00000000 ntdll!DbgBreakPoint
0007fc94 7c91fad7 0007fd30 7c900000 0007fce0 ntdll!LdrpInitializeProcess+0x1014
0007fd1c 7c90e457 0007fd30 7c900000 00000000 ntdll!_LdrpInitialize+0x183
00000000 00000000 00000000 00000000 00000000 ntdll!KiUserApcDispatcher+0x7
0:000> .echo "only echo is echoed all other aw are dumped here"
only echo is echoed all other aw are dumped here

添加了屏幕截图,以防写的内容听起来很乱

a screenshot added in case what is written sounds gibberish

这篇关于WinDbg 可以连接到远程运行的调试对象的标准输入吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆