-
Notifications
You must be signed in to change notification settings - Fork 5
/
draytek_fw.ksy
107 lines (98 loc) · 1.96 KB
/
draytek_fw.ksy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
meta:
id: draytek
file-extension: all
endian: be
params:
- id: has_dlm
type: bool
seq:
- id: bin
type: bin_section
- id: web
type: web_section
types:
u3:
seq:
- id: b12
type: u2
- id: b3
type: u1
instances:
value:
value: '(b12 << 12) | b3'
bin_header:
seq:
- id: size
type: u4
- id: version_info
type: u1
- id: next_section
type: u3
- id: rest
size: 0xf8
instances:
adj_size:
value: (((size + 3) >> 2) -1 ) << 2
bootloader_version:
value: version_info >> 4
product_number:
value: version_info & 0xf
bootloader:
seq:
- id: data
type: u4
repeat: until
repeat-until: _ == 0xa55aa55a
rtos:
seq:
- id: rtos_size
type: u4
- id: data
size: rtos_size
- id: padding
size: 4 - _io.pos % 4 # Check if there is no other data
if: _io.pos % 4 != 0
dlm:
seq:
- id: magic
contents: DLM/1.0
- id: data
size: _parent.header.adj_size - _io.pos
bin_section:
seq:
- id: header
type: bin_header
- id: bootloader
type: bootloader
- id: rtos
type: rtos
- id: dlm
type: dlm
if: _parent.has_dlm
- id: not_checksum
type: u4
instances:
checksum:
value: not_checksum ^ 0xffffffff
web_header:
seq:
- id: size
type: u4
- id: next_section
type: u4
instances:
adj_size:
value: (((size + 3) >> 2) -1 ) << 2
web_section:
seq:
- id: header
type: web_header
- id: data
size: header.next_section
- id: padding
size: header.size - header.next_section - 12
- id: not_checksum
type: u4
instances:
checksum:
value: not_checksum ^ 0xffffffff