This commit is contained in:
Alex 2023-02-07 03:22:44 +02:00
parent 3bc76edec0
commit a23d999183
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
4 changed files with 28 additions and 5 deletions

View File

@ -124,17 +124,14 @@ static uintptr_t sys_kernelctl(SyscallsFrame *Frame, enum KCtl Command, uint64_t
UNUSED(Frame); UNUSED(Frame);
} }
static int sys_ipc(SyscallsFrame *Frame, int Command, int Type, int ID, int Flags, void *Buffer, size_t Size) static int sys_ipc(SyscallsFrame *Frame, enum IPCCommand Command, enum IPCType Type, int ID, int Flags, void *Buffer, size_t Size)
{ {
SmartTimeoutLock(SyscallsLock, 10000); SmartTimeoutLock(SyscallsLock, 10000);
/* Allow everyone to use IPC */ /* Allow everyone to use IPC */
if (!CheckTrust(TrustedByKernel | Trusted | Untrusted)) if (!CheckTrust(TrustedByKernel | Trusted | Untrusted))
return SYSCALL_ACCESS_DENIED; return SYSCALL_ACCESS_DENIED;
IPC *ipc = TaskManager->GetCurrentProcess()->IPC;
UNUSED(Frame); UNUSED(Frame);
return 0; return TaskManager->GetCurrentProcess()->IPC->HandleSyscall(Command, Type, ID, Flags, Buffer, Size);
} }
static int sys_file_open(SyscallsFrame *Frame) static int sys_file_open(SyscallsFrame *Frame)

View File

@ -146,6 +146,11 @@ namespace InterProcessCommunication
return IPCIDNotFound; return IPCIDNotFound;
} }
int IPC::HandleSyscall(long Command, long Type, int ID, int Flags, void *Buffer, size_t Size)
{
return 0;
}
IPC::IPC(void *Process) IPC::IPC(void *Process)
{ {
this->Process = Process; this->Process = Process;

View File

@ -59,6 +59,7 @@ namespace InterProcessCommunication
IPC(void *Process); IPC(void *Process);
~IPC(); ~IPC();
int HandleSyscall(long Command, long Type, int ID, int Flags, void *Buffer, size_t Size);
IPCHandle *Create(IPCType Type, char UniqueToken[16]); IPCHandle *Create(IPCType Type, char UniqueToken[16]);
IPCErrorCode Destroy(IPCID ID); IPCErrorCode Destroy(IPCID ID);
IPCErrorCode Read(IPCID ID, uint8_t *Buffer, long Size); IPCErrorCode Read(IPCID ID, uint8_t *Buffer, long Size);

View File

@ -14,6 +14,7 @@ enum NativeSyscalls
* This syscall is used to exit the current process with the provided exit code. * This syscall is used to exit the current process with the provided exit code.
*/ */
_Exit = 0, _Exit = 0,
/** @brief Print a message to the kernel console /** @brief Print a message to the kernel console
* @fn int Print(char Char, int Index) * @fn int Print(char Char, int Index)
* This syscall is used to print a message to the kernel console. * This syscall is used to print a message to the kernel console.
@ -25,11 +26,13 @@ enum NativeSyscalls
* This syscall is used to request a specific number of pages of memory from the kernel. * This syscall is used to request a specific number of pages of memory from the kernel.
*/ */
_RequestPages, _RequestPages,
/** @brief Free pages of memory /** @brief Free pages of memory
* @fn int FreePages(uintptr_t Address, size_t Count) * @fn int FreePages(uintptr_t Address, size_t Count)
* This syscall is used to free a specific number of pages of memory that were previously requested. * This syscall is used to free a specific number of pages of memory that were previously requested.
*/ */
_FreePages, _FreePages,
/** @brief Detach memory address /** @brief Detach memory address
* @fn int DetachAddress(uintptr_t Address) * @fn int DetachAddress(uintptr_t Address)
* This syscall is used to detach a specific memory address from the current process. * This syscall is used to detach a specific memory address from the current process.
@ -54,26 +57,31 @@ enum NativeSyscalls
* This syscall is used to open a file with the provided path and flags. * This syscall is used to open a file with the provided path and flags.
*/ */
_FileOpen, _FileOpen,
/** @brief Close a file /** @brief Close a file
* @fn * @fn
* This syscall is used to close a file that was previously opened. * This syscall is used to close a file that was previously opened.
*/ */
_FileClose, _FileClose,
/** @brief Read from a file /** @brief Read from a file
* @fn * @fn
* This syscall is used to read a specific number of bytes from a file at a specific offset. * This syscall is used to read a specific number of bytes from a file at a specific offset.
*/ */
_FileRead, _FileRead,
/** @brief Write to a file /** @brief Write to a file
* @fn * @fn
* This syscall is used to write a specific number of bytes to a file at a specific offset. * This syscall is used to write a specific number of bytes to a file at a specific offset.
*/ */
_FileWrite, _FileWrite,
/** @brief Seek in a file /** @brief Seek in a file
* @fn * @fn
* This syscall is used to change the current offset in a file. * This syscall is used to change the current offset in a file.
*/ */
_FileSeek, _FileSeek,
/** @brief Get file status /** @brief Get file status
* @fn * @fn
* This syscall is used to retrieve information about a file such as its size, permissions, etc. * This syscall is used to retrieve information about a file such as its size, permissions, etc.
@ -85,58 +93,70 @@ enum NativeSyscalls
* This syscall is used to wait for a specific process or thread to terminate. It returns the exit code of the process or thread. * This syscall is used to wait for a specific process or thread to terminate. It returns the exit code of the process or thread.
*/ */
_Wait, _Wait,
/** @brief Kill a process or a thread /** @brief Kill a process or a thread
* @fn * @fn
* This syscall is used to send a termination signal to a specific process or thread * This syscall is used to send a termination signal to a specific process or thread
*/ */
_Kill, _Kill,
/** @brief Spawn a new process /** @brief Spawn a new process
* @fn * @fn
* This syscall is used to create a new process with the provided path and arguments. * This syscall is used to create a new process with the provided path and arguments.
*/ */
_Spawn, _Spawn,
/** @brief Spawn a new thread /** @brief Spawn a new thread
* @fn * @fn
* This syscall is used to create a new thread within the current process with the provided function and arguments. * This syscall is used to create a new thread within the current process with the provided function and arguments.
*/ */
_SpawnThread, _SpawnThread,
/** @brief Get thread list of a process /** @brief Get thread list of a process
* @fn * @fn
* This syscall is used to retrieve a list of all the threads within a specific process. * This syscall is used to retrieve a list of all the threads within a specific process.
*/ */
_GetThreadListOfProcess, _GetThreadListOfProcess,
/** @brief Get current process /** @brief Get current process
* @fn * @fn
* This syscall is used to retrieve information about the current process. * This syscall is used to retrieve information about the current process.
*/ */
_GetCurrentProcess, _GetCurrentProcess,
/** @brief Get current thread /** @brief Get current thread
* @fn * @fn
* This syscall is used to retrieve information about the current thread. * This syscall is used to retrieve information about the current thread.
*/ */
_GetCurrentThread, _GetCurrentThread,
/** @brief Get process by PID /** @brief Get process by PID
* @fn * @fn
* This syscall is used to retrieve information about a specific process by its PID. * This syscall is used to retrieve information about a specific process by its PID.
*/ */
_GetProcessByPID, _GetProcessByPID,
/** @brief Get thread by TID /** @brief Get thread by TID
* @fn * @fn
* This syscall is used to retrieve information about a specific thread by its TID. * This syscall is used to retrieve information about a specific thread by its TID.
*/ */
_GetThreadByTID, _GetThreadByTID,
/** @brief Kill a process /** @brief Kill a process
* @fn * @fn
* This syscall is used to send a termination signal to a specific process. * This syscall is used to send a termination signal to a specific process.
*/ */
_KillProcess, _KillProcess,
/** @brief Kill a thread /** @brief Kill a thread
* @fn * @fn
* This syscall is used to send a termination signal to a specific thread. * This syscall is used to send a termination signal to a specific thread.
*/ */
_KillThread, _KillThread,
/** @brief Reserved syscall */ /** @brief Reserved syscall */
_SysReservedCreateProcess, _SysReservedCreateProcess,
/** @brief Reserved syscall */ /** @brief Reserved syscall */
_SysReservedCreateThread, _SysReservedCreateThread,
}; };