diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layeredrom.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layeredrom.cpp index 044e742e7..b225bb4b2 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layeredrom.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layeredrom.cpp @@ -142,7 +142,9 @@ Result LayeredRomFS::Read(void *buffer, size_t size, u64 offset) { } break; default: - fatalSimple(0xF601); + /* TODO: Better error. */ + fatalSimple(ResultKernelConnectionClosed); + break; } read_so_far += cur_read_size; offset += cur_read_size; diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfsbuild.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfsbuild.cpp index b2073083d..48e5e8a25 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfsbuild.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfsbuild.cpp @@ -43,7 +43,7 @@ void RomFSBuildContext::VisitDirectory(FsFileSystem *filesys, RomFSBuildDirector child->path = new char[child->path_len + 1]; strcpy(child->path, parent->path); if (child->path_len > FS_MAX_PATH - 1) { - fatalSimple(0xF601); + fatalSimple(ResultFsTooLongPath); } strcat(child->path + parent->path_len, "/"); strcat(child->path + parent->path_len, this->dir_entry.name); @@ -62,7 +62,7 @@ void RomFSBuildContext::VisitDirectory(FsFileSystem *filesys, RomFSBuildDirector child->path = new char[child->path_len + 1]; strcpy(child->path, parent->path); if (child->path_len > FS_MAX_PATH - 1) { - fatalSimple(0xF601); + fatalSimple(ResultFsTooLongPath); } strcat(child->path + parent->path_len, "/"); strcat(child->path + parent->path_len, this->dir_entry.name); @@ -116,7 +116,7 @@ void RomFSBuildContext::VisitDirectory(RomFSBuildDirectoryContext *parent, u32 p child->path = new char[child->path_len + 1]; strcpy(child->path, parent->path); if (child->path_len > FS_MAX_PATH - 1) { - fatalSimple(0xF601); + fatalSimple(ResultFsTooLongPath); } strcat(child->path + parent->path_len, "/"); strncat(child->path + parent->path_len, cur_file->name, cur_file->name_size); @@ -146,7 +146,7 @@ void RomFSBuildContext::VisitDirectory(RomFSBuildDirectoryContext *parent, u32 p child->path = new char[child->path_len + 1]; strcpy(child->path, parent->path); if (child->path_len > FS_MAX_PATH - 1) { - fatalSimple(0xF601); + fatalSimple(ResultFsTooLongPath); } strcat(child->path + parent->path_len, "/"); strncat(child->path + parent->path_len, cur_child->name, cur_child->name_size); @@ -157,7 +157,8 @@ void RomFSBuildContext::VisitDirectory(RomFSBuildDirectoryContext *parent, u32 p delete child; } if (real == NULL) { - fatalSimple(0xF601); + /* TODO: Better error. */ + fatalSimple(ResultKernelConnectionClosed); } this->VisitDirectory(real, cur_child_offset, dir_table, dir_table_size, file_table, file_table_size); @@ -278,7 +279,8 @@ void RomFSBuildContext::Build(std::vector *out_infos) { if (expected != cur_file->orig_offset) { if (expected > cur_file->orig_offset) { /* This case should NEVER happen. */ - fatalSimple(0xF601); + /* TODO: Better error. */ + fatalSimple(ResultKernelConnectionClosed); } this->file_partition_size += cur_file->orig_offset - expected; } @@ -348,7 +350,9 @@ void RomFSBuildContext::Build(std::vector *out_infos) { } break; default: - fatalSimple(0xF601); + /* TODO: Better error. */ + fatalSimple(ResultKernelConnectionClosed); + break; } } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfsbuild.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfsbuild.hpp index bdc5f0058..424bfa825 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfsbuild.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfsbuild.hpp @@ -81,7 +81,9 @@ struct RomFSSourceInfo { case RomFSDataSource::MetaData: case RomFSDataSource::Memory: default: - fatalSimple(0xF601); + /* TODO: Better error. */ + fatalSimple(ResultKernelConnectionClosed); + break; } } @@ -97,7 +99,9 @@ struct RomFSSourceInfo { case RomFSDataSource::BaseRomFS: case RomFSDataSource::FileRomFS: default: - fatalSimple(0xF601); + /* TODO: Better error. */ + fatalSimple(ResultKernelConnectionClosed); + break; } } @@ -110,7 +114,9 @@ struct RomFSSourceInfo { case RomFSDataSource::BaseRomFS: case RomFSDataSource::FileRomFS: default: - fatalSimple(0xF601); + /* TODO: Better error. */ + fatalSimple(ResultKernelConnectionClosed); + break; } } @@ -127,7 +133,9 @@ struct RomFSSourceInfo { std::free((void*)this->memory_source_info.data); break; default: - fatalSimple(0xF601); + /* TODO: Better error. */ + fatalSimple(ResultKernelConnectionClosed); + break; } } diff --git a/stratosphere/dmnt/source/dmnt_service_debug.cpp b/stratosphere/dmnt/source/dmnt_service_debug.cpp index 2c384a910..0ca40724a 100644 --- a/stratosphere/dmnt/source/dmnt_service_debug.cpp +++ b/stratosphere/dmnt/source/dmnt_service_debug.cpp @@ -40,8 +40,8 @@ Result DebugMonitorService::GetProcessId(Out out_pid, Handle hnd) { Result DebugMonitorService::GetProcessHandle(Out out_hnd, u64 pid) { Result rc = svcDebugActiveProcess(out_hnd.GetPointer(), pid); - if (rc == 0xF401) { - rc = 0x4B7; + if (rc == ResultKernelAlreadyExists) { + rc = ResultDebugAlreadyAttached; } return rc; } diff --git a/stratosphere/dmnt/source/dmnt_service_target_io.cpp b/stratosphere/dmnt/source/dmnt_service_target_io.cpp index ef56cfdbd..0a3d71496 100644 --- a/stratosphere/dmnt/source/dmnt_service_target_io.cpp +++ b/stratosphere/dmnt/source/dmnt_service_target_io.cpp @@ -104,7 +104,8 @@ static void FixPath(char *dst, size_t dst_size, InBuffer &path) { Result DebugMonitorService::TargetIO_FileOpen(OutBuffer out_hnd, InBuffer path, int open_mode, u32 create_mode) { if (out_hnd.num_elements != 1) { - return 0xF601; + /* Serialization error. */ + return ResultKernelConnectionClosed; } Result rc = EnsureSdInitialized(); @@ -151,7 +152,8 @@ Result DebugMonitorService::TargetIO_FileOpen(OutBuffer out_hnd, InBuffer hnd) { if (hnd.num_elements != 1) { - return 0xF601; + /* Serialization error. */ + return ResultKernelConnectionClosed; } return CloseFileByHandle(hnd[0]); @@ -159,7 +161,8 @@ Result DebugMonitorService::TargetIO_FileClose(InBuffer hnd) { Result DebugMonitorService::TargetIO_FileRead(InBuffer hnd, OutBuffer out_data, Out out_read, u64 offset) { if (hnd.num_elements != 1) { - return 0xF601; + /* Serialization error. */ + return ResultKernelConnectionClosed; } FsFile f; @@ -176,7 +179,8 @@ Result DebugMonitorService::TargetIO_FileRead(InBuffer hnd, OutBuffer hnd, InBuffer data, Out out_written, u64 offset) { if (hnd.num_elements != 1) { - return 0xF601; + /* Serialization error. */ + return ResultKernelConnectionClosed; } FsFile f; @@ -201,7 +205,8 @@ Result DebugMonitorService::TargetIO_FileSetAttributes(InBuffer path, InBu Result DebugMonitorService::TargetIO_FileGetInformation(InBuffer path, OutBuffer out_info, Out is_directory) { if (out_info.num_elements != 4) { - return 0xF601; + /* Serialization error. */ + return ResultKernelConnectionClosed; } Result rc = EnsureSdInitialized(); diff --git a/stratosphere/libstratosphere b/stratosphere/libstratosphere index d448c03c5..a3ca9cf1a 160000 --- a/stratosphere/libstratosphere +++ b/stratosphere/libstratosphere @@ -1 +1 @@ -Subproject commit d448c03c5d65a413b68e504d93929ef161858dcb +Subproject commit a3ca9cf1a352899b3a4289e210f094997cbacbaf diff --git a/stratosphere/loader/source/ldr_map.cpp b/stratosphere/loader/source/ldr_map.cpp index 920ea7553..e94090ec7 100644 --- a/stratosphere/loader/source/ldr_map.cpp +++ b/stratosphere/loader/source/ldr_map.cpp @@ -50,7 +50,7 @@ Result MapUtils::LocateSpaceForMapModern(u64 *out, u64 out_size) { cur_base = address_space.addspace_base; - rc = 0xD001; + rc = ResultKernelOutOfMemory; cur_end = cur_base + out_size; if (cur_end <= cur_base) { return rc; @@ -103,7 +103,7 @@ Result MapUtils::LocateSpaceForMapDeprecated(u64 *out, u64 out_size) { return rc; } - rc = 0xD001; + rc = ResultKernelOutOfMemory; while (true) { if (mem_info.type == 0x10) { return rc; @@ -152,7 +152,7 @@ Result MapUtils::MapCodeMemoryForProcessModern(Handle process_h, u64 base_addres break; } rc = svcMapProcessCodeMemory(process_h, try_address, base_address, size); - if (rc != 0xD401) { + if (rc != ResultKernelInvalidMemoryState) { break; } } @@ -181,7 +181,7 @@ Result MapUtils::MapCodeMemoryForProcessDeprecated(Handle process_h, bool is_64_ for (unsigned int i = 0; i < 0x200; i++) { try_address = addspace_base + (RandomUtils::GetRandomU64((u64)(addspace_size - size) >> 12) << 12); rc = svcMapProcessCodeMemory(process_h, try_address, base_address, size); - if (rc != 0xD401) { + if (rc != ResultKernelInvalidMemoryState) { break; } } diff --git a/stratosphere/loader/source/ldr_nso.cpp b/stratosphere/loader/source/ldr_nso.cpp index a01cbee3b..a4968772b 100644 --- a/stratosphere/loader/source/ldr_nso.cpp +++ b/stratosphere/loader/source/ldr_nso.cpp @@ -209,7 +209,7 @@ Result NsoUtils::CalculateNsoLoadExtents(u32 addspace_type, u32 args_size, NsoLo break; default: /* TODO: Panic. */ - return 0xD001; + return ResultKernelOutOfMemory; } } else { if (addspace_type & 2) { @@ -221,7 +221,7 @@ Result NsoUtils::CalculateNsoLoadExtents(u32 addspace_type, u32 args_size, NsoLo } } if (extents->total_size > addspace_size) { - return 0xD001; + return ResultKernelOutOfMemory; } u64 aslr_slide = 0; diff --git a/stratosphere/pm/source/pm_boot2.cpp b/stratosphere/pm/source/pm_boot2.cpp index d37a0c025..7b395717f 100644 --- a/stratosphere/pm/source/pm_boot2.cpp +++ b/stratosphere/pm/source/pm_boot2.cpp @@ -62,15 +62,15 @@ static void LaunchTitle(Boot2KnownTitleId title_id, FsStorageId storage_id, u32 Result rc = Registration::LaunchProcessByTidSid(Registration::TidSid{(u64)title_id, storage_id}, launch_flags, &local_pid); switch (rc) { - case 0xCE01: + case ResultKernelResourceExhausted: /* Out of resource! */ std::abort(); break; - case 0xDE01: + case ResultKernelOutOfMemory: /* Out of memory! */ std::abort(); break; - case 0xD001: + case ResultKernelLimitReached: /* Limit Reached! */ std::abort(); break; diff --git a/stratosphere/pm/source/pm_debug_monitor.cpp b/stratosphere/pm/source/pm_debug_monitor.cpp index fe964da58..831dc6693 100644 --- a/stratosphere/pm/source/pm_debug_monitor.cpp +++ b/stratosphere/pm/source/pm_debug_monitor.cpp @@ -89,7 +89,7 @@ Result DebugMonitorService::AtmosphereGetProcessInfo(Out proc_hand Result DebugMonitorService::AtmosphereGetCurrentLimitInfo(Out cur_val, Out lim_val, u32 category, u32 resource) { Result rc; if(category > ResourceLimitUtils::ResourceLimitCategory::ResourceLimitCategory_Applet) { - return 0xF001; + return ResultKernelInvalidEnumValue; } Handle limit_h = ResourceLimitUtils::GetResourceLimitHandleByCategory((ResourceLimitUtils::ResourceLimitCategory) category); diff --git a/stratosphere/pm/source/pm_registration.cpp b/stratosphere/pm/source/pm_registration.cpp index 957f5ad08..06fd4b01f 100644 --- a/stratosphere/pm/source/pm_registration.cpp +++ b/stratosphere/pm/source/pm_registration.cpp @@ -275,7 +275,7 @@ Result Registration::HandleSignaledProcess(std::shared_ptrflags & PROCESSFLAGS_NOTIFYDEBUGEVENTS) { process->flags |= (PROCESSFLAGS_DEBUGEVENTPENDING | PROCESSFLAGS_DEBUGSUSPENDED); diff --git a/stratosphere/pm/source/pm_resource_limits.cpp b/stratosphere/pm/source/pm_resource_limits.cpp index b3e37cef7..28513a4f9 100644 --- a/stratosphere/pm/source/pm_resource_limits.cpp +++ b/stratosphere/pm/source/pm_resource_limits.cpp @@ -276,7 +276,7 @@ Result ResourceLimitUtils::BoostSystemMemoryResourceLimit(u64 boost_size) { } } } else { - rc = 0xF601; + rc = ResultKernelConnectionClosed; } if (R_SUCCEEDED(rc)) { g_system_boost_size = boost_size; diff --git a/stratosphere/sm/source/sm_registration.cpp b/stratosphere/sm/source/sm_registration.cpp index df8d6d3b1..08d346ec9 100644 --- a/stratosphere/sm/source/sm_registration.cpp +++ b/stratosphere/sm/source/sm_registration.cpp @@ -282,7 +282,7 @@ Result Registration::GetServiceHandle(u64 pid, u64 service, Handle *out) { } } if (R_FAILED(rc)) { - if ((rc & 0x3FFFFF) == 0xE01) { + if ((rc & 0x3FFFFF) == ResultKernelOutOfSessions) { return ResultSmInsufficientSessions; } }