loader: Use NPDM information when loading NSOs
This commit is contained in:
parent
2b28fd7809
commit
fd3806fd30
@ -53,6 +53,7 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileUti
|
||||
FileType 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 filename
|
||||
if (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 modules
|
||||
const 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 modules
|
||||
VAddr 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 directory
|
||||
filepath_romfs = FindRomFS(directory);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user