summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2019-06-27 01:05:04 +0200
committerZach Hilman <zachhilman@gmail.com>2019-06-27 01:05:04 +0200
commit49af3bcdcba76decc8aec5b6812eac04e488e47f (patch)
tree6b46afffc64470d57f48c9551b30ee4feed97b2f /src
parentMerge pull request #2548 from DarkLordZach/applet-shopn (diff)
downloadyuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.tar
yuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.tar.gz
yuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.tar.bz2
yuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.tar.lz
yuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.tar.xz
yuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.tar.zst
yuzu-49af3bcdcba76decc8aec5b6812eac04e488e47f.zip
Diffstat (limited to 'src')
-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 @@
namespace Service::PM {
+namespace {
+
+constexpr ResultCode ERROR_PROCESS_NOT_FOUND{ErrorModule::PM, 1};
+
+constexpr u64 NO_PROCESS_FOUND_PID{0};
+
+std::optional<Kernel::SharedPtr<Kernel::Process>> SearchProcessList(
+ const std::vector<Kernel::SharedPtr<Kernel::Process>>& process_list,
+ std::function<bool(const Kernel::SharedPtr<Kernel::Process>&)> predicate) {
+ const auto iter = std::find_if(process_list.begin(), process_list.end(), predicate);
+
+ if (iter == process_list.end()) {
+ return std::nullopt;
+ }
+
+ return *iter;
+}
+
+} // Anonymous namespace
+
class BootMode final : public ServiceFramework<BootMode> {
public:
explicit BootMode() : ServiceFramework{"pm:bm"} {
@@ -60,12 +80,37 @@ public:
class Info final : public ServiceFramework<Info> {
public:
- explicit Info() : ServiceFramework{"pm:info"} {
+ explicit Info(const std::vector<Kernel::SharedPtr<Kernel::Process>>& process_list)
+ : ServiceFramework{"pm:info"}, process_list(process_list) {
static const FunctionInfo functions[] = {
- {0, nullptr, "GetTitleId"},
+ {0, &Info::GetTitleId, "GetTitleId"},
};
RegisterHandlers(functions);
}
+
+private:
+ void GetTitleId(Kernel::HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto process_id = rp.PopRaw<u64>();
+
+ LOG_DEBUG(Service_PM, "called, process_id={:016X}", process_id);
+
+ const auto process = SearchProcessList(process_list, [process_id](const auto& process) {
+ return process->GetProcessID() == process_id;
+ });
+
+ if (!process.has_value()) {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ERROR_PROCESS_NOT_FOUND);
+ return;
+ }
+
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(RESULT_SUCCESS);
+ rb.Push((*process)->GetTitleID());
+ }
+
+ const std::vector<Kernel::SharedPtr<Kernel::Process>>& process_list;
};
class Shell final : public ServiceFramework<Shell> {