shadPS4/src/core/libraries/sysmodule/sysmodule.h
Stephen Miller cc6af03adf
Lib.SysModule: Proper HLE implementation (#4102)
* Replace sysmodule enums with table

Dumped this from the 12.52 module, using a script I created.

* Better documentation

* Separate from system libraries

That system folder is going to be getting quite large if I left all the sysmodule stuff in there.

* More arrays from library

* Found another preload list

Ghidra really hates decompiling libSceSysmodule, so I didn't notice this one at first.
Also documented specific versions tied to each preload list.

* Start work on implementation

* Some basic implementations

* Initial stub for module loading

Just enough to see if the logic functions appropriately.

* Clang

* sceSysmoduleLoadModule

Now I need to get sceSysmodulePreloadModuleForLibkernel done so that we don't have bugs from not loading internal LLEs.

* sceSysmoduleLoadModuleInternal

* sceSysmodulePreloadModuleForLibkernel

I have successfully broken quite literally everything.
I shall debug this tomorrow.

* Slight fix

* Maybe fix?

* Change log

Enjoy the log spam 😄

* Increased defined stub count

Now that libc and libSceLibcInternal loads later, all the auto stubs are getting consumed by it.

* sceSysmoduleUnloadModule stub

Also a couple fixes. Sysmodule does pass argc and argv to game modules, but only after loading them once to check  binaries.
Shouldn't matter for the most part.

* Clang

* Less stubs

2 thousand is seemingly enough.

* sceSysmoduleLoadModuleInternalWithArg

Doesn't hurt to have, since Apex Legends calls it.

* Oops

* Oops 2

* Rename isModuleLoaded to getModuleHandle

Review comment

* Remove debug game module loads

These cases only trigger when specific sceRegMgr key values are set, and for our purposes, we can treat that case as false.

* Allow preloading to fail

For kalaposfos

* Clang
2026-03-08 21:48:03 +02:00

39 lines
1.6 KiB
C++

// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/types.h"
#include "core/libraries/kernel/process.h"
namespace Core::Loader {
class SymbolsResolver;
}
namespace Libraries::SysModule {
using OrbisSysModule = u16;
using OrbisSysModuleInternal = u32;
s32 PS4_SYSV_ABI sceSysmoduleGetModuleHandleInternal(OrbisSysModuleInternal id, s32* handle);
s32 PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind(VAddr addr, s32 flags,
Kernel::OrbisModuleInfoForUnwind* info);
s32 PS4_SYSV_ABI sceSysmoduleIsCalledFromSysModule();
s32 PS4_SYSV_ABI sceSysmoduleIsCameraPreloaded();
s32 PS4_SYSV_ABI sceSysmoduleIsLoaded(OrbisSysModule id);
s32 PS4_SYSV_ABI sceSysmoduleIsLoadedInternal(OrbisSysModuleInternal id);
s32 PS4_SYSV_ABI sceSysmoduleLoadModule(OrbisSysModule id);
s32 PS4_SYSV_ABI sceSysmoduleLoadModuleByNameInternal();
s32 PS4_SYSV_ABI sceSysmoduleLoadModuleInternal(OrbisSysModuleInternal id);
s32 PS4_SYSV_ABI sceSysmoduleLoadModuleInternalWithArg(OrbisSysModuleInternal id, s32 argc,
const void* argv, u64 unk, s32* res_out);
s32 PS4_SYSV_ABI sceSysmoduleMapLibcForLibkernel();
s32 PS4_SYSV_ABI sceSysmodulePreloadModuleForLibkernel();
s32 PS4_SYSV_ABI sceSysmoduleUnloadModule(OrbisSysModule id);
s32 PS4_SYSV_ABI sceSysmoduleUnloadModuleByNameInternal();
s32 PS4_SYSV_ABI sceSysmoduleUnloadModuleInternal();
s32 PS4_SYSV_ABI sceSysmoduleUnloadModuleInternalWithArg();
void RegisterLib(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::SysModule