Skip to content

Instantly share code, notes, and snippets.

@pzskc383
Created November 28, 2019 04:14
Show Gist options
  • Save pzskc383/edd1d2dd4faebe0d5a94baabd214a300 to your computer and use it in GitHub Desktop.
Save pzskc383/edd1d2dd4faebe0d5a94baabd214a300 to your computer and use it in GitHub Desktop.
apm_partition_table.ksy
meta:
id: apm_partition_table (bit better wrong)
title: APM (Apple Partition Map) partition table
license: CC0-1.0
endian: be
encoding: ascii
doc-ref: Specification taken from https://en.wikipedia.org/wiki/Apple_Partition_Map
doc-ref: https://opensource.apple.com/source/pdisk/pdisk-9/dpme.h.auto.html
doc-ref: https://opensource.apple.com/source/IOStorageFamily/IOStorageFamily-92.9/IOApplePartitionScheme.h.auto.html
types:
ddm:
seq:
- id: block_start
type: u4
- id: block_size
type: u2
- id: system_type
type: u2
boot_data:
seq:
- id: boot_code_start
type: u4
doc: "Boot block start"
- id: boot_code_size
type: u4
doc: "Boot block size"
- id: boot_code_load_addr
type: u4
doc: "Address of bootloader code"
- id: boot_code_load_addr2
type: u4
- id: boot_code_goto_addr
type: u4
doc: "Boot code entry point"
- id: boot_code_goto_addr2
type: u4
- id: boot_code_cksum
type: u4
doc: "Boot code checksum"
- id: processor_type
type: strz
size: 0x10
- id: boot_args
size: 4*32
block_zero:
seq:
- id: magic
contents: "ER"
- id: device_blocksize
type: u2
- id: device_blockcount
type: u4
- id: device_type
type: u2
- id: device_id
type: u2
- id: driver_data
type: u4
- id: driver_count
type: u2
- id: driver_table
type: ddm
repeat: expr
repeat-expr: 8
- id: reserved
size: 430
partition_flags:
seq:
- id: reserved
type: b23
- id: os_specific1
type: b1
- id: os_specific2
type: b1
- id: os_pic_code
type: b1
- id: writable
type: b1
- id: readable
type: b1
- id: bootable
type: b1
- id: in_use
type: b1
- id: allocated
type: b1
- id: valid
type: b1
partition_entry:
seq:
- id: magic
contents: [ 0x50, 0x4d ]
- id: reserved_1
size: 0x2
- id: number_of_partitions
type: u4
- id: partition_start
type: u4
doc: "First sector"
- id: partition_size
type: u4
doc: "Number of sectors"
- id: partition_name
type: strz
size: 0x20
- id: partition_type
type: strz
size: 0x20
- id: lblock_start
type: u4
doc: "First sector"
- id: lblock_size
type: u4
doc: "Number of sectors"
- id: status_flags
type: partition_flags
- id: boot
type: boot_data
- id: reserved3
size: 4*62
instances:
block0:https://opensource.apple.com/source/IOStorageFamily/IOStorageFamily-92.9/IOApplePartitionScheme.h.auto.html
type: block_zero
pos: 0x0
partition_map:
type: partition_entry
pos: block0.device_blocksize
partitions:
type: partition_entry
pos: block0.device_blocksize
repeat: expr
repeat-expr: partition_map.number_of_partitions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment