mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-18 17:11:23 +00:00
kern/ipc: add Atmosphere's mitm pid passthrough logic
This commit is contained in:
parent
4e226b523e
commit
2ec4ed3568
@ -123,9 +123,23 @@ namespace ams::kern {
|
||||
|
||||
/* Copy the process ID. */
|
||||
if (src_special_header.GetHasProcessId()) {
|
||||
/* TODO: Atmosphere mitm extension support. */
|
||||
/* 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. */
|
||||
auto &dst_handle_table = dst_process.GetHandleTable();
|
||||
|
Loading…
Reference in New Issue
Block a user