mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
strat: refactor address taking of form &var[...]
This commit is contained in:
parent
b0e520112b
commit
ec65c39d17
12 changed files with 53 additions and 53 deletions
|
@ -186,7 +186,7 @@ namespace ams::kern::board::nintendo::nx::smc {
|
|||
MESOSPHERE_INIT_ABORT_UNLESS((static_cast<SmcResult>(args.x[0]) == SmcResult::Success));
|
||||
|
||||
/* Copy output. */
|
||||
std::memcpy(dst, &args.x[1], size);
|
||||
std::memcpy(dst, std::addressof(args.x[1]), size);
|
||||
}
|
||||
|
||||
bool ReadWriteRegister(u32 *out, u64 address, u32 mask, u32 value) {
|
||||
|
@ -255,7 +255,7 @@ namespace ams::kern::board::nintendo::nx::smc {
|
|||
MESOSPHERE_ABORT_UNLESS((static_cast<SmcResult>(args.x[0]) == SmcResult::Success));
|
||||
|
||||
/* Copy output. */
|
||||
std::memcpy(dst, &args.x[1], size);
|
||||
std::memcpy(dst, std::addressof(args.x[1]), size);
|
||||
}
|
||||
|
||||
void NORETURN Panic(u32 color) {
|
||||
|
|
|
@ -617,7 +617,7 @@ namespace ams::sf::impl {
|
|||
static_assert(Offset <= Size, "Offset <= Size");
|
||||
static_assert(TypeSize <= Size, "TypeSize <= Size");
|
||||
static_assert(Offset + TypeSize <= Size, "Offset + TypeSize <= Size");
|
||||
return reinterpret_cast<uintptr_t>(&data[Offset]);
|
||||
return reinterpret_cast<uintptr_t>(std::addressof(data[Offset]));
|
||||
}
|
||||
|
||||
constexpr inline void CopyTo(void *dst) const {
|
||||
|
@ -760,7 +760,7 @@ namespace ams::sf::impl {
|
|||
template<size_t Index, typename Interface>
|
||||
Out<SharedPointer<Interface>> GetOutObject() {
|
||||
auto sp = std::construct_at(GetOutObjectSharedPointer<Index, Interface>());
|
||||
return Out<SharedPointer<Interface>>(sp, &this->out_object_ids[Index]);
|
||||
return Out<SharedPointer<Interface>>(sp, this->out_object_ids + Index);
|
||||
}
|
||||
|
||||
template<size_t Index, typename Interface>
|
||||
|
@ -907,11 +907,11 @@ namespace ams::sf::impl {
|
|||
if constexpr (Attributes & SfBufferAttr_HipcMapAlias) {
|
||||
is_buffer_map_alias = true;
|
||||
if constexpr (Attributes & SfBufferAttr_In) {
|
||||
const HipcBufferDescriptor *desc = &ctx.request.data.send_buffers[Info.send_map_alias_index];
|
||||
const HipcBufferDescriptor *desc = std::addressof(ctx.request.data.send_buffers[Info.send_map_alias_index]);
|
||||
buffer = cmif::PointerAndSize(hipcGetBufferAddress(desc), hipcGetBufferSize(desc));
|
||||
if (!IsMapTransferModeValid<Attributes>(static_cast<u32>(desc->mode))) { map_alias_buffers_valid = false; }
|
||||
} else if constexpr (Attributes & SfBufferAttr_Out) {
|
||||
const HipcBufferDescriptor *desc = &ctx.request.data.recv_buffers[Info.recv_map_alias_index];
|
||||
const HipcBufferDescriptor *desc = std::addressof(ctx.request.data.recv_buffers[Info.recv_map_alias_index]);
|
||||
buffer = cmif::PointerAndSize(hipcGetBufferAddress(desc), hipcGetBufferSize(desc));
|
||||
if (!IsMapTransferModeValid<Attributes>(static_cast<u32>(desc->mode))) { map_alias_buffers_valid = false; }
|
||||
} else {
|
||||
|
@ -920,7 +920,7 @@ namespace ams::sf::impl {
|
|||
} else if constexpr (Attributes & SfBufferAttr_HipcPointer) {
|
||||
is_buffer_map_alias = false;
|
||||
if constexpr (Attributes & SfBufferAttr_In) {
|
||||
const HipcStaticDescriptor *desc = &ctx.request.data.send_statics[Info.send_pointer_index];
|
||||
const HipcStaticDescriptor *desc = std::addressof(ctx.request.data.send_statics[Info.send_pointer_index]);
|
||||
buffer = cmif::PointerAndSize(hipcGetStaticAddress(desc), hipcGetStaticSize(desc));
|
||||
const size_t size = buffer.GetSize();
|
||||
if (size) {
|
||||
|
@ -943,8 +943,8 @@ namespace ams::sf::impl {
|
|||
}
|
||||
} else if constexpr (Attributes & SfBufferAttr_HipcAutoSelect) {
|
||||
if constexpr (Attributes & SfBufferAttr_In) {
|
||||
const HipcBufferDescriptor *map_desc = &ctx.request.data.send_buffers[Info.send_map_alias_index];
|
||||
const HipcStaticDescriptor *ptr_desc = &ctx.request.data.send_statics[Info.send_pointer_index];
|
||||
const HipcBufferDescriptor *map_desc = std::addressof(ctx.request.data.send_buffers[Info.send_map_alias_index]);
|
||||
const HipcStaticDescriptor *ptr_desc = std::addressof(ctx.request.data.send_statics[Info.send_pointer_index]);
|
||||
is_buffer_map_alias = hipcGetBufferAddress(map_desc) != 0;
|
||||
if (is_buffer_map_alias) {
|
||||
buffer = cmif::PointerAndSize(hipcGetBufferAddress(map_desc), hipcGetBufferSize(map_desc));
|
||||
|
@ -957,7 +957,7 @@ namespace ams::sf::impl {
|
|||
}
|
||||
}
|
||||
} else if constexpr (Attributes & SfBufferAttr_Out) {
|
||||
const HipcBufferDescriptor *map_desc = &ctx.request.data.recv_buffers[Info.recv_map_alias_index];
|
||||
const HipcBufferDescriptor *map_desc = std::addressof(ctx.request.data.recv_buffers[Info.recv_map_alias_index]);
|
||||
is_buffer_map_alias = hipcGetBufferAddress(map_desc) != 0;
|
||||
if (is_buffer_map_alias) {
|
||||
buffer = cmif::PointerAndSize(hipcGetBufferAddress(map_desc), hipcGetBufferSize(map_desc));
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace ams::fssystem {
|
|||
R_UNLESS(len >= 2, fs::ResultInvalidPathFormat());
|
||||
|
||||
/* Find previous separator, add null terminator */
|
||||
char *cur = &dst_path_buf[len - 2];
|
||||
char *cur = dst_path_buf + len - 2;
|
||||
while (!fs::PathNormalizer::IsSeparator(*cur) && cur > dst_path_buf) {
|
||||
cur--;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace ams::spl::smc {
|
|||
svc::CallSecureMonitor(std::addressof(args));
|
||||
|
||||
if (args.r[0] == static_cast<u64>(Result::Success) && (size <= sizeof(args) - sizeof(args.r[0]))) {
|
||||
std::memcpy(out, &args.r[1], size);
|
||||
std::memcpy(out, std::addressof(args.r[1]), size);
|
||||
}
|
||||
return static_cast<Result>(args.r[0]);
|
||||
}
|
||||
|
@ -220,8 +220,8 @@ namespace ams::spl::smc {
|
|||
args.r[0] = static_cast<u64>(FunctionId::PrepareEsDeviceUniqueKey);
|
||||
args.r[1] = reinterpret_cast<u64>(base);
|
||||
args.r[2] = reinterpret_cast<u64>(mod);
|
||||
std::memset(&args.r[3], 0, 4 * sizeof(args.r[3]));
|
||||
std::memcpy(&args.r[3], label_digest, std::min(size_t(4 * sizeof(args.r[3])), label_digest_size));
|
||||
std::memset(std::addressof(args.r[3]), 0, 4 * sizeof(args.r[3]));
|
||||
std::memcpy(std::addressof(args.r[3]), label_digest, std::min(size_t(4 * sizeof(args.r[3])), label_digest_size));
|
||||
args.r[7] = option;
|
||||
svc::CallSecureMonitor(std::addressof(args));
|
||||
|
||||
|
@ -358,7 +358,7 @@ namespace ams::spl::smc {
|
|||
args.r[2] = paths;
|
||||
svc::CallSecureMonitor(std::addressof(args));
|
||||
|
||||
std::memcpy(out_config, &args.r[1], sizeof(args) - sizeof(args.r[0]));
|
||||
std::memcpy(out_config, std::addressof(args.r[1]), sizeof(args) - sizeof(args.r[0]));
|
||||
return static_cast<Result>(args.r[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace ams::mitm::bpc {
|
|||
|
||||
/* Copy in payload. */
|
||||
for (size_t ofs = 0; ofs < sizeof(g_reboot_payload); ofs += sizeof(g_work_page)) {
|
||||
std::memcpy(g_work_page, &g_reboot_payload[ofs], std::min(sizeof(g_reboot_payload) - ofs, sizeof(g_work_page)));
|
||||
std::memcpy(g_work_page, g_reboot_payload + ofs, std::min(sizeof(g_reboot_payload) - ofs, sizeof(g_work_page)));
|
||||
exosphere::CopyToIram(IramPayloadBase + ofs, g_work_page, sizeof(g_work_page));
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ namespace ams::mitm::bpc {
|
|||
|
||||
/* Copy in payload. */
|
||||
for (size_t ofs = 0; ofs < sizeof(g_reboot_payload); ofs += sizeof(g_work_page)) {
|
||||
std::memcpy(g_work_page, &g_reboot_payload[ofs], std::min(sizeof(g_reboot_payload) - ofs, sizeof(g_work_page)));
|
||||
std::memcpy(g_work_page, g_reboot_payload + ofs, std::min(sizeof(g_reboot_payload) - ofs, sizeof(g_work_page)));
|
||||
exosphere::CopyToIram(IramPayloadBase + ofs, g_work_page, sizeof(g_work_page));
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace ams::boot {
|
|||
|
||||
/* Copy in payload. */
|
||||
for (size_t ofs = 0; ofs < fusee_bin_size; ofs += sizeof(g_work_page)) {
|
||||
std::memcpy(g_work_page, &fusee_bin[ofs], std::min(static_cast<size_t>(fusee_bin_size - ofs), sizeof(g_work_page)));
|
||||
std::memcpy(g_work_page, fusee_bin + ofs, std::min(static_cast<size_t>(fusee_bin_size - ofs), sizeof(g_work_page)));
|
||||
exosphere::CopyToIram(IramPayloadBase + ofs, g_work_page, sizeof(g_work_page));
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ namespace ams::boot {
|
|||
|
||||
/* Copy in payload. */
|
||||
for (size_t ofs = 0; ofs < fusee_bin_size; ofs += sizeof(g_work_page)) {
|
||||
std::memcpy(g_work_page, &fusee_bin[ofs], std::min(static_cast<size_t>(fusee_bin_size - ofs), sizeof(g_work_page)));
|
||||
std::memcpy(g_work_page, fusee_bin + ofs, std::min(static_cast<size_t>(fusee_bin_size - ofs), sizeof(g_work_page)));
|
||||
exosphere::CopyToIram(IramPayloadBase + ofs, g_work_page, sizeof(g_work_page));
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace ams::dmnt::cheat::impl {
|
|||
|
||||
void ResetCheatEntry(size_t i) {
|
||||
if (i < MaxCheatCount) {
|
||||
std::memset(&this->cheat_entries[i], 0, sizeof(this->cheat_entries[i]));
|
||||
std::memset(this->cheat_entries + i, 0, sizeof(this->cheat_entries[i]));
|
||||
this->cheat_entries[i].cheat_id = i;
|
||||
|
||||
this->SetNeedsReloadVm(true);
|
||||
|
@ -146,7 +146,7 @@ namespace ams::dmnt::cheat::impl {
|
|||
|
||||
CheatEntry *GetCheatEntryById(size_t i) {
|
||||
if (i < MaxCheatCount) {
|
||||
return &this->cheat_entries[i];
|
||||
return this->cheat_entries + i;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -156,7 +156,7 @@ namespace ams::dmnt::cheat::impl {
|
|||
/* Check all non-master cheats for match. */
|
||||
for (size_t i = 1; i < MaxCheatCount; i++) {
|
||||
if (std::strncmp(this->cheat_entries[i].definition.readable_name, readable_name, sizeof(this->cheat_entries[i].definition.readable_name)) == 0) {
|
||||
return &this->cheat_entries[i];
|
||||
return this->cheat_entries + i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ namespace ams::dmnt::cheat::impl {
|
|||
/* Check all non-master cheats for availability. */
|
||||
for (size_t i = 1; i < MaxCheatCount; i++) {
|
||||
if (this->cheat_entries[i].definition.num_opcodes == 0) {
|
||||
return &this->cheat_entries[i];
|
||||
return this->cheat_entries + i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -837,9 +837,9 @@ namespace ams::dmnt::cheat::impl {
|
|||
/* if we aren't auto-attaching. */
|
||||
const LoaderModuleInfo *proc_module = nullptr;
|
||||
if (num_modules == 2) {
|
||||
proc_module = &proc_modules[1];
|
||||
proc_module = std::addressof(proc_modules[1]);
|
||||
} else if (num_modules == 1 && !on_process_launch) {
|
||||
proc_module = &proc_modules[0];
|
||||
proc_module = std::addressof(proc_modules[0]);
|
||||
} else {
|
||||
return dmnt::cheat::ResultCheatNotAttached();
|
||||
}
|
||||
|
@ -915,14 +915,14 @@ namespace ams::dmnt::cheat::impl {
|
|||
|
||||
/* s[i+1:j] is cheat name. */
|
||||
const size_t cheat_name_len = std::min(j - i - 1, sizeof(cur_entry->definition.readable_name));
|
||||
std::memcpy(cur_entry->definition.readable_name, &s[i+1], cheat_name_len);
|
||||
std::memcpy(cur_entry->definition.readable_name, s + (i + 1), cheat_name_len);
|
||||
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
||||
|
||||
/* Skip onwards. */
|
||||
i = j + 1;
|
||||
} else if (s[i] == '{') {
|
||||
/* We're parsing a master cheat. */
|
||||
cur_entry = &this->cheat_entries[0];
|
||||
cur_entry = std::addressof(this->cheat_entries[0]);
|
||||
|
||||
/* There can only be one master cheat. */
|
||||
if (cur_entry->definition.num_opcodes > 0) {
|
||||
|
@ -940,7 +940,7 @@ namespace ams::dmnt::cheat::impl {
|
|||
|
||||
/* s[i+1:j] is cheat name. */
|
||||
const size_t cheat_name_len = std::min(j - i - 1, sizeof(cur_entry->definition.readable_name));
|
||||
memcpy(cur_entry->definition.readable_name, &s[i+1], cheat_name_len);
|
||||
memcpy(cur_entry->definition.readable_name, s + (i + 1), cheat_name_len);
|
||||
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
||||
|
||||
/* Skip onwards. */
|
||||
|
@ -966,7 +966,7 @@ namespace ams::dmnt::cheat::impl {
|
|||
|
||||
/* Parse the new opcode. */
|
||||
char hex_str[9] = {0};
|
||||
std::memcpy(hex_str, &s[i], 8);
|
||||
std::memcpy(hex_str, s + i, 8);
|
||||
cur_entry->definition.opcodes[cur_entry->definition.num_opcodes++] = std::strtoul(hex_str, NULL, 16);
|
||||
|
||||
/* Skip onwards. */
|
||||
|
@ -1013,7 +1013,7 @@ namespace ams::dmnt::cheat::impl {
|
|||
|
||||
/* s[i+1:j] is cheat name. */
|
||||
const size_t cheat_name_len = std::min(j - i - 1, sizeof(cur_cheat_name));
|
||||
std::memcpy(cur_cheat_name, &s[i+1], cheat_name_len);
|
||||
std::memcpy(cur_cheat_name, s + (i + 1), cheat_name_len);
|
||||
cur_cheat_name[cheat_name_len] = 0;
|
||||
|
||||
/* Skip onwards. */
|
||||
|
@ -1035,7 +1035,7 @@ namespace ams::dmnt::cheat::impl {
|
|||
|
||||
/* s[i:j] is toggle. */
|
||||
const size_t toggle_len = (j - i);
|
||||
std::memcpy(toggle, &s[i], toggle_len);
|
||||
std::memcpy(toggle, s + i, toggle_len);
|
||||
toggle[toggle_len] = 0;
|
||||
|
||||
/* Allow specifying toggle for not present cheat. */
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace ams::fatal::srv::font {
|
|||
for (int tmpy = 0; tmpy < height; tmpy++) {
|
||||
for (int tmpx = 0; tmpx < width; tmpx++) {
|
||||
/* Implement very simple blending, as the bitmap value is an alpha value. */
|
||||
u16 *ptr = &g_frame_buffer[g_unswizzle_func(x + tmpx, y + tmpy)];
|
||||
u16 *ptr = g_frame_buffer + g_unswizzle_func(x + tmpx, y + tmpy);
|
||||
*ptr = Blend(g_font_color, *ptr, imageptr[width * tmpy + tmpx]);
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ namespace ams::fatal::srv::font {
|
|||
u32 prev_char = 0;
|
||||
for (u32 i = 0; i < len; ) {
|
||||
u32 cur_char;
|
||||
ssize_t unit_count = decode_utf8(&cur_char, reinterpret_cast<const u8 *>(&str[i]));
|
||||
ssize_t unit_count = decode_utf8(&cur_char, reinterpret_cast<const u8 *>(str + i));
|
||||
if (unit_count <= 0) break;
|
||||
|
||||
if (!g_mono_adv && i > 0) {
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace ams::ldr::args {
|
|||
ArgumentInfo *FindArgumentInfo(ncm::ProgramId program_id) {
|
||||
for (size_t i = 0; i < MaxArgumentInfos; i++) {
|
||||
if (g_argument_infos[i].program_id == program_id) {
|
||||
return &g_argument_infos[i];
|
||||
return g_argument_infos + i;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace ams::ldr::ro {
|
|||
/* Helpers. */
|
||||
ProcessInfo *GetProcessInfo(PinId pin_id) {
|
||||
for (size_t i = 0; i < ProcessCountMax; i++) {
|
||||
ProcessInfo *info = &g_process_infos[i];
|
||||
ProcessInfo *info = g_process_infos + i;
|
||||
if (info->in_use && info->pin_id == pin_id) {
|
||||
return info;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace ams::ldr::ro {
|
|||
|
||||
ProcessInfo *GetProcessInfo(os::ProcessId process_id) {
|
||||
for (size_t i = 0; i < ProcessCountMax; i++) {
|
||||
ProcessInfo *info = &g_process_infos[i];
|
||||
ProcessInfo *info = g_process_infos + i;
|
||||
if (info->in_use && info->process_id == process_id) {
|
||||
return info;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace ams::ldr::ro {
|
|||
|
||||
ProcessInfo *GetFreeProcessInfo() {
|
||||
for (size_t i = 0; i < ProcessCountMax; i++) {
|
||||
ProcessInfo *info = &g_process_infos[i];
|
||||
ProcessInfo *info = g_process_infos + i;
|
||||
if (!info->in_use) {
|
||||
return info;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ namespace ams::ldr::ro {
|
|||
|
||||
/* Nintendo doesn't actually care about successful allocation. */
|
||||
for (size_t i = 0; i < ModuleCountMax; i++) {
|
||||
ModuleInfo *module = &info->modules[i];
|
||||
ModuleInfo *module = info->modules + i;
|
||||
if (module->in_use) {
|
||||
continue;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ namespace ams::ldr::ro {
|
|||
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i < ModuleCountMax && count < max_out_count; i++) {
|
||||
const ModuleInfo *module = &info->modules[i];
|
||||
const ModuleInfo *module = info->modules + i;
|
||||
if (!module->in_use) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ namespace ams::pm::resource {
|
|||
R_ABORT_UNLESS(svc::GetInfo(&value, svc::InfoType_ResourceLimit, svc::InvalidHandle, 0));
|
||||
g_resource_limit_handles[i] = static_cast<svc::Handle>(value);
|
||||
} else {
|
||||
R_ABORT_UNLESS(svc::CreateResourceLimit(&g_resource_limit_handles[i]));
|
||||
R_ABORT_UNLESS(svc::CreateResourceLimit(g_resource_limit_handles + i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,8 +243,8 @@ namespace ams::pm::resource {
|
|||
R_ABORT_UNLESS(svc::GetResourceLimitLimitValue(&total_memory, GetResourceLimitHandle(ResourceLimitGroup_System), svc::LimitableResource_PhysicalMemoryMax));
|
||||
|
||||
/* Get and save application + applet memory. */
|
||||
R_ABORT_UNLESS(svc::GetSystemInfo(&g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_Application], svc::SystemInfoType_TotalPhysicalMemorySize, svc::InvalidHandle, svc::PhysicalMemorySystemInfo_Application));
|
||||
R_ABORT_UNLESS(svc::GetSystemInfo(&g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_Applet], svc::SystemInfoType_TotalPhysicalMemorySize, svc::InvalidHandle, svc::PhysicalMemorySystemInfo_Applet));
|
||||
R_ABORT_UNLESS(svc::GetSystemInfo(std::addressof(g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_Application]), svc::SystemInfoType_TotalPhysicalMemorySize, svc::InvalidHandle, svc::PhysicalMemorySystemInfo_Application));
|
||||
R_ABORT_UNLESS(svc::GetSystemInfo(std::addressof(g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_Applet]), svc::SystemInfoType_TotalPhysicalMemorySize, svc::InvalidHandle, svc::PhysicalMemorySystemInfo_Applet));
|
||||
|
||||
const s64 application_size = g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_Application];
|
||||
const s64 applet_size = g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_Applet];
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace ams::ro::impl {
|
|||
for (size_t i = 0; i < MaxNrrInfos; i++) {
|
||||
if (this->nrr_in_use[i] && this->nrr_infos[i].nrr_heap_address == nrr_heap_address) {
|
||||
if (out != nullptr) {
|
||||
*out = &this->nrr_infos[i];
|
||||
*out = this->nrr_infos + i;
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace ams::ro::impl {
|
|||
for (size_t i = 0; i < MaxNrrInfos; i++) {
|
||||
if (!this->nrr_in_use[i]) {
|
||||
if (out != nullptr) {
|
||||
*out = &this->nrr_infos[i];
|
||||
*out = this->nrr_infos + i;
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ namespace ams::ro::impl {
|
|||
for (size_t i = 0; i < MaxNroInfos; i++) {
|
||||
if (this->nro_in_use[i] && this->nro_infos[i].base_address == nro_address) {
|
||||
if (out != nullptr) {
|
||||
*out = &this->nro_infos[i];
|
||||
*out = this->nro_infos + i;
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -129,9 +129,9 @@ namespace ams::ro::impl {
|
|||
|
||||
Result GetNroInfoByModuleId(NroInfo **out, const ModuleId *module_id) {
|
||||
for (size_t i = 0; i < MaxNroInfos; i++) {
|
||||
if (this->nro_in_use[i] && std::memcmp(&this->nro_infos[i].module_id, module_id, sizeof(*module_id)) == 0) {
|
||||
if (this->nro_in_use[i] && std::memcmp(std::addressof(this->nro_infos[i].module_id), module_id, sizeof(*module_id)) == 0) {
|
||||
if (out != nullptr) {
|
||||
*out = &this->nro_infos[i];
|
||||
*out = this->nro_infos + i;
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ namespace ams::ro::impl {
|
|||
for (size_t i = 0; i < MaxNroInfos; i++) {
|
||||
if (!this->nro_in_use[i]) {
|
||||
if (out != nullptr) {
|
||||
*out = &this->nro_infos[i];
|
||||
*out = this->nro_infos + i;
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -282,13 +282,13 @@ namespace ams::ro::impl {
|
|||
}
|
||||
|
||||
AMS_ABORT_UNLESS(context_id < MaxSessions);
|
||||
return &g_process_contexts[context_id];
|
||||
return g_process_contexts + context_id;
|
||||
}
|
||||
|
||||
ProcessContext *GetContextByProcessId(os::ProcessId process_id) {
|
||||
for (size_t i = 0; i < MaxSessions; i++) {
|
||||
if (g_process_contexts[i].process_id == process_id) {
|
||||
return &g_process_contexts[i];
|
||||
return g_process_contexts + i;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -297,7 +297,7 @@ namespace ams::ro::impl {
|
|||
size_t AllocateContext(os::NativeHandle process_handle, os::ProcessId process_id) {
|
||||
/* Find a free process context. */
|
||||
for (size_t i = 0; i < MaxSessions; i++) {
|
||||
ProcessContext *context = &g_process_contexts[i];
|
||||
ProcessContext *context = g_process_contexts + i;
|
||||
|
||||
if (!context->in_use) {
|
||||
std::memset(context, 0, sizeof(*context));
|
||||
|
@ -548,10 +548,10 @@ namespace ams::ro::impl {
|
|||
continue;
|
||||
}
|
||||
|
||||
const NroInfo *nro_info = &context->nro_infos[i];
|
||||
const NroInfo *nro_info = context->nro_infos + i;
|
||||
|
||||
/* Just copy out the info. */
|
||||
LoaderModuleInfo *out_info = &out_infos[count++];
|
||||
LoaderModuleInfo *out_info = std::addressof(out_infos[count++]);
|
||||
memcpy(out_info->build_id, &nro_info->module_id, sizeof(nro_info->module_id));
|
||||
out_info->base_address = nro_info->base_address;
|
||||
out_info->size = nro_info->nro_heap_size + nro_info->bss_heap_size;
|
||||
|
|
Loading…
Reference in a new issue