mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-07 13:39:55 +00:00
fix(libkernel_sys): return EFAULT on unwritable mode pointer in sceKernelGetCpumodeGame
This commit is contained in:
1 parent
88e804b0a7
commit
aa3af8f736
2 files changed
+3
-1
No files matched your search
@@ -385,7 +385,8 @@ int APS5_VABI sceKernelGetOpenPsIdForSystem(void* id) {
|
||||
|
||||
int APS5_VABI sceKernelGetCpumodeGame(int* mode) {
|
||||
if (mode == nullptr) throw std::runtime_error("sceKernelGetCpumodeGame: a null output faults on the console");
|
||||
*mode = g_gameCpumode.load(std::memory_order_relaxed);
|
||||
const int val = g_gameCpumode.load(std::memory_order_relaxed);
|
||||
if (!GuestCopyOut_nid_no_patch(mode, &val, sizeof(val))) return SCE_KERNEL_ERROR_EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ int main() {
|
||||
Require(Throws([] { sceKernelSetCpumodeGame(8); }), "an unmeasured mode did not throw");
|
||||
Require(Throws([] { sceKernelSetCpumodeGame(-1); }), "a negative mode did not throw");
|
||||
Require(Throws([] { sceKernelGetCpumodeGame(nullptr); }), "a null output did not throw");
|
||||
Require(sceKernelGetCpumodeGame(reinterpret_cast<int*>(0x10)) == static_cast<int>(0x8002000Eu), "unwritable mode did not return EFAULT");
|
||||
std::puts("game CPU mode tests passed");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user