获取启动时崩溃的进程的转储

发布于 2024-07-16 05:43:12 字数 488 浏览 11 评论 0原文

在我无法访问的客户计算机 (WinXP SP2) 上,我的 Win32 EXE(非托管 C++)在启动时崩溃。 我想解决此问题的最佳方法是获取(小型)转储并稍后使用 Windbg 或类似工具对其进行分析。

现在,我通常会告诉客户安装 Windows 调试工具并运行

cscript adplus.vbs -crash

但是,似乎您无法将 adplus 用于启动时崩溃的应用程序 (http://support.microsoft.com/kb/q286350/ 表示“请勿在以下情况下使用 ADPlus: 如果您必须对某个程序或进程进行故障排除启动期间意外退出”)。 同一篇文章说“使用用户模式进程转储”,但我未能成功安装它。

知道如何获取 Win32 上启动时崩溃的进程的转储吗?

On a customer machine (WinXP SP2) to which I have no access, I have a Win32 EXE (unmanaged C++) that crashes on startup. I guess the best way to troubleshoot this is to obtain a (mini-)dump and analyze it later with windbg or similar.

Now, I would normally tell the customer to install Debugging Tools for Windows and run

cscript adplus.vbs -crash

However, it appears that you can't use adplus for apps that crash on startup (http://support.microsoft.com/kb/q286350/ says that "Do not use ADPlus in the following situations: If you must troubleshoot a program or process that quits unexpectedly during startup"). The same article says "use User Mode Process Dump", but I failed to install it successfully.

Any idea of how to get a dump of a process that crashes on startup on Win32?

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

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

发布评论

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

评论(4

瞳孔里扚悲伤 2024-07-23 05:43:12

或者,您可以设置自己的转储生成框架,当遇到任何未处理的异常时,该框架会自动创建进程转储。 这将避免客户端必须安装 Windbg。

使用 SetUnhandledExceptionFilter Win32 API 在应用程序启动时注册应用程序级异常处理程序。 每当有任何未处理的异常时,就会调用注册的回调函数。 然后,您可以使用 DbgHelp.dll 中的 MiniDumpWriteDump api 创建进程转储。

示例代码:-

LONG WINAPI My_UnhandledExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo)
{
    HANDLE hFile = CreateFile("FileName",
            GENERIC_WRITE,
            0,
            NULL,
            CREATE_ALWAYS,
            FILE_ATTRIBUTE_NORMAL,
            NULL);

    MINIDUMP_EXCEPTION_INFORMATION aMiniDumpInfo;
    aMiniDumpInfo.ThreadId = GetCurrentThreadId();
    aMiniDumpInfo.ExceptionPointers = ExceptionInfo;
    aMiniDumpInfo.ClientPointers = TRUE;

    MiniDumpWriteDump(GetCurrentProcess(),
            GetCurrentProcessId(),
            hFile,
            (MINIDUMP_TYPE) (MiniDumpWithFullMemory|MiniDumpWithHandleData),
            &aMiniDumpInfo,
            NULL,
            NULL);

    CloseHandle(hFile);

    return EXCEPTION_EXECUTE_HANDLER;
}


int main(int argc, char* argv[])
{
    SetUnhandledExceptionFilter(&My_UnhandledExceptionFilter);

    // User code throwing exception..

    return 0; 
}

注意:- 调试进程时不会调用已注册的异常过滤器。 因此,在调试过程中,如果您在异常过滤器函数中放置断点,即使在导致未处理的异常后它也没有命中,请不要感到惊讶。

Alternatively you may set up your own dump generation framework which automatically creates a process dump when any Unhandled exception is encountered. This would avoid clients having to install Windbg.

Use SetUnhandledExceptionFilter Win32 API to register the application level exception handler at the application start up. The registered callback function is called whenever there is any exception which is not handled. U may then create the process dump using MiniDumpWriteDump api from DbgHelp.dll.

Sample Code:-

LONG WINAPI My_UnhandledExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo)
{
    HANDLE hFile = CreateFile("FileName",
            GENERIC_WRITE,
            0,
            NULL,
            CREATE_ALWAYS,
            FILE_ATTRIBUTE_NORMAL,
            NULL);

    MINIDUMP_EXCEPTION_INFORMATION aMiniDumpInfo;
    aMiniDumpInfo.ThreadId = GetCurrentThreadId();
    aMiniDumpInfo.ExceptionPointers = ExceptionInfo;
    aMiniDumpInfo.ClientPointers = TRUE;

    MiniDumpWriteDump(GetCurrentProcess(),
            GetCurrentProcessId(),
            hFile,
            (MINIDUMP_TYPE) (MiniDumpWithFullMemory|MiniDumpWithHandleData),
            &aMiniDumpInfo,
            NULL,
            NULL);

    CloseHandle(hFile);

    return EXCEPTION_EXECUTE_HANDLER;
}


int main(int argc, char* argv[])
{
    SetUnhandledExceptionFilter(&My_UnhandledExceptionFilter);

    // User code throwing exception..

    return 0; 
}

NB:- The registered exception filter is not called when the process is being debugged. So during debugging if you put breakpoint in the exception filter function dont be surprised if it does not hit even after causing an Unhandled Exception.

活雷疯 2024-07-23 05:43:12

您可以在客户端计算机上安装 WinDBG,然后使用“图像文件执行选项" 并将 WinDBG 设置为在进程启动后打开。 然后运行崩溃的进程,WinDBG 将立即打开。 按g(Go)并等待进程崩溃,然后输入“.dump /mfh dumpFileName.dmp”。 现在您有了可以调试的转储文件。

You can install WinDBG on the client machine and then use "Image File Execution Options" and set WinDBG to open once that the process has started. Then run the crashing process and WinDBG will open up immediately. press g (Go) and wait for the process to crash then type ".dump /mfh dumpFileName.dmp". Now you have dump file that you can debug.

只为一人 2024-07-23 05:43:12

以下是收集 Vista SP1 崩溃的好方法:

http: //msdn.microsoft.com/en-us/library/bb787181(VS.85).aspx

无需在计算机上安装任何东西!

Here is a nice way to collect Vista SP1 crashes:

http://msdn.microsoft.com/en-us/library/bb787181(VS.85).aspx

No need to install anything on the machine!

等待我真够勒 2024-07-23 05:43:12

在客户端计算机上安装开发人员工具将是我最后的手段,我必须承认我讨厌这个想法,尤其是在有适合您的替代方案的情况下。

首先注册 WinQual。 您现在可以自动访问客户的故障转储和其他错误。 我记得这是一项免费服务,没有理由不使用它。

由于 WinQual 可能需要一段时间才能将故障转储发送给您,并且对客户的响应速度更快一点总是好的,尤其是当您的应用程序崩溃时,请使用 博士。 沃森。 我记得当崩溃发生时,在单击对话框之前,您可以从“开始”->“运行”或命令行运行 drwatsn32,然后 Dr Watson 就会弹出。 此时关闭崩溃对话框将生成一个崩溃转储文件。 如果失败,请通过在命令行上使用 -i 参数运行 Dr Watson 来安装它。

Installing developer tools on a client machine would be my last resort, I must admit I hate the idea especially where there are alternatives that will work for you.

First sign up for WinQual. You'll now get access to crash dumps and other error from your customers automatically. As I recall this is a free service, no reason not to use it.

Since WinQual will likely take a while for the crash dump to get to you, and it is always nice to be a little more responsive to customers especially when you application crashes, use Dr. Watson. As I recall when the crash occurs, before clicking on the dialog you can run drwatsn32 from Start->Run or the command line and Dr Watson will pop up. At this point dismissing the crash dialog will generate a crash dump file. Should this fail, install Dr Watson by running it with the -i parameter on the command line.

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