mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
* feat(xbox): stage the PlayFab Game Saves save-folder proxy from the Nexus runtime Xbox titles that use PlayFab Game Saves, such as Forza Horizon 6, stop with "Initialization Failed" E:0-17 right after sign-in. The SDK's default provider needs Gaming Runtime save APIs that xgameruntime does not have, and its in-process provider needs a save folder the title never passes on Windows. xodus-nexus already builds a proxy for this into the runtime archive we pin (scripts/runtime-compat, MIT): it keeps the title's SDK as nexus_pgs_native.dll, sets ForceUseInprocGameSaves and passes the PersistentLocalStorage PlayFabGameSaves folder. runtime.py now takes it and its license from the archive, checked against runtime.lock.json, and droiddeck-xbox stages it before each launch when the game's PlayFabGameSave.dll has exactly the SDK's 40 exports. A game update that brings a new SDK replaces the kept copy; anything unknown is left alone. Unlike Nexus, no DLL override is set for the two DLLs: Wine has no builtin of either, and forcing them native-only made Forza Horizon 6 fail with E:0-0-4. * fix(xbox): check the whole PlayFab export table and never overwrite an unknown kept SDK The SDK and proxy checks now also require the export address table to hold exactly 40 functions, so a DLL with the same names plus an ordinal-only export is no longer taken for the SDK. Before copying a new SDK to nexus_pgs_native.dll, an existing file there must itself be a regular file holding the SDK; an unknown file or a link is left as it is.
72 lines
3.1 KiB
Python
Executable File
72 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
import tarfile
|
|
import urllib.request
|
|
|
|
recipe = Path(__file__).resolve().parent
|
|
lock = json.loads((recipe / 'runtime.lock.json').read_text())
|
|
cache = Path(sys.argv[1]); output = Path(sys.argv[2])
|
|
cache.mkdir(parents=True, exist_ok=True)
|
|
output.mkdir(parents=True, exist_ok=True)
|
|
url = 'https://github.com/' + lock['repository'] + '/releases/download/' + lock['tag'] + '/'
|
|
|
|
def download(name, expected, algorithm):
|
|
target = cache / name
|
|
def matches():
|
|
if not target.is_file():
|
|
return False
|
|
digest = hashlib.new(algorithm)
|
|
with target.open('rb') as file:
|
|
for block in iter(lambda: file.read(1024 * 1024), b''):
|
|
digest.update(block)
|
|
return digest.hexdigest() == expected
|
|
if not matches():
|
|
part = target.with_suffix(target.suffix + '.part')
|
|
with urllib.request.urlopen(url + name, timeout=90) as response, part.open('wb') as file:
|
|
shutil.copyfileobj(response, file)
|
|
part.replace(target)
|
|
if not matches():
|
|
raise RuntimeError('Xbox runtime checksum mismatch: ' + name)
|
|
return target
|
|
|
|
archive = download(lock['archive'], lock['sha512'], 'sha512')
|
|
source = lock['source']
|
|
download(source['name'], source['sha256'], 'sha256')
|
|
remaining = set(lock['dlls'])
|
|
# Prebuilt runtime-compat files from the same archive (MIT), placed next to windows/ in the pack: the
|
|
# PlayFab Game Saves save-folder proxy that droiddeck-xbox stages in front of a title's SDK, and its license.
|
|
compat = dict(lock.get('compat', {}))
|
|
with tarfile.open(archive) as tar:
|
|
for member in tar:
|
|
relative = member.name.partition('/')[2]
|
|
if relative in compat:
|
|
target, expected = compat.pop(relative)
|
|
if not member.isfile() or member.size > 32 * 1024 * 1024:
|
|
raise RuntimeError('Invalid Xbox runtime compatibility file')
|
|
data = tar.extractfile(member).read()
|
|
if hashlib.sha256(data).hexdigest() != expected:
|
|
raise RuntimeError('Xbox runtime compatibility file checksum mismatch')
|
|
(output.parent / target).parent.mkdir(parents=True, exist_ok=True)
|
|
(output.parent / target).write_bytes(data)
|
|
continue
|
|
name = Path(member.name).name
|
|
if '/files/lib/wine/x86_64-windows/' not in member.name or name not in remaining:
|
|
continue
|
|
if not member.isfile() or member.size > 32 * 1024 * 1024:
|
|
raise RuntimeError('Invalid Xbox Windows runtime module')
|
|
data = tar.extractfile(member).read()
|
|
if hashlib.sha256(data).hexdigest() != lock['dlls'][name] or data[:2] != b'MZ':
|
|
raise RuntimeError('Xbox Windows runtime module checksum mismatch')
|
|
if data[64:80] == b'Wine builtin DLL':
|
|
data = data[:64] + b'DroidDeck native' + data[80:]
|
|
(output / name).write_bytes(data)
|
|
remaining.remove(name)
|
|
if remaining:
|
|
raise RuntimeError('Missing Xbox runtime modules')
|
|
if compat:
|
|
raise RuntimeError('Missing Xbox runtime compatibility files')
|