#!/usr/bin/env bash # Fix 1: make kmyCore.dll's scanPlugin use the on-disk filesystem. # # kmyPlugin::PluginMgr::scanPlugin calls kmyIO::FS::newFS(0, NULL) which, in # packaged mode, hands back the in-memory data.rbpack filesystem. The engine's # .dlp asset loaders (FBXLoader/PNGLoader/OGGLoader/BulletPhysics/...) do NOT # live inside data.rbpack, so the scan finds none of them and the game loads an # empty scene (grey screen). This flips the target of that one `call` so it goes # to the disk-FS creator at RVA 0xAAA10 (which safely handles a NULL path). # # The change is a single byte in the rel32 displacement of the call: # file offset 0xD0B54 : 0x58 -> 0xB8 (retargets 0xAA9B0 -> 0xAAA10) # Before writing, the FULL 5-byte call instruction at 0xD0B53 is verified # (e8 58 92 fd ff), so a different build can't pass on a coincidental byte. # # Reversible: a .orig backup is written next to the file the first time. set -euo pipefail GAME_ROOT="${1:?usage: 01-kmycore-diskfs.sh }" DLL="$GAME_ROOT/data/kmyCore.dll" OFF=$((0xD0B54)) # the rel32 low byte we flip CALL_OFF=$((0xD0B53)) # start of the 5-byte call instruction ORIG_CALL="e85892fdff" # call -> disk/pack FS dispatcher RVA 0xAA9B0 NEW_CALL="e8b892fdff" # call -> disk-FS creator RVA 0xAAA10 # md5 of the known-good v1.1.0 unpatched kmyCore.dll (5,423,536 bytes) KNOWN_ORIG_MD5="68590231c9418eeab8b9d70203e1f08d" [ -f "$DLL" ] || { echo "!! not found: $DLL"; exit 1; } cur=$(od -An -tx1 -j "$CALL_OFF" -N5 "$DLL" | tr -d ' \n') if [ "$cur" = "$NEW_CALL" ]; then echo "== Fix 1: already applied (call @0x$(printf %x $CALL_OFF) = $NEW_CALL)"; exit 0 fi if [ "$cur" != "$ORIG_CALL" ]; then echo "!! Fix 1: unexpected bytes $cur @0x$(printf %x $CALL_OFF) (expected $ORIG_CALL)." echo "!! This kmyCore.dll is a different build than this patch targets. Aborting." exit 3 fi md5now=$(md5sum "$DLL" | cut -d' ' -f1) [ "$md5now" = "$KNOWN_ORIG_MD5" ] || \ echo " (note: kmyCore.dll md5 $md5now != known $KNOWN_ORIG_MD5; byte matches, continuing)" [ -f "$DLL.orig" ] || cp -n "$DLL" "$DLL.orig" printf "\xb8" | dd of="$DLL" bs=1 seek="$OFF" count=1 conv=notrunc status=none echo "== Fix 1: patched kmyCore.dll (disk-FS), backup at kmyCore.dll.orig"