What actions do I need to take to get a crash dump in ALL error scenarios?

前端 未结 6 1122
孤独总比滥情好
孤独总比滥情好 2021-02-04 09:39

We\'re on Windows and we want to get a crash dump (possibly using MiniDumpWriteDump) for all scenarios where our application exit\'s unexpectedly.

6条回答
  •  耶瑟儿~
    2021-02-04 10:02

    I use exactly the ones you've listed, plus _set_purecall_handler, plus this handy snippet of code:

    void EnableCrashingOnCrashes()
    {
        typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags);
        typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags);
        static const DWORD EXCEPTION_SWALLOWING = 0x1;
    
        const HMODULE kernel32 = LoadLibraryA("kernel32.dll");
        const tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32, "GetProcessUserModeExceptionPolicy");
        const tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32, "SetProcessUserModeExceptionPolicy");
        if(pGetPolicy && pSetPolicy)
        {
            DWORD dwFlags;
            if(pGetPolicy(&dwFlags))
            {
                // Turn off the filter
                pSetPolicy(dwFlags & ~EXCEPTION_SWALLOWING);
            }
        }
    }
    

    Source: http://randomascii.wordpress.com/2012/07/05/when-even-crashing-doesnt-work/

    These other articles on his site also helped me understand this: http://randomascii.wordpress.com/2011/12/07/increased-reliability-through-more-crashes/ http://randomascii.wordpress.com/2012/07/22/more-adventures-in-failing-to-crash-properly/

提交回复
热议问题