Skip to content

Commit

Permalink
Use the partition flags to detect if a partition has data in ROM
Browse files Browse the repository at this point in the history
  • Loading branch information
corna committed Oct 22, 2017
1 parent 210adf0 commit 2ea3387
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions me_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ def start_end_to_flreg(start, end):

for i in range(entries):
partition = partitions[i * 0x20:(i + 1) * 0x20]
flags = unpack("<I", partition[0x1c:0x20])[0]

try:
part_name = \
Expand All @@ -629,12 +630,17 @@ def start_end_to_flreg(start, end):
part_start, part_length = unpack("<II", partition[0x08:0x10])
part_end = part_start + part_length

if part_start == 0 or part_length == 0 or part_end > me_end:
print(" {:<4} ({:^23}, 0x{:08x} total bytes): nothing to "
if flags & 0x7f == 2:
print(" {:<4} ({:^24}, 0x{:08x} total bytes): nothing to "
"remove"
.format(part_name, "NVRAM partition, no data",
part_length))
elif part_start == 0 or part_length == 0 or part_end > me_end:
print(" {:<4} ({:^24}, 0x{:08x} total bytes): nothing to "
"remove"
.format(part_name, "no data here", part_length))
else:
sys.stdout.write(" {:<4} (0x{:08x} - 0x{:08x}, 0x{:08x} "
sys.stdout.write(" {:<4} (0x{:08x} - 0x{:09x}, 0x{:08x} "
"total bytes): ".format(part_name,
part_start,
part_end,
Expand Down

0 comments on commit 2ea3387

Please sign in to comment.