From 907322a1224e782ffabcc36e2b71ee847e19c8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B3=D0=BE=D1=80?= Date: Thu, 17 Apr 2025 06:51:38 +0200 Subject: [PATCH] create ipc.c --- src/ipc.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/ipc.c diff --git a/src/ipc.c b/src/ipc.c new file mode 100644 index 0000000..9315f27 --- /dev/null +++ b/src/ipc.c @@ -0,0 +1,51 @@ +# include + +enum SendIPCErrors +{ + Ok = 0, + BufferNotDefined = 1, + BufferLocked = 2, + BufferOverflow = 3, + PidNotExist = 4 +} + +inline static void define_ipc(ksys_ipc_buffer *buffer, size_t bufLen) +{ + asm_inline( + "int $0x40" + ::"a"(60), "b"(1), "c"(buffer), "d"(bufLen) + ); +} + +inline static enum SendIPCErrors send_ipc(int pid, ksys_ipc_msg *msg, size_t msgLen) +{ + enum SendIPCErrors ret; + + asm_inline( + "int $0x40" + : "=a"(ret), + : "a"(60), "b"(1), "c"(pid), "d"(msg), "S"(msgLen) + ) + + return ret; +} + +int syscalls_DefineIPCBuffer(lua_State *L) +{ + define_ipc(); + + return 0; +} + +int syscalls_SendIPCMessage(lua_State *L) +{ + lua_pushinteger( + L, + send_ipc( + lua_checkinteger(L, 1);, + + ) + ); + + return 1; +}