Loader: Save process->is_64_bit as prep for ldr:ro

This commit is contained in:
Michael Scire 2018-04-26 14:51:07 -06:00
parent ea609e68d3
commit 82d9728372
3 changed files with 11 additions and 3 deletions

View File

@ -174,7 +174,13 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
/* Update the list of registered processes with the new process. */ /* Update the list of registered processes with the new process. */
svcGetProcessId(&process_id, process_h); svcGetProcessId(&process_id, process_h);
Registration::set_process_id_and_tid_min(index, process_id, npdm_info.aci0->title_id); bool is_64_bit;
if (kernelAbove200()) {
is_64_bit = (((npdm_info.header->mmu_flags >> 1) & 5) | 2) == 3;
} else {
is_64_bit = (npdm_info.header->mmu_flags & 0xE) == 0x2;
}
Registration::set_process_id_tid_min_and_is_64_bit(index, process_id, npdm_info.aci0->title_id, is_64_bit);
for (unsigned int i = 0; i < NSO_NUM_MAX; i++) { for (unsigned int i = 0; i < NSO_NUM_MAX; i++) {
if (NsoUtils::IsNsoPresent(i)) { if (NsoUtils::IsNsoPresent(i)) {
Registration::add_nso_info(index, nso_extents.nso_addresses[i], nso_extents.nso_sizes[i], NsoUtils::GetNsoBuildId(i)); Registration::add_nso_info(index, nso_extents.nso_addresses[i], nso_extents.nso_sizes[i], NsoUtils::GetNsoBuildId(i));

View File

@ -75,7 +75,7 @@ Result Registration::get_registered_tid_sid(u64 index, Registration::TidSid *out
return 0; return 0;
} }
void Registration::set_process_id_and_tid_min(u64 index, u64 process_id, u64 tid_min) { void Registration::set_process_id_tid_min_and_is_64_bit(u64 index, u64 process_id, u64 tid_min, bool is_64_bit) {
Registration::Process *target_process = get_process(index); Registration::Process *target_process = get_process(index);
if (target_process == NULL) { if (target_process == NULL) {
return; return;
@ -83,6 +83,7 @@ void Registration::set_process_id_and_tid_min(u64 index, u64 process_id, u64 tid
target_process->process_id = process_id; target_process->process_id = process_id;
target_process->title_id_min = tid_min; target_process->title_id_min = tid_min;
target_process->is_64_bit = is_64_bit;
} }
void Registration::add_nso_info(u64 index, u64 base_address, u64 size, const unsigned char *build_id) { void Registration::add_nso_info(u64 index, u64 base_address, u64 size, const unsigned char *build_id) {

View File

@ -25,6 +25,7 @@ class Registration {
struct Process { struct Process {
bool in_use; bool in_use;
bool is_64_bit;
u64 index; u64 index;
u64 process_id; u64 process_id;
u64 title_id_min; u64 title_id_min;
@ -44,7 +45,7 @@ class Registration {
static Result get_registered_tid_sid(u64 index, Registration::TidSid *out); 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 register_tid_sid(const TidSid *tid_sid, u64 *out_index);
static bool unregister_index(u64 index); static bool unregister_index(u64 index);
static void set_process_id_and_tid_min(u64 index, u64 process_id, u64 tid_min); static void set_process_id_tid_min_and_is_64_bit(u64 index, u64 process_id, u64 tid_min, bool is_64_bit);
static void add_nso_info(u64 index, u64 base_address, u64 size, const unsigned char *build_id); 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 Result get_nso_infos_for_process_id(NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written);
}; };