无法远程连接到windbg服务器,可能是因为dll版本不匹配



我的目标是从另一个C++程序控制WinDbg的运行实例。我看到API DebugConnectWide可以让你远程连接到调试客户端,所以我尝试使用它,并通过输入以下命令确保从正在运行的windgg客户端启动服务器:

CCD_ 1。

我可以打开第二个windbg实例,并通过在命令行参数中输入以下内容远程连接到第一个实例:

CCD_ 2。

但是,当我尝试从C++控制台应用程序以编程方式连接时,我从HRESULT:The server is currently disabled.中得到以下错误

#include <dbgeng.h>
#include <iostream>
int main()
{
HRESULT hr;
IDebugClient7* debugger = nullptr;
hr = DebugConnectWide(L"npipe:Pipe=testname,Server=DESKTOP-NAME", IID_PPV_ARGS(&debugger));
std::getchar();
}

我在文档中读到,如果想要远程连接,那么所有windbg实例都必须具有相同的版本,这一点很重要。所以我的问题可能与此有关。我看到我的计算机上有很多版本的dbgeng.dlldbgeng.lib,那么我如何确保我的C++应用程序运行的是相同版本的dbgeng呢?

是的,您需要服务器运行的dbgeng.dll版本

通常在服务器和客户端安装相同的windbg版本,并从客户端运行应用程序windbg安装文件夹将工作

或者您可以将dbgeng复制到exe所在的本地文件夹

将c:\proaxxxxxx\dbgeng.dll.复制到可执行的目录

这是上的流程示例

执行DebugConnect(((DebugConectWide的Ascii版本(的代码

#include <stdio.h>
#include <dbgeng.h>
#pragma comment(lib, "dbgeng.lib")
int main(int argc, char *argv[])
{
if (argc == 2)
{
IDebugClient *dbgclient = NULL;
HRESULT hr = E_FAIL;
hr = DebugConnect(argv[1], __uuidof(IDebugClient), (VOID **)&dbgclient);
if (hr == S_OK && dbgclient != NULL)
{
ULONG mask = 0xdeadbeef;
hr = dbgclient->GetOutputMask(&mask);
if (hr == S_OK && mask != 0xdeadbeef)
{
printf("Outputmask = %xn", mask);
}
printf("hresult = %xtmask = %xn", hr, mask);
}
printf("hresult = %xtdbgclient = %pn", hr, dbgclient);
}
else
{
printf("usage %s remote connection string", argv[0]);
}
return 0;
}

在x64中编译为win10 1803中的x64,使用使用vs2017社区开发cmdprompt

cl /Zi /W4 /analyze /Od /EHsc /nologo concliw.cpp /link /release

在本地机器中运行的命令行参数中有cdb的进程的列表

server debuggee client and wmic  commandlines 
C:>whoami
krxxxxx
C:>wmic process get CommandLine /format:list | grep -i cdb
CommandLine=cdb  -server npipe:pipe=windpipe cdb
CommandLine=cdb
CommandLine=cdb  -remote npipe:server=KR,pipe=windpipe
CommandLine=grep  -i cdb

复制了正确的dbgeng.dll并将其重命名为test_dbgeng.dll

copy "C:Program Files (x86)Windows Kits10Debuggersx64dbgeng.dll" .
ren dbgeng.dll test_dbgeng.dll

执行二进制重命名回dbgeng.dll并重新执行二进制

concliw.exe
usage concliw.exe remote connection string
concliw.exe "npipe:server=KR,pipe=windpipe"
hresult = 8007053d      dbgclient = 0000000000000000
ren test_dbgeng.dll dbgeng.dll
concliw.exe "npipe:server=KR,pipe=windpipe"
Outputmask = 3f7
hresult = 0     mask = 3f7
hresult = 0     dbgclient = 000001FA6B9D2590

最新更新