mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[GEN_BASEADDRESS] Add handling of 64 bit builds
This commit is contained in:
parent
9cc4d8994b
commit
7377f14339
1 changed files with 25 additions and 12 deletions
|
@ -15,6 +15,9 @@ Specify the build output dir as commandline argument to the script:
|
||||||
|
|
||||||
Multiple directories can be specified:
|
Multiple directories can be specified:
|
||||||
`python gen_baseaddress r:/build/msvc r:/build/gcc`
|
`python gen_baseaddress r:/build/msvc r:/build/gcc`
|
||||||
|
|
||||||
|
Specify -64 as first argument to use 64-bit addresses:
|
||||||
|
`python gen_baseaddress -64 r:\\build\\msvc-x64`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -102,7 +105,6 @@ EXCLUDE = (
|
||||||
'bmfd.dll',
|
'bmfd.dll',
|
||||||
'bootvid.dll',
|
'bootvid.dll',
|
||||||
'framebuf.dll',
|
'framebuf.dll',
|
||||||
'framebuf_new.dll',
|
|
||||||
'ftfd.dll',
|
'ftfd.dll',
|
||||||
'genincdata.dll',
|
'genincdata.dll',
|
||||||
'hal.dll',
|
'hal.dll',
|
||||||
|
@ -209,9 +211,10 @@ EXCLUDE = (
|
||||||
'MyEventProvider.dll',
|
'MyEventProvider.dll',
|
||||||
'redirtest1.dll',
|
'redirtest1.dll',
|
||||||
'redirtest2.dll',
|
'redirtest2.dll',
|
||||||
'w32kdll_2k3sp2.dll',
|
'win32u_2k3sp2.dll',
|
||||||
'w32kdll_ros.dll',
|
'win32u_vista.dll',
|
||||||
'w32kdll_xpsp2.dll',
|
'win32u_xpsp2.dll',
|
||||||
|
'testvdd.dll',
|
||||||
)
|
)
|
||||||
|
|
||||||
IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x10b
|
IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x10b
|
||||||
|
@ -222,10 +225,11 @@ IMAGE_TYPES = {
|
||||||
IMAGE_NT_OPTIONAL_HDR64_MAGIC: 0
|
IMAGE_NT_OPTIONAL_HDR64_MAGIC: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_x64():
|
IS_64_BIT = False
|
||||||
return IMAGE_TYPES[IMAGE_NT_OPTIONAL_HDR64_MAGIC] > IMAGE_TYPES[IMAGE_NT_OPTIONAL_HDR32_MAGIC]
|
|
||||||
|
|
||||||
def size_of_image(filename):
|
def size_of_image(filename):
|
||||||
|
if IS_64_BIT:
|
||||||
|
return 0xFE0000 # This results in 0x1000000 / 16MB space
|
||||||
with open(filename, 'rb') as fin:
|
with open(filename, 'rb') as fin:
|
||||||
if fin.read(2) != b'MZ':
|
if fin.read(2) != b'MZ':
|
||||||
print(filename, 'No dos header found!')
|
print(filename, 'No dos header found!')
|
||||||
|
@ -296,7 +300,7 @@ class MemoryLayout(object):
|
||||||
|
|
||||||
def _next_address(self, size):
|
def _next_address(self, size):
|
||||||
if self.start_at:
|
if self.start_at:
|
||||||
addr = (self.start_at - size - self.module_padding - 0xffff) & 0xffff0000
|
addr = (self.start_at - size - self.module_padding - 0xffff) & 0xffffffffffff0000
|
||||||
self.start_at = addr
|
self.start_at = addr
|
||||||
else:
|
else:
|
||||||
addr = self.start_at = self.initial
|
addr = self.start_at = self.initial
|
||||||
|
@ -350,10 +354,10 @@ def get_target_file(ntdll_path):
|
||||||
ntdll_pe = pefile.PE(ntdll_path, fast_load=True)
|
ntdll_pe = pefile.PE(ntdll_path, fast_load=True)
|
||||||
names = [sect.Name.strip(b'\0') for sect in ntdll_pe.sections]
|
names = [sect.Name.strip(b'\0') for sect in ntdll_pe.sections]
|
||||||
count = b'|'.join(names).count(b'/')
|
count = b'|'.join(names).count(b'/')
|
||||||
if b'.rossym' in names:
|
if IS_64_BIT:
|
||||||
|
return 'baseaddress64.cmake'
|
||||||
|
elif b'.rossym' in names:
|
||||||
return 'baseaddress.cmake'
|
return 'baseaddress.cmake'
|
||||||
elif is_x64():
|
|
||||||
return 'baseaddress_msvc_x64.cmake'
|
|
||||||
elif count == 0:
|
elif count == 0:
|
||||||
return 'baseaddress_msvc.cmake'
|
return 'baseaddress_msvc.cmake'
|
||||||
elif count > 3:
|
elif count > 3:
|
||||||
|
@ -363,6 +367,9 @@ def get_target_file(ntdll_path):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def run_dir(target):
|
def run_dir(target):
|
||||||
|
if IS_64_BIT:
|
||||||
|
layout = MemoryLayout(0x7FFB7000000)
|
||||||
|
else:
|
||||||
layout = MemoryLayout(0x7c920000)
|
layout = MemoryLayout(0x7c920000)
|
||||||
layout.add_reserved('user32.dll', 0x77a20000)
|
layout.add_reserved('user32.dll', 0x77a20000)
|
||||||
IMAGE_TYPES[IMAGE_NT_OPTIONAL_HDR64_MAGIC] = 0
|
IMAGE_TYPES[IMAGE_NT_OPTIONAL_HDR64_MAGIC] = 0
|
||||||
|
@ -387,6 +394,12 @@ def run_dir(target):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
dirs = sys.argv[1:]
|
dirs = sys.argv[1:]
|
||||||
|
|
||||||
|
if len(dirs) > 0 and dirs[0] == '-64':
|
||||||
|
print('Using 64-bit addresses')
|
||||||
|
global IS_64_BIT
|
||||||
|
IS_64_BIT = True
|
||||||
|
dirs = sys.argv[2:]
|
||||||
if len(dirs) < 1:
|
if len(dirs) < 1:
|
||||||
trydir = os.getcwd()
|
trydir = os.getcwd()
|
||||||
print(USAGE)
|
print(USAGE)
|
||||||
|
|
Loading…
Reference in a new issue