367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
720 lines
45 KiB
Python
720 lines
45 KiB
Python
#!/usr/bin/env python3
|
|
"""Fixed, read-only public engine metadata; no auth buffers or engine calls.
|
|
|
|
Used only by the diagnostic parent of its own pinned disposable WowB child.
|
|
Pointer traversal is limited to the observed registry and NetClient fields.
|
|
"""
|
|
import math
|
|
import hashlib
|
|
from pathlib import Path
|
|
import struct
|
|
BASE=0x140000000
|
|
REGISTRY=0x147ed91e8
|
|
NETCLIENT=0x145e7a098
|
|
SLOTS=((8,'accepts_opcode'),(0x28,'decode_callback'),(0x30,'receive_callback'))
|
|
# One-request diagnostic opt-in. Original 655770 and the World-loaded getter
|
|
# 64f0e0 establish this fixed registry and its triangular-probe key lookup.
|
|
# Ordinary health/launcher snapshots do not traverse this table.
|
|
ENABLE_MAP_AREA_DESCRIPTOR_LOOKUP=False
|
|
ENABLE_MAP_AREA_TYPED_METHOD_LOOKUP=False
|
|
ENABLE_MAP_AREA_SCHEMA_LOOKUP=False
|
|
ENABLE_MAP1_RECORD_CACHE_HEADER_LOOKUP=False
|
|
MAP_AREA_REGISTRY=0x145c80710
|
|
MAP_AREA_TABLE_KEYS=(('Map',0xbd84cd62),('AreaTable',0x7253eb43))
|
|
MAP_AREA_GETTER_ANCHOR=(0x14064f100,bytes.fromhex('488d05091663054883c438c3'))
|
|
MAP_AREA_TYPED_VTABLES=(('Map',0x144cd3f60),('AreaTable',0x144cd5568))
|
|
MAP_AREA_TYPED_DESCRIPTORS=(('Map',0x14603ac60),('AreaTable',0x14603c2e0))
|
|
|
|
def inspect_map1_materialized_cache_header(read):
|
|
"""One 16-byte image-data header; no bucket, record or on-disk reads.
|
|
|
|
Original 64eba0 selects descriptor+78; complete 65eb40 returns an empty
|
|
iterator immediately when that container's +8 pointer is null. This does
|
|
not describe the separately retained hotfix blob or baseline DB2 rows.
|
|
"""
|
|
result={'kind':'fixed-original-Map1-materialized-cache-header','record_id':1,
|
|
'descriptor':'0x14603ac60','bytes_read_limit':16,
|
|
'engine_calls_made':False,'bucket_or_node_walk':False,
|
|
'on_disk_or_hotfix_blob_absence_proven':False}
|
|
if MAP_AREA_TYPED_DESCRIPTORS!=(('Map',0x14603ac60),('AreaTable',0x14603c2e0)):
|
|
result.update(status='fixed-descriptor-pins-held');return result
|
|
try:
|
|
extent,array=struct.unpack('<2Q',read(0x14603ac60+0x78,16))
|
|
result.update(bucket_extent_observed=extent,bucket_array_pointer=hex(array))
|
|
if array==0:
|
|
result.update(status='materialized-container-unallocated',record1_in_materialized_cache=False)
|
|
else:
|
|
result.update(status='materialized-container-present-record1-lookup-held',record1_in_materialized_cache=None,
|
|
required_original_code='140660920 bucket function remains executable-guard-refused; no retry')
|
|
except (OSError,ValueError,struct.error) as error:
|
|
result.update(status='header-mapping-held',reason=str(error))
|
|
return result
|
|
|
|
def inspect_map_area_schemas(read):
|
|
"""Only schema fields actually read by the captured original row decoder.
|
|
|
|
Reuses the two exact-key matches in the same owned c49 World lifetime.
|
|
No names, data rows, callbacks or other descriptors are followed.
|
|
"""
|
|
result={'kind':'fixed-original-Map-Area-schema-metadata','tables':[],'engine_calls_made':False}
|
|
if MAP_AREA_TYPED_DESCRIPTORS!=(('Map',0x14603ac60),('AreaTable',0x14603c2e0)):
|
|
result.update(status='fixed-descriptor-pins-held');return result
|
|
for name,descriptor in MAP_AREA_TYPED_DESCRIPTORS:
|
|
row={'table':name,'descriptor':hex(descriptor)};result['tables'].append(row)
|
|
try:
|
|
schema=struct.unpack('<Q',read(descriptor+8,8))[0]
|
|
if schema==0 or schema&7 or schema>0xffffffffffffffff-0x38:
|
|
raise ValueError('Typed schema pointer held')
|
|
row_size,field_count=struct.unpack('<2I',read(schema+0x10,8))
|
|
if not 1<=row_size<=65536 or not 1<=field_count<=128:
|
|
raise ValueError('Typed schema size/count held')
|
|
pointers=struct.unpack('<3Q',read(schema+0x20,24))
|
|
arrays=[]
|
|
for pointer in pointers:
|
|
if pointer==0 or pointer&3 or pointer>0xffffffffffffffff-field_count*4:
|
|
raise ValueError('Typed schema array extent held')
|
|
arrays.append(list(struct.unpack('<'+'I'*field_count,read(pointer,field_count*4))))
|
|
offsets,counts,types=arrays
|
|
if any(offset>=row_size for offset in offsets) or any(not 1<=count<=65536 for count in counts) or any(kind>5 for kind in types):
|
|
raise ValueError('Typed schema field metadata held')
|
|
row.update(status='original-schema-fields-observed',schema=hex(schema),row_size=row_size,
|
|
field_count=field_count,offsets=offsets,element_counts=counts,wire_types=types,
|
|
source_defaults_or_semantic_type_aliases_proven=False)
|
|
except (OSError,ValueError,struct.error) as error:
|
|
row.update(status='schema-mapping-or-shape-held',reason=str(error))
|
|
result['status']='two-exact-schema-lookups'
|
|
return result
|
|
|
|
def inspect_map_area_typed_methods(read,executable):
|
|
"""Eight immutable vtable cells certified by the local-World key lookup.
|
|
|
|
Reuses that same owned c49 lifetime; does not repeat the registry search or
|
|
follow descriptor/data pointers. Slots come from the captured +48 method.
|
|
"""
|
|
result={'kind':'fixed-original-Map-Area-typed-methods','engine_calls_made':False,'tables':[]}
|
|
if MAP_AREA_TYPED_VTABLES!=(('Map',0x144cd3f60),('AreaTable',0x144cd5568)):
|
|
result.update(status='fixed-vtable-pins-held');return result
|
|
# Exact original c49 .rdata virtual extent from the retained PE header.
|
|
rdata_begin,rdata_end=0x1447c2000,0x145663024
|
|
for name,vtable in MAP_AREA_TYPED_VTABLES:
|
|
row={'table':name,'vtable':hex(vtable),'methods':[]};result['tables'].append(row)
|
|
for offset in (0xf0,0x68,0x70,0x80):
|
|
cell={'slot':hex(offset)};row['methods'].append(cell)
|
|
try:
|
|
address=vtable+offset
|
|
if not rdata_begin<=address<=rdata_end-8 or address&7:
|
|
raise ValueError('Typed method cell outside pinned original rdata')
|
|
method=struct.unpack('<Q',read(address,8))[0]
|
|
cell.update(status='original-vtable-method-observed',method=hex(method),
|
|
executable=executable(method,1),semantics_proven=False)
|
|
except (OSError,ValueError,struct.error) as error:
|
|
cell.update(status='method-mapping-held',reason=str(error))
|
|
result['status']='eight-exact-typed-method-cells'
|
|
return result
|
|
|
|
def inspect_map_area_descriptors(read,executable):
|
|
"""Two exact DB2 keys only; no native invocation or registry inventory.
|
|
|
|
The owning c49 clean-child route supplies its existing mapped-readable
|
|
bounded reader. The loaded getter anchor additionally binds this layout.
|
|
Descriptor+20d is only the observed DB_REPLY notification gate.
|
|
"""
|
|
result={'kind':'fixed-original-Map-Area-descriptor-lookup','engine_calls_made':False,
|
|
'table_keys':dict(MAP_AREA_TABLE_KEYS),'max_probes_per_key':32,'tables':[]}
|
|
try:
|
|
if MAP_AREA_REGISTRY!=0x145c80710 or MAP_AREA_TABLE_KEYS!=(('Map',0xbd84cd62),('AreaTable',0x7253eb43)):
|
|
raise ValueError('Fixed original table-key pins differ')
|
|
address,signature=MAP_AREA_GETTER_ANCHOR
|
|
if read(address,len(signature))!=signature:
|
|
raise ValueError('Original registry getter anchor differs')
|
|
capacity,entries,unused,tombstones=struct.unpack('<4Q',read(MAP_AREA_REGISTRY,32))
|
|
if not 1<=capacity<=0x100000 or capacity&(capacity-1):
|
|
raise ValueError('Original registry capacity held')
|
|
if entries==0 or entries&15 or entries>0xffffffffffffffff-(capacity+1)*16:
|
|
raise ValueError('Original registry entry extent held')
|
|
if tombstones>capacity:
|
|
raise ValueError('Original registry tombstone count held')
|
|
except (OSError,ValueError,struct.error) as error:
|
|
result.update(status='registry-held',reason=str(error));return result
|
|
result.update(status='bounded-exact-key-lookups',capacity=capacity)
|
|
for name,key in MAP_AREA_TABLE_KEYS:
|
|
row={'table':name,'table_key':key,'probes':0}
|
|
result['tables'].append(row)
|
|
# Exact arithmetic from original 655770; this is not Python hash().
|
|
value=(key*0xff51afd7ed558ccd)&0xffffffffffffffff
|
|
value=((value^(value>>33))*0xc4ceb9fe1a85ec53)&0xffffffffffffffff
|
|
index=(value^(value>>33))&(capacity-1)
|
|
try:
|
|
for step in range(min(capacity,32)):
|
|
entry=entries+index*16
|
|
found=struct.unpack('<I',read(entry,4))[0]
|
|
row['probes']+=1
|
|
if found==0:
|
|
row['status']='no-matching-key';break
|
|
if not(tombstones and found==1) and found==key:
|
|
descriptor=struct.unpack('<Q',read(entry+8,8))[0]
|
|
if descriptor==0 or descriptor&7 or descriptor>0xffffffffffffffff-0x20e:
|
|
raise ValueError('Matching descriptor pointer held')
|
|
vtable=struct.unpack('<Q',read(descriptor,8))[0]
|
|
if vtable==0 or vtable&7 or vtable>0xffffffffffffffff-0x50:
|
|
raise ValueError('Matching descriptor vtable held')
|
|
gate=read(descriptor+0x20d,1)[0]
|
|
method=struct.unpack('<Q',read(vtable+0x48,8))[0]
|
|
row.update(status='exact-key-descriptor-observed',descriptor=hex(descriptor),
|
|
vtable=hex(vtable),notify_gate_20d=gate,
|
|
notify_method_48=hex(method),notify_method_executable=executable(method,1),
|
|
row_admission_or_reindex_semantics_proven=False)
|
|
break
|
|
index=(index+step+1)&(capacity-1)
|
|
else:row['status']='probe-bound-held'
|
|
except (OSError,ValueError,struct.error,IndexError) as error:
|
|
row.update(status='matching-key-or-mapping-held',reason=str(error))
|
|
return result
|
|
# Source-disassembled getter 0x141e8cf00 returns this fixed service object on
|
|
# the actual auth receiver path; receiver 0x1422b8780 reads its +0x2c50 slot.
|
|
AUTH_SERVICE_CALLBACK_SLOT=0x147f5a9f0+0x2c50
|
|
|
|
# Exact original-code witnesses captured through the pinned startup owner.
|
|
# CorpseLocation callback142842690 -> setter142836950 establishes this
|
|
# primary state layout. Range transition142836da0 reads/writes14606af78.
|
|
# These are fixed original image globals, never addresses supplied by callers.
|
|
CORPSE_STATE_ANCHORS=(
|
|
(0x142836950,bytes.fromhex('48895c2408574883ec60488bbc2498000000488bd9891148')),
|
|
(0x142836da0,bytes.fromhex('4883ec283b0dce4183030f8494000000')),
|
|
)
|
|
_CORPSE_CODE_SCAN_CACHE=globals().get('_CORPSE_CODE_SCAN_CACHE',{})
|
|
# Diagnostic discovery is intentionally off for ordinary launcher/health
|
|
# snapshots. Recorded code witnesses remain in the isolated runtime dossier.
|
|
ENABLE_CORPSE_CODE_REFERENCE_SCAN=False
|
|
CORPSE_FIXED_RIP_TARGETS={
|
|
0x14606af78:'range-state-rip-reference',
|
|
# Pinned original .rdata Corpse_C.cpp/type/assertion descriptors; not
|
|
# user-supplied search addresses or proof of a field's meaning.
|
|
0x144f40a10:'corpse-class-source-path-reference',
|
|
0x144e5b1f0:'corpse-class-name-reference',
|
|
0x144f408a0:'corpse-mirror-type-name-reference',
|
|
0x144f40ec0:'corpse-model-assertion-reference',
|
|
0x144f40f10:'corpse-component-assertion-reference',
|
|
0x144f40f60:'corpse-display-assertion-reference',
|
|
0x144f40fb0:'corpse-model-update-assertion-reference',
|
|
0x144f41000:'corpse-scale-assertion-reference',
|
|
0x144f41050:'corpse-effect-assertion-reference',
|
|
}
|
|
|
|
def _corpse_text_bounds(path,expected_sha):
|
|
"""Verify the immutable original PE before a code-only address scan."""
|
|
if path.is_symlink() or not path.is_file() or not 0<path.stat().st_size<=134217728:
|
|
raise ValueError('Pinned original PE required')
|
|
digest=hashlib.sha256()
|
|
with path.open('rb')as stream:
|
|
for chunk in iter(lambda:stream.read(1048576),b''):digest.update(chunk)
|
|
if digest.hexdigest()!=expected_sha:raise ValueError('Original PE identity differs')
|
|
stream.seek(0);header=stream.read(4096)
|
|
if header[:2]!=b'MZ':raise ValueError('Original PE DOS header differs')
|
|
pe=struct.unpack_from('<I',header,0x3c)[0]
|
|
if pe>3072 or header[pe:pe+4]!=b'PE\0\0':raise ValueError('Original PE header bound')
|
|
machine,count=struct.unpack_from('<HH',header,pe+4)
|
|
optional=struct.unpack_from('<H',header,pe+20)[0]
|
|
if machine!=0x8664 or not 1<=count<=32 or optional<112:raise ValueError('Original PE architecture differs')
|
|
if struct.unpack_from('<H',header,pe+24)[0]!=0x20b or struct.unpack_from('<Q',header,pe+48)[0]!=BASE:
|
|
raise ValueError('Original PE image base differs')
|
|
sections=[]
|
|
for index in range(count):
|
|
at=pe+24+optional+index*40
|
|
if at+40>len(header):raise ValueError('Original PE sections exceed header')
|
|
name=header[at:at+8].rstrip(b'\0')
|
|
if name==b'.text':
|
|
size,rva=struct.unpack_from('<II',header,at+8)
|
|
flags=struct.unpack_from('<I',header,at+36)[0]
|
|
if not flags&0x20000000 or flags&0x80000000 or not 0x1000<=rva<rva+size<=0x5000000:
|
|
raise ValueError('Original executable text bounds differ')
|
|
sections.append((BASE+rva,BASE+rva+size))
|
|
if len(sections)!=1:raise ValueError('Unique original text section required')
|
|
return sections[0]
|
|
|
|
def _corpse_code_candidates(data,address):
|
|
"""Byte candidates only; instruction/function boundaries need verification."""
|
|
found=[]
|
|
for index,opcode in enumerate(data):
|
|
if opcode in(0xe8,0xe9)and index+5<=len(data):
|
|
target=address+index+5+struct.unpack_from('<i',data,index+1)[0]
|
|
if target==0x142836da0:found.append((index,5,'direct-call'if opcode==0xe8 else'direct-jump',target))
|
|
if opcode not in(0x8b,0x89,0x3b,0x39,0x83,0x81,0xc7,0xf7,0x85,0x8d)or index+6>len(data):continue
|
|
modrm=data[index+1]
|
|
if modrm&0xc7!=5:continue
|
|
immediate=1 if opcode==0x83 else 4 if opcode in(0x81,0xc7,0xf7)else 0
|
|
if opcode==0xf7 and modrm&0x38:continue
|
|
length=6+immediate
|
|
if index+length>len(data):continue
|
|
target=address+index+length+struct.unpack_from('<i',data,index+2)[0]
|
|
if target in CORPSE_FIXED_RIP_TARGETS:found.append((index,length,CORPSE_FIXED_RIP_TARGETS[target],target))
|
|
rows=[]
|
|
for index,length,kind,target in found:
|
|
first=max(0,index-16);last=min(len(data),index+length+24);window=data[first:last]
|
|
rows.append({'kind':kind+'-candidate','address':hex(address+index),'target':hex(target),
|
|
'instruction_hex':data[index:index+length].hex(),'window_address':hex(address+first),
|
|
'window_hex':window.hex(),'window_sha256':hashlib.sha256(window).hexdigest()})
|
|
return rows
|
|
|
|
def corpse_range_code_references(read,executable,bounds=None):
|
|
"""Fixed original-code search, no arbitrary targets, heap or engine calls."""
|
|
report={'available':False,'engine_calls_made':False,'heap_read':False,
|
|
'matches_are_candidates':True,'max_results':16,'byte_cap':67108864,
|
|
'page_cap':16384,'results':[]}
|
|
try:
|
|
if any(read(address,len(signature))!=signature for address,signature in CORPSE_STATE_ANCHORS):return report
|
|
if bounds is None:
|
|
bounds=_corpse_text_bounds(Path(__file__).resolve().parents[1]/'runtime/native-client/_classic_beta_/WowB.exe',
|
|
'c49ce22c3e0aaeb7a7007a5c5cb792e4c3e6cdecc55a1145a5933fc113e3e57f')
|
|
key=(bounds,tuple(signature for _,signature in CORPSE_STATE_ANCHORS),tuple(CORPSE_FIXED_RIP_TARGETS))
|
|
if key in _CORPSE_CODE_SCAN_CACHE:return _CORPSE_CODE_SCAN_CACHE[key]
|
|
else:key=None # Isolated offline fixtures only; production has no supplied bounds.
|
|
lo,hi=bounds
|
|
if not BASE<=lo<hi<=BASE+0x5000000:raise ValueError('Original text bounds')
|
|
scanned=pages=0;seen=set();carry=b'';previous_end=None;truncated=False
|
|
near_lo=max(lo,0x142036000);near_hi=min(hi,0x143036000)
|
|
ranges=[(near_lo,near_hi),(lo,near_lo),(near_hi,hi)]if near_lo<near_hi else[(lo,hi)]
|
|
report['scan_order']='corpse-manager-neighborhood-first-then-remaining-original-text'
|
|
report['ordered_text_ranges']=[[hex(a),hex(b)]for a,b in ranges if a<b]
|
|
for address in (p for a,b in ranges if a<b for p in range(a,b,4096)):
|
|
size=min(4096,hi-address)
|
|
if not executable(address,size):carry=b'';previous_end=None;continue
|
|
if pages>=report['page_cap']or scanned+size>report['byte_cap']:truncated=True;break
|
|
# Reuse the owner's existing512-byte metadata-read ceiling.
|
|
# Never widen its process-memory API for this scan.
|
|
data=b''.join(read(address+offset,min(512,size-offset))for offset in range(0,size,512))
|
|
if len(data)!=size:raise ValueError('Incomplete original executable page')
|
|
prefix=carry if previous_end==address else b''
|
|
rows=_corpse_code_candidates(prefix+data,address-len(prefix));scanned+=size;pages+=1
|
|
for row in rows:
|
|
if row['address']in seen:continue
|
|
if len(report['results'])==report['max_results']:truncated=True;break
|
|
seen.add(row['address']);report['results'].append(row)
|
|
if truncated:break
|
|
carry=data[-16:];previous_end=address+size
|
|
report.update(available=True,text_begin=hex(lo),text_end=hex(hi),
|
|
executable_bytes_scanned=scanned,executable_pages_scanned=pages,truncated=truncated)
|
|
if key is not None:_CORPSE_CODE_SCAN_CACHE[key]=report
|
|
except (OSError,ValueError,struct.error):
|
|
report['reason']='fixed-original-code-page-unavailable-or-changing'
|
|
return report
|
|
|
|
def corpse_state(read):
|
|
"""Inspect only source-bound static corpse fields; no pointer traversal.
|
|
|
|
The existing startup owner supplies this read callback only for its exact
|
|
pinned private client. Code identity must match before any state is read.
|
|
Raw XYZ is the stored corpse-query position, not the player's position or
|
|
proof that the original proximity evaluator has accepted the corpse.
|
|
"""
|
|
unavailable={'available':False,'reason':'original-corpse-layout-unavailable'}
|
|
try:
|
|
if any(read(address,len(signature))!=signature
|
|
for address,signature in CORPSE_STATE_ANCHORS):
|
|
return unavailable
|
|
def guid(address):
|
|
low,high=struct.unpack('<QQ',read(address,16))
|
|
return {'low':hex(low),'high':hex(high),'empty':not(low or high)}
|
|
actual_map,map_id=struct.unpack('<ii',read(0x14576e850,8))
|
|
owner=guid(0x14576e858)
|
|
corpse=guid(0x14576e868)
|
|
xyz=struct.unpack('<fff',read(0x14576e890,12))
|
|
range_value=struct.unpack('<I',read(0x14606af78,4))[0]
|
|
return {'available':True,'original_layout_verified':True,
|
|
'actual_map_id':actual_map,'map_id':map_id,
|
|
'owner_guid':owner,'corpse_guid':corpse,
|
|
'stored_corpse_xyz':list(xyz) if all(map(math.isfinite,xyz)) else None,
|
|
'stored_corpse_xyz_finite':all(map(math.isfinite,xyz)),
|
|
'range_state_dword':range_value,
|
|
'range_state_boolean':bool(range_value) if range_value in(0,1) else None,
|
|
'engine_calls_made':False,'pointer_traversal':False}
|
|
except (OSError,ValueError,struct.error):
|
|
return unavailable
|
|
|
|
LOCAL_PLAYER_CORPSE_GATE_ANCHORS=(
|
|
(0x14252b105,bytes.fromhex('488b0de406b40349b80cae4b3c8c0c15d64903c848bf2683c2293ed1c1664833cf48894d10488d4d10e89db50200488b4d10488bd148c1e90348c1e23d480bd1')),
|
|
(0x14252b200,bytes.fromhex('4833908301000048c1ca3b')),
|
|
(0x1425566d0,bytes.fromhex('48b83a545278e91fc4dc480101c3')),
|
|
(0x1428360a4,bytes.fromhex('f680d026000010')),
|
|
)
|
|
LOCAL_PLAYER_POSITION_ANCHORS=(
|
|
(0x1401f008a,bytes.fromhex('488b184883e3fe743e488bcb')),
|
|
(0x1401effe0,bytes.fromhex('4883ec284c8b4108418b403085c0793e83f8ff7507')),
|
|
(0x14453fdb2,bytes.fromhex('488b72084c8bfa4c8be1f64620400f8443020000')),
|
|
(0x144540009,bytes.fromhex('488d467c')),
|
|
)
|
|
|
|
def _owned_player_world_position(read,player):
|
|
"""Only the source-proven inline ECS component path; no external lookup."""
|
|
unavailable={'available':False,'reason':'original-inline-position-unavailable'}
|
|
try:
|
|
if any(read(a,len(s))!=s for a,s in LOCAL_PLAYER_POSITION_ANCHORS):return unavailable
|
|
tagged=struct.unpack('<Q',read(player+8,8))[0];handle=tagged&~1
|
|
if not 0x10000<=handle<0x0000800000000000 or handle&7:return unavailable
|
|
layout=struct.unpack('<Q',read(handle+8,8))[0]
|
|
if not 0x10000<=layout<0x0000800000000000 or layout&7:return unavailable
|
|
offset=struct.unpack('<i',read(layout+0x30,4))[0]
|
|
if not 0<=offset<=0x10000:return {'available':False,'reason':'external-position-component-not-followed'}
|
|
component=handle+offset
|
|
flags=struct.unpack('<I',read(component+0x20,4))[0]
|
|
if flags&0x40:return {'available':False,'reason':'original-position-cache-dirty'}
|
|
raw=read(component+0x7c,12);xyz=struct.unpack('<fff',raw)
|
|
if not all(map(math.isfinite,xyz)):return unavailable
|
|
if read(component+0x20,4)!=struct.pack('<I',flags)or read(player+8,8)!=struct.pack('<Q',tagged):return unavailable
|
|
return {'available':True,'original_inline_component_verified':True,
|
|
'world_xyz':list(xyz),'cache_dirty':False,'pointer_data_exported':False}
|
|
except (OSError,ValueError,struct.error):return unavailable
|
|
|
|
def _decode_local_player_cache(cached,key):
|
|
"""Exact captured getter arithmetic; pure integer evaluation, no calls."""
|
|
mask=(1<<64)-1
|
|
def ror(value,count):return ((value>>count)|(value<<(64-count)))&mask
|
|
value=((cached+0xd6150c8c3c4bae0c)&mask)^0x66c1d13e29c28326
|
|
value=(value+0xdcc41fe97852543a)&mask
|
|
value=((ror(value,3)^0x5f)-0x226b38657ebdef29)&mask
|
|
return ror(value^key,59)
|
|
|
|
def local_player_corpse_gate(read,primary):
|
|
"""Source-bound cached local player only; no general object/heap traversal.
|
|
|
|
Internal pointer-obfuscation data is never returned. The decoded object
|
|
must have an original-image vtable and the exact already verified owner
|
|
GUID before the single predicate-member byte is read.
|
|
"""
|
|
unavailable={'available':False,'reason':'original-owned-player-gate-unavailable'}
|
|
try:
|
|
if not primary.get('available')or primary['owner_guid']['empty']:return unavailable
|
|
if any(read(address,len(signature))!=signature for address,signature in LOCAL_PLAYER_CORPSE_GATE_ANCHORS):return unavailable
|
|
cached=struct.unpack('<Q',read(0x14606b7f0,8))[0]
|
|
context=struct.unpack('<Q',read(0x145e6da88,8))[0]
|
|
if not 0x10000<=context<0x0000800000000000 or context&7:return unavailable
|
|
key=struct.unpack('<Q',read(context+0x183,8))[0]
|
|
player=_decode_local_player_cache(cached,key)
|
|
if not 0x10000<=player<0x0000800000000000 or player&7:return unavailable
|
|
vtable=struct.unpack('<Q',read(player,8))[0]
|
|
if not 0x1447c145c<=vtable<0x145700000 or vtable&7:return unavailable
|
|
entry=struct.unpack('<Q',read(vtable,8))[0]
|
|
if not BASE<=entry<0x1447c145c:return unavailable
|
|
low,high=struct.unpack('<QQ',read(player+0x10,16))
|
|
if (hex(low),hex(high))!=(primary['owner_guid']['low'],primary['owner_guid']['high']):return unavailable
|
|
gate=read(player+0x26d0,1)
|
|
if len(gate)!=1:return unavailable
|
|
position=_owned_player_world_position(read,player)
|
|
if read(player+0x10,16)!=struct.pack('<QQ',low,high):return unavailable
|
|
if position.get('available')and primary.get('stored_corpse_xyz_finite'):
|
|
position['distance_squared_to_stored_corpse_xyz']=sum((a-b)**2 for a,b in zip(position['world_xyz'],primary['stored_corpse_xyz']))
|
|
return {'available':True,'original_code_verified':True,
|
|
'owned_player_guid_matches':True,'original_image_vtable_verified':True,
|
|
'predicate_member_26d0_bit10':bool(gate[0]&0x10),
|
|
'native_player_position':position,
|
|
'pointer_data_exported':False,'engine_calls_made':False}
|
|
except (OSError,ValueError,struct.error):return unavailable
|
|
|
|
def auth_classes_field(read,address):
|
|
"""Expose only whether the source-traced opaque field is zeroed."""
|
|
try:
|
|
raw=read(address,24)
|
|
return {'header_read':True,'all_zero':not any(raw)}
|
|
except (OSError,ValueError,struct.error):
|
|
return {'header_read':False,'all_zero':None}
|
|
|
|
def auth_state_receiver(read,executable,owner):
|
|
"""Identify, but never invoke, the source-traced AuthResponse receiver."""
|
|
try:
|
|
manager=struct.unpack('<Q',read(owner+0xc58,8))[0]
|
|
if not 0x10000<=manager<0x0000800000000000:return None
|
|
vtable=struct.unpack('<Q',read(manager,8))[0]
|
|
if not 0x10000<=vtable<0x0000800000000000:return None
|
|
target=struct.unpack('<Q',read(vtable+0x20,8))[0]
|
|
if not BASE<=target<BASE+0x5000000 or not executable(target,1):return None
|
|
return hex(target)
|
|
except (OSError,ValueError,struct.error):
|
|
return None
|
|
|
|
def auth_service_callback(read,executable):
|
|
"""Inspect only the receiver's statically derived callback slot.
|
|
|
|
Never follows a returned pointer. Only an executable pointer into the
|
|
pinned client image is exposed; arbitrary heap/DLL addresses are redacted.
|
|
"""
|
|
try:
|
|
target=struct.unpack('<Q',read(AUTH_SERVICE_CALLBACK_SLOT,8))[0]
|
|
in_image=BASE<=target<BASE+0x5000000
|
|
return {'present':bool(target),
|
|
'client_target':hex(target) if target and in_image and executable(target,1) else None,
|
|
'kind':'client-code' if target and in_image and executable(target,1) else
|
|
'client-not-executable' if target and in_image else
|
|
'other-or-unavailable' if target else 'null'}
|
|
except (OSError,ValueError,struct.error):
|
|
return {'available':False}
|
|
|
|
def inspect(read,executable,packet_layout=None):
|
|
report={'kind':'read-only-engine-session-metadata','engine_calls_made':False,
|
|
'authentication_buffers_read':False,'engine_world_entry_proven':False}
|
|
if ENABLE_MAP_AREA_DESCRIPTOR_LOOKUP:
|
|
report['original_map_area_descriptors']=inspect_map_area_descriptors(read,executable)
|
|
if ENABLE_MAP_AREA_TYPED_METHOD_LOOKUP:
|
|
report['original_map_area_typed_methods']=inspect_map_area_typed_methods(read,executable)
|
|
if ENABLE_MAP_AREA_SCHEMA_LOOKUP:
|
|
report['original_map_area_schemas']=inspect_map_area_schemas(read)
|
|
if ENABLE_MAP1_RECORD_CACHE_HEADER_LOOKUP:
|
|
report['original_Map1_materialized_cache_header']=inspect_map1_materialized_cache_header(read)
|
|
# The installed image's GetCharacterSelection registration anchors this
|
|
# fixed glue-API table. Inspect immutable names/function identities only.
|
|
# No Lua state, arguments, account buffers or callbacks are touched.
|
|
glue={}
|
|
for row in range(0x145759000,0x14575a130,16):
|
|
try:
|
|
name,callback=struct.unpack('<QQ',read(row,16))
|
|
if not 0x144a00000<=name<0x145700000 or not BASE<=callback<0x144a00000:continue
|
|
label=read(name,64).split(b'\0',1)[0]
|
|
if label not in (b'EnterWorld',b'EnterWorldRPE',b'GetCharacterSelection'):continue
|
|
glue[label.decode()]=dict(registration=hex(row),callback=hex(callback),executable=executable(callback,1))
|
|
except (OSError,ValueError,struct.error):pass
|
|
if glue:report['glue_world_callbacks']=glue
|
|
report['generated_enter_world']={'callback':'0x141343000','executable':executable(0x141343000,1)}
|
|
try:
|
|
# Fixed public race/class availability vector used by140208974..9f7.
|
|
pointer,count,capacity=struct.unpack('<QQQ',read(0x147c67110,24))
|
|
if count>32 or count>(capacity&0x7fffffffffffffff):raise ValueError('Public race availability bound')
|
|
races=[]
|
|
for index in range(count):
|
|
row=pointer+index*32;race=read(row,1)[0]
|
|
classes,n,cap=struct.unpack('<QQQ',read(row+8,24))
|
|
if not 1<=race<=32 or n>16 or n>(cap&0x7fffffffffffffff):raise ValueError('Public class availability bound')
|
|
raw=read(classes,n*4) if n else b''
|
|
races.append(dict(race=race,classes=[list(raw[i:i+4]) for i in range(0,len(raw),4)]))
|
|
report['login_race_class_availability']=races
|
|
except (OSError,ValueError,struct.error):pass
|
|
# Original same-realm callback plus fixed public purchase-crash code pages.
|
|
# Read only pages already executable; never activate protected/cold code,
|
|
# invoke a callback or capture closure/account/session data.
|
|
report['world_login_callback_code']=[]
|
|
for page in (0x1423fb000,0x140818000,0x140819000,0x1408e8000,0x144631000,0x144633000):
|
|
try:
|
|
if not executable(page,4096):continue
|
|
code=b''.join(read(page+at,512) for at in range(0,4096,512))
|
|
if read(page,32)!=code[:32]:continue
|
|
import hashlib
|
|
from pathlib import Path
|
|
path=Path(__file__).resolve().parents[1]/'runtime/native-handler-code'/f'{page:x}.bin'
|
|
if path.exists() and path.read_bytes()!=code:continue
|
|
if not path.exists():path.write_bytes(code);path.chmod(0o600)
|
|
report['world_login_callback_code'].append(dict(page=hex(page),sha256=hashlib.sha256(code).hexdigest()))
|
|
except (OSError,ValueError,struct.error):pass
|
|
try:
|
|
head=read(REGISTRY,24)
|
|
pointer,count,capacity=struct.unpack('<QQQ',head)
|
|
if count>64 or count>(capacity&0x7fffffffffffffff):raise ValueError('Registry bounds')
|
|
rows=read(pointer,count*8) if count else b''
|
|
callbacks=[]
|
|
for index in range(count):
|
|
descriptor=struct.unpack_from('<Q',rows,index*8)[0]
|
|
functions={'index':index}
|
|
for offset,label in SLOTS:
|
|
address=struct.unpack('<Q',read(descriptor+offset,8))[0]
|
|
# Export only addresses within the pinned image, never arbitrary
|
|
# heap pointers. An image address is NOT a callable ABI proof.
|
|
in_image=BASE<=address<BASE+0x5000000
|
|
functions[label]=hex(address) if in_image else None
|
|
functions[label+'_kind']=('client-code' if in_image and executable(address,1) else
|
|
'null' if not address else 'other-executable' if executable(address,1) else
|
|
'client-not-executable' if BASE<=address<BASE+0x5000000 else 'unclassified')
|
|
callbacks.append(functions)
|
|
if read(REGISTRY,24)!=head:raise ValueError('Registry changed during read')
|
|
report['registry']={'stable':True,'count':count,'callbacks':callbacks}
|
|
except (OSError,ValueError,struct.error):
|
|
report['registry']={'stable':False,'reason':'unavailable-or-changing'}
|
|
try:
|
|
original=read(NETCLIENT,8);pointer=struct.unpack('<Q',original)[0]
|
|
if not pointer:report['netclient']={'present':False}
|
|
else:
|
|
state=struct.unpack('<I',read(pointer+0x98,4))[0]
|
|
connections=struct.unpack('<QQQQ',read(pointer+0x1a0,32))
|
|
if state>32 or read(NETCLIENT,8)!=original:raise ValueError('NetClient changed')
|
|
report['netclient']={'present':True,'state_enum':state,
|
|
'connection_slots_present':[bool(p) for p in connections]}
|
|
try:
|
|
report['netclient']['selected_virtual_realm']=hex(struct.unpack('<I',read(pointer+0x898,4))[0])
|
|
report['netclient']['realm_change_pending']=bool(read(pointer+0xc4a,1)[0])
|
|
except (OSError,ValueError,struct.error):pass
|
|
vtable=struct.unpack('<Q',read(pointer,8))[0]
|
|
original_vtable=vtable
|
|
try:
|
|
host=struct.unpack('<6I3Q',read(vtable-56,48))
|
|
if host[:2]==(1,1080) and host[6]==pointer and BASE+0x47c2000<=host[7]<BASE+0x5663024:
|
|
original_vtable=host[7]
|
|
report['netclient']['poll_host']={'stage':host[2],'calls':host[3],'windows_thread':host[4],'error':host[5]}
|
|
if packet_layout:
|
|
receive_callback=struct.unpack('<Q',read(vtable+0x30,8))[0]
|
|
module=receive_callback-packet_layout['gw_packet_receive_callback']
|
|
if read(module,2)==b'MZ':
|
|
packet=struct.unpack('<12IQ',read(module+packet_layout['gw_packet_host_data'],56))
|
|
if packet[:2]==(1,16440):
|
|
report['netclient']['packet_host']={'ready':packet[2],'ack':packet[3],'server_proof_verified':packet[4]==1,'bytes':packet[5],'submitted':packet[6],'received':packet[7],'opcode':hex(packet[8]),'state_at_receive':packet[9],'error':packet[10],
|
|
'self_create_consumed':bool(packet[11]&2),'active_mover_consumed':bool(packet[11]&1),
|
|
'original_receiver':hex(packet[12]) if packet[12]==0x141e47960 else None,'original_receiver_executable':packet[12]==0x141e47960 and executable(packet[12],1)}
|
|
# Optional ABI-1 metadata-only history from the
|
|
# matching bridge; the owner limits reads to 512 bytes.
|
|
history_rva=packet_layout.get('gw_packet_header_history')
|
|
if type(history_rva) is int and 0<history_rva<0x20000:
|
|
try:
|
|
address=module+history_rva
|
|
before=read(address,32)
|
|
abi,size,capacity,reserved,total,roster=struct.unpack('<4I2Q',before)
|
|
if (abi,size,capacity,reserved)!=(1,1056,128,0):raise ValueError('History ABI mismatch')
|
|
slots=struct.unpack('<128Q',read(address+32,512)+read(address+544,512))
|
|
if read(address,32)!=before:raise ValueError('History changed during read')
|
|
report['netclient']['packet_host']['history']={'available':True,'total':total,'roster_dispatches':roster,
|
|
'headers':[{'slot':i,'opcode':hex(value&0xffffffff),'bytes':value>>32} for i,value in enumerate(slots) if i<min(total,128)],
|
|
'note':'Slot order is not necessarily callback order; read after callbacks quiesce.'}
|
|
except (OSError,ValueError,struct.error):
|
|
report['netclient']['packet_host']['history']={'available':False,'reason':'unavailable-or-changing'}
|
|
except (OSError,ValueError,struct.error):pass
|
|
# Only the source-traced ClientConnection subtype has these fields.
|
|
# No keys, account names, endpoint buffers or socket handles read.
|
|
if original_vtable==0x144efa998:
|
|
try:
|
|
import importlib,engine_channel_state
|
|
inspect_channels=importlib.reload(engine_channel_state).inspect
|
|
report['netclient']['channels']=inspect_channels(read,pointer)
|
|
except (OSError,ValueError,struct.error):
|
|
report['netclient']['channels']={'available':False,'reason':'unavailable-or-changing'}
|
|
# The verified 14224df60 parser copies AuthResponse's
|
|
# AvailableClasses field to +0x838. Its destination layout is
|
|
# not fully identified, so report only whether its 24-byte
|
|
# header is zero; never export pointers or row bytes.
|
|
report['netclient']['auth_available_classes_field']=auth_classes_field(read,pointer+0x838)
|
|
report['netclient']['auth_state_receiver']=auth_state_receiver(read,executable,pointer)
|
|
report['netclient']['auth_service_callback']=auth_service_callback(read,executable)
|
|
lifecycle={}
|
|
listener=None
|
|
try:
|
|
listener=struct.unpack('<Q',read(pointer+0x220,8))[0]
|
|
lifecycle['transport_listener_present']=bool(listener)
|
|
if listener:
|
|
table,owner=struct.unpack('<QQ',read(listener,16))
|
|
lifecycle['transport_listener_vtable']=hex(table) if table==0x144e5a748 else None
|
|
lifecycle['transport_listener_owner_matches']=owner==pointer
|
|
except (OSError,ValueError,struct.error):lifecycle['transport_listener_present']=None
|
|
for offset,label in ((0x7e8,'world_auth_response_accepted'),(0xc49,'connected_callback_marker'),(0xca0,'character_list_consumer_marker')):
|
|
try:
|
|
value=read(pointer+offset,1)[0]
|
|
lifecycle[label]=bool(value) if value<=1 else None
|
|
except (OSError,ValueError,IndexError):lifecycle[label]=None
|
|
try:
|
|
lifecycle['character_list_pending']=bool(struct.unpack('<Q',read(pointer+0xc90,8))[0])
|
|
readiness=struct.unpack('<Q',read(pointer+0xca8,8))[0]
|
|
lifecycle['character_list_readiness_callback']=hex(readiness) if BASE<=readiness<BASE+0x47c145c else None
|
|
lifecycle['character_list_readiness_callback_present']=bool(readiness)
|
|
except (OSError,ValueError,struct.error):lifecycle['character_list_pending']=None
|
|
# Source-traced readiness predicate0x140225b00 reads these
|
|
# flags/null tests. Report conditions only; never invoke its
|
|
# side effects or follow the two global object pointers.
|
|
try:
|
|
flags=[read(address,1)[0] for address in (0x145700079,0x145ffa559,0x145e6e976,0x145e720f8,0x1456ad44d)]
|
|
if any(value>1 for value in flags):raise ValueError('Readiness flag outside boolean range')
|
|
nulls=[not struct.unpack('<Q',read(address,8))[0] for address in (0x146004ea8,0x1457139c0)]
|
|
phase=struct.unpack('<I',read(0x145ead210,4))[0]
|
|
conditions={'flag_145700079_clear':not flags[0],'flag_145ffa559_set':bool(flags[1]),
|
|
'object_146004ea8_absent':nulls[0],'object_1457139c0_absent':nulls[1],
|
|
'flag_145e6e976_set':bool(flags[2]),'phase_145ead210':phase if phase<=2 else None,
|
|
'phase_ready_flag_145e720f8':bool(flags[3]),'poll_gate_1456ad44d_clear':not flags[4]}
|
|
conditions['predicate_conditions_satisfied']=bool(not flags[0] and flags[1] and all(nulls) and flags[2] and phase in (1,2) and flags[3]) if phase<=2 else None
|
|
lifecycle['character_list_readiness_conditions']=conditions
|
|
except (OSError,ValueError,struct.error,IndexError):lifecycle['character_list_readiness_conditions']={'available':False}
|
|
methods={}
|
|
for offset,label in ((0x38,'connected'),(0x40,'disconnected'),(0x48,'connection_failed')):
|
|
try:
|
|
address=struct.unpack('<Q',read(vtable+offset,8))[0]
|
|
methods[label]=hex(address) if BASE<=address<BASE+0x47c145c else None
|
|
except (OSError,ValueError,struct.error):methods[label]=None
|
|
lifecycle['event_handlers']=methods
|
|
transports=[]
|
|
for index,connection in enumerate(connections):
|
|
row={'slot':index,'present':bool(connection)}
|
|
if connection:
|
|
try:
|
|
transport_vtable=struct.unpack('<Q',read(connection,8))[0]
|
|
row['vtable']=hex(transport_vtable) if BASE+0x47c2000<=transport_vtable<BASE+0x5663024 else None
|
|
row['kind']='tcp' if transport_vtable==0x1450396b0 else 'unverified'
|
|
if row['kind']=='tcp':
|
|
observer=struct.unpack('<Q',read(connection+0x28,8))[0]
|
|
row['listener_matches']=bool(listener and observer==listener)
|
|
socket=struct.unpack('<Q',read(connection+0x18,8))[0]
|
|
row['socket_present']=bool(socket)
|
|
if socket:
|
|
value=struct.unpack('<I',read(socket+0x20,4))[0]
|
|
row['socket_state']=value if value<=9 else None
|
|
# Recheck ownership after following its one
|
|
# fixed state field; a changing slot is not
|
|
# a stable transport observation.
|
|
if read(connection+0x18,8)!=struct.pack('<Q',socket):raise ValueError('Socket changed')
|
|
except (OSError,ValueError,struct.error):row={'slot':index,'present':True,'stable':False}
|
|
transports.append(row)
|
|
if read(pointer+0x1a0,32)==struct.pack('<QQQQ',*connections):
|
|
lifecycle['transports']=transports
|
|
report['netclient']['lifecycle']=lifecycle
|
|
receive=struct.unpack('<Q',read(vtable+0x30,8))[0]
|
|
report['netclient']['queued_receive_handler']=hex(receive) if BASE<=receive<BASE+0x5000000 else None
|
|
report['netclient']['queued_receive_executable']=bool(BASE<=receive<BASE+0x5000000 and executable(receive,1))
|
|
methods={}
|
|
for offset,label in ((0x58,'auth_response'),(0x78,'character_enumeration')):
|
|
address=struct.unpack('<Q',read(vtable+offset,8))[0]
|
|
methods[label]={'address':hex(address) if BASE<=address<BASE+0x5000000 else None,
|
|
'executable':bool(BASE<=address<BASE+0x5000000 and executable(address,1))}
|
|
report['netclient']['packet_handler_methods']=methods
|
|
queue=struct.unpack('<Q',read(pointer+0xa0,8))[0]
|
|
if queue:
|
|
owner=struct.unpack('<Q',read(queue,8))[0]
|
|
report['netclient']['event_queue_present']=True
|
|
report['netclient']['event_queue_owner_matches']=owner==pointer
|
|
else:report['netclient']['event_queue_present']=False
|
|
except (OSError,ValueError,struct.error):
|
|
report['netclient']={'present':None,'reason':'unavailable-or-changing'}
|
|
# Observed jump table of the actual0x470000-family decoder. Fixed public
|
|
# code RVAs only, not general-purpose process-memory access.
|
|
targets={}
|
|
for opcode in (0x470001,0x470018,0x470064,0x4700f8,0x470171,0x470172,
|
|
0x47017f,0x4701f5,0x470212):
|
|
try:
|
|
rva=struct.unpack('<I',read(BASE+0x8efb78+4*(opcode-0x470000),4))[0]
|
|
targets[hex(opcode)]=hex(BASE+rva) if 0<rva<0x5000000 else None
|
|
except (OSError,ValueError,struct.error):targets[hex(opcode)]=None
|
|
report['core_decoder_cases']=targets
|
|
handlers={}
|
|
for label,address in (('auth_response',0x145e70a58),('character_enumeration',0x145e709b8),('world_auth_data_provider',0x147c64de0),('resume_comms',0x145e70518),('db_reply',0x145e71090),('available_hotfixes',0x145e71098),('hotfix_request_serializer',0x144d15bd0),('death_release_location',0x145e6fb60),('corpse_location',0x145e6fef0)):
|
|
try:
|
|
callback=struct.unpack('<Q',read(address,8))[0]
|
|
handlers[label]={'address':hex(callback) if BASE<=callback<BASE+0x5000000 else None,
|
|
'executable':bool(BASE<=callback<BASE+0x5000000 and executable(callback,1))}
|
|
if label in('death_release_location','corpse_location'):handlers[label]['present']=bool(callback)
|
|
except (OSError,ValueError,struct.error):handlers[label]={'address':None,'executable':False}
|
|
report['typed_packet_handlers']=handlers
|
|
report['corpse_state']=corpse_state(read)
|
|
report['local_player_corpse_gate']=local_player_corpse_gate(read,report['corpse_state'])
|
|
if ENABLE_CORPSE_CODE_REFERENCE_SCAN:
|
|
report['corpse_range_code_references']=corpse_range_code_references(read,executable)
|
|
cases={}
|
|
for index in range(0x360,0x365):
|
|
try:
|
|
offset=struct.unpack('<I',read(BASE+0x8efb78+index*4,4))[0]
|
|
if not 0x1000<=offset<0x47c145c:raise ValueError('Fixed decoder case outside image')
|
|
cases[hex(0x470000+index)]=hex(BASE+offset)
|
|
except (OSError,ValueError,struct.error):cases[hex(0x470000+index)]=None
|
|
report['collection_decoder_candidates']=cases
|
|
collection_handlers={}
|
|
for label,address in (('opcode470361',0x145e6ed40),('opcode470363',0x145e6ed18)):
|
|
try:
|
|
value=struct.unpack('<Q',read(address,8))[0]
|
|
collection_handlers[label]=hex(value) if BASE<=value<BASE+0x47c145c else None
|
|
except (OSError,ValueError,struct.error):collection_handlers[label]=None
|
|
report['collection_typed_handlers']=collection_handlers
|
|
code_checks=[]
|
|
for address,encoded in ((0x141e46a80,'405657415441554883ec68'),(0x1445b7db0,'48895c2408574883ec2041833800'),(0x14452a5d0,'48895c241048896c2418')):
|
|
signature=bytes.fromhex(encoded)
|
|
try:code_checks.append(dict(address=hex(address),executable=executable(address,len(signature)),identity_matches=read(address,len(signature))==signature))
|
|
except (OSError,ValueError,struct.error):code_checks.append(dict(address=hex(address),available=False))
|
|
report['channel_policy_code_contracts']=code_checks
|
|
return report
|