Fix MinGW valgrind build

QueryFullProcessImageName is only available on Windows >= Vista.
iSetting _WIN32_WINNT fixes availability on MinGW and moving the
functionality to winutils avoids code duplication.

Change-Id: I0ff1a12a1c092b1ad9cde75b636b52c5b959ce7d
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Oliver Wolff
2018-02-05 12:15:57 +01:00
parent 88a889d45a
commit 74d718c001
4 changed files with 26 additions and 46 deletions

View File

@@ -26,10 +26,10 @@
#include "winutils.h"
#include "qtcassert.h"
// Enable WinAPI Windows XP and later
// Enable WinAPI Windows Vista and later
#ifdef Q_OS_WIN
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#define _WIN32_WINNT 0x0600 // Needed for QueryFullProcessImageName
#include <windows.h>
#endif
@@ -168,6 +168,23 @@ QTCREATOR_UTILS_EXPORT bool is64BitWindowsBinary(const QString &binaryIn)
#endif
}
QTCREATOR_UTILS_EXPORT QString imageName(quint32 processId)
{
QString result;
#ifdef Q_OS_WIN
HANDLE handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId);
if (handle == NULL)
return result;
wchar_t path[MAX_PATH];
DWORD pathLen = MAX_PATH;
if (QueryFullProcessImageName(handle, 0, path, &pathLen))
result = QString::fromUtf16(reinterpret_cast<const ushort*>(path));
CloseHandle(handle);
#endif
return result;
}
WindowsCrashDialogBlocker::WindowsCrashDialogBlocker()
#ifdef Q_OS_WIN
: silenceErrorMode(SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS),