nso/nro: Add NSO arguments structure to data section

Only added if arguments string is non-empty and a pass is requested by loader.
This commit is contained in:
Zach Hilman 2018-09-30 14:04:48 -04:00
parent e5d1e17fc1
commit 19203e1dc0
4 changed files with 38 additions and 3 deletions

View file

@ -18,7 +18,9 @@
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/vm_manager.h"
#include "core/loader/nro.h"
#include "core/loader/nso.h"
#include "core/memory.h"
#include "core/settings.h"
namespace Loader {
@ -150,6 +152,17 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) {
codeset->segments[i].size = PageAlignSize(nro_header.segments[i].size);
}
if (!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());
}
// Read MOD header
ModHeader mod_header{};
// Default .bss to NRO header bss size if MOD0 section doesn't exist