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

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
"""Verify the actual constellation style and shared world-line submission, offline."""
from pathlib import Path
import hashlib,json,struct
import pefile
from capstone import Cs,CS_ARCH_X86,CS_MODE_64
from capstone.x86_const import X86_OP_IMM

root=Path('artifacts/galaxy-query-research')
image=Path('artifacts/ship-model-reference/client-copy/EliteDangerous64.exe').read_bytes()
expected='6891f70a021fa9f3a0e00458c284f48d1226e68ae7fc02ad48081aed47857e93'
if hashlib.sha256(image).hexdigest()!=expected:raise ValueError('Original image changed')
pe=pefile.PE(data=image,fast_load=True);base=pe.OPTIONAL_HEADER.ImageBase
pe.parse_data_directories(directories=[pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_EXCEPTION']])
decoder=Cs(CS_ARCH_X86,CS_MODE_64);decoder.detail=True
functions=[]
for rva in (0x3A06740,0x3C05B20,0x3A75150,0x3A1CED0,0x3A20A10,0x3C11750):
    entry=next(e.struct for e in pe.DIRECTORY_ENTRY_EXCEPTION if e.struct.BeginAddress==rva)
    code=pe.get_data(rva,entry.EndAddress-rva)
    calls=[i.operands[0].imm-base for i in decoder.disasm(code,base+rva)
        if i.mnemonic=='call' and i.operands[0].type==X86_OP_IMM]
    functions.append(dict(rva=hex(rva),bytes=len(code),codeSha256=hashlib.sha256(code).hexdigest(),directCalls=[hex(c) for c in calls]))
    if rva==0x3A1CED0 and 0x3A20A10 not in calls:raise ValueError('Constellation callback changed')
    if rva==0x3A20A10 and 0x3C11750 not in calls:raise ValueError('Shared line writer changed')
slots=[]
for slot,target in ((0x130,0x3A75150),(0x138,0x3A1CED0)):
    actual=struct.unpack('<Q',pe.get_data(0x551F408+slot,8))[0]-base
    if actual!=target:raise ValueError('Actual renderer+58 callback changed')
    slots.append(dict(interfaceOffset='0x58',vtableRva='0x551f408',slot=hex(slot),targetRva=hex(target)))
scope={};exec(Path('research/Extract-OriginalGalaxyAppearance.py').read_text().split('# Federation row')[0],scope)
b=scope['b'];at=scope['at'];refs=scope['references'];cfg=(295,14000)
if hashlib.sha256(b).hexdigest()!='5135b3d55e5239b3d11f79a76adeda954eb78be5101b6a516fd25df257affa77':raise ValueError('Original configuration changed')
pointer=refs[cfg[0],cfg[1]+0x190];count=struct.unpack_from('<I',b,at(cfg)+0x198)[0]
styles=[]
for index in range(count):
    start=at((pointer[0],pointer[1]+index*52));raw=b[start:start+52]
    if raw[0]==6:styles.append(raw)
if len(styles)!=1:raise ValueError('Constellation style6 not unique')
raw=styles[0];rgba=list(struct.unpack_from('<4f',raw,4));repeat,width=struct.unpack_from('<2f',raw,20)
pattern=raw[48];divisor=b[at(cfg)+0x1a8]
if rgba!=[1,1,1,1] or repeat!=2.5 or width!=struct.unpack('<f',bytes.fromhex('cdcccc3d'))[0] or (pattern,divisor)!=(0,8):
    raise ValueError('Original constellation world style changed')
# The original constructor copies 48 bytes after the type byte/padding into
# renderer+420+type*30h. Type6 is therefore precisely renderer+540.
constructor=root/'palette-resources/decompiled/solo-3a06740.c'
text=constructor.read_text()
if 'lVar20 = (ulonglong)*pbVar22 * 3 + 0x42;' not in text or 'pbVar22 = pbVar22 + 0x34' not in text:
    raise ValueError('Style-vector copy no longer matches the pinned constructor')
sources=[constructor,*[root/('constellations/decompiled/solo-'+rva+'.c')
    for rva in ('3a1cf60','3c05b20','3a75150','3a1ced0','3a20a10')],
    root/'power-outer-sources/grid/solo-3c11750.c']
result=dict(imageSha256=expected,gameProcessAccess=False,gameCalls=0,functions=functions,interfaceSlots=slots,
    configuration=dict(pool=cfg[0],offset=cfg[1],frozenSha256=hashlib.sha256(b).hexdigest(),
        field='0x190',styleCount=count,stylePointer=pointer,styleIndex=6,styleRaw=raw.hex()),
    rendererStyleOffset='0x540',rgba=rgba,groupAlphaReplacesSourceAlpha=True,
    worldHalfWidth=width,halfFields=[10,.1,width,10],pattern=[pattern,divisor,repeat,0],
    viewportObject='renderer.viewport[index]+0x40',viewportSlot=8,recordBytes=64,
    material='sectorline_nodepth',shaderClass='StarMapLine',
    sources=[dict(path=str(p).replace('\\','/'),sha256=hashlib.sha256(p.read_bytes()).hexdigest()) for p in sources],
    remainingLimits=['Original native catalogue LOD boundary (current finite4D policy is explicit tool fallback)','Shared RGB/final HDR output',
        'Runtime material scalar binding and sampler quality','Live catalogue readiness and visual comparison'])
target=root/'constellations/original-constellation-material.json'
target.write_text(json.dumps(result,indent=2)+'\n')
print(json.dumps(dict(style=result['configuration'],worldHalfWidth=width,pattern=result['pattern']),indent=2))