From ee3dba289edd77f87f4ef733fb8a9aff0ff4d212 Mon Sep 17 00:00:00 2001 From: itsme Date: Fri, 9 Jul 2021 19:57:22 +0200 Subject: crodump: added part of CroSys decoder. --- crodump.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/crodump.py b/crodump.py index 148b3cf..09823b8 100644 --- a/crodump.py +++ b/crodump.py @@ -55,6 +55,10 @@ class Datafile: raise Exception("not a Crofile") self.use64bit = self.version == b'01.03' + if self.version == b'01.11': + # only found in app: v5/CroSys.dat + raise Exception("v01.11 format is not yet supported") + # blocksize # 0040 -> Bank # 0400 -> Index or Sys @@ -264,7 +268,32 @@ def destruct_base_definition(args, data): remaining = rd.readbytes() print("rem: %s" % tohex(remaining)) - + +def destruct_sys3_def(rd): + pass +def destruct_sys4_def(rd): + n = rd.readdword() + for _ in range(n): + marker = rd.readdword() + description = rd.readlongstring() + path = rd.readlongstring() + marker2 = rd.readdword() + + print("%08x;%08x: %-50s : %s" % (marker, marker2, path, description)) + +def destruct_sys_definition(args, data): + """ + decode the 'sys' / dbindex definition + """ + rd = ByteReader(data) + + systype = rd.readbyte() + if systype == 3: + return destruct_sys3_def(rd) + elif systype == 4: + return destruct_sys4_def(rd) + else: + raise Exception("unsupported sys record") class Database: @@ -439,6 +468,13 @@ def stru_dump(args): db = Database(args.dbdir) db.strudump(args) +def sys_dump(args): + """ hexdump all CroSys records """ + + db = Database(args.dbdir) + if db.sys: + db.sys.dump(args) + def bank_dump(args): """ hexdump all records """ if args.maxrecs: @@ -463,6 +499,8 @@ def destruct(args): destruct_bank_definition(args, data) elif args.type==2: destruct_base_definition(args, data) + elif args.type==3: + destruct_sys_definition(args, data) def main(): import argparse @@ -492,6 +530,14 @@ def main(): p.add_argument('dbdir', type=str) p.set_defaults(handler=cro_dump) + p = subparsers.add_parser('sysdump', help='SYSdumper') + p.add_argument('--verbose', '-v', action='store_true') + p.add_argument('--ascdump', '-a', action='store_true') + p.add_argument('--nodecompress', action='store_false', dest='decompress', default='true') + p.add_argument('dbdir', type=str) + p.set_defaults(handler=sys_dump) + + p = subparsers.add_parser('bankdump', help='BANKdumper') p.add_argument('--verbose', '-v', action='store_true') p.add_argument('--ascdump', '-a', action='store_true') -- cgit v1.2.3