mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-22 20:57:06 +00:00
[host] Added a crash handler to write out mini dumps
This commit is contained in:
parent
d450d792e3
commit
df5aa13029
79
host/CrashHandler.cpp
Normal file
79
host/CrashHandler.cpp
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
KVMGFX Client - A KVM Client for VGA Passthrough
|
||||||
|
Copyright (C) 2017 Geoffrey McRae <geoff@hostfission.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CrashHandler.h"
|
||||||
|
|
||||||
|
typedef BOOL (WINAPI * PMiniDumpWriteDump)(
|
||||||
|
_In_ HANDLE hProcess,
|
||||||
|
_In_ DWORD ProcessId,
|
||||||
|
_In_ HANDLE hFile,
|
||||||
|
_In_ MINIDUMP_TYPE DumpType,
|
||||||
|
_In_opt_ PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
|
||||||
|
_In_opt_ PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
|
||||||
|
_In_opt_ PMINIDUMP_CALLBACK_INFORMATION CallbackParam
|
||||||
|
);
|
||||||
|
|
||||||
|
void CrashHandler::Initialize()
|
||||||
|
{
|
||||||
|
SetUnhandledExceptionFilter(CrashHandler::ExceptionFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG WINAPI CrashHandler::ExceptionFilter(struct _EXCEPTION_POINTERS * apExceptionInfo)
|
||||||
|
{
|
||||||
|
HMODULE lib;
|
||||||
|
PMiniDumpWriteDump fn_MiniDumpWriteDump;
|
||||||
|
|
||||||
|
lib = LoadLibraryA("dbghelp.dll");
|
||||||
|
if (!lib)
|
||||||
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
||||||
|
fn_MiniDumpWriteDump = (PMiniDumpWriteDump)GetProcAddress(lib, "MiniDumpWriteDump");
|
||||||
|
if (!fn_MiniDumpWriteDump)
|
||||||
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
||||||
|
HANDLE hFile = CreateFileA(
|
||||||
|
"kvm-ivshmem-host.dump",
|
||||||
|
GENERIC_WRITE,
|
||||||
|
FILE_SHARE_WRITE,
|
||||||
|
NULL,
|
||||||
|
CREATE_ALWAYS,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
||||||
|
_MINIDUMP_EXCEPTION_INFORMATION info;
|
||||||
|
info.ThreadId = GetCurrentThreadId();
|
||||||
|
info.ExceptionPointers = apExceptionInfo;
|
||||||
|
info.ClientPointers = FALSE;
|
||||||
|
|
||||||
|
fn_MiniDumpWriteDump(
|
||||||
|
GetCurrentProcess(),
|
||||||
|
GetCurrentProcessId(),
|
||||||
|
hFile,
|
||||||
|
MiniDumpNormal,
|
||||||
|
&info,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
}
|
29
host/CrashHandler.h
Normal file
29
host/CrashHandler.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
KVMGFX Client - A KVM Client for VGA Passthrough
|
||||||
|
Copyright (C) 2017 Geoffrey McRae <geoff@hostfission.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <DbgHelp.h>
|
||||||
|
|
||||||
|
class CrashHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void Initialize();
|
||||||
|
private:
|
||||||
|
static LONG WINAPI ExceptionFilter(struct _EXCEPTION_POINTERS * apExceptionInfo);
|
||||||
|
};
|
@ -22,6 +22,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "common\debug.h"
|
#include "common\debug.h"
|
||||||
#include "vendor\getopt\getopt.h"
|
#include "vendor\getopt\getopt.h"
|
||||||
|
|
||||||
|
#include "CrashHandler.h"
|
||||||
#include "CaptureFactory.h"
|
#include "CaptureFactory.h"
|
||||||
#include "Service.h"
|
#include "Service.h"
|
||||||
|
|
||||||
@ -47,6 +48,8 @@ struct StartupArgs
|
|||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdParam, int iCmdShow)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdParam, int iCmdShow)
|
||||||
{
|
{
|
||||||
|
CrashHandler::Initialize();
|
||||||
|
|
||||||
struct StartupArgs args;
|
struct StartupArgs args;
|
||||||
ZeroMemory(&args, sizeof(struct StartupArgs));
|
ZeroMemory(&args, sizeof(struct StartupArgs));
|
||||||
int ret = parseArgs(args);
|
int ret = parseArgs(args);
|
||||||
|
Loading…
Reference in New Issue
Block a user