Пример #1
0
    def _parse(self):
        if read_at(self.f, 0x0, 0x4) != b'META':
            raise ValueError('Invalid META magic')
        self.mmu_flags = read_u8(self.f, 0xC)
        self.main_thread_priority = read_u8(self.f, 0xE)
        self.default_cpu_id = read_u8(self.f, 0xF)
        self.process_category = self.process_categories[read_u32(self.f, 0x18)]
        self.main_thread_stack_size = read_u32(self.f, 0x1C)
        self.title_name = read_at(self.f, 0x20, 0x50).strip(b'\0').decode()

        aci0_offset = read_u32(self.f, 0x70)
        aci0_size = read_u32(self.f, 0x74)
        acid_offset = read_u32(self.f, 0x78)
        acid_size = read_u32(self.f, 0x7C)

        self.acid = ACID(io.BytesIO(read_at(self.f, acid_offset, acid_size)))
        self.aci0 = ACI0(io.BytesIO(read_at(self.f, aci0_offset, aci0_size)))
    def __init__(self, raw_header):
        self.rsa_sig_1 = read_at(raw_header, 0x0, 0x100)
        self.rsa_sig_2 = read_at(raw_header, 0x100, 0x100)
        self.magic = read_at(raw_header, 0x200, 0x4)
        self.is_game_card = bool(read_u8(raw_header, 0x204))
        self.content_type = self.content_types[read_u8(raw_header, 0x205)]
        self.crypto_type = read_u8(raw_header, 0x206)
        self.kaek_ind = read_u8(raw_header, 0x207)
        self.size = read_u64(raw_header, 0x208)
        self.tid = read_u64(raw_header, 0x210)
        self.sdk_rev = '.'.join(
            str(read_u8(raw_header, 0x21C + n)) for n in range(4))[::-1]
        self.crypto_type_2 = read_u8(raw_header, 0x220)
        self.sig_key_gen = read_u8(raw_header, 0x221)
        self.rights_id = read_at(raw_header, 0x230, 0x10)

        self.section_tables = []
        for n in range(4):
            raw_section_table = io.BytesIO(
                read_at(raw_header, 0x240 + 0x10 * n, 0x10))
            self.section_tables.append(SectionTable(raw_section_table))

        self.hash_table = []
        for n in range(4):
            self.hash_table.append(read_at(raw_header, 0x280 + n * 0x20, 0x20))
        self.enc_key_area = read_at(raw_header, 0x300, 0x40)

        self.section_headers = []
        for n in range(4):
            if self.section_tables[n].start_offset:  # Sections exists
                raw_section_header = io.BytesIO(
                    read_at(raw_header, 0x400 + n * FS_HEADER_LENGTH,
                            FS_HEADER_LENGTH))
                self.section_headers.append(
                    SectionHeader(raw_section_header, self.section_tables[n]))
    def __init__(self, raw_section_header, section_table):
        self.offset = section_table.start_offset
        self.size = section_table.end_offset - self.offset

        self.part_type = self.part_types[read_u8(raw_section_header, 0x2)]
        self.fs_type = self.fs_types[read_u8(raw_section_header, 0x3)]
        self.crypto_type = self.crypto_types[read_u8(raw_section_header, 0x4)]
        raw_superblock = io.BytesIO(
            read_at(raw_section_header, 0x8, self.SECTION_HEADER_LENGTH))
        self.section_ctr = read_u64(raw_section_header, 0x140)

        if self.fs_type == 'PFS0':
            self.superblock = PFS0Superblock(raw_superblock)
            self.fs_offset = self.superblock.offset
            self.fs_size = self.superblock.size
        elif self.fs_type == 'RomFS':
            self.superblock = IVFCSuperblock(raw_superblock)
            self.fs_offset = self.superblock.lvls[-1].offset
            self.fs_size = self.superblock.lvls[-1].size
Пример #4
0
	def _parse(self):
		self.version     = read_u8(self.f, 0x0)
		self.permissions = read_u64(self.f, 0x4)