From 40cd0bb97b3d6db6eba0e18fae6560c8e1b69794 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sat, 20 Nov 2021 19:39:26 -0500 Subject: [PATCH 1/3] service: pm: Rename title id to program id --- src/core/hle/service/pm/pm.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index 88fc5b5cc0..969300795e 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -95,13 +95,13 @@ public: private: void GetProcessId(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - const auto title_id = rp.PopRaw(); + const auto program_id = rp.PopRaw(); - LOG_DEBUG(Service_PM, "called, title_id={:016X}", title_id); + LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id); const auto process = - SearchProcessList(kernel.GetProcessList(), [title_id](const auto& proc) { - return proc->GetProgramID() == title_id; + SearchProcessList(kernel.GetProcessList(), [program_id](const auto& proc) { + return proc->GetProgramID() == program_id; }); if (!process.has_value()) { @@ -128,13 +128,13 @@ public: explicit Info(Core::System& system_, const std::vector& process_list_) : ServiceFramework{system_, "pm:info"}, process_list{process_list_} { static const FunctionInfo functions[] = { - {0, &Info::GetTitleId, "GetTitleId"}, + {0, &Info::GetProgramId, "GetProgramId"}, }; RegisterHandlers(functions); } private: - void GetTitleId(Kernel::HLERequestContext& ctx) { + void GetProgramId(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw(); From 3dc38d185b595ef2cf1d539f7bc68554999cd1db Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sat, 20 Nov 2021 19:42:30 -0500 Subject: [PATCH 2/3] service: pm: Add all relevant result codes --- src/core/hle/service/pm/pm.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index 969300795e..b2e97a2184 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -13,7 +13,12 @@ namespace Service::PM { namespace { -constexpr ResultCode ERROR_PROCESS_NOT_FOUND{ErrorModule::PM, 1}; +constexpr ResultCode ResultProcessNotFound{ErrorModule::PM, 1}; +[[maybe_unused]] constexpr ResultCode ResultAlreadyStarted{ErrorModule::PM, 2}; +[[maybe_unused]] constexpr ResultCode ResultNotTerminated{ErrorModule::PM, 3}; +[[maybe_unused]] constexpr ResultCode ResultDebugHookInUse{ErrorModule::PM, 4}; +[[maybe_unused]] constexpr ResultCode ResultApplicationRunning{ErrorModule::PM, 5}; +[[maybe_unused]] constexpr ResultCode ResultInvalidSize{ErrorModule::PM, 6}; constexpr u64 NO_PROCESS_FOUND_PID{0}; @@ -106,7 +111,7 @@ private: if (!process.has_value()) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERROR_PROCESS_NOT_FOUND); + rb.Push(ResultProcessNotFound); return; } @@ -146,7 +151,7 @@ private: if (!process.has_value()) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERROR_PROCESS_NOT_FOUND); + rb.Push(ResultProcessNotFound); return; } From 9173f07a51ee355d79c60fed21e7731868db5e6d Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sat, 20 Nov 2021 19:52:25 -0500 Subject: [PATCH 3/3] service: pm: Implement AtmosphereGetProcessId - Used by Skyline modding framework --- src/core/hle/service/pm/pm.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index b2e97a2184..277abc17a1 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -134,6 +134,9 @@ public: : ServiceFramework{system_, "pm:info"}, process_list{process_list_} { static const FunctionInfo functions[] = { {0, &Info::GetProgramId, "GetProgramId"}, + {65000, &Info::AtmosphereGetProcessId, "AtmosphereGetProcessId"}, + {65001, nullptr, "AtmosphereHasLaunchedProgram"}, + {65002, nullptr, "AtmosphereGetProcessInfo"}, }; RegisterHandlers(functions); } @@ -160,6 +163,27 @@ private: rb.Push((*process)->GetProgramID()); } + void AtmosphereGetProcessId(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto program_id = rp.PopRaw(); + + LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id); + + const auto process = SearchProcessList(process_list, [program_id](const auto& proc) { + return proc->GetProgramID() == program_id; + }); + + if (!process.has_value()) { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultProcessNotFound); + return; + } + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push((*process)->GetProcessID()); + } + const std::vector& process_list; };