ams: replace most remaining operator & with std::addressof
This commit is contained in:
@@ -31,7 +31,7 @@ namespace ams::ldr {
|
||||
std::memset(out, 0, sizeof(*out));
|
||||
cfg::OverrideStatus status = {};
|
||||
|
||||
R_TRY(ldr::GetProgramInfo(out, &status, loc));
|
||||
R_TRY(ldr::GetProgramInfo(out, std::addressof(status), loc));
|
||||
|
||||
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None) && loc.program_id != out->program_id) {
|
||||
char path[fs::EntryNameLengthMax];
|
||||
@@ -64,7 +64,7 @@ namespace ams::ldr {
|
||||
char path[fs::EntryNameLengthMax];
|
||||
|
||||
/* Get location and override status. */
|
||||
R_TRY(ldr::ro::GetProgramLocationAndStatus(&loc, &override_status, id));
|
||||
R_TRY(ldr::ro::GetProgramLocationAndStatus(std::addressof(loc), std::addressof(override_status), id));
|
||||
|
||||
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None)) {
|
||||
R_TRY(ResolveContentPath(path, loc));
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace ams::ldr {
|
||||
|
||||
/* Validate the meta. */
|
||||
{
|
||||
Meta *meta = &cache->meta;
|
||||
Meta *meta = std::addressof(cache->meta);
|
||||
|
||||
Npdm *npdm = reinterpret_cast<Npdm *>(cache->buffer);
|
||||
R_TRY(ValidateNpdm(npdm, npdm_size));
|
||||
@@ -194,11 +194,11 @@ namespace ams::ldr {
|
||||
R_TRY(fs::OpenFile(std::addressof(file), AtmosphereMetaPath, fs::OpenMode_Read));
|
||||
{
|
||||
ON_SCOPE_EXIT { fs::CloseFile(file); };
|
||||
R_TRY(LoadMetaFromFile(file, &g_meta_cache));
|
||||
R_TRY(LoadMetaFromFile(file, std::addressof(g_meta_cache)));
|
||||
}
|
||||
|
||||
/* Patch meta. Start by setting all program ids to the current program id. */
|
||||
Meta *meta = &g_meta_cache.meta;
|
||||
Meta *meta = std::addressof(g_meta_cache.meta);
|
||||
meta->acid->program_id_min = loc.program_id;
|
||||
meta->acid->program_id_max = loc.program_id;
|
||||
meta->aci->program_id = loc.program_id;
|
||||
@@ -209,8 +209,8 @@ namespace ams::ldr {
|
||||
ON_SCOPE_EXIT { fs::CloseFile(file); };
|
||||
|
||||
|
||||
if (R_SUCCEEDED(LoadMetaFromFile(file, &g_original_meta_cache))) {
|
||||
Meta *o_meta = &g_original_meta_cache.meta;
|
||||
if (R_SUCCEEDED(LoadMetaFromFile(file, std::addressof(g_original_meta_cache)))) {
|
||||
Meta *o_meta = std::addressof(g_original_meta_cache.meta);
|
||||
|
||||
/* Fix pool partition. */
|
||||
if (hos::GetVersion() >= hos::Version_5_0_0) {
|
||||
@@ -253,8 +253,8 @@ namespace ams::ldr {
|
||||
if (static_cast<ncm::StorageId>(loc.storage_id) != ncm::StorageId::None || ncm::IsApplicationId(loc.program_id)) {
|
||||
R_TRY(fs::OpenFile(std::addressof(file), BaseMetaPath, fs::OpenMode_Read));
|
||||
ON_SCOPE_EXIT { fs::CloseFile(file); };
|
||||
R_TRY(LoadMetaFromFile(file, &g_original_meta_cache));
|
||||
R_TRY(ValidateAcidSignature(&g_original_meta_cache.meta));
|
||||
R_TRY(LoadMetaFromFile(file, std::addressof(g_original_meta_cache)));
|
||||
R_TRY(ValidateAcidSignature(std::addressof(g_original_meta_cache.meta)));
|
||||
meta->modulus = g_original_meta_cache.meta.modulus;
|
||||
meta->check_verification_data = g_original_meta_cache.meta.check_verification_data;
|
||||
}
|
||||
|
||||
@@ -118,15 +118,15 @@ namespace ams::ldr {
|
||||
}
|
||||
|
||||
ro::ModuleId module_id;
|
||||
std::memcpy(&module_id.build_id, build_id, sizeof(module_id.build_id));
|
||||
ams::patcher::LocateAndApplyIpsPatchesToModule(LoaderSdMountName, NsoPatchesDirectory, NsoPatchesProtectedSize, NsoPatchesProtectedOffset, &module_id, reinterpret_cast<u8 *>(mapped_nso), mapped_size);
|
||||
std::memcpy(std::addressof(module_id.build_id), build_id, sizeof(module_id.build_id));
|
||||
ams::patcher::LocateAndApplyIpsPatchesToModule(LoaderSdMountName, NsoPatchesDirectory, NsoPatchesProtectedSize, NsoPatchesProtectedOffset, std::addressof(module_id), reinterpret_cast<u8 *>(mapped_nso), mapped_size);
|
||||
}
|
||||
|
||||
/* Apply embedded patches. */
|
||||
void ApplyEmbeddedPatchesToModule(const u8 *build_id, uintptr_t mapped_nso, size_t mapped_size) {
|
||||
/* Make module id. */
|
||||
ro::ModuleId module_id;
|
||||
std::memcpy(&module_id.build_id, build_id, sizeof(module_id.build_id));
|
||||
std::memcpy(std::addressof(module_id.build_id), build_id, sizeof(module_id.build_id));
|
||||
|
||||
if (IsUsb30ForceEnabled()) {
|
||||
for (const auto &patch : Usb30ForceEnablePatches) {
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace ams::ldr {
|
||||
out->reslimit = reslimit_h;
|
||||
|
||||
/* Set flags. */
|
||||
R_TRY(GetCreateProcessFlags(&out->flags, meta, flags));
|
||||
R_TRY(GetCreateProcessFlags(std::addressof(out->flags), meta, flags));
|
||||
|
||||
/* 3.0.0+ System Resource Size. */
|
||||
if (hos::GetVersion() >= hos::Version_3_0_0) {
|
||||
@@ -574,11 +574,11 @@ namespace ams::ldr {
|
||||
R_TRY(map.GetResult());
|
||||
|
||||
/* Load NSO segments. */
|
||||
R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Text], nso_header->text_compressed_size, nso_header->text_hash, (nso_header->flags & NsoHeader::Flag_CompressedText) != 0,
|
||||
R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Text]), nso_header->text_compressed_size, nso_header->text_hash, (nso_header->flags & NsoHeader::Flag_CompressedText) != 0,
|
||||
(nso_header->flags & NsoHeader::Flag_CheckHashText) != 0, map_address + nso_header->text_dst_offset, map_address + nso_size));
|
||||
R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Ro], nso_header->ro_compressed_size, nso_header->ro_hash, (nso_header->flags & NsoHeader::Flag_CompressedRo) != 0,
|
||||
R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Ro]), nso_header->ro_compressed_size, nso_header->ro_hash, (nso_header->flags & NsoHeader::Flag_CompressedRo) != 0,
|
||||
(nso_header->flags & NsoHeader::Flag_CheckHashRo) != 0, map_address + nso_header->ro_dst_offset, map_address + nso_size));
|
||||
R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Rw], nso_header->rw_compressed_size, nso_header->rw_hash, (nso_header->flags & NsoHeader::Flag_CompressedRw) != 0,
|
||||
R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Rw]), nso_header->rw_compressed_size, nso_header->rw_hash, (nso_header->flags & NsoHeader::Flag_CompressedRw) != 0,
|
||||
(nso_header->flags & NsoHeader::Flag_CheckHashRw) != 0, map_address + nso_header->rw_dst_offset, map_address + nso_size));
|
||||
|
||||
/* Clear unused space to zero. */
|
||||
@@ -670,10 +670,10 @@ namespace ams::ldr {
|
||||
|
||||
/* Load meta, possibly from cache. */
|
||||
Meta meta;
|
||||
R_TRY(LoadMetaFromCache(&meta, loc, override_status));
|
||||
R_TRY(LoadMetaFromCache(std::addressof(meta), loc, override_status));
|
||||
|
||||
/* Validate meta. */
|
||||
R_TRY(ValidateMeta(&meta, loc, mount.GetCodeVerificationData()));
|
||||
R_TRY(ValidateMeta(std::addressof(meta), loc, mount.GetCodeVerificationData()));
|
||||
|
||||
/* Load, validate NSOs. */
|
||||
R_TRY(LoadNsoHeaders(nso_headers, has_nso));
|
||||
@@ -681,13 +681,13 @@ namespace ams::ldr {
|
||||
|
||||
/* Actually create process. */
|
||||
ProcessInfo info;
|
||||
R_TRY(CreateProcessImpl(&info, &meta, nso_headers, has_nso, arg_info, flags, reslimit_h));
|
||||
R_TRY(CreateProcessImpl(std::addressof(info), std::addressof(meta), nso_headers, has_nso, arg_info, flags, reslimit_h));
|
||||
|
||||
/* Ensure we close the process handle, if we fail. */
|
||||
ON_SCOPE_EXIT { os::CloseNativeHandle(info.process_handle); };
|
||||
|
||||
/* Load NSOs into process memory. */
|
||||
R_TRY(LoadNsosIntoProcessMemory(&info, nso_headers, has_nso, arg_info));
|
||||
R_TRY(LoadNsosIntoProcessMemory(std::addressof(info), nso_headers, has_nso, arg_info));
|
||||
|
||||
/* Register NSOs with ro manager. */
|
||||
{
|
||||
@@ -732,13 +732,13 @@ namespace ams::ldr {
|
||||
{
|
||||
ScopedCodeMount mount(loc);
|
||||
R_TRY(mount.GetResult());
|
||||
R_TRY(LoadMeta(&meta, loc, mount.GetOverrideStatus()));
|
||||
R_TRY(LoadMeta(std::addressof(meta), loc, mount.GetOverrideStatus()));
|
||||
if (out_status != nullptr) {
|
||||
*out_status = mount.GetOverrideStatus();
|
||||
}
|
||||
}
|
||||
|
||||
return GetProgramInfoFromMeta(out, &meta);
|
||||
return GetProgramInfoFromMeta(out, std::addressof(meta));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user