# uncompyle6 version 3.9.3 # Python bytecode version base 2.6 (62161) # Decompiled from: Python 3.9.25 (main, Oct 31 2025, 23:16:49) # [GCC 14.2.0] # Embedded file name: countDSPs.pyc # Compiled at: 2025-01-21 13:03:48 import shutil, zipfile, os, datetime, time, struct, sys row = 200 column = 300 sys.stdout.write(('\x1b[8;{rows};{cols}t').format(rows=row, cols=column)) print '\x1b[3;0;0t' time.sleep(0.1) flashDiskStartAddress = 262144 imageStartAddress = 65536 removeLock = True def unzipAndExtractFFI(path): if zipfile.is_zipfile(path): zfile = zipfile.ZipFile(path, 'r') lockData = '' for info in zfile.infolist(): fname = info.filename if len(fname) < 8: continue if fname.endswith('info.lst'): lockData = zfile.read(fname) continue else: data = zfile.read(fname) try: return ( data, lockData) except: return ([], []) else: f = open(path, 'rb') data = f.read() f.close() return (data, '') return def createDir(file): myPath = os.path.split(file)[0].split('/') for i in range(5, len(myPath) + 1): path = '' for j in range(i): path += '/' + myPath[j] if not os.path.exists(path): os.mkdir(path) return def Walk(root, recurse=1, pattern='*', return_folders=0, return_files=1): import fnmatch, os, string result = [] try: names = os.listdir(root) except os.error: return result else: pattern = pattern or '*' pat_list = string.splitfields(pattern, ';') for name in names: fullname = os.path.normpath(os.path.join(root, name)) for pat in pat_list: if fnmatch.fnmatch(name, pat): if return_files == 1 and os.path.isfile(fullname) or return_folders == 1 and os.path.isdir(fullname): if fullname.find('.') >= 0 and return_files != 1: continue result.append(fullname) continue if recurse: if os.path.isdir(fullname) and not os.path.islink(fullname): result = result + Walk(fullname, recurse, pattern, return_folders) return result loaderStartPositions = {944: 'MK2.1', 3488: 'MK2.2', 3760: 'MK2.3', 4320: 'MK2.5', 52: 'MK1', 0: 'MK3.1'} def countDSPs(srcData): aantalNullen = 0 aantalEnen = 0 lastV = -1 pos = 0 loaderStartPos = 0 dataStartPos = 0 for vChar in srcData: v = ord(vChar) if v == 0 and lastV == 0: aantalNullen += 1 if v == 255 and lastV == 255: aantalEnen += 1 if aantalNullen > 32 and loaderStartPos == 0: if v != 0: loaderStartPos = pos if aantalEnen > 32 and dataStartPos == 0: if v != 255: dataStartPos = pos break if v != 0: aantalNullen = 0 lastV = v pos += 1 if pos > 5000: break try: return loaderStartPositions[loaderStartPos] except: print 'Error: onbekende loader start pos', loaderStartPos return return if __name__ == '__main__': ffiFiles = Walk(os.getcwd()) print ' ' for ffiFile in ffiFiles: if ffiFile.endswith('.ffi') == False: continue (srcData, lockData) = unzipAndExtractFFI(ffiFile) aantalDSPs = countDSPs(srcData) print ffiFile, 'Aantal DSPs:', aantalDSPs # okay decompiling pycode/countDSPs.pyc