Libraries: Implement sceKernelIsInSandbox, update OrbisSysModule enum (#3546)

* Implement sceKernelIsInSandbox

libSceSysmodule uses this to determine if it should use sceKernelGetFsSandboxRandomWord or just hardcode "system" for retrieving modules.
Also changes some function types to use our types.

* Update OrbisSysModule enum

Adds missing values based on library testing.

* Clang
This commit is contained in:
Stephen Miller
2025-09-07 15:11:15 -05:00
committed by GitHub
parent d34ae8ce08
commit b5d8426db7
4 changed files with 109 additions and 84 deletions

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/config.h"
@@ -12,18 +12,22 @@
namespace Libraries::Kernel {
int PS4_SYSV_ABI sceKernelIsNeoMode() {
s32 PS4_SYSV_ABI sceKernelIsInSandbox() {
return 1;
}
s32 PS4_SYSV_ABI sceKernelIsNeoMode() {
return Config::isNeoModeConsole() &&
Common::ElfInfo::Instance().GetPSFAttributes().support_neo_mode;
}
int PS4_SYSV_ABI sceKernelGetCompiledSdkVersion(int* ver) {
int version = Common::ElfInfo::Instance().RawFirmwareVer();
s32 PS4_SYSV_ABI sceKernelGetCompiledSdkVersion(s32* ver) {
s32 version = Common::ElfInfo::Instance().RawFirmwareVer();
*ver = version;
return (version >= 0) ? ORBIS_OK : ORBIS_KERNEL_ERROR_EINVAL;
}
int PS4_SYSV_ABI sceKernelGetCpumode() {
s32 PS4_SYSV_ABI sceKernelGetCpumode() {
return 0;
}
@@ -33,7 +37,7 @@ void* PS4_SYSV_ABI sceKernelGetProcParam() {
}
s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, u64 args, const void* argp,
u32 flags, const void* pOpt, int* pRes) {
u32 flags, const void* pOpt, s32* pRes) {
LOG_INFO(Lib_Kernel, "called filename = {}, args = {}", moduleFileName, args);
ASSERT(flags == 0);
@@ -201,6 +205,7 @@ s32 PS4_SYSV_ABI exit(s32 status) {
}
void RegisterProcess(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("xeu-pV8wkKs", "libkernel", 1, "libkernel", 1, 1, sceKernelIsInSandbox);
LIB_FUNCTION("WB66evu8bsU", "libkernel", 1, "libkernel", 1, 1, sceKernelGetCompiledSdkVersion);
LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, sceKernelIsNeoMode);
LIB_FUNCTION("VOx8NGmHXTs", "libkernel", 1, "libkernel", 1, 1, sceKernelGetCpumode);

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -11,7 +11,7 @@ class SymbolsResolver;
namespace Libraries::Kernel {
static constexpr size_t ORBIS_DBG_MAX_NAME_LENGTH = 256;
static constexpr u64 ORBIS_DBG_MAX_NAME_LENGTH = 256;
struct OrbisModuleInfoForUnwind {
u64 st_size;
@@ -23,9 +23,9 @@ struct OrbisModuleInfoForUnwind {
u64 seg0_size;
};
int PS4_SYSV_ABI sceKernelIsNeoMode();
s32 PS4_SYSV_ABI sceKernelIsNeoMode();
int PS4_SYSV_ABI sceKernelGetCompiledSdkVersion(int* ver);
s32 PS4_SYSV_ABI sceKernelGetCompiledSdkVersion(s32* ver);
s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, s32 flags,
OrbisModuleInfoForUnwind* info);