summaryrefslogtreecommitdiffstats
path: root/src/core/loader/nso.cpp
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-09-30 20:04:48 +0200
committerZach Hilman <zachhilman@gmail.com>2018-10-07 20:30:15 +0200
commite09505ff6147815d7d3c7adcc0d260638cf49706 (patch)
treea430bbf3af585ac0e117c28b5782ee9556a2895a /src/core/loader/nso.cpp
parentMerge pull request #1396 from DarkLordZach/packed-updates (diff)
downloadyuzu-e09505ff6147815d7d3c7adcc0d260638cf49706.tar
yuzu-e09505ff6147815d7d3c7adcc0d260638cf49706.tar.gz
yuzu-e09505ff6147815d7d3c7adcc0d260638cf49706.tar.bz2
yuzu-e09505ff6147815d7d3c7adcc0d260638cf49706.tar.lz
yuzu-e09505ff6147815d7d3c7adcc0d260638cf49706.tar.xz
yuzu-e09505ff6147815d7d3c7adcc0d260638cf49706.tar.zst
yuzu-e09505ff6147815d7d3c7adcc0d260638cf49706.zip
Diffstat (limited to 'src/core/loader/nso.cpp')
-rw-r--r--src/core/loader/nso.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 2186b02af..8ee2c6f2b 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -17,6 +17,7 @@
#include "core/hle/kernel/vm_manager.h"
#include "core/loader/nso.h"
#include "core/memory.h"
+#include "core/settings.h"
namespace Loader {
@@ -94,6 +95,7 @@ static constexpr u32 PageAlignSize(u32 size) {
}
VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base,
+ bool should_pass_arguments,
boost::optional<FileSys::PatchManager> pm) {
if (file == nullptr)
return {};
@@ -125,6 +127,17 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base,
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;
+ codeset->DataSegment().size += 0x9000;
+ NSOArgumentHeader args_header{0x9000, arg_data.size(), {}};
+ program_image.resize(static_cast<u32>(program_image.size()) + 0x9000);
+ std::memcpy(program_image.data() + program_image.size() - 0x9000, &args_header,
+ sizeof(NSOArgumentHeader));
+ std::memcpy(program_image.data() + program_image.size() - 0x8FE0, arg_data.data(),
+ arg_data.size());
+ }
+
// MOD header pointer is at .text offset + 4
u32 module_offset;
std::memcpy(&module_offset, program_image.data() + 4, sizeof(u32));
@@ -172,7 +185,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::Process& process) {
// Load module
const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress();
- LoadModule(file, base_address);
+ LoadModule(file, base_address, true);
LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address);
process.Run(base_address, Kernel::THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE);