aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2012-07-20 08:45:49 +0200
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2012-08-03 14:51:51 +0200
commit3d88c9b4d3714daddd77ab72d0e44b61c0b9800a (patch)
tree79e874a66ff11c6742cf875dd34cbf1592fe666a /src/init.cpp
parentdd199d0ebd086262626a5cc0ce794de6a477d731 (diff)
downloadbitcoin-3d88c9b4d3714daddd77ab72d0e44b61c0b9800a.tar.xz
Bitcoin-Qt (Windows only): enable DEP for bitcoin-qt.exe
- this enables DEP on all Windows version which support the SetProcessDEPPolicy() call in Kernel32.dll - use a dynamic approach via GetProcAddress() to not rely on headers or compiler libs - this is the same way the Tor-project does it
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 3235bf5833..2937643bca 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -312,10 +312,22 @@ bool AppInit2()
// Disable confusing "helpful" text message on abort, Ctrl-C
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
-#ifndef WIN32
- umask(077);
+#ifdef WIN32
+ // Enable Data Execution Prevention (DEP)
+ // Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008
+ // A failure is non-critical and needs no further attention!
+#ifndef PROCESS_DEP_ENABLE
+// We define this here, because GCCs winbase.h limits this to _WIN32_WINNT >= 0x0601 (Windows 7),
+// which is not correct. Can be removed, when GCCs winbase.h is fixed!
+#define PROCESS_DEP_ENABLE 0x00000001
+#endif
+ typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
+ PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy");
+ if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE);
#endif
#ifndef WIN32
+ umask(077);
+
// Clean shutdown on SIGTERM
struct sigaction sa;
sa.sa_handler = HandleSIGTERM;