mirror of
https://github.com/nefarius/ViGEmBus.git
synced 2025-08-10 00:52:17 +00:00
Merge branch 'master' into issue/vigembus/13
This commit is contained in:
@@ -27,6 +27,7 @@ SOFTWARE.
|
||||
#include <Windows.h>
|
||||
#include <SetupAPI.h>
|
||||
#include <initguid.h>
|
||||
#include <Dbghelp.h>
|
||||
|
||||
#include "ViGEm/km/BusShared.h"
|
||||
#include "ViGEm/Client.h"
|
||||
@@ -47,6 +48,11 @@ SOFTWARE.
|
||||
//
|
||||
#define VIGEM_TARGETS_MAX USHRT_MAX
|
||||
|
||||
|
||||
typedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
|
||||
LONG WINAPI vigem_internal_exception_handler(struct _EXCEPTION_POINTERS* apExceptionInfo);
|
||||
|
||||
//
|
||||
// Represents a driver connection object.
|
||||
//
|
||||
@@ -104,8 +110,39 @@ PVIGEM_TARGET FORCEINLINE VIGEM_TARGET_ALLOC_INIT(
|
||||
}
|
||||
|
||||
|
||||
LONG WINAPI vigem_internal_exception_handler(struct _EXCEPTION_POINTERS* apExceptionInfo)
|
||||
{
|
||||
const auto mhLib = LoadLibrary(L"dbghelp.dll");
|
||||
const auto pDump = reinterpret_cast<MINIDUMPWRITEDUMP>(GetProcAddress(mhLib, "MiniDumpWriteDump"));
|
||||
|
||||
const auto hFile = CreateFile(
|
||||
L"ViGEmClient.dmp",
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE,
|
||||
nullptr,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
nullptr
|
||||
);
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
|
||||
ExInfo.ThreadId = GetCurrentThreadId();
|
||||
ExInfo.ExceptionPointers = apExceptionInfo;
|
||||
ExInfo.ClientPointers = FALSE;
|
||||
|
||||
pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, nullptr, nullptr);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
PVIGEM_CLIENT vigem_alloc()
|
||||
{
|
||||
SetUnhandledExceptionFilter(vigem_internal_exception_handler);
|
||||
|
||||
const auto driver = static_cast<PVIGEM_CLIENT>(malloc(sizeof(VIGEM_CLIENT)));
|
||||
|
||||
if (!driver)
|
||||
|
||||
Reference in New Issue
Block a user