Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.
HTML apple-siliconbattle-netcrossover-alternatived3dmetaldiablo-ii-resurrecteddxmtea-appepic-gamesgame-porting-toolkitgogmac-gamingmacosmacos-gamingrockstar-gamessteamubisoft-connectwhisky-alternativewindows-gameswinewine-wrapper
Xbox PC: Retro Classics reaches its menu (#67)
Mikekeef8756c0fe9
diff --git a/NOTICE b/NOTICEindex 2e045fbd124..a0043eb0d67 100644--- a/NOTICE+++ b/NOTICE@@ -25,6 +25,11 @@ Built or downloaded by the scripts (open-source component releases include correpinned commit in resources/xodus-backend.json; the patched source stays in build/xodus-src.- MACxus / Xodus Nexus backend patches: MIT, github.com/fladnaG86/MACxus (pinned commit,SHA-256 per patch); downloaded at build time, not stored in this repository.+- Xbox game runtime (xgameruntime.dll and companions): Wine 11.0 / Xodus Nexus runtime, LGPL-2.1+,+ github.com/domsvoboda/xodus-nexus. Five DLLs come unchanged from MACxus' release image and the Nexus+ runtime; xgameruntime.dll is Soju's build of the Nexus source with the two MACxus runtime patches and+ patches/xgameruntime-store-empty-strings.patch (LGPL-2.1+ to match). scripts/build-xbox-runtime.sh+ rebuilds it from the pinned inputs in resources/xbox-runtime.json.Trademarks: Xbox is a trademark of Microsoft Corporation. Battle.net and Diablo are trademarks of Blizzard Entertainment.Steam is a trademark of Valve Corporation. This project is not affiliated withdiff --git a/README.ko.md b/README.ko.mdindex 779602d36b6..71adec60828 100644--- a/README.ko.md+++ b/README.ko.md@@ -147,7 +147,7 @@ scripts/play.sh gog-kill # GOG 보틀 종료 (창을 닫으면 메뉴## Xbox PC / Microsoft Store (Xodus 백엔드, 실험 기능)-Microsoft 계정으로 로그인해 보유 게임과 PC Game Pass 게임을 가져오고, Microsoft Store를 검색하고, 게임을 내려받고 실행할 수 있습니다. **게임 실행은 실험 기능이며 Soju에서 실제 게임으로는 아직 확인하지 않았습니다.** 실행 방식은 맥에서 여러 게임이 실행된 MACxus와 같습니다. 실행하려면 CX 엔진과 Apple GPTK가 필요합니다. Xbox PC를 설정하면 엔진이 설치되고, GPTK는 Battle.net·Epic·GOG처럼 Platforms에서 추가합니다.+Microsoft 계정으로 로그인해 보유 게임과 PC Game Pass 게임을 가져오고, Microsoft Store를 검색하고, 게임을 내려받고 실행할 수 있습니다. **게임 실행은 실험 기능입니다.** M4 Pro·macOS 26.5에서 Retro Classics가 메인 화면까지 실행되는 것을 확인했고, 다른 게임은 아직 확인하지 않았습니다. 게임별 Wine 설정은 `resources/xbox-compat.json`에 있습니다. 실행 방식은 맥에서 여러 게임이 실행된 MACxus와 같습니다. 실행하려면 CX 엔진과 Apple GPTK가 필요합니다. Xbox PC를 설정하면 엔진이 설치되고, GPTK는 Battle.net·Epic·GOG처럼 Platforms에서 추가합니다.실행 방식: `xodus-cli run`이 라이선스를 받아 게임을 임시 RAM 디스크에 풀고, `scripts/xbox-wine.sh`가 전용 보틀(`xbox-bottle`)에서 CX 엔진과 D3DMetal로 실행합니다. 이 보틀에는 Xbox 게임 런타임 DLL(xgameruntime 등, LGPL, `resources/xbox-runtime.json`에 고정, 처음 한 번 약 600MB)과 Microsoft VC++ 런타임이 들어갑니다. 게임 중에는 `xodus-service`가 로그인·라이선스·클라우드 저장을 맡고, 게임이 쓴 파일은 끝날 때 게임 폴더로 복사됩니다. Library의 **Stop**으로 게임을 닫으면 저장 파일을 먼저 복사합니다.diff --git a/README.md b/README.mdindex ffa4fbe0718..48cf8e9790b 100644--- a/README.md+++ b/README.md@@ -11,7 +11,7 @@ Sign in to **Steam** to import your owned library, or import theowned library cached by **GOG GALAXY**. Installed and uninstalled games share thesame library, with availability filters and official-client install actions.**Discover** searches Steam, GOG and Microsoft Store listings and prices, with links to buy from the stores.-**Xbox PC (experimental):** sign in to a Microsoft account to import owned and PC Game Pass games, download them through the [Xodus](https://github.com/xodus-gaming/xodus) backend and start them on Soju's engine. Game launch has not been verified with a game on Soju yet. Purchases, downloads and updates stay with the official stores.+**Xbox PC (experimental):** sign in to a Microsoft account to import owned and PC Game Pass games, download them through the [Xodus](https://github.com/xodus-gaming/xodus) backend and start them on Soju's engine. Retro Classics reaches its main menu on Soju; other games are untested. Purchases, downloads and updates stay with the official stores.Epic and Battle.net account imports are not included yet. Compatibility varies by game.@@ -54,7 +54,7 @@ All verified on an M4 Pro running macOS 26.5. Separate bottles for each launcher| Epic Games Launcher | ✅ | ✅ | parks in the menu bar tray on close || GOG GALAXY | ✅ | ✅ | login + library; games not broadly tested yet || Steam (Windows client) | ✅ | ✅ | private Wine 11 + DXMT bottle |-| Xbox PC / Microsoft Store | ✅ | ✅ | Xodus backend; game launch experimental, not yet verified with a game |+| Xbox PC / Microsoft Store | ✅ | ✅ | Xodus backend; game launch experimental (Retro Classics reaches its menu) || Game | Store | Graphics | Status | Notes || --- | --- | --- | :-: | --- |@@ -167,7 +167,7 @@ Games have not been broadly tested yet; anything that needs kernel anti-cheat (E## Xbox PC / Microsoft Store (Xodus backend, experimental)-Soju can sign in to a Microsoft account, import owned and PC Game Pass games, search the Microsoft Store, download games and start them. **Starting games is experimental and has not been verified with a game on Soju yet.** The launch follows the path [MACxus](https://github.com/fladnaG86/MACxus) uses on macOS, where Vampire Survivors, TUNIC, Deep Rock Galactic and others reach gameplay on a CrossOver 26 based engine like Soju's.+Soju can sign in to a Microsoft account, import owned and PC Game Pass games, search the Microsoft Store, download games and start them. **Starting games is experimental.** On an M4 Pro / macOS 26.5, Retro Classics reaches its main menu; other titles are untested. Per-game Wine settings live in `resources/xbox-compat.json`. The launch follows the path [MACxus](https://github.com/fladnaG86/MACxus) uses on macOS, where Vampire Survivors, TUNIC, Deep Rock Galactic and others reach gameplay on a CrossOver 26 based engine like Soju's.How a launch works: `xodus-cli run` gets the licence and decrypts the game into a temporary RAM-disk view; `scripts/xbox-wine.sh` starts it on the CX engine with D3DMetal in its own prefix (`xbox-bottle`). That prefix gets the Xbox game runtime DLLs (xgameruntime and friends, LGPL, from the Xodus Nexus runtime as MACxus rebuilt them for macOS; pinned in `resources/xbox-runtime.json`, about 600 MB downloaded once) and Microsoft's VC++ runtime. `xodus-service` runs during the session for sign-in, licences and cloud saves; the game reaches it through a keyed 127.0.0.1 bridge. Files the game writes are copied back into its folder when it exits. Playing needs the CX engine and Apple GPTK; setting up Xbox PC installs the engine, and GPTK is added in Platforms like for Battle.net, Epic and GOG.diff --git a/README.zh.md b/README.zh.mdindex 6b9fddce96f..04cac5018a2 100644--- a/README.zh.md+++ b/README.zh.md@@ -150,7 +150,7 @@ scripts/play.sh gog-kill # 停止 GOG bottle(关窗口会缩到菜单## Xbox PC / Microsoft Store(Xodus 后端,实验功能)-可以登录 Microsoft 账户,导入已拥有的游戏和 PC Game Pass 游戏,搜索 Microsoft Store 并下载游戏。也可以启动下载好的游戏(实验功能,尚未在 Soju 上用实际游戏验证)。启动需要 CX 引擎和 Apple GPTK:设置 Xbox PC 时会安装引擎,GPTK 与 Battle.net、Epic、GOG 一样在 Platforms 中添加。+可以登录 Microsoft 账户,导入已拥有的游戏和 PC Game Pass 游戏,搜索 Microsoft Store 并下载游戏。也可以启动下载好的游戏(实验功能:在 M4 Pro / macOS 26.5 上已确认 Retro Classics 能进入主菜单,其他游戏尚未测试;按游戏的 Wine 设置在 `resources/xbox-compat.json`)。启动需要 CX 引擎和 Apple GPTK:设置 Xbox PC 时会安装引擎,GPTK 与 Battle.net、Epic、GOG 一样在 Platforms 中添加。启动流程:`xodus-cli run` 获取许可证并把游戏解密到临时 RAM 盘,`scripts/xbox-wine.sh` 在独立前缀(`xbox-bottle`)中用 CX 引擎和 D3DMetal 运行。该前缀包含 Xbox 游戏运行时 DLL(xgameruntime 等,LGPL,固定在 `resources/xbox-runtime.json`,首次下载约 600 MB)和 Microsoft VC++ 运行库。游戏期间 `xodus-service` 负责登录、许可证和云存档,游戏写入的文件在退出时复制回游戏目录。在 Library 中点 **Stop** 关闭游戏时会先复制存档。diff --git a/patches/xgameruntime-store-empty-strings.patch b/patches/xgameruntime-store-empty-strings.patchnew file mode 100644index 00000000000..f263907e5dc--- /dev/null+++ b/patches/xgameruntime-store-empty-strings.patch@@ -0,0 +1,35 @@+--- a/dlls/xgameruntime/xstore_entitled.h 2026-11-01 20:47:52++++ b/dlls/xgameruntime/xstore_entitled.h 2026-11-01 20:47:52+@@ -469,6 +469,24 @@+ IXThreadingImpl_Release(threading); return hr;+ }+++/* Windows hands out products without NULL strings, and games copy these fields++ * unchecked (Retro Classics reads linkUri/currencyCode right after enumerating++ * and crashes on NULL). Fill what the snapshot does not carry with "". */++static const char entitled_empty[] = "";++static void entitled_fill_strings( XStoreProduct *p )++{++ UINT32 j;++ if (!p->linkUri) p->linkUri = (char *)entitled_empty;++ if (!p->price.currencyCode) p->price.currencyCode = entitled_empty;++ for (j = 0; j < p->skusCount; j++)++ {++ XStoreSku *s = &p->skus[j];++ if (!s->price.currencyCode) s->price.currencyCode = entitled_empty;++ if (!s->collectionData.campaignId) s->collectionData.campaignId = entitled_empty;++ if (!s->collectionData.developerOfferId) s->collectionData.developerOfferId = entitled_empty;++ }++}+++ static HRESULT entitled_enumerate( XStoreProductQueryHandle handle, void *arg, XStoreProductQueryCallback *callback )+ {+ struct entitled_page *page;+@@ -480,6 +498,7 @@+ for (i = page->offset; i < end; i++)+ {+ TRACE( " product %s kind %#x inCollection %d\n", debugstr_a( page->snapshot->products[i].storeId ), page->snapshot->products[i].productKind, page->snapshot->products[i].isInUserCollection );++ entitled_fill_strings(&page->snapshot->products[i]);+ if (!callback(&page->snapshot->products[i], arg)) break;+ }+ entitled_page_release(page); return S_OK;diff --git a/resources/xbox-compat.json b/resources/xbox-compat.jsonnew file mode 100644index 00000000000..03ea79c0095--- /dev/null+++ b/resources/xbox-compat.json@@ -0,0 +1,10 @@+{+ "schema": 1,+ "games": {+ "9MTVJ3HHTQGS": {+ "title": "Retro Classics",+ "heap_free_check": true,+ "why": "Its UI logs a console string after freeing it. Windows' heap keeps that memory readable; Wine hands it back to the system, so the read crashes (exit code 5). FLG_HEAP_ENABLE_FREE_CHECK keeps recent frees parked."+ }+ }+}diff --git a/resources/xbox-runtime.json b/resources/xbox-runtime.jsonindex a83fd02b067..524e5bb0f6d 100644--- a/resources/xbox-runtime.json+++ b/resources/xbox-runtime.json@@ -1,26 +1,56 @@{- "version": "xbox-runtime-v1",- "runtime": "xodus-nexus-runtime-11.0-20261022-gf4adc821",- "license": "LGPL-2.1-or-later (Wine 11.0 + xgameruntime); sources: Nexus runtime source tarball and MACxus assets/runtime-patches",- "macxus": {- "url": "https://github.com/fladnaG86/MACxus/releases/download/v0.3.11-mac.12/MACxus-0.3.11-arm64.dmg",- "size": 234969830,- "sha256": "beb561d3d533bef2bcdb985777a1a70302941d373d32e5feed8c719bc7704ee1",- "asar": "MACxus.app/Contents/Resources/app.asar",- "folder": "assets/mac-runtime-dlls"- },- "nexus": {- "url": "https://github.com/domsvoboda/xodus-nexus/releases/download/runtime-11.0-20261022-gf4adc821/xodus-nexus-runtime-11.0-20261022-gf4adc821-x86_64.tar.xz",- "size": 370856848,- "sha256": "2874f6d4f6bed83985627a5d1ed7294d9cde77fbfbc8c0da22b0eaa080116735",- "member": "xodus-nexus-runtime-11.0-20261022-gf4adc821/files/lib/wine/x86_64-windows/libnghttp2.dll"- },- "dlls": {- "xgameruntime.dll": "f46bc9eb5f51e2f3d1d4c89eaf2b96be3695ee7339930cd552740a1063d88c0f",- "windows.web.dll": "7be54bf8e319c0100d689caeb84354e6b5b0453df33d20c4988c4888839cd580",- "twinapi.appcore.dll": "c6e7a618f9a98fb8d110c810712a5fd2412a9813cd0591b4c320e35e0dc06026",- "gamingtcui.dll": "918cb47fb1efab7d2fbc6d6fe67bcae25033b12433cedc129d07632f0d129167",- "winhttp.dll": "e1aec3bc2bf9d6f0718c1ea3ebd76c1b80d441da7e275fed7575ece35115068f",- "libnghttp2.dll": "2d8a707b7210f326df887920c6059e92eafddf9196a3c9dd7f22fe3b4308add1"- }+ "version": "xbox-runtime-v2",+ "runtime": "xodus-nexus-runtime-11.0-20261022-gf4adc821",+ "license": "LGPL-2.1-or-later (Wine 11.0 + xgameruntime); sources: Nexus runtime source tarball, MACxus assets/runtime-patches and patches/xgameruntime-store-empty-strings.patch; scripts/build-xbox-runtime.sh rebuilds xgameruntime.dll",+ "macxus": {+ "url": "https://github.com/fladnaG86/MACxus/releases/download/v0.3.11-mac.12/MACxus-0.3.11-arm64.dmg",+ "size": 234969830,+ "sha256": "beb561d3d533bef2bcdb985777a1a70302941d373d32e5feed8c719bc7704ee1",+ "asar": "MACxus.app/Contents/Resources/app.asar",+ "folder": "assets/mac-runtime-dlls"+ },+ "nexus": {+ "url": "https://github.com/domsvoboda/xodus-nexus/releases/download/runtime-11.0-20261022-gf4adc821/xodus-nexus-runtime-11.0-20261022-gf4adc821-x86_64.tar.xz",+ "size": 370856848,+ "sha256": "2874f6d4f6bed83985627a5d1ed7294d9cde77fbfbc8c0da22b0eaa080116735",+ "member": "xodus-nexus-runtime-11.0-20261022-gf4adc821/files/lib/wine/x86_64-windows/libnghttp2.dll"+ },+ "dlls": {+ "xgameruntime.dll": "f1ad4280db9bd49c1560fdb2751469f87723c4123a911b7fe3722c8bb91be920",+ "windows.web.dll": "7be54bf8e319c0100d689caeb84354e6b5b0453df33d20c4988c4888839cd580",+ "twinapi.appcore.dll": "c6e7a618f9a98fb8d110c810712a5fd2412a9813cd0591b4c320e35e0dc06026",+ "gamingtcui.dll": "918cb47fb1efab7d2fbc6d6fe67bcae25033b12433cedc129d07632f0d129167",+ "winhttp.dll": "e1aec3bc2bf9d6f0718c1ea3ebd76c1b80d441da7e275fed7575ece35115068f",+ "libnghttp2.dll": "2d8a707b7210f326df887920c6059e92eafddf9196a3c9dd7f22fe3b4308add1"+ },+ "soju": {+ "url": "https://github.com/BCD1210/soju/releases/download/xbox-runtime-v2/xgameruntime.dll",+ "size": 9765166,+ "sha256": "f1ad4280db9bd49c1560fdb2751469f87723c4123a911b7fe3722c8bb91be920",+ "dlls": [+ "xgameruntime.dll"+ ],+ "build": {+ "source": {+ "url": "https://github.com/domsvoboda/xodus-nexus/releases/download/runtime-11.0-20261022-gf4adc821/xodus-nexus-runtime-11.0-20261022-gf4adc821-source.tar.xz",+ "size": 69251888,+ "sha256": "6716280fa13584d034426898c00133ea3f20e29a15324142fd2f5753d4ff1108"+ },+ "macxus_commit": "0ab2972cc25a56fcde84b8a8345025f7443b5dcd",+ "patches": [+ {+ "macxus": "assets/runtime-patches/wine-macos-gs-last-error.patch",+ "sha256": "896f26f0ecd9d135a8a1980ac47d1683a9f5ccdc7ca1b36fb898d0d177f85520"+ },+ {+ "macxus": "assets/runtime-patches/xgameruntime-xstore-queries.patch",+ "sha256": "53c3e6068daae7442639dba63b0bee7da4056f3ed435fbb66e706649442be855"+ },+ {+ "soju": "patches/xgameruntime-store-empty-strings.patch",+ "sha256": "c4e2757143f8a2a579e62ede94fc685689fafcf7d2496c4d6924e33899673333"+ }+ ]+ }+ }}diff --git a/scripts/build-xbox-runtime.sh b/scripts/build-xbox-runtime.shnew file mode 100755index 00000000000..cdd7b6fbca8--- /dev/null+++ b/scripts/build-xbox-runtime.sh@@ -0,0 +1,61 @@+#!/usr/bin/env bash+# Rebuild Soju's xgameruntime.dll (the one file resources/xbox-runtime.json takes+# from Soju's own release instead of MACxus): the Xodus Nexus runtime's Wine 11.0+# tree + the two MACxus runtime patches + patches/xgameruntime-store-empty-strings.patch.+# Every input is pinned in resources/xbox-runtime.json ("soju" -> "build").+# Needs Xcode CLT, Homebrew mingw-w64 and bison. Output: dist/xbox-runtime/xgameruntime.dll+# (bytes differ between toolchains; the release pins the published build).+set -euo pipefail+ROOT="$(cd "$(dirname "$0")/.." && pwd)"+WORK="${SOJU_XBOX_RUNTIME_BUILD:-$HOME/.battlenet-macos/build/xbox-runtime-src}"+OUT="${SOJU_XBOX_RUNTIME_OUT:-$ROOT/dist/xbox-runtime}"+export PATH="/opt/homebrew/opt/bison/bin:/opt/homebrew/bin:$PATH"+command -v x86_64-w64-mingw32-gcc >/dev/null || { echo "Install mingw-w64 first: brew install mingw-w64" >&2; exit 1; }++# Download $1 to $2 (kept between runs) and use it only when its SHA-256 is $3.+fetch_checked(){ # url, dest, sha256+ local got+ if [ ! -f "$2" ]; then+ curl -fL --retry 3 --proto =https "$1" -o "$2.part" || { rm -f "$2.part"; echo "Download failed: $1" >&2; return 1; }+ mv -f "$2.part" "$2"+ fi+ got=$(shasum -a 256 "$2" | awk '{print $1}')+ if [ "$got" != "$3" ]; then+ rm -f "$2"+ printf 'Checksum mismatch for %s\n expected %s\n got %s\n' "$1" "$3" "$got" >&2+ return 1+ fi+}+field(){ python3 -c 'import json,sys+v=json.load(open(sys.argv[1]))["soju"]["build"]+for k in sys.argv[2].split("."): v=v[int(k)] if k.isdigit() else v[k]+print(v)' "$ROOT/resources/xbox-runtime.json" "$1"; }++mkdir -p "$WORK" "$OUT"+cd "$WORK"+fetch_checked "$(field source.url)" source.tar.xz "$(field source.sha256)"+commit="$(field macxus_commit)"+for i in 0 1; do+ path="$(field patches.$i.macxus)"+ fetch_checked "https://raw.githubusercontent.com/fladnaG86/MACxus/$commit/$path" "$(basename "$path")" "$(field patches.$i.sha256)"+done+ours="$ROOT/$(field patches.2.soju)"+[ "$(shasum -a 256 "$ours" | awk '{print $1}')" = "$(field patches.2.sha256)" ] \+ || { echo "$ours does not match resources/xbox-runtime.json" >&2; exit 1; }++# A fresh tree each run, so a half-applied patch never carries over.+rm -rf tree build64; mkdir tree+tar -xJf source.tar.xz -C tree+WINE="$WORK/tree/shared-build/wine-src"+for p in "$WORK/$(basename "$(field patches.0.macxus)")" "$WORK/$(basename "$(field patches.1.macxus)")" "$ours"; do+ patch -p1 -d "$WINE" < "$p"+done+mkdir build64 && cd build64+"$WINE/configure" --enable-archs=x86_64 --disable-tests --without-x --without-freetype > configure.log 2>&1 \+ || { tail -20 configure.log >&2; exit 1; }+make -j"${SOJU_BUILD_JOBS:-8}" dlls/xgameruntime/x86_64-windows/xgameruntime.dll > make.log 2>&1 \+ || { tail -20 make.log >&2; exit 1; }+cp dlls/xgameruntime/x86_64-windows/xgameruntime.dll "$OUT/xgameruntime.dll"+echo "Built $OUT/xgameruntime.dll"+echo " size $(stat -f %z "$OUT/xgameruntime.dll")"+echo " sha256 $(shasum -a 256 "$OUT/xgameruntime.dll" | awk '{print $1}')"diff --git a/scripts/fetch-xbox-runtime.py b/scripts/fetch-xbox-runtime.pyindex 8b710afb05b..532baffb85e 100755--- a/scripts/fetch-xbox-runtime.py+++ b/scripts/fetch-xbox-runtime.py@@ -4,9 +4,12 @@GDK games need Xbox services inside Wine. Those come from the Xodus Nexus runtime(Wine 11.0 + xgameruntime, LGPL-2.1-or-later). MACxus rebuilt five of its DLLsfor macOS Wine; they ship inside its signed release image, and libnghttp2.dll-comes from the Nexus runtime release. Both archives are pinned by size and-SHA-256 in resources/xbox-runtime.json, and every DLL is checked again after-extraction. The image is mounted read-only and nothing from it is executed.+comes from the Nexus runtime release. xgameruntime.dll is Soju's own build with+one more fix (scripts/build-xbox-runtime.sh), published as a Soju release file.+Every source is pinned by size and SHA-256 in resources/xbox-runtime.json, and+every DLL is checked again after extraction. The image is mounted read-only and+nothing from it is executed. DLLs already installed that still match their pin+are kept, so an update downloads only what changed."""import hashlibimport json@@ -92,12 +95,16 @@ def from_image(image, manifest, stage):finally:shutil.rmtree(mount, ignore_errors=True)for name, value in manifest['dlls'].items():- if name in files:+ if name in files and name not in soju_names(manifest):if digest_bytes(files[name]) != value:raise ValueError(name + ' does not match the pinned runtime; nothing was changed')(stage / name).write_bytes(files[name])+def soju_names(manifest):+ return set(manifest.get('soju', {}).get('dlls', []))++def from_runtime(archive, manifest, stage):member = manifest['nexus']['member']name = PurePosixPath(member).name@@ -123,14 +130,28 @@ def fetch(base, manifest):work = Path(temp)stage = work / 'runtime'stage.mkdir()- image = work / 'macxus.dmg'- download(manifest['macxus']['url'], image, manifest['macxus']['size'], manifest['macxus']['sha256'], 'MACxus runtime DLLs')- from_image(image, manifest, stage)- image.unlink()- archive = work / 'runtime.tar.xz'- download(manifest['nexus']['url'], archive, manifest['nexus']['size'], manifest['nexus']['sha256'], 'Xodus Nexus runtime')- from_runtime(archive, manifest, stage)- archive.unlink()+ for name, value in manifest['dlls'].items():+ try:+ if (target / name).is_file() and digest(target / name) == value:+ shutil.copyfile(target / name, stage / name)+ except OSError:+ pass+ def missing(names):+ return [n for n in names if not (stage / n).is_file()]+ nexus = PurePosixPath(manifest['nexus']['member']).name+ ours = soju_names(manifest)+ if missing(n for n in manifest['dlls'] if n not in ours and n != nexus):+ image = work / 'macxus.dmg'+ download(manifest['macxus']['url'], image, manifest['macxus']['size'], manifest['macxus']['sha256'], 'MACxus runtime DLLs')+ from_image(image, manifest, stage)+ image.unlink()+ if missing([nexus]):+ archive = work / 'runtime.tar.xz'+ download(manifest['nexus']['url'], archive, manifest['nexus']['size'], manifest['nexus']['sha256'], 'Xodus Nexus runtime')+ from_runtime(archive, manifest, stage)+ archive.unlink()+ for name in missing(sorted(ours)):+ download(manifest['soju']['url'], stage / name, manifest['soju']['size'], manifest['soju']['sha256'], 'Soju ' + name)missing = [n for n in manifest['dlls'] if not (stage / n).is_file()]if missing:raise ValueError('Runtime DLLs missing: ' + ', '.join(missing))diff --git a/scripts/xbox-run.py b/scripts/xbox-run.pyindex 17d52921f80..a569f4a4958 100755--- a/scripts/xbox-run.py+++ b/scripts/xbox-run.py@@ -78,6 +78,34 @@ def executable(folder):raise LaunchError('The game package does not name its executable (MicrosoftGame.config).')+COMPAT = ROOT / 'resources/xbox-compat.json'+IFEO = r'HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'+# FLG_HEAP_ENABLE_FREE_CHECK: the heap parks the last 1024 freed blocks instead of+# returning their pages at once, like Windows' heap effectively does.+FREE_CHECK = 0x20+++def compat(pid):+ try:+ value = json.loads(COMPAT.read_text()).get('games', {}).get(pid, {})+ return value if isinstance(value, dict) else {}+ except (OSError, ValueError, AttributeError):+ return {}+++def apply_compat(pid, exe):+ """Per-game Wine settings from resources/xbox-compat.json, set before each launch."""+ name = PureWindowsPath(exe).name+ if not compat(pid).get('heap_free_check') or not re.fullmatch(r'[A-Za-z0-9 ._-]{1,100}\.exe', name, re.I):+ return+ code = subprocess.run(['/bin/sh', str(ROOT / 'scripts/xbox-wine.sh'), 'reg', 'add', IFEO + '\\' + name,+ '/v', 'GlobalFlag', '/t', 'REG_DWORD', '/d', hex(FREE_CHECK), '/f'],+ env=dict(os.environ, SOJU_BASE=str(BASE)), stdin=subprocess.DEVNULL,+ capture_output=True, timeout=120).returncode+ if code != 0:+ print('soju: could not apply the compatibility setting for ' + name + ' (code ' + str(code) + ').', file=sys.stderr)++def market():value = os.environ.get('SOJU_XBOX_MARKET', '')if not value:@@ -292,6 +320,7 @@ def main():return 130if prepared != 0:return 1+ apply_compat(pid, exe)title = json.loads(record.read_text()).get('title') or pidprint('Starting ' + str(title)[:300] + ' (' + exe + ')…', flush=True)service = Service()diff --git a/scripts/xbox-wine.sh b/scripts/xbox-wine.shindex df70dc7670e..6d1797e579e 100755--- a/scripts/xbox-wine.sh+++ b/scripts/xbox-wine.sh@@ -6,7 +6,9 @@BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"ENGINE="${ENGINE:-$BASE/cx26-engine}"export WINEPREFIX="$BASE/xbox-bottle"-export WINEDEBUG="${WINEDEBUG:-fixme-all}"+# xbox-run.py drops WINE* variables from the environment; SOJU_XBOX_WINEDEBUG+# passes a Wine debug channel list through for diagnosis.+export WINEDEBUG="${SOJU_XBOX_WINEDEBUG:-${WINEDEBUG:-fixme-all}}"export WINEMSYNC="${WINEMSYNC:-1}"export ROSETTA_ADVERTISE_AVX="${ROSETTA_ADVERTISE_AVX:-1}"[ "$ROSETTA_ADVERTISE_AVX" = 0 ] && unset ROSETTA_ADVERTISE_AVXdiff --git a/tests/test_xbox.py b/tests/test_xbox.pyindex fb7883b8928..72165c906b2 100644--- a/tests/test_xbox.py+++ b/tests/test_xbox.py@@ -500,6 +500,73 @@ class XboxLaunchTests(unittest.TestCase):self.assertEqual(len(m['dlls']), 6)for value in m['dlls'].values():self.assertRegex(value, r'^[0-9a-f]{64}$')+ # Soju's own xgameruntime build: one file from Soju's release, rebuildable from pinned inputs.+ soju = m['soju']+ self.assertEqual(soju['dlls'], ['xgameruntime.dll'])+ self.assertTrue(soju['url'].startswith('https://github.com/BCD1210/soju/releases/download/'))+ self.assertEqual(soju['sha256'], m['dlls']['xgameruntime.dll'])+ build = soju['build']+ self.assertRegex(build['source']['sha256'], r'^[0-9a-f]{64}$')+ self.assertRegex(build['macxus_commit'], r'^[0-9a-f]{40}$')+ ours = [p for p in build['patches'] if 'soju' in p]+ self.assertEqual(len(ours), 1)+ import hashlib+ self.assertEqual(hashlib.sha256((ROOT / ours[0]['soju']).read_bytes()).hexdigest(), ours[0]['sha256'])++ def test_compat_sets_heap_free_check_only_for_listed_games(self):+ calls = []+ def run(args, **kwargs):+ calls.append(args)+ return subprocess.CompletedProcess(args, 0, '', '')+ with patch.object(runner.subprocess, 'run', side_effect=run):+ runner.apply_compat('9MTVJ3HHTQGS', 'RetroClassics.exe')+ runner.apply_compat(SILKSONG, 'Game.exe')+ runner.apply_compat('9MTVJ3HHTQGS', 'bad"name.exe')+ self.assertEqual(len(calls), 1)+ args = calls[0]+ self.assertTrue(args[1].endswith('scripts/xbox-wine.sh'))+ self.assertEqual(args[2:4], ['reg', 'add'])+ self.assertTrue(args[4].endswith('Image File Execution Options\\RetroClassics.exe'))+ self.assertEqual(args[5:], ['/v', 'GlobalFlag', '/t', 'REG_DWORD', '/d', '0x20', '/f'])++ def test_compat_list_is_well_formed(self):+ data = json.loads((ROOT / 'resources/xbox-compat.json').read_text())+ self.assertEqual(data['schema'], 1)+ for pid, game in data['games'].items():+ self.assertRegex(pid, r'^[0-9A-Z]{12}$')+ self.assertTrue(game['why'])++ def test_store_patch_fills_every_string_the_runtime_leaves_null(self):+ patch_text = (ROOT / 'patches/xgameruntime-store-empty-strings.patch').read_text()+ for field in ('p->linkUri', 'p->price.currencyCode', 's->price.currencyCode',+ 's->collectionData.campaignId', 's->collectionData.developerOfferId'):+ self.assertIn(field, patch_text)+ self.assertIn('+ entitled_fill_strings(&page->snapshot->products[i]);', patch_text)++ def test_update_reuses_matching_dlls_and_fetches_only_soju_fix(self):+ import hashlib+ m = json.loads((ROOT / 'resources/xbox-runtime.json').read_text())+ with tempfile.TemporaryDirectory() as temp:+ base = Path(temp)+ target = base / 'xbox-runtime'+ target.mkdir()+ fake = {}+ for name in m['dlls']:+ fake[name] = ('old-' + name).encode()+ (target / name).write_bytes(fake[name])+ pinned = dict(m, dlls={n: hashlib.sha256(fake[n]).hexdigest() for n in m['dlls']})+ new = b'fixed xgameruntime'+ pinned['dlls']['xgameruntime.dll'] = hashlib.sha256(new).hexdigest()+ pinned['soju'] = dict(m['soju'], sha256=pinned['dlls']['xgameruntime.dll'], size=len(new))+ fetched = []+ def download(url, dest, size, sha256, label):+ fetched.append(url)+ dest.write_bytes(new)+ with patch.object(runtime, 'download', side_effect=download):+ runtime.fetch(base, pinned)+ self.assertEqual(fetched, [m['soju']['url']])+ self.assertEqual((target / 'xgameruntime.dll').read_bytes(), new)+ self.assertTrue(runtime.ready(target, pinned))def test_asar_reader_returns_only_the_requested_folder(self):import struct