Skip to content
Zack Didcott edited this page Apr 7, 2025 · 2 revisions

Summary

Models are the foundation for converting raw binary data into OOP data structures.

Most of the higher-level models are taken directly from igelsdk.h, with added methods to assist data handling.

BaseBytesModel provides an abstract base class, with concrete methods for handling bytes, shared across various models.

BaseDataModel is the parent class for all higher-level models. For these models to be instantiated directly from bytes, they must define fields with metadata containing the size of bytes to read. To set default values when instantiating models from nothing with new, add the default value to the metadata of the field.

All model classes are dataclasses, with fields for each attribute.

Section

  • Stores section header, partition block, hash block and payload
  • Contains a __post_init__ magic dataclass method to parse payload into additional data groups
  • Has methods to calculate hash, split into or extract data, such as partition extents, from sections

Partition

  • Stores partition header and extent information; the actual extent payload is stored at the beginning of the section payload, and can span multiple sections
  • Provides methods to parse partition and extent information

Hash

  • Data group to store hash header, excludes and values
  • Implements calculating hashes, getting digest values and verifying signatures
  • See Verification for more information

Boot Registry

  • Stores basic boot information and boot registry entries
  • Legacy format uses \n-separated key=value pairs, terminated by EOF
  • New format uses fixed-size entry models with a 2-byte flag to indicate size and continuation

Directory

  • Stores directory information to look-up locations of partitions efficiently, without linearly searching the entire filesystem
  • Find:
    • Partition descriptor by partition minor
    • Fragment descriptor by partition descriptor attribute (first_fragment)
    • First section of partition by fragment descriptor attribute (first_section)
  • See directory.c for more background information

Bootsplash

  • Stores extent information from bootsplash partition
  • Contains bootsplash header, list of bootsplash information models and payload
  • Provides method to obtain PIL.Image.Image instances from payload

Extent Filesystem

  • Stores cryptographic information in header alongside encrypted payload
  • Provides methods to handle encryption and compression of writable extent filesystems
  • See Encrypted Partitions for more information

Clone this wiki locally