diff --git a/stratosphere/loader/source/ldr_ro_service.cpp b/stratosphere/loader/source/ldr_ro_service.cpp index f5f7f5984..2375a0b0b 100644 --- a/stratosphere/loader/source/ldr_ro_service.cpp +++ b/stratosphere/loader/source/ldr_ro_service.cpp @@ -31,27 +31,36 @@ Result RelocatableObjectsService::dispatch(IpcParsedCommand &r, IpcCommand &out_ } -std::tuple load_nro(PidDescriptor pid, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size) { +std::tuple RelocatableObjectsService::load_nro(PidDescriptor pid_desc, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size) { /* TODO */ return std::make_tuple(0xF601, 0); } -std::tuple unload_nro(PidDescriptor pid, u64 nro_address) { +std::tuple RelocatableObjectsService::unload_nro(PidDescriptor pid_desc, u64 nro_address) { /* TODO */ return std::make_tuple(0xF601); } -std::tuple load_nrr(PidDescriptor pid, u64 nrr_address, u64 nrr_size) { +std::tuple RelocatableObjectsService::load_nrr(PidDescriptor pid_desc, u64 nrr_address, u64 nrr_size) { /* TODO */ return std::make_tuple(0xF601); } -std::tuple unload_nrr(PidDescriptor pid, u64 nrr_address) { +std::tuple RelocatableObjectsService::unload_nrr(PidDescriptor pid_desc, u64 nrr_address) { /* TODO */ return std::make_tuple(0xF601); } -std::tuple initialize(PidDescriptor pid, CopiedHandle process_h) { - /* TODO */ - return std::make_tuple(0xF601); +std::tuple RelocatableObjectsService::initialize(PidDescriptor pid_desc, CopiedHandle process_h) { + u64 handle_pid; + Result rc = 0xAE09; + if (R_SUCCEEDED(svcGetProcessId(&handle_pid, process_h.handle)) && handle_pid == pid_desc.pid) { + if (this->has_initialized) { + svcCloseHandle(this->process_handle); + } + this->process_handle = process_h.handle; + this->has_initialized = true; + rc = 0; + } + return std::make_tuple(rc); } diff --git a/stratosphere/loader/source/ldr_ro_service.hpp b/stratosphere/loader/source/ldr_ro_service.hpp index 29d057ba0..f2a02f252 100644 --- a/stratosphere/loader/source/ldr_ro_service.hpp +++ b/stratosphere/loader/source/ldr_ro_service.hpp @@ -26,9 +26,9 @@ class RelocatableObjectsService : IServiceObject { private: /* Actual commands. */ - std::tuple load_nro(PidDescriptor pid, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size); - std::tuple unload_nro(PidDescriptor pid, u64 nro_address); - std::tuple load_nrr(PidDescriptor pid, u64 nrr_address, u64 nrr_size); - std::tuple unload_nrr(PidDescriptor pid, u64 nrr_address); - std::tuple initialize(PidDescriptor pid, CopiedHandle process_h); + std::tuple load_nro(PidDescriptor pid_desc, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size); + std::tuple unload_nro(PidDescriptor pid_desc, u64 nro_address); + std::tuple load_nrr(PidDescriptor pid_desc, u64 nrr_address, u64 nrr_size); + std::tuple unload_nrr(PidDescriptor pid_desc, u64 nrr_address); + std::tuple initialize(PidDescriptor pid_desc, CopiedHandle process_h); }; \ No newline at end of file