Kaitai Struct YAML

or try loading some examples:

meta: id: dos_mz title: DOS MZ executable endian: le file-extension: - exe - ovl license: CC0-1.0 doc: | DOS MZ file format is a traditional format for executables in MS-DOS environment. Many modern formats (i.e. Windows PE) still maintain compatibility stub with this format. As opposed to .com file format (which basically sports one 64K code segment of raw CPU instructions), DOS MZ .exe file format allowed more flexible memory management, loading of larger programs and added support for relocations. seq: - id: hdr type: mz_header - id: mz_header2 size: hdr.relocations_ofs - 0x1c - id: relocations type: relocation repeat: expr repeat-expr: hdr.qty_relocations - id: body size-eos: true types: mz_header: seq: - id: magic size: 2 - id: last_page_extra_bytes type: u2 - id: qty_pages type: u2 - id: qty_relocations type: u2 - id: header_size type: u2 - id: min_allocation type: u2 - id: max_allocation type: u2 - id: initial_ss type: u2 - id: initial_sp type: u2 - id: checksum type: u2 - id: initial_ip type: u2 - id: initial_cs type: u2 - id: relocations_ofs type: u2 - id: overlay_id type: u2 relocation: seq: - id: ofs type: u2 - id: seg type: u2 #instances: # relocations: # pos: relocations_ofs # type: relocation # repeat: expr # repeat-expr: hdr.qty_relocations
meta: id: doom_wad endian: le file-extension: wad application: id Tech 1 seq: - id: magic type: str size: 4 encoding: ASCII - id: index_qty type: s4 - id: index_offset type: s4 instances: index: pos: index_offset type: index_entry repeat: expr repeat-expr: index_qty types: index_entry: seq: - id: offset type: s4 - id: size type: s4 - id: name type: str size: 8 encoding: ASCII instances: contents: io: _root._io pos: offset size: size
meta: id: doom_wad application: id Tech 1 file-extension: wad license: CC0-1.0 endian: le seq: - id: magic type: str size: 4 encoding: ASCII - id: num_index_entries type: s4 doc: Number of entries in the lump index - id: index_offset type: s4 doc: Offset to the start of the index types: index_entry: seq: - id: offset type: s4 - id: size type: s4 - id: name type: str size: 8 encoding: ASCII pad-right: 0 instances: contents: io: _root._io pos: offset size: size type: switch-on: name cases: '"THINGS"': things '"LINEDEFS"': linedefs '"SIDEDEFS"': sidedefs '"VERTEXES"': vertexes '"BLOCKMAP"': blockmap '"SECTORS"': sectors '"TEXTURE1"': texture12 '"TEXTURE2"': texture12 '"PNAMES"': pnames things: seq: - id: entries type: thing repeat: eos thing: seq: - id: x type: s2 - id: y type: s2 - id: angle type: u2 - id: type type: u2 - id: flags type: u2 linedefs: seq: - id: entries type: linedef repeat: eos linedef: seq: - id: vertex_start_idx type: u2 - id: vertex_end_idx type: u2 - id: flags type: u2 - id: line_type type: u2 - id: sector_tag type: u2 - id: sidedef_right_idx type: u2 - id: sidedef_left_idx type: u2 sidedefs: seq: - id: entries type: sidedef repeat: eos sidedef: seq: - id: offset_x type: s2 - id: offset_y type: s2 - id: upper_texture_name type: str size: 8 encoding: ASCII - id: lower_texture_name type: str size: 8 encoding: ASCII - id: normal_texture_name type: str size: 8 encoding: ASCII - id: sector_id type: s2 vertexes: seq: - id: entries type: vertex repeat: eos vertex: seq: - id: x type: s2 - id: y type: s2 blockmap: seq: - id: origin_x type: s2 doc: Grid origin, X coord - id: origin_y type: s2 doc: Grid origin, Y coord - id: num_cols type: s2 doc: Number of columns - id: num_rows type: s2 doc: Number of rows - id: linedefs_in_block type: blocklist repeat: expr repeat-expr: num_cols * num_rows doc: Lists of linedefs for every block types: blocklist: seq: - id: offset type: u2 doc: Offset to the list of linedefs instances: linedefs: pos: offset * 2 type: s2 repeat: until repeat-until: _ == -1 doc: List of linedefs found in this block sectors: seq: - id: entries type: sector repeat: eos sector: seq: - id: floor_z type: s2 - id: ceil_z type: s2 - id: floor_flat type: str size: 8 encoding: ASCII - id: ceil_flat type: str size: 8 encoding: ASCII - id: light type: s2 doc: | Light level of the sector [0..255]. Original engine uses COLORMAP to render lighting, so only 32 actual levels are available (i.e. 0..7, 8..15, etc). - id: special_type type: u2 enum: special_sector - id: tag type: u2 doc: | Tag number. When the linedef with the same tag number is activated, some effect will be triggered in this sector. enums: special_sector: 0: normal 1: d_light_flicker 2: d_light_strobe_fast 3: d_light_strobe_slow 4: d_light_strobe_hurt 5: d_damage_hellslime 7: d_damage_nukage 8: d_light_glow 9: secret 10: d_sector_door_close_in_30 11: d_damage_end 12: d_light_strobe_slow_sync 13: d_light_strobe_fast_sync 14: d_sector_door_raise_in_5_mins 15: d_friction_low 16: d_damage_super_hellslime 17: d_light_fire_flicker 18: d_damage_lava_wimpy 19: d_damage_lava_hefty 20: d_scroll_east_lava_damage 21: light_phased 22: light_sequence_start 23: light_sequence_special1 24: light_sequence_special2 texture12: doc: | Used for TEXTURE1 and TEXTURE2 lumps, which designate how to combine wall patches to make wall textures. This essentially provides a very simple form of image compression, allowing certain elements ("patches") to be reused / recombined on different textures for more variety in the game. doc-ref: http://doom.wikia.com/wiki/TEXTURE1 seq: - id: num_textures type: s4 doc: Number of wall textures - id: textures type: texture_index repeat: expr repeat-expr: num_textures types: texture_index: seq: - id: offset type: s4 instances: body: pos: offset type: texture_body texture_body: -orig-id: maptexture_t seq: - id: name type: str size: 8 pad-right: 0 encoding: ASCII doc: Name of a texture, only `A-Z`, `0-9`, `[]_-` are valid - id: masked type: u4 - id: width type: u2 - id: height type: u2 - id: column_directory type: u4 doc: Obsolete, ignored by all DOOM versions - id: num_patches type: u2 doc: Number of patches that are used in a texture - id: patches type: patch repeat: expr repeat-expr: num_patches patch: -orig-id: mappatch_t seq: - id: origin_x type: s2 doc: X offset to draw a patch at (pixels from left boundary of a texture) - id: origin_y type: s2 doc: Y offset to draw a patch at (pixels from upper boundary of a texture) - id: patch_id type: u2 doc: Identifier of a patch (as listed in PNAMES lump) to draw - id: step_dir type: u2 - id: colormap type: u2 pnames: doc-ref: http://doom.wikia.com/wiki/PNAMES seq: - id: num_patches type: u4 doc: Number of patches registered in this global game directory - id: names type: str size: 8 encoding: ASCII pad-right: 0 repeat: expr repeat-expr: num_patches instances: index: pos: index_offset type: index_entry repeat: expr repeat-expr: num_index_entries
meta: id: ipv4_packet ks-version: 0.7 seq: - id: b1 type: u1 - id: b2 type: u1 - id: total_length type: u2be - id: identification type: u2be - id: b67 type: u2be - id: ttl type: u1 - id: protocol type: u1 enum: protocol_enum - id: header_checksum type: u2be - id: src_ip_addr size: 4 - id: dst_ip_addr size: 4 - id: options type: ipv4_options size: ihl_bytes - 20 - id: body size: total_length - ihl_bytes enums: protocol_enum: # http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml 0: hopopt 1: icmp 2: igmp 3: ggp 4: ipv4 5: st 6: tcp 7: cbt 8: egp 9: igp 10: bbn_rcc_mon 11: nvp_ii 12: pup 13: argus 14: emcon 15: xnet 16: chaos 17: udp 18: mux 19: dcn_meas 20: hmp 21: prm 22: xns_idp 23: trunk_1 24: trunk_2 25: leaf_1 26: leaf_2 27: rdp 28: irtp 29: iso_tp4 30: netblt 31: mfe_nsp 32: merit_inp 33: dccp 34: x_3pc 35: idpr 36: xtp 37: ddp 38: idpr_cmtp 39: tp_plus_plus 40: il 41: ipv6 42: sdrp 43: ipv6_route 44: ipv6_frag 45: idrp 46: rsvp 47: gre 48: dsr 49: bna 50: esp 51: ah 52: i_nlsp 53: swipe 54: narp 55: mobile 56: tlsp 57: skip 58: ipv6_icmp 59: ipv6_nonxt 60: ipv6_opts 61: any_host_internal_protocol 62: cftp 63: any_local_network 64: sat_expak 65: kryptolan 66: rvd 67: ippc 68: any_distributed_file_system 69: sat_mon 70: visa 71: ipcv 72: cpnx 73: cphb 74: wsn 75: pvp 76: br_sat_mon 77: sun_nd 78: wb_mon 79: wb_expak 80: iso_ip 81: vmtp 82: secure_vmtp 83: vines 84: ttp 84: iptm 85: nsfnet_igp 86: dgp 87: tcf 88: eigrp 89: ospfigp 90: sprite_rpc 91: larp 92: mtp 93: ax_25 94: ipip 95: micp 96: scc_sp 97: etherip 98: encap 99: any_private_encryption_scheme 100: gmtp 101: ifmp 102: pnni 103: pim 104: aris 105: scps 106: qnx 107: a_n 108: ipcomp 109: snp 110: compaq_peer 111: ipx_in_ip 112: vrrp 113: pgm 114: any_0_hop 115: l2tp 116: ddx 117: iatp 118: stp 119: srp 120: uti 121: smp 122: sm 123: ptp 124: isis_over_ipv4 125: fire 126: crtp 127: crudp 128: sscopmce 129: iplt 130: sps 131: pipe 132: sctp 133: fc 134: rsvp_e2e_ignore 135: mobility_header 136: udplite 137: mpls_in_ip 138: manet 139: hip 140: shim6 141: wesp 142: rohc 255: reserved_255 instances: version: value: (b1 & 0xf0) >> 4 ihl: value: b1 & 0xf ihl_bytes: value: ihl * 4 types: ipv4_options: seq: - id: entries type: ipv4_option repeat: eos ipv4_option: seq: - id: b1 type: u1 - id: len type: u1 - id: body size: 'len > 2 ? len - 2 : 0' instances: copy: value: (b1 & 0b10000000) >> 7 opt_class: value: (b1 & 0b01100000) >> 5 number: value: (b1 & 0b00011111)
meta: id: gif file-extension: gif title: GIF (Graphics Interchange Format) image file endian: le license: CC0-1.0 doc: | GIF (Graphics Interchange Format) is an image file format, developed in 1987. It became popular in 1990s as one of the main image formats used in World Wide Web. GIF format allows encoding of palette-based images up to 256 colors (each of the colors can be chosen from a 24-bit RGB colorspace). Image data stream uses LZW (Lempel–Ziv–Welch) lossless compression. Over the years, several version of the format were published and several extensions to it were made, namely, a popular Netscape extension that allows to store several images in one file, switching between them, which produces crude form of animation. Structurally, format consists of several mandatory headers and then a stream of blocks follows. Blocks can carry additional metainformation or image data. seq: - id: hdr type: header - id: logical_screen_descriptor type: logical_screen_descriptor_struct - id: global_color_table type: color_table if: logical_screen_descriptor.has_color_table size: logical_screen_descriptor.color_table_size * 3 doc-ref: https://www.w3.org/Graphics/GIF/spec-gif89a.txt - section 18 - id: blocks type: block repeat: eos types: header: doc-ref: https://www.w3.org/Graphics/GIF/spec-gif89a.txt - section 17 seq: - id: magic contents: 'GIF' - id: version type: str size: 3 encoding: ASCII logical_screen_descriptor_struct: doc-ref: https://www.w3.org/Graphics/GIF/spec-gif89a.txt - section 18 seq: - id: screen_width type: u2 - id: screen_height type: u2 - id: flags type: u1 - id: bg_color_index type: u1 - id: pixel_aspect_ratio type: u1 instances: has_color_table: value: '(flags & 0b10000000) != 0' color_table_size: value: '2 << (flags & 7)' color_table: doc-ref: https://www.w3.org/Graphics/GIF/spec-gif89a.txt - section 19 seq: - id: entries type: color_table_entry repeat: eos color_table_entry: seq: - id: red type: u1 - id: green type: u1 - id: blue type: u1 block: seq: - id: block_type type: u1 enum: block_type - id: body type: switch-on: block_type cases: 'block_type::extension': extension 'block_type::local_image_descriptor': local_image_descriptor local_image_descriptor: seq: - id: left type: u2 - id: top type: u2 - id: width type: u2 - id: height type: u2 - id: flags type: u1 - id: local_color_table type: color_table if: has_color_table size: color_table_size * 3 - id: image_data type: image_data instances: has_color_table: value: '(flags & 0b10000000) != 0' has_interlace: value: '(flags & 0b01000000) != 0' has_sorted_color_table: value: '(flags & 0b00100000) != 0' color_table_size: value: '2 << (flags & 7)' image_data: doc-ref: https://www.w3.org/Graphics/GIF/spec-gif89a.txt - section 22 seq: - id: lzw_min_code_size type: u1 - id: subblocks type: subblocks extension: seq: - id: label type: u1 enum: extension_label - id: body type: switch-on: label cases: 'extension_label::application': ext_application 'extension_label::comment': subblocks 'extension_label::graphic_control': ext_graphic_control _: subblocks ext_application: seq: - id: application_id type: subblock - id: subblocks type: subblock repeat: until repeat-until: _.num_bytes == 0 ext_graphic_control: doc-ref: https://www.w3.org/Graphics/GIF/spec-gif89a.txt - section 23 seq: - id: block_size contents: [4] - id: flags type: u1 - id: delay_time type: u2 - id: transparent_idx type: u1 - id: terminator contents: [0] instances: transparent_color_flag: value: '(flags & 0b00000001) != 0' user_input_flag: value: '(flags & 0b00000010) != 0' subblocks: seq: - id: entries type: subblock repeat: until repeat-until: _.num_bytes == 0 subblock: seq: - id: num_bytes type: u1 - id: bytes size: num_bytes enums: block_type: 0x21: extension 0x2c: local_image_descriptor 0x3b: end_of_file extension_label: 0xf9: graphic_control 0xfe: comment 0xff: application
meta: id: zip file-extension: zip endian: le license: CC0-1.0 doc-ref: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT seq: - id: sections type: pk_section repeat: eos types: pk_section: seq: - id: magic contents: 'PK' - id: section_type type: u2 - id: body type: switch-on: section_type cases: 0x0201: central_dir_entry 0x0403: local_file 0x0605: end_of_central_dir local_file: seq: - id: header type: local_file_header - id: body size: header.compressed_size local_file_header: seq: - id: version type: u2 - id: flags type: u2 - id: compression_method type: u2 enum: compression - id: file_mod_time type: u2 - id: file_mod_date type: u2 - id: crc32 type: u4 - id: compressed_size type: u4 - id: uncompressed_size type: u4 - id: file_name_len type: u2 - id: extra_len type: u2 - id: file_name type: str size: file_name_len encoding: UTF-8 - id: extra size: extra_len type: extras central_dir_entry: doc-ref: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT - 4.3.12 seq: - id: version_made_by type: u2 - id: version_needed_to_extract type: u2 - id: flags type: u2 - id: compression_method type: u2 enum: compression - id: last_mod_file_time type: u2 - id: last_mod_file_date type: u2 - id: crc32 type: u4 - id: compressed_size type: u4 - id: uncompressed_size type: u4 - id: file_name_len type: u2 - id: extra_len type: u2 - id: comment_len type: u2 - id: disk_number_start type: u2 - id: int_file_attr type: u2 - id: ext_file_attr type: u4 - id: local_header_offset type: s4 - id: file_name type: str size: file_name_len encoding: UTF-8 - id: extra size: extra_len type: extras - id: comment type: str size: comment_len encoding: UTF-8 instances: local_header: pos: local_header_offset type: pk_section # https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT - 4.3.16 end_of_central_dir: seq: - id: disk_of_end_of_central_dir type: u2 - id: disk_of_central_dir type: u2 - id: qty_central_dir_entries_on_disk type: u2 - id: qty_central_dir_entries_total type: u2 - id: central_dir_size type: u4 - id: central_dir_offset type: u4 - id: comment_len type: u2 - id: comment type: str size: comment_len encoding: UTF-8 extras: seq: - id: entries type: extra_field repeat: eos extra_field: seq: - id: code type: u2 enum: extra_codes - id: size type: u2 - id: body size: size type: switch-on: code cases: 'extra_codes::ntfs': ntfs 'extra_codes::extended_timestamp': extended_timestamp 'extra_codes::infozip_unix_var_size': infozip_unix_var_size types: ntfs: doc-ref: 'https://github.com/LuaDist/zip/blob/master/proginfo/extrafld.txt#L191' seq: - id: reserved type: u4 - id: attributes type: attribute repeat: eos types: attribute: seq: - id: tag type: u2 - id: size type: u2 - id: body size: size type: switch-on: tag cases: 1: attribute_1 attribute_1: seq: - id: last_mod_time type: u8 - id: last_access_time type: u8 - id: creation_time type: u8 extended_timestamp: doc-ref: 'https://github.com/LuaDist/zip/blob/master/proginfo/extrafld.txt#L817' seq: - id: flags type: u1 - id: mod_time type: u4 - id: access_time type: u4 if: not _io.eof - id: create_time type: u4 if: not _io.eof infozip_unix_var_size: doc-ref: 'https://github.com/LuaDist/zip/blob/master/proginfo/extrafld.txt#L1339' seq: - id: version type: u1 doc: Version of this extra field, currently 1 - id: uid_size type: u1 doc: Size of UID field - id: uid size: uid_size doc: UID (User ID) for a file - id: gid_size type: u1 doc: Size of GID field - id: gid size: gid_size doc: GID (Group ID) for a file enums: compression: 0: none 1: shrunk 2: reduced_1 3: reduced_2 4: reduced_3 5: reduced_4 6: imploded 8: deflated 9: enhanced_deflated 10: pkware_dcl_imploded 12: bzip2 14: lzma 18: ibm_terse 19: ibm_lz77_z 98: ppmd extra_codes: # https://github.com/LuaDist/zip/blob/master/proginfo/extrafld.txt 0x0001: zip64 0x0007: av_info # 0x0008: reserved for extended language encoding data (PFS) (see APPENDIX D) 0x0009: os2 0x000a: ntfs 0x000c: openvms 0x000d: pkware_unix 0x000e: file_stream_and_fork_descriptors 0x000f: patch_descriptor 0x0014: pkcs7 0x0015: x509_cert_id_and_signature_for_file 0x0016: x509_cert_id_for_central_dir 0x0017: strong_encryption_header 0x0018: record_management_controls 0x0019: pkcs7_enc_recip_cert_list 0x0065: ibm_s390_uncomp 0x0066: ibm_s390_comp 0x4690: poszip_4690 0x5455: extended_timestamp 0x7855: infozip_unix 0x7875: infozip_unix_var_size