VERY experimental Nintendo Switch 2 emulator
C++
loader: Use NPDM information when loading NSOs
shinyquagsire23013d8828a3b2
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cppindex 661803b5f1..83666eb86b 100644--- a/src/core/loader/deconstructed_rom_directory.cpp+++ b/src/core/loader/deconstructed_rom_directory.cpp@@ -53,6 +53,7 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileUtiFileType AppLoader_DeconstructedRomDirectory::IdentifyType(FileUtil::IOFile& file,const std::string& filepath) {bool is_main_found{};+ bool is_npdm_found{};bool is_rtld_found{};bool is_sdk_found{};@@ -67,6 +68,9 @@ FileType AppLoader_DeconstructedRomDirectory::IdentifyType(FileUtil::IOFile& fil// Verify filenameif (Common::ToLower(virtual_name) == "main") {is_main_found = true;+ } else if (Common::ToLower(virtual_name) == "main.npdm") {+ is_npdm_found = true;+ return true;} else if (Common::ToLower(virtual_name) == "rtld") {is_rtld_found = true;} else if (Common::ToLower(virtual_name) == "sdk") {@@ -83,14 +87,14 @@ FileType AppLoader_DeconstructedRomDirectory::IdentifyType(FileUtil::IOFile& fil}// We are done if we've found and verified all required NSOs- return !(is_main_found && is_rtld_found && is_sdk_found);+ return !(is_main_found && is_npdm_found && is_rtld_found && is_sdk_found);};// Search the directory recursively, looking for the required modulesconst std::string directory = filepath.substr(0, filepath.find_last_of("/\\")) + DIR_SEP;FileUtil::ForeachDirectoryEntry(nullptr, directory, callback);- if (is_main_found && is_rtld_found && is_sdk_found) {+ if (is_main_found && is_npdm_found && is_rtld_found && is_sdk_found) {return FileType::DeconstructedRomDirectory;}@@ -108,9 +112,13 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(process = Kernel::Process::Create("main");+ const std::string directory = filepath.substr(0, filepath.find_last_of("/\\")) + DIR_SEP;+ const std::string npdm_path = directory + DIR_SEP + "main.npdm";+ metadata.Load(npdm_path);+ metadata.Print();+// Load NSO modulesVAddr next_load_addr{Memory::PROCESS_IMAGE_VADDR};- const std::string directory = filepath.substr(0, filepath.find_last_of("/\\")) + DIR_SEP;for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3","subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) {const std::string path = directory + DIR_SEP + module;@@ -127,7 +135,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(process->address_mappings = default_address_mappings;process->resource_limit =Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);- process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Kernel::DEFAULT_STACK_SIZE);+ process->Run(Memory::PROCESS_IMAGE_VADDR, metadata.GetMainThreadPriority(),+ metadata.GetMainThreadStackSize());// Find the RomFS by searching for a ".romfs" file in this directoryfilepath_romfs = FindRomFS(directory);diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.hindex 536a2dab7e..23295d9111 100644--- a/src/core/loader/deconstructed_rom_directory.h+++ b/src/core/loader/deconstructed_rom_directory.h@@ -6,6 +6,7 @@#include <string>#include "common/common_types.h"+#include "core/file_sys/program_metadata.h"#include "core/hle/kernel/kernel.h"#include "core/loader/loader.h"@@ -41,6 +42,7 @@ public:private:std::string filepath_romfs;std::string filepath;+ FileSys::ProgramMetadata metadata;};} // namespace Loader