mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-10 07:06:34 +00:00
Loader: Implement ldr:ro->UnloadNrr()
This commit is contained in:
parent
8524f284fd
commit
e7aa5c246b
3 changed files with 32 additions and 3 deletions
|
@ -111,7 +111,7 @@ Result Registration::AddNrrInfo(u64 index, MappedCodeMemory *nrr_info) {
|
||||||
return 0x7009;
|
return 0x7009;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < NSO_INFO_MAX; i++) {
|
for (unsigned int i = 0; i < NRR_INFO_MAX; i++) {
|
||||||
if (!target_process->nrr_infos[i].IsActive()) {
|
if (!target_process->nrr_infos[i].IsActive()) {
|
||||||
target_process->nrr_infos[i] = *nrr_info;
|
target_process->nrr_infos[i] = *nrr_info;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -120,6 +120,21 @@ Result Registration::AddNrrInfo(u64 index, MappedCodeMemory *nrr_info) {
|
||||||
return 0x7009;
|
return 0x7009;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result Registration::RemoveNrrInfo(u64 index, u64 base_address) {
|
||||||
|
Registration::Process *target_process = GetProcess(index);
|
||||||
|
if (target_process == NULL) {
|
||||||
|
/* Despite the fact that this should really be a panic condition, Nintendo returns 0x1009 in this case. */
|
||||||
|
return 0x1009;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < NRR_INFO_MAX; i++) {
|
||||||
|
if (target_process->nrr_infos[i].IsActive() && target_process->nrr_infos[i].base_address == base_address) {
|
||||||
|
target_process->nrr_infos[i].Close();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0xAA09;
|
||||||
|
}
|
||||||
|
|
||||||
Result Registration::GetNsoInfosForProcessId(Registration::NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written) {
|
Result Registration::GetNsoInfosForProcessId(Registration::NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written) {
|
||||||
Registration::Process *target_process = GetProcessByProcessId(process_id);
|
Registration::Process *target_process = GetProcessByProcessId(process_id);
|
||||||
|
|
|
@ -52,5 +52,6 @@ class Registration {
|
||||||
static void SetProcessIdTidMinAndIs64BitAddressSpace(u64 index, u64 process_id, u64 tid_min, bool is_64_bit_addspace);
|
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 void AddNsoInfo(u64 index, u64 base_address, u64 size, const unsigned char *build_id);
|
||||||
static Result AddNrrInfo(u64 index, MappedCodeMemory *nrr_info);
|
static Result AddNrrInfo(u64 index, MappedCodeMemory *nrr_info);
|
||||||
|
static Result RemoveNrrInfo(u64 index, u64 base_address);
|
||||||
static Result GetNsoInfosForProcessId(NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written);
|
static Result GetNsoInfosForProcessId(NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written);
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,8 +86,21 @@ LOAD_NRR_END:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<Result> RelocatableObjectsService::unload_nrr(PidDescriptor pid_desc, u64 nrr_address) {
|
std::tuple<Result> RelocatableObjectsService::unload_nrr(PidDescriptor pid_desc, u64 nrr_address) {
|
||||||
/* TODO */
|
Registration::Process *target_proc = NULL;
|
||||||
return std::make_tuple(0xF601);
|
if (!this->has_initialized || this->process_id != pid_desc.pid) {
|
||||||
|
return 0xAE09;
|
||||||
|
}
|
||||||
|
if (nrr_address & 0xFFF) {
|
||||||
|
return 0xA209;
|
||||||
|
}
|
||||||
|
|
||||||
|
target_proc = Registration::GetProcessByProcessId(pid_desc.pid);
|
||||||
|
if (target_proc == NULL || (target_proc->owner_ro_service != NULL && (RelocatableObjectsService *)(target_proc->owner_ro_service) != this)) {
|
||||||
|
return 0xAC09;
|
||||||
|
}
|
||||||
|
target_proc->owner_ro_service = this;
|
||||||
|
|
||||||
|
return Registration::RemoveNrrInfo(target_proc->index, nrr_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<Result> RelocatableObjectsService::initialize(PidDescriptor pid_desc, CopiedHandle process_h) {
|
std::tuple<Result> RelocatableObjectsService::initialize(PidDescriptor pid_desc, CopiedHandle process_h) {
|
||||||
|
|
Loading…
Reference in a new issue