[MPlayer-dev-eng] [PATCH] Execute protection for "funnyYcode" on windows
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Feb 23 15:16:26 CET 2005
Hi,
can somebody please test if the attached patch works on windows (esp.
MinGW)? MS can't decide whether you still need to do an extra VirtualProtect
call to actually enable the execute permission :-(.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: postproc/swscale.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.c,v
retrieving revision 1.154
diff -u -r1.154 swscale.c
--- postproc/swscale.c 23 Feb 2005 14:07:18 -0000 1.154
+++ postproc/swscale.c 23 Feb 2005 14:13:32 -0000
@@ -2076,6 +2076,9 @@
#ifdef MAP_ANONYMOUS
c->funnyYCode = (uint8_t*)mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
c->funnyUVCode = (uint8_t*)mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+#elif defined(WIN32)
+ c->funnyYCode = (uint8_t*)VirtualAlloc(NULL, MAX_FUNNY_CODE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ c->funnyUVCode = (uint8_t*)VirtualAlloc(NULL, MAX_FUNNY_CODE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else
c->funnyYCode = (uint8_t*)memalign(32, MAX_FUNNY_CODE_SIZE);
c->funnyUVCode = (uint8_t*)memalign(32, MAX_FUNNY_CODE_SIZE);
@@ -2642,6 +2645,9 @@
#ifdef MAP_ANONYMOUS
if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
+#elif defined(WIN32)
+ if(c->funnyYCode) VirtualFree(c->funnyYCode, MAX_FUNNY_CODE_SIZE, MEM_RELEASE);
+ if(c->funnyUVCode) VirtualFree(c->funnyUVCode, MAX_FUNNY_CODE_SIZE, MEM_RELEASE);
#else
if(c->funnyYCode) free(c->funnyYCode);
if(c->funnyUVCode) free(c->funnyUVCode);
More information about the MPlayer-dev-eng
mailing list