summaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorJohn Brooks <special@dereferenced.net>2011-01-06 22:08:27 -0700
committerNick Mathewson <nickm@torproject.org>2011-02-03 14:18:00 -0500
commit895409011f20d6a08da75ac8dde44ad5e9ba1371 (patch)
tree779eb2897b76ce15dd3917b8e0deae04cba36c05 /src/or/main.c
parente94ee583d6f81f2375ea9126e77495aeb3ca18bf (diff)
downloadtor-895409011f20d6a08da75ac8dde44ad5e9ba1371.tar.gz
tor-895409011f20d6a08da75ac8dde44ad5e9ba1371.zip
Enable ASLR and permanent DEP for Windows executables
Fix for #2358
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 4b512905c3..979a2bec5c 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -2194,6 +2194,19 @@ tor_main(int argc, char *argv[])
}
#endif
+#ifdef MS_WINDOWS
+ /* Call SetProcessDEPPolicy to permanently enable DEP.
+ The function will not resolve on earlier versions of Windows,
+ and failure is not dangerous. */
+ HMODULE hMod = GetModuleHandleA("Kernel32.dll");
+ if (hMod) {
+ typedef BOOL (WINAPI *PSETDEP)(DWORD);
+ PSETDEP setdeppolicy = (PSETDEP)GetProcAddress(hMod,
+ "SetProcessDEPPolicy");
+ if (setdeppolicy) setdeppolicy(1); /* PROCESS_DEP_ENABLE */
+ }
+#endif
+
update_approx_time(time(NULL));
tor_threads_init();
init_logging();