mirror of
https://github.com/elliotnunn/ToolboxToolbox.git
synced 2024-12-26 12:29:19 +00:00
Sundry changes
This commit is contained in:
parent
cdada5d559
commit
4950d06683
@ -77,6 +77,7 @@ if __name__ == '__main__':
|
||||
fname += ' "%s"' % r.name.decode('ascii')
|
||||
if r.combo_field != 'AllCombos':
|
||||
fname += ' (%s)' % r.combo_field
|
||||
fname = fname.replace('/', '-')
|
||||
|
||||
with open(os.path.join(dest, fname), 'wb') as f:
|
||||
f.write(r.data)
|
||||
|
33
EveryKernelExtractor.py
Executable file
33
EveryKernelExtractor.py
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from os.path import split, join
|
||||
|
||||
klist = []
|
||||
for x in sys.argv[1:]:
|
||||
try:
|
||||
y = open(x, 'rb').read()
|
||||
if len(y) != 0x400000: raise ValueError
|
||||
except:
|
||||
continue
|
||||
|
||||
y = y[0x310000:]
|
||||
y = y[:y.index(bytes(256))]
|
||||
while len(y) % 4: y += bytes(1)
|
||||
|
||||
klist.append((x, y))
|
||||
|
||||
kseries = defaultdict(list)
|
||||
for x, y in klist:
|
||||
kseries[y].append(x)
|
||||
|
||||
flg = False
|
||||
for kerndata, owners in kseries.items():
|
||||
if flg: print()
|
||||
flg = True
|
||||
for o in owners: print(o)
|
||||
|
||||
a, b = split(owners[0])
|
||||
dest = join(a, 'NK-'+b)
|
||||
open(dest, 'wb').write(kerndata)
|
38
ExtractBinDates.py
Executable file
38
ExtractBinDates.py
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
import argparse
|
||||
|
||||
def macdatestr(srcint):
|
||||
dt = datetime(1904, 1, 1) + timedelta(seconds=srcint)
|
||||
st = dt.isoformat()
|
||||
st = st.replace('T', ' ')
|
||||
return st
|
||||
|
||||
args = argparse.ArgumentParser()
|
||||
|
||||
args.add_argument('src', nargs='+', help='Binary to extract build dates from')
|
||||
args.add_argument('--all', action='store_true', help='Show every date, not just the latest one')
|
||||
|
||||
args = args.parse_args()
|
||||
|
||||
for binpath in args.src:
|
||||
thebin = open(binpath, 'rb').read()
|
||||
|
||||
if args.all: print(binpath)
|
||||
|
||||
maxdat = -1
|
||||
|
||||
while b'Joy!peffpwpc' in thebin:
|
||||
thebin = thebin[thebin.index(b'Joy!peffpwpc') + 16:]
|
||||
dt = int.from_bytes(thebin[:4], byteorder='big')
|
||||
maxdat = max(maxdat, dt)
|
||||
|
||||
if args.all: print(macdatestr(dt))
|
||||
|
||||
if not args.all:
|
||||
suffix = ' [%s]' % binpath
|
||||
if maxdat == -1:
|
||||
print('???????????????????' + suffix)
|
||||
else:
|
||||
print(macdatestr(maxdat) + suffix)
|
@ -20,7 +20,7 @@ for fname in argv[2:]:
|
||||
print('--- no kernel')
|
||||
continue
|
||||
vers = '%02x%02x' % tuple(b[4:6])
|
||||
if not vers.startswith('02'): continue
|
||||
# if not vers.startswith('02'): continue
|
||||
print('---', vers)
|
||||
if vers in kerns:
|
||||
if kerns[vers] != b:
|
||||
|
28
RemoveNulsFromTextFiles.py
Executable file
28
RemoveNulsFromTextFiles.py
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
from os import path
|
||||
|
||||
the_dir = sys.argv[1]
|
||||
|
||||
def get_textfiles_from_dir(the_dir):
|
||||
textfiles = []
|
||||
for parent, dirs, files in os.walk(the_dir):
|
||||
for flnam in files:
|
||||
flnam = path.join(parent, flnam)
|
||||
try:
|
||||
if open(flnam + '.idump', 'rb').read(4) != b'TEXT':
|
||||
continue
|
||||
except:
|
||||
continue
|
||||
textfiles.append(flnam)
|
||||
return textfiles
|
||||
|
||||
BADCHAR = b'\x00'
|
||||
|
||||
for f in get_textfiles_from_dir(the_dir):
|
||||
dat = open(f, 'rb').read()
|
||||
if BADCHAR in dat:
|
||||
print('Writing', f)
|
||||
open(f, 'wb').write(dat.replace(BADCHAR, b''))
|
@ -6,7 +6,7 @@ import struct
|
||||
CR = '\r'
|
||||
|
||||
ROMSIZE = 0x400000
|
||||
EMBASE = 0x360000
|
||||
EMBASE = 0x320000
|
||||
|
||||
try:
|
||||
rom_path, = argv[1:]
|
||||
@ -23,7 +23,7 @@ except:
|
||||
exit(1)
|
||||
|
||||
# read special offsets into emulator, from ConfigInfo struct
|
||||
em_entry, em_kernel_trap_table = struct.unpack_from('>LL', rom, 0x30d080)
|
||||
em_entry, em_kernel_trap_table = struct.unpack_from('>LL', rom, 0x30c080)
|
||||
|
||||
labels = {
|
||||
EMBASE: ['EmTop'],
|
||||
|
Loading…
Reference in New Issue
Block a user