7 #if defined(Q_OS_WIN) && QT_VERSION >= 0x050000 15 #include <openssl/rand.h> 19 bool WinShutdownMonitor::nativeEventFilter(
const QByteArray &eventType,
void *pMessage,
long *pnResult)
23 MSG *pMsg =
static_cast<MSG *
>(pMessage);
26 if (RAND_event(pMsg->message, pMsg->wParam, pMsg->lParam) == 0) {
28 static bool warned =
false;
30 LogPrintf(
"%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__);
37 case WM_QUERYENDSESSION:
56 void WinShutdownMonitor::registerShutdownBlockReason(
const QString& strReason,
const HWND& mainWinId)
58 typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
59 PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)GetProcAddress(GetModuleHandleA(
"User32.dll"),
"ShutdownBlockReasonCreate");
60 if (shutdownBRCreate ==
nullptr) {
61 qWarning() <<
"registerShutdownBlockReason: GetProcAddress for ShutdownBlockReasonCreate failed";
65 if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
66 qWarning() <<
"registerShutdownBlockReason: Successfully registered: " + strReason;
68 qWarning() <<
"registerShutdownBlockReason: Failed to register: " + strReason;