mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 08:45:25 +08:00
6.6.1 patched files
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
|
||||
#include <qt_windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <VersionHelpers.h>
|
||||
#include <intshcut.h>
|
||||
#include <qvarlengtharray.h>
|
||||
|
||||
@ -60,20 +61,26 @@ static inline void appendTestMode(QString &path)
|
||||
|
||||
static bool isProcessLowIntegrity()
|
||||
{
|
||||
if (!IsWindows8OrGreater())
|
||||
return false;
|
||||
|
||||
// same as GetCurrentProcessToken()
|
||||
const auto process_token = HANDLE(quintptr(-4));
|
||||
|
||||
QVarLengthArray<char,256> token_info_buf(256);
|
||||
auto* token_info = reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_info_buf.data());
|
||||
DWORD token_info_length = token_info_buf.size();
|
||||
if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_info, token_info_length, &token_info_length)) {
|
||||
if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_info, token_info_length, &token_info_length)
|
||||
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
// grow buffer and retry GetTokenInformation
|
||||
token_info_buf.resize(token_info_length);
|
||||
token_info = reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_info_buf.data());
|
||||
if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_info, token_info_length, &token_info_length))
|
||||
return false; // assume "normal" process
|
||||
}
|
||||
|
||||
else
|
||||
return false;
|
||||
|
||||
// The GetSidSubAuthorityCount return-code is undefined on failure, so
|
||||
// there's no point in checking before dereferencing
|
||||
DWORD integrity_level = *GetSidSubAuthority(token_info->Label.Sid, *GetSidSubAuthorityCount(token_info->Label.Sid) - 1);
|
||||
|
@ -361,10 +361,15 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
|
||||
ok = t->fastTimerId;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
typedef BOOL (WINAPI *SetCoalescableTimerFunc) (HWND, UINT_PTR, UINT, TIMERPROC, ULONG);
|
||||
static SetCoalescableTimerFunc mySetCoalescableTimerFunc =
|
||||
(SetCoalescableTimerFunc)::GetProcAddress(::GetModuleHandle(L"User32"), "SetCoalescableTimer");
|
||||
|
||||
if (!ok && mySetCoalescableTimerFunc) {
|
||||
// user normal timers for (Very)CoarseTimers, or if no more multimedia timers available
|
||||
ok = SetCoalescableTimer(internalHwnd, t->timerId, interval, nullptr, tolerance);
|
||||
ok = mySetCoalescableTimerFunc(internalHwnd, t->timerId, interval, nullptr, tolerance);
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
ok = SetTimer(internalHwnd, t->timerId, interval, nullptr);
|
||||
|
||||
|
@ -43,23 +43,33 @@ QComHelper::~QComHelper()
|
||||
*/
|
||||
bool qt_win_hasPackageIdentity()
|
||||
{
|
||||
typedef BOOL (WINAPI *GetCurrentPackageFullNameFunc) (UINT32 *, PWSTR);
|
||||
static GetCurrentPackageFullNameFunc myGetCurrentPackageFullName =
|
||||
(GetCurrentPackageFullNameFunc)::GetProcAddress(::GetModuleHandle(L"kernel32"), "GetCurrentPackageFullName");
|
||||
|
||||
if (myGetCurrentPackageFullName)
|
||||
{
|
||||
#if defined(HAS_APPMODEL)
|
||||
static const bool hasPackageIdentity = []() {
|
||||
UINT32 length = 0;
|
||||
switch (const auto result = GetCurrentPackageFullName(&length, nullptr)) {
|
||||
case ERROR_INSUFFICIENT_BUFFER:
|
||||
return true;
|
||||
case APPMODEL_ERROR_NO_PACKAGE:
|
||||
return false;
|
||||
default:
|
||||
qWarning("Failed to resolve package identity (error code %ld)", result);
|
||||
return false;
|
||||
}
|
||||
}();
|
||||
return hasPackageIdentity;
|
||||
|
||||
static const bool hasPackageIdentity = []() {
|
||||
UINT32 length = 0;
|
||||
switch (const auto result = myGetCurrentPackageFullName(&length, nullptr)) {
|
||||
case ERROR_INSUFFICIENT_BUFFER:
|
||||
return true;
|
||||
case APPMODEL_ERROR_NO_PACKAGE:
|
||||
return false;
|
||||
default:
|
||||
qWarning("Failed to resolve package identity (error code %ld)", result);
|
||||
return false;
|
||||
}
|
||||
}();
|
||||
return hasPackageIdentity;
|
||||
#else
|
||||
return false;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -107,39 +107,6 @@ namespace QtLinuxFutex {
|
||||
}
|
||||
namespace QtFutex = QtLinuxFutex;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#elif defined(Q_OS_WIN)
|
||||
# include <qt_windows.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace QtWindowsFutex {
|
||||
#define QT_ALWAYS_USE_FUTEX
|
||||
constexpr inline bool futexAvailable() { return true; }
|
||||
|
||||
template <typename Atomic>
|
||||
inline void futexWait(Atomic &futex, typename Atomic::Type expectedValue)
|
||||
{
|
||||
QtTsan::futexRelease(&futex);
|
||||
WaitOnAddress(&futex, &expectedValue, sizeof(expectedValue), INFINITE);
|
||||
QtTsan::futexAcquire(&futex);
|
||||
}
|
||||
template <typename Atomic>
|
||||
inline bool futexWait(Atomic &futex, typename Atomic::Type expectedValue, qint64 nstimeout)
|
||||
{
|
||||
BOOL r = WaitOnAddress(&futex, &expectedValue, sizeof(expectedValue), DWORD(nstimeout / 1000 / 1000));
|
||||
return r || GetLastError() != ERROR_TIMEOUT;
|
||||
}
|
||||
template <typename Atomic> inline void futexWakeAll(Atomic &futex)
|
||||
{
|
||||
WakeByAddressAll(&futex);
|
||||
}
|
||||
template <typename Atomic> inline void futexWakeOne(Atomic &futex)
|
||||
{
|
||||
WakeByAddressSingle(&futex);
|
||||
}
|
||||
}
|
||||
namespace QtFutex = QtWindowsFutex;
|
||||
QT_END_NAMESPACE
|
||||
#else
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -915,8 +915,10 @@ QT_END_NAMESPACE
|
||||
|
||||
#if defined(QT_ALWAYS_USE_FUTEX)
|
||||
// nothing
|
||||
#elif defined(Q_OS_DARWIN)
|
||||
#elif defined(Q_OS_MAC)
|
||||
# include "qmutex_mac.cpp"
|
||||
#elif defined(Q_OS_WIN)
|
||||
# include "qmutex_win.cpp"
|
||||
#else
|
||||
# include "qmutex_unix.cpp"
|
||||
#endif
|
||||
#endif
|
@ -86,6 +86,8 @@ public:
|
||||
semaphore_t mach_semaphore;
|
||||
#elif defined(Q_OS_UNIX)
|
||||
sem_t semaphore;
|
||||
#elif defined(Q_OS_WIN)
|
||||
Qt::HANDLE event;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
30
qtbase/src/corelib/thread/qmutex_win.cpp
Normal file
30
qtbase/src/corelib/thread/qmutex_win.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include "qmutex.h"
|
||||
#include <qatomic.h>
|
||||
#include "qmutex_p.h"
|
||||
#include <qt_windows.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QMutexPrivate::QMutexPrivate()
|
||||
{
|
||||
event = CreateEvent(0, FALSE, FALSE, 0);
|
||||
|
||||
if (!event)
|
||||
qWarning("QMutexPrivate::QMutexPrivate: Cannot create event");
|
||||
}
|
||||
|
||||
QMutexPrivate::~QMutexPrivate()
|
||||
{ CloseHandle(event); }
|
||||
|
||||
bool QMutexPrivate::wait(QDeadlineTimer timeout)
|
||||
{
|
||||
return (WaitForSingleObjectEx(event, timeout.isForever() ? INFINITE : timeout.remainingTime(), FALSE) == WAIT_OBJECT_0);
|
||||
}
|
||||
|
||||
void QMutexPrivate::wakeUp() noexcept
|
||||
{ SetEvent(event); }
|
||||
|
||||
QT_END_NAMESPACE
|
Reference in New Issue
Block a user