-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnbrf.ksy
319 lines (284 loc) · 7.87 KB
/
nbrf.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
meta:
id: nrbf
endian: le
application: .NET
imports:
- vlq_base128_le
- utf8
doc: |
.NET binary serialisation format (BinaryFormatter)
seq:
- id: records
type: record
repeat: expr
repeat-expr: 4
types:
# 2 Structures
# 2.1 Common Definitions
# 2.1.1 Common Data Types
# 2.1.1.1 Char
# We will use utf8.ksy
# 2.1.1.2 Double
# We will use f8
# 2.1.1.3 Single
# We will use f4
# 2.1.1.4 TimeSpan
time_span:
seq:
- id: value
type: s8
# 2.1.1.5 DateTime
date_time:
seq:
- id: ticks
type: b62
- id: kind
type: b2
doc: here be dragons
-webide-representation: 'ticks={ticks} kind={kind}'
# 2.1.1.6 LengthPrefixedString
length_prefixed_string:
seq:
- id: length
type: vlq_base128_le
- id: chars
type: str
encoding: 'UTF-8'
size: length.value
-webide-representation: '{chars}'
# 2.1.1.7 Decimal
decimal:
seq:
- id: value
type: length_prefixed_string
-webide-representation: '{value}'
# 2.1.1.8 ClassTypeInfo
class_type_info:
seq:
- id: type_name
type: length_prefixed_string
- id: library_id
type: s4
-webide-representation: 'type={type_name}, library_id={library_id}'
# 2.1.2 Enumerations
# See enums below
# 2.2 Method Invocation Records
# 2.2.1 Enumerations
# See enums below
# 2.2.2 Common Structures
# 2.2.2.1 ValueWithCode
value_with_code:
seq:
- id: primitive_type_enum
type: u1
enum: primitive_type_enumeration
- id: value
if: primitive_type_enum != primitive_type_enumeration::null
type:
switch-on: primitive_type_enum
cases:
'primitive_type_enumeration::boolean': u1
'primitive_type_enumeration::byte': u1
'primitive_type_enumeration::char': utf8
'primitive_type_enumeration::decimal': decimal
'primitive_type_enumeration::double': f8
'primitive_type_enumeration::int16': s2
'primitive_type_enumeration::int32': s4
'primitive_type_enumeration::int64': s8
'primitive_type_enumeration::sbyte': s1
'primitive_type_enumeration::single': f4
'primitive_type_enumeration::time_span': time_span
'primitive_type_enumeration::date_time': date_time
'primitive_type_enumeration::uint16': u2
'primitive_type_enumeration::uint32': u4
'primitive_type_enumeration::uint64': u8
'primitive_type_enumeration::string': length_prefixed_string
# 2.3.1.1 ClassInfo
class_info:
seq:
- id: object_id
type: s4
- id: name
type: length_prefixed_string
- id: member_count
type: s4
- id: member_names
type: length_prefixed_string
repeat: expr
repeat-expr: member_count
-webide-representation: 'object_id={object_id}, name={name}'
# 2.3.1.2 MemberTypeInfo
member_type_info:
seq:
- id: binary_type_enums
type: u1
enum: binary_type_enumeration
repeat: expr
repeat-expr: _parent.class_info.member_count
- id: additional_infos
type: member_type_info_additional_info(_index)
repeat: expr
repeat-expr: _parent.class_info.member_count
member_type_info_additional_info:
params:
- id: i
type: u4
seq:
- id: primitive_type
type: u1
enum: primitive_type_enumeration
if: |
binary_type_enum == binary_type_enumeration::primitive or
binary_type_enum == binary_type_enumeration::primitive_array
- id: class_name
type: length_prefixed_string
if: binary_type_enum == binary_type_enumeration::system_class
- id: class_type_info
type: class_type_info
if: binary_type_enum == binary_type_enumeration::class
instances:
binary_type_enum:
value: _parent.binary_type_enums[i]
record:
seq:
- id: record_type_enum
type: u1
enum: record_type_enumeration
- id: payload
type:
switch-on: record_type_enum
cases:
'record_type_enumeration::serialized_stream_header': serialization_header_record
'record_type_enumeration::binary_library': binary_library
'record_type_enumeration::class_with_members_and_types': class_with_members_and_types
-webide-representation: 'type={record_type_enum}({record_type_enum:dec}), payload={payload}'
# 2.3.2.1 ClassWithMembersAndTypes
class_with_members_and_types:
seq:
- id: class_info
type: class_info
- id: member_type_info
type: member_type_info
- id: library_id
type: s4
-webide-representation: 'class_info={class_info} library_id={library_id}'
# 2.3.2.2 ClassWithMembers
class_with_members:
seq:
- id: class_info
type: class_info
- id: library_id
type: s4
-webide-representation: 'class_info={class_info} library_id={library_id}'
# 2.3.2.3 SystemClassWithMembersAndTypes
system_class_with_members_and_types:
seq:
- id: class_info
type: class_info
- id: member_type_info
type: member_type_info
-webide-representation: 'class_info={class_info}'
# 2.3.2.4 SystemClassWithMembers
system_class_with_members:
seq:
- id: class_info
type: class_info
-webide-representation: 'class_info={class_info}'
# 2.3.2.5 ClassWithId
class_with_id:
seq:
- id: object_id
type: s4
- id: metadata_id
type: s4
-webide-representation: 'object_id={object_id} metadata_id={metadata_id}'
# 2.6.1 SerializationHeaderRecord
serialization_header_record:
seq:
- id: top_id
type: u4
- id: header_id
type: u4
- id: major_version
type: u4
- id: minor_version
type: u4
-webide-representation: 'top_id={top_id} header_id={header_id} version={major_version:dec}.{minor_version:dec}'
# 2.6.2 BinaryLibrary
binary_library:
seq:
- id: library_id
type: u4
- id: library_name
type: length_prefixed_string
-webide-representation: 'id={library_id} name={library_name}'
enums:
# 2.1.2.1 RecordTypeEnumeration
record_type_enumeration:
0: serialized_stream_header
1: class_with_id
2: system_class_with_members
3: class_with_members
4: system_class_with_members_and_types
5: class_with_members_and_types
6: binary_object_string
7: binary_array
8: member_primitive_typed
9: member_reference
10: object_null
11: message_end
12: binary_library
13: object_null_multiple256
14: object_null_multiple
15: array_single_primitive
16: array_single_object
17: array_single_string
21: method_call
22: method_return
# 2.1.2.2 BinaryTypeEnumeration
binary_type_enumeration:
0: primitive
1: string
2: object
3: system_class
4: class
5: object_array
6: string_array
7: primitive_array
# 2.1.2.3 PrimitiveTypeEnumeration
primitive_type_enumeration:
1: boolean
2: byte
3: char
4: unused4
5: decimal
6: double
7: int16
8: int32
9: int64
10: sbyte
11: single
12: time_span
13: date_time
14: uint16
15: uint32
16: uint64
17: 'null'
18: string
# 2.2.1.1 MessageFlags
message_flags:
0x00000001: no_args
0x00000002: args_inline
0x00000004: args_is_array
0x00000008: args_in_array
0x00000010: no_context
0x00000020: context_inline
0x00000040: context_in_array
0x00000080: method_signature_in_array
0x00000100: properties_in_array
0x00000200: no_return_value
0x00000400: return_value_void
0x00000800: return_value_inline
0x00001000: return_value_in_array
0x00002000: exception_in_array
0x00008000: generic_method