26 lines
847 B
Python
26 lines
847 B
Python
|
|
import struct
|
||
|
|
|
||
|
|
with open('partitions_backup.bin', 'rb') as f:
|
||
|
|
data = f.read()
|
||
|
|
|
||
|
|
print("Name | Type | SubType | Offset | Size | Flags")
|
||
|
|
print("-" * 75)
|
||
|
|
|
||
|
|
for i in range(0, len(data), 32):
|
||
|
|
entry = data[i:i+32]
|
||
|
|
if len(entry) < 32:
|
||
|
|
break
|
||
|
|
|
||
|
|
magic = struct.unpack('<H', entry[0:2])[0]
|
||
|
|
|
||
|
|
if magic == 0x50aa: # Valid partition magic
|
||
|
|
type_val = entry[2]
|
||
|
|
subtype = entry[3]
|
||
|
|
offset = struct.unpack('<I', entry[4:8])[0]
|
||
|
|
size = struct.unpack('<I', entry[8:12])[0]
|
||
|
|
flags = struct.unpack('<H', entry[12:14])[0]
|
||
|
|
name = entry[16:32].rstrip(b'\x00').decode('ascii', errors='ignore')
|
||
|
|
|
||
|
|
print(f"{name:<13} | {type_val:02x} | {subtype:02x} | 0x{offset:08x} | 0x{size:08x} | {flags:04x}")
|
||
|
|
elif magic == 0xebeb:
|
||
|
|
break # End marker
|