XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
"""Probe the original local frozen-pool table boundaries, offline only."""
import json
import struct
from pathlib import Path

out=Path('artifacts/galaxy-query-research/palette-resources')
key='86ec03fba621526059fc6812faca6f10adcb63cb'
f=(out/(key+'.fres')).read_bytes();b=(out/(key+'.indexed1')).read_bytes()
pool_count=struct.unpack_from('<I',f,0x34)[0]
buffer_count=struct.unpack_from('<I',f,0x38)[0]-struct.unpack_from('<I',f,0x40)[0]
root_count=struct.unpack_from('<I',f,0x20)[0]
cursor=0;tags=[];total=0
while total<pool_count:
    kind,count=struct.unpack_from('<HH',b,cursor);cursor+=4;total+=count;tags.append((kind,count))
if total!=pool_count:raise ValueError('Unrecognised pool grouping')
pool_table=cursor
pools=[dict(size=struct.unpack_from('<I',b,cursor+i*32+8)[0],offset=struct.unpack_from('<I',b,cursor+i*32+12)[0]) for i in range(pool_count)]
cursor+=pool_count*32;buffer_table=cursor
buffers=[struct.unpack_from('<IIHHIQQ',b,cursor+i*32) for i in range(buffer_count)]
cursor+=buffer_count*32
buffer_entries=sum(row[3] for row in buffers);cursor+=buffer_entries*8
root_table=cursor
roots=[struct.unpack_from('<IIII',b,cursor+i*16) for i in range(root_count)]
cursor+=root_count*16;reference_table=cursor
references=[]
while cursor+16<=len(b):
    source,source_offset,target,target_offset=struct.unpack_from('<IIII',b,cursor)
    if source>=pool_count or target>=pool_count or source_offset>=pools[source]['size'] or target_offset>=pools[target]['size']:break
    references.append((source,source_offset,target,target_offset));cursor+=16
result=dict(poolCount=pool_count,tags=tags,poolTable=pool_table,bufferCount=buffer_count,bufferTable=buffer_table,
    bufferEntries=buffer_entries,rootCount=root_count,rootTable=root_table,rootFirst=roots[:5],rootLast=roots[-5:],
    referenceTable=reference_table,parsedReferences=len(references),firstReferences=references[:4],
    dataStartCandidate=cursor,atCandidate=b[cursor:cursor+64].hex(),poolBytes=sum(row['size'] for row in pools),remaining=len(b)-cursor)
(out/'frozen-layout-probe.json').write_text(json.dumps(result,indent=2),encoding='utf-8')
print(json.dumps(result,indent=2))