summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/file_sys/control_metadata.h4
-rw-r--r--src/core/hle/service/am/service/application_functions.cpp13
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 {
64 u64_le cache_storage_size; 64 u64_le cache_storage_size;
65 u64_le cache_storage_journal_size; 65 u64_le cache_storage_journal_size;
66 u64_le cache_storage_data_and_journal_max_size; 66 u64_le cache_storage_data_and_journal_max_size;
67 u64_le cache_storage_max_index; 67 u16_le cache_storage_max_index;
68 INSERT_PADDING_BYTES(0xE70); 68 INSERT_PADDING_BYTES(0xE76);
69}; 69};
70static_assert(sizeof(RawNACP) == 0x4000, "RawNACP has incorrect size."); 70static_assert(sizeof(RawNACP) == 0x4000, "RawNACP has incorrect size.");
71 71
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<u32> out_cache_storage_inde
272 Out<u64> out_max_journal_size) { 272 Out<u64> out_max_journal_size) {
273 LOG_DEBUG(Service_AM, "called"); 273 LOG_DEBUG(Service_AM, "called");
274 274
275 const auto title_id = m_applet->program_id;
276
277 std::vector<u8> nacp; 275 std::vector<u8> nacp;
278 const auto result = system.GetARPManager().GetControlProperty(&nacp, title_id); 276 R_TRY(system.GetARPManager().GetControlProperty(&nacp, m_applet->program_id));
279 277
280 if (R_SUCCEEDED(result)) { 278 FileSys::RawNACP raw_nacp{};
281 const auto rawnacp = reinterpret_cast<FileSys::RawNACP*>(nacp.data()); 279 std::memcpy(&raw_nacp, nacp.data(), std::min(sizeof(raw_nacp), nacp.size()));
282 280
283 *out_cache_storage_index_max = static_cast<u32>(rawnacp->cache_storage_max_index); 281 *out_cache_storage_index_max = static_cast<u32>(raw_nacp.cache_storage_max_index);
284 *out_max_journal_size = static_cast<u64>(rawnacp->cache_storage_data_and_journal_max_size); 282 *out_max_journal_size = static_cast<u64>(raw_nacp.cache_storage_data_and_journal_max_size);
285 }
286 283
287 R_SUCCEED(); 284 R_SUCCEED();
288} 285}