mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-29 23:32:23 +00:00
Loader: Add NRRInfo to RegisteredProcess, refactor Registration::
This commit is contained in:
parent
977a51edb0
commit
991357f309
5 changed files with 45 additions and 31 deletions
|
@ -41,7 +41,7 @@ std::tuple<Result, u32> DebugMonitorService::get_nso_info(u64 pid, OutPointerWit
|
|||
|
||||
std::fill(out.pointer, out.pointer + out.num_elements, (const Registration::NsoInfo){0});
|
||||
|
||||
Result rc = Registration::get_nso_infos_for_process_id(out.pointer, out.num_elements, pid, &out_num_nsos);
|
||||
Result rc = Registration::GetNsoInfosForProcessId(out.pointer, out.num_elements, pid, &out_num_nsos);
|
||||
|
||||
return std::make_tuple(rc, out_num_nsos);
|
||||
}
|
|
@ -96,7 +96,7 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
|
|||
Result rc;
|
||||
|
||||
/* Get the process from the registration queue. */
|
||||
target_process = Registration::get_process(index);
|
||||
target_process = Registration::GetProcess(index);
|
||||
if (target_process == NULL) {
|
||||
return 0x1009;
|
||||
}
|
||||
|
@ -180,10 +180,10 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
|
|||
} else {
|
||||
is_64_bit_addspace = (npdm_info.header->mmu_flags & 0xE) == 0x2;
|
||||
}
|
||||
Registration::set_process_id_tid_min_and_is_64_bit_addspace(index, process_id, npdm_info.aci0->title_id, is_64_bit_addspace);
|
||||
Registration::SetProcessIdTidMinAndIs64BitAddressSpace(index, process_id, npdm_info.aci0->title_id, is_64_bit_addspace);
|
||||
for (unsigned int i = 0; i < NSO_NUM_MAX; i++) {
|
||||
if (NsoUtils::IsNsoPresent(i)) {
|
||||
Registration::add_nso_info(index, nso_extents.nso_addresses[i], nso_extents.nso_sizes[i], NsoUtils::GetNsoBuildId(i));
|
||||
Registration::AddNsoInfo(index, nso_extents.nso_addresses[i], nso_extents.nso_sizes[i], NsoUtils::GetNsoBuildId(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ std::tuple<Result, MovedHandle> ProcessManagerService::create_process(u64 flags,
|
|||
|
||||
fprintf(stderr, "CreateProcess(%016lx, %016lx, %08x);\n", flags, index, reslimit_h.handle);
|
||||
|
||||
rc = Registration::get_registered_tid_sid(index, &tid_sid);
|
||||
rc = Registration::GetRegisteredTidSid(index, &tid_sid);
|
||||
if (R_FAILED(rc)) {
|
||||
std::make_tuple(rc, MovedHandle{process_h});
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ std::tuple<Result> ProcessManagerService::get_program_info(Registration::TidSid
|
|||
|
||||
std::tuple<Result, u64> ProcessManagerService::register_title(Registration::TidSid tid_sid) {
|
||||
u64 out_index = 0;
|
||||
if (Registration::register_tid_sid(&tid_sid, &out_index)) {
|
||||
if (Registration::RegisterTidSid(&tid_sid, &out_index)) {
|
||||
return std::make_tuple(0, out_index);
|
||||
} else {
|
||||
return std::make_tuple(0xE09, out_index);
|
||||
|
@ -93,7 +93,7 @@ std::tuple<Result, u64> ProcessManagerService::register_title(Registration::TidS
|
|||
}
|
||||
|
||||
std::tuple<Result> ProcessManagerService::unregister_title(u64 index) {
|
||||
if (Registration::unregister_index(index)) {
|
||||
if (Registration::UnregisterIndex(index)) {
|
||||
return std::make_tuple(0);
|
||||
} else {
|
||||
return std::make_tuple(0x1009);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
static Registration::List g_registration_list = {0};
|
||||
static u64 g_num_registered = 1;
|
||||
|
||||
Registration::Process *Registration::get_free_process() {
|
||||
Registration::Process *Registration::GetFreeProcess() {
|
||||
unsigned int i;
|
||||
for (i = 0; i < REGISTRATION_LIST_MAX; i++) {
|
||||
if (!g_registration_list.processes[i].in_use) {
|
||||
|
@ -16,7 +16,7 @@ Registration::Process *Registration::get_free_process() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Registration::Process *Registration::get_process(u64 index) {
|
||||
Registration::Process *Registration::GetProcess(u64 index) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < REGISTRATION_LIST_MAX && (!g_registration_list.processes[i].in_use || g_registration_list.processes[i].index != index); i++) {
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ Registration::Process *Registration::get_process(u64 index) {
|
|||
return &g_registration_list.processes[i];
|
||||
}
|
||||
|
||||
Registration::Process *Registration::get_process_by_process_id(u64 pid) {
|
||||
Registration::Process *Registration::GetProcessByProcessId(u64 pid) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < REGISTRATION_LIST_MAX && (!g_registration_list.processes[i].in_use || g_registration_list.processes[i].process_id != pid); i++) {
|
||||
|
||||
|
@ -37,8 +37,8 @@ Registration::Process *Registration::get_process_by_process_id(u64 pid) {
|
|||
return &g_registration_list.processes[i];
|
||||
}
|
||||
|
||||
bool Registration::register_tid_sid(const TidSid *tid_sid, u64 *out_index) {
|
||||
Registration::Process *free_process = get_free_process();
|
||||
bool Registration::RegisterTidSid(const TidSid *tid_sid, u64 *out_index) {
|
||||
Registration::Process *free_process = GetFreeProcess();
|
||||
if (free_process == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ bool Registration::register_tid_sid(const TidSid *tid_sid, u64 *out_index) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Registration::unregister_index(u64 index) {
|
||||
Registration::Process *target_process = get_process(index);
|
||||
bool Registration::UnregisterIndex(u64 index) {
|
||||
Registration::Process *target_process = GetProcess(index);
|
||||
if (target_process == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ bool Registration::unregister_index(u64 index) {
|
|||
}
|
||||
|
||||
|
||||
Result Registration::get_registered_tid_sid(u64 index, Registration::TidSid *out) {
|
||||
Registration::Process *target_process = get_process(index);
|
||||
Result Registration::GetRegisteredTidSid(u64 index, Registration::TidSid *out) {
|
||||
Registration::Process *target_process = GetProcess(index);
|
||||
if (target_process == NULL) {
|
||||
return 0x1009;
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ Result Registration::get_registered_tid_sid(u64 index, Registration::TidSid *out
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Registration::set_process_id_tid_min_and_is_64_bit_addspace(u64 index, u64 process_id, u64 tid_min, bool is_64_bit_addspace) {
|
||||
Registration::Process *target_process = get_process(index);
|
||||
void Registration::SetProcessIdTidMinAndIs64BitAddressSpace(u64 index, u64 process_id, u64 tid_min, bool is_64_bit_addspace) {
|
||||
Registration::Process *target_process = GetProcess(index);
|
||||
if (target_process == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ void Registration::set_process_id_tid_min_and_is_64_bit_addspace(u64 index, u64
|
|||
target_process->is_64_bit_addspace = is_64_bit_addspace;
|
||||
}
|
||||
|
||||
void Registration::add_nso_info(u64 index, u64 base_address, u64 size, const unsigned char *build_id) {
|
||||
Registration::Process *target_process = get_process(index);
|
||||
void Registration::AddNsoInfo(u64 index, u64 base_address, u64 size, const unsigned char *build_id) {
|
||||
Registration::Process *target_process = GetProcess(index);
|
||||
if (target_process == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ void Registration::add_nso_info(u64 index, u64 base_address, u64 size, const uns
|
|||
}
|
||||
|
||||
|
||||
Result Registration::get_nso_infos_for_process_id(Registration::NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written) {
|
||||
Registration::Process *target_process = get_process_by_process_id(process_id);
|
||||
Result Registration::GetNsoInfosForProcessId(Registration::NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written) {
|
||||
Registration::Process *target_process = GetProcessByProcessId(process_id);
|
||||
if (target_process == NULL) {
|
||||
return 0x1009;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#define REGISTRATION_LIST_MAX (0x40)
|
||||
|
||||
#define NSO_INFO_MAX (0x20)
|
||||
#define NRR_INFO_MAX (0x40)
|
||||
|
||||
class Registration {
|
||||
public:
|
||||
|
@ -18,6 +19,18 @@ class Registration {
|
|||
NsoInfo info;
|
||||
};
|
||||
|
||||
struct NrrInfo {
|
||||
u64 base_address;
|
||||
u64 size;
|
||||
u64 code_memory_address;
|
||||
u64 address_for_loader;
|
||||
};
|
||||
|
||||
struct NrrInfoHolder {
|
||||
bool in_use;
|
||||
NrrInfo info;
|
||||
};
|
||||
|
||||
struct TidSid {
|
||||
u64 title_id;
|
||||
FsStorageId storage_id;
|
||||
|
@ -31,6 +44,7 @@ class Registration {
|
|||
u64 title_id_min;
|
||||
Registration::TidSid tid_sid;
|
||||
Registration::NsoInfoHolder nso_infos[NSO_INFO_MAX];
|
||||
Registration::NrrInfoHolder nrr_infos[NRR_INFO_MAX];
|
||||
u64 _0x730;
|
||||
};
|
||||
|
||||
|
@ -39,13 +53,13 @@ class Registration {
|
|||
u64 num_processes;
|
||||
};
|
||||
|
||||
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_tid_min_and_is_64_bit_addspace(u64 index, u64 process_id, u64 tid_min, bool is_64_bit_addspace);
|
||||
static void add_nso_info(u64 index, u64 base_address, u64 size, const unsigned char *build_id);
|
||||
static Result get_nso_infos_for_process_id(NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written);
|
||||
static Registration::Process *GetFreeProcess();
|
||||
static Registration::Process *GetProcess(u64 index);
|
||||
static Registration::Process *GetProcessByProcessId(u64 pid);
|
||||
static Result GetRegisteredTidSid(u64 index, Registration::TidSid *out);
|
||||
static bool RegisterTidSid(const TidSid *tid_sid, u64 *out_index);
|
||||
static bool UnregisterIndex(u64 index);
|
||||
static void SetProcessIdTidMinAndIs64BitAddressSpace(u64 index, u64 process_id, u64 tid_min, bool is_64_bit_addspace);
|
||||
static void AddNsoInfo(u64 index, u64 base_address, u64 size, const unsigned char *build_id);
|
||||
static Result GetNsoInfosForProcessId(NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue