mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-30 14:35:17 -04:00
ldr/pm: update for 20.0.0 abi changes
This commit is contained in:
parent
07df13e2a0
commit
f55cf42433
17 changed files with 186 additions and 141 deletions
35
stratosphere/pm/source/impl/pm_process_attributes.hpp
Normal file
35
stratosphere/pm/source/impl/pm_process_attributes.hpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::pm::impl {
|
||||
|
||||
struct ProcessAttributes {
|
||||
u8 unknown[3];
|
||||
ldr::ProgramAttributes program_attrs;
|
||||
};
|
||||
static_assert(sizeof(ProcessAttributes) == 5);
|
||||
|
||||
constexpr inline ProcessAttributes ProcessAttributes_Nx = {
|
||||
.unknown = {},
|
||||
.program_attrs = {
|
||||
.platform = ncm::ContentMetaPlatform::Nx,
|
||||
.content_attributes = fs::ContentAttributes_None,
|
||||
},
|
||||
};
|
||||
|
||||
}
|
|
@ -76,7 +76,7 @@ namespace ams::pm::impl {
|
|||
|
||||
}
|
||||
|
||||
ProcessInfo::ProcessInfo(os::NativeHandle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l, const cfg::OverrideStatus &s) : m_process_id(pid), m_pin_id(pin), m_loc(l), m_status(s), m_handle(h), m_state(svc::ProcessState_Created), m_flags(0) {
|
||||
ProcessInfo::ProcessInfo(os::NativeHandle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l, const cfg::OverrideStatus &s, const ProcessAttributes &attrs) : m_process_id(pid), m_pin_id(pin), m_loc(l), m_status(s), m_handle(h), m_state(svc::ProcessState_Created), m_flags(0), m_attrs(attrs) {
|
||||
os::InitializeMultiWaitHolder(std::addressof(m_multi_wait_holder), m_handle);
|
||||
os::SetMultiWaitHolderUserData(std::addressof(m_multi_wait_holder), reinterpret_cast<uintptr_t>(this));
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ namespace ams::pm::impl {
|
|||
return ProcessListAccessor(g_exit_list);
|
||||
}
|
||||
|
||||
ProcessInfo *AllocateProcessInfo(svc::Handle process_handle, os::ProcessId process_id, ldr::PinId pin_id, const ncm::ProgramLocation &location, const cfg::OverrideStatus &override_status) {
|
||||
return g_process_info_allocator.AllocateProcessInfo(process_handle, process_id, pin_id, location, override_status);
|
||||
ProcessInfo *AllocateProcessInfo(svc::Handle process_handle, os::ProcessId process_id, ldr::PinId pin_id, const ncm::ProgramLocation &location, const cfg::OverrideStatus &override_status, const ProcessAttributes &attrs) {
|
||||
return g_process_info_allocator.AllocateProcessInfo(process_handle, process_id, pin_id, location, override_status, attrs);
|
||||
}
|
||||
|
||||
void CleanupProcessInfo(ProcessListAccessor &list, ProcessInfo *process_info) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include "pm_process_manager.hpp"
|
||||
#include "pm_process_attributes.hpp"
|
||||
|
||||
namespace ams::pm::impl {
|
||||
|
||||
|
@ -46,6 +47,7 @@ namespace ams::pm::impl {
|
|||
os::NativeHandle m_handle;
|
||||
svc::ProcessState m_state;
|
||||
u32 m_flags;
|
||||
ProcessAttributes m_attrs;
|
||||
os::MultiWaitHolderType m_multi_wait_holder;
|
||||
private:
|
||||
void SetFlag(Flag flag) {
|
||||
|
@ -60,7 +62,7 @@ namespace ams::pm::impl {
|
|||
return (m_flags & flag);
|
||||
}
|
||||
public:
|
||||
ProcessInfo(os::NativeHandle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l, const cfg::OverrideStatus &s);
|
||||
ProcessInfo(os::NativeHandle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l, const cfg::OverrideStatus &s, const ProcessAttributes &attrs);
|
||||
~ProcessInfo();
|
||||
void Cleanup();
|
||||
|
||||
|
@ -88,6 +90,10 @@ namespace ams::pm::impl {
|
|||
return m_status;
|
||||
}
|
||||
|
||||
const ProcessAttributes &GetProcessAttributes() const {
|
||||
return m_attrs;
|
||||
}
|
||||
|
||||
svc::ProcessState GetState() const {
|
||||
return m_state;
|
||||
}
|
||||
|
@ -235,7 +241,7 @@ namespace ams::pm::impl {
|
|||
ProcessListAccessor GetProcessList();
|
||||
ProcessListAccessor GetExitList();
|
||||
|
||||
ProcessInfo *AllocateProcessInfo(svc::Handle process_handle, os::ProcessId process_id, ldr::PinId pin_id, const ncm::ProgramLocation &location, const cfg::OverrideStatus &override_status);
|
||||
ProcessInfo *AllocateProcessInfo(svc::Handle process_handle, os::ProcessId process_id, ldr::PinId pin_id, const ncm::ProgramLocation &location, const cfg::OverrideStatus &override_status, const ProcessAttributes &attrs);
|
||||
void CleanupProcessInfo(ProcessListAccessor &list, ProcessInfo *process_info);
|
||||
|
||||
}
|
||||
|
|
|
@ -117,14 +117,14 @@ namespace ams::pm::impl {
|
|||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result LaunchProgramImpl(ProcessInfo **out_process_info, os::ProcessId *out_process_id, const ncm::ProgramLocation &loc, u32 flags) {
|
||||
Result LaunchProgramImpl(ProcessInfo **out_process_info, os::ProcessId *out_process_id, const ncm::ProgramLocation &loc, u32 flags, const ProcessAttributes &attrs) {
|
||||
/* Set the output to nullptr, if we fail. */
|
||||
*out_process_info = nullptr;
|
||||
|
||||
/* Get Program Info. */
|
||||
ldr::ProgramInfo program_info;
|
||||
cfg::OverrideStatus override_status;
|
||||
R_TRY(ldr::pm::AtmosphereGetProgramInfo(std::addressof(program_info), std::addressof(override_status), loc));
|
||||
R_TRY(ldr::pm::AtmosphereGetProgramInfo(std::addressof(program_info), std::addressof(override_status), loc, attrs.program_attrs));
|
||||
const bool is_application = (program_info.flags & ldr::ProgramInfoFlag_ApplicationTypeMask) == ldr::ProgramInfoFlag_Application;
|
||||
const bool allow_debug = (program_info.flags & ldr::ProgramInfoFlag_AllowDebug) || hos::GetVersion() < hos::Version_2_0_0;
|
||||
|
||||
|
@ -166,14 +166,14 @@ namespace ams::pm::impl {
|
|||
WaitResourceAvailable(std::addressof(program_info));
|
||||
|
||||
/* Actually create the process. */
|
||||
R_TRY(ldr::pm::CreateProcess(std::addressof(process_handle), pin_id, GetLoaderCreateProcessFlags(flags), GetResourceLimitHandle(std::addressof(program_info))));
|
||||
R_TRY(ldr::pm::CreateProcess(std::addressof(process_handle), pin_id, GetLoaderCreateProcessFlags(flags), GetResourceLimitHandle(std::addressof(program_info)), attrs.program_attrs));
|
||||
}
|
||||
|
||||
/* Get the process id. */
|
||||
os::ProcessId process_id = os::GetProcessId(process_handle);
|
||||
|
||||
/* Make new process info. */
|
||||
ProcessInfo *process_info = AllocateProcessInfo(process_handle, process_id, pin_id, fixed_location, override_status);
|
||||
ProcessInfo *process_info = AllocateProcessInfo(process_handle, process_id, pin_id, fixed_location, override_status, attrs);
|
||||
AMS_ABORT_UNLESS(process_info != nullptr);
|
||||
|
||||
/* Add the new process info to the process list. */
|
||||
|
@ -253,7 +253,7 @@ namespace ams::pm::impl {
|
|||
Result LaunchProgram(os::ProcessId *out_process_id, const ncm::ProgramLocation &loc, u32 flags) {
|
||||
/* Launch the program. */
|
||||
ProcessInfo *process_info = nullptr;
|
||||
R_TRY(LaunchProgramImpl(std::addressof(process_info), out_process_id, loc, flags));
|
||||
R_TRY(LaunchProgramImpl(std::addressof(process_info), out_process_id, loc, flags, ProcessAttributes_Nx));
|
||||
|
||||
/* Register the process info with the tracker. */
|
||||
g_process_tracker.QueueEntry(process_info);
|
||||
|
@ -268,7 +268,7 @@ namespace ams::pm::impl {
|
|||
R_UNLESS(!process_info->HasStarted(), pm::ResultAlreadyStarted());
|
||||
|
||||
ldr::ProgramInfo program_info;
|
||||
R_TRY(ldr::pm::GetProgramInfo(std::addressof(program_info), process_info->GetProgramLocation()));
|
||||
R_TRY(ldr::pm::GetProgramInfo(std::addressof(program_info), process_info->GetProgramLocation(), process_info->GetProcessAttributes().program_attrs));
|
||||
R_RETURN(StartProcess(process_info, std::addressof(program_info)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue