今天在找如何在Windows上编译breakpad的答案时,看到了这个博客:https://www.cnblogs.com/cswuyg/p/3207576.html。在这个博客的代码中学到了点东西,现在就来记录一下。
talk is cheap show me the code.先上代码好了,下面的代码是我从上面的博客上精简下来的测试代码,如下
#include <Windows.h>
#include <iostream>
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI TempSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
{
std::cout << "TempSetUnhandledExceptionFilter\n";
return NULL;
}
BOOL PreventSetUnhandledExceptionFilter()
{
HMODULE hKernel32 = LoadLibrary(L"kernel32.dll");
if (hKernel32 == NULL)
{
return FALSE;
}
void *pOrgEntry = ::GetProcAddress(hKernel32, "SetUnhandledExceptionFilter");
if (pOrgEntry == NULL)
{
return FALSE;