https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5e6810d5d2263d62b5cfc…
commit 5e6810d5d2263d62b5cfcb5d18baeccc5de4a17a
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sat Sep 8 11:10:51 2018 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Sat Sep 8 11:11:08 2018 +0200
[SDK] Make gen_baseaddress.py compatible with Python 3.
---
sdk/tools/gen_baseaddress.py | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/sdk/tools/gen_baseaddress.py b/sdk/tools/gen_baseaddress.py
index 3d8605b7a8..5219a4ee32 100644
--- a/sdk/tools/gen_baseaddress.py
+++ b/sdk/tools/gen_baseaddress.py
@@ -4,7 +4,7 @@ LICENSE: MIT (
https://spdx.org/licenses/MIT)
PURPOSE: Update baseaddresses of all modules
COPYRIGHT: Copyright 2017,2018 Mark Jansen (mark.jansen(a)reactos.org)
'''
-
+from __future__ import print_function, absolute_import, division
import os
import struct
import sys
@@ -12,9 +12,9 @@ import sys
try:
import pefile
except ImportError:
- print '# Please install pefile from pip or
https://github.com/erocarrera/pefile'
- print '# Using fallback'
- print
+ print('# Please install pefile from pip or
https://github.com/erocarrera/pefile')
+ print('# Using fallback')
+ print()
ALL_EXTENSIONS = (
'.dll', '.acm', '.ax', '.cpl', '.drv',
'.ocx'
@@ -194,18 +194,18 @@ EXCLUDE = (
def size_of_image_fallback(filename):
with open(filename, 'rb') as fin:
if fin.read(2) != 'MZ':
- print filename, 'No dos header found!'
+ print(filename, 'No dos header found!')
return 0
fin.seek(0x3C)
e_lfanew = struct.unpack('i', fin.read(4))[0]
fin.seek(e_lfanew)
if fin.read(4) != 'PE\0\0':
- print filename, 'No PE header found!'
+ print(filename, 'No PE header found!')
return 0
fin.seek(e_lfanew + 0x18)
pe_magic = struct.unpack('h', fin.read(2))[0]
if pe_magic != 0x10b:
- print filename, 'is not a 32 bit exe!'
+ print(filename, 'is not a 32 bit exe!')
return 0
fin.seek(e_lfanew + 0x50)
pe_size_of_image = struct.unpack('i', fin.read(4))[0]
@@ -233,7 +233,7 @@ class Module(object):
postfix = ' # should be above 0x%08x' % self.address
elif self._reserved:
postfix = ' # reserved'
- print 'set(baseaddress_%-30s 0x%08x)%s' % (name, self.address, postfix)
+ print('set(baseaddress_%-30s 0x%08x)%s' % (name, self.address, postfix))
def end(self):
return self.address + self.size
@@ -276,7 +276,7 @@ class MemoryLayout(object):
current_start = self._next_address(size)
current_end = current_start + size + self.module_padding
# Is there overlap with reserved modules?
- for key, reserved in self.reserved.iteritems():
+ for key, reserved in self.reserved.items():
res_start = reserved[0]
res_end = res_start + reserved[1] + self.module_padding
if (res_start <= current_start <= res_end) or \
@@ -293,11 +293,11 @@ class MemoryLayout(object):
def update(self, priorities):
# sort addresses, should only contain reserved modules at this point!
- for key, reserved in self.reserved.iteritems():
+ for key, reserved in self.reserved.items():
assert reserved[1] != 0, key
for curr in priorities:
if not curr in self.found:
- print '# Did not find', curr, '!'
+ print('# Did not find', curr, '!')
else:
obj = self.found[curr]
del self.found[curr]
@@ -315,8 +315,8 @@ class MemoryLayout(object):
obj.gen_baseaddress()
def run_dir(target):
- print '# Generated from', target
- print '# Generated by sdk/tools/gen_baseaddress.py'
+ print('# Generated from', target)
+ print('# Generated by sdk/tools/gen_baseaddress.py')
layout = MemoryLayout(0x7c920000)
layout.add_reserved('user32.dll', 0x77a20000)
for root, _, files in os.walk(target):
@@ -329,7 +329,7 @@ def run_dir(target):
def main(dirs):
if len(dirs) < 1:
trydir = os.getcwd()
- print '# No path specified, trying', trydir
+ print('# No path specified, trying', trydir)
dirs = [trydir]
for onedir in dirs:
run_dir(onedir)