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

peflags.py -> peflags.pl

parent 1476c5ee
......@@ -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) {} \;
#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 {} \;
package-win-base: package-win-common
......
#!/usr/bin/env python
# -*- coding: utf8 -*-
#
#!/usr/bin/perl
# Copyright © 2011 Rafaël Carré <funman at videolanorg>
#
# This program is free software; you can redistribute it and/or modify
......@@ -18,40 +16,47 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
#
from os import SEEK_CUR
from sys import argv
use warnings;
if ($#ARGV != 0) {
die "Need exactly one argument";
}
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
open F, "+<$ARGV[0]"
or die "Can't open `$ARGV[0]'";
binmode F;
###
seek F, 0x3c, 0;
my $offset = get_le(4);
seek F, $offset, 0;
if len(argv) != 2:
exit(1)
if (get_le(4) != 0x00004550) { # IMAGE_NT_SIGNATURE
die "Not a NT executable";
}
f = open(argv[1], 'r+b')
seek F, 20 + 70, 1;
f.seek(0x3c)
f.seek(get_le(f, 4))
my $flags = get_le(2);
seek F, -2, 1;
if get_le(f, 4) != 0x00004550: # IMAGE_NT_SIGNATURE
raise Exception('Not a NT executable')
$flags |= 0x100; # NX Compat
$flags |= 0x40; # Dynamic Base
f.seek(20 + 70, SEEK_CUR)
printf F "%c%c", $flags & 0xff,($flags >> 8) & 0xff;
flags = get_le(f, 2)
f.seek(-2, SEEK_CUR)
flags |= 0x100 # NX Compat
flags |= 0x40 # Dynamic Base
close F;
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