mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
fix(ea): bind activation licences to the CPUID of the game's own bitness
The machine hash of activation versions 2 and 3 includes CPUID leaf 1 ECX, and FEX reports AVX to 64-bit (ARM64EC) processes but not to 32-bit (WOW64) ones. The hardware probe only ran a 32-bit CPUID program, so 64-bit games rejected their licence and looped through ActivationUI. The probe now runs CPUID in both bitnesses, the game gets the values its exe sees, and the cache is retaken when the Proton or FEX build changes.
This commit is contained in:
1 parent
1f70d43fe2
commit
2702ba2db8
3 files changed
+234
-37
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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("<I", buf)
|
||||
rva = 0x1000
|
||||
if wide:
|
||||
base, thunk, optional, names, dll, buf, written = 0x140000000, 8, 0xF0, (0x168, 0x178, 0x184), 0x192, 0x1A0, 0x1F0
|
||||
else:
|
||||
base, thunk, optional, names, dll, buf, written = 0x400000, 4, 0xE0, (0x148, 0x158, 0x164), 0x172, 0x180, 0x1D0
|
||||
ilt, iat = 0x128, 0x128 + 4 * thunk
|
||||
code = bytearray()
|
||||
|
||||
def rip(op, target):
|
||||
code.extend(op + struct.pack("<i", target - len(code) - len(op) - 4))
|
||||
|
||||
if wide:
|
||||
code += b"\x53\x57\x48\x83\xec\x38"
|
||||
rip(b"\x48\x8d\x3d", buf)
|
||||
else:
|
||||
code += b"\x53\x57\xbf" + struct.pack("<I", base + rva + buf)
|
||||
for leaf in CPUID_LEAVES:
|
||||
code += b"\xb8" + struct.pack("<I", leaf) + b"\x31\xc9\x0f\xa2\x89\x07\x89\x5f\x04\x89\x4f\x08\x89\x57\x0c\x83\xc7\x10"
|
||||
code += b"\x6a\xf5\xff\x15" + struct.pack("<I", iat)
|
||||
code += b"\x6a\x00\x68" + struct.pack("<I", written) + b"\x6a\x50\x68" + struct.pack("<I", buf) + b"\x50\xff\x15" + struct.pack("<I", iat + 4)
|
||||
code += b"\x6a\x00\xff\x15" + struct.pack("<I", iat + 8)
|
||||
code += b"\xb8" + struct.pack("<I", leaf) + b"\x31\xc9\x0f\xa2\x89\x07\x89\x5f\x04\x89\x4f\x08\x89\x57\x0c"
|
||||
code += b"\x48\x83\xc7\x10" if wide else b"\x83\xc7\x10"
|
||||
if wide:
|
||||
code += b"\xb9\xf5\xff\xff\xff"
|
||||
rip(b"\xff\x15", iat)
|
||||
code += b"\x48\x89\xc1"
|
||||
rip(b"\x48\x8d\x15", buf)
|
||||
code += b"\x41\xb8\x50\x00\x00\x00"
|
||||
rip(b"\x4c\x8d\x0d", written)
|
||||
code += b"\x48\xc7\x44\x24\x20\x00\x00\x00\x00"
|
||||
rip(b"\xff\x15", iat + 8)
|
||||
code += b"\x31\xc9"
|
||||
rip(b"\xff\x15", iat + 16)
|
||||
else:
|
||||
at = base + rva
|
||||
code += b"\x6a\xf5\xff\x15" + struct.pack("<I", at + iat)
|
||||
code += b"\x6a\x00\x68" + struct.pack("<I", at + written) + b"\x6a\x50\x68" + struct.pack("<I", at + buf)
|
||||
code += b"\x50\xff\x15" + struct.pack("<I", at + iat + 4) + b"\x6a\x00\xff\x15" + struct.pack("<I", at + iat + 8)
|
||||
section = bytearray(0x200)
|
||||
section[:len(code)] = code
|
||||
names = [(0x148, b"GetStdHandle"), (0x158, b"WriteFile"), (0x164, b"ExitProcess")]
|
||||
struct.pack_into("<IIIII", section, 0x100, rva + 0x128, 0, 0, rva + 0x172, rva + 0x138)
|
||||
for i, (at, name) in enumerate(names):
|
||||
struct.pack_into("<I", section, 0x128 + 4 * i, rva + at)
|
||||
struct.pack_into("<I", section, 0x138 + 4 * i, rva + at)
|
||||
struct.pack_into("<IIIII", section, 0x100, rva + ilt, 0, 0, rva + dll, rva + iat)
|
||||
entry = "<Q" if wide else "<I"
|
||||
for i, (at, name) in enumerate(zip(names, (b"GetStdHandle", b"WriteFile", b"ExitProcess"))):
|
||||
struct.pack_into(entry, section, ilt + thunk * i, rva + at)
|
||||
struct.pack_into(entry, section, iat + thunk * i, rva + at)
|
||||
section[at + 2:at + 2 + len(name)] = name
|
||||
section[0x172:0x172 + 12] = b"KERNEL32.dll"
|
||||
section[dll:dll + 12] = b"KERNEL32.dll"
|
||||
header = bytearray(0x200)
|
||||
header[0:2] = b"MZ"
|
||||
struct.pack_into("<I", header, 0x3C, 0x40)
|
||||
header[0x40:0x44] = b"PE\0\0"
|
||||
struct.pack_into("<HHIIIHH", header, 0x44, 0x14C, 1, 0, 0, 0, 0xE0, 0x0103)
|
||||
opt = struct.pack("<HBBIIIIIIIIIHHHHHHIIIIHHIIIIII", 0x10B, 0, 0, 0x200, 0, 0, rva, rva, rva, base, 0x1000, 0x200,
|
||||
4, 0, 0, 0, 4, 0, 0, 0x2000, 0x200, 0, 3, 0, 0x100000, 0x1000, 0x100000, 0x1000, 0, 16)
|
||||
struct.pack_into("<HHIIIHH", header, 0x44, 0x8664 if wide else 0x14C, 1, 0, 0, 0, optional, 0x0023 if wide else 0x0103)
|
||||
if wide:
|
||||
opt = struct.pack("<HBBIIIIIQIIHHHHHHIIIIHHQQQQII", 0x20B, 0, 0, 0x200, 0, 0, rva, rva, base, 0x1000, 0x200,
|
||||
5, 2, 0, 0, 5, 2, 0, 0x2000, 0x200, 0, 3, 0, 0x100000, 0x1000, 0x100000, 0x1000, 0, 16)
|
||||
else:
|
||||
opt = struct.pack("<HBBIIIIIIIIIHHHHHHIIIIHHIIIIII", 0x10B, 0, 0, 0x200, 0, 0, rva, rva, rva, base, 0x1000, 0x200,
|
||||
4, 0, 0, 0, 4, 0, 0, 0x2000, 0x200, 0, 3, 0, 0x100000, 0x1000, 0x100000, 0x1000, 0, 16)
|
||||
dirs = bytearray(128)
|
||||
struct.pack_into("<II", dirs, 8, rva + 0x100, 40)
|
||||
struct.pack_into("<II", dirs, 96, rva + 0x138, 16)
|
||||
header[0x58:0x58 + 0xE0] = opt + bytes(dirs)
|
||||
header[0x138:0x138 + 40] = struct.pack("<8sIIIIIIHHI", b".text", 0x1000, rva, 0x200, 0x200, 0, 0, 0, 0, 0xE0000060)
|
||||
struct.pack_into("<II", dirs, 96, rva + iat, 4 * thunk)
|
||||
header[0x58:0x58 + optional] = opt + bytes(dirs)
|
||||
header[0x58 + optional:0x58 + optional + 40] = struct.pack("<8sIIIIIIHHI", b".text", 0x1000, rva, 0x200, 0x200, 0, 0, 0, 0, 0xE0000060)
|
||||
return bytes(header) + bytes(section)
|
||||
|
||||
|
||||
@@ -1315,20 +1345,60 @@ EA_PROBE_FIELDS = ("boardManufacturer", "biosManufacturer", "osInstallDate", "os
|
||||
"cpuVendor", "cpuEax", "cpuEdx", "cpuEcx")
|
||||
|
||||
|
||||
EA_CPU64 = "cpu64"
|
||||
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 runtime_stamp(proton):
|
||||
if not proton or not Path(proton).is_file():
|
||||
return ""
|
||||
root = Path(proton).parent
|
||||
parts = []
|
||||
for name in EA_RUNTIME_FILES:
|
||||
try:
|
||||
parts.append(name + " " + hashlib.sha256((root / name).read_bytes()).hexdigest())
|
||||
except OSError:
|
||||
parts.append(name + " -")
|
||||
return hashlib.sha256("\n".join(parts).encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
def read_cpuid(path):
|
||||
try:
|
||||
return cpuid_values(path.read_bytes())
|
||||
except OSError:
|
||||
return {}
|
||||
|
||||
|
||||
def ea_game_hardware(values, folder, sidecar):
|
||||
chosen = {key: value for key, value in values.items() if key not in (EA_CPU64, EA_RUNTIME)}
|
||||
wide = values.get(EA_CPU64)
|
||||
exe = find_case(folder, str(sidecar.get("exe") or ""))
|
||||
if isinstance(wide, dict) and exe is not None and exe.is_file():
|
||||
pe = runpy.run_path(str(Path(__file__).resolve().parent / "droiddeck-wine-pe"))
|
||||
if pe["pe_machine"](str(exe)) == 0x8664:
|
||||
chosen.update(wide)
|
||||
return chosen
|
||||
|
||||
|
||||
def ea_hardware(compat_data, proton, timeout=240):
|
||||
pfx = Path(compat_data) / "pfx"
|
||||
cache = pfx / EA_HARDWARE
|
||||
runtime = runtime_stamp(proton)
|
||||
stale = {}
|
||||
try:
|
||||
cached = json.loads(cache.read_text())
|
||||
if isinstance(cached, dict) and probe_complete(cached):
|
||||
return cached, "cached"
|
||||
if not runtime or cached.get(EA_RUNTIME) == runtime:
|
||||
return cached, "cached"
|
||||
stale = cached
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
if not proton or not Path(proton).is_file():
|
||||
if not runtime:
|
||||
return {}, "no-proton"
|
||||
values = {}
|
||||
with tempfile.TemporaryDirectory(prefix="droiddeck-ea-") as tmp:
|
||||
@@ -1338,17 +1408,18 @@ def ea_hardware(compat_data, proton, timeout=240):
|
||||
lines.append('wmic path %s get %s > "%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)))
|
||||
|
||||
@@ -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('<H', exe, 0x58)[0] == 0x20B
|
||||
base = struct.unpack_from('<Q', exe, 0x58 + 24)[0] if wide else struct.unpack_from('<I', exe, 0x58 + 28)[0]
|
||||
dirs = 0x58 + struct.unpack_from('<H', exe, 0x54)[0] - 128
|
||||
raw = lambda rva: 0x200 + rva - 0x1000
|
||||
ilt, _, _, dll, iat = struct.unpack_from('<IIIII', exe, raw(struct.unpack_from('<I', exe, dirs + 8)[0]))
|
||||
thunk = 8 if wide else 4
|
||||
slots = {}
|
||||
for i in range(3):
|
||||
hint = struct.unpack_from('<Q' if wide else '<I', exe, raw(iat) + thunk * i)[0]
|
||||
if hint != struct.unpack_from('<Q' if wide else '<I', exe, raw(ilt) + thunk * i)[0]:
|
||||
return None
|
||||
slots[iat + thunk * i] = exe[raw(hint) + 2:].split(b'\0')[0]
|
||||
code = exe[0x200:0x300]
|
||||
called = []
|
||||
for at in range(len(code) - 6):
|
||||
if code[at:at + 2] == b'\xff\x15':
|
||||
value = struct.unpack_from('<i' if wide else '<I', code, at + 2)[0]
|
||||
called.append(slots.get(0x1000 + at + 6 + value if wide else value - base))
|
||||
return exe[raw(dll):].split(b'\0')[0], called
|
||||
|
||||
|
||||
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'
|
||||
@@ -100,6 +124,105 @@ class EaHook(unittest.TestCase):
|
||||
self.assertEqual(struct.unpack_from('<H', exe, 0x58 + 68)[0], 3)
|
||||
self.assertIn(b'KERNEL32.dll', exe)
|
||||
self.assertEqual(len(exe), 0x400)
|
||||
self.assertEqual(called_imports(exe), (b'KERNEL32.dll', [b'GetStdHandle', b'WriteFile', b'ExitProcess']))
|
||||
|
||||
def test_cpuid_probe_has_a_64_bit_form_that_writes_the_same_leaves(self):
|
||||
exe = store.cpuid_exe(True)
|
||||
self.assertEqual(exe[:2], b'MZ')
|
||||
self.assertEqual(struct.unpack_from('<H', exe, 0x44)[0], 0x8664)
|
||||
self.assertEqual(struct.unpack_from('<H', exe, 0x58)[0], 0x20B)
|
||||
self.assertEqual(struct.unpack_from('<H', exe, 0x58 + 68)[0], 3)
|
||||
self.assertEqual(len(exe), 0x400)
|
||||
self.assertEqual(called_imports(exe), (b'KERNEL32.dll', [b'GetStdHandle', b'WriteFile', b'ExitProcess']))
|
||||
code = exe[0x200:0x300]
|
||||
self.assertEqual(code.count(b'\x0f\xa2'), len(store.CPUID_LEAVES))
|
||||
loads = {}
|
||||
for at in range(len(code) - 7):
|
||||
if code[at:at + 3] in (b'\x48\x8d\x3d', b'\x48\x8d\x15', b'\x4c\x8d\x0d'):
|
||||
loads[code[at:at + 3]] = at + 7 + struct.unpack_from('<i', code, at + 3)[0]
|
||||
self.assertEqual(loads[b'\x48\x8d\x3d'], loads[b'\x48\x8d\x15'])
|
||||
self.assertGreaterEqual(loads[b'\x4c\x8d\x0d'], loads[b'\x48\x8d\x15'] + 16 * len(store.CPUID_LEAVES))
|
||||
self.assertLessEqual(loads[b'\x4c\x8d\x0d'] + 4, 0x200)
|
||||
self.assertFalse(any(exe[0x200 + loads[b'\x48\x8d\x15']:0x200 + loads[b'\x4c\x8d\x0d'] + 4]))
|
||||
self.assertEqual(store.cpuid_exe(False), store.cpuid_exe())
|
||||
|
||||
def test_each_game_is_sent_the_cpuid_of_its_own_bitness(self):
|
||||
narrow = {'cpuVendor': 'GenuineIntel', 'cpuEax': '000A0661', 'cpuEdx': '278BFBFF', 'cpuEcx': '82d8230f', 'cpuBrand': 'Cortex-A520'}
|
||||
probe = dict({key: 'x' for key in store.EA_PROBE_FIELDS}, **narrow)
|
||||
values = dict(probe, cpu64=dict(narrow, cpuEcx='bed8330f'), runtime='stamp')
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
folder = Path(tmp)
|
||||
(folder / 'Game64.exe').write_bytes(store.cpuid_exe(True))
|
||||
(folder / 'bin').mkdir()
|
||||
(folder / 'bin/Game32.exe').write_bytes(store.cpuid_exe())
|
||||
self.assertEqual(store.ea_game_hardware(values, folder, {'exe': 'game64.exe'}), dict(probe, cpuEcx='bed8330f'))
|
||||
self.assertEqual(store.ea_game_hardware(values, folder, {'exe': 'bin/Game32.exe'}), probe)
|
||||
self.assertEqual(store.ea_game_hardware(values, folder, {'exe': 'Missing.exe'}), probe)
|
||||
self.assertEqual(store.ea_game_hardware(values, folder, {}), probe)
|
||||
self.assertEqual(store.ea_game_hardware(probe, folder, {'exe': 'Game64.exe'}), probe)
|
||||
|
||||
def test_a_probe_from_another_proton_or_fex_build_is_taken_again(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proton = Path(tmp) / 'tool/proton'
|
||||
fex = proton.parent / 'files/lib/wine/aarch64-windows/libwow64fex.dll'
|
||||
fex.parent.mkdir(parents=True)
|
||||
proton.write_text('')
|
||||
(proton.parent / 'version').write_text('1 experimental-11.0')
|
||||
fex.write_bytes(b'fex 1')
|
||||
runtime = store.runtime_stamp(str(proton))
|
||||
self.assertTrue(runtime)
|
||||
self.assertEqual(store.runtime_stamp(str(proton)), runtime)
|
||||
self.assertEqual(store.runtime_stamp(''), '')
|
||||
compat = Path(tmp) / 'compat'
|
||||
(compat / 'pfx').mkdir(parents=True)
|
||||
cached = dict({key: 'x' for key in store.EA_PROBE_FIELDS}, runtime=runtime)
|
||||
(compat / 'pfx' / store.EA_HARDWARE).write_text(json.dumps(cached))
|
||||
with patch.object(store.subprocess, 'run', side_effect=AssertionError('probed again')):
|
||||
self.assertEqual(store.ea_hardware(str(compat), str(proton)), (cached, 'cached'))
|
||||
self.assertEqual(store.ea_hardware(str(compat), ''), (cached, 'cached'))
|
||||
fex.write_bytes(b'fex 2')
|
||||
self.assertNotEqual(store.runtime_stamp(str(proton)), runtime)
|
||||
with patch.object(store.subprocess, 'run', side_effect=OSError) as run:
|
||||
self.assertEqual(store.ea_hardware(str(compat), str(proton)), (cached, 'failed'))
|
||||
run.assert_called_once()
|
||||
(proton.parent / 'version').write_text('2 experimental-11.0')
|
||||
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):
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user