]> git.sesse.net Git - vlc/commitdiff
peflags: rewrite needed features in python
authorRafaël Carré <funman@videolan.org>
Mon, 7 Nov 2011 21:18:48 +0000 (16:18 -0500)
committerRafaël Carré <funman@videolan.org>
Mon, 7 Nov 2011 21:18:48 +0000 (16:18 -0500)
remove conditional from configure.ac

Makefile.am
configure.ac
contrib/TODO
extras/package/win32/peflags.py [new file with mode: 0755]

index 68530b3e2c53e94ba363adb360dec704b926f4ec..1ba4cf0341eb377494202ba3a73b22ce8d878e25 100644 (file)
@@ -773,9 +773,7 @@ endif
        find $(win32_destdir) -type f \( -name "*xml" -or -name "*html" -or -name '*js' -or -name '*css' -or -name '*hosts' -or -iname '*txt' -or -name '*.cfg' -or -name '*.lua' \) -exec $(U2D) {} \;
 
 #Enable DEP and ASLR for all the binaries
-if USE_PEFLAGS
-       find $(win32_destdir) -type f \( -name '*$(LIBEXT)' -print -o -name '*$(EXEEXT)' -print \) -exec $(PEFLAGS) --dynamicbase=true --nxcompat=true {} \;
-endif
+       find $(win32_destdir) -type f \( -name '*$(LIBEXT)' -print -o -name '*$(EXEEXT)' -print \) -exec $(top_srcdir)/extras/package/win32/peflags.py {} \;
        find $(win32_destdir)/plugins/ -type f \( -name '*.a' -or -name '*.la' \) -exec rm -rvf {} \;
 
 package-win-base: package-win-common
index b688d8f80646619e1d2cc23143f3a9fbebc81870..85919eab272d29532f273b9b630017c0a3e7485c 100644 (file)
@@ -343,15 +343,6 @@ case "${host_os}" in
         VLC_ADD_LDFLAGS([vlc],[-mwindows])
         VLC_ADD_LIBS([win32text],[-lgdi32])
         VLC_ADD_LIBS([cdda vcdx sdl_image vout_sdl],[-lwinmm])
-        dnl
-        dnl DEP and ASLR options
-        dnl
-        AC_ARG_WITH(peflags,
-          [AS_HELP_STRING([--with-peflags],
-            [use peflags (default enabled on Windows)])])
-        if test "${with_peflags}" != "no" ; then
-          AC_PATH_TOOL(PEFLAGS, peflags, :)
-        fi
         AC_CHECK_PROGS(U2D, [unix2dos todos], unix2dos)
         ac_default_prefix="`pwd`/_win32"
         DESTDIR="`pwd`/_win32/"
@@ -405,7 +396,6 @@ AM_CONDITIONAL(HAVE_WIN32,   test "${SYS}" = "mingw32")
 AM_CONDITIONAL(HAVE_WIN64,   test "${HAVE_WIN64}" = "1")
 AM_CONDITIONAL(HAVE_WINCE,   test "${SYS}" = "mingwce")
 AM_CONDITIONAL(HAVE_SYMBIAN, test "${SYS}" = "symbian")
-AM_CONDITIONAL(USE_PEFLAGS,  test "${with_peflags}" = "yes")
 
 dnl
 dnl Sadly autoconf doesn't think about testing foo.exe when ask to test
index 063f652e1d5ca5b4352137af4c9171b48dbc4075..1b31ec879335972b543eac9a99e945dff2f78d1b 100644 (file)
@@ -12,7 +12,3 @@ Sparkle
 vcdimager, cdio -- why are they used only in osx binaries, do we really need them?
 
 build tools     -- (autotools, libtool, yasm...) see extras/tools
-
-# Windows
-
-peflags         -- a build tool, only a single .c file; we should rather put it in git
diff --git a/extras/package/win32/peflags.py b/extras/package/win32/peflags.py
new file mode 100755 (executable)
index 0000000..eea3ccb
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+#
+# Copyright © 2011 Rafaël Carré <funman at videolanorg>
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+#
+
+from os import SEEK_CUR
+from sys import argv
+
+def get_le(f, n):
+    array = bytearray(f.read(n))
+    if len(array) != n:
+        raise Exception('Reading failed!')
+    shift = 0
+    ret = 0
+    for c in array:
+        ret = ret + (c << shift)
+        shift = shift + 8
+    return ret
+
+###
+
+if len(argv) != 2:
+    exit(1)
+
+f = open(argv[1], 'r+b')
+
+f.seek(0x3c)
+f.seek(get_le(f, 4))
+
+if get_le(f, 4) != 0x00004550: # IMAGE_NT_SIGNATURE
+    raise Exception('Not a NT executable')
+
+f.seek(20 + 70, SEEK_CUR)
+
+flags = get_le(f, 2)
+f.seek(-2, SEEK_CUR)
+flags |= 0x100  # NX Compat
+flags |= 0x40   # Dynamic Base
+
+f.write(bytearray([flags & 0xff, (flags >> 8) & 0xff ]))
+
+f.close