From cddec5c754d3773e63e5b170a4ed481fef5c74ef Mon Sep 17 00:00:00 2001 From: plutoo Date: Sun, 3 Dec 2017 19:17:38 +0100 Subject: [PATCH] More pm --- nx/include/switch/services/pm.h | 7 ++++++ nx/source/services/pm.c | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 nx/include/switch/services/pm.h diff --git a/nx/include/switch/services/pm.h b/nx/include/switch/services/pm.h new file mode 100644 index 00000000..706a46cc --- /dev/null +++ b/nx/include/switch/services/pm.h @@ -0,0 +1,7 @@ +// Copyright 2017 plutoo +Result pmdmntInitialize(); +Result pmdmntStartProcess(u64 pid); +Result pmdmntGetTitlePid(u64* pid_out, u64 title_id); +Result pmdmntEnableDebugForTitleId(Handle* handle_out, u64 title_id); +Result pmdmntGetApplicationPid(u64* pid_out); +Result pmdmntEnableDebugForApplication(Handle* handle_out); diff --git a/nx/source/services/pm.c b/nx/source/services/pm.c index b888d558..cd1257d9 100644 --- a/nx/source/services/pm.c +++ b/nx/source/services/pm.c @@ -46,6 +46,44 @@ Result pmdmntStartProcess(u64 pid) { return rc; } +Result pmdmntGetTitlePid(u64* pid_out, u64 title_id) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + u64 title_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 3; + raw->title_id = title_id; + + Result rc = ipcDispatch(g_pmdmntHandle); + + if (R_SUCCEEDED(rc)) { + IpcCommandResponse r; + ipcParseResponse(&r); + + struct { + u64 magic; + u64 result; + u64 pid; + } *resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc)) { + *pid_out = resp->pid; + } + } + + return rc; +} + Result pmdmntEnableDebugForTitleId(Handle* handle_out, u64 title_id) { IpcCommand c; ipcInitialize(&c);