From c19750a0d597bfa12c8c2ea27d91e09b5fce329f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 4 May 2018 01:01:53 -0600 Subject: [PATCH] ProcessManager: Make launch flag parsing version agnostic. --- stratosphere/pm/source/pm_registration.cpp | 11 +++++++---- stratosphere/pm/source/pm_registration.hpp | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/stratosphere/pm/source/pm_registration.cpp b/stratosphere/pm/source/pm_registration.cpp index 4f5d784d3..d433a0f9d 100644 --- a/stratosphere/pm/source/pm_registration.cpp +++ b/stratosphere/pm/source/pm_registration.cpp @@ -143,7 +143,7 @@ void Registration::HandleProcessLaunch() { } /* Try to create the process... */ - if (R_FAILED((rc = ldrPmCreateProcess((launch_flags >> 2) & 3, new_process.ldr_queue_index, g_resource_limit_handles[reslimit_idx], &new_process.handle)))) { + if (R_FAILED((rc = ldrPmCreateProcess(LAUNCHFLAGS_ARGLOW(launch_flags) | LAUNCHFLAGS_ARGHIGH(launch_flags), new_process.ldr_queue_index, g_resource_limit_handles[reslimit_idx], &new_process.handle)))) { goto PROCESS_CREATION_FAILED; } @@ -168,10 +168,13 @@ void Registration::HandleProcessLaunch() { if (program_info.application_type & 1) { new_process.flags |= 0x40; } - if (launch_flags & 1) { + if (kernelAbove200() && LAUNCHFLAGS_NOTIYDEBUGSPECIAL(launch_flags) && (program_info.application_type & 4)) { + + } + if (LAUNCHFLAGS_NOTIFYWHENEXITED(launch_flags)) { new_process.flags |= 1; } - if (launch_flags & 0x10) { + if (LAUNCHFLAGS_NOTIFYDEBUGEVENTS(launch_flags) && (!kernelAbove200() || (program_info.application_type & 4))) { new_process.flags |= 0x8; } @@ -187,7 +190,7 @@ void Registration::HandleProcessLaunch() { g_debug_application_event->signal_event(); g_debug_next_application = false; rc = 0; - } else if (launch_flags & 2) { + } else if (LAUNCHFLAGS_STARTSUSPENDED(launch_flags)) { rc = 0; } else { rc = svcStartProcess(new_process.handle, program_info.main_thread_priority, program_info.default_cpu_id, program_info.main_thread_stack_size); diff --git a/stratosphere/pm/source/pm_registration.hpp b/stratosphere/pm/source/pm_registration.hpp index ad549bc72..832382e72 100644 --- a/stratosphere/pm/source/pm_registration.hpp +++ b/stratosphere/pm/source/pm_registration.hpp @@ -2,6 +2,14 @@ #include #include +#define LAUNCHFLAGS_NOTIFYWHENEXITED(flags) (flags & 1) +#define LAUNCHFLAGS_STARTSUSPENDED(flags) (flags & (kernelAbove500() ? 0x10 : 0x2)) +#define LAUNCHFLAGS_ARGLOW(flags) (kernelAbove500() ? ((flags & 0x14) != 0x10) : (kernelAbove200() ? ((flags & 0x6) != 0x2) : ((flags >> 2) & 1))) +#define LAUNCHFLAGS_ARGHIGH(flags) (flags & (kernelAbove500() ? 0x20 : 0x8)) +#define LAUNCHFLAGS_NOTIFYDEBUGEVENTS(flags) (flags & (kernelAbove500() ? 0x8 : 0x10)) +#define LAUNCHFLAGS_NOTIYDEBUGSPECIAL(flags) (flags & (kernelAbove500() ? 0x2 : (kernelAbove200() ? 0x20 : 0x0))) + + class Registration { public: struct TidSid {