调试动态加载的可执行文件

发布于 2024-10-27 21:32:31 字数 449 浏览 1 评论 0原文

我收到了一份支持申请,我正在努力弄清楚如何去做。我确实有源代码,并且可以进行一些更改,但我显然不想完全更改应用程序的架构。

该应用程序位于由 9 个不同项目组成的 VS2010 解决方案中。主要的一个是 Windows 窗体应用程序,但它在其他线程中派生出其他应用程序。

困难就在这里。尽管不同的项目是同一解决方案的一部分,但它们是单独的可执行文件,而不是 DLL。当主程序启动其他项目之一时,它通过创建一个新进程,将可执行文件的文件名、启动参数和其他各种参数设置到 process.StartInfo 对象中,然后调用 process.Start() 来实现。

如何设置断点并调试从属可执行文件?在加载它们之前我无法附加到它们,但是直到调用 process.Start() 才加载它们,到那时就为时已晚了。是否有一个方法调用可以插入到主程序中以使其在实际开始执行之前加载可执行文件(以便我可以在其中设置断点)?

谢谢。

I've been handed an application to support, and I'm trying to figure out how to do it. I do have the source, and can make some changes, but I obviously don't want to completely change the architecture of the application.

The app is in a VS2010 solution composed of 9 different projects. The main one is a Windows Form application, but it spins off others in other threads.

Here's the difficulty. Even though the different projects are parts of the same solution, they are separate executables, not DLLs. When the main program starts one of the other projects, it does so by creating a new process, setting the filename of the executeable, the startup arguments and other assorted parameters into the process.StartInfo object, and then calls process.Start().

How can I set breakpoints and debug subordinate executables? I can't attach to them until they are loaded, but they don't get loaded until process.Start() is called, and by then it's too late. Is there a method call I can insert into the main program to get it to load the executable (so I can set breakpoints in it) before it actually begins execution?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沧桑㈠ 2024-11-03 21:32:31

您能够重新编译其他可执行文件吗?如果是这样,您是否尝试过将 DebugBreak 放在合适的位置? (或 _asm int 3)。

您无法(有用地)加载该进程,因为根据定义,它将在与您在启动之前调试的地址空间不同的地址空间中运行。

Are you able to recompile the other executables? If so, have you tried putting DebugBreak in suitable places? (or _asm int 3).

You can't load the process (usefully), since by definition it will be run in a different addres space from the one you are debugging before it starts.

你另情深 2024-11-03 21:32:31

一种简单的解决方案可能是添加对 DebugActiveProcess 函数到参与您的应用程序的每个进程的“主要”函数。

One simple solution could be adding a call to DebugActiveProcess function to the "main" function of every process which participates in your application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文