Improve seccfg error handling

This commit is contained in:
Bjoern Kerler 2023-06-14 22:52:21 +02:00
parent 8d1dc0d295
commit 33e0f93ea0
No known key found for this signature in database
GPG key ID: 52E823BB96A55380
3 changed files with 12 additions and 5 deletions

View file

@ -181,9 +181,11 @@ class legacyext(metaclass=LogBase):
if seccfg_data[:0xC] == b"AND_SECCFG_v": if seccfg_data[:0xC] == b"AND_SECCFG_v":
self.info("Detected V3 Lockstate") self.info("Detected V3 Lockstate")
sc_org = seccfgV3(hwc, self.mtk) sc_org = seccfgV3(hwc, self.mtk)
else: elif seccfg_data[:4] == b"\x4D\x4D\x4D\x4D":
self.info("Detected V4 Lockstate") self.info("Detected V4 Lockstate")
sc_org = seccfgV4(hwc, self.mtk) sc_org = seccfgV4(hwc, self.mtk)
else:
return False, "Unknown lockstate or no lockstate"
if not sc_org.parse(seccfg_data): if not sc_org.parse(seccfg_data):
return False, "Device has is either already unlocked or algo is unknown. Aborting." return False, "Device has is either already unlocked or algo is unknown. Aborting."
writedata = sc_org.create(lockflag=lockflag) writedata = sc_org.create(lockflag=lockflag)

View file

@ -1785,7 +1785,8 @@ class DALegacy(metaclass=LogBase):
else: else:
buffer = bytearray() buffer = bytearray()
bytestoread = length bytestoread = length
self.mtk.daloader.progress.show_progress("Read", 0, length, display) if display:
self.mtk.daloader.progress.show_progress("Read", 0, length, display)
while bytestoread > 0: while bytestoread > 0:
size = bytestoread size = bytestoread
if bytestoread > packetsize: if bytestoread > packetsize:
@ -1799,6 +1800,8 @@ class DALegacy(metaclass=LogBase):
rpos = length - bytestoread rpos = length - bytestoread
else: else:
rpos = 0 rpos = 0
self.mtk.daloader.progress.show_progress("Read", rpos, length, display) if display:
self.mtk.daloader.progress.show_progress("Read", length, length, display) self.mtk.daloader.progress.show_progress("Read", rpos, length, display)
if display:
self.mtk.daloader.progress.show_progress("Read", length, length, display)
return buffer return buffer

View file

@ -524,9 +524,11 @@ class xflashext(metaclass=LogBase):
if seccfg_data[:0xC] == b"AND_SECCFG_v": if seccfg_data[:0xC] == b"AND_SECCFG_v":
self.info("Detected V3 Lockstate") self.info("Detected V3 Lockstate")
sc_org = seccfgV3(hwc, self.mtk) sc_org = seccfgV3(hwc, self.mtk)
else: elif seccfg_data[:4] == b"\x4D\x4D\x4D\x4D":
self.info("Detected V4 Lockstate") self.info("Detected V4 Lockstate")
sc_org = seccfgV4(hwc, self.mtk) sc_org = seccfgV4(hwc, self.mtk)
else:
return False, "Unknown lockstate or no lockstate"
if not sc_org.parse(seccfg_data): if not sc_org.parse(seccfg_data):
return False, "Device has is either already unlocked or algo is unknown. Aborting." return False, "Device has is either already unlocked or algo is unknown. Aborting."
writedata = sc_org.create(lockflag=lockflag) writedata = sc_org.create(lockflag=lockflag)