def make_page_for_record_construct(record_construct): RecordHeader = Struct( "transaction" / Int16ub, "bitfield" / Int16ub, ) RecordWrapper = Struct( "start" / Tell, "header" / RecordHeader, "record" / record_construct, "end" / Tell ) # THIS LIBRARY IS VERY COMPLEX. MAKE ANY CHANGES HERE WITH CAUTION return Struct( # TODO these could probably be a nested/embedded substruct, # that might be useful for index parsing "count" / Rebuild(Int16ub, lambda this: len(this['records'])), "records" / Array(this.count, RecordWrapper), "padding_size" / Rebuild( Int16ub, lambda this: ( 4096 - (2 + 4 * this.count) - this['records'][-1]["end"])), Rebuild(Array(this.padding_size, Byte), lambda this: [0 for _ in range(this.padding_size)]), 'line_pointers' / Rebuild(Array(this.count, Int16ub >> Int16ub), lambda this: [ [r['start'], r['end'] - r['start']] for r in this.records]), )
def SwitchLength(type, switch, mapping, path, default=0): def rebuild(type, v): return Rebuild(type, lambda x: len(v.build(path(x)))) return Switch( switch, {k: rebuild(type, v) for k, v in mapping.items()}, default=Rebuild(type, lambda x: default), )
def EmbeddedBitStruct(name, *args, reversed=False): """ Emulates BitStruct embedding: - for parsing, adds Computed accessor fields to the parent construct, - for building, Rebuild the bit struct using keys passed to the parent NOTE: This is a hack. Do not use unless you absolutely have to. """ bit_struct = BitStruct(*args) if reversed: bit_struct = Reversed(bit_struct) bit_struct.__construct_doc__ = Embedded(Struct(*args)) return (name / Rebuild(bit_struct, dict), ) + \ tuple(i.name / Computed(this[name][i.name]) for i in args if i.name is not None)
RawRuleStruct = """ Struct that contains a single rule which can be applied on the process monitor events. """ * Struct( "reserved1" / Default(Bytes(3), 0) * "!!Unknown field!!", "column" / ColumnType, "relation" / RuleRelationType, "action" / RuleActionType, "value_offset" / Tell, # NOT IN THE REAL FORMAT - USED FOR BUILDING ONLY "value_length" / Default(Int32ul, 0), "before_value_offset" / Tell, # NOT IN THE REAL FORMAT - USED FOR BUILDING ONLY "value" / FixedUTF16CString(lambda this: this.value_length, "value"), "after_value_offset" / Tell, # NOT IN THE REAL FORMAT - USED FOR BUILDING ONLY "int_value" / Rebuild( Int32ul, lambda this: get_rule_integer_value(this.column, this.value)), "reserved2" / Default(Bytes(1), 0) * "!!Unknown field!!", # To calculate value string in build time "value_length" / Pointer( lambda this: this.value_offset, Default( Int32ul, lambda this: this.after_value_offset - this.before_value_offset))) class RuleStructAdapter(Adapter): def _decode(self, obj, context, path): return Rule(column=obj["column"], relation=obj["relation"], value=obj["value"],
Struct("version" / Int8ub, "revision" / Int8ub, "build" / Int8ub), "panel_id" / Int16ub, "_not_used1" / Bytes(5), "transceiver" / Struct( "firmware_build" / Int8ub, "family" / Int8ub, "firmware_version" / Int8ub, "firmware_revision" / Int8ub, "noise_floor_level" / Int8ub, "status" / BitStruct( "_not_used" / BitsInteger(6), "noise_floor_high" / Flag, "constant_carrier" / Flag, ), "hardware_revision" / Int8ub, ), "_not_used2" / Bytes(14), )), "checksum" / Checksum( Bytes(1), lambda data: calculate_checksum(data), this.fields.data)) CloseConnection = Struct( "fields" / RawCopy( Struct( "po" / Struct("command" / Const(0x70, Int8ub)), "length" / Rebuild( Int8ub, lambda this: this._root._subcons.fields.sizeof() + this ._root._subcons.checksum.sizeof()), "_not_used0" / Padding(34), )), "checksum" / Checksum( Bytes(1), lambda data: calculate_checksum(data), this.fields.data))
4: Struct(event_index=Byte, ), 5: Struct(gate_index=Byte, ), 6: Struct( string_asset_id=Int32ub, lore_type=Byte, extra=Byte, ) })) ConstructArea = Struct(name=CString("utf8"), in_dark_aether=Flag, asset_id=Int32ub, _node_count=Rebuild(Byte, lambda this: len(this.nodes)), default_node_index=Byte, nodes=Array(lambda this: this._node_count, ConstructNode), connections=Array( lambda this: this._node_count, Array(lambda this: this._node_count - 1, ConstructRequirementSet))) ConstructWorld = Struct( name=CString("utf8"), dark_name=CString("utf8"), asset_id=Int32ub, areas=PrefixedArray(Byte, ConstructArea), )
def RebuildLength(type, subcons, path): return Rebuild(type, lambda x: len(subcons.build(path(x))))
def get_indicator_led(self): """Get the indicator led status.""" return self.send("get_indicatorLamp") class ProntoPulseAdapter(Adapter): def _decode(self, obj, context, path): return int(obj * context._.modulation_period) def _encode(self, obj, context, path): raise RuntimeError("Not implemented") ChuangmiIrSignal = Struct( Const(0xA567, Int16ul), "edge_count" / Rebuild(Int16ul, len_(this.edge_pairs) * 2 - 1), "times_index" / Array(16, Int32ul), "edge_pairs" / Array( (this.edge_count + 1) // 2, BitStruct("gap" / BitsInteger(4), "pulse" / BitsInteger(4)), ), ) ProntoBurstPair = Struct( "pulse" / ProntoPulseAdapter(Int16ub), "gap" / ProntoPulseAdapter(Int16ub) ) Pronto = Struct( Const(0, Int16ub), "_ticks" / Int16ub,
from construct import (Array, BitStruct, Const, CString, Default, Flag, Float32l, GreedyRange, Int8ul, Int32ul, Int64ul, Padding, Rebuild, Struct) from world_server import op_code, router ClientCharEnum = router.ClientPacket.Register( op_code.Client.CHAR_ENUM, Struct(), ) ServerCharEnum = Struct( 'num_characters' / Rebuild(Int8ul, lambda this: len(this.characters)), 'characters' / GreedyRange( Struct( 'guid' / Int64ul, 'name' / CString('ascii'), 'race' / Int8ul, 'class_' / Int8ul, 'gender' / Int8ul, 'appearance' / Struct( 'skin' / Int8ul, 'face' / Int8ul, 'hair_style' / Int8ul, 'hair_color' / Int8ul, 'feature' / Int8ul, ), 'level' / Int8ul, 'location' / Struct( 'zone' / Int32ul, 'map' / Int32ul,
LOAD_SEGMENT_CHUNK_HEADER_LENGTH = 3 MIN_PADDING_LENGTH = 1 SCP_MAC_LENGTH = 0xE LEDGER_HSM_URL = "https://hsmprod.hardwarewallet.com/hsm/process" LEDGER_HSM_KEY = "perso_11" ApduListAppsResponse = Struct( Const(b"\x01"), # Version apps=GreedyRange( Struct( # Application # Prefixed by the size of the structure, size included. _size=Rebuild(Int8ub, 1 + 4 + 32 + 32 + len_(this.name)), flags=Hex(Int32ub), code_data_hash=Bytes(32), full_hash=Bytes(32), name=PascalString(Int8ub, "utf-8"), ) ), ) VersionInfo = Struct( target_id=Hex(Int32ub), se_version=PascalString(Int8ub, "utf-8"), _flags_len=Const(b"\x04"), flags=FlagsEnum( Int32ul, recovery_mode=1,
from construct import Array, Const, Int16ul, Int32ul, Rebuild, Struct ServerInitialSpells = Struct( Const(b'\x00'), 'spell_count' / Rebuild(Int16ul, lambda c: len(c.spells)), 'spells' / Array(lambda c: c.spell_count, Struct( 'id' / Int16ul, Const(b'\x00\x00'), )), 'spell_cooldown_count' / Rebuild(Int16ul, lambda c: len(c.spell_cooldowns)), 'spell_cooldowns' / Array( lambda c: c.spell_cooldown_count, Struct( 'id' / Int16ul, 'cast_item_id' / Int16ul, 'category' / Int16ul, 'cooldown' / Int32ul, 'category_cooldown' / Int32ul, )), )
"extra" / Switch( this.type, { "link_query": Struct("u3" / Default(Int16ub, 0x0c), "source_ip" / IpAddr), "rekordbox_hello": Struct("payload_size" / Int16ub), # always 0 till now "link_reply": Struct("payload_size" / Int16ub), # always 0x9c }, default=Struct( "u3" / Default( Int16ub, 0xf8 ), # b0 cdj2000nxs, f8 xdj1000, 14 djm, 34/38 rekordbox, 104 rdbx_reply "player_number2" / Rebuild(Int8ub, this._.player_number), # equal to player_number "u4" / Default(Int8ub, 0) # 1 cdj2000nxs or 0 xdj1000, 0 for rekordbox)) )), # default: 38 bytes until now "content" / Switch( this.type, { "cdj": Struct( "activity" / Int16ub, # 0 when idle, 1 when playing, 0xc0 for rekordbox "loaded_player_number" / Int8ub, # player number of loaded track, own number if local track "loaded_slot" / PlayerSlot, "track_analyze_type" / TrackAnalyzeType,
def PacketLength(subcons): return Rebuild( subcons, lambda x: x._root._subcons.fields.sizeof() + x._root._subcons.checksum.sizeof(), )
def checksum_16(data): c = 0 for i in range(len(data) // 2): c = c + (data[i * 2 + 1] << 8) + data[i * 2] return c & 0xFFFF WriteCommand = Struct("address" / Int16ul, "value" / Int16ul) WriteMessageRequest = Struct( "fields" / RawCopy( Struct( "length" / Rebuild( Int16ul, len_(this.items) * WriteCommand.sizeof() // Int16ul.sizeof() + 2, ), "command" / Const(vlxDevConstants.WS_WEB_UI_COMMAND_WRITE_DATA, Int16ul), "items" / WriteCommand[len_(this.items)], )), "checksum" / Checksum(Int16ul, lambda data: checksum_16(data), this.fields.data), ) ReadTableResponse = GreedyRange(Int16ub) ReadTableRequest = Struct( "fields" / RawCopy( Struct(
def _encode(self, obj, context, path): return { "column": obj.column, "relation": obj.relation, "action": obj.action, "value": obj.value } RuleStruct = RuleStructAdapter(RawRuleStruct) RawRulesStruct = """ Struct that contains a list of procmon rules. """ * Struct( "reserved1" / Const(1, Int8ul) * "!!Unknown field!!", "rules_count" / Rebuild(Int8ul, lambda this: len(this.rules)), "rules" / Array(lambda this: this.rules_count, RuleStruct), "reserved1" / Default(Bytes(3), 0) * "!!Unknown field!!", ) class RulesStructAdapter(Adapter): def _decode(self, obj, context, path): return list(obj["rules"]) def _encode(self, obj, context, path): return {"rules": obj} RulesStruct = RulesStructAdapter(RawRulesStruct) RawRecordStruct = """
lambda decrypted_bytes: decrypted_bytes[:decrypted_bytes.rfind( b'\x00')] if b'\x00' in decrypted_bytes else decrypted_bytes ] for i, quirk in enumerate(decrypted_quirks): decoded = quirk(decrypted).decode('utf-8') try: return json.loads(decoded) except Exception as ex: # log the error when decrypted bytes couldn't be loaded # after trying all quirk adaptions if i == len(decrypted_quirks) - 1: _LOGGER.error("unable to parse json '%s': %s", decoded, ex) return None Message = Struct( # for building we need data before anything else. "data" / Pointer(32, RawCopy(EncryptionAdapter(GreedyBytes))), "header" / RawCopy( Struct( Const(0x2131, Int16ub), "length" / Rebuild(Int16ub, Utils.get_length), "unknown" / Default(Int32ub, 0x00000000), "device_id" / Hex(Bytes(4)), "ts" / TimeAdapter(Default(Int32ub, datetime.datetime.utcnow())))), "checksum" / IfThenElse(Utils.is_hello, Bytes(16), Checksum(Bytes(16), Utils.md5, Utils.checksum_field_bytes)), )
AddressType.UNICAST, AddressType.UNASSIGNED, ) UnicastUnassignedGroupAddress = AddressTypeValidator( Int16ul, AddressType.UNICAST, AddressType.UNASSIGNED, AddressType.GROUP, ) Int12ul = ExprValidator(Int16ul, (obj_ & 0xF000) == 0x00) CompositionDataElement = Struct( "location" / GATTNamespaceDescriptorAdapter, "sig_number" / Rebuild(Int8ul, len_(this["sig_models"])), "vendor_number" / Rebuild(Int8ul, len_(this["vendor_models"])), "sig_models" / SIGModelId[this["sig_number"]], "vendor_models" / VendorModelId[this["vendor_number"]], ) CompositionData = Struct( "cid" / Int16ul, "pid" / Int16ul, "vid" / Int16ul, "crpl" / Int16ul, "features" / Int16ul, # TODO should be parsed "elements" / GreedyRange(CompositionDataElement), ) Retransmit = BitStruct(
from construct import Int32ul, Float32l, Struct, Int16ul, Rebuild, GreedyRange ServerInitWorldStates = Struct( 'map' / Int32ul, 'zone' / Int32ul, 'n_blocks' / Rebuild(Int16ul, lambda this: len(this.blocks)), 'blocks' / GreedyRange(Struct( 'state' / Int32ul, 'value' / Int32ul, )), )
from construct import Array, Int32ul, Rebuild, Struct ServerRaidInstanceInfo = Struct( 'count' / Rebuild(Int32ul, lambda c: len(c.instances)), 'instances' / Array(lambda c: c.count, Struct( 'map_id' / Int32ul, 'reset_time' / Int32ul, 'instance_id' / Int32ul, )), )
from construct import Struct, RawCopy, BitStruct, Const, Nibble, Flag, Rebuild, Int8ub, BitsInteger, Int16ub, Checksum, \ Bytes, this, Default, Padding, Enum, Int24ub, ExprAdapter, Byte, obj_, Array, Computed, Subconstruct, \ ValidationError, ExprSymmetricAdapter from .adapters import PGMFlags, StatusAdapter, DateAdapter, ZoneFlags, PartitionStatus, EventAdapter from ..common import CommunicationSourceIDEnum, ProductIdEnum, calculate_checksum LoginConfirmationResponse = Struct( "fields" / RawCopy( Struct( "po" / BitStruct( "command" / Const(0x1, Nibble), "status" / Struct("reserved" / Flag, "alarm_reporting_pending" / Flag, "Winload_connected" / Flag, "NeWare_connected" / Flag)), "length" / Rebuild( Int8ub, lambda this: this._root._subcons.fields.sizeof() + this ._root._subcons.checksum.sizeof()), "result" / BitStruct("_not_used0" / BitsInteger(4), "partition_2" / Flag, "_not_used1" / BitsInteger(3)), "callback" / Int16ub)), "checksum" / Checksum(Bytes(1), lambda data: calculate_checksum(data), this.fields.data)) InitializeCommunication = Struct( "fields" / RawCopy( Struct( "po" / Struct("command" / Const(0x00, Int8ub)), "module_address" / Default(Int8ub, 0x00), "_not_used0" / Padding(2), "product_id" / ProductIdEnum, "firmware" / Struct("version" / Int8ub, "revision" / Int8ub, "build" / Int8ub),
raise ChuangmiIrException('Invalid command arguments') from ex return play_method(command, *command_args) class ProntoPulseAdapter(Adapter): def _decode(self, obj, context): return int(obj * context._.modulation_period) def _encode(self, obj, context): raise RuntimeError('Not implemented') ChuangmiIrSignal = Struct( Const(0xa567, Int16ul), 'edge_count' / Rebuild(Int16ul, len_(this.edge_pairs) * 2 - 1), 'times_index' / Array(16, Int32ul), 'edge_pairs' / Array( (this.edge_count + 1) / 2, BitStruct( 'gap' / BitsInteger(4), 'pulse' / BitsInteger(4), ))) ProntoBurstPair = Struct( 'pulse' / ProntoPulseAdapter(Int16ub), 'gap' / ProntoPulseAdapter(Int16ub), ) Pronto = Struct( Const(0, Int16ub), '_ticks' / Int16ub,
#RPC_TYPE.LIST_PEERS_RESULT : RpcMessage_LIST_PEERS_RESULT, #RPC_TYPE.KILL_SESSIONS : RpcMessage_KILL_SESSIONS, #RPC_TYPE.KILL_SESSIONS_RESULT : RpcMessage_KILL_SESSIONS_RESULT, #RPC_TYPE.DEL_ENTRIES : RpcMessage_DEL_ENTRIES, #RPC_TYPE.DEL_ENTRIES_RESULT : RpcMessage_DEL_ENTRIES_RESULT, #RPC_TYPE.SHOW_ENTRIES : RpcMessage_SHOW_ENTRIES, #RPC_TYPE.SHOW_ENTRIES_RESULT : RpcMessage_SHOW_ENTRIES_RESULT, #RPC_TYPE.DUMP_MD : RpcMessage_DUMP_MD, #RPC_TYPE.DUMP_MD_RESULT : RpcMessage_DUMP_MD_RESULT, #RPC_TYPE.CLEAN_DB : RpcMessage_CLEAN_DB, #RPC_TYPE.DEBUGCTL : RpcMessage_DEBUGCTL, }, default=None) # RPC packet common header rpc_packet_t = con.Struct("length" / Rebuild(Hex(Int32ub), len_(this.data)), "code" / RPC_TYPE, "data" / con.HexDump(con.Bytes(this.length))) def rpc_message_build(code, **kwargs): """ Build and serialize an RPC packet """ data = RpcMessage.build(kwargs, code=code) return rpc_packet_t.build(Container(code=code, data=data)) def rpc_message_parse(source): """
artwork=0x4002, invalid_request=0x4003, # guessed? menu_item=0x4101, menu_footer=0x4201, preview_waveform=0x4402, unknown1=0x4502, beatgrid=0x4602, cues=0x4702, waveform=0x4a02, unknown2=0x4e02) DBMessage = Struct( "magic" / Const(0x872349ae, DBFieldFixed("int32")), "transaction_id" / Default(DBFieldFixed("int32"), 1), "type" / DBRequestType, "argument_count" / Rebuild(DBFieldFixed("int8"), len_(this.args)), "arg_types" / ArgumentTypesField, "args" / Array(this.argument_count, DBField)) ManyDBMessages = GreedyRange(DBMessage) Beatgrid = Struct( Padding(4), "beat_count" / Int32ul, "payload_size" / Int32ul, # bytes "u1" / Default(Int32ul, 1), "u2" / Int16ul, "u3" / Int16ul, "beats" / Array( this.beat_count, Struct(
def OptionalValue(subcon): return construct.FocusedSeq( "value", present=Rebuild(Flag, construct.this.value != None), value=If(construct.this.present, subcon), )
damage=PrefixedArray(Byte, Struct( Embedded(ConstructResourceInfo), reductions=PrefixedArray(Byte, Struct( index=Byte, multiplier=Float32b, )), )), versions=PrefixedArray(Byte, ConstructResourceInfo), misc=PrefixedArray(Byte, ConstructResourceInfo), difficulty=PrefixedArray(Byte, ConstructResourceInfo), requirement_template=PrefixedArray(VarInt, Sequence(CString("utf8"), ConstructRequirement)) ) ConstructEchoesBeamConfiguration = Struct( item_index=Byte, _has_ammo_a=Rebuild(Flag, lambda this: this.ammo_a is not None), ammo_a=If(lambda this: this._has_ammo_a, Byte), _has_ammo_b=Rebuild(Flag, lambda this: this.ammo_b is not None), ammo_b=If(lambda this: this._has_ammo_b, Byte), uncharged_cost=Byte, charged_cost=Byte, combo_missile_cost=Byte, combo_ammo_cost=Byte, ) ConstructEchoesGameSpecific = Struct( energy_per_tank=Float32b, beam_configurations=PrefixedArray(Byte, ConstructEchoesBeamConfiguration), ) ConstructResourceGain = Struct(
from construct import (BitStruct, Const, CString, Flag, Float32l, GreedyRange, Int8ul, Int32ul, Padding, Rebuild, Struct) from common import srp from login_server import op_code, router ClientRealmlist = router.ClientPacket.Register( op_code.Client.REALMLIST, Struct('unk1' / Const(int(0).to_bytes(4, 'little')))) ServerRealmlist = Struct( 'unk1' / Const(int(0).to_bytes(4, 'little')), 'n_realms' / Rebuild(Int8ul, lambda this: len(this.realms)), 'realms' / GreedyRange( Struct( 'icon' / Int32ul, 'flags' / BitStruct( 'is_full' / Flag, # "full" population 'is_recommended' / Flag, # recommended in green text 'for_new_players' / Flag, # recommended in blue text 'unused' / Padding(3), 'is_offline' / Flag, # marks as offline 'is_unavailable' / Flag, # shows name in red ), 'name' / CString('ascii'), 'hostport' / CString('ascii'), 'population' / Float32l, # relative population of realms 'n_characters' / Int8ul, 'zone' / Const(b'\x01'), # Will show as "English" 'unk' / Const(b'\x00'), )),
Struct(event_index=VarInt, ), "translator_gate": Struct(gate_index=VarInt, ), "logbook": Struct( string_asset_id=VarInt, lore_type=ConstructLoreType, extra=VarInt, ) })) ConstructArea = Struct( name=CString("utf8"), in_dark_aether=Flag, asset_id=VarInt, _node_count=Rebuild(VarInt, construct.len_(construct.this.nodes)), default_node_index=OptionalValue(VarInt), valid_starting_location=Flag, nodes=Array(lambda this: this._node_count, ConstructNode), connections=Array( lambda this: this._node_count, Array(lambda this: this._node_count - 1, ConstructRequirement))) ConstructWorld = Struct( name=CString("utf8"), dark_name=CString("utf8"), asset_id=VarInt, areas=PrefixedArray(VarInt, ConstructArea), ) game_specific_map = {
if obj == 256: obj = 0 return obj struct_blit_pixel = Struct( 'r' / Int8ul, 'g' / Int8ul, 'b' / Int8ul, 'a' / Int8ul ) struct_blit_image = Struct( 'header' / Const(b'SPRITE'), 'type' / PaddedString(2, 'ASCII'), 'size' / Rebuild(Int32ul, len_(this.data) + (this.palette_entries * 4) + 18), 'width' / Int16ul, 'height' / Int16ul, 'format' / Const(0x02, Int8ul), 'palette_entries' / PaletteCountAdapter(Int8ul), 'palette' / Array(this.palette_entries, struct_blit_pixel), 'bit_length' / Computed(compute_bit_length), 'data_length' / Computed(compute_data_length), 'data' / Array(this.data_length, Int8ul) ) struct_blit_meta = Struct( 'header' / Const(b'BLITMETA'), 'data' / Prefixed(Int16ul, Struct( 'checksum' / Checksum( Int32ul,
decrypted = decrypted.rstrip(b"\x00") except Exception as ex: _LOGGER.debug("Unable to decrypt, returning raw bytes.") return obj try: jsoned = json.loads(decrypted.decode('utf-8')) except: _LOGGER.error("unable to parse json, was: %s", decrypted) jsoned = b'{}' raise return jsoned Message = Struct( # for building we need data before anything else. "data" / Pointer(32, RawCopy(EncryptionAdapter(GreedyBytes))), "header" / RawCopy( Struct( Const(Int16ub, 0x2131), "length" / Rebuild(Int16ub, Utils.get_length), "unknown" / Default(Int32ub, 0x00000000), "devtype" / Enum(Default(Int16ub, 0x02c1), default=Pass, **xiaomi_devices), "serial" / Default(Int16ub, 0xa40d), "ts" / TimeAdapter(Default(Int32ub, datetime.datetime.utcnow())))), "checksum" / IfThenElse(Utils.is_hello, Bytes(16), Checksum(Bytes(16), Utils.md5, Utils.checksum_field_bytes)), )
"process" / ProcessIndex, "thread_id" / Int32ul, "event_class" / EventClassType, "operation" / Switch(lambda this: this.event_class, { EventClass.Process: ProcessOperationType, EventClass.Registry: RegistryOperationType, EventClass.Network: NetworkOperationType, EventClass.Profiling: ProfilingOperationType, EventClass.File_System: FilesystemOperationType, }, Error), "reserved1" / Int16ul * "!!Unknown field!!", "reserved2" / Int32ul * "!!Unknown field!!", "duration" / Duration, "date" / Filetime, "result" / Int32ul, "stacktrace_depth" / Rebuild(Int16ul, lambda this: len(this.stacktrace)), CheckCustom(lambda this: this.stacktrace_depth <= 0x100, RuntimeError, "stack trace is unreasonably big"), "reserved3" / Int16ul * "!!Unknown field!!", "detail_size" / Int32ul, "detail_offset" / Int32ul, "stacktrace" / ListAdapter(Array(lambda this: this.stacktrace_depth, PVoid)), "details" / Switch(lambda this: this.event_class, { EventClass.Process: ProcessDetails, EventClass.Registry: RegistryDetails, EventClass.Network: NetworkDetails, EventClass.Profiling: Pass, EventClass.File_System: FilesystemDetails, }), "operation" / Computed(lambda ctx: ctx.operation), # The operation might be changed because of the specific details )