From f004854d5f2a0bc246a2524ddb843e369b21de99 Mon Sep 17 00:00:00 2001 From: itsme Date: Tue, 13 Jul 2021 21:19:11 +0200 Subject: now the enumerate_XXX functions actually work --- crodump.py | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'crodump.py') diff --git a/crodump.py b/crodump.py index 5b495de..984770f 100644 --- a/crodump.py +++ b/crodump.py @@ -78,9 +78,16 @@ class Datafile: if self.use64bit: # 01.03 has 64 bit file offsets self.tadidx = [ struct.unpack_from(" 1: _ = rd.readbyte() # always 0 anyway + self.unk2 = rd.readbyte() # if this is not 5 (but 9), there's another 4 bytes inserted, this could be a length-byte. self.unk3 = rd.readbyte() - if self.unk2 > 5: # seen only 5 and 9 for now with 9 implying an extra dword _ = rd.readdword() + self.unk4 = rd.readdword() self.tableid = rd.readdword() - self.unk5 = rd.readdword() self.tablename = rd.readname() self.abbrev = rd.readname() @@ -293,10 +300,13 @@ class TableDefinition: self.remainingdata = rd.readbytes() + def __str__(self): + return "%d,%d<%d,%d,%d>%d %d,%d '%s' '%s'" % ( self.unk1, self.version, self.unk2, self.unk3, self.unk4, self.tableid, self.unk7, len(self.fields), self.tablename, self.abbrev) def dump(self, args): if args.verbose: print("table: %s" % tohex(self.headerdata)) - print("%d,%d,%d,%d,%d,%d %d,%d '%s' '%s'" % ( self.unk1, self.version, self.unk2, self.unk3, self.tableid, self.unk5, self.unk7, len(self.fields), self.tablename, self.abbrev)) + + print(str(self)) for field in self.fields: if args.verbose: @@ -345,6 +355,8 @@ class Database: self.sys = self.getfile("Sys") # BankTemp, Int + def nrofrecords(self): + return len(self.bank.tadidx) def getfile(self, name): try: @@ -440,26 +452,26 @@ class Database: for rec in db.enumerate_records(tab): print(sqlformatter(tab, rec)) """ - for i in range(1, args.maxrecs+1): - data = db.readrec(i) - if data and struct.unpack_from("0 or data.find(b"\x1b")>0): print("%d -> %s" % (i, b2a_hex(data))) @@ -509,10 +521,6 @@ class Database: if v: print("%5d * %02x" % (v, k)) - def readrec(self, sysnum): - data = self.bank.readrec(sysnum) - tabnum, = struct.unpack_from("