| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/usr/bin/env bash
- # Fix 2: make bakinplayer.exe pass a real plugin path to the native engine.
- #
- # Yukar.Player.Program calls SharpKmy.Entry.initialize("", null), so pluginpath
- # is NULL. The native scanPlugin then tries GetModuleFileNameW(NULL) to derive a
- # search dir, which under Wine does not resolve to the on-disk data dir where the
- # .dlp loaders live, so nothing is found. We rewrite the managed IL so the second
- # argument becomes AppDomain.CurrentDomain.BaseDirectory (the folder containing
- # bakinplayer.exe), which makes scanPlugin take its explicit-path branch.
- #
- # This is a pure IL rewrite done with Mono.Cecil (see Program.cs). It needs the
- # .NET SDK (`dotnet`) available on PATH to build the tiny patcher. Reversible via
- # the bakinplayer.exe.orig backup.
- set -euo pipefail
- GAME_ROOT="${1:?usage: apply.sh <game-root-dir>}"
- HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
- EXE="$GAME_ROOT/data/bakinplayer.exe"
- KNOWN_ORIG_MD5="dc76b6ee233efaa1270d845b47fd4e3d" # unpatched v1.1.0 (589,312 bytes)
- [ -f "$EXE" ] || { echo "!! not found: $EXE"; exit 1; }
- command -v dotnet >/dev/null || { echo "!! 'dotnet' (.NET SDK) not found on PATH, needed to build the IL patcher"; exit 2; }
- md5now=$(md5sum "$EXE" | cut -d' ' -f1)
- if [ "$md5now" != "$KNOWN_ORIG_MD5" ]; then
- echo " (note: bakinplayer.exe md5 $md5now != known-original $KNOWN_ORIG_MD5)"
- echo " If it was already patched by this tool, that is expected; continuing."
- fi
- echo "== Fix 2: building IL patcher (dotnet) ..."
- dotnet build -c Release -o "$HERE/bin" "$HERE/patcher.csproj" >/dev/null
- [ -f "$EXE.orig" ] || cp -n "$EXE" "$EXE.orig"
- TMP="$(mktemp --suffix=.exe)"
- if dotnet "$HERE/bin/patcher.dll" "$EXE.orig" "$TMP"; then
- cp "$TMP" "$EXE"; rm -f "$TMP"
- echo "== Fix 2: patched bakinplayer.exe (pluginpath=BaseDirectory), backup at bakinplayer.exe.orig"
- else
- rm -f "$TMP"
- echo "!! Fix 2: patcher found no patch site; bakinplayer.exe may be a different build"; exit 4
- fi
|