Files
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

454 lines
34 KiB
Python

"""Data-only per-pipe binding at the pinned original constructor return.
Parent installs/inspects only. All packets stay in actual WowB engine-owned TCP,
Windows/Wine module and its genuine queue. No credential/engine packet-buffer reads; only declared bounded item/spell
request specimens in the owned module can expose public gameplay bytes.
"""
import json,struct
from pathlib import Path
import native_runtime_paths
import engine_poll_host as host
import engine_wire_host as wire
ROOT=Path(__file__).resolve().parents[1]
ENTRY=0x141e46101
PREFIX=bytes.fromhex('33d2488bcfe895480000')
TABLE=0x144e59fe8
METHODS=(0x141e4ca60,0x141e4d120,0x1401d9200,0x141e4e8e0,0x14091e6e0,0x1409e95f0,0x141e4c8f0,0x141e4c9e0,0x141e4ca20)
SIZE=640
ENTITY_FIELD_OFFSET=41008
ENTITY_FIELD_BYTES=2080
ENTITY_ABIS={(1,10288):256,(2,41008):1024,(3,43088):1024}
SOURCE_UNIT_FIELDS=frozenset((16,17,46,133,138,164))|frozenset(range(22,34))
def decode_aura_state(metadata):
if len(metadata)!=1376:raise ValueError('Aura diagnostic size differs')
v=struct.unpack_from('<8I',metadata)
if v[:2]!=(1,1376) or v[4]>1 or v[5]>48 or v[6]>v[5] or v[7]:raise ValueError('Aura diagnostic bounds differ')
result=dict(zip(('updates_sent','unsupported','known','occupied','shown'),v[2:7]));result['rows']=[]
for slot in range(48):
row=struct.unpack_from('<7I',metadata,32+slot*28)
if row[1]>15 or row[2]>255 or row[3]>255 or row[4]>7 or row[6]>1 or (not row[0] and row[6]):raise ValueError('Aura slot bounds differ')
if row[0]:result['rows'].append(dict(slot=slot,**dict(zip(('spell','flags','level','applications_minus_one','active_mask','visual_link','queued'),row))))
if len(result['rows'])!=v[5] or sum(r['queued'] for r in result['rows'])!=v[6]:raise ValueError('Aura counters differ; retry read-only snapshot')
return result
COUNTERS=('read_calls write_calls read_thread write_thread challenge_bytes auth_request_sent world_auth queued auth_queued glue_queued roster_queued restrictions_queued last_in_opcode last_in_bytes last_out_opcode last_out_bytes unsupported_in unsupported_out enum_sent pings_sent pongs_received closed characters trace_count').split()
def decode_gameplay_request(metadata,expected_opcode):
if len(metadata)!=280:raise ValueError('Item-use specimen size differs')
abi,size,opcode,length,captured,result=struct.unpack_from('<5Ii',metadata)
if (abi,size)!=(1,280) or captured>256 or length!=captured or result not in (0,1,-1,-2,-3) or opcode not in (0,expected_opcode) or (not opcode and captured):raise ValueError('Item-use specimen bounds differ')
return dict(opcode=opcode,bytes=length,captured=captured,result=result,payload_hex=metadata[24:24+captured].hex())
def decode_item_request(metadata):return decode_gameplay_request(metadata,0x3e0171)
def decode_spell_request(metadata):return decode_gameplay_request(metadata,0x3e0176)
def decode_entity_page(header,metadata,offset=0):
if len(header)!=48 or type(offset) is not int or offset not in (0,256,512,768):raise ValueError('Entity page header/offset differs')
fields=struct.unpack('<12I',header);limit=ENTITY_ABIS.get(fields[:2])
if limit is None or fields[10]>limit or fields[11]>1 or offset>=limit:raise ValueError('Entity metadata bounds differ')
count=min(256,max(0,fields[10]-offset))
if len(metadata)!=count*40:raise ValueError('Entity page body length differs')
result=dict(zip(('server_creatures','sent_creatures','sent_gameobjects','templates','pending_batches','pending_requests','removals','unsupported','captured','truncated'),fields[2:]))
result.update(captured=count,truncated=bool(fields[11] or offset or fields[10]>count),snapshot_captured=fields[10],snapshot_truncated=bool(fields[11]),page_offset=offset,next_offset=offset+count if offset+count<fields[10] else None,actors=[])
for index in range(count):
legacy,modern,entry,kind,sent,creature_type=struct.unpack_from('<Q16s4I',metadata,index*40)
# Actor.kind is the source update-object type, not the native TypeID.
# NativeEntityTranslation exports genuine peer players as source kind4;
# they have no creature template entry or creature-type metadata.
if (kind not in (3,4,5,7) or sent>1 or creature_type>15
or kind==4 and (entry!=0 or creature_type!=0)):
raise ValueError('Entity identity metadata differs')
result['actors'].append(dict(legacy_guid=str(legacy),modern_guid=modern.hex(),entry=entry,kind=kind,sent=bool(sent),creature_type=creature_type))
return result
ENTITY_OBSERVATION_ATTEMPTS=3
_ENTITY_OBSERVATION_ERRORS={
'Entity page header/offset differs':'entity-header-invalid',
'Entity metadata bounds differ':'entity-header-bounds',
'Entity page body length differs':'entity-page-length',
'Entity identity metadata differs':'entity-identity-invalid',
}
def _entity_observation_candidate(access,address,offset,read):
# Access/module ownership/read failures deliberately propagate; only local
# optional snapshot structure is retryable. Every read stays <=2048bytes.
header=read(access,address,48)
reason=None;metadata=b''
if len(header)!=48:
reason='Entity page header/offset differs'
else:
fields=struct.unpack('<12I',header);limit=ENTITY_ABIS.get(fields[:2])
if limit is None or fields[10]>limit or fields[11]>1 or offset>=limit:
reason='Entity metadata bounds differ'
else:
count=min(256,max(0,fields[10]-offset));remaining=count*40
metadata=b''.join(read(access,address+48+offset*40+part,min(2048,remaining-part))
for part in range(0,remaining,2048))
after=read(access,address,48)
return header,metadata,after,reason
def read_optional_entity_page(access,address,offset=0,*,read=None):
"""Bounded observational consistency; never admits invalid/fake actors.
Double header/page/header observations must be byte-identical and the
unchanged strict decoder must pass. This reduces torn memcpy reads, but is
not a producer seqlock or a proof of atomic publication. No source packet,
authentication or gameplay action is retried here.
"""
if type(offset) is not int or offset not in (0,256,512,768):
raise ValueError('Entity page offset must be0/256/512/768')
if read is None:read=wire.read_public_bytes
reason='entity-snapshot-changing';detail='Entity snapshot changed during observation'
consistency='changing';last_header=None
for attempt in range(1,ENTITY_OBSERVATION_ATTEMPTS+1):
first=_entity_observation_candidate(access,address,offset,read)
second=_entity_observation_candidate(access,address,offset,read)
header,metadata,after,invalid=first
if header!=after or second[0]!=second[2] or first!=second:
reason='entity-snapshot-changing';detail='Entity snapshot changed during observation'
consistency='changing';last_header=None;continue
consistency='stable-invalid'
if invalid:
reason=_ENTITY_OBSERVATION_ERRORS[invalid];detail=invalid;last_header=None;continue
last_header=header
try:
result=decode_entity_page(header,metadata,offset)
except ValueError as error:
# This decoder emits only fixed public structural error strings.
# Unknown failures remain fatal rather than becoming a broad catch.
detail=str(error)
if detail not in _ENTITY_OBSERVATION_ERRORS:raise
reason=_ENTITY_OBSERVATION_ERRORS[detail];continue
result.update(available=True,snapshot_attempts=attempt,snapshot_consistency='stable-double-read')
return result,header
return dict(available=False,observation='unavailable',diagnostic_reason=reason,
diagnostic_error=detail,snapshot_attempts=ENTITY_OBSERVATION_ATTEMPTS,
snapshot_consistency=consistency),last_header
def decode_source_unit_fields(header,metadata,offset=0):
"""Actual source words only; not translated values or engine/UI acceptance."""
if len(header)!=32 or type(offset) is not int or not 0<=offset<=64:raise ValueError('Source-field diagnostic header/page differs')
abi,size,packets,total,captured,overwritten,overflow,reserved=struct.unpack('<8I',header)
if (abi,size)!=(1,ENTITY_FIELD_BYTES) or captured!=min(total,64) or overwritten!=total-captured or overflow>1 or reserved or offset>captured:raise ValueError('Source-field diagnostic bounds differ')
count=captured-offset
if len(metadata)!=32*count:raise ValueError('Source-field diagnostic row length differs')
result=dict(source_packets=packets,total=total,capacity=64,snapshot_captured=captured,overwritten=overwritten,
overflow=bool(overflow),captured=count,page_offset=offset,truncated=bool(offset),rows=[],engine_application_verified=False)
for i in range(count):
legacy,sequence,source_packet,opcode,kind,field,value=struct.unpack_from('<Q6I',metadata,32*i)
if not legacy or sequence!=total-captured+offset+i+1 or not 0<source_packet<=packets or opcode not in (0xa9,0x1f6) or kind not in (0,2,3) or field not in SOURCE_UNIT_FIELDS:raise ValueError('Source-field diagnostic identity/order/whitelist differs')
result['rows'].append(dict(legacy_guid=str(legacy),sequence=sequence,source_packet=source_packet,opcode=opcode,kind=kind,field=field,value=value))
return result
def read_source_unit_fields(access,address,full=False):
# The enclosing export is copied by the one packet owner. Header stability
# and exact row sequences detect a concurrent copy; ordinary packets may
# advance source_packets without changing any observed field rows.
for _ in range(3):
header=wire.read_public_bytes(access,address,32)
fields=struct.unpack('<8I',header)
decode_source_unit_fields(header,b'',fields[4])
offset=0 if full else max(0,fields[4]-16);start=address+32+offset*32;remaining=(fields[4]-offset)*32
metadata=b''.join(wire.read_public_bytes(access,start+i,min(2048,remaining-i)) for i in range(0,remaining,2048))
latest=wire.read_public_bytes(access,address,32);current=struct.unpack('<8I',latest)
decode_source_unit_fields(latest,b'',current[4])
if current[2]<fields[2]:raise ValueError('Source-field packet counter reset during bounded read')
if fields[:2]+fields[3:]!=current[:2]+current[3:]:continue
return decode_source_unit_fields(latest,metadata,offset)
return dict(available=False,retryable=True,reason='source-field-snapshot-busy',attempts=3,rows=[],engine_application_verified=False)
def bound_source_field_reply(result):
"""Preserve existing identity pagination; only trim the optional field tail."""
fields=result.get('source_unit_fields')
if not fields or result.get('unit_fields_only'):return
while fields['rows'] and len(json.dumps(result).encode())>64000:
fields['rows'].pop(0);fields['captured']-=1;fields['page_offset']+=1;fields['truncated']=True
def inspect_code_contracts(access,targets):
result=[]
for address,value in targets:
expected=bytes.fromhex(value);readable=access.allowed(address,len(expected),'r')
actual=access.read(address,len(expected)) if readable else b''
result.append(dict(address=hex(address),readable=readable,executable=access.allowed(address,len(expected),'x'),prefix_matches=actual==expected,observed_prefix=actual.hex()))
return result
def reject(reason):
allowed=('Require verified constructor-return instruction','Pipe constructor return identity differs','Owned pipe ABI differs',
'Owned pipe module not idle','Require genuinely authenticated prepared channel','Engine owner changed',
'Require real connecting state','Real TCP ownership differs','Real TCP close/write method differs',
'Original new primary pipe differs','Original complete pipe methods differ','Live queue/open identity preflight missing')
(native_runtime_paths.state_file(ROOT,'engine-pipe-bind-rejection.json')).write_text(json.dumps({'validation':reason if reason in allowed else 'bounded-precondition-rejected'})+'\n')
(native_runtime_paths.state_file(ROOT,'engine-pipe-bind-rejection.json')).chmod(0o600)
raise ValueError(reason)
def bind_setup_return(pid,caller):
# This is the naturally reached constructor-return entry after the
# already verified queue safepoint and successful original OpenRealm.
# A non-null caller means we stopped at a different phase.
if caller is not None:reject('Require verified constructor-return instruction')
access=host.Access(pid)
try:
if not access.allowed(ENTRY,len(PREFIX),'x') or access.read(ENTRY,len(PREFIX))!=PREFIX:reject('Pipe constructor return identity differs')
base,info,_=wire.module(access);data=base+info['exports']['gw_wire_pipe_data']
from engine_session_retirement import pipe_binding
poll=json.loads((native_runtime_paths.state_file(ROOT,'engine-poll-binding.json')).read_text())
callbacks,immutable_table,generation=pipe_binding(access,pid,base,info['exports'],poll)
if struct.unpack('<II',access.read(data,8))!=(1,SIZE) or any(access.read(data+8,SIZE-8)) or not all(access.allowed(p,1,'x') for p in callbacks):reject('Owned pipe module not idle')
account=wire.inspect_account(pid)
if account['state']!=2 or account['server_proof_verified']!=1 or account['transport_prepared']!=1:reject('Require genuinely authenticated prepared channel')
poll=json.loads((native_runtime_paths.state_file(ROOT,'engine-poll-binding.json')).read_text());owner=poll['owner']
if poll['pid']!=pid or poll['restored'] or access.u64(0x145e7a098)!=owner or access.u64(owner)!=poll['bound_vtable']:reject('Engine owner changed')
if struct.unpack('<I',access.read(owner+0x98,4))[0]!=4:reject('Require real connecting state')
connection=access.u64(owner+0x1a0);queue=access.u64(owner+0xa0);listener=access.u64(owner+0x220)
if not connection or access.u64(connection)!=0x1450396b0 or access.u64(queue)!=owner or access.u64(connection+0x28)!=listener or access.u64(listener+8)!=owner:reject('Real TCP ownership differs')
if access.u64(0x1450396b0+17*8)!=0x1434db6b0 or access.u64(0x1450396b0+18*8)!=0x1434db7a0:reject('Real TCP close/write method differs')
holder=access.u64(owner+0x228);pipe=access.u64(holder)
if not pipe or access.u64(pipe)!=TABLE or access.u64(pipe+8)!=owner or access.u64(pipe+16)!=0:reject('Original new primary pipe differs')
from engine_session_retirement import require_fresh_receiver
require_fresh_receiver(access,base,info['exports'],pipe,generation)
methods=struct.unpack('<9Q',access.read(TABLE,72))
if methods!=METHODS:reject('Original complete pipe methods differ')
# Submit already observed with this six-argument ABI. Require live entry
# naturally RX; never force protections or install a guessed function.
preflight=json.loads((native_runtime_paths.state_file(ROOT,'engine-pipe-entry-preflight.json')).read_text())
if preflight!=dict(pid=pid,verified_entries=[0x141e46020,ENTRY],previously_verified_queue=0x141e54190):reject('Live queue/open identity preflight missing')
clone=immutable_table+8 if immutable_table is not None else data+184
record=dict(pid=pid,owner=owner,connection=connection,holder=holder,pipe=pipe,data=data,clone=clone,original_table=TABLE,restored=False,credentials_generation=generation)
path=native_runtime_paths.state_file(ROOT,'engine-pipe-binding.json');path.write_text(json.dumps(record,indent=2)+'\n');path.chmod(0o600)
payload=struct.pack('<4I8Q',1,SIZE,1,0,owner,pipe,connection,queue,TABLE,METHODS[1],METHODS[0],0)
payload+=bytes(96)+struct.pack('<10Q',access.u64(TABLE-8),*callbacks,*METHODS[2:])+bytes(384)
assert len(payload)==SIZE
if immutable_table is not None:
# A generation row is initialized exactly once; old rows remain
# callable and reject stale epochs inside the native wrapper.
access.write(immutable_table,struct.pack('<10Q',access.u64(TABLE-8),*callbacks,*METHODS[2:]))
access.write(data,payload)
try:access.write(pipe,struct.pack('<Q',clone))
except BaseException:
if access.u64(pipe)==clone:access.write(pipe,struct.pack('<Q',TABLE))
record['restored']=True;path.write_text(json.dumps(record,indent=2)+'\n');raise
finally:access.close()
def restore(pid,caller):
host.require_safepoint(caller);access=host.Access(pid)
try:
path=native_runtime_paths.state_file(ROOT,'engine-pipe-binding.json');r=json.loads(path.read_text())
if r['pid']!=pid or r['restored'] or access.u64(0x145e7a098)!=r['owner']:raise ValueError('Pipe rollback owner changed')
# Original cleanup may already have destroyed the pipe. Never touch a
# historical heap pointer unless still the primary engine-owned object.
holder=access.u64(r['owner']+0x228)
current=access.u64(holder) if holder else 0
if current==r['pipe']:
if access.u64(current)!=r['clone'] or access.u64(current+8)!=r['owner']:raise ValueError('Live pipe binding differs')
access.write(current,struct.pack('<Q',r['original_table']))
access.write(r['data']+8,struct.pack('<I',4));r.update(restored=True,original_pipe_already_destroyed=current!=r['pipe']);path.write_text(json.dumps(r,indent=2)+'\n')
finally:access.close()
def decode_motion_metadata(metadata):
"""Decode the bounded legacy motion prefix plus ABI2 numeric action journal."""
if len(metadata)<32:raise ValueError('Motion metadata header truncated')
fields=struct.unpack_from('<8I',metadata)
if (fields[0],fields[1])not in[(1,1056),(2,2208)]or len(metadata)!=fields[1]or fields[6]>16 or fields[0]==2 and fields[7]>16:raise ValueError('Motion metadata bounds differ')
result=dict(zip(('received','sent','unknown','rejected','captured'),fields[2:7]));result.update(abi=fields[0],snapshot_bytes=fields[1],rows=[],actions=[])
for index in range(fields[6]):
legacy,modern,spline_id,duration,*rest=struct.unpack_from('<Q16sII6fII',metadata,32+index*64)
result['rows'].append(dict(legacy_guid=str(legacy),modern_guid=modern.hex(),id=spline_id,duration=duration,start=rest[:3],destination=rest[3:6],points=rest[6],facing=rest[7]))
reasons={1: 'modern monster spline profile bound', 2: 'monster spline coordinate bound', 3: 'monster spline duration bound', 4: 'monster spline facing target has no matching binding', 5: 'monster spline packet bound', 6: 'monster spline point count bound', 7: 'monster spline spot facing unsupported', 8: 'monster spline target outside unit profile', 9: 'spline outside linear-ground/smooth-flight flags', 10: 'spline outside ordinary creature/player profile', 11: 'spline target bearing unavailable', 12: 'spline target has no current source position', 13: 'unexpected monster spline target binding', 1001: 'source mover has no admitted native actor', 65535: 'unregistered fixed rejection; use numeric parse stage'}
kinds={1:'source-spell-queued',2:'source-cast-result',3:'source-spell-go',4:'controlled-self-spline-sent',5:'self-or-unidentified-spline-rejected',6:'source-nonmelee-damage',7:'diagnostic-scope-change'}
matches={0:'no-action-association',1:'single-outstanding-spell',2:'ambiguous-overlap',3:'candidate-target-match',4:'candidate-unconfirmed-target',5:'candidate-Execute-child-and-target'}
for index in range(fields[7]if fields[0]==2 else 0):
values=struct.unpack_from('<QQQ10IQ',metadata,1056+index*72)
action,target,mover=values[:3];kind,spell,opcode,status,reason,spline,flags,match,available,facing=values[3:13];sequence=values[13]
if not sequence or kind not in kinds or match not in matches or available&~31:raise ValueError('Action diagnostic row bounds differ')
observed=[name for bit,name in[(1,'mover'),(2,'spline_id'),(4,'facing'),(8,'source_flags'),(16,'source_target')]if available&bit]
row=dict(sequence=str(sequence),action=str(action),source_target=str(target),source_mover=str(mover),kind=kind,kind_name=kinds[kind],spell=spell,opcode=opcode,status=status,reason=reason,spline_id=spline if available&2 else None,source_flags=flags if available&8 else None,match=match,match_name=matches[match],available=available,facing=facing if available&4 else None,observed_fields=observed)
if kind in(4,5):
if not available&1:row['source_mover']=None
if not available&16:row['source_target']=None
if kind==5:row['rejection']=reasons.get(reason,'unregistered fixed rejection')
if kind==4 and reason==1002:
row.update(final_facing_held=True,projection='source-path-without-final-target-facing')
if kind==6:row.update(damage=status,blocked=reason)
if kind==7:row.update(realm=status,map=reason)
result['actions'].append(row)
return result
def decode_world_failure(raw):
if len(raw)!=48:raise ValueError('World failure diagnostic size differs')
fields=struct.unpack('<IIIi8I',raw)
if fields[:2]!=(1,48) or fields[2]>12:raise ValueError('World failure diagnostic ABI differs')
names=('phase','result','source_opcode','source_bytes','modern_opcode','modern_bytes','required','capacity','count','index')
return dict(zip(names,fields[2:]))
def decode_world_call_failure(raw):
if len(raw)!=32:raise ValueError('World call failure diagnostic size differs')
abi,size,present,generation,transport_status,call_result,state,source_received=struct.unpack('<IIIIiiII',raw)
if (abi,size)!=(1,32) or present>1 or source_received>1 or state&~0x8000007f:
raise ValueError('World call failure diagnostic fields differ')
if not present and any((generation,transport_status,call_result,state,source_received)):
raise ValueError('Unpublished World call failure contains data')
valid=bool(state&0x80000000)
return dict(present=bool(present),generation=generation,transport_status=transport_status,
call_result=call_result,backend_state_valid=valid,
authenticated=bool(state&1) if valid else None,
world_present=bool(state&2) if valid else None,
logout_complete=bool(state&4) if valid else None,
realm_matches=bool(state&8) if valid else None,
source_packet_pending=bool(state&16) if valid else None,
encoded_output_pending=bool(state&32) if valid else None,
local_presentation_pending=bool(state&64) if valid else None,
source_received=bool(source_received))
def decode_world_call_phase(raw):
if len(raw)!=16:raise ValueError('World call phase diagnostic size differs')
abi,size,present,phase=struct.unpack('<4I',raw)
if (abi,size)!=(1,16) or present>1 or phase>4 or (not present and phase):
raise ValueError('World call phase diagnostic fields differ')
names=('not-observed','dispatch-entered','clock-read','state-read','translation-entered')
return dict(present=bool(present),phase=phase,phase_name=names[phase] if present else None)
def decode_roster_diagnostics(raw):
if len(raw)!=256:raise ValueError('Public roster metadata size differs')
abi,size,count,reason=struct.unpack_from('<4I',raw)
if abi not in (1,2) or size!=256 or count>255 or reason>6:raise ValueError('Public roster metadata ABI differs')
rows=[]
for index in range(min(count,10)):
race,cls,gender,level,issue,preview=struct.unpack_from('<6I',raw,16+24*index)
if issue>6 or (preview if abi==1 else preview>255):raise ValueError('Public roster metadata fields differ')
row=dict(race=race,class_id=cls,gender=gender,level=level,reason=issue)
if abi==2:row['preview_race']=preview
rows.append(row)
return dict(abi=abi,count=count,overall_reason=reason,rows=rows,names_or_guids_read=False)
def decode_create_observation(raw):
abi,size,count,saturated=struct.unpack('<4I',raw)
if (abi,size)!=(1,16) or saturated not in (0,1) or (saturated and count!=0xffffffff):
raise ValueError('Create observation ABI differs')
return {'outbound_create_count':count,'saturated':bool(saturated)}
def inspect(pid,entity_offset=0,unit_fields_only=False):
if type(entity_offset) is not int or not 0<=entity_offset<1024 or entity_offset%256:raise ValueError("Entity page offset must be0/256/512/768")
if type(unit_fields_only) is not bool:raise ValueError('Source-field-only inspection must be Boolean')
access=host.Access(pid)
try:
base,info,_=wire.module(access);data=base+info['exports']['gw_wire_pipe_data'];raw=access.read(data,SIZE)
abi,size,stage,error=struct.unpack('<4I',raw[:16])
if (abi,size)!=(1,SIZE):raise ValueError('Owned pipe ABI differs')
result=dict(zip(COUNTERS,struct.unpack('<24I',raw[80:176])))
unsupported=struct.unpack('<Q',raw[72:80])[0]
result['last_unsupported_out']=dict(opcode=unsupported&0xffffffff,bytes=unsupported>>32)
count=min(result['trace_count'],32)
start=max(0,result['trace_count']-32)
result.update(kind='actual-engine-Turtle-pipe',stage=stage,error=error,trace=[dict(zip(('direction','opcode','bytes'),struct.unpack('<3I',raw[256+((start+i)%32)*12:268+((start+i)%32)*12]))) for i in range(count)],
packet_payloads_exported=False,account_state_fabricated=False,native_character_selection_verified=False,native_world_entry_verified=False)
create_export=info['exports'].get('gw_wire_create_observation')
if create_export:
result['create_observation']=decode_create_observation(wire.read_public_bytes(access,base+create_export,16))
roster_export=info['exports'].get('gw_wire_roster_diagnostics_data')
if roster_export:result['roster_diagnostics']=decode_roster_diagnostics(wire.read_public_bytes(access,base+roster_export,256))
hotfix=wire.read_public_bytes(access,base+info['exports']['gw_wire_hotfix_data'],40)
fields=struct.unpack('<9Ii',hotfix)
if fields[:2]!=(1,40):raise ValueError('Owned public hotfix metadata ABI differs')
result['hotfix']=dict(zip(('queries','replies','client_build','data_build','push_count','request_bytes','reply_bytes','result'),fields[2:]))
queries=base+info['exports']['gw_wire_pipe_queries']
metadata=wire.read_public_bytes(access,queries,1168)
abi,size,count,malformed=struct.unpack('<4I',metadata[:16])
if (abi,size)!=(1,1168) or count>8:raise ValueError('Owned public DB query metadata differs')
result['db_query_malformed']=malformed;result['db_queries']=[]
for index in range(count):
fields=struct.unpack('<36I',metadata[16+index*144:160+index*144])
if fields[2]>32 or fields[2]>fields[1]:raise ValueError('Public DB query count differs')
result['db_queries'].append(dict(table_hash=hex(fields[0]),requested_count=fields[1],captured_ids=list(fields[4:4+fields[2]])))
world=wire.read_public_bytes(access,base+info['exports']['gw_wire_world_data'],432)
fields=struct.unpack('<12I',world[:48])
if fields[:2]!=(1,432):raise ValueError('Owned public world diagnostics ABI differs')
result['world']=dict(zip(('login_sent','received','queued','self_create','ignored','last_legacy','last_modern','last_bytes','trace_count'),fields[2:11]))
result['world']['flags']=fields[11]
result['world']['realm_context_bound']=bool(fields[11]&1)
result['world']['self_create_queued']=bool(fields[11]&2)
result['world']['active_mover_queued']=bool(fields[11]&4)
result['world']['active_mover_request']=bool(fields[11]&8)
result['world']['active_mover_accepted']=bool(fields[11]&16)
result['world']['movement_request']=bool(fields[11]&32)
result['world']['movement_accepted']=bool(fields[11]&64)
result['world']['movement_rejected']=bool(fields[11]&128)
result['world']['move_init_active_mover_complete']=bool(fields[11]&256)
result['world']['move_init_active_mover_bad_size']=bool(fields[11]&512)
n=min(fields[10],32);start=max(0,fields[10]-32)
result['world']['trace']=[dict(zip(('direction','opcode','bytes'),struct.unpack('<3I',world[48+((start+i)%32)*12:60+((start+i)%32)*12]))) for i in range(n)]
entity_export=info['exports'].get('gw_wire_entity_data')
if entity_export:
if unit_fields_only:
header=wire.read_public_bytes(access,base+entity_export,48)
fields=struct.unpack('<12I',header);limit=ENTITY_ABIS.get(fields[:2])
if limit is None or fields[10]>limit or fields[11]>1:raise ValueError('Entity metadata bounds differ')
else:
result['entities'],header=read_optional_entity_page(access,base+entity_export,entity_offset)
fields=struct.unpack('<12I',header) if header is not None else None
if fields is not None and fields[0]==3:result['source_unit_fields']=read_source_unit_fields(access,base+entity_export+ENTITY_FIELD_OFFSET,unit_fields_only)
result['unit_fields_only']=unit_fields_only
capture_export=info['exports'].get('gw_wire_private_capture')
if capture_export:
raw=wire.read_public_bytes(access,base+capture_export,32)
abi,size,configured,error,records,byte_count=struct.unpack('<4I2Q',raw)
if(abi,size)!=(1,32):raise ValueError('Private capture status ABI differs')
result['private_capture']=dict(configured=bool(configured),error=error,records=records,bytes=byte_count)
motion_export=info['exports'].get('gw_wire_motion_data')
if motion_export:
header=wire.read_public_bytes(access,base+motion_export,8)
abi,size=struct.unpack('<2I',header)
if (abi,size)not in[(1,1056),(2,2208)]:raise ValueError('Motion metadata ABI differs')
metadata=wire.read_public_bytes(access,base+motion_export,size,max_size=2208)
result['motion']=decode_motion_metadata(metadata)
failure_export=info['exports'].get('gw_wire_movement_failure')
world_failure_export=info['exports'].get('gw_wire_world_failure')
if world_failure_export:
raw=wire.read_public_bytes(access,base+world_failure_export,48)
result['world_failure']=decode_world_failure(raw)
world_call_failure_export=info['exports'].get('gw_wire_world_call_failure')
if world_call_failure_export:
raw=wire.read_public_bytes(access,base+world_call_failure_export,32)
result['world_call_failure']=decode_world_call_failure(raw)
world_call_phase_export=info['exports'].get('gw_wire_world_call_phase')
if world_call_phase_export:
raw=wire.read_public_bytes(access,base+world_call_phase_export,16)
result['world_call_phase']=decode_world_call_phase(raw)
item_export=info['exports'].get('gw_wire_item_request')
inventory_export=info['exports'].get('gw_wire_inventory_data')
if inventory_export:
metadata=wire.read_public_bytes(access,base+inventory_export,1344);values=struct.unpack_from('<8I',metadata)
if values[:2]!=(2,1344) or values[3]>32 or values[4]>1:raise ValueError('Inventory diagnostic bounds differ')
result['inventory']=dict(zip(('items','captured','truncated','value_updates','creates','removals'),values[2:]))
result['inventory']['rows']=[]
for index in range(values[3]):
guid,contained,entry,count,durability,maximum,enchant,duration=struct.unpack_from('<QQ6I',metadata,32+40*index)
result['inventory']['rows'].append(dict(guid=str(guid),contained=str(contained),entry=entry,count=count,durability=durability,max_durability=maximum,temporary_enchant=enchant,temporary_duration=duration))
result['inventory']['metadata']=dict(zip(('templates','pending_queries','queued_queries','replies','missing','last_entry','cooldown_packets','cooldown_modifier_blocks'),struct.unpack_from('<8I',metadata,1312)))
aura_export=info['exports'].get('gw_wire_aura_data')
if aura_export:result['auras']=decode_aura_state(wire.read_public_bytes(access,base+aura_export,1376))
cast_export=info['exports'].get('gw_wire_cast_result')
if cast_export:
metadata=wire.read_public_bytes(access,base+cast_export,48);values=struct.unpack('<12I',metadata)
if values[:2]!=(1,48) or values[3] not in (0,0x130) or values[-1]>8:raise ValueError('Cast result diagnostic bounds differ')
result['cast_result']=dict(zip(('count','opcode','bytes','spell','status','reason','inventory_count','inventory_reason','stand_received','stand_state'),values[2:]))
if item_export:
metadata=wire.read_public_bytes(access,base+item_export,280)
result['item_request']=decode_item_request(metadata)
result['item_use_payload_exported']=bool(result['item_request']['captured'])
result['packet_payloads_exported']=result['item_use_payload_exported']
spell_export=info['exports'].get('gw_wire_spell_request')
if spell_export:
metadata=wire.read_public_bytes(access,base+spell_export,280)
result['spell_request']=decode_spell_request(metadata)
result['spell_cast_payload_exported']=bool(result['spell_request']['captured'])
result['packet_payloads_exported']=result['packet_payloads_exported'] or result['spell_cast_payload_exported']
if failure_export:
fields=struct.unpack('<4Ii7I',wire.read_public_bytes(access,base+failure_export,48))
if fields[:2]!=(1,48):raise ValueError('Movement failure diagnostic ABI differs')
result['movement_failure']=dict(zip(('opcode','bytes','result','flags_lo','flags_hi','options','tail','forces','fall_direction','remaining'),fields[2:]))
import engine_channel_policy_host
result['original_send_contracts']=inspect_code_contracts(access,engine_channel_policy_host.TARGETS)
bound_source_field_reply(result)
return result
finally:access.close()