mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-10-04 17:28:12 -07:00
misc: various clean up for diagnosing launch failures (#872)
## Link to GitHub Issue or related Pull Request, if one exists #345 ## Description of change **IIDX TDJ rom probe no longer touches removable media** — `C:\000rom.txt` and `D:\001rom.txt` are not emulated paths; they hit whatever is actually mounted on the user's machine. `D:` is commonly an optical drive or card reader, and the launcher clears `SEM_FAILCRITICALERRORS` process-wide before attach, so an empty drive raises the modal *"insert a disk"* dialog and blocks the attaching thread. The probe now checks `GetDriveTypeW` and only reads fixed and RAM disks. **`iat_find` no longer calls `log_fatal` on an unparseable module** — `iat_try(nullptr)` walks every loaded module, including foreign ones (injected, manually mapped, header wiped by AV/EDR/overlays). A non-`MZ` DOS header called `log_fatal`. There is nothing to hook in such a module, so it is skipped. **`logger::stop()` can no longer hang forever** — hook installation suspends every other thread, including the logging thread. `stop()` unconditionally joined that thread, so `log_fatal` and the 30-second `show_popup` watchdog both wedged instead of terminating, and logging is asynchronous so nothing reached log.txt either. It now waits with a timeout, then detaches and flushes synchronously. **`GetFileSizeEx` was never hooked** — the hook was registered under the name `"GetFileSize"`, so it re-patched that slot instead. **Warn when `-modules` is set** — it changes where the game is run from, and is usually set accidentally. ## Testing *how was the code tested?*
This commit is contained in:
@@ -279,6 +279,26 @@ namespace games::iidx {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// best-effort read of a TDJ ROM file to determine if the game is running in TDJ mode
|
||||
//
|
||||
// these paths are not emulated - they hit whatever is actually mounted at that drive letter.
|
||||
// an empty optical or removable drive raises the modal "insert a disk" error (the launcher
|
||||
// clears SEM_FAILCRITICALERRORS process-wide) and a downed network drive stalls on redirector
|
||||
// timeouts, so only probe what a TDJ cabinet would actually be laid out on.
|
||||
// drive_path must be absolute and start with a drive letter.
|
||||
static bool tdj_rom_matches(const char *drive_path, const char *expected) {
|
||||
const wchar_t root[] = { (wchar_t) drive_path[0], L':', L'\\', L'\0' };
|
||||
const auto drive_type = GetDriveTypeW(root);
|
||||
|
||||
if (drive_type != DRIVE_FIXED && drive_type != DRIVE_RAMDISK) {
|
||||
log_misc("iidx", "not probing '{}' for TDJ, not a local disk (drive type {})",
|
||||
drive_path, drive_type);
|
||||
return false;
|
||||
}
|
||||
|
||||
return fileutils::text_read(drive_path) == expected;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
IIDXGame::IIDXGame() : Game("Beatmania IIDX") {
|
||||
@@ -339,8 +359,10 @@ namespace games::iidx {
|
||||
HAS_LIBAIO = true;
|
||||
|
||||
// check TDJ mode
|
||||
TDJ_MODE |= fileutils::text_read("C:\\000rom.txt") == "TDJ-JA";
|
||||
TDJ_MODE |= fileutils::text_read("D:\\001rom.txt") == "TDJ";
|
||||
if (!TDJ_MODE) {
|
||||
TDJ_MODE = tdj_rom_matches("C:\\000rom.txt", "TDJ-JA")
|
||||
|| tdj_rom_matches("D:\\001rom.txt", "TDJ");
|
||||
}
|
||||
|
||||
// force TDJ mode
|
||||
if (TDJ_MODE) {
|
||||
|
||||
Reference in New Issue
Block a user