1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-09-20 14:03:25 +01:00

Stratosphere: Make TODOs for Loader::CreateProcess().

This commit is contained in:
Michael Scire 2018-04-23 13:33:56 -06:00
parent 0075a42d39
commit 0e11788e43
3 changed files with 60 additions and 2 deletions

View file

@ -6,6 +6,13 @@
static NpdmUtils::NpdmCache g_npdm_cache = {0};
Result NpdmUtils::LoadNpdmFromCache(u64 tid, NpdmInfo *out) {
if (g_npdm_cache.info.title_id != tid) {
return LoadNpdm(tid, out);
}
*out = g_npdm_cache.info;
return 0;
}
Result NpdmUtils::LoadNpdm(u64 tid, NpdmInfo *out) {
Result rc;

View file

@ -78,4 +78,5 @@ class NpdmUtils {
static_assert(sizeof(NpdmAci0) == 0x40, "Incorrectly defined NpdmAci0!");
static Result LoadNpdm(u64 tid, NpdmInfo *out);
static Result LoadNpdmFromCache(u64 tid, NpdmInfo *out);
};

View file

@ -7,6 +7,56 @@
#include "ldr_npdm.hpp"
Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nca_path, LaunchQueue::LaunchItem *launch_item, u64 flags, Handle reslimit_h) {
/* TODO */
return 0xA09;
NpdmUtils::NpdmInfo info;
Registration::Process *target_process;
Result rc;
target_process = Registration::get_process(index);
if (target_process == NULL) {
return 0x1009;
}
rc = ContentManagement::MountCodeForTidSid(&target_process->tid_sid);
if (R_FAILED(rc)) {
return rc;
}
rc = NpdmUtils::LoadNpdmFromCache(target_process->tid_sid.title_id, &info);
if (R_FAILED(rc)) {
goto CREATE_PROCESS_END;
}
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;
}
/* TODO: Parse and verify ACI0 kernel caps vs ACID kernel caps. */
/* TODO: Read in all NSO headers, see what NSOs are present. */
/* TODO: Validate that the set of NSOs to be loaded is correct. */
/* TODO: Create the CreateProcessInfo. */
/* TODO: Figure out where NSOs will be mapped, and how much space they (and arguments) will take up. */
/* TODO: Call svcCreateProcessInfo(). */
/* TODO: For each NSO, call svcMapProcessMemory, load the NSO into memory there (validating it), and then svcUnmapProcessMemory. */
/* TODO: svcSetProcessMemoryPermission for each memory segment in the new process. */
/* TODO: Map and load arguments to the process, if relevant. */
/* TODO: Update the list of registered processes with the new process. */
rc = 0;
CREATE_PROCESS_END:
if (R_SUCCEEDED(rc)) {
rc = ContentManagement::UnmountCode();
} else {
ContentManagement::UnmountCode();
}
return rc;
}