Skip to content

Commit

Permalink
nandtwl: re-add partition files (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihaveamac committed May 23, 2021
1 parent 4382bb5 commit 8b94147
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ninfs/mount/nandtwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ def __init__(self, nand_fp: BinaryIO, g_stat: dict, consoleid: str = None, cid:
if mbr_sig != b'\x55\xaa':
exit(f'MBR signature not found (expected "55aa", got "{mbr_sig.hex()}"). '
f'Make sure the provided Console ID and CID are correct.')
partitions = [[readle(mbr[i + 8:i + 12]) * 0x200,
readle(mbr[i + 12:i + 16]) * 0x200] for i in range(0, 0x40, 0x10)]

for idx, part in enumerate(partitions):
if part[0]:
ptype = 'enc' if idx < 2 else 'dec'
pname = ('twl_main', 'twl_photo', 'twl_unk1', 'twk_unk2')[idx]
self.files[f'/{pname}.img'] = {'offset': part[0], 'size': part[1], 'type': ptype}

def __del__(self, *args):
try:
Expand Down

0 comments on commit 8b94147

Please sign in to comment.