summaryrefslogtreecommitdiffhomepage
path: root/dev/ddk/src/ddk_kernel_call.c
diff options
context:
space:
mode:
authorAmlal <amlal@el-mahrouss-logic.com>2024-09-28 19:13:46 +0200
committerAmlal <amlal@el-mahrouss-logic.com>2024-09-28 19:13:46 +0200
commit421db65331663304466577b7187780d9eba18077 (patch)
tree3c7c4dc68537935b8cf98313e6a5bfe51786b7d2 /dev/ddk/src/ddk_kernel_call.c
parentb6e416c9986bb545956a642d626e6aafd54f3b76 (diff)
feat: Add common XPCOM controls directory, restructure project, and introduce API breaking changes
- Added a new directory for common XPCOM controls to organize reusable components. - Restructured project layout for better modularity and maintainability. - Introduced API breaking changes in the process, requiring adjustments for backward compatibility. Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/ddk/src/ddk_kernel_call.c')
-rw-r--r--dev/ddk/src/ddk_kernel_call.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/dev/ddk/src/ddk_kernel_call.c b/dev/ddk/src/ddk_kernel_call.c
new file mode 100644
index 00000000..d768cb09
--- /dev/null
+++ b/dev/ddk/src/ddk_kernel_call.c
@@ -0,0 +1,60 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+ Purpose: DDK Kernel call.
+
+------------------------------------------- */
+
+#include <ddk/ddk.h>
+#include <stdarg.h>
+
+/// @brief this is an internal call, do not use it.
+DK_EXTERN ATTRIBUTE(naked) void* __KernelCallDispatch(const char* name, int32_t cnt, void* data, size_t sz);
+
+/// @brief Interupt Kernel
+/// @param KernelRpcName RPC name
+/// @param cnt number of elements in **data** pointer.
+/// @param data data pointer.
+/// @param sz The size of the whole data pointer.
+/// @retval void* Kernel call was successful.
+/// @retval nil Kernel call failed, call KernelLastError(void)
+DK_EXTERN void* KernelCall(const char* name, int32_t cnt, void* data, size_t sz)
+{
+ if (!name || *name == 0 || cnt == 0)
+ return nil;
+
+ return __KernelCallDispatch(name, cnt, data, sz);
+}
+
+/// @brief Add system call.
+/// @param slot system call slot
+/// @param slotFn, syscall slot.
+DK_EXTERN void KernelAddSyscall(const int slot, void (*slotFn)(void* a0))
+{
+ KernelCall("IntAddSyscall", slot, slotFn, 1);
+}
+
+/// @brief Get a Kernel property.
+/// @param slot property id (always 0)
+/// @param name the object's name.
+/// @return Object manifest.
+DK_EXTERN struct DDK_OBJECT_MANIFEST* KernelGetObject(const int slot, const char* name)
+{
+ struct DDK_OBJECT_MANIFEST* manifest = (struct DDK_OBJECT_MANIFEST*)KernelCall("RtlGetObject", slot, (void*)name, 1);
+
+ if (!manifest)
+ return nil;
+
+ return manifest;
+}
+
+/// @brief Set a Kernel property.
+/// @param slot property id (always 0)
+/// @param name the object's name.
+/// @param ddk_pr pointer to a object's DDK_OBJECT_MANIFEST.
+/// @return property's object.
+DK_EXTERN void* KernelSetObject(const int slot, const struct DDK_OBJECT_MANIFEST* ddk_pr)
+{
+ return KernelCall("RtlSetObject", slot, (void*)ddk_pr, 1);
+}