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



commit fc7831f7a141681610304f3271e945c5f9e7994e
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 d395c34..08cc4d9 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -84,6 +84,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
@@ -249,6 +250,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]