diff --git a/docs/development/ea-store.md b/docs/development/ea-store.md index 89a345c80f..0a0e9b0e13 100644 --- a/docs/development/ea-store.md +++ b/docs/development/ea-store.md @@ -12,7 +12,7 @@ EA games install, update and start without the EA app. The research behind it is | Queries | `app/src/main/resources/ea/graphql/*.gql` | EA's own query texts, byte for byte. The gateway matches persisted queries by SHA-256, so these files must not be reformatted (`-text` in `.gitattributes`). | | Downloads | Rust `src/ea/` in `libdroiddeckstores.so`, `EaInstaller.kt` | A build is one ZIP on EA's CDN. The engine reads its central directory with ranged reads, keeps files whose size and CRC match, and streams every other entry through inflate into place. `.droiddeck-ea-files` records what it placed, so a resume or update does not re-hash those files; files a new build drops are removed. | | Updates | `EaUpdates` in `EaBackend.kt` | The game page compares the installed version with the offer's live `gameVersion` (every 30 minutes at most). Update runs the same install, which only fetches changed files. | -| Launch, guest | `droiddeck-store-launch` (`prepare_ea`) | Creates the prefix, reads the machine as Wine reports it (`wmic`, `vol`, `hostname`; cached in `pfx/.droiddeck-ea-hw.json`), writes EA app presence keys and the game's `Install Dir` keys in both registry views, runs the build's Touchup once per installed build, then asks the app for the session and writes any licence files. | +| Launch, guest | `droiddeck-store-launch` (`prepare_ea`) | Creates the prefix, reads the machine as Wine reports it (`wmic`, `vol`, `hostname`, CPUID from a 32-bit and a 64-bit probe; cached in `pfx/.droiddeck-ea-hw.json` until the Proton version or its FEX libraries change), writes EA app presence keys and the game's `Install Dir` keys in both registry views, runs the build's Touchup once per installed build, then asks the app for the session and writes any licence files. | | Launch, app | `EaLaunch.kt`, `EaOoa.kt`, `EaLsx.kt` | Answers `ea-prepare`: starts the LSX endpoint on `127.0.0.1:3216`, mints the short-lived opaque token, writes `.droiddeck-ea-env` (read once and deleted by the launcher `.bat`), and for games with a `Core` folder requests an online-activation licence for the machine hash. | | LSX | `EaLsx.kt` | The local endpoint EA's SDK talks to instead of the EA app: challenge, AES session key, config, profile, settings, game info, auth codes for the game's own client ids, licences with Denuvo tokens, entitlements. Friends, presence and the overlay answer empty. | @@ -20,8 +20,9 @@ EA games install, update and start without the EA app. The research behind it is The licence names a hash of the machine the game's activation layer computes itself. The hash version follows the activation library's product version (`Core/activation.dll` or `awc.dll`): -5.x → 4, 4.7.6+ → 3, 4.7.x → 2, 4.x → 1. Versions 2 and 3 also need CPUID leaf 1 ECX, which Wine's -WMI does not expose, so those use `00000000` unless the probe learns it. +5.x → 4, 4.7.6+ → 3, 4.7.x → 2, 4.x → 1. Versions 2 and 3 also hash CPUID leaf 1 ECX, which FEX +reports differently to 32-bit (WOW64) and 64-bit (ARM64EC) processes when their AVX support differs, +so the game is sent the CPUID its own exe's bitness sees. ## Not done yet diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch b/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch index 76bdb395f0..ed37fa5889 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch @@ -1227,39 +1227,69 @@ def wmi_value(text): CPUID_LEAVES = (0, 1, 0x80000002, 0x80000003, 0x80000004) -def cpuid_exe(): - """A 32-bit console program that writes the raw CPUID leaves an x86 game sees under the emulator.""" +def cpuid_exe(wide=False): + """A console program that writes the raw CPUID leaves an x86 game sees under the emulator: 32-bit, or 64-bit when wide.""" import struct - base, rva = 0x400000, 0x1000 - buf, written = base + rva + 0x180, base + rva + 0x1D0 - iat = base + rva + 0x138 - code = b"\x53\x57\xbf" + struct.pack(" "%s"' % (cls, prop, windows_path(str(folder / (key + ".txt"))))) lines.append('vol C: > "%s"' % windows_path(str(folder / "volume.txt"))) lines.append('hostname > "%s"' % windows_path(str(folder / "hostname.txt"))) - (folder / "cpuid.exe").write_bytes(cpuid_exe()) - lines.append('"%s" > "%s"' % (windows_path(str(folder / "cpuid.exe")), windows_path(str(folder / "cpuid.bin")))) + for name, wide in (("cpuid", False), ("cpuid64", True)): + (folder / (name + ".exe")).write_bytes(cpuid_exe(wide)) + lines.append('"%s" > "%s"' % (windows_path(str(folder / (name + ".exe"))), windows_path(str(folder / (name + ".bin"))))) bat = folder / "probe.bat" bat.write_bytes(("\r\n".join(lines) + "\r\n").encode()) try: subprocess.run([proton, "run", "cmd.exe", "/d", "/c", windows_path(str(bat))], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=timeout) except subprocess.TimeoutExpired: - return {}, "timeout" + return stale, "timeout" except OSError: - return {}, "failed" + return stale, "failed" for key, _, _ in EA_WMI: try: values[key] = wmi_value(decode_output((folder / (key + ".txt")).read_bytes())) @@ -1363,17 +1434,18 @@ def ea_hardware(compat_data, proton, timeout=240): values["hostname"] = decode_output((folder / "hostname.txt").read_bytes()).strip().splitlines()[0].strip() except (OSError, IndexError): values["hostname"] = "" - try: - values.update(cpuid_values((folder / "cpuid.bin").read_bytes())) - except OSError: - pass + values.update(read_cpuid(folder / "cpuid.bin")) + wide = read_cpuid(folder / "cpuid64.bin") + if wide: + values[EA_CPU64] = wide if probe_complete(values): + values[EA_RUNTIME] = runtime try: cache.write_text(json.dumps(values)) except OSError: pass return values, "probed" - return values, "incomplete" + return stale or values, "incomplete" def ea_registry_entries(folder, sidecar): @@ -1522,7 +1594,8 @@ def prepare_ea(folder, sidecar, compat_data, launch_dir): hardware, probe = ea_hardware(compat_data, proton) if ready else ({}, "no-prefix") answer = None if launch_dir: - answer = ask(Path(launch_dir) / "stores", {"op": "ea-prepare", "store": "ea", "id": game, "hardware": hardware}, timeout=40.0) + answer = ask(Path(launch_dir) / "stores", {"op": "ea-prepare", "store": "ea", "id": game, + "hardware": ea_game_hardware(hardware, folder, sidecar)}, timeout=40.0) sidecar = sidecar_at(Path(folder)) or sidecar log("ea %s prefix=%s stub=%s hardware=%s registry=%s touchup=%s" % ( game, made, stub, probe, ea_registry(folder, sidecar, compat_data, proton), ea_touchup(folder, sidecar, compat_data, proton))) diff --git a/tools/tests/test_store_launch_ea.py b/tools/tests/test_store_launch_ea.py index 1dd912f0ab..88e401f242 100644 --- a/tools/tests/test_store_launch_ea.py +++ b/tools/tests/test_store_launch_ea.py @@ -3,6 +3,8 @@ import importlib.machinery import importlib.util import json from pathlib import Path +import re +import struct import tempfile import unittest from unittest.mock import patch @@ -14,6 +16,28 @@ store = importlib.util.module_from_spec(spec) loader.exec_module(store) +def called_imports(exe): + wide = struct.unpack_from(' "([^"]*)"$', line) + if not found: + continue + source, out = found.group(1), Path(found.group(2)[2:].replace('\\', '/')) + if source.endswith('cpuid64.exe'): + out.write_bytes(bytes(wide)) + elif source.endswith('cpuid.exe'): + out.write_bytes(narrow) + elif source.startswith('vol'): + out.write_text(' Volume Serial Number is 1A2B-3C4D\r\n') + else: + out.write_text('Header\r\nvalue\r\n') + + with patch.object(store.subprocess, 'run', side_effect=fake_run): + values, how = store.ea_hardware(str(compat), str(proton)) + self.assertEqual(how, 'probed') + self.assertEqual(values['cpuEcx'], '82d8230f') + self.assertEqual(values['cpu64']['cpuEcx'], 'bed8330f') + self.assertEqual(values['volumeSerial'], '1a2b3c4d') + self.assertEqual(values['runtime'], store.runtime_stamp(str(proton))) + self.assertEqual(json.loads((compat / 'pfx' / store.EA_HARDWARE).read_text()), values) def test_origin_stub_is_a_windowless_program_installed_once(self): import struct