[Kernel/XMP] Add title-specific file I/O hooks for XMP volume sync

Some games persist BGM volume through their own save files but never
call XMPSetVolume. Add a TitlePatch system that intercepts NtReadFile/
NtWriteFile to apply game-specific logic as well as logic to identify
the memory location that the volume data is read into and monitor that
memory location for changes, updating XMP player volume if it changes
during gameplay.

Includes patches for known games with this issue:
Dead or Alive Xtreme 2 (544307D2), PGR4 (4D5307F9) and PGR3 (4D5307D1)
This commit is contained in:
Herman S.
2026-03-08 14:42:11 +09:00
parent 54400cbc2c
commit 02fccd9113
6 changed files with 246 additions and 4 deletions

View File

@@ -407,6 +407,9 @@ void KernelState::SetExecutableModule(object_ref<UserModule> module) {
xboxkrnl::XboxkrnlModule::kExLoadedCommandLineSize);
}
// Initialize file I/O hooks for XMP volume title-specific patches.
InitXmpVolumePatch();
// Spin up deferred dispatch worker.
// TODO(benvanik): move someplace more appropriate (out of ctor, but around
// here).
@@ -738,8 +741,13 @@ void KernelState::UnloadUserModule(const object_ref<UserModule>& module,
object_table()->ReleaseHandleInLock(module->handle());
}
void KernelState::InitXmpVolumePatch() {
xmp_volume_patch_ = XmpVolumePatch::CreateForTitle(title_id(), this);
}
void KernelState::TerminateTitle() {
XELOGD("KernelState::TerminateTitle");
xmp_volume_patch_.reset();
auto global_lock = global_critical_region_.Acquire();
// Call terminate routines.