fix(libkernel): apply the memory type in sceKernelMemoryPoolBatch type-protect entries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
This commit is contained in:
Claude 2026-10-11 20:58:50 +00:00
parent 0a8b1d32b1
commit 29af23e718
No known key found for this signature in database
2 changed files with 12 additions and 1 deletions

View File

@ -70,7 +70,7 @@ int APS5_VABI sceKernelMemoryPoolBatch(const KernelMemoryPoolBatchEntry* entries
case 1: return PoolCommit(e.commit.addr, e.commit.len, e.commit.prot);
case 2: return PoolDecommit(e.decommit.addr, e.decommit.len);
case 3: return DoMprotect(e.protect.addr, static_cast<size_t>(e.protect.len), e.protect.prot);
case 4: return DoMprotect(e.type_protect.addr, static_cast<size_t>(e.type_protect.len), e.type_protect.prot);
case 4: return DoMtypeprotect(e.type_protect.addr, static_cast<size_t>(e.type_protect.len), e.type_protect.type, e.type_protect.prot);
default: return SCE_KERNEL_ERROR_EINVAL;
}
});

View File

@ -53,6 +53,7 @@ int APS5_VABI sceKernelReleaseFlexibleMemory(void*, std::size_t);
int APS5_VABI sceKernelMprotect(const void*, std::size_t, int);
int APS5_VABI sceKernelMtypeprotect(const void*, std::size_t, int, int);
int APS5_VABI sceKernelBatchMap2(KernelBatchMapEntry*, int, int*, int);
int APS5_VABI sceKernelMemoryPoolBatch(const KernelMemoryPoolBatchEntry*, int, int*, int);
int APS5_VABI sceKernelVirtualQuery(const void*, int, VirtualQueryInfo*, std::uint64_t);
int APS5_VABI sceKernelSetVirtualRangeName(const void*, std::uint64_t, const char*);
int APS5_VABI sceKernelClearVirtualRangeName(const void*, std::uint64_t);
@ -421,6 +422,16 @@ static void CheckMtypeprotect() {
check(0, 0, 3);
check(1, 3, 1);
check(2, 5, 3);
KernelMemoryPoolBatchEntry poolEntry{};
poolEntry.op = 4;
poolEntry.type_protect.addr = bytes + page * 2;
poolEntry.type_protect.len = page;
poolEntry.type_protect.prot = 1;
poolEntry.type_protect.type = 4;
processed = -1;
Require(sceKernelMemoryPoolBatch(&poolEntry, 1, &processed, 0) == 0 && processed == 1);
check(1, 3, 1);
check(2, 4, 1);
Require(sceKernelMtypeprotect(bytes, page * 3, 2, 3) == 0);
VirtualQueryInfo whole{};
Require(sceKernelVirtualQuery(bytes, 0, &whole, sizeof(whole)) == 0);