diff --git a/edlclient/Tools/fhloaderparse b/edlclient/Tools/fhloaderparse index ab5e0cb..6439339 100755 --- a/edlclient/Tools/fhloaderparse +++ b/edlclient/Tools/fhloaderparse @@ -6,6 +6,7 @@ import hashlib from struct import unpack, pack from shutil import copyfile import os, sys, inspect +from io import BytesIO current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parent_dir = os.path.dirname(current_dir) sys.path.insert(0, parent_dir) @@ -50,7 +51,7 @@ def grabtext(data): return text -def extract_hdr(memsection, sign_info, mem_section, code_size, signature_size): +def extract_hdr(memsection, version, sign_info, mem_section, code_size, signature_size, hdr1, hdr2, hdr3, hdr4): try: md_size = \ unpack("= 6: # SDM - signinfo = extract_hdr(memsection, signinfo, mem_section, code_size, signature_size) + signinfo = extract_hdr(memsection, version, signinfo, mem_section, code_size, signature_size, hdr1, + hdr2, hdr3, hdr4) if signinfo is None: continue filelist.append(signinfo) + break else: print("Unknown version for " + filename) continue - elif hdr == 0x844BDCD1: + if elfpos == -1 and int.from_bytes(data[:4],'little') == 0x844BDCD1: mbn = MBN(mem_section) if mbn.sigsz == 0: print("%s has no signature." % filename) @@ -324,7 +340,7 @@ def main(argv): if signinfo is None: continue filelist.append(signinfo) - else: + elif elfpos == -1: print("Error on " + filename) continue @@ -387,7 +403,7 @@ def main(argv): copyfile(item.filename, os.path.join(outputdir, "Duplicate", (loader_info.hw_id + "_" + loader_info.pk_hash[0:16] + "_FHPRG.bin").lower())) - print(item.filename + " does already exist. Skipping") + print(item.filename + f" is duplicate of {hashes[item.hash]}. Skipping") try: rt.write(info + "\n") except: