mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-14 11:07:52 +01:00
Stratosphere: Skeleton create process up through the ProcessCreation::CreateProcess() call
This commit is contained in:
parent
878d68f7e0
commit
6a51ce25b3
@ -71,3 +71,12 @@ void LaunchQueue::clear() {
|
||||
g_launch_queue[i].tid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LaunchQueue::LaunchItem *LaunchQueue::get_item(u64 tid) {
|
||||
int idx;
|
||||
if ((idx = get_index(tid)) == LAUNCH_QUEUE_FULL) {
|
||||
return NULL;
|
||||
}
|
||||
return &g_launch_queue[idx];
|
||||
}
|
@ -14,6 +14,8 @@ class LaunchQueue {
|
||||
char args[LAUNCH_QUEUE_ARG_SIZE_MAX];
|
||||
};
|
||||
|
||||
static LaunchQueue::LaunchItem *get_item(u64 tid);
|
||||
|
||||
static Result add(u64 tid, const char *args, u64 arg_size);
|
||||
static Result add_item(const LaunchItem *item);
|
||||
static Result add_copy(u64 tid_base, u64 new_tid);
|
||||
|
13
stratosphere/loader/source/ldr_process_creation.cpp
Normal file
13
stratosphere/loader/source/ldr_process_creation.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
|
||||
#include "ldr_process_creation.hpp"
|
||||
#include "ldr_registration.hpp"
|
||||
#include "ldr_launch_queue.hpp"
|
||||
#include "ldr_content_management.hpp"
|
||||
#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;
|
||||
}
|
12
stratosphere/loader/source/ldr_process_creation.hpp
Normal file
12
stratosphere/loader/source/ldr_process_creation.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
|
||||
#include "ldr_registration.hpp"
|
||||
#include "ldr_launch_queue.hpp"
|
||||
|
||||
/* Utilities for Process Creation, for Loader. */
|
||||
|
||||
class ProcessCreation {
|
||||
public:
|
||||
static Result CreateProcess(Handle *out_process_h, u64 index, char *nca_path, LaunchQueue::LaunchItem *launch_item, u64 flags, Handle reslimit_h);
|
||||
};
|
@ -28,10 +28,30 @@ Result ProcessManagerService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u
|
||||
return rc;
|
||||
}
|
||||
|
||||
std::tuple<Result, MovedHandle> ProcessManagerService::create_process(u64 flags, u64 title_id, CopiedHandle reslimit_h) {
|
||||
/* TODO */
|
||||
fprintf(stderr, "CreateProcess(%016lx, %016lx, %08x);\n", flags, title_id, reslimit_h.handle);
|
||||
return std::make_tuple(0xF601, MovedHandle{0x00});
|
||||
std::tuple<Result, MovedHandle> ProcessManagerService::create_process(u64 flags, u64 index, CopiedHandle reslimit_h) {
|
||||
Result rc;
|
||||
Registration::TidSid tid_sid;
|
||||
LaunchQueue::LaunchItem *launch_item;
|
||||
char nca_path[FS_MAX_PATH] = {0};
|
||||
Handle process_h = 0;
|
||||
|
||||
fprintf(stderr, "CreateProcess(%016lx, %016lx, %08x);\n", flags, index, reslimit_h.handle);
|
||||
|
||||
rc = Registration::get_registered_tid_sid(index, &tid_sid);
|
||||
if (R_FAILED(rc)) {
|
||||
std::make_tuple(rc, MovedHandle{process_h});
|
||||
}
|
||||
|
||||
rc = ContentManagement::GetContentPathForTidSid(nca_path, &tid_sid);
|
||||
if (R_FAILED(rc)) {
|
||||
std::make_tuple(rc, MovedHandle{process_h});
|
||||
}
|
||||
|
||||
launch_item = LaunchQueue::get_item(tid_sid.title_id);
|
||||
|
||||
rc = ProcessCreation::CreateProcess(&process_h, index, nca_path, launch_item, flags, reslimit_h.handle);
|
||||
|
||||
return std::make_tuple(rc, MovedHandle{process_h});
|
||||
}
|
||||
|
||||
std::tuple<Result> ProcessManagerService::get_program_info(Registration::TidSid tid_sid, OutPointerWithServerSize<ProcessManagerService::ProgramInfo, 0x1> out_program_info) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "iserviceobject.hpp"
|
||||
#include "ldr_registration.hpp"
|
||||
#include "ldr_process_creation.hpp"
|
||||
|
||||
enum ProcessManagerServiceCmd {
|
||||
Pm_Cmd_CreateProcess = 0,
|
||||
@ -32,7 +33,7 @@ class ProcessManagerService : IServiceObject {
|
||||
|
||||
private:
|
||||
/* Actual commands. */
|
||||
std::tuple<Result, MovedHandle> create_process(u64 flags, u64 title_id, CopiedHandle reslimit_h);
|
||||
std::tuple<Result, MovedHandle> create_process(u64 flags, u64 index, CopiedHandle reslimit_h);
|
||||
std::tuple<Result> get_program_info(Registration::TidSid tid_sid, OutPointerWithServerSize<ProcessManagerService::ProgramInfo, 0x1> out_program_info);
|
||||
std::tuple<Result, u64> register_title(Registration::TidSid tid_sid);
|
||||
std::tuple<Result> unregister_title(u64 index);
|
||||
|
@ -63,6 +63,18 @@ bool Registration::unregister_index(u64 index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Result Registration::get_registered_tid_sid(u64 index, Registration::TidSid *out) {
|
||||
Registration::Process *target_process = get_process(index);
|
||||
if (target_process == NULL) {
|
||||
return 0x1009;
|
||||
}
|
||||
|
||||
*out = target_process->tid_sid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Registration::set_process_id_and_tid_min(u64 index, u64 process_id, u64 tid_min) {
|
||||
Registration::Process *target_process = get_process(index);
|
||||
if (target_process == NULL) {
|
||||
|
@ -41,6 +41,7 @@ class Registration {
|
||||
static Registration::Process *get_free_process();
|
||||
static Registration::Process *get_process(u64 index);
|
||||
static Registration::Process *get_process_by_process_id(u64 pid);
|
||||
static Result get_registered_tid_sid(u64 index, Registration::TidSid *out);
|
||||
static bool register_tid_sid(const TidSid *tid_sid, u64 *out_index);
|
||||
static bool unregister_index(u64 index);
|
||||
static void set_process_id_and_tid_min(u64 index, u64 process_id, u64 tid_min);
|
||||
|
Loading…
Reference in New Issue
Block a user