From 173e6c8c0f9a9126ebadc45a8425ffc3efaeb37f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 8 May 2018 18:46:38 -0600 Subject: [PATCH] PM: Fix missing flags set/missing wait. Now works on 5.x. --- stratosphere/pm/source/pm_registration.cpp | 6 +++--- stratosphere/pm/source/pm_resource_limits.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/stratosphere/pm/source/pm_registration.cpp b/stratosphere/pm/source/pm_registration.cpp index c74f5e6e6..9c0d4b440 100644 --- a/stratosphere/pm/source/pm_registration.cpp +++ b/stratosphere/pm/source/pm_registration.cpp @@ -94,7 +94,7 @@ void Registration::HandleProcessLaunch() { if ((program_info.application_type & 3) == 1) { ResourceLimitUtils::EnsureApplicationResourcesAvailable(); } - + /* Try to create the process... */ if (R_FAILED((rc = ldrPmCreateProcess(LAUNCHFLAGS_ARGLOW(launch_flags) | LAUNCHFLAGS_ARGHIGH(launch_flags), new_process.ldr_queue_index, ResourceLimitUtils::GetResourceLimitHandle(program_info.application_type), &new_process.handle)))) { goto PROCESS_CREATION_FAILED; @@ -121,8 +121,8 @@ void Registration::HandleProcessLaunch() { if (program_info.application_type & 1) { new_process.flags |= 0x40; } - if (kernelAbove200() && LAUNCHFLAGS_NOTIYDEBUGSPECIAL(launch_flags) && (program_info.application_type & 4)) { - + if (kernelAbove200() && LAUNCHFLAGS_NOTIYDEBUGSPECIAL(launch_flags) && (program_info.application_type & 4)) { + new_process.flags |= 0x80; } if (LAUNCHFLAGS_NOTIFYWHENEXITED(launch_flags)) { new_process.flags |= 1; diff --git a/stratosphere/pm/source/pm_resource_limits.cpp b/stratosphere/pm/source/pm_resource_limits.cpp index d59a4919b..1174c68e4 100644 --- a/stratosphere/pm/source/pm_resource_limits.cpp +++ b/stratosphere/pm/source/pm_resource_limits.cpp @@ -123,6 +123,7 @@ void ResourceLimitUtils::InitializeLimits() { } void ResourceLimitUtils::EnsureApplicationResourcesAvailable() { + Result rc; Handle application_reslimit_h = g_resource_limit_handles[1]; for (unsigned int i = 0; i < 5; i++) { u64 result; @@ -133,6 +134,15 @@ void ResourceLimitUtils::EnsureApplicationResourcesAvailable() { svcSleepThread(1000000ULL); } while (result); } + if (kernelAbove500()) { + u64 result; + do { + if (R_FAILED(svcGetSystemInfo(&result, 1, 0, 0))) { + /* TODO: Panic. */ + } + svcSleepThread(1000000ULL); + } while (result); + } } Handle ResourceLimitUtils::GetResourceLimitHandle(u16 application_type) {