Skip to content

Instantly share code, notes, and snippets.

@AKosterin
Last active February 27, 2025 12:31
Show Gist options
  • Save AKosterin/4ab0f35be71e901e57879055c602b286 to your computer and use it in GitHub Desktop.
Save AKosterin/4ab0f35be71e901e57879055c602b286 to your computer and use it in GitHub Desktop.
meta:
id: nv
endian: le
file-extension:
- nv
- nvu
seq:
- id: revision
type: u2
- id: nvnumber
type: u2
- id: carrier_id
type: u2
enum: carrier_id
- id: version
type: u4be
- id: nv_items
type: item
if: nvnumber != 0
repeat: expr
repeat-expr: nvnumber
- id: nv_items2
type: item
if: nvnumber == 0
repeat: eos
types:
nv_num:
seq:
- id: num
type: u2
- id: length
type: u4
- id: value
size: length
nv_file_prop:
-webide-representation: '{type}, {loc}, {path}'
seq:
- id: b1
type: u1
instances:
path:
value: (b1 & 0x8 > 0) ? "Relative" : "Absolute"
loc:
value: (b1 & 0x4 > 0) ? "APSS" : "MPSS"
type:
value: (b1 & 0x1 > 0) ? "EFS_ITEM" : "EFS"
nv_file:
seq:
- id: name_magic
contents: [0x01, 0x00]
- id: name_length
type: u4
- id: property
type: nv_file_prop
- id: name
size: name_length - 1
type: str
encoding: ASCII
- id: value_magic
contents: [0x02, 0x00]
- id: value_length
type: u4
- id: value
size: value_length
item:
seq:
- id: length
type: u4
- id: type
type: u1
enum: item_type
- id: attrib
type: u1
- id: opcode
type: u1
enum: operation
- id: arraysize
type: u1
- id: body
size: length - 8
type:
switch-on: type
cases:
'item_type::qctnv': nv_num
'item_type::swinv': nv_file
'item_type::efs': nv_file
'item_type::dirbu': nv_file
enums:
operation:
0x00: none
0x01: write
0x02: delete
0x03: backup
item_type:
0x00: qctnv
0x01: swinv
0x02: efs
0x03: dirbu
carrier_id:
0x00: none
0x01: softbank
0x02: telstra
0x03: bigpond
0x04: att
0x05: verizon
0x06: netindex
0x07: dna
0x08: bell
0x09: telus
0x0a: rogers
0x0b: sprint
0x0c: telefonica
0x0d: zain
0x67: alltel
0x6a: uscellular
0x6c: chinaunicom
0x6d: tnz
0x6e: sktelcom
0x6f: reliance
0x70: tata
0x71: metropcs
0x72: leap
0x73: kddi
0x74: grupo_iusaall
0x75: chinamobile
0x76: omh
0xca: vodafone
0xcb: tmobile
0xcc: orange
0xce: tim
0xcf: three
0xd1: sfr
0xd2: swisscom
0xd5: singapore
0xd7: bhartiairtel
0xd8: nttdcm
0xd9: emobile
0xdb: kt
0xdd: telnor
0xde: netcomenorway
0xe0: amx
0xe1: vivo
0xe2: dish
0xfe: any
meta:
id: swicwe
file-extension:
- bin
- cwe
endian: be
imports:
- nv
seq:
- id: header
type: header
- id: body
size: header.image_sz
type:
switch-on: header.image_type
cases:
'"SPKG"': list
'"FOTO"': list
'"BOOT"': list
'"MODM"': list
'"APPL"': list
'"FILE"': list
'"NVUP"': nv
'"NVBF"': nv
'"NVBO"': nv
'"NVBU"': nv
'"NVBC"': nv
types:
swicwe_foto_toc:
seq:
- id: toc
size: 0x20
#type: swicwe_foto_toc_element
repeat: eos
header:
-webide-representation: 'image_type:{image_type}, prod_type:{prod_type}, size:{image_sz:dec}'
seq:
- id: prod_buf
size: 0x100
- id: psb_crc
type: u4be
- id: hdr_rev
type: u4
- id: crc_ind
type: str
encoding: ASCII
size: 4
- id: image_type
type: str
encoding: ASCII
size: 4
- id: prod_type
type: str
encoding: ASCII
size: 4
- id: image_sz
type: u4
- id: image_crc
type: u4
- id: version
type: str
encoding: ASCII
size: 84
- id: rel_date
type: str
encoding: ASCII
size: 8
- id: compat
type: u4
- id: misc_opts
type: u1
- id: reserved1
type: u1
- id: reserved2
type: u1
- id: reserved3
type: u1
- id: stor_addr
type: u4
- id: prog_addr
type: u4
- id: entry_pt
type: u4
- id: signature
type: u4
list:
seq:
- id: list
type: swicwe
repeat: eos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment