8 #if defined(Q_OS_WIN) && QT_VERSION >= 0x050000 16 #include <openssl/rand.h> 20 bool WinShutdownMonitor::nativeEventFilter(
const QByteArray &eventType,
void *pMessage,
long *pnResult)
24 MSG *pMsg =
static_cast<MSG *
>(pMessage);
27 if (RAND_event(pMsg->message, pMsg->wParam, pMsg->lParam) == 0) {
29 static bool warned =
false;
31 LogPrintf(
"%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__);
38 case WM_QUERYENDSESSION:
57 void WinShutdownMonitor::registerShutdownBlockReason(
const QString& strReason,
const HWND& mainWinId)
59 typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
60 PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)GetProcAddress(GetModuleHandleA(
"User32.dll"),
"ShutdownBlockReasonCreate");
61 if (shutdownBRCreate ==
nullptr) {
62 qWarning() <<
"registerShutdownBlockReason: GetProcAddress for ShutdownBlockReasonCreate failed";
66 if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
67 qWarning() <<
"registerShutdownBlockReason: Successfully registered: " + strReason;
69 qWarning() <<
"registerShutdownBlockReason: Failed to register: " + strReason;