简体   繁体   English

如何附加到加载我的DLL并调试它的进程

[英]how to attach to a process that loads my DLL and debug it

basically, I am developing a DLL (an open interface) that will be used by a third party software. 基本上,我正在开发一个将由第三方软件使用的DLL(开放接口)。 I want to debug my DLL after it is loaded by this thirdparty DLL, because I found a specific bug that only happens when my DLL is loaded by this third party software (my DLL works OK for all other software that accepts this open interface) 我希望在这个第三方DLL加载后调试我的DLL,因为我发现了一个特定的错误,只有在我的DLL被这个第三方软件加载时才会发生(我的DLL适用于接受这个开放接口的所有其他软件)

I set __debugbreak() in my the code DLL and run the third party software. 我在代码DLL中设置__debugbreak()并运行第三方软件。 An Visual studio dialog did jump up asking if I want to debug.. but after I click OK, instead of getting get into a visual studio window that shows the line of code that I set a breakpoint, visual studio just crashes. 一个Visual Studio对话框确实跳起来询问我是否要调试..但是在我单击OK之后,而不是进入一个可视工作室窗口,显示我设置断点的代码行,visual studio只是崩溃了。

I found out that the third party softward loads my DLL and runs it in another thread. 我发现第三方软件加载我的DLL并在另一个线程中运行它。 And I suspect this is the reason that the third party software crashes, because effetively __debugbreak() throws an uncaught execption in a thread launched by the main thread. 我怀疑这就是第三方软件崩溃的原因,因为有效的__debugbreak()会在主线程启动的线程中抛出一个未被捕获的execption。

In this case, how can i debug my DLL? 在这种情况下,我如何调试我的DLL?

It's unfortunate that VS crashes, but you might find a way around that. 不幸的是,VS崩溃了,但你可能会找到解决方法。

Best to start the debugging session right ahead. 最好立即开始调试会话。 Or use 'attach to process' when the process is blocked on a messagebox or some other input. 或者在消息框或其他输入上阻止进程时使用“附加到进程”。 Also better use breakpoints. 也更好地使用断点。

With __debugbreak() or forced access violation try to ask a new instance of VS not an existing one. 使用__debugbreak()或强制访问冲突尝试询问VS的新实例而不是现有实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM