mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-31 19:47:06 +01:00
HLE: Add sceKernelQueryLoadCoreCB
The firmware's semawm.prx (6.61), which PMP Mod and psp-me-bench load, decrypts code that walks LoadCore's registered-library hash buckets at the start of this block, looking for libraries a custom firmware would add. We don't keep those structures, so it gets an empty table in kernel memory, made on first use and kept in the savestate. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a51fe51055
commit
33b6229a6f
3 files changed
+29
-2
No files matched your search
@@ -152,6 +152,9 @@ static void UnexportFuncSymbol(const FuncSymbolExport &func);
|
||||
// Chinese-patch loaders (see sctrlHENSetStartModuleHandler below).
|
||||
static u32 g_startModuleHandler = 0;
|
||||
|
||||
// LoadCore's control block, for sceKernelQueryLoadCoreCB. Made on first use.
|
||||
static u32 g_loadCoreCB = 0;
|
||||
|
||||
static bool KernelImportModuleFuncs(PSPModule *module, u32 *firstImportStubAddr, bool reimporting = false);
|
||||
|
||||
// by QueryModuleInfo
|
||||
@@ -563,7 +566,7 @@ std::vector<std::pair<u32, u32>> __KernelModuleCodeRanges() {
|
||||
}
|
||||
|
||||
void __KernelModuleDoState(PointerWrap &p) {
|
||||
auto s = p.Section("sceKernelModule", 1, 6);
|
||||
auto s = p.Section("sceKernelModule", 1, 7);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
@@ -612,6 +615,12 @@ void __KernelModuleDoState(PointerWrap &p) {
|
||||
g_vshModuleStarting = 0;
|
||||
}
|
||||
|
||||
if (s >= 7) {
|
||||
Do(p, g_loadCoreCB);
|
||||
} else if (p.mode == p.MODE_READ) {
|
||||
g_loadCoreCB = 0;
|
||||
}
|
||||
|
||||
if (p.mode == p.MODE_READ) {
|
||||
u32 error;
|
||||
// We process these late, since they depend on loadedModules for interlinking.
|
||||
@@ -652,6 +661,7 @@ void __KernelModuleShutdown() {
|
||||
g_pendingModuleLoads.clear();
|
||||
g_vshModulesToStart.clear();
|
||||
g_vshModuleStarting = 0;
|
||||
g_loadCoreCB = 0;
|
||||
MIPSAnalyst::Reset();
|
||||
HLEPlugins::Unload();
|
||||
}
|
||||
@@ -3360,6 +3370,21 @@ u32 sceKernelFindModuleByUID(u32 uid)
|
||||
return hleLogInfo(Log::sceModule, module->modulePtr.ptr);
|
||||
}
|
||||
|
||||
// The firmware's semawm.prx walks the first 0x200 bytes, the registered libraries' 128 hash buckets,
|
||||
// for libraries a custom firmware adds (decrypted from semawm 6.61, run by PMP Mod and psp-me-bench).
|
||||
// We don't keep LoadCore's structures, so every bucket is empty.
|
||||
u32 sceKernelQueryLoadCoreCB() {
|
||||
if (!g_loadCoreCB) {
|
||||
u32 size = 0x400;
|
||||
const u32 addr = kernelMemory.Alloc(size, false, "LoadCoreCB");
|
||||
if (addr == (u32)-1)
|
||||
return hleLogError(Log::sceModule, 0, "out of kernel memory");
|
||||
Memory::Memset(addr, 0, size, "LoadCoreCB");
|
||||
g_loadCoreCB = addr;
|
||||
}
|
||||
return hleLogInfo(Log::sceModule, g_loadCoreCB);
|
||||
}
|
||||
|
||||
u32 sceKernelFindModuleByName(const char *name)
|
||||
{
|
||||
u32 error;
|
||||
|
||||
Reference in new issue
Block a user