Mesa (mesa_7_7_branch): rtasm: Play nicely with Windows' s Data Execution Prevention.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Sun Jan 3 11:03:54 UTC 2010


Module: Mesa
Branch: mesa_7_7_branch
Commit: 66c1de77ed58ea8856c5bc72c8e4c69e23aa04f2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=66c1de77ed58ea8856c5bc72c8e4c69e23aa04f2

Author: José Fonseca <jfonseca at vmware.com>
Date:   Sun Jan  3 11:02:12 2010 +0000

rtasm: Play nicely with Windows's Data Execution Prevention.

---

 src/gallium/auxiliary/rtasm/rtasm_execmem.c |   32 +++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/rtasm/rtasm_execmem.c b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
index 01811d5..ffed768 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_execmem.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
@@ -41,6 +41,12 @@
 #define MAP_ANONYMOUS MAP_ANON
 #endif
 
+#if defined(PIPE_OS_WINDOWS)
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#endif
 
 #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
 
@@ -118,7 +124,29 @@ rtasm_exec_free(void *addr)
 }
 
 
-#else /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
+#elif defined(PIPE_OS_WINDOWS)
+
+
+/*
+ * Avoid Data Execution Prevention.
+ */
+
+void *
+rtasm_exec_malloc(size_t size)
+{
+   return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+}
+
+
+void
+rtasm_exec_free(void *addr)
+{
+   VirtualFree(addr, 0, MEM_RELEASE);
+}
+
+
+#else
+
 
 /*
  * Just use regular memory.
@@ -138,4 +166,4 @@ rtasm_exec_free(void *addr)
 }
 
 
-#endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
+#endif




More information about the mesa-commit mailing list