"""Locate current map UI activity callback/label strings in the original PE, read-only."""
import json
from pathlib import Path
import pefile
image=Path('artifacts/ship-model-reference/client-copy/EliteDangerous64.exe')
pe=pefile.PE(str(image),fast_load=True)
needles=['OnPowerActivityPowerChange','OnPowerActivityTypeChanged','OnMinPowerActivityToggled','OnActivityValueChange','OnPowerSelectAny','FilterActivities','powerID','reinforcing','undermining','acquiring','contesting']
rows=[]
for section in pe.sections:
raw=section.get_data()
for value in needles:
encoded=value.encode('ascii')+b'\0';start=0
while (start:=raw.find(encoded,start))>=0:
rows.append(dict(text=value,rva=hex(section.VirtualAddress+start)));start+=len(encoded)
out=Path('artifacts/galaxy-query-research/power-activities');out.mkdir(exist_ok=True)
(out/'strings.json').write_text(json.dumps(rows,indent=2),encoding='utf-8')
print(json.dumps(rows,indent=2))
"""Locate current map UI activity callback/label strings in the original PE, read-only."""
import json
from pathlib import Path
import pefile
image=Path('artifacts/ship-model-reference/client-copy/EliteDangerous64.exe')
pe=pefile.PE(str(image),fast_load=True)
needles=['OnPowerActivityPowerChange','OnPowerActivityTypeChanged','OnMinPowerActivityToggled','OnActivityValueChange','OnPowerSelectAny','FilterActivities','powerID','reinforcing','undermining','acquiring','contesting']
rows=[]
for section in pe.sections:
raw=section.get_data()
for value in needles:
encoded=value.encode('ascii')+b'\0';start=0
while (start:=raw.find(encoded,start))>=0:
rows.append(dict(text=value,rva=hex(section.VirtualAddress+start)));start+=len(encoded)
out=Path('artifacts/galaxy-query-research/power-activities');out.mkdir(exist_ok=True)
(out/'strings.json').write_text(json.dumps(rows,indent=2),encoding='utf-8')
print(json.dumps(rows,indent=2))