From e9ee084231a4e98e6f0011be5a9223cfc24700de Mon Sep 17 00:00:00 2001 From: luxsie <877033040@qq.com> Date: Tue, 12 Aug 2014 04:15:20 +0800 Subject: [PATCH] Automatic-Pause at specified function calls, can be set up using "pause.bin" with rpcs3. You would need to find the function ids you wanna play with and write them reversed with Hex Editor. That's quite pity i have no knowledge about wxWidgets so there is no GUI to set up this. --- rpcs3/Emu/SysCalls/ModuleManager.cpp | 47 ++++++++++++++++++++++++++++ rpcs3/Emu/SysCalls/ModuleManager.h | 3 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/SysCalls/ModuleManager.cpp b/rpcs3/Emu/SysCalls/ModuleManager.cpp index e3f354b86e..3a0e882b87 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.cpp +++ b/rpcs3/Emu/SysCalls/ModuleManager.cpp @@ -263,6 +263,7 @@ void ModuleManager::init() m_mod_init.emplace_back(0x000e, sys_fs_init); initialized = true; } + LoadFuncPauses(); //Load the list of pause functions } ModuleManager::ModuleManager() : @@ -293,6 +294,17 @@ bool ModuleManager::IsLoadedFunc(u32 id) bool ModuleManager::CallFunc(u32 num) { + //Pause at specified function calls + for (u32 i = 0; i < m_funcs_pause_funcs.size(); ++i) + { + //Add Call Pause Here. This call is from BLJS10157 + if (num == m_funcs_pause_funcs[i]) + { + Emu.Pause(); //So it is now pause, yep. + LOG_ERROR(HLE, "TEST PAUSE AT %x", num); //Used Error + } + } + func_caller* func = nullptr; { std::lock_guard lock(m_funcs_lock); @@ -306,6 +318,7 @@ bool ModuleManager::CallFunc(u32 num) } } } + if (func) { (*func)(); @@ -362,6 +375,9 @@ void ModuleManager::UnloadModules() std::lock_guard lock(m_funcs_lock); m_modules_funcs_list.clear(); + + //unload pause list + m_funcs_pause_funcs.clear(); } Module* ModuleManager::GetModuleByName(const std::string& name) @@ -463,3 +479,34 @@ void ModuleManager::AddFunc(ModuleFunc *func) } } +//read pause.bin to get some function id that should auto-pause at call. +//you can make this file with Hex Editors, such as MadEdit.. +//you can find the function ids in \rpcs3\rpcs3\Emu\SysCalls\FuncList.cpp +//or just by searching the function name with grep within repo. +//Example if i want it to pause at 0x1051d134, i create the file with 34D15110(Hex, start from 00). +void ModuleManager::LoadFuncPauses(void) +{ + if (rExists("pause.bin")) + { + m_funcs_pause_funcs.reserve(16); + rFile list; + list.Open("pause.bin", rFile::read); + u32 num; + size_t fmax = list.Length(); + size_t fcur = 0; + list.Seek(0); + while (fcur <= fmax - sizeof(u32)) + { + list.Read(&num, sizeof(u32)); + fcur += sizeof(u32); + if (num == 0xFFFFFFFF) break; + m_funcs_pause_funcs.push_back(num); + LOG_WARNING(HLE, "Read Pause Function ID: %x", num); + } + list.Close(); + } + else + { + LOG_WARNING(HLE, "No Pause Function ID specified in pause.bin"); + } +} \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/ModuleManager.h b/rpcs3/Emu/SysCalls/ModuleManager.h index e4a85c9958..8b10ec24c7 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.h +++ b/rpcs3/Emu/SysCalls/ModuleManager.h @@ -10,6 +10,7 @@ class ModuleManager std::vector m_modules_funcs_list; std::vector m_mod_init; bool initialized; + std::vector m_funcs_pause_funcs; public: ModuleManager(); ~ModuleManager(); @@ -24,5 +25,5 @@ public: u32 GetFuncNumById(u32 id); Module* GetModuleByName(const std::string& name); Module* GetModuleById(u16 id); - + void LoadFuncPauses(void); }; \ No newline at end of file