From 4f387b0b74138e033b88fbe4e137d6ab8c7130ac Mon Sep 17 00:00:00 2001 From: Leystryku Date: Sun, 18 Feb 2024 06:00:42 +0100 Subject: file_sys: Fix nacp field cache_storage_max_index datatype --- src/core/file_sys/control_metadata.h | 4 ++-- src/core/hle/service/am/service/application_functions.cpp | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 555b9d8f7..667efbbab 100644 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h @@ -64,8 +64,8 @@ struct RawNACP { u64_le cache_storage_size; u64_le cache_storage_journal_size; u64_le cache_storage_data_and_journal_max_size; - u64_le cache_storage_max_index; - INSERT_PADDING_BYTES(0xE70); + u16_le cache_storage_max_index; + INSERT_PADDING_BYTES(0xE76); }; static_assert(sizeof(RawNACP) == 0x4000, "RawNACP has incorrect size."); diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index eee9428ce..fe37083f3 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -272,17 +272,14 @@ Result IApplicationFunctions::GetCacheStorageMax(Out out_cache_storage_inde Out out_max_journal_size) { LOG_DEBUG(Service_AM, "called"); - const auto title_id = m_applet->program_id; - std::vector nacp; - const auto result = system.GetARPManager().GetControlProperty(&nacp, title_id); + R_TRY(system.GetARPManager().GetControlProperty(&nacp, m_applet->program_id)); - if (R_SUCCEEDED(result)) { - const auto rawnacp = reinterpret_cast(nacp.data()); + FileSys::RawNACP raw_nacp{}; + std::memcpy(&raw_nacp, nacp.data(), std::min(sizeof(raw_nacp), nacp.size())); - *out_cache_storage_index_max = static_cast(rawnacp->cache_storage_max_index); - *out_max_journal_size = static_cast(rawnacp->cache_storage_data_and_journal_max_size); - } + *out_cache_storage_index_max = static_cast(raw_nacp.cache_storage_max_index); + *out_max_journal_size = static_cast(raw_nacp.cache_storage_data_and_journal_max_size); R_SUCCEED(); } -- cgit v1.2.3