From 37e2dafb009439c1a0ae01f7c35b6f9d90e4ca28 Mon Sep 17 00:00:00 2001 From: /dev/root Date: Tue, 14 Mar 2017 18:16:12 +0100 Subject: [PATCH] [Exception] Only start crash-helper if *.dmp exist --- src/Components/Modules/Exception.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index a4320019..ee6336b6 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -258,19 +258,26 @@ namespace Components }); #pragma warning(pop) - if (Utils::IO::FileExists("crash-helper.exe")) + // Check if folder exists && crash-helper exists + if (PathIsDirectoryA("minidumps\\") && Utils::IO::FileExists("crash-helper.exe")) { - STARTUPINFOA sInfo; - PROCESS_INFORMATION pInfo; + // Walk through directory and search for valid minidumps + WIN32_FIND_DATAA ffd; + HANDLE hFind = FindFirstFileA(Utils::String::VA("%s\\*.dmp", "minidumps"), &ffd); + if (hFind != INVALID_HANDLE_VALUE) + { + STARTUPINFOA sInfo; + PROCESS_INFORMATION pInfo; - ZeroMemory(&sInfo, sizeof(sInfo)); - ZeroMemory(&pInfo, sizeof(pInfo)); - sInfo.cb = sizeof(sInfo); + ZeroMemory(&sInfo, sizeof(sInfo)); + ZeroMemory(&pInfo, sizeof(pInfo)); + sInfo.cb = sizeof(sInfo); - CreateProcessA("crash-helper.exe", const_cast(Utils::String::VA("crash-helper.exe %s", VERSION)), nullptr, nullptr, false, NULL, nullptr, nullptr, &sInfo, &pInfo); + CreateProcessA("crash-helper.exe", const_cast(Utils::String::VA("crash-helper.exe %s", VERSION)), nullptr, nullptr, false, NULL, nullptr, nullptr, &sInfo, &pInfo); - if (pInfo.hThread && pInfo.hThread != INVALID_HANDLE_VALUE) CloseHandle(pInfo.hThread); - if (pInfo.hProcess && pInfo.hProcess != INVALID_HANDLE_VALUE) CloseHandle(pInfo.hProcess); + if (pInfo.hThread && pInfo.hThread != INVALID_HANDLE_VALUE) CloseHandle(pInfo.hThread); + if (pInfo.hProcess && pInfo.hProcess != INVALID_HANDLE_VALUE) CloseHandle(pInfo.hProcess); + } } }