hangover icon indicating copy to clipboard operation
hangover copied to clipboard

Packed 32-bit DLL fails to initialize: box64 hangs in DllMain, FEX access-violates (PSOBB / ephinea.dll)

Open deltapath-eric opened this issue 3 months ago • 0 comments

Summary

A packed/obfuscated 32-bit DLL fails to initialize under Hangover, in two different ways depending on the WoW64 emulator:

  • box64 (HODLL=wowbox64.dll): DllMain(PROCESS_ATTACH) is entered and never returns. The process spins at ~100% CPU forever and no window is ever created.
  • FEX (HODLL=libwow64fex.dll): DllMain faults with EXCEPTION_ACCESS_VIOLATION, Wine logs Initialization of L"ephinea.dll" failed, and the host app continues without the DLL.

Everything else works well — the same 32-bit game renders through wined3d/GL and reaches its network login screen. Only this one DLL fails, so the scope is narrow.

Reproduced on two Hangover versions with different emulator versions:

Hangover 11.9 (upstream) Hangover 11.16 (mikugirls fork)
Wine 11.9 11.16
box64 v0.4.2 v0.4.5
box64 result hang; c0000094 INT_DIVIDE_BY_ZERO @ 0x7A8CF894 hang; c000001d ILLEGAL_INSTRUCTION @ pc=0x100fe9d9c
FEX result fails; c0000005 @ 0x779CD33C fails; c0000005 @ 0x7790D33C

Environment

Host OS ROCKNIX 20260820 (LibreELEC-derived, immutable rootfs), kernel 7.1.2 aarch64
glibc 2.41
SoC Qualcomm SM6115 (Snapdragon 662: 4x Cortex-A73 + 4x A53), Adreno 610
Page size 4096
Build used hangover_<ver>_debian12_bookworm_arm64.tar, .deb payload extracted to /storage/hangover* (distro is immutable)
Graphics sway + Xwayland, Wine X11 driver, mesa 26.1.6 freedreno, GL 4.6

ldd is clean on bin/wine, bin/wineserver, bin/winebuild.

The DLL

ephinea.dll, 12.6 MB, from the Ephinea PSOBB client. Clearly packed:

  • a section named .banana (3.8 MB) plus several unnamed RWX sections
  • prefers base 0x10000000, has DYNAMIC_BASE, so Wine relocates it
  • Wine logs warn:module:alloc_module disabling no-exec because of L"ephinea.dll"

Host process is PsoBB.exe (32-bit PE), which imports it.

Steps to reproduce

The client is a free download and the installer does not need to be run — 7z extracts it:

curl -O https://files.pioneer2.net/Ephinea_PSOBB_Installer.exe    # NSIS, ~855 MB
7z x Ephinea_PSOBB_Installer.exe -o/path/to/psobb
cd /path/to/psobb

export WINEPREFIX=~/.psobb-prefix
export WINEDLLOVERRIDES="mscoree=d;mshtml=d"
wine wineboot -u

# PSOBB only accepts 16-bit display modes, otherwise it exits before loading the DLL:
wine reg add 'HKCU\Software\Wine\X11 Driver' /v ScreenDepth /t REG_SZ /d 16 /f

HODLL=wowbox64.dll    WINEDEBUG=+loaddll,+module,+seh wine explorer /desktop=pso,1280x720 PsoBB.exe
HODLL=libwow64fex.dll WINEDEBUG=+loaddll,+module,+seh wine explorer /desktop=pso,1280x720 PsoBB.exe

box64: DllMain never returns

trace:module:map_image_into_view relocating L"...\ephinea.dll" dynamic base 10000000 -> 73300000
warn:module:alloc_module disabling no-exec because of L"ephinea.dll"
trace:module:process_attach (L"ephinea.dll",00000000) - START
trace:module:MODULE_InitDLL (73300000 L"ephinea.dll",PROCESS_ATTACH,00000000) - CALL
trace:seh:dispatch_exception code=c0000094 (EXCEPTION_INT_DIVIDE_BY_ZERO) flags=1 addr=000000007A8CF894
   <no matching RETURN; ~100% CPU indefinitely, no window>

The DLL is mapped (grep -c ephinea /proc/<pid>/maps = 1) but DllMain never completes. Over a 10-minute run: 100% CPU on one thread, read_bytes advanced ~11 KB, no window.

On box64 v0.4.5 the exception becomes c000001d EXCEPTION_ILLEGAL_INSTRUCTION at pc=0x100fe9d9c — above the 4 GB boundary and therefore not inside the DLL (mapped at 0x73270000), which looks like it is in box64's own JIT region. BOX64_DYNAREC_MISSING=1 reported no missing opcodes.

FEX: DllMain access-violates

trace:module:map_image_into_view relocating L"...\ephinea.dll" dynamic base 10000000 -> 74820000
trace:module:MODULE_InitDLL (74820000 L"ephinea.dll",PROCESS_ATTACH,00000000) - CALL
trace:seh:dispatch_exception code=c0000005 (EXCEPTION_ACCESS_VIOLATION) flags=0 addr=00000000779CD33C
trace:module:MODULE_InitDLL (74820000 L"ephinea.dll",PROCESS_DETACH,00000000) - CALL
warn:module:process_attach Initialization of L"ephinea.dll" failed

0x779CD33C is inside the DLL's mapped range (0x74820000-0x779D0000). An earlier fault in the same run reported info[1]=0x27E0976A as the inaccessible address. FEX faults at a nearly identical address on both Hangover versions, i.e. deterministic in the same spot; box64's exception type varies with configuration.

What I ruled out

  • Not JIT codegen alone: BOX64_DYNAREC=0 (interpreter) also hangs.
  • Not dynarec tuning: BOX64_DYNAREC_SAFEFLAGS=2 BIGBLOCK=0 CALLRET=0 STRONGMEM=3 still hangs. [BOX64] BOX64ENV: Variables overridden: confirms the variables were applied.
  • Not general 32-bit breakage: wine C:\windows\syswow64\cmd.exe /c echo hi works under both emulators on both versions, and the rest of this 32-bit game runs fine.
  • Not Windows version: winecfg /v win7 and /v winxp behave identically.
  • Not the display path: same with and without explorer /desktop.
  • Not fixed by newer submodules: Wine 11.9 -> 11.16, box64 0.4.2 -> 0.4.5.
  • Inconclusive: I tried FEX_SMCCHECKS=full/mman and FEX_PARANOIDTSO=1 on the theory that stale translations of self-modifying unpacker code were involved. No change — but FEX printed nothing to confirm the variables were even read, so please treat that as untested rather than ruled out. If there is a correct way to set FEX options for libwow64fex.dll, I am happy to retest.

Speculation (flagged as such)

box64's INT_DIVIDE_BY_ZERO with flags=1 (EXCEPTION_NONCONTINUABLE) made me wonder whether the unpacker uses exception-based control flow — raise a deliberate fault, catch it in SEH, resume — and whether a continuable guest exception is reaching the handler as non-continuable. I have not verified this, and box64 0.4.5's illegal-instruction-in-JIT symptom does not fit it neatly. Possibly related: #216, #217 (virtual_setup_exception / stack-limit issues), though those fail differently.

Happy to help

The device has SSH access and I can run any WINEDEBUG channels, env vars, patched builds, or test binaries on request. If a minimal repro would be more useful than an 855 MB game, I can try to build a small 32-bit PE that raises a continuable divide-by-zero, catches it in __try/__except, and resumes — just say what shape would help most.

deltapath-eric avatar Aug 27 '26 09:08 deltapath-eric