From 127101a683853d293c072e1cc7a073498a07ef99 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Sat, 30 Mar 2019 15:05:49 +0100 Subject: [PATCH] Fix debug bug --- sysmodules/pm/source/launch.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sysmodules/pm/source/launch.c b/sysmodules/pm/source/launch.c index 0bc6b4e..1905f6d 100644 --- a/sysmodules/pm/source/launch.c +++ b/sysmodules/pm/source/launch.c @@ -10,7 +10,7 @@ #include "luma.h" // Note: official PM has two distinct functions for sysmodule vs. regular app. We refactor that into a single function. -static Result launchTitleImpl(Handle *debug, ProcessData **outProcessData, const FS_ProgramInfo *programInfo, +static Result launchTitleImpl(Handle *outDebug, ProcessData **outProcessData, const FS_ProgramInfo *programInfo, const FS_ProgramInfo *programInfoUpdate, u32 launchFlags, ExHeader_Info *exheaderInfo); // Note: official PM doesn't include svcDebugActiveProcess in this function, but rather in the caller handling dependencies @@ -23,6 +23,10 @@ static Result loadWithoutDependencies(Handle *outDebug, ProcessData **outProcess ProcessData *process; const ExHeader_Arm11SystemLocalCapabilities *localcaps = &exheaderInfo->aci.local_caps; + if (outDebug != NULL) { + *outDebug = 0; + } + if (outProcessData != NULL) { *outProcessData = NULL; } @@ -83,7 +87,7 @@ static Result loadWithoutDependencies(Handle *outDebug, ProcessData **outProcess (*outProcessData)->flags |= PROCESSFLAG_NORMAL_APPLICATION; // not in official PM } - if (launchFlags & PMLAUNCHFLAG_QUEUE_DEBUG_APPLICATION) { + if (outDebug != NULL) { TRY(svcDebugActiveProcess(outDebug, pid)); } @@ -106,6 +110,11 @@ static Result loadWithDependencies(Handle *outDebug, ProcessData **outProcessDat ProcessData *process = *outProcessData; if (R_FAILED(res)) { + if (outDebug != NULL) { + svcCloseHandle(*outDebug); + *outDebug = 0; + } + if (process != NULL) { svcTerminateProcess(process->handle); } @@ -150,6 +159,11 @@ static Result loadWithDependencies(Handle *outDebug, ProcessData **outProcessDat remrefcounts[i] = 0; listMergeUniqueDependencies(depProcs, dependencies, remrefcounts, &numUnique, depExheaderInfo); // does some incref too } else if (process != NULL) { + if (outDebug != NULL) { + svcCloseHandle(*outDebug); + *outDebug = 0; + } + svcTerminateProcess(process->handle); ExHeaderInfoHeap_Delete(depExheaderInfo); return res;