From 6346b5ebdfddb5ef5058be86acf882cd32af1517 Mon Sep 17 00:00:00 2001 From: The412Banner <205237651+The412Banner@users.noreply.github.com> Date: Sun, 22 Nov 2026 15:29:17 +0000 Subject: [PATCH] fix(ea): retake the hardware probe when its 64-bit CPUID run fails --- docs/development/ea-store.md | 5 +- .../usr/local/bin/droiddeck-store-launch | 11 +-- tools/tests/test_store_launch_ea.py | 74 +++++++++++++------ 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/docs/development/ea-store.md b/docs/development/ea-store.md index 0a0e9b0e13..bfdbccd050 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`, 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, 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; a probe that times out, fails or misses a value keeps the older complete cache), 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. | @@ -22,7 +22,8 @@ The licence names a hash of the machine the game's activation layer computes its 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 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. +so the game is sent the CPUID its own exe's bitness sees. A cache from before the 64-bit probe has +only the 32-bit values, and every game gets those until a probe with Proton found succeeds. ## 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 ed37fa5889..bc8aaed774 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch @@ -1341,8 +1341,9 @@ def cpuid_values(raw): "cpuEcx": "%08x" % regs[1][2], "cpuBrand": brand} -EA_PROBE_FIELDS = ("boardManufacturer", "biosManufacturer", "osInstallDate", "osSerial", "volumeSerial", "hostname", - "cpuVendor", "cpuEax", "cpuEdx", "cpuEcx") +EA_CPU_FIELDS = ("cpuVendor", "cpuEax", "cpuEdx", "cpuEcx") +EA_PROBE_FIELDS = ("boardManufacturer", "biosManufacturer", "osInstallDate", "osSerial", "volumeSerial", + "hostname") + EA_CPU_FIELDS EA_CPU64 = "cpu64" @@ -1350,8 +1351,8 @@ EA_RUNTIME = "runtime" EA_RUNTIME_FILES = ("version", "files/lib/wine/aarch64-windows/libarm64ecfex.dll", "files/lib/wine/aarch64-windows/libwow64fex.dll") -def probe_complete(values): - return all(str(values.get(key) or "").strip() for key in EA_PROBE_FIELDS) +def probe_complete(values, fields=EA_PROBE_FIELDS): + return all(str(values.get(key) or "").strip() for key in fields) def runtime_stamp(proton): @@ -1438,7 +1439,7 @@ def ea_hardware(compat_data, proton, timeout=240): wide = read_cpuid(folder / "cpuid64.bin") if wide: values[EA_CPU64] = wide - if probe_complete(values): + if probe_complete(values) and probe_complete(values.get(EA_CPU64, {}), EA_CPU_FIELDS): values[EA_RUNTIME] = runtime try: cache.write_text(json.dumps(values)) diff --git a/tools/tests/test_store_launch_ea.py b/tools/tests/test_store_launch_ea.py index 88e401f242..28859706a9 100644 --- a/tools/tests/test_store_launch_ea.py +++ b/tools/tests/test_store_launch_ea.py @@ -38,6 +38,31 @@ def called_imports(exe): return exe[raw(dll):].split(b'\0')[0], called +PROBE_NARROW = bytes.fromhex('1600000047656e756e74656c696e654961060a00000805000f23d882fffb8b27436f727465782d4135323000000000000000000000000000000000000000000000000000000000000000000000000000') +PROBE_WIDE = bytearray(PROBE_NARROW) +PROBE_WIDE[16 + 8:16 + 12] = bytes.fromhex('0f33d8be') + + +def fake_probe(wide): + def run(argv, **kwargs): + bat = Path(argv[-1][2:].replace('\\', '/')) + for line in bat.read_text().splitlines(): + found = re.search(r'"?([^"]*)"? > "([^"]*)"$', line) + if not found: + continue + source, out = found.group(1), Path(found.group(2)[2:].replace('\\', '/')) + if source.endswith('cpuid64.exe'): + if wide is not None: + out.write_bytes(wide) + elif source.endswith('cpuid.exe'): + out.write_bytes(PROBE_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') + return run + + class EaHook(unittest.TestCase): def test_wmi_output_reads_the_value_under_the_header(self): text = 'Manufacturer \r\r\nThe Wine Project \r\r\n\r\r\n' @@ -189,33 +214,13 @@ class EaHook(unittest.TestCase): self.assertNotEqual(store.runtime_stamp(str(proton)), runtime) def test_the_probe_records_both_bitnesses_and_the_runtime(self): - narrow = bytes.fromhex('1600000047656e756e74656c696e654961060a00000805000f23d882fffb8b27436f727465782d4135323000000000000000000000000000000000000000000000000000000000000000000000000000') - wide = bytearray(narrow) - wide[16 + 8:16 + 12] = bytes.fromhex('0f33d8be') with tempfile.TemporaryDirectory() as tmp: proton = Path(tmp) / 'tool/proton' proton.parent.mkdir() proton.write_text('') compat = Path(tmp) / 'compat' (compat / 'pfx').mkdir(parents=True) - - def fake_run(argv, **kwargs): - bat = Path(argv[-1][2:].replace('\\', '/')) - for line in bat.read_text().splitlines(): - found = re.search(r'"?([^"]*)"? > "([^"]*)"$', 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): + with patch.object(store.subprocess, 'run', side_effect=fake_probe(bytes(PROBE_WIDE))): values, how = store.ea_hardware(str(compat), str(proton)) self.assertEqual(how, 'probed') self.assertEqual(values['cpuEcx'], '82d8230f') @@ -224,6 +229,33 @@ class EaHook(unittest.TestCase): self.assertEqual(values['runtime'], store.runtime_stamp(str(proton))) self.assertEqual(json.loads((compat / 'pfx' / store.EA_HARDWARE).read_text()), values) + def test_a_failed_64_bit_probe_keeps_the_old_cache_and_is_retried(self): + with tempfile.TemporaryDirectory() as tmp: + proton = Path(tmp) / 'tool/proton' + proton.parent.mkdir() + proton.write_text('') + compat = Path(tmp) / 'compat' + (compat / 'pfx').mkdir(parents=True) + cache = compat / 'pfx' / store.EA_HARDWARE + for wide in (None, PROBE_NARROW[:40]): + with patch.object(store.subprocess, 'run', side_effect=fake_probe(wide)): + values, how = store.ea_hardware(str(compat), str(proton)) + self.assertEqual(how, 'incomplete') + self.assertEqual(values['cpuEcx'], '82d8230f') + self.assertNotIn('cpu64', values) + self.assertNotIn('runtime', values) + self.assertFalse(cache.exists()) + stale = dict({key: 'x' for key in store.EA_PROBE_FIELDS}, cpu64={'cpuEcx': 'bed8330f'}, runtime='old') + cache.write_text(json.dumps(stale)) + with patch.object(store.subprocess, 'run', side_effect=fake_probe(None)): + self.assertEqual(store.ea_hardware(str(compat), str(proton)), (stale, 'incomplete')) + self.assertEqual(json.loads(cache.read_text()), stale) + with patch.object(store.subprocess, 'run', side_effect=fake_probe(bytes(PROBE_WIDE))): + values, how = store.ea_hardware(str(compat), str(proton)) + self.assertEqual(how, 'probed') + self.assertEqual(values['cpu64']['cpuEcx'], 'bed8330f') + self.assertEqual(json.loads(cache.read_text()), values) + def test_origin_stub_is_a_windowless_program_installed_once(self): import struct exe = store.origin_stub_exe()