1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-18 16:32:05 +00:00

loader: fix process handle management on create process error

This commit is contained in:
Michael Scire 2020-12-06 21:20:42 -08:00
parent 32803d9920
commit 9ca1d3a7f7

View file

@ -464,13 +464,18 @@ namespace ams::ldr {
Result CreateProcessImpl(ProcessInfo *out, const Meta *meta, const NsoHeader *nso_headers, const bool *has_nso, const args::ArgumentInfo *arg_info, u32 flags, Handle reslimit_h) {
/* Get CreateProcessParameter. */
svc::CreateProcessParameter param;
R_TRY(GetCreateProcessParameter(&param, meta, flags, reslimit_h));
R_TRY(GetCreateProcessParameter(std::addressof(param), meta, flags, reslimit_h));
/* Decide on an NSO layout. */
R_TRY(DecideAddressSpaceLayout(out, &param, nso_headers, has_nso, arg_info));
R_TRY(DecideAddressSpaceLayout(out, std::addressof(param), nso_headers, has_nso, arg_info));
/* Actually create process. const_cast necessary because libnx doesn't declare svcCreateProcess with const u32*. */
return svcCreateProcess(out->process_handle.GetPointer(), &param, reinterpret_cast<const u32 *>(meta->aci_kac), meta->aci->kac_size / sizeof(u32));
/* Actually create process. */
Handle process_handle;
R_TRY(svc::CreateProcess(std::addressof(process_handle), std::addressof(param), static_cast<const u32 *>(meta->aci_kac), meta->aci->kac_size / sizeof(u32)));
/* Set the output handle. */
*out->process_handle.GetPointer() = process_handle;
return ResultSuccess();
}
Result LoadNsoSegment(fs::FileHandle file, const NsoHeader::SegmentInfo *segment, size_t file_size, const u8 *file_hash, bool is_compressed, bool check_hash, uintptr_t map_base, uintptr_t map_end) {