1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-26 13:52:21 +00:00

ProcessManager: Add pm:info, fix pm:shell missing qualifiers

This commit is contained in:
Michael Scire 2018-05-04 20:16:40 -06:00
parent e596fd0de5
commit 772401b81f
5 changed files with 65 additions and 13 deletions

View file

@ -0,0 +1,31 @@
#include <switch.h>
#include "pm_registration.hpp"
#include "pm_info.hpp"
Result InformationService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) {
Result rc = 0xF601;
switch ((InformationCmd)cmd_id) {
case Information_Cmd_GetTitleId:
rc = WrapIpcCommandImpl<&InformationService::get_title_id>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break;
default:
break;
}
return rc;
}
Result InformationService::handle_deferred() {
/* This service is never deferrable. */
return 0;
}
std::tuple<Result, u64> InformationService::get_title_id(u64 pid) {
Registration::AutoProcessListLock auto_lock;
Registration::Process *proc = Registration::GetProcess(pid);
if (proc != NULL) {
return {0x0, proc->tid_sid.title_id};
} else {
return {0x20F, 0x0};
}
}

View file

@ -0,0 +1,17 @@
#pragma once
#include <switch.h>
#include <stratosphere/iserviceobject.hpp>
enum InformationCmd {
Information_Cmd_GetTitleId = 0,
};
class InformationService : IServiceObject {
public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size);
virtual Result handle_deferred();
private:
/* Actual commands. */
std::tuple<Result, u64> get_title_id(u64 pid);
};

View file

@ -7,6 +7,8 @@
#include <stratosphere.hpp> #include <stratosphere.hpp>
#include "pm_boot_mode.hpp" #include "pm_boot_mode.hpp"
#include "pm_info.hpp"
#include "pm_shell.hpp"
#include "pm_process_track.hpp" #include "pm_process_track.hpp"
#include "pm_registration.hpp" #include "pm_registration.hpp"
@ -107,7 +109,9 @@ int main(int argc, char **argv)
WaitableManager *server_manager = new WaitableManager(U64_MAX); WaitableManager *server_manager = new WaitableManager(U64_MAX);
/* TODO: Create services. */ /* TODO: Create services. */
server_manager->add_waitable(new ServiceServer<BootModeService>("pm:bm", 4)); server_manager->add_waitable(new ServiceServer<ShellService>("pm:shell", 3));
server_manager->add_waitable(new ServiceServer<BootModeService>("pm:bm", 5));
server_manager->add_waitable(new ServiceServer<InformationService>("pm:info", 1));
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->process(); server_manager->process();

View file

@ -51,7 +51,7 @@ Result ShellService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id
rc = WrapIpcCommandImpl<&ShellService::get_process_event_type>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&ShellService::get_process_event_type>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
case Shell_Cmd_FinalizeExitedProcess: case Shell_Cmd_FinalizeExitedProcess:
rc = WrapIpcCommandImpl<&ShellService::finalize_dead_process>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&ShellService::finalize_exited_process>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
case Shell_Cmd_ClearProcessNotificationFlag: case Shell_Cmd_ClearProcessNotificationFlag:
rc = WrapIpcCommandImpl<&ShellService::clear_process_notification_flag>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&ShellService::clear_process_notification_flag>(this, r, out_c, pointer_buffer, pointer_buffer_size);
@ -77,13 +77,13 @@ Result ShellService::handle_deferred() {
return 0; return 0;
} }
std::tuple<Result, u64> launch_process(u64 launch_flags, Registration::TidSid tid_sid) { std::tuple<Result, u64> ShellService::launch_process(u64 launch_flags, Registration::TidSid tid_sid) {
u64 pid = 0; u64 pid = 0;
Result rc = Registration::LaunchProcessByTidSid(tid_sid, launch_flags, &pid); Result rc = Registration::LaunchProcessByTidSid(tid_sid, launch_flags, &pid);
return {rc, pid}; return {rc, pid};
} }
std::tuple<Result> terminate_process_id(u64 pid) { std::tuple<Result> ShellService::terminate_process_id(u64 pid) {
Registration::AutoProcessListLock auto_lock; Registration::AutoProcessListLock auto_lock;
Registration::Process *proc = Registration::GetProcess(pid); Registration::Process *proc = Registration::GetProcess(pid);
@ -94,7 +94,7 @@ std::tuple<Result> terminate_process_id(u64 pid) {
} }
} }
std::tuple<Result> terminate_title_id(u64 tid) { std::tuple<Result> ShellService::terminate_title_id(u64 tid) {
Registration::AutoProcessListLock auto_lock; Registration::AutoProcessListLock auto_lock;
Registration::Process *proc = Registration::GetProcessByTitleId(tid); Registration::Process *proc = Registration::GetProcessByTitleId(tid);
@ -105,17 +105,17 @@ std::tuple<Result> terminate_title_id(u64 tid) {
} }
} }
std::tuple<Result, CopiedHandle> get_process_wait_event() { std::tuple<Result, CopiedHandle> ShellService::get_process_wait_event() {
return {0x0, Registration::GetProcessEventHandle()}; return {0x0, Registration::GetProcessEventHandle()};
} }
std::tuple<Result, u64, u64> get_process_event_type() { std::tuple<Result, u64, u64> ShellService::get_process_event_type() {
u64 type, pid; u64 type, pid;
Registration::GetProcessEventType(&pid, &type); Registration::GetProcessEventType(&pid, &type);
return {0x0, type, pid}; return {0x0, type, pid};
} }
std::tuple<Result> finalize_exited_process(u64 pid) { std::tuple<Result> ShellService::finalize_exited_process(u64 pid) {
Registration::AutoProcessListLock auto_lock; Registration::AutoProcessListLock auto_lock;
Registration::Process *proc = Registration::GetProcess(pid); Registration::Process *proc = Registration::GetProcess(pid);
@ -129,7 +129,7 @@ std::tuple<Result> finalize_exited_process(u64 pid) {
} }
} }
std::tuple<Result> clear_process_notification_flag(u64 pid) { std::tuple<Result> ShellService::clear_process_notification_flag(u64 pid) {
Registration::AutoProcessListLock auto_lock; Registration::AutoProcessListLock auto_lock;
Registration::Process *proc = Registration::GetProcess(pid); Registration::Process *proc = Registration::GetProcess(pid);
@ -141,7 +141,7 @@ std::tuple<Result> clear_process_notification_flag(u64 pid) {
} }
} }
std::tuple<Result> notify_boot_finished() { std::tuple<Result> ShellService::notify_boot_finished() {
u64 boot2_pid; u64 boot2_pid;
if (!g_has_boot_finished) { if (!g_has_boot_finished) {
g_has_boot_finished = true; g_has_boot_finished = true;
@ -150,7 +150,7 @@ std::tuple<Result> notify_boot_finished() {
return {0}; return {0};
} }
std::tuple<Result, u64> get_application_process_id() { std::tuple<Result, u64> ShellService::get_application_process_id() {
Registration::AutoProcessListLock auto_lock; Registration::AutoProcessListLock auto_lock;
Registration::Process *app_proc; Registration::Process *app_proc;
@ -160,7 +160,7 @@ std::tuple<Result, u64> get_application_process_id() {
return {0x20F, 0}; return {0x20F, 0};
} }
std::tuple<Result> boost_system_memory_resource_limit() { std::tuple<Result> ShellService::boost_system_memory_resource_limit() {
if (!kernelAbove400()) { if (!kernelAbove400()) {
return {0xF601}; return {0xF601};
} }

View file

@ -42,7 +42,7 @@ class ShellService : IServiceObject {
std::tuple<Result> terminate_title_id(u64 tid); std::tuple<Result> terminate_title_id(u64 tid);
std::tuple<Result, CopiedHandle> get_process_wait_event(); std::tuple<Result, CopiedHandle> get_process_wait_event();
std::tuple<Result, u64, u64> get_process_event_type(); std::tuple<Result, u64, u64> get_process_event_type();
std::tuple<Result> finalize_dead_process(u64 pid); std::tuple<Result> finalize_exited_process(u64 pid);
std::tuple<Result> clear_process_notification_flag(u64 pid); std::tuple<Result> clear_process_notification_flag(u64 pid);
std::tuple<Result> notify_boot_finished(); std::tuple<Result> notify_boot_finished();
std::tuple<Result, u64> get_application_process_id(); std::tuple<Result, u64> get_application_process_id();