From 28d630a23e0ac7efe0aaf28b4adb1cf2b5cde06b Mon Sep 17 00:00:00 2001 From: misson20000 Date: Thu, 7 Jun 2018 23:32:45 -0700 Subject: [PATCH] pm: add Atmosphere GetProcessHandle command to pm:dmnt (#133) --- stratosphere/pm/source/pm_debug_monitor.cpp | 14 ++++++++++++++ stratosphere/pm/source/pm_debug_monitor.hpp | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/stratosphere/pm/source/pm_debug_monitor.cpp b/stratosphere/pm/source/pm_debug_monitor.cpp index 0d8026cae..722277ba3 100644 --- a/stratosphere/pm/source/pm_debug_monitor.cpp +++ b/stratosphere/pm/source/pm_debug_monitor.cpp @@ -24,6 +24,9 @@ Result DebugMonitorService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 case Dmnt_Cmd_5X_EnableDebugForApplication: rc = WrapIpcCommandImpl<&DebugMonitorService::enable_debug_for_application>(this, r, out_c, pointer_buffer, pointer_buffer_size); break; + case Dmnt_Cmd_5X_AtmosphereGetProcessHandle: + rc = WrapIpcCommandImpl<&DebugMonitorService::get_process_handle>(this, r, out_c, pointer_buffer, pointer_buffer_size); + break; default: break; } @@ -50,6 +53,9 @@ Result DebugMonitorService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 case Dmnt_Cmd_EnableDebugForApplication: rc = WrapIpcCommandImpl<&DebugMonitorService::enable_debug_for_application>(this, r, out_c, pointer_buffer, pointer_buffer_size); break; + case Dmnt_Cmd_AtmosphereGetProcessHandle: + rc = WrapIpcCommandImpl<&DebugMonitorService::get_process_handle>(this, r, out_c, pointer_buffer, pointer_buffer_size); + break; default: break; } @@ -117,3 +123,11 @@ std::tuple DebugMonitorService::enable_debug_for_applicati Result rc = Registration::EnableDebugForApplication(&h); return {rc, h}; } + +std::tuple DebugMonitorService::get_process_handle(u64 pid) { + Registration::Process *proc = Registration::GetProcess(pid); + if(proc == NULL) { + return {0x20F, 0}; + } + return {0, proc->handle}; +} diff --git a/stratosphere/pm/source/pm_debug_monitor.hpp b/stratosphere/pm/source/pm_debug_monitor.hpp index 8b74a1819..a3bfcba81 100644 --- a/stratosphere/pm/source/pm_debug_monitor.hpp +++ b/stratosphere/pm/source/pm_debug_monitor.hpp @@ -12,6 +12,8 @@ enum DmntCmd { Dmnt_Cmd_EnableDebugForTitleId = 4, Dmnt_Cmd_GetApplicationProcessId = 5, Dmnt_Cmd_EnableDebugForApplication = 6, + + Dmnt_Cmd_AtmosphereGetProcessHandle = 65000 }; enum DmntCmd_5X { @@ -21,6 +23,8 @@ enum DmntCmd_5X { Dmnt_Cmd_5X_EnableDebugForTitleId = 3, Dmnt_Cmd_5X_GetApplicationProcessId = 4, Dmnt_Cmd_5X_EnableDebugForApplication = 5, + + Dmnt_Cmd_5X_AtmosphereGetProcessHandle = 65000 }; class DebugMonitorService final : IServiceObject { @@ -37,4 +41,7 @@ class DebugMonitorService final : IServiceObject { std::tuple enable_debug_for_tid(u64 tid); std::tuple get_application_process_id(); std::tuple enable_debug_for_application(); + + /* Atmosphere commands. */ + std::tuple get_process_handle(u64 pid); };