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__);
35 switch (pMsg->message) {
36 case WM_QUERYENDSESSION: {
53 void WinShutdownMonitor::registerShutdownBlockReason(
const QString& strReason,
const HWND& mainWinId)
55 typedef BOOL(WINAPI * PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
56 PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)GetProcAddress(GetModuleHandleA(
"User32.dll"),
"ShutdownBlockReasonCreate");
57 if (shutdownBRCreate == NULL) {
58 qDebug() <<
"registerShutdownBlockReason: GetProcAddress for ShutdownBlockReasonCreate failed";
62 if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
63 qDebug() <<
"registerShutdownBlockReason: Successfully registered: " + strReason;
65 qDebug() <<
"registerShutdownBlockReason: Failed to register: " + strReason;