Copy exception message to clipboard for easy coby basting
This commit is contained in:
parent
3fdadb45a5
commit
e3278840e9
@ -43,10 +43,10 @@ namespace Components
|
|||||||
Utils::Time::Interval interval;
|
Utils::Time::Interval interval;
|
||||||
while (IsWindow(Window::GetWindow()) != FALSE && !interval.elapsed(2s))
|
while (IsWindow(Window::GetWindow()) != FALSE && !interval.elapsed(2s))
|
||||||
{
|
{
|
||||||
if (PeekMessage(&msg, nullptr, NULL, NULL, PM_REMOVE))
|
if (PeekMessageA(&msg, nullptr, NULL, NULL, PM_REMOVE))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessageA(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::this_thread::sleep_for(10ms);
|
std::this_thread::sleep_for(10ms);
|
||||||
@ -57,6 +57,32 @@ namespace Components
|
|||||||
Game::Sys_SuspendOtherThreads();
|
Game::Sys_SuspendOtherThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Exception::CopyMessageToClipboard(const std::string& error)
|
||||||
|
{
|
||||||
|
const auto hWndNewOwner = GetDesktopWindow();
|
||||||
|
const auto result = OpenClipboard(hWndNewOwner);
|
||||||
|
|
||||||
|
if (result == FALSE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EmptyClipboard();
|
||||||
|
auto* hMem = GlobalAlloc(GMEM_MOVEABLE, error.size() + 1);
|
||||||
|
|
||||||
|
if (hMem != nullptr)
|
||||||
|
{
|
||||||
|
auto lock = reinterpret_cast<char*>(GlobalLock(hMem));
|
||||||
|
|
||||||
|
if (lock != nullptr)
|
||||||
|
{
|
||||||
|
std::strcpy(lock, error.data()); // Should be okay since we allocated size + 1
|
||||||
|
GlobalUnlock(hMem);
|
||||||
|
SetClipboardData(1, hMem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
LONG WINAPI Exception::ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo)
|
LONG WINAPI Exception::ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo)
|
||||||
{
|
{
|
||||||
// Pass on harmless errors
|
// Pass on harmless errors
|
||||||
@ -90,6 +116,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
Exception::CopyMessageToClipboard(errorStr);
|
||||||
MessageBoxA(nullptr, errorStr.data(), "ERROR", MB_ICONERROR);
|
MessageBoxA(nullptr, errorStr.data(), "ERROR", MB_ICONERROR);
|
||||||
|
|
||||||
if (doFullDump)
|
if (doFullDump)
|
||||||
|
@ -18,7 +18,8 @@ namespace Components
|
|||||||
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilterStub(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilterStub(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
||||||
static __declspec(noreturn) void ErrorLongJmp(jmp_buf _Buf, int _Value);
|
static __declspec(noreturn) void ErrorLongJmp(jmp_buf _Buf, int _Value);
|
||||||
static __declspec(noreturn) void LongJmp(jmp_buf _Buf, int _Value);
|
static __declspec(noreturn) void LongJmp(jmp_buf _Buf, int _Value);
|
||||||
static void DebugMinidumpCommand(Command::Params*);
|
|
||||||
|
static void CopyMessageToClipboard(const std::string& error);
|
||||||
|
|
||||||
static int MiniDumpType;
|
static int MiniDumpType;
|
||||||
static Utils::Hook SetFilterHook;
|
static Utils::Hook SetFilterHook;
|
||||||
|
Loading…
Reference in New Issue
Block a user