1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-23 12:22:08 +00:00

kern/ipc: add Atmosphere's mitm pid passthrough logic

This commit is contained in:
Michael Scire 2020-07-10 10:45:22 -07:00
parent 4e226b523e
commit 2ec4ed3568

View file

@ -123,9 +123,23 @@ namespace ams::kern {
/* Copy the process ID. */ /* Copy the process ID. */
if (src_special_header.GetHasProcessId()) { 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()); offset = dst_msg.SetProcessId(offset, src_process.GetId());
} }
}
/* Prepare to process handles. */ /* Prepare to process handles. */
auto &dst_handle_table = dst_process.GetHandleTable(); auto &dst_handle_table = dst_process.GetHandleTable();