Loader: Add Nso Header loading, loadset validation in CreateProcess

This commit is contained in:
Michael Scire 2018-04-23 20:05:22 -06:00
parent 16439fd336
commit 73b6225d2e
3 changed files with 176 additions and 2 deletions

View file

@ -5,40 +5,54 @@
#include "ldr_launch_queue.hpp"
#include "ldr_content_management.hpp"
#include "ldr_npdm.hpp"
#include "ldr_nso.hpp"
Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nca_path, LaunchQueue::LaunchItem *launch_item, u64 flags, Handle reslimit_h) {
NpdmUtils::NpdmInfo info;
Registration::Process *target_process;
Result rc;
/* Get the process from the registration queue. */
target_process = Registration::get_process(index);
if (target_process == NULL) {
return 0x1009;
}
/* Mount the title's exefs. */
rc = ContentManagement::MountCodeForTidSid(&target_process->tid_sid);
if (R_FAILED(rc)) {
return rc;
}
/* Load the process's NPDM. */
rc = NpdmUtils::LoadNpdmFromCache(target_process->tid_sid.title_id, &info);
if (R_FAILED(rc)) {
goto CREATE_PROCESS_END;
}
/* Validate the title we're loading is what we expect. */
if (info.aci0->title_id < info.acid->title_id_range_min || info.aci0->title_id > info.acid->title_id_range_max) {
rc = 0x1209;
goto CREATE_PROCESS_END;
}
/* Validate that the ACI0 Kernel Capabilities are valid and restricted by the ACID Kernel Capabilities. */
rc = NpdmUtils::ValidateCapabilities((u32 *)info.acid_kac, info.acid->kac_size/sizeof(u32), (u32 *)info.aci0_kac, info.aci0->kac_size/sizeof(u32));
if (R_FAILED(rc)) {
goto CREATE_PROCESS_END;
}
/* TODO: Read in all NSO headers, see what NSOs are present. */
/* Read in all NSO headers, see what NSOs are present. */
rc = NsoUtils::LoadNsoHeaders(info.aci0->title_id);
if (R_FAILED(rc)) {
goto CREATE_PROCESS_END;
}
/* TODO: Validate that the set of NSOs to be loaded is correct. */
/* Validate that the set of NSOs to be loaded is correct. */
rc = NsoUtils::ValidateNsoLoadSet();
if (R_FAILED(rc)) {
goto CREATE_PROCESS_END;
}
/* TODO: Create the CreateProcessInfo. */