aboutsummaryrefslogtreecommitdiff
path: root/src/qt/winshutdownmonitor.cpp
diff options
context:
space:
mode:
authorRoy Badami <roy@gnomon.org.uk>2014-07-07 22:06:21 +0100
committerRoy Badami <roy@gnomon.org.uk>2014-07-07 22:06:21 +0100
commit96df327834af3b55918adfac9b3f65adfc960b3a (patch)
tree8bd199df46ea6f39f7094c0e7db2185b4d3f5d6d /src/qt/winshutdownmonitor.cpp
parent2e4fee2ac4824570c1340a8f8fe2aed4580de879 (diff)
parent1fedd65fcf9ac04b70f0fa8cf6caa9629857d586 (diff)
Merge remote-tracking branch 'upstream/master'
Conflicts: src/qt/overviewpage.cpp src/qt/transactiondesc.cpp
Diffstat (limited to 'src/qt/winshutdownmonitor.cpp')
-rw-r--r--src/qt/winshutdownmonitor.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/qt/winshutdownmonitor.cpp b/src/qt/winshutdownmonitor.cpp
index b7526f0ae4..a06f42f66e 100644
--- a/src/qt/winshutdownmonitor.cpp
+++ b/src/qt/winshutdownmonitor.cpp
@@ -6,11 +6,14 @@
#if defined(Q_OS_WIN) && QT_VERSION >= 0x050000
#include "init.h"
+#include "util.h"
#include <windows.h>
#include <QDebug>
+#include <openssl/rand.h>
+
// If we don't want a message to be processed by Qt, return true and set result to
// the value that the window procedure should return. Otherwise return false.
bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult)
@@ -19,6 +22,16 @@ bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pM
MSG *pMsg = static_cast<MSG *>(pMessage);
+ // Seed OpenSSL PRNG with Windows event data (e.g. mouse movements and other user interactions)
+ if (RAND_event(pMsg->message, pMsg->wParam, pMsg->lParam) == 0) {
+ // Warn only once as this is performance-critical
+ static bool warned = false;
+ if (!warned) {
+ LogPrint("%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__);
+ warned = true;
+ }
+ }
+
switch(pMsg->message)
{
case WM_QUERYENDSESSION:
@@ -45,13 +58,13 @@ void WinShutdownMonitor::registerShutdownBlockReason(const QString& strReason, c
typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)GetProcAddress(GetModuleHandleA("User32.dll"), "ShutdownBlockReasonCreate");
if (shutdownBRCreate == NULL) {
- qDebug() << "registerShutdownBlockReason : GetProcAddress for ShutdownBlockReasonCreate failed";
+ qWarning() << "registerShutdownBlockReason: GetProcAddress for ShutdownBlockReasonCreate failed";
return;
}
if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
- qDebug() << "registerShutdownBlockReason : Successfully registered: " + strReason;
+ qWarning() << "registerShutdownBlockReason: Successfully registered: " + strReason;
else
- qDebug() << "registerShutdownBlockReason : Failed to register: " + strReason;
+ qWarning() << "registerShutdownBlockReason: Failed to register: " + strReason;
}
#endif