mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-23 04:41:12 +00:00
strat: replace kernel/dbg magic numbers with result defs
This commit is contained in:
parent
285feba42b
commit
acffae6643
13 changed files with 52 additions and 33 deletions
|
@ -142,7 +142,9 @@ Result LayeredRomFS::Read(void *buffer, size_t size, u64 offset) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatalSimple(0xF601);
|
/* TODO: Better error. */
|
||||||
|
fatalSimple(ResultKernelConnectionClosed);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
read_so_far += cur_read_size;
|
read_so_far += cur_read_size;
|
||||||
offset += cur_read_size;
|
offset += cur_read_size;
|
||||||
|
|
|
@ -43,7 +43,7 @@ void RomFSBuildContext::VisitDirectory(FsFileSystem *filesys, RomFSBuildDirector
|
||||||
child->path = new char[child->path_len + 1];
|
child->path = new char[child->path_len + 1];
|
||||||
strcpy(child->path, parent->path);
|
strcpy(child->path, parent->path);
|
||||||
if (child->path_len > FS_MAX_PATH - 1) {
|
if (child->path_len > FS_MAX_PATH - 1) {
|
||||||
fatalSimple(0xF601);
|
fatalSimple(ResultFsTooLongPath);
|
||||||
}
|
}
|
||||||
strcat(child->path + parent->path_len, "/");
|
strcat(child->path + parent->path_len, "/");
|
||||||
strcat(child->path + parent->path_len, this->dir_entry.name);
|
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];
|
child->path = new char[child->path_len + 1];
|
||||||
strcpy(child->path, parent->path);
|
strcpy(child->path, parent->path);
|
||||||
if (child->path_len > FS_MAX_PATH - 1) {
|
if (child->path_len > FS_MAX_PATH - 1) {
|
||||||
fatalSimple(0xF601);
|
fatalSimple(ResultFsTooLongPath);
|
||||||
}
|
}
|
||||||
strcat(child->path + parent->path_len, "/");
|
strcat(child->path + parent->path_len, "/");
|
||||||
strcat(child->path + parent->path_len, this->dir_entry.name);
|
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];
|
child->path = new char[child->path_len + 1];
|
||||||
strcpy(child->path, parent->path);
|
strcpy(child->path, parent->path);
|
||||||
if (child->path_len > FS_MAX_PATH - 1) {
|
if (child->path_len > FS_MAX_PATH - 1) {
|
||||||
fatalSimple(0xF601);
|
fatalSimple(ResultFsTooLongPath);
|
||||||
}
|
}
|
||||||
strcat(child->path + parent->path_len, "/");
|
strcat(child->path + parent->path_len, "/");
|
||||||
strncat(child->path + parent->path_len, cur_file->name, cur_file->name_size);
|
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];
|
child->path = new char[child->path_len + 1];
|
||||||
strcpy(child->path, parent->path);
|
strcpy(child->path, parent->path);
|
||||||
if (child->path_len > FS_MAX_PATH - 1) {
|
if (child->path_len > FS_MAX_PATH - 1) {
|
||||||
fatalSimple(0xF601);
|
fatalSimple(ResultFsTooLongPath);
|
||||||
}
|
}
|
||||||
strcat(child->path + parent->path_len, "/");
|
strcat(child->path + parent->path_len, "/");
|
||||||
strncat(child->path + parent->path_len, cur_child->name, cur_child->name_size);
|
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;
|
delete child;
|
||||||
}
|
}
|
||||||
if (real == NULL) {
|
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);
|
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<RomFSSourceInfo> *out_infos) {
|
||||||
if (expected != cur_file->orig_offset) {
|
if (expected != cur_file->orig_offset) {
|
||||||
if (expected > cur_file->orig_offset) {
|
if (expected > cur_file->orig_offset) {
|
||||||
/* This case should NEVER happen. */
|
/* This case should NEVER happen. */
|
||||||
fatalSimple(0xF601);
|
/* TODO: Better error. */
|
||||||
|
fatalSimple(ResultKernelConnectionClosed);
|
||||||
}
|
}
|
||||||
this->file_partition_size += cur_file->orig_offset - expected;
|
this->file_partition_size += cur_file->orig_offset - expected;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +350,9 @@ void RomFSBuildContext::Build(std::vector<RomFSSourceInfo> *out_infos) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatalSimple(0xF601);
|
/* TODO: Better error. */
|
||||||
|
fatalSimple(ResultKernelConnectionClosed);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,9 @@ struct RomFSSourceInfo {
|
||||||
case RomFSDataSource::MetaData:
|
case RomFSDataSource::MetaData:
|
||||||
case RomFSDataSource::Memory:
|
case RomFSDataSource::Memory:
|
||||||
default:
|
default:
|
||||||
fatalSimple(0xF601);
|
/* TODO: Better error. */
|
||||||
|
fatalSimple(ResultKernelConnectionClosed);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +99,9 @@ struct RomFSSourceInfo {
|
||||||
case RomFSDataSource::BaseRomFS:
|
case RomFSDataSource::BaseRomFS:
|
||||||
case RomFSDataSource::FileRomFS:
|
case RomFSDataSource::FileRomFS:
|
||||||
default:
|
default:
|
||||||
fatalSimple(0xF601);
|
/* TODO: Better error. */
|
||||||
|
fatalSimple(ResultKernelConnectionClosed);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +114,9 @@ struct RomFSSourceInfo {
|
||||||
case RomFSDataSource::BaseRomFS:
|
case RomFSDataSource::BaseRomFS:
|
||||||
case RomFSDataSource::FileRomFS:
|
case RomFSDataSource::FileRomFS:
|
||||||
default:
|
default:
|
||||||
fatalSimple(0xF601);
|
/* TODO: Better error. */
|
||||||
|
fatalSimple(ResultKernelConnectionClosed);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +133,9 @@ struct RomFSSourceInfo {
|
||||||
std::free((void*)this->memory_source_info.data);
|
std::free((void*)this->memory_source_info.data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatalSimple(0xF601);
|
/* TODO: Better error. */
|
||||||
|
fatalSimple(ResultKernelConnectionClosed);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ Result DebugMonitorService::GetProcessId(Out<u64> out_pid, Handle hnd) {
|
||||||
|
|
||||||
Result DebugMonitorService::GetProcessHandle(Out<Handle> out_hnd, u64 pid) {
|
Result DebugMonitorService::GetProcessHandle(Out<Handle> out_hnd, u64 pid) {
|
||||||
Result rc = svcDebugActiveProcess(out_hnd.GetPointer(), pid);
|
Result rc = svcDebugActiveProcess(out_hnd.GetPointer(), pid);
|
||||||
if (rc == 0xF401) {
|
if (rc == ResultKernelAlreadyExists) {
|
||||||
rc = 0x4B7;
|
rc = ResultDebugAlreadyAttached;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,8 @@ static void FixPath(char *dst, size_t dst_size, InBuffer<char> &path) {
|
||||||
|
|
||||||
Result DebugMonitorService::TargetIO_FileOpen(OutBuffer<u64> out_hnd, InBuffer<char> path, int open_mode, u32 create_mode) {
|
Result DebugMonitorService::TargetIO_FileOpen(OutBuffer<u64> out_hnd, InBuffer<char> path, int open_mode, u32 create_mode) {
|
||||||
if (out_hnd.num_elements != 1) {
|
if (out_hnd.num_elements != 1) {
|
||||||
return 0xF601;
|
/* Serialization error. */
|
||||||
|
return ResultKernelConnectionClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result rc = EnsureSdInitialized();
|
Result rc = EnsureSdInitialized();
|
||||||
|
@ -151,7 +152,8 @@ Result DebugMonitorService::TargetIO_FileOpen(OutBuffer<u64> out_hnd, InBuffer<c
|
||||||
|
|
||||||
Result DebugMonitorService::TargetIO_FileClose(InBuffer<u64> hnd) {
|
Result DebugMonitorService::TargetIO_FileClose(InBuffer<u64> hnd) {
|
||||||
if (hnd.num_elements != 1) {
|
if (hnd.num_elements != 1) {
|
||||||
return 0xF601;
|
/* Serialization error. */
|
||||||
|
return ResultKernelConnectionClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CloseFileByHandle(hnd[0]);
|
return CloseFileByHandle(hnd[0]);
|
||||||
|
@ -159,7 +161,8 @@ Result DebugMonitorService::TargetIO_FileClose(InBuffer<u64> hnd) {
|
||||||
|
|
||||||
Result DebugMonitorService::TargetIO_FileRead(InBuffer<u64> hnd, OutBuffer<u8, BufferType_Type1> out_data, Out<u32> out_read, u64 offset) {
|
Result DebugMonitorService::TargetIO_FileRead(InBuffer<u64> hnd, OutBuffer<u8, BufferType_Type1> out_data, Out<u32> out_read, u64 offset) {
|
||||||
if (hnd.num_elements != 1) {
|
if (hnd.num_elements != 1) {
|
||||||
return 0xF601;
|
/* Serialization error. */
|
||||||
|
return ResultKernelConnectionClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
FsFile f;
|
FsFile f;
|
||||||
|
@ -176,7 +179,8 @@ Result DebugMonitorService::TargetIO_FileRead(InBuffer<u64> hnd, OutBuffer<u8, B
|
||||||
|
|
||||||
Result DebugMonitorService::TargetIO_FileWrite(InBuffer<u64> hnd, InBuffer<u8, BufferType_Type1> data, Out<u32> out_written, u64 offset) {
|
Result DebugMonitorService::TargetIO_FileWrite(InBuffer<u64> hnd, InBuffer<u8, BufferType_Type1> data, Out<u32> out_written, u64 offset) {
|
||||||
if (hnd.num_elements != 1) {
|
if (hnd.num_elements != 1) {
|
||||||
return 0xF601;
|
/* Serialization error. */
|
||||||
|
return ResultKernelConnectionClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
FsFile f;
|
FsFile f;
|
||||||
|
@ -201,7 +205,8 @@ Result DebugMonitorService::TargetIO_FileSetAttributes(InBuffer<char> path, InBu
|
||||||
|
|
||||||
Result DebugMonitorService::TargetIO_FileGetInformation(InBuffer<char> path, OutBuffer<u64> out_info, Out<int> is_directory) {
|
Result DebugMonitorService::TargetIO_FileGetInformation(InBuffer<char> path, OutBuffer<u64> out_info, Out<int> is_directory) {
|
||||||
if (out_info.num_elements != 4) {
|
if (out_info.num_elements != 4) {
|
||||||
return 0xF601;
|
/* Serialization error. */
|
||||||
|
return ResultKernelConnectionClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result rc = EnsureSdInitialized();
|
Result rc = EnsureSdInitialized();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d448c03c5d65a413b68e504d93929ef161858dcb
|
Subproject commit a3ca9cf1a352899b3a4289e210f094997cbacbaf
|
|
@ -50,7 +50,7 @@ Result MapUtils::LocateSpaceForMapModern(u64 *out, u64 out_size) {
|
||||||
|
|
||||||
cur_base = address_space.addspace_base;
|
cur_base = address_space.addspace_base;
|
||||||
|
|
||||||
rc = 0xD001;
|
rc = ResultKernelOutOfMemory;
|
||||||
cur_end = cur_base + out_size;
|
cur_end = cur_base + out_size;
|
||||||
if (cur_end <= cur_base) {
|
if (cur_end <= cur_base) {
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -103,7 +103,7 @@ Result MapUtils::LocateSpaceForMapDeprecated(u64 *out, u64 out_size) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = 0xD001;
|
rc = ResultKernelOutOfMemory;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (mem_info.type == 0x10) {
|
if (mem_info.type == 0x10) {
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -152,7 +152,7 @@ Result MapUtils::MapCodeMemoryForProcessModern(Handle process_h, u64 base_addres
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rc = svcMapProcessCodeMemory(process_h, try_address, base_address, size);
|
rc = svcMapProcessCodeMemory(process_h, try_address, base_address, size);
|
||||||
if (rc != 0xD401) {
|
if (rc != ResultKernelInvalidMemoryState) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ Result MapUtils::MapCodeMemoryForProcessDeprecated(Handle process_h, bool is_64_
|
||||||
for (unsigned int i = 0; i < 0x200; i++) {
|
for (unsigned int i = 0; i < 0x200; i++) {
|
||||||
try_address = addspace_base + (RandomUtils::GetRandomU64((u64)(addspace_size - size) >> 12) << 12);
|
try_address = addspace_base + (RandomUtils::GetRandomU64((u64)(addspace_size - size) >> 12) << 12);
|
||||||
rc = svcMapProcessCodeMemory(process_h, try_address, base_address, size);
|
rc = svcMapProcessCodeMemory(process_h, try_address, base_address, size);
|
||||||
if (rc != 0xD401) {
|
if (rc != ResultKernelInvalidMemoryState) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ Result NsoUtils::CalculateNsoLoadExtents(u32 addspace_type, u32 args_size, NsoLo
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* TODO: Panic. */
|
/* TODO: Panic. */
|
||||||
return 0xD001;
|
return ResultKernelOutOfMemory;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (addspace_type & 2) {
|
if (addspace_type & 2) {
|
||||||
|
@ -221,7 +221,7 @@ Result NsoUtils::CalculateNsoLoadExtents(u32 addspace_type, u32 args_size, NsoLo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (extents->total_size > addspace_size) {
|
if (extents->total_size > addspace_size) {
|
||||||
return 0xD001;
|
return ResultKernelOutOfMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 aslr_slide = 0;
|
u64 aslr_slide = 0;
|
||||||
|
|
|
@ -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);
|
Result rc = Registration::LaunchProcessByTidSid(Registration::TidSid{(u64)title_id, storage_id}, launch_flags, &local_pid);
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
case 0xCE01:
|
case ResultKernelResourceExhausted:
|
||||||
/* Out of resource! */
|
/* Out of resource! */
|
||||||
std::abort();
|
std::abort();
|
||||||
break;
|
break;
|
||||||
case 0xDE01:
|
case ResultKernelOutOfMemory:
|
||||||
/* Out of memory! */
|
/* Out of memory! */
|
||||||
std::abort();
|
std::abort();
|
||||||
break;
|
break;
|
||||||
case 0xD001:
|
case ResultKernelLimitReached:
|
||||||
/* Limit Reached! */
|
/* Limit Reached! */
|
||||||
std::abort();
|
std::abort();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -89,7 +89,7 @@ Result DebugMonitorService::AtmosphereGetProcessInfo(Out<CopiedHandle> proc_hand
|
||||||
Result DebugMonitorService::AtmosphereGetCurrentLimitInfo(Out<u64> cur_val, Out<u64> lim_val, u32 category, u32 resource) {
|
Result DebugMonitorService::AtmosphereGetCurrentLimitInfo(Out<u64> cur_val, Out<u64> lim_val, u32 category, u32 resource) {
|
||||||
Result rc;
|
Result rc;
|
||||||
if(category > ResourceLimitUtils::ResourceLimitCategory::ResourceLimitCategory_Applet) {
|
if(category > ResourceLimitUtils::ResourceLimitCategory::ResourceLimitCategory_Applet) {
|
||||||
return 0xF001;
|
return ResultKernelInvalidEnumValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle limit_h = ResourceLimitUtils::GetResourceLimitHandleByCategory((ResourceLimitUtils::ResourceLimitCategory) category);
|
Handle limit_h = ResourceLimitUtils::GetResourceLimitHandleByCategory((ResourceLimitUtils::ResourceLimitCategory) category);
|
||||||
|
|
|
@ -275,7 +275,7 @@ Result Registration::HandleSignaledProcess(std::shared_ptr<Registration::Process
|
||||||
} else {
|
} else {
|
||||||
FinalizeExitedProcess(process);
|
FinalizeExitedProcess(process);
|
||||||
}
|
}
|
||||||
return 0xF601;
|
return ResultKernelConnectionClosed;
|
||||||
case ProcessState_DebugSuspended:
|
case ProcessState_DebugSuspended:
|
||||||
if (process->flags & PROCESSFLAGS_NOTIFYDEBUGEVENTS) {
|
if (process->flags & PROCESSFLAGS_NOTIFYDEBUGEVENTS) {
|
||||||
process->flags |= (PROCESSFLAGS_DEBUGEVENTPENDING | PROCESSFLAGS_DEBUGSUSPENDED);
|
process->flags |= (PROCESSFLAGS_DEBUGEVENTPENDING | PROCESSFLAGS_DEBUGSUSPENDED);
|
||||||
|
|
|
@ -276,7 +276,7 @@ Result ResourceLimitUtils::BoostSystemMemoryResourceLimit(u64 boost_size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rc = 0xF601;
|
rc = ResultKernelConnectionClosed;
|
||||||
}
|
}
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
g_system_boost_size = boost_size;
|
g_system_boost_size = boost_size;
|
||||||
|
|
|
@ -282,7 +282,7 @@ Result Registration::GetServiceHandle(u64 pid, u64 service, Handle *out) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
if ((rc & 0x3FFFFF) == 0xE01) {
|
if ((rc & 0x3FFFFF) == ResultKernelOutOfSessions) {
|
||||||
return ResultSmInsufficientSessions;
|
return ResultSmInsufficientSessions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue