ams: use R_SUCCEED, R_THROW globally

This commit is contained in:
Michael Scire
2022-03-26 00:14:36 -07:00
parent e5b1739f65
commit dd78ede99f
370 changed files with 2107 additions and 2107 deletions

View File

@@ -56,7 +56,7 @@ namespace ams::ldr {
entry.argument_size = size;
std::memcpy(entry.argument, argument, entry.argument_size);
return ResultSuccess();
R_SUCCEED();
}
}

View File

@@ -43,7 +43,7 @@ namespace ams::ldr {
for (auto &entry : m_argument_map) {
entry.program_id = ncm::InvalidProgramId;
}
return ResultSuccess();
R_SUCCEED();
}
private:
static int FindIndex(Entry *map, ncm::ProgramId program_id);

View File

@@ -353,7 +353,7 @@ namespace ams::ldr {
#undef VALIDATE_CASE
}
return ResultSuccess();
R_SUCCEED();
}
u16 MakeProgramInfoFlag(const util::BitPack32 *kac, size_t count) {

View File

@@ -68,7 +68,7 @@ namespace ams::ldr {
m_mounted_code = true;
}
return ResultSuccess();
R_SUCCEED();
}
void ScopedCodeMount::EnsureOverrideStatus(const ncm::ProgramLocation &loc) {
@@ -85,7 +85,7 @@ namespace ams::ldr {
if (static_cast<ncm::StorageId>(loc.storage_id) == ncm::StorageId::None) {
std::memset(out_path, 0, out_size);
std::memcpy(out_path, "/", std::min<size_t>(out_size, 2));
return ResultSuccess();
R_SUCCEED();
}
lr::Path path;
@@ -118,13 +118,13 @@ namespace ams::ldr {
std::memset(out_path, 0, out_size);
std::memcpy(out_path, path.str, std::min(out_size, sizeof(path)));
return ResultSuccess();
R_SUCCEED();
}
Result RedirectProgramPath(const char *path, size_t size, const ncm::ProgramLocation &loc) {
/* Check for storage id none. */
if (static_cast<ncm::StorageId>(loc.storage_id) == ncm::StorageId::None) {
return ResultSuccess();
R_SUCCEED();
}
/* Open location resolver. */
@@ -139,7 +139,7 @@ namespace ams::ldr {
/* Redirect the path. */
lr.RedirectProgramPath(lr_path, loc.program_id);
return ResultSuccess();
R_SUCCEED();
}
Result RedirectHtmlDocumentPathForHbl(const ncm::ProgramLocation &loc) {
@@ -156,7 +156,7 @@ namespace ams::ldr {
R_TRY(lr.ResolveProgramPath(std::addressof(path), loc.program_id));
lr.RedirectApplicationHtmlDocumentPath(path, loc.program_id, loc.program_id);
return ResultSuccess();
R_SUCCEED();
}
}

View File

@@ -74,7 +74,7 @@ namespace ams::pm::info {
Result HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id) {
*out = ldr::HasLaunchedBootProgram(program_id);
return ResultSuccess();
R_SUCCEED();
}
}

View File

@@ -76,7 +76,7 @@ namespace ams::ldr {
*out_status = status;
}
return ResultSuccess();
R_SUCCEED();
}
Result LoaderService::PinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) {
@@ -116,7 +116,7 @@ namespace ams::ldr {
Result LoaderService::SetEnabledProgramVerification(bool enabled) {
ldr::SetEnabledProgramVerification(enabled);
return ResultSuccess();
R_SUCCEED();
}
}

View File

@@ -47,7 +47,7 @@ namespace ams::ldr {
R_UNLESS(allowed_start <= start, ldr::ResultInvalidMeta());
R_UNLESS(start <= allowed_end, ldr::ResultInvalidMeta());
R_UNLESS(start + size <= allowed_end, ldr::ResultInvalidMeta());
return ResultSuccess();
R_SUCCEED();
}
Result ValidateNpdm(const Npdm *npdm, size_t size) {
@@ -77,7 +77,7 @@ namespace ams::ldr {
/* Validate Aci extends. */
R_TRY(ValidateSubregion(sizeof(Npdm), size, npdm->aci_offset, npdm->aci_size, sizeof(Aci)));
return ResultSuccess();
R_SUCCEED();
}
Result ValidateAcid(const Acid *acid, size_t size) {
@@ -94,7 +94,7 @@ namespace ams::ldr {
R_TRY(ValidateSubregion(sizeof(Acid), size, acid->sac_offset, acid->sac_size));
R_TRY(ValidateSubregion(sizeof(Acid), size, acid->kac_offset, acid->kac_size));
return ResultSuccess();
R_SUCCEED();
}
Result ValidateAci(const Aci *aci, size_t size) {
@@ -106,7 +106,7 @@ namespace ams::ldr {
R_TRY(ValidateSubregion(sizeof(Aci), size, aci->sac_offset, aci->sac_size));
R_TRY(ValidateSubregion(sizeof(Aci), size, aci->kac_offset, aci->kac_size));
return ResultSuccess();
R_SUCCEED();
}
const u8 *GetAcidSignatureModulus(u32 key_generation) {
@@ -117,7 +117,7 @@ namespace ams::ldr {
/* Loader did not check signatures prior to 10.0.0. */
if (hos::GetVersion() < hos::Version_10_0_0) {
meta->check_verification_data = false;
return ResultSuccess();
R_SUCCEED();
}
/* Verify the signature. */
@@ -133,7 +133,7 @@ namespace ams::ldr {
R_UNLESS(is_signature_valid || !IsEnabledProgramVerification(), ldr::ResultInvalidAcidSignature());
meta->check_verification_data = is_signature_valid;
return ResultSuccess();
R_SUCCEED();
}
Result LoadMetaFromFile(fs::FileHandle file, MetaCache *cache) {
@@ -182,7 +182,7 @@ namespace ams::ldr {
meta->modulus = acid->modulus;
}
return ResultSuccess();
R_SUCCEED();
}
}
@@ -270,7 +270,7 @@ namespace ams::ldr {
g_cached_override_status = status;
*out_meta = *meta;
return ResultSuccess();
R_SUCCEED();
}
Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) {
@@ -278,7 +278,7 @@ namespace ams::ldr {
return LoadMeta(out_meta, loc, status);
}
*out_meta = g_meta_cache.meta;
return ResultSuccess();
R_SUCCEED();
}
void InvalidateMetaCache() {

View File

@@ -126,7 +126,7 @@ namespace ams::ldr {
#else
AMS_UNUSED(program_id, version);
#endif
return ResultSuccess();
R_SUCCEED();
}
/* Helpers. */
@@ -157,7 +157,7 @@ namespace ams::ldr {
/* Copy flags. */
out->flags = MakeProgramInfoFlag(static_cast<const util::BitPack32 *>(meta->aci_kac), meta->aci->kac_size / sizeof(util::BitPack32));
return ResultSuccess();
R_SUCCEED();
}
bool IsApplet(const Meta *meta) {
@@ -195,7 +195,7 @@ namespace ams::ldr {
}
}
return ResultSuccess();
R_SUCCEED();
}
Result ValidateNsoHeaders(const NsoHeader *nso_headers, const bool *has_nso) {
@@ -214,7 +214,7 @@ namespace ams::ldr {
R_UNLESS(nso_headers[i].text_dst_offset == 0, ldr::ResultInvalidNso());
}
return ResultSuccess();
R_SUCCEED();
}
Result ValidateMeta(const Meta *meta, const ncm::ProgramLocation &loc, const fs::CodeVerificationData &code_verification_data) {
@@ -244,7 +244,7 @@ namespace ams::ldr {
}
/* All good. */
return ResultSuccess();
R_SUCCEED();
}
Result GetCreateProcessFlags(u32 *out, const Meta *meta, const u32 ldr_flags) {
@@ -272,7 +272,7 @@ namespace ams::ldr {
flags |= svc::CreateProcessFlag_AddressSpace64Bit;
break;
default:
return ldr::ResultInvalidMeta();
R_THROW(ldr::ResultInvalidMeta());
}
/* Set Enable Debug. */
@@ -317,7 +317,7 @@ namespace ams::ldr {
flags |= svc::CreateProcessFlag_PoolPartitionSystemNonSecure;
break;
default:
return ldr::ResultInvalidMeta();
R_THROW(ldr::ResultInvalidMeta());
}
} else if (hos::GetVersion() >= hos::Version_4_0_0) {
/* On 4.0.0+, the corresponding bit was simply "UseSecureMemory". */
@@ -332,7 +332,7 @@ namespace ams::ldr {
}
*out = flags;
return ResultSuccess();
R_SUCCEED();
}
Result GetCreateProcessParameter(svc::CreateProcessParameter *out, const Meta *meta, u32 flags, os::NativeHandle resource_limit) {
@@ -367,7 +367,7 @@ namespace ams::ldr {
out->system_resource_num_pages = meta->npdm->system_resource_size >> 12;
}
return ResultSuccess();
R_SUCCEED();
}
ALWAYS_INLINE u64 GetCurrentProcessInfo(svc::InfoType info_type) {
@@ -415,7 +415,7 @@ namespace ams::ldr {
/* If the memory range is free and big enough, use it. */
if (mem_info.state == svc::MemoryState_Free && mapping_size <= ((mem_info.base_address + mem_info.size) - address)) {
*out = address;
return ResultSuccess();
R_SUCCEED();
}
/* Check that we can advance. */
@@ -514,7 +514,7 @@ namespace ams::ldr {
out_param->code_address = aslr_start;
out_param->code_num_pages = total_size >> 12;
return ResultSuccess();
R_SUCCEED();
}
Result CreateProcessImpl(ProcessInfo *out, const Meta *meta, const NsoHeader *nso_headers, const bool *has_nso, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit) {
@@ -532,7 +532,7 @@ namespace ams::ldr {
/* Set the output handle. */
out->process_handle = process_handle;
return ResultSuccess();
R_SUCCEED();
}
Result LoadNsoSegment(fs::FileHandle file, const NsoHeader::SegmentInfo *segment, size_t file_size, const u8 *file_hash, bool is_compressed, bool check_hash, uintptr_t map_base, uintptr_t map_end) {
@@ -565,7 +565,7 @@ namespace ams::ldr {
R_UNLESS(std::memcmp(hash, file_hash, sizeof(hash)) == 0, ldr::ResultInvalidNso());
}
return ResultSuccess();
R_SUCCEED();
}
Result LoadAutoLoadModule(os::NativeHandle process_handle, fs::FileHandle file, uintptr_t map_address, const NsoHeader *nso_header, uintptr_t nso_address, size_t nso_size) {
@@ -612,7 +612,7 @@ namespace ams::ldr {
R_TRY(svc::SetProcessMemoryPermission(process_handle, nso_address + nso_header->rw_dst_offset, rw_size, svc::MemoryPermission_ReadWrite));
}
return ResultSuccess();
R_SUCCEED();
}
Result LoadAutoLoadModules(const ProcessInfo *process_info, const NsoHeader *nso_headers, const bool *has_nso, const ArgumentStore::Entry *argument) {
@@ -651,7 +651,7 @@ namespace ams::ldr {
R_TRY(svc::SetProcessMemoryPermission(process_info->process_handle, process_info->args_address, process_info->args_size, svc::MemoryPermission_ReadWrite));
}
return ResultSuccess();
R_SUCCEED();
}
}
@@ -742,22 +742,22 @@ namespace ams::ldr {
Result PinProgram(PinId *out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status) {
R_UNLESS(RoManager::GetInstance().Allocate(out_id, loc, override_status), ldr::ResultMaxProcess());
return ResultSuccess();
R_SUCCEED();
}
Result UnpinProgram(PinId id) {
R_UNLESS(RoManager::GetInstance().Free(id), ldr::ResultNotPinned());
return ResultSuccess();
R_SUCCEED();
}
Result GetProcessModuleInfo(u32 *out_count, ldr::ModuleInfo *out, size_t max_out_count, os::ProcessId process_id) {
R_UNLESS(RoManager::GetInstance().GetProcessModuleInfo(out_count, out, max_out_count, process_id), ldr::ResultNotPinned());
return ResultSuccess();
R_SUCCEED();
}
Result GetProgramLocationAndOverrideStatusFromPinId(ncm::ProgramLocation *out, cfg::OverrideStatus *out_status, PinId pin_id) {
R_UNLESS(RoManager::GetInstance().GetProgramLocationAndStatus(out, out_status, pin_id), ldr::ResultNotPinned());
return ResultSuccess();
R_SUCCEED();
}
}