Use GlobalFree & more

This commit is contained in:
FutureRave 2022-02-10 14:23:53 +00:00
parent e3278840e9
commit 4fea4b4479
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955

View File

@ -68,19 +68,22 @@ namespace Components
EmptyClipboard(); EmptyClipboard();
auto* hMem = GlobalAlloc(GMEM_MOVEABLE, error.size() + 1); auto* hMem = GlobalAlloc(GMEM_MOVEABLE, error.size() + 1);
if (hMem != nullptr) if (hMem == nullptr)
{ {
auto lock = reinterpret_cast<char*>(GlobalLock(hMem)); CloseClipboard();
return;
}
if (lock != nullptr) auto lock = GlobalLock(hMem);
{ if (lock != nullptr)
std::strcpy(lock, error.data()); // Should be okay since we allocated size + 1 {
GlobalUnlock(hMem); std::memcpy(lock, error.data(), error.size() + 1);
SetClipboardData(1, hMem); GlobalUnlock(hMem);
} SetClipboardData(1, hMem);
} }
CloseClipboard(); CloseClipboard();
GlobalFree(hMem);
} }
LONG WINAPI Exception::ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo) LONG WINAPI Exception::ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo)
@ -104,22 +107,10 @@ namespace Components
//Exception::SuspendProcess(); //Exception::SuspendProcess();
bool doFullDump = Flags::HasFlag("bigdumps") || Flags::HasFlag("reallybigdumps"); Exception::CopyMessageToClipboard(Utils::String::VA("0x%08X", ExceptionInfo->ExceptionRecord->ExceptionAddress));
/*if (!doFullDump)
{
if (MessageBoxA(nullptr,
Utils::String::VA("%s\n\n" // errorStr
"Would you like to create a full crash dump for the developers (this can be 100mb or more)?\nNo will create small dumps that are automatically uploaded.", errorStr),
"IW4x Error!", MB_YESNO | MB_ICONERROR) == IDYES)
{
doFullDump = true;
}
}*/
Exception::CopyMessageToClipboard(errorStr);
MessageBoxA(nullptr, errorStr.data(), "ERROR", MB_ICONERROR); MessageBoxA(nullptr, errorStr.data(), "ERROR", MB_ICONERROR);
if (doFullDump) if ( Flags::HasFlag("bigminidumps"))
{ {
Exception::SetMiniDumpType(true, false); Exception::SetMiniDumpType(true, false);
} }