summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/Sources/Network
diff options
context:
space:
mode:
Diffstat (limited to 'dev/ZKA/Sources/Network')
-rw-r--r--dev/ZKA/Sources/Network/IPC.cxx45
1 files changed, 43 insertions, 2 deletions
diff --git a/dev/ZKA/Sources/Network/IPC.cxx b/dev/ZKA/Sources/Network/IPC.cxx
index 926224d9..2ec50892 100644
--- a/dev/ZKA/Sources/Network/IPC.cxx
+++ b/dev/ZKA/Sources/Network/IPC.cxx
@@ -30,8 +30,12 @@ Bool ipc_int_sanitize_packet(IPC_MESSAGE_STRUCT* pckt)
break;
}
- case Endian::kEndianMixed:
+ case Endian::kEndianMixed: {
+ if (pckt->IpcEndianess == eIPCEPMixedEndian)
+ goto ipc_check_failed;
+
break;
+ }
default:
goto ipc_check_failed;
}
@@ -42,7 +46,7 @@ Bool ipc_int_sanitize_packet(IPC_MESSAGE_STRUCT* pckt)
goto ipc_check_failed;
}
- return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic;
+ return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cIPCEPHeaderMagic;
ipc_check_failed:
ErrLocal() = kErrorIPC;
@@ -65,4 +69,41 @@ namespace Kernel
return true;
}
+
+ /// @brief Construct packet function
+ /// @retval true packet is correct.
+ /// @retval false packet is incorrect and process has crashed.
+ Bool ipc_construct_packet(_Output IPC_MESSAGE_STRUCT** pckt_in)
+ {
+ // don't do anything if it's valid already.
+ if (*pckt_in)
+ return true;
+
+ // crash process if the packet pointer of pointer is NULL.
+ if (!pckt_in)
+ {
+ ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
+ return false;
+ }
+
+ *pckt_in = new IPC_MESSAGE_STRUCT();
+
+ MUST_PASS((*pckt_in));
+
+ if (*pckt_in)
+ {
+ (*pckt_in)->IpcHeaderMagic = cIPCEPHeaderMagic;
+
+ auto endian = DEDUCE_ENDIAN((*pckt_in), ((Char*)(*pckt_in))[0]);
+
+ (*pckt_in)->IpcEndianess = static_cast<UInt8>(endian);
+ (*pckt_in)->IpcPacketSize = sizeof(IPC_MESSAGE_STRUCT);
+ (*pckt_in)->IpcFrom.ProcessID = Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().ProcessId;
+ (*pckt_in)->IpcFrom.ProcessTeam = Kernel::ProcessScheduler::The().Leak().CurrentTeam().mTeamId;
+ return true;
+ }
+
+ ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
+ return false;
+ }
} // namespace Kernel