mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-08 21:21:48 +00:00
kern/ipc: add Atmosphere's mitm pid passthrough logic
This commit is contained in:
parent
4e226b523e
commit
2ec4ed3568
1 changed files with 16 additions and 2 deletions
|
@ -123,8 +123,22 @@ namespace ams::kern {
|
|||
|
||||
/* Copy the process ID. */
|
||||
if (src_special_header.GetHasProcessId()) {
|
||||
/* TODO: Atmosphere mitm extension support. */
|
||||
offset = dst_msg.SetProcessId(offset, src_process.GetId());
|
||||
/* NOTE: Atmosphere extends the official kernel here to enable the mitm api. */
|
||||
/* If building the kernel without this support, just set the following to false. */
|
||||
constexpr bool EnableProcessIdPassthroughForAtmosphere = true;
|
||||
|
||||
if constexpr (EnableProcessIdPassthroughForAtmosphere) {
|
||||
constexpr u64 PassthroughProcessIdMask = UINT64_C(0xFFFF000000000000);
|
||||
constexpr u64 PassthroughProcessIdValue = UINT64_C(0xFFFE000000000000);
|
||||
static_assert((PassthroughProcessIdMask & PassthroughProcessIdValue) == PassthroughProcessIdValue);
|
||||
|
||||
const u64 src_process_id_value = src_msg.GetProcessId(offset);
|
||||
const bool is_passthrough = (src_process_id_value & PassthroughProcessIdMask) == PassthroughProcessIdValue;
|
||||
|
||||
offset = dst_msg.SetProcessId(offset, is_passthrough ? (src_process_id_value & ~PassthroughProcessIdMask) : src_process.GetId());
|
||||
} else {
|
||||
offset = dst_msg.SetProcessId(offset, src_process.GetId());
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare to process handles. */
|
||||
|
|
Loading…
Reference in a new issue