2018-04-18 09:30:34 +00:00
|
|
|
#include <switch.h>
|
2018-04-18 22:24:40 +00:00
|
|
|
#include <cstdio>
|
2018-04-19 22:14:48 +00:00
|
|
|
#include <algorithm>
|
2018-06-12 22:00:09 +00:00
|
|
|
#include <stratosphere.hpp>
|
2018-04-18 09:30:34 +00:00
|
|
|
#include "ldr_debug_monitor.hpp"
|
|
|
|
#include "ldr_launch_queue.hpp"
|
2018-04-19 22:14:48 +00:00
|
|
|
#include "ldr_registration.hpp"
|
2018-04-18 09:30:34 +00:00
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
Result DebugMonitorService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) {
|
2018-04-18 09:52:19 +00:00
|
|
|
Result rc = 0xF601;
|
2018-04-19 05:00:10 +00:00
|
|
|
|
2018-04-18 09:52:19 +00:00
|
|
|
switch ((DebugMonitorServiceCmd)cmd_id) {
|
2018-04-18 18:10:45 +00:00
|
|
|
case Dmnt_Cmd_AddTitleToLaunchQueue:
|
2018-04-21 01:34:29 +00:00
|
|
|
rc = WrapIpcCommandImpl<&DebugMonitorService::add_title_to_launch_queue>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
2018-04-18 09:52:19 +00:00
|
|
|
break;
|
2018-04-18 18:10:45 +00:00
|
|
|
case Dmnt_Cmd_ClearLaunchQueue:
|
2018-04-21 01:34:29 +00:00
|
|
|
rc = WrapIpcCommandImpl<&DebugMonitorService::clear_launch_queue>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
2018-04-18 09:52:19 +00:00
|
|
|
break;
|
2018-04-18 18:10:45 +00:00
|
|
|
case Dmnt_Cmd_GetNsoInfo:
|
2018-04-21 01:34:29 +00:00
|
|
|
rc = WrapIpcCommandImpl<&DebugMonitorService::get_nso_info>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
2018-04-18 09:52:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
2018-04-18 09:30:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
std::tuple<Result> DebugMonitorService::add_title_to_launch_queue(u64 tid, InPointer<char> args) {
|
2018-05-05 15:47:25 +00:00
|
|
|
fprintf(stderr, "Add to launch queue: %p, %zX\n", args.pointer, args.num_elements);
|
2018-05-05 18:41:39 +00:00
|
|
|
return {LaunchQueue::add(tid, args.pointer, args.num_elements)};
|
2018-04-18 09:30:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
std::tuple<Result> DebugMonitorService::clear_launch_queue(u64 dat) {
|
|
|
|
fprintf(stderr, "Clear launch queue: %lx\n", dat);
|
2018-04-18 09:30:34 +00:00
|
|
|
LaunchQueue::clear();
|
2018-05-05 18:41:39 +00:00
|
|
|
return {0};
|
2018-04-18 09:30:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
std::tuple<Result, u32> DebugMonitorService::get_nso_info(u64 pid, OutPointerWithClientSize<Registration::NsoInfo> out) {
|
|
|
|
u32 out_num_nsos = 0;
|
|
|
|
|
2018-04-21 03:03:26 +00:00
|
|
|
std::fill(out.pointer, out.pointer + out.num_elements, (const Registration::NsoInfo){0});
|
2018-04-19 22:14:48 +00:00
|
|
|
|
2018-04-26 23:03:10 +00:00
|
|
|
Result rc = Registration::GetNsoInfosForProcessId(out.pointer, out.num_elements, pid, &out_num_nsos);
|
2018-04-21 03:03:26 +00:00
|
|
|
|
2018-05-05 18:41:39 +00:00
|
|
|
return {rc, out_num_nsos};
|
|
|
|
}
|