diff options
author | Michael Scire <SciresM@gmail.com> | 2020-01-23 05:14:06 +0100 |
---|---|---|
committer | Michael Scire <SciresM@gmail.com> | 2020-01-23 05:14:06 +0100 |
commit | 5a7eecc3adfb179335d921725a3b60c622e92836 (patch) | |
tree | 5be51ae470df6428478da91f1e8454e3c18b0955 | |
parent | Merge pull request #3339 from Simek/dark-theme-update (diff) | |
download | yuzu-5a7eecc3adfb179335d921725a3b60c622e92836.tar yuzu-5a7eecc3adfb179335d921725a3b60c622e92836.tar.gz yuzu-5a7eecc3adfb179335d921725a3b60c622e92836.tar.bz2 yuzu-5a7eecc3adfb179335d921725a3b60c622e92836.tar.lz yuzu-5a7eecc3adfb179335d921725a3b60c622e92836.tar.xz yuzu-5a7eecc3adfb179335d921725a3b60c622e92836.tar.zst yuzu-5a7eecc3adfb179335d921725a3b60c622e92836.zip |
-rw-r--r-- | src/core/loader/nso.cpp | 11 | ||||
-rw-r--r-- | src/core/loader/nso.h | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 515c5accb..044067a5b 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -97,7 +97,8 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, if (nso_header.IsSegmentCompressed(i)) { data = DecompressSegment(data, nso_header.segments[i]); } - program_image.resize(nso_header.segments[i].location + data.size()); + program_image.resize(nso_header.segments[i].location + + PageAlignSize(static_cast<u32>(data.size()))); std::memcpy(program_image.data() + nso_header.segments[i].location, data.data(), data.size()); codeset.segments[i].addr = nso_header.segments[i].location; @@ -105,8 +106,12 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, codeset.segments[i].size = PageAlignSize(static_cast<u32>(data.size())); } - if (should_pass_arguments && !Settings::values.program_args.empty()) { - const auto arg_data = Settings::values.program_args; + if (should_pass_arguments) { + std::vector<u8> arg_data{Settings::values.program_args.begin(), + Settings::values.program_args.end()}; + if (arg_data.empty()) { + arg_data.resize(NSO_ARGUMENT_DEFAULT_SIZE); + } codeset.DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE; NSOArgumentHeader args_header{ NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}}; diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 58cbe162d..d2d600cd9 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h @@ -56,6 +56,8 @@ static_assert(sizeof(NSOHeader) == 0x100, "NSOHeader has incorrect size."); static_assert(std::is_trivially_copyable_v<NSOHeader>, "NSOHeader must be trivially copyable."); constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000; +// NOTE: Official software default argument state is unverified. +constexpr u64 NSO_ARGUMENT_DEFAULT_SIZE = 1; struct NSOArgumentHeader { u32_le allocated_size; |