|
|
@ -300,7 +300,7 @@ Result KProcess::Initialize(const Svc::CreateProcessParameter& params, const KPa
|
|
|
|
False(params.flags & Svc::CreateProcessFlag::DisableDeviceAddressSpaceMerge);
|
|
|
|
False(params.flags & Svc::CreateProcessFlag::DisableDeviceAddressSpaceMerge);
|
|
|
|
R_TRY(m_page_table.Initialize(as_type, enable_aslr, enable_das_merge, !enable_aslr, pool,
|
|
|
|
R_TRY(m_page_table.Initialize(as_type, enable_aslr, enable_das_merge, !enable_aslr, pool,
|
|
|
|
params.code_address, params.code_num_pages * PageSize,
|
|
|
|
params.code_address, params.code_num_pages * PageSize,
|
|
|
|
m_system_resource, res_limit, this->GetMemory()));
|
|
|
|
m_system_resource, res_limit, this->GetMemory(), 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ON_RESULT_FAILURE_2 {
|
|
|
|
ON_RESULT_FAILURE_2 {
|
|
|
|
m_page_table.Finalize();
|
|
|
|
m_page_table.Finalize();
|
|
|
@ -332,7 +332,7 @@ Result KProcess::Initialize(const Svc::CreateProcessParameter& params, const KPa
|
|
|
|
|
|
|
|
|
|
|
|
Result KProcess::Initialize(const Svc::CreateProcessParameter& params,
|
|
|
|
Result KProcess::Initialize(const Svc::CreateProcessParameter& params,
|
|
|
|
std::span<const u32> user_caps, KResourceLimit* res_limit,
|
|
|
|
std::span<const u32> user_caps, KResourceLimit* res_limit,
|
|
|
|
KMemoryManager::Pool pool) {
|
|
|
|
KMemoryManager::Pool pool, KProcessAddress aslr_space_start) {
|
|
|
|
ASSERT(res_limit != nullptr);
|
|
|
|
ASSERT(res_limit != nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
// Set members.
|
|
|
|
// Set members.
|
|
|
@ -393,7 +393,7 @@ Result KProcess::Initialize(const Svc::CreateProcessParameter& params,
|
|
|
|
False(params.flags & Svc::CreateProcessFlag::DisableDeviceAddressSpaceMerge);
|
|
|
|
False(params.flags & Svc::CreateProcessFlag::DisableDeviceAddressSpaceMerge);
|
|
|
|
R_TRY(m_page_table.Initialize(as_type, enable_aslr, enable_das_merge, !enable_aslr, pool,
|
|
|
|
R_TRY(m_page_table.Initialize(as_type, enable_aslr, enable_das_merge, !enable_aslr, pool,
|
|
|
|
params.code_address, code_size, m_system_resource, res_limit,
|
|
|
|
params.code_address, code_size, m_system_resource, res_limit,
|
|
|
|
this->GetMemory()));
|
|
|
|
this->GetMemory(), aslr_space_start));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ON_RESULT_FAILURE_2 {
|
|
|
|
ON_RESULT_FAILURE_2 {
|
|
|
|
m_page_table.Finalize();
|
|
|
|
m_page_table.Finalize();
|
|
|
@ -1128,7 +1128,7 @@ KProcess::KProcess(KernelCore& kernel)
|
|
|
|
KProcess::~KProcess() = default;
|
|
|
|
KProcess::~KProcess() = default;
|
|
|
|
|
|
|
|
|
|
|
|
Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size,
|
|
|
|
Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size,
|
|
|
|
bool is_hbl) {
|
|
|
|
KProcessAddress aslr_space_start, bool is_hbl) {
|
|
|
|
// Create a resource limit for the process.
|
|
|
|
// Create a resource limit for the process.
|
|
|
|
const auto physical_memory_size =
|
|
|
|
const auto physical_memory_size =
|
|
|
|
m_kernel.MemoryManager().GetSize(Kernel::KMemoryManager::Pool::Application);
|
|
|
|
m_kernel.MemoryManager().GetSize(Kernel::KMemoryManager::Pool::Application);
|
|
|
@ -1179,7 +1179,7 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std:
|
|
|
|
.name = {},
|
|
|
|
.name = {},
|
|
|
|
.version = {},
|
|
|
|
.version = {},
|
|
|
|
.program_id = metadata.GetTitleID(),
|
|
|
|
.program_id = metadata.GetTitleID(),
|
|
|
|
.code_address = code_address,
|
|
|
|
.code_address = code_address + GetInteger(aslr_space_start),
|
|
|
|
.code_num_pages = static_cast<s32>(code_size / PageSize),
|
|
|
|
.code_num_pages = static_cast<s32>(code_size / PageSize),
|
|
|
|
.flags = flag,
|
|
|
|
.flags = flag,
|
|
|
|
.reslimit = Svc::InvalidHandle,
|
|
|
|
.reslimit = Svc::InvalidHandle,
|
|
|
@ -1193,7 +1193,7 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std:
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize for application process.
|
|
|
|
// Initialize for application process.
|
|
|
|
R_TRY(this->Initialize(params, metadata.GetKernelCapabilities(), res_limit,
|
|
|
|
R_TRY(this->Initialize(params, metadata.GetKernelCapabilities(), res_limit,
|
|
|
|
KMemoryManager::Pool::Application));
|
|
|
|
KMemoryManager::Pool::Application, aslr_space_start));
|
|
|
|
|
|
|
|
|
|
|
|
// Assign remaining properties.
|
|
|
|
// Assign remaining properties.
|
|
|
|
m_is_hbl = is_hbl;
|
|
|
|
m_is_hbl = is_hbl;
|
|
|
|