[gimp/gimp-2-6] Reduce risks on Windows also for plug-ins



commit 927d0c380adf208f21c48c46b2e2c9365efa4f2c
Author: Tor Lillqvist <tml iki fi>
Date:   Thu Sep 2 21:28:29 2010 +0300

    Reduce risks on Windows also for plug-ins

 libgimp/gimp.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index 9baa66d..02df570 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -85,6 +85,7 @@
 
 #if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
 #  define STRICT
+#  define _WIN32_WINNT 0x0601
 #  include <windows.h>
 #  undef RGB
 #  define USE_WIN32_SHM 1
@@ -237,6 +238,28 @@ gimp_main (const GimpPlugInInfo *info,
 #ifdef G_OS_WIN32
   gint i, j, k;
 
+  /* Reduce risks */
+  {
+    typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
+    t_SetDllDirectoryA p_SetDllDirectoryA;
+
+    p_SetDllDirectoryA = GetProcAddress (GetModuleHandle ("kernel32.dll"),
+					 "SetDllDirectoryA");
+    if (p_SetDllDirectoryA)
+      (*p_SetDllDirectoryA) ("");
+  }
+#ifndef _WIN64
+  {
+    typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
+    t_SetProcessDEPPolicy p_SetProcessDEPPolicy;
+
+    p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"),
+					    "SetProcessDEPPolicy");
+    if (p_SetProcessDEPPolicy)
+      (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
+  }
+#endif
+
   /* Check for exe file name with spaces in the path having been split up
    * by buggy NT C runtime, or something. I don't know why this happens
    * on NT (including w2k), but not on w95/98.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]