Exemple #1
0
class GPTHeader(
        make_struct('GPTHeader', [
            ('signature', '8s'),
            ('revision', '4s'),
            ('header_size', 'L'),
            ('crc32', 'L'),
            (None, '4s'),
            ('current_lba', 'Q'),
            ('backup_lba', 'Q'),
            ('first_usable_lba', 'Q'),
            ('last_usable_lba', 'Q'),
            ('disk_guid', '16s'),
            ('part_entry_start_lba', 'Q'),
            ('num_part_entries', 'L'),
            ('part_entry_size', 'L'),
            ('crc32_part_array', 'L'),
        ])):
    def _after(self, f):
        if self.signature != b'EFI PART':
            raise Exception('bad signature:', self.signature)
        if self.revision != b'\x00\x00\x01\x00':
            raise Exception('bad revision:', self.revision)
        if self.header_size < 92:
            raise Exception('bad header size:', self.header_size)
        return self._replace(disk_guid=uuid.UUID(bytes_le=self.disk_guid), )
Exemple #2
0
class ImageHeader(
        make_struct('ImageHeader', [
            ('cbSize', 'L'),
            ('signature', '12s'),
            ('ManifestLength', 'L'),
            ('dwChunkSize', 'L'),
        ])):
    def _check(self):
        return self.signature == b'ImageFlash  '
Exemple #3
0
class SecurityHeader(
        make_struct('SecurityHeader', [
            ('cbSize', 'L'),
            ('signature', '12s'),
            ('dwChunkSizeInKb', 'L'),
            ('dwAlgId', 'L'),
            ('dwCatalogSize', 'L'),
            ('dwHashTableSize', 'L'),
        ])):
    def _check(self):
        return self.signature == b'SignedImage '
Exemple #4
0
class BlockDataEntry(
        make_struct('BlockDataEntry', [
            ('dwLocationCount', 'L'),
            ('dwBlockCount', 'L'),
            ('rgDiskLocations', None),
        ])):
    def _after(self, f):
        rgDiskLocations = []
        for _ in range(self.dwLocationCount):
            rgDiskLocations.append(DiskLocation._read(f))
        return self._replace(rgDiskLocations=rgDiskLocations)
Exemple #5
0
class GPTEntry(
        make_struct('GPTEntry', [
            ('type', '16s'),
            ('unique', '16s'),
            ('first_lba', 'Q'),
            ('last_lba', 'Q'),
            ('flags', 'Q'),
            ('name', '72s'),
        ])):
    def _after(self, f):
        if self.type != 16 * b'\x00':
            return self._replace(
                type=str(uuid.UUID(bytes_le=self.type)),
                unique=str(uuid.UUID(bytes_le=self.unique)),
                name=self.name.decode('utf-16').split('\0', 1)[0],
            )
Exemple #6
0

StoreHeader = make_struct(
    'StoreHeader',
    [
        ('dwUpdateType', 'L'),
        ('MajorVersion', 'H'),
        ('MinorVersion', 'H'),
        ('FullFlashMajorVersion', 'H'),
        ('FullFlashMinorVersion', 'H'),
        ('szPlatformId', '192s'),
        ('dwBlockSizeInBytes', 'L'),
        ('dwWriteDescriptorCount', 'L'),
        ('dwWriteDescriptorLength', 'L'),
        ('dwValidateDescriptorCount', 'L'),
        ('dwValidateDescriptorLength', 'L'),
        ('dwInitialTableIndex', 'L'),
        ('dwInitialTableCount', 'L'),
        ('dwFlashOnlyTableIndex', 'L'),
        ('dwFlashOnlyTableCount', 'L'),
        ('dwFinalTableIndex', 'L'),
        ('dwFinalTableCount', 'L'),
        # V2
        # ('NumOfStores'                   , 'H'),
        # ('StoreIndex'                    , 'H'),
        # ('StorePayloadSize'              , 'Q'),
        # ('DevicePathLength'              , 'H'),
        # ('DevicePath'                    , None),
    ])

DiskLocation = make_struct('DiskLocation', [