mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-06-02 12:45:46 -06:00
Load custom modules stored in custom_modules/<gameid> (#4440)
* Load custom modules stored in custom_modules/<gameid> * Fix formatting
This commit is contained in:
parent
e9cbc02c01
commit
482d17c6e1
@ -131,6 +131,7 @@ static auto UserPaths = [] {
|
|||||||
create_path(PathType::CacheDir, user_dir / CACHE_DIR);
|
create_path(PathType::CacheDir, user_dir / CACHE_DIR);
|
||||||
create_path(PathType::FontsDir, user_dir / FONTS_DIR);
|
create_path(PathType::FontsDir, user_dir / FONTS_DIR);
|
||||||
create_path(PathType::HomeDir, user_dir / HOME_DIR);
|
create_path(PathType::HomeDir, user_dir / HOME_DIR);
|
||||||
|
create_path(PathType::CustomModulesDir, user_dir / CUSTOM_MODULES_DIR);
|
||||||
|
|
||||||
std::ofstream notice_file(user_dir / CUSTOM_TROPHY / "Notice.txt");
|
std::ofstream notice_file(user_dir / CUSTOM_TROPHY / "Notice.txt");
|
||||||
if (notice_file.is_open()) {
|
if (notice_file.is_open()) {
|
||||||
|
|||||||
@ -10,23 +10,24 @@
|
|||||||
namespace Common::FS {
|
namespace Common::FS {
|
||||||
|
|
||||||
enum class PathType {
|
enum class PathType {
|
||||||
UserDir, // Where shadPS4 stores its data.
|
UserDir, // Where shadPS4 stores its data.
|
||||||
LogDir, // Where log files are stored.
|
LogDir, // Where log files are stored.
|
||||||
ScreenshotsDir, // Where screenshots are stored.
|
ScreenshotsDir, // Where screenshots are stored.
|
||||||
ShaderDir, // Where shaders are stored.
|
ShaderDir, // Where shaders are stored.
|
||||||
TempDataDir, // Where game temp data is stored.
|
TempDataDir, // Where game temp data is stored.
|
||||||
GameDataDir, // Where game data is stored.
|
GameDataDir, // Where game data is stored.
|
||||||
SysModuleDir, // Where system modules are stored.
|
SysModuleDir, // Where system modules are stored.
|
||||||
DownloadDir, // Where downloads/temp files are stored.
|
DownloadDir, // Where downloads/temp files are stored.
|
||||||
CapturesDir, // Where rdoc captures are stored.
|
CapturesDir, // Where rdoc captures are stored.
|
||||||
CheatsDir, // Where cheats are stored.
|
CheatsDir, // Where cheats are stored.
|
||||||
PatchesDir, // Where patches are stored.
|
PatchesDir, // Where patches are stored.
|
||||||
MetaDataDir, // Where game metadata (e.g. trophies and menu backgrounds) is stored.
|
MetaDataDir, // Where game metadata (e.g. trophies and menu backgrounds) is stored.
|
||||||
CustomTrophy, // Where custom files for trophies are stored.
|
CustomTrophy, // Where custom files for trophies are stored.
|
||||||
CustomConfigs, // Where custom files for different games are stored.
|
CustomConfigs, // Where custom files for different games are stored.
|
||||||
CacheDir, // Where pipeline and shader cache is stored.
|
CacheDir, // Where pipeline and shader cache is stored.
|
||||||
FontsDir, // Where dumped system fonts are stored.
|
FontsDir, // Where dumped system fonts are stored.
|
||||||
HomeDir, // PS4 home directory
|
HomeDir, // PS4 home directory
|
||||||
|
CustomModulesDir // Where custom modules are stored.
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr auto PORTABLE_DIR = "user";
|
constexpr auto PORTABLE_DIR = "user";
|
||||||
@ -48,6 +49,7 @@ constexpr auto CUSTOM_CONFIGS = "custom_configs";
|
|||||||
constexpr auto CACHE_DIR = "cache";
|
constexpr auto CACHE_DIR = "cache";
|
||||||
constexpr auto FONTS_DIR = "fonts";
|
constexpr auto FONTS_DIR = "fonts";
|
||||||
constexpr auto HOME_DIR = "home";
|
constexpr auto HOME_DIR = "home";
|
||||||
|
constexpr auto CUSTOM_MODULES_DIR = "custom_modules";
|
||||||
|
|
||||||
// Filenames
|
// Filenames
|
||||||
constexpr auto LOG_FILE = "shad_log.txt";
|
constexpr auto LOG_FILE = "shad_log.txt";
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "common/arch.h"
|
#include "common/arch.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/elf_info.h"
|
#include "common/elf_info.h"
|
||||||
|
#include "common/logging/formatter.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
@ -125,6 +126,24 @@ void Linker::Execute(const std::vector<std::string>& args) {
|
|||||||
// Have libSceSysmodule preload our libraries.
|
// Have libSceSysmodule preload our libraries.
|
||||||
Libraries::SysModule::sceSysmodulePreloadModuleForLibkernel();
|
Libraries::SysModule::sceSysmodulePreloadModuleForLibkernel();
|
||||||
|
|
||||||
|
// Load and start custom modules from the user directory.
|
||||||
|
std::string_view id = Common::ElfInfo::Instance().GameSerial();
|
||||||
|
const auto& custom_mod_directory =
|
||||||
|
Common::FS::GetUserPath(Common::FS::PathType::CustomModulesDir) / id;
|
||||||
|
if (!std::filesystem::exists(custom_mod_directory)) {
|
||||||
|
std::filesystem::create_directory(custom_mod_directory);
|
||||||
|
}
|
||||||
|
for (const auto& entry : std::filesystem::directory_iterator(custom_mod_directory)) {
|
||||||
|
if (entry.is_regular_file()) {
|
||||||
|
LOG_INFO(Core_Linker, "Loading custom module: {}",
|
||||||
|
fmt::UTF(entry.path().u8string()));
|
||||||
|
if (LoadAndStartModule(entry.path(), 0, nullptr, nullptr) == -1) {
|
||||||
|
LOG_ERROR(Core_Linker, "Failed to load custom module: {}",
|
||||||
|
fmt::UTF(entry.path().u8string()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Simulate libSceGnmDriver initialization, which maps a chunk of direct memory.
|
// Simulate libSceGnmDriver initialization, which maps a chunk of direct memory.
|
||||||
// Some games fail without accurately emulating this behavior.
|
// Some games fail without accurately emulating this behavior.
|
||||||
s64 phys_addr{};
|
s64 phys_addr{};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user