From 9e558dafeeb537748a01cc6c08baf4768b2e8bb5 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 7 May 2018 07:22:30 -0600 Subject: [PATCH 1/2] libstratosphere: Make boolean autoparsing match official semantics. --- .../libstratosphere/include/stratosphere/ipc_templating.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stratosphere/libstratosphere/include/stratosphere/ipc_templating.hpp b/stratosphere/libstratosphere/include/stratosphere/ipc_templating.hpp index 25d6f7b14..7fc259ecd 100644 --- a/stratosphere/libstratosphere/include/stratosphere/ipc_templating.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/ipc_templating.hpp @@ -210,6 +210,10 @@ T GetValueFromIpcParsedCommand(IpcParsedCommand& r, IpcCommand& out_c, u8 *point } else if constexpr (std::is_same::value) { cur_rawdata_index += sizeof(u64) / sizeof(u32); return PidDescriptor(r.Pid); + } else if constexpr (std::is_same::value) { + /* Official bools accept non-zero values with low bit unset as false. */ + cur_rawdata_index += size_in_raw_data::value / sizeof(u32); + return ((*(((u32 *)r.Raw + old_rawdata_index))) & 1) == 1; } else { cur_rawdata_index += size_in_raw_data::value / sizeof(u32); return *((T *)((u32 *)r.Raw + old_rawdata_index)); From b346c8f3759693f2291f4cb246fd6f7af6d4fdd6 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 7 May 2018 07:31:36 -0600 Subject: [PATCH 2/2] Fix minor bugs in loader/sm --- stratosphere/loader/source/ldr_registration.cpp | 2 +- stratosphere/sm/source/sm_user_service.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stratosphere/loader/source/ldr_registration.cpp b/stratosphere/loader/source/ldr_registration.cpp index 729a2c3ad..70204eca3 100644 --- a/stratosphere/loader/source/ldr_registration.cpp +++ b/stratosphere/loader/source/ldr_registration.cpp @@ -230,7 +230,7 @@ Result Registration::RemoveNroInfo(u64 index, Handle process_h, u64 nro_heap_add return 0xA809; } - for (unsigned int i = 0; i < NRR_INFO_MAX; i++) { + for (unsigned int i = 0; i < NRO_INFO_MAX; i++) { if (target_process->nro_infos[i].in_use && target_process->nro_infos[i].nro_heap_address == nro_heap_address) { NroInfo *info = &target_process->nro_infos[i]; Result rc = svcUnmapProcessCodeMemory(process_h, info->base_address + info->text_size + info->ro_size + info->rw_size, info->bss_heap_address, info->bss_heap_size); diff --git a/stratosphere/sm/source/sm_user_service.cpp b/stratosphere/sm/source/sm_user_service.cpp index b445a5ab3..0e3d91025 100644 --- a/stratosphere/sm/source/sm_user_service.cpp +++ b/stratosphere/sm/source/sm_user_service.cpp @@ -65,11 +65,11 @@ std::tuple UserService::register_service(u64 service, u8 is Result rc = 0x415; #ifdef SM_ENABLE_SMHAX if (!this->has_initialized) { - rc = Registration::RegisterServiceForPid(Registration::GetInitialProcessId(), service, max_sessions, is_light != 0, &service_h); + rc = Registration::RegisterServiceForPid(Registration::GetInitialProcessId(), service, max_sessions, (is_light & 1) != 0, &service_h); } #endif if (this->has_initialized) { - rc = Registration::RegisterServiceForPid(this->pid, service, max_sessions, is_light != 0, &service_h); + rc = Registration::RegisterServiceForPid(this->pid, service, max_sessions, (is_light & 1) != 0, &service_h); } return {rc, MovedHandle{service_h}}; }