From a127233e41c35de2332b7ccbce66ae4b8c8db4d3 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 20 Apr 2018 21:03:26 -0600 Subject: [PATCH] Adjust padding for C descriptor size parsing --- stratosphere/loader/source/ipc_templating.hpp | 6 +++--- stratosphere/loader/source/ldr_debug_monitor.cpp | 9 ++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/stratosphere/loader/source/ipc_templating.hpp b/stratosphere/loader/source/ipc_templating.hpp index b3dd3be1f..f7ac28707 100644 --- a/stratosphere/loader/source/ipc_templating.hpp +++ b/stratosphere/loader/source/ipc_templating.hpp @@ -251,7 +251,7 @@ struct Validator> { if (r.RawSize < size_in_raw_data_with_out_pointers_for_arguments::value) { return 0xF601; } - + if (r.NumBuffers != num_inoutbuffers_in_arguments::value) { return 0xF601; } @@ -278,7 +278,7 @@ struct Validator> { size_t a_index = 0, b_index = num_inbuffers_in_arguments::value, x_index = 0, c_index = 0, h_index = 0; size_t cur_rawdata_index = 4; - size_t cur_c_size_offset = 8 + size_in_raw_data_for_arguments::value; + size_t cur_c_size_offset = 8 + size_in_raw_data_for_arguments::value + (0x10 - ((uintptr_t)r.Raw - (uintptr_t)r.RawWithoutPadding)); size_t total_c_size = 0; if (!(ValidateIpcParsedCommandArgument(r, cur_rawdata_index, cur_c_size_offset, a_index, b_index, x_index, c_index, h_index, total_c_size) && ...)) { @@ -303,7 +303,7 @@ struct Decoder> { static std::tuple Decode(IpcParsedCommand& r, IpcCommand &out_c, u8 *pointer_buffer) { size_t a_index = 0, b_index = num_inbuffers_in_arguments::value, x_index = 0, c_index = 0, h_index = 0; size_t cur_rawdata_index = 4; - size_t cur_c_size_offset = 8 + size_in_raw_data_for_arguments::value; + size_t cur_c_size_offset = 8 + size_in_raw_data_for_arguments::value + (0x10 - ((uintptr_t)r.Raw - (uintptr_t)r.RawWithoutPadding)); size_t pointer_buffer_offset = 0; return std::tuple { GetValueFromIpcParsedCommand(r, out_c, pointer_buffer, pointer_buffer_offset, cur_rawdata_index, cur_c_size_offset, a_index, b_index, x_index, c_index, h_index) diff --git a/stratosphere/loader/source/ldr_debug_monitor.cpp b/stratosphere/loader/source/ldr_debug_monitor.cpp index a7754e90a..218e82f47 100644 --- a/stratosphere/loader/source/ldr_debug_monitor.cpp +++ b/stratosphere/loader/source/ldr_debug_monitor.cpp @@ -6,11 +6,6 @@ #include "ldr_launch_queue.hpp" #include "ldr_registration.hpp" -std::tuple fake_clear_launch_queue() { - LaunchQueue::clear(); - return std::make_tuple(0); -} - Result DebugMonitorService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) { Result rc = 0xF601; @@ -44,9 +39,9 @@ std::tuple DebugMonitorService::clear_launch_queue(u64 dat) { std::tuple DebugMonitorService::get_nso_info(u64 pid, OutPointerWithClientSize out) { u32 out_num_nsos = 0; - //std::fill(out.pointer, out.pointer + out.num_elements, (const Registration::NsoInfo){0}); + std::fill(out.pointer, out.pointer + out.num_elements, (const Registration::NsoInfo){0}); Result rc = Registration::get_nso_infos_for_process_id(out.pointer, out.num_elements, pid, &out_num_nsos); - + return std::make_tuple(rc, out_num_nsos); } \ No newline at end of file