diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/pm/pm.cpp | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index 88fc5b5cc..277abc17a 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp | |||
| @@ -13,7 +13,12 @@ namespace Service::PM { | |||
| 13 | 13 | ||
| 14 | namespace { | 14 | namespace { |
| 15 | 15 | ||
| 16 | constexpr ResultCode ERROR_PROCESS_NOT_FOUND{ErrorModule::PM, 1}; | 16 | constexpr ResultCode ResultProcessNotFound{ErrorModule::PM, 1}; |
| 17 | [[maybe_unused]] constexpr ResultCode ResultAlreadyStarted{ErrorModule::PM, 2}; | ||
| 18 | [[maybe_unused]] constexpr ResultCode ResultNotTerminated{ErrorModule::PM, 3}; | ||
| 19 | [[maybe_unused]] constexpr ResultCode ResultDebugHookInUse{ErrorModule::PM, 4}; | ||
| 20 | [[maybe_unused]] constexpr ResultCode ResultApplicationRunning{ErrorModule::PM, 5}; | ||
| 21 | [[maybe_unused]] constexpr ResultCode ResultInvalidSize{ErrorModule::PM, 6}; | ||
| 17 | 22 | ||
| 18 | constexpr u64 NO_PROCESS_FOUND_PID{0}; | 23 | constexpr u64 NO_PROCESS_FOUND_PID{0}; |
| 19 | 24 | ||
| @@ -95,18 +100,18 @@ public: | |||
| 95 | private: | 100 | private: |
| 96 | void GetProcessId(Kernel::HLERequestContext& ctx) { | 101 | void GetProcessId(Kernel::HLERequestContext& ctx) { |
| 97 | IPC::RequestParser rp{ctx}; | 102 | IPC::RequestParser rp{ctx}; |
| 98 | const auto title_id = rp.PopRaw<u64>(); | 103 | const auto program_id = rp.PopRaw<u64>(); |
| 99 | 104 | ||
| 100 | LOG_DEBUG(Service_PM, "called, title_id={:016X}", title_id); | 105 | LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id); |
| 101 | 106 | ||
| 102 | const auto process = | 107 | const auto process = |
| 103 | SearchProcessList(kernel.GetProcessList(), [title_id](const auto& proc) { | 108 | SearchProcessList(kernel.GetProcessList(), [program_id](const auto& proc) { |
| 104 | return proc->GetProgramID() == title_id; | 109 | return proc->GetProgramID() == program_id; |
| 105 | }); | 110 | }); |
| 106 | 111 | ||
| 107 | if (!process.has_value()) { | 112 | if (!process.has_value()) { |
| 108 | IPC::ResponseBuilder rb{ctx, 2}; | 113 | IPC::ResponseBuilder rb{ctx, 2}; |
| 109 | rb.Push(ERROR_PROCESS_NOT_FOUND); | 114 | rb.Push(ResultProcessNotFound); |
| 110 | return; | 115 | return; |
| 111 | } | 116 | } |
| 112 | 117 | ||
| @@ -128,13 +133,16 @@ public: | |||
| 128 | explicit Info(Core::System& system_, const std::vector<Kernel::KProcess*>& process_list_) | 133 | explicit Info(Core::System& system_, const std::vector<Kernel::KProcess*>& process_list_) |
| 129 | : ServiceFramework{system_, "pm:info"}, process_list{process_list_} { | 134 | : ServiceFramework{system_, "pm:info"}, process_list{process_list_} { |
| 130 | static const FunctionInfo functions[] = { | 135 | static const FunctionInfo functions[] = { |
| 131 | {0, &Info::GetTitleId, "GetTitleId"}, | 136 | {0, &Info::GetProgramId, "GetProgramId"}, |
| 137 | {65000, &Info::AtmosphereGetProcessId, "AtmosphereGetProcessId"}, | ||
| 138 | {65001, nullptr, "AtmosphereHasLaunchedProgram"}, | ||
| 139 | {65002, nullptr, "AtmosphereGetProcessInfo"}, | ||
| 132 | }; | 140 | }; |
| 133 | RegisterHandlers(functions); | 141 | RegisterHandlers(functions); |
| 134 | } | 142 | } |
| 135 | 143 | ||
| 136 | private: | 144 | private: |
| 137 | void GetTitleId(Kernel::HLERequestContext& ctx) { | 145 | void GetProgramId(Kernel::HLERequestContext& ctx) { |
| 138 | IPC::RequestParser rp{ctx}; | 146 | IPC::RequestParser rp{ctx}; |
| 139 | const auto process_id = rp.PopRaw<u64>(); | 147 | const auto process_id = rp.PopRaw<u64>(); |
| 140 | 148 | ||
| @@ -146,7 +154,7 @@ private: | |||
| 146 | 154 | ||
| 147 | if (!process.has_value()) { | 155 | if (!process.has_value()) { |
| 148 | IPC::ResponseBuilder rb{ctx, 2}; | 156 | IPC::ResponseBuilder rb{ctx, 2}; |
| 149 | rb.Push(ERROR_PROCESS_NOT_FOUND); | 157 | rb.Push(ResultProcessNotFound); |
| 150 | return; | 158 | return; |
| 151 | } | 159 | } |
| 152 | 160 | ||
| @@ -155,6 +163,27 @@ private: | |||
| 155 | rb.Push((*process)->GetProgramID()); | 163 | rb.Push((*process)->GetProgramID()); |
| 156 | } | 164 | } |
| 157 | 165 | ||
| 166 | void AtmosphereGetProcessId(Kernel::HLERequestContext& ctx) { | ||
| 167 | IPC::RequestParser rp{ctx}; | ||
| 168 | const auto program_id = rp.PopRaw<u64>(); | ||
| 169 | |||
| 170 | LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id); | ||
| 171 | |||
| 172 | const auto process = SearchProcessList(process_list, [program_id](const auto& proc) { | ||
| 173 | return proc->GetProgramID() == program_id; | ||
| 174 | }); | ||
| 175 | |||
| 176 | if (!process.has_value()) { | ||
| 177 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 178 | rb.Push(ResultProcessNotFound); | ||
| 179 | return; | ||
| 180 | } | ||
| 181 | |||
| 182 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 183 | rb.Push(ResultSuccess); | ||
| 184 | rb.Push((*process)->GetProcessID()); | ||
| 185 | } | ||
| 186 | |||
| 158 | const std::vector<Kernel::KProcess*>& process_list; | 187 | const std::vector<Kernel::KProcess*>& process_list; |
| 159 | }; | 188 | }; |
| 160 | 189 | ||