From b95b1fc42d371b08aa82fea8e92aa04b2ef5631f Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 21 Aug 2024 23:07:43 +0200 Subject: Kernel+DLL: See below. + Document LPC functions and reworked err_bug_check function to return false when everything is OK. + Added native APIs to SCI as well (threading, loader...) + Update ReadMe(s) of the other DLLs. Signed-off-by: Amlal El Mahrouss --- dev/CRT/ReadMe.md | 2 +- dev/DDK/ReadMe.md | 2 +- dev/EFS/ReadMe.md | 2 +- dev/SCI/Hint.h | 23 ++++++++++++++++++ dev/SCI/Hint.hxx | 23 ------------------ dev/SCI/ReadMe.md | 4 ++-- dev/SCI/SCIBase.hxx | 60 ++++++++++++++++++++++++++++++++-------------- dev/ZKA/KernelKit/LPC.hxx | 7 +++++- dev/ZKA/Sources/HError.cxx | 34 -------------------------- dev/ZKA/Sources/LPC.cxx | 34 ++++++++++++++++++++++++++ dev/ZKA/amd64-efi.make | 2 +- 11 files changed, 111 insertions(+), 82 deletions(-) create mode 100644 dev/SCI/Hint.h delete mode 100644 dev/SCI/Hint.hxx delete mode 100644 dev/ZKA/Sources/HError.cxx create mode 100644 dev/ZKA/Sources/LPC.cxx (limited to 'dev') diff --git a/dev/CRT/ReadMe.md b/dev/CRT/ReadMe.md index a959d6b8..c90f5b5f 100644 --- a/dev/CRT/ReadMe.md +++ b/dev/CRT/ReadMe.md @@ -1,4 +1,4 @@ -# ZKA C++ RunTime +# ZKA C++ RunTime. This is the public interface of ZKA' C++ RunTime. diff --git a/dev/DDK/ReadMe.md b/dev/DDK/ReadMe.md index ee12a9c1..41e39d83 100644 --- a/dev/DDK/ReadMe.md +++ b/dev/DDK/ReadMe.md @@ -1,4 +1,4 @@ -# DDK (Device Driver Kit) +# ZKA's Device Driver Kit. A kit used to write kernel HALs, using the NDK compiler suite. diff --git a/dev/EFS/ReadMe.md b/dev/EFS/ReadMe.md index ba9de32f..e99d4105 100644 --- a/dev/EFS/ReadMe.md +++ b/dev/EFS/ReadMe.md @@ -1,4 +1,4 @@ -# ZKA Encrypted File System +# ZKA Encrypted File System. This is the ZKA's Encrypted file system DLL. diff --git a/dev/SCI/Hint.h b/dev/SCI/Hint.h new file mode 100644 index 00000000..c785f953 --- /dev/null +++ b/dev/SCI/Hint.h @@ -0,0 +1,23 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#ifndef __SCI_HINT_HXX__ +#define __SCI_HINT_HXX__ + +#pragma compiler(hint_manifest) + +#define _Input +#define _Output + +#define _Optional + +#define _StrictCheckInput +#define _StrictCheckOutput + +#define _InOut +#define _StrictInOut + +#endif // ifndef __SCI_HINT_HXX__ diff --git a/dev/SCI/Hint.hxx b/dev/SCI/Hint.hxx deleted file mode 100644 index c785f953..00000000 --- a/dev/SCI/Hint.hxx +++ /dev/null @@ -1,23 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#ifndef __SCI_HINT_HXX__ -#define __SCI_HINT_HXX__ - -#pragma compiler(hint_manifest) - -#define _Input -#define _Output - -#define _Optional - -#define _StrictCheckInput -#define _StrictCheckOutput - -#define _InOut -#define _StrictInOut - -#endif // ifndef __SCI_HINT_HXX__ diff --git a/dev/SCI/ReadMe.md b/dev/SCI/ReadMe.md index 72732c21..00d90c14 100644 --- a/dev/SCI/ReadMe.md +++ b/dev/SCI/ReadMe.md @@ -1,5 +1,5 @@ -# ZKA System Call Interface. +# ZKA's SCI. -System Call Interface and Component Interface. +System Call and Component Interface, used maninly to communicate with kernel and registered objects. ###### (c) ZKA Technologies, all rights reserved. diff --git a/dev/SCI/SCIBase.hxx b/dev/SCI/SCIBase.hxx index 1e79bbbc..982ca950 100644 --- a/dev/SCI/SCIBase.hxx +++ b/dev/SCI/SCIBase.hxx @@ -10,9 +10,7 @@ Purpose: SCI/M core header file (C++) #ifndef __SCI_BASE_HXX__ #define __SCI_BASE_HXX__ -#ifdef __cplusplus - -#include +#include #define IMPORT_CXX extern "C++" #define IMPORT_C extern "C" @@ -96,32 +94,34 @@ typedef VoidPtr NEW_OBJECT; typedef NEW_OBJECT DLL_OBJECT; typedef NEW_OBJECT IO_OBJECT; typedef NEW_OBJECT COMP_OBJECT; +typedef NEW_OBJECT SCM_OBJECT; // ------------------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------------------ // -/// @note Part of NK loader API. +/// @note Part of ZKA loader API. // ------------------------------------------------------------------------------------------ // - /// @brief Get function which is part of the DLL. /// @param symbol the symbol to look for /// @param dll_handle the DLL handle. /// @return the proc pointer. -IMPORT_C VoidPtr RtlGetDLLProc(_Input const Char* symbol, _Input NEW_OBJECT dll_handle); +IMPORT_C NEW_OBJECT LdrGetDLLProc(_Input const Char* symbol, _Input NEW_OBJECT dll_handle); /// @brief Open DLL handle. /// @param path /// @param drv /// @return -IMPORT_C NEW_OBJECT RtlOpenDLL(_Input const Char* path, _Input const Char* drive_letter); +IMPORT_C NEW_OBJECT LdrOpenDLL(_Input const Char* path, _Input const Char* drive_letter); /// @brief Close DLL handle /// @param dll_handle /// @return -IMPORT_C UInt0 RtlCloseDLL(_Input NEW_OBJECT dll_handle); +IMPORT_C UInt0 LdrCloseDLL(_Input NEW_OBJECT dll_handle); -/// @note Part of NK file API. +// ------------------------------------------------------------------------------------------ // +// File API. +// ------------------------------------------------------------------------------------------ // /// @brief Opens a file from a drive. /// @param fs_path the filesystem path. @@ -134,10 +134,18 @@ IMPORT_C NEW_OBJECT RtlOpenFile(const Char* fs_path, const Char* drive_letter); /// @return IMPORT_C UInt0 RtlCloseFile(_Input NEW_OBJECT file_desc); +// ------------------------------------------------------------------------ +// TLS API. +// ------------------------------------------------------------------------ + /// @brief Installs the TIB and GIB inside the current process. -/// @param none +/// @param void. /// @return > 0 error ocurred or already present, = 0 success. -IMPORT_C UInt32 RtlInstallInfoBlocks(UInt0); +IMPORT_C UInt32 TlsInstallIB(UInt0); + +// ------------------------------------------------------------------------ +// SCM API. +// ------------------------------------------------------------------------ /// @brief Allocate new SCM object. /// @tparam TCLS the class type. @@ -157,27 +165,43 @@ SInt32 ScmReleaseClass(_Input TCLS* cls); /// @brief Creates an SCM instance in the process. /// @param handle_instance the SCM handle. /// @param flags the SCM flags. -SInt32 ScmCreateInstance(_Input UInt32 flags, _Output VoidPtr* handle_instance); +IMPORT_C SInt32 ScmCreateInstance(_Input UInt32 flags, _Output SCM_OBJECT* handle_instance); /// @brief Destroys an SCM instance of the process. /// @param handle_instance the SCM handle. -UInt0 ScmDestroyInstance(_Input VoidPtr handle_instance); +IMPORT_C UInt0 ScmDestroyInstance(_Input SCM_OBJECT handle_instance); + +// ------------------------------------------------------------------------ +// Memory Management API. +// ------------------------------------------------------------------------ /// @brief Creates a new heap from the process's address space. /// @param len the length of it. /// @param flags the flags of it. /// @return heap pointer. -VoidPtr RtlCreateHeap(_Input SizeT len, _Input UInt32 flags); +IMPORT_C VoidPtr RtlCreateHeap(_Input SizeT len, _Input UInt32 flags); /// @brief Destroys the pointer /// @param heap the heap itself. /// @return void. -UInt0 RtlDestroyHeap(_Input VoidPtr heap); +IMPORT_C UInt0 RtlDestroyHeap(_Input VoidPtr heap); -#else +// ------------------------------------------------------------------------ +// Error handling API. +// ------------------------------------------------------------------------ + +IMPORT_C SInt32 ErrGetLastError(UInt0); + +// ------------------------------------------------------------------------ +// Threading API. +// ------------------------------------------------------------------------ + +IMPORT_C UInt0 ThrExitCurrentThread(SInt32 exit_code); +IMPORT_C UInt0 ThrExitMainThread(SInt32 exit_code); -#include +IMPORT_C UInt0 ThrExitYieldThread(UInt0); -#endif // ifdef __cplusplus +IMPORT_C UInt0 ThrExitJoinThread(UInt0); +IMPORT_C UInt0 ThrExitDetachThread(UInt0); #endif // ifndef __SCI_BASE_HXX__ diff --git a/dev/ZKA/KernelKit/LPC.hxx b/dev/ZKA/KernelKit/LPC.hxx index fec1d637..6553f45c 100644 --- a/dev/ZKA/KernelKit/LPC.hxx +++ b/dev/ZKA/KernelKit/LPC.hxx @@ -51,6 +51,11 @@ namespace Kernel inline constexpr HError kErrorInvalidCreds = 61; inline constexpr HError kErrorUnimplemented = 0; - Void err_bug_check_raise(void) noexcept; + /// @brief Reports a bug to system check. + Void err_bug_check_raise(void) noexcept; + + /// @brief Does a system wide bug check. + /// @param void no params. + /// @return if error-free: false, otherwise true. Boolean err_bug_check(void) noexcept; } // namespace Kernel diff --git a/dev/ZKA/Sources/HError.cxx b/dev/ZKA/Sources/HError.cxx deleted file mode 100644 index 5ccf8aea..00000000 --- a/dev/ZKA/Sources/HError.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#include -#include - -namespace Kernel -{ - STATIC Bool cRaise = false; - - /// @brief Does a system wide bug check. - /// @param void no params. - /// @return if error-free: true, otherwise false. - Boolean err_bug_check(void) noexcept - { - if (cRaise) - { - ke_stop(RUNTIME_CHECK_BAD_BEHAVIOR); - } - - return true; - } - - /// @brief Tells if we should raise a bug check not. - /// @param void - /// @return void - Void err_bug_check_raise(Void) noexcept - { - cRaise = true; - } -} // namespace Kernel diff --git a/dev/ZKA/Sources/LPC.cxx b/dev/ZKA/Sources/LPC.cxx new file mode 100644 index 00000000..46f621bb --- /dev/null +++ b/dev/ZKA/Sources/LPC.cxx @@ -0,0 +1,34 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#include +#include + +namespace Kernel +{ + STATIC Bool cRaise = false; + + /// @brief Does a system wide bug check. + /// @param void no params. + /// @return if error-free: false, otherwise true. + Boolean err_bug_check(void) noexcept + { + if (cRaise) + { + ke_stop(RUNTIME_CHECK_BAD_BEHAVIOR); + } + + return false; + } + + /// @brief Tells if we should raise a bug check not. + /// @param void + /// @return void + Void err_bug_check_raise(Void) noexcept + { + cRaise = true; + } +} // namespace Kernel diff --git a/dev/ZKA/amd64-efi.make b/dev/ZKA/amd64-efi.make index 0926e7c0..3797e5ba 100644 --- a/dev/ZKA/amd64-efi.make +++ b/dev/ZKA/amd64-efi.make @@ -71,7 +71,7 @@ link-amd64-epm: .PHONY: all all: newos-amd64-epm link-amd64-epm - @echo "NewOSKrnl => OK." + @echo "Kernel => OK." .PHONY: help help: -- cgit v1.2.3