summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-06-26 19:05:04 -0400
committerGravatar Zach Hilman2019-06-26 19:05:04 -0400
commit49af3bcdcba76decc8aec5b6812eac04e488e47f (patch)
tree6b46afffc64470d57f48c9551b30ee4feed97b2f /src/core/hle
parentMerge pull request #2548 from DarkLordZach/applet-shopn (diff)
downloadyuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.tar.gz
yuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.tar.xz
yuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.zip
pm: Implement pm:info GetTitleId
Searches the process list for a process with the specified ID, returning the title ID if it exists.
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/pm/pm.cpp49
1 files changed, 47 insertions, 2 deletions
diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp
index ebcc41a43..b6a7d3474 100644
--- a/src/core/hle/service/pm/pm.cpp
+++ b/src/core/hle/service/pm/pm.cpp
@@ -8,6 +8,26 @@
8 8
9namespace Service::PM { 9namespace Service::PM {
10 10
11namespace {
12
13constexpr ResultCode ERROR_PROCESS_NOT_FOUND{ErrorModule::PM, 1};
14
15constexpr u64 NO_PROCESS_FOUND_PID{0};
16
17std::optional<Kernel::SharedPtr<Kernel::Process>> SearchProcessList(
18 const std::vector<Kernel::SharedPtr<Kernel::Process>>& process_list,
19 std::function<bool(const Kernel::SharedPtr<Kernel::Process>&)> predicate) {
20 const auto iter = std::find_if(process_list.begin(), process_list.end(), predicate);
21
22 if (iter == process_list.end()) {
23 return std::nullopt;
24 }
25
26 return *iter;
27}
28
29} // Anonymous namespace
30
11class BootMode final : public ServiceFramework<BootMode> { 31class BootMode final : public ServiceFramework<BootMode> {
12public: 32public:
13 explicit BootMode() : ServiceFramework{"pm:bm"} { 33 explicit BootMode() : ServiceFramework{"pm:bm"} {
@@ -60,12 +80,37 @@ public:
60 80
61class Info final : public ServiceFramework<Info> { 81class Info final : public ServiceFramework<Info> {
62public: 82public:
63 explicit Info() : ServiceFramework{"pm:info"} { 83 explicit Info(const std::vector<Kernel::SharedPtr<Kernel::Process>>& process_list)
84 : ServiceFramework{"pm:info"}, process_list(process_list) {
64 static const FunctionInfo functions[] = { 85 static const FunctionInfo functions[] = {
65 {0, nullptr, "GetTitleId"}, 86 {0, &Info::GetTitleId, "GetTitleId"},
66 }; 87 };
67 RegisterHandlers(functions); 88 RegisterHandlers(functions);
68 } 89 }
90
91private:
92 void GetTitleId(Kernel::HLERequestContext& ctx) {
93 IPC::RequestParser rp{ctx};
94 const auto process_id = rp.PopRaw<u64>();
95
96 LOG_DEBUG(Service_PM, "called, process_id={:016X}", process_id);
97
98 const auto process = SearchProcessList(process_list, [process_id](const auto& process) {
99 return process->GetProcessID() == process_id;
100 });
101
102 if (!process.has_value()) {
103 IPC::ResponseBuilder rb{ctx, 2};
104 rb.Push(ERROR_PROCESS_NOT_FOUND);
105 return;
106 }
107
108 IPC::ResponseBuilder rb{ctx, 4};
109 rb.Push(RESULT_SUCCESS);
110 rb.Push((*process)->GetTitleID());
111 }
112
113 const std::vector<Kernel::SharedPtr<Kernel::Process>>& process_list;
69}; 114};
70 115
71class Shell final : public ServiceFramework<Shell> { 116class Shell final : public ServiceFramework<Shell> {