Skip to content

armgit / soju

Public Imported from GitHub
0

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.

Fix CEF renderer int3 without CrossOver's ntdll: WINE_SIMULATE_WRITECOPY=1

mikey923953f6e91591
diff --git a/docs/DIAGNOSIS.md b/docs/DIAGNOSIS.md
index faf0f65dddd..9c2948bddb0 100644
--- a/docs/DIAGNOSIS.md
+++ b/docs/DIAGNOSIS.md
@@ -28,6 +28,38 @@ stock Whisky / frankea 엔진(v3.1.1, v4.5beta, v2.5.0)은 전부 **신형 WoW64
- `--disable-gpu-compositing`로 실행 (소프트웨어 합성).
- GL 에러(`SharedImageStub`, `Failed to create ... context for virtualization`)는 **무해** — 진짜 CrossOver도 동일하게 99개씩 냄.
+## 벽 1 — 진짜 원인 확정: `WINE_SIMULATE_WRITECOPY` (2026-08-29)
+
+위 "신형 WoW64" 설명은 결과적으로 맞는 엔진을 고르게 했지만 원인은 아니었다. CrossOver 26.3 GPL 소스로
+직접 빌드한 엔진(`cx26-engine`)에서도 같은 int3(`libcef.dll+0x16D00E1`)가 재현됐고, CX 출하 바이너리의
+`ntdll.so` 하나만 바꿔 끼우면 사라졌다. 동적 추적(`WINEDEBUG=+seh,+virtual,+process,+loaddll`)으로 특정한 내용:
+
+- 크래시 프로세스: `Battle.net.exe --type=renderer` (CEF 렌더러)의 초기 스레드, DLL 로드 직후.
+- 크래시 지점 디스어셈블(libcef RVA `0x16D00A0`):
+ ```
+ ret = VirtualProtect(addr, size, PAGE_READONLY /*2*/, &old);
+ if (!ret) int3; // 0x16D00DE
+ if (old != PAGE_READWRITE /*4*/) int3; // 0x16D00E1 ← 여기서 죽음
+ ```
+- `addr`는 `libcef.dll`의 `.data` 페이지(이미지 매핑, write-copy). 순정 wine은 이미지의 쓰기 가능 페이지를
+ 처음부터 RW로 mmap 하고 첫 쓰기를 추적하지 않으므로 `old`가 영원히 `PAGE_WRITECOPY(8)`이다.
+ Windows는 첫 쓰기 후 `PAGE_READWRITE(4)`로 바뀐다.
+- CX 소스에는 이를 흉내 내는 **CW Hack 22996** (`simulate_writecopy`, `dlls/ntdll/unix/virtual.c`
+ `NtProtectVirtualMemory`의 "Setting VPROT_COPIED")가 있지만, 공개 소스는 `WINE_SIMULATE_WRITECOPY` 환경변수로만
+ 켜진다(`loader.c: hacks_init`). CX 출하 바이너리는 같은 환경에서 이 경로를 탄다 → 기본값이 다름.
+
+검증 (각 75~90초, 같은 보틀):
+
+| 엔진 | `EXCEPTION_BREAKPOINT` | 렌더러 생존 |
+|---|---|---|
+| cx26-engine (우리 빌드) | 2 | ✗ |
+| cx26-engine + SDK15 재빌드 ntdll | 2 | ✗ (툴체인 가설 기각) |
+| cx26-engine + CX ntdll.so | 0 | ✓ |
+| cx26-engine + `WINE_SIMULATE_WRITECOPY=1` | 0 | ✓ (90초 후 렌더러 2개 생존, 로그인·메인창 OK) |
+
+해결: 모든 실행 경로(`install.sh`, `scripts/play.sh`, `scripts/create-bottle.sh`)에 `WINE_SIMULATE_WRITECOPY=1`.
+CrossOver 바이너리 의존 0.
+
## 벽 2 — Battle.net Agent caller 서명 검증 실패 (해결됨)
### 증상
diff --git a/install.sh b/install.sh
index e2d01aedde5..617a5c84d45 100644
--- a/install.sh
+++ b/install.sh
@@ -82,7 +82,7 @@ EOT
fi
# ---------- 3. Bottle + Battle.net ----------
-export WINEPREFIX="$BOTTLE" WINEDEBUG=fixme-all WINEMSYNC=1 ROSETTA_ADVERTISE_AVX=1
+export WINEPREFIX="$BOTTLE" WINEDEBUG=fixme-all WINEMSYNC=1 ROSETTA_ADVERTISE_AVX=1 WINE_SIMULATE_WRITECOPY=1
export CX_APPLEGPTK_LIBD3DSHARED_PATH="$ENGINE/lib/external/libd3dshared.dylib"
export DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib"
if [ -f "$BOTTLE/drive_c/Program Files (x86)/Battle.net/Battle.net.exe" ]; then
@@ -120,7 +120,7 @@ APP="$HOME/Applications/Battle.net.app"
mkdir -p "$APP/Contents/MacOS"
cat > "$APP/Contents/MacOS/launcher" <<EOF
#!/bin/bash
-export WINEPREFIX="$BOTTLE" WINEDEBUG=fixme-all WINEMSYNC=1 ROSETTA_ADVERTISE_AVX=1
+export WINEPREFIX="$BOTTLE" WINEDEBUG=fixme-all WINEMSYNC=1 ROSETTA_ADVERTISE_AVX=1 WINE_SIMULATE_WRITECOPY=1
export CX_APPLEGPTK_LIBD3DSHARED_PATH="$ENGINE/lib/external/libd3dshared.dylib"
export DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib"
BN="\$WINEPREFIX/drive_c/Program Files (x86)/Battle.net"
diff --git a/research/writecopy-root-cause.txt b/research/writecopy-root-cause.txt
new file mode 100644
index 00000000000..18e18071c75
--- /dev/null
+++ b/research/writecopy-root-cause.txt
@@ -0,0 +1,28 @@
+=== CEF renderer int3 root cause (2026-08-29) ===
+crash thread (renderer initial thread), WINEDEBUG=+seh,+virtual,+loaddll,+process, cx26-engine (our ntdll):
+
+0394:trace:loaddll:build_module Loaded L"C:\\Program Files (x86)\\Battle.net\\Battle.net.17731\\libcef.dll" at 678C0000: native
+...
+0394:trace:virtual:NtProtectVirtualMemory 0xffffffffffffffff 0x710a9000 00001000 00000002
+0394:trace:virtual:get_vprot_range_size base 0x710a9000, size 0x1000, mask 0x20.
+0394:trace:virtual:dump_view View: 0x678c0000 - 0x71843fff c-rWx (image)
+0394:trace:virtual:dump_view 0x71089000 - 0x710a8fff c-rW-
+0394:trace:virtual:dump_view 0x710a9000 - 0x710a9fff c-r--
+0394:trace:seh:dispatch_exception code=80000003 (EXCEPTION_BREAKPOINT) flags=0 addr=68F900E1 (= libcef+0x16D00E1)
+wine: Unhandled exception 0x80000003 in thread 394 at address 68F900E1 (thread 0394), starting debugger...
+
+same call under CX-shipped ntdll.so (shadow-engine), same page (libcef @ 6C680000 -> 0x75e69000):
+03ec:trace:virtual:NtProtectVirtualMemory 0xffffffffffffffff 0x75e69000 00001000 00000002
+03ec:trace:virtual:get_vprot_range_size base 0x75e69000, size 0x1000, mask 0x20.
+03ec:trace:virtual:NtProtectVirtualMemory Setting VPROT_COPIED. <-- simulate_writecopy path (CW Hack 22996)
+(no breakpoint)
+
+libcef.dll 0x116d00a0 (image base 0x10000000):
+ calll *0x197bc9e0 ; IAT -> KERNEL32.VirtualProtect(a, b, 2, &local)
+ testl %eax,%eax ; je 116d00de (int3)
+ cmpl $0x4,-0x8(%ebp) ; jne 116d00e1 (int3) ; old protection must be PAGE_READWRITE
+
+crashing process cmdline: "Battle.net.exe --type=renderer ..." (parent NtCreateUserProcess pid 0390 tid 0394)
+
+fix verified: WINE_SIMULATE_WRITECOPY=1 with pristine cx26-engine -> 0 breakpoints, renderers alive at 90s,
+"Logged into Battle.net successfully" + "Attempting to show main window".
diff --git a/scripts/build-engine.sh b/scripts/build-engine.sh
index 7a317edbe8b..c68e304a71d 100755
--- a/scripts/build-engine.sh
+++ b/scripts/build-engine.sh
@@ -85,7 +85,7 @@ echo "==> Done: $ENGINE"
DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib" "$ENGINE/bin/wine" --version
echo
echo "Example launch:"
-echo " export WINEPREFIX=<bottle> CX_GRAPHICS_BACKEND=d3dmetal WINEMSYNC=1"
+echo " export WINEPREFIX=<bottle> CX_GRAPHICS_BACKEND=d3dmetal WINEMSYNC=1 WINE_SIMULATE_WRITECOPY=1"
echo " export DYLD_FALLBACK_LIBRARY_PATH='$ENGINE/lib:/usr/lib'"
echo " '$ENGINE/bin/wine' 'C:\\\\Program Files (x86)\\\\Battle.net\\\\Battle.net Launcher.exe' --disable-gpu-compositing"
echo " (Apple-protected binaries (nohup, ...) in the chain strip DYLD_* — background it with a subshell & instead)"
diff --git a/scripts/create-bottle.sh b/scripts/create-bottle.sh
index 2fede1a3d71..3b214b03a5a 100755
--- a/scripts/create-bottle.sh
+++ b/scripts/create-bottle.sh
@@ -7,7 +7,7 @@ set -euo pipefail
ENGINE="${ENGINE:-$HOME/.battlenet-macos/cx26-engine}"
export WINEPREFIX="${WINEPREFIX:-$HOME/.battlenet-macos/bottle}"
export WINEDEBUG="${WINEDEBUG:-fixme-all}"
-export WINEMSYNC=1 ROSETTA_ADVERTISE_AVX=1
+export WINEMSYNC=1 ROSETTA_ADVERTISE_AVX=1 WINE_SIMULATE_WRITECOPY=1
export CX_APPLEGPTK_LIBD3DSHARED_PATH="$ENGINE/lib/external/libd3dshared.dylib"
export DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib"
diff --git a/scripts/play.sh b/scripts/play.sh
index d4abcd0de00..2c304ad1733 100755
--- a/scripts/play.sh
+++ b/scripts/play.sh
@@ -27,6 +27,13 @@ fi
export WINEDEBUG="${WINEDEBUG:-fixme-all}"
export WINEMSYNC=1
export ROSETTA_ADVERTISE_AVX=1
+# Battle.net's CEF renderer CHECKs that VirtualProtect() on a written .data page
+# of libcef.dll reports PAGE_READWRITE. Plain wine reports PAGE_WRITECOPY for
+# image pages forever (it maps them RW and never tracks the first write), so the
+# renderer hits int3 on startup and the login webview stays blank. CrossOver's
+# ntdll enables the "simulate writecopy" hack (CW Hack 22996) by default; the
+# GPL source only enables it through this env var. See docs/DIAGNOSIS.md.
+export WINE_SIMULATE_WRITECOPY=1
export CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal
export CX_GRAPHICS_BACKEND=d3dmetal
export CX_APPLEGPTK_LIBD3DSHARED_PATH="$ENGINE/lib/external/libd3dshared.dylib"