Commit 4b4963f3 authored by Rafaël Carré's avatar Rafaël Carré

peflags.py -> peflags.pl

parent 1476c5ee
...@@ -767,7 +767,7 @@ endif ...@@ -767,7 +767,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) {} \; 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 #Enable DEP and ASLR for all the binaries
find $(win32_destdir) -type f \( -name '*$(LIBEXT)' -print -o -name '*$(EXEEXT)' -print \) -exec $(top_srcdir)/extras/package/win32/peflags.py {} \; find $(win32_destdir) -type f \( -name '*$(LIBEXT)' -print -o -name '*$(EXEEXT)' -print \) -exec $(top_srcdir)/extras/package/win32/peflags.pl {} \;
find $(win32_destdir)/plugins/ -type f \( -name '*.a' -or -name '*.la' \) -exec rm -rvf {} \; find $(win32_destdir)/plugins/ -type f \( -name '*.a' -or -name '*.la' \) -exec rm -rvf {} \;
package-win-base: package-win-common package-win-base: package-win-common
......
#!/usr/bin/env python #!/usr/bin/perl
# -*- coding: utf8 -*-
#
# Copyright © 2011 Rafaël Carré <funman at videolanorg> # Copyright © 2011 Rafaël Carré <funman at videolanorg>
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
...@@ -18,40 +16,47 @@ ...@@ -18,40 +16,47 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
# #
from os import SEEK_CUR use warnings;
from sys import argv
if ($#ARGV != 0) {
die "Need exactly one argument";
}
def get_le(f, n): open F, "+<$ARGV[0]"
array = bytearray(f.read(n)) or die "Can't open `$ARGV[0]'";
if len(array) != n: binmode F;
raise Exception('Reading failed!')
shift = 0
ret = 0
for c in array:
ret = ret + (c << shift)
shift = shift + 8
return ret
### seek F, 0x3c, 0;
my $offset = get_le(4);
seek F, $offset, 0;
if len(argv) != 2: if (get_le(4) != 0x00004550) { # IMAGE_NT_SIGNATURE
exit(1) die "Not a NT executable";
}
f = open(argv[1], 'r+b') seek F, 20 + 70, 1;
f.seek(0x3c) my $flags = get_le(2);
f.seek(get_le(f, 4)) seek F, -2, 1;
if get_le(f, 4) != 0x00004550: # IMAGE_NT_SIGNATURE $flags |= 0x100; # NX Compat
raise Exception('Not a NT executable') $flags |= 0x40; # Dynamic Base
f.seek(20 + 70, SEEK_CUR) printf F "%c%c", $flags & 0xff,($flags >> 8) & 0xff;
flags = get_le(f, 2) close F;
f.seek(-2, SEEK_CUR)
flags |= 0x100 # NX Compat
flags |= 0x40 # Dynamic Base
f.write(bytearray([flags & 0xff, (flags >> 8) & 0xff ])) sub get_le {
my $bytes;
read F, $bytes, $_[0];
if (length $bytes ne $_[0]) {
die "Couldn't read";
}
f.close my $ret = 0;
my @array = split //, $bytes;
for (my $shift = 0, my $i = 0; $i < $_[0]; $i++, $shift += 8) {
$ret += (ord $array[$i]) << $shift;
}
return $ret;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment