From 3b3b36dcc6542e203475fe1d50ed89799e3f3fc6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 25 Mar 2024 20:17:53 +0100 Subject: Kernel: implement some tickets, improved stuff. Signed-off-by: Amlal El Mahrouss --- Private/KernelKit/Framebuffer.hpp | 22 +- Private/ObjectKit/ObjectKit.hxx | 3 +- Private/Source/Framebuffer.cxx | 32 ++- Private/Source/KernelHeap.cxx | 10 +- Public/Developer/.gitkeep | 0 Public/Developer/System.Core/.gitkeep | 0 .../System.Core/AMD64/HCoreAssemblyRoutines.s | 24 ++ Public/Developer/System.Core/ARM64/.gitkeep | 0 .../System.Core/Headers/Containers/ODF.hxx | 41 ++++ .../System.Core/Headers/Containers/XIFF.hxx | 57 +++++ Public/Developer/System.Core/Headers/Defines.hxx | 250 +++++++++++++++++++++ Public/Developer/System.Core/Headers/File.hxx | 105 +++++++++ Public/Developer/System.Core/Headers/Heap.hxx | 64 ++++++ Public/Developer/System.Core/Headers/Hint.hxx | 18 ++ Public/Developer/System.Core/Headers/Thread.hxx | 23 ++ .../System.Core/Headers/Window/Dialog.hxx | 9 + .../Developer/System.Core/Headers/Window/Image.hxx | 8 + .../Developer/System.Core/Headers/Window/Menu.hxx | 8 + .../Developer/System.Core/Headers/Window/Rsrc.hxx | 8 + .../System.Core/Headers/Window/TrueType.hxx | 7 + .../System.Core/Headers/Window/Window.hxx | 38 ++++ Public/Developer/System.Core/Makefile | 20 ++ Public/Developer/System.Core/RISCV/.gitkeep | 0 Public/Developer/System.Core/ReadMe.md | 8 + Public/Developer/System.Core/Sources/Heap.cxx | 83 +++++++ .../System.Core/Sources/LibEntrypoint.cxx | 14 ++ .../Developer/System.Core/Sources/New+Delete.cxx | 55 +++++ Public/Developer/System.Core/compile_flags.txt | 4 + Public/Documentation/BUG_LIST.TXT | 1 - Public/Documentation/DESIGN.DRAWIO | 70 ------ Public/Documentation/SPECIFICATION.TXT | 53 ----- Public/Documentation/Specs.md | 53 +++++ Public/Documentation/TODO_LIST.TXT | 25 --- Public/Documentation/Todo.md | 21 ++ Public/Documentation/compile_flags.txt | 5 - Public/Documentation/kernel-design.drawio | 70 ++++++ Public/SDK/.gitkeep | 0 Public/SDK/System.Core/.gitkeep | 0 .../SDK/System.Core/AMD64/HCoreAssemblyRoutines.s | 24 -- Public/SDK/System.Core/ARM64/.gitkeep | 0 Public/SDK/System.Core/Headers/Defines.hxx | 250 --------------------- Public/SDK/System.Core/Headers/File.hxx | 103 --------- .../SDK/System.Core/Headers/FormatManager/ODF.hxx | 41 ---- .../SDK/System.Core/Headers/FormatManager/XIFF.hxx | 42 ---- Public/SDK/System.Core/Headers/Heap.hxx | 77 ------- Public/SDK/System.Core/Headers/Hint.hxx | 18 -- Public/SDK/System.Core/Headers/Thread.hxx | 27 --- .../SDK/System.Core/Headers/UIManager/Dialog.hxx | 8 - Public/SDK/System.Core/Headers/UIManager/Image.hxx | 8 - Public/SDK/System.Core/Headers/UIManager/Menu.hxx | 8 - Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx | 8 - .../SDK/System.Core/Headers/UIManager/TrueType.hxx | 7 - .../SDK/System.Core/Headers/UIManager/Window.hxx | 8 - Public/SDK/System.Core/Makefile | 20 -- Public/SDK/System.Core/RISCV/.gitkeep | 0 Public/SDK/System.Core/ReadMe.md | 8 - Public/SDK/System.Core/Sources/Heap.cxx | 83 ------- Public/SDK/System.Core/Sources/LibEntrypoint.cxx | 14 -- Public/SDK/System.Core/Sources/New+Delete.cxx | 42 ---- Public/SDK/System.Core/compile_flags.txt | 4 - 60 files changed, 1042 insertions(+), 967 deletions(-) create mode 100644 Public/Developer/.gitkeep create mode 100644 Public/Developer/System.Core/.gitkeep create mode 100644 Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s create mode 100644 Public/Developer/System.Core/ARM64/.gitkeep create mode 100644 Public/Developer/System.Core/Headers/Containers/ODF.hxx create mode 100644 Public/Developer/System.Core/Headers/Containers/XIFF.hxx create mode 100644 Public/Developer/System.Core/Headers/Defines.hxx create mode 100644 Public/Developer/System.Core/Headers/File.hxx create mode 100644 Public/Developer/System.Core/Headers/Heap.hxx create mode 100644 Public/Developer/System.Core/Headers/Hint.hxx create mode 100644 Public/Developer/System.Core/Headers/Thread.hxx create mode 100644 Public/Developer/System.Core/Headers/Window/Dialog.hxx create mode 100644 Public/Developer/System.Core/Headers/Window/Image.hxx create mode 100644 Public/Developer/System.Core/Headers/Window/Menu.hxx create mode 100644 Public/Developer/System.Core/Headers/Window/Rsrc.hxx create mode 100644 Public/Developer/System.Core/Headers/Window/TrueType.hxx create mode 100644 Public/Developer/System.Core/Headers/Window/Window.hxx create mode 100644 Public/Developer/System.Core/Makefile create mode 100644 Public/Developer/System.Core/RISCV/.gitkeep create mode 100644 Public/Developer/System.Core/ReadMe.md create mode 100644 Public/Developer/System.Core/Sources/Heap.cxx create mode 100644 Public/Developer/System.Core/Sources/LibEntrypoint.cxx create mode 100644 Public/Developer/System.Core/Sources/New+Delete.cxx create mode 100644 Public/Developer/System.Core/compile_flags.txt delete mode 100644 Public/Documentation/BUG_LIST.TXT delete mode 100644 Public/Documentation/DESIGN.DRAWIO delete mode 100644 Public/Documentation/SPECIFICATION.TXT create mode 100644 Public/Documentation/Specs.md delete mode 100644 Public/Documentation/TODO_LIST.TXT create mode 100644 Public/Documentation/Todo.md delete mode 100644 Public/Documentation/compile_flags.txt create mode 100644 Public/Documentation/kernel-design.drawio delete mode 100644 Public/SDK/.gitkeep delete mode 100644 Public/SDK/System.Core/.gitkeep delete mode 100644 Public/SDK/System.Core/AMD64/HCoreAssemblyRoutines.s delete mode 100644 Public/SDK/System.Core/ARM64/.gitkeep delete mode 100644 Public/SDK/System.Core/Headers/Defines.hxx delete mode 100644 Public/SDK/System.Core/Headers/File.hxx delete mode 100644 Public/SDK/System.Core/Headers/FormatManager/ODF.hxx delete mode 100644 Public/SDK/System.Core/Headers/FormatManager/XIFF.hxx delete mode 100644 Public/SDK/System.Core/Headers/Heap.hxx delete mode 100644 Public/SDK/System.Core/Headers/Hint.hxx delete mode 100644 Public/SDK/System.Core/Headers/Thread.hxx delete mode 100644 Public/SDK/System.Core/Headers/UIManager/Dialog.hxx delete mode 100644 Public/SDK/System.Core/Headers/UIManager/Image.hxx delete mode 100644 Public/SDK/System.Core/Headers/UIManager/Menu.hxx delete mode 100644 Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx delete mode 100644 Public/SDK/System.Core/Headers/UIManager/TrueType.hxx delete mode 100644 Public/SDK/System.Core/Headers/UIManager/Window.hxx delete mode 100644 Public/SDK/System.Core/Makefile delete mode 100644 Public/SDK/System.Core/RISCV/.gitkeep delete mode 100644 Public/SDK/System.Core/ReadMe.md delete mode 100644 Public/SDK/System.Core/Sources/Heap.cxx delete mode 100644 Public/SDK/System.Core/Sources/LibEntrypoint.cxx delete mode 100644 Public/SDK/System.Core/Sources/New+Delete.cxx delete mode 100644 Public/SDK/System.Core/compile_flags.txt diff --git a/Private/KernelKit/Framebuffer.hpp b/Private/KernelKit/Framebuffer.hpp index daf95ed0..0dfeacef 100644 --- a/Private/KernelKit/Framebuffer.hpp +++ b/Private/KernelKit/Framebuffer.hpp @@ -28,7 +28,8 @@ class FramebufferContext final { class Framebuffer final { public: - explicit Framebuffer(Ref &addr) : m_FrameBufferAddr(addr) {} + explicit Framebuffer(Ref &addr) + : m_FrameBufferAddr(addr) {} ~Framebuffer() {} Framebuffer &operator=(const Framebuffer &) = delete; @@ -37,12 +38,29 @@ class Framebuffer final { volatile UIntPtr *operator[](const UIntPtr &pos); operator bool(); - + const FramebufferColorKind &Color( const FramebufferColorKind &colour = FramebufferColorKind::INVALID); Ref &Leak(); + /// @brief Draws a rectangle inside the fb. + /// @param width + /// @param height + /// @param x + /// @param y + /// @param color + /// @return + Framebuffer &DrawRect(SizeT width, SizeT height, SizeT x, SizeT y, + UInt32 color); + + /// @brief Puts a pixel on the screen. + /// @param x where in X + /// @param y where in Y + /// @param color the color of it. + /// @return + Framebuffer &PutPixel(SizeT x, SizeT y, UInt32 color); + private: Ref m_FrameBufferAddr; FramebufferColorKind m_Colour; diff --git a/Private/ObjectKit/ObjectKit.hxx b/Private/ObjectKit/ObjectKit.hxx index 904e23cb..744f8a61 100644 --- a/Private/ObjectKit/ObjectKit.hxx +++ b/Private/ObjectKit/ObjectKit.hxx @@ -9,8 +9,7 @@ #include #include -#define kObjectGlobalNamespaceSystem "HCORE_ROOT\\" -#define kObjectGlobalNamespaceUser "HCORE_USER_ROOT\\" +#define kObjectGlobalNamespace ":\\" enum { kObjectTypeProcess, diff --git a/Private/Source/Framebuffer.cxx b/Private/Source/Framebuffer.cxx index 6ea2fa5b..9c964a3c 100644 --- a/Private/Source/Framebuffer.cxx +++ b/Private/Source/Framebuffer.cxx @@ -33,13 +33,14 @@ volatile UIntPtr *Framebuffer::operator[](const UIntPtr &pos) { /// @brief Boolean operator. Framebuffer::operator bool() { - return m_FrameBufferAddr.Leak()->m_Base != 0 && m_Colour != FramebufferColorKind::INVALID && - m_FrameBufferAddr.Leak()->m_Base != kBadPtr; + return m_FrameBufferAddr.Leak()->m_Base != 0 && + m_Colour != FramebufferColorKind::INVALID && + m_FrameBufferAddr.Leak()->m_Base != kBadPtr; } /// @brief Set color kind of framebuffer. -/// @param colour -/// @return +/// @param colour +/// @return const FramebufferColorKind &Framebuffer::Color( const FramebufferColorKind &colour) { if (m_Colour != FramebufferColorKind::INVALID && @@ -50,8 +51,29 @@ const FramebufferColorKind &Framebuffer::Color( return m_Colour; } -/// @brief Leak fraembuffer context. +/// @brief Leak framebuffer context. /// @return The reference of the framebuffer context. Ref &Framebuffer::Leak() { return this->m_FrameBufferAddr; } + +Framebuffer &Framebuffer::DrawRect(SizeT width, SizeT height, SizeT x, SizeT y, + UInt32 color) { + for (HCore::SizeT i = x; i < width + x; ++i) { + for (HCore::SizeT u = y; u < height + y; ++u) { + *(((volatile HCore::UInt32 *)(m_FrameBufferAddr.Leak()->m_Base + + 4 * m_FrameBufferAddr.Leak()->m_Bpp * i + + 4 * u))) = color; + } + } + + return *this; +} + +Framebuffer &Framebuffer::PutPixel(SizeT x, SizeT y, UInt32 color) { + *(((volatile HCore::UInt32 *)(m_FrameBufferAddr.Leak()->m_Base + + 4 * m_FrameBufferAddr.Leak()->m_Bpp * x + + 4 * y))) = color; + + return *this; +} \ No newline at end of file diff --git a/Private/Source/KernelHeap.cxx b/Private/Source/KernelHeap.cxx index a38156f4..39648102 100644 --- a/Private/Source/KernelHeap.cxx +++ b/Private/Source/KernelHeap.cxx @@ -75,8 +75,9 @@ Int32 ke_delete_ke_heap(VoidPtr heapPtr) { if (virtualAddress->hCRC32 != 0) { if (virtualAddress->hCRC32 != ke_calculate_crc32((Char *)virtualAddress->hAddress, - virtualAddress->hSizeAddress)) + virtualAddress->hSizeAddress)) { ke_stop(RUNTIME_CHECK_POINTER); + } } virtualAddress->hSizeAddress = 0UL; @@ -112,8 +113,8 @@ Boolean ke_is_valid_heap(VoidPtr heapPtr) { } /// @brief Protect the heap pointer with a CRC32. -/// @param heapPtr -/// @return +/// @param heapPtr +/// @return Boolean ke_protect_ke_heap(VoidPtr heapPtr) { if (heapPtr) { Detail::HeapInformationBlockPtr virtualAddress = @@ -121,7 +122,8 @@ Boolean ke_protect_ke_heap(VoidPtr heapPtr) { (UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock)); if (virtualAddress->hPresent && virtualAddress->hMagic == kHeapMagic) { - virtualAddress->hCRC32 = ke_calculate_crc32((Char*)heapPtr, virtualAddress->hSizeAddress); + virtualAddress->hCRC32 = + ke_calculate_crc32((Char *)heapPtr, virtualAddress->hSizeAddress); return true; } } diff --git a/Public/Developer/.gitkeep b/Public/Developer/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Public/Developer/System.Core/.gitkeep b/Public/Developer/System.Core/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s b/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s new file mode 100644 index 00000000..a61d6d1f --- /dev/null +++ b/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s @@ -0,0 +1,24 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +.section .text + +.globl HcGetInstanceObject +.globl __assert_chk_fail + +/* @brief Process object getter */ +/* @throws: ApptError: appartement error. */ +HcGetInstanceObject: + mov $0x10, %rcx /* sysGetProcessObject */ + int $0x21 + + /* rax gets saved and returned. */ + ret + +__assert_chk_fail: + mov $0x11, %rcx /* sysTerminateCurrentProcess */ + int $0x21 + + ret + diff --git a/Public/Developer/System.Core/ARM64/.gitkeep b/Public/Developer/System.Core/ARM64/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Public/Developer/System.Core/Headers/Containers/ODF.hxx b/Public/Developer/System.Core/Headers/Containers/ODF.hxx new file mode 100644 index 00000000..266726bf --- /dev/null +++ b/Public/Developer/System.Core/Headers/Containers/ODF.hxx @@ -0,0 +1,41 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#ifndef __ODF__ +#define __ODF__ + +#include + +/** + * @brief Open Document Format + * @file ODF.hxx + */ + +/// @brief four-character code for ODF. +#define kFourCCLength_ODF 4 + +/// @brief Document file header. +typedef struct ODFFileHeader { + CharacterTypeUTF8 f_Ident[kFourCCLength_ODF]; + + Int32Type f_DocumentKind; + Int32Type f_DocumentSize; + + Int64Type f_MetaForkOffset; + Int64Type f_DocumentForkOffset; + + CharacterTypeUTF8 f_Padding[4]; +} PACKED ODFFileHeader; + +/// @brief ODF Fork header +typedef struct ODFForkHeader { + CharacterTypeUTF8 f_MetadataName[255]; + + Int32Type f_MetadataKind; + Int32Type f_MetadataSize; + + CharacterTypeUTF8 f_Padding; +} PACKED ODFForkHeader; + +#endif // !__ODF__ \ No newline at end of file diff --git a/Public/Developer/System.Core/Headers/Containers/XIFF.hxx b/Public/Developer/System.Core/Headers/Containers/XIFF.hxx new file mode 100644 index 00000000..11d286e9 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Containers/XIFF.hxx @@ -0,0 +1,57 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#ifndef __XIFF__ +#define __XIFF__ + +/** --------------------------------------------------- + + * THIS FILE CONTAINS CODE FOR THE eXtended Information File Format. + * XIFF is used to make setup programs/audio/video files. + +------------------------------------------------------- */ + +#include + +/// @brief four-character code for XIFF. +#define kFourCCLength_XIFF 4 +#define kXIFFNameLength 255 + +#define kXIFFContainerVideo "XVFF" +#define kXIFFContainerAudio "XAFF" +#define kXIFFContainerInstaller "XNFF" +#define kXIFFContainerGeneric "XIFF" +#define kXIFFContainerBinary "XBFF" + +/*** + * @brief Generic XIFF header + * Used by XIFF based containers. + */ + +struct PACKED XiffHeader final { + ByteType f_Magic[kFourCCLength_XIFF]; // XIFF string (includes \0) + DWordType f_Size; // overall size of header (XiffHeader) in bytes + DWordType f_FormatType; // format type. generic + ByteType f_SpecificMag[kFourCCLength_XIFF]; // The sub header magic + DWordType f_SpecificSize; // length of the format data + DWordType f_SpecificFormatType; // format type. generic +}; + +typedef struct XiffHeader XiffHeader; + +/// @brief XIFF metadata header, either located in forks or in file directly. +/// @author Amlal EL Mahrouss +struct ML_PACKED XiffMetadataHeader final { + ByteType f_Name[kXIFFNameLength]; + DWordType f_Flags; + DWordType f_Type; + QWordType f_Offset; + SizeType f_Size; +}; + +#define kXIFFStringMetadata4CC "strp" +#define kXIFFFontMetadata4CC "font" +#define kXIFFResourceMetadata4CC "resx" + +#endif // ifndef __XIFF__ diff --git a/Public/Developer/System.Core/Headers/Defines.hxx b/Public/Developer/System.Core/Headers/Defines.hxx new file mode 100644 index 00000000..867dac76 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Defines.hxx @@ -0,0 +1,250 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#ifndef __cplusplus +#error This API is meant to be used with C++. +#endif + +#ifdef CA_MUST_PASS +#undef CA_MUST_PASS +#endif + +#ifdef _DEBUG +#define CA_MUST_PASS(e) { if (!e) { __assert_chk_fail() } } +#else +#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) +#endif + +#ifdef __cplusplus + +#define CA_EXTERN_C extern "C" + +#else + +#define CA_EXTERN_C extern + +#endif + +CA_EXTERN_C void __assert_chk_fail(void); + +#define CA_STDCALL __attribute__((stdcall)) +#define CA_CDECL __attribute__((cdecl)) +#define CA_MSCALL __attribute__((ms_abi)) + +#define PACKED __attribute__((packed)) + +#define CA_PASCAL CA_STDCALL + +typedef __UINT8_TYPE__ ByteType; +typedef __UINT16_TYPE__ WordType; +typedef __UINT32_TYPE__ DWordType; +typedef __UINT64_TYPE__ QWordType; +typedef __SIZE_TYPE__ SizeType; + +typedef char CharacterTypeUTF8; +typedef CharacterTypeUTF8* PtrCharacterType; + +typedef void* PtrVoidType; +typedef void VoidType; + +typedef __UINTPTR_TYPE__ UIntPtrType; +typedef __INTPTR_TYPE__ IntPtrType; +typedef __UINT64_TYPE__ UInt64Type; +typedef __INT64_TYPE__ Int64Type; +typedef __UINT32_TYPE__ UInt32Type; +typedef __INT32_TYPE__ Int32Type; + +typedef CharacterTypeUTF8 BooleanType; + +#define CA_COPY_DELETE(KLASS) \ + KLASS &operator=(const KLASS &) = delete; \ + KLASS(const KLASS &) = delete; + + +#define CA_COPY_DEFAULT(KLASS) \ + KLASS &operator=(const KLASS &) = default; \ + KLASS(const KLASS &) = default; + + +#define CA_MOVE_DELETE(KLASS) \ + KLASS &operator=(KLASS &&) = delete; \ + KLASS(KLASS &&) = delete; + + +#define CA_MOVE_DEFAULT(KLASS) \ + KLASS &operator=(KLASS &&) = default; \ + KLASS(KLASS &&) = default; + + +#define Yes 1 +#define No 0 + +#define CA_PTR * + +#define CA_FAR __far +#define CA_NEAR __near + +#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)e) + +#ifdef __x86_64__ +# define _M_AMD64 2 +#endif + +#ifdef __aarch64__ +# define _M_AARCH64 3 +#endif + +#ifdef __powerpc64__ +# define _M_PPC64 4 +#endif + +#ifdef __64x0__ +# define _M_64000 5 +#endif + +#ifdef __riscv__ +# define _M_RISCV 6 +#endif + +#define CA_STATIC static +#define CA_INLINE inline +#define CA_CONST const + +#ifdef __cplusplus +#define CA_CONSTEXPR constexpr +#else +#define CA_CONSTEXPR +#endif // __cplusplus + +enum HcProcessCall { + kProcessCallAllocPtr = 1, + kProcessCallFreePtr, + kProcessCallSizePtr, + kProcessCallCheckPtr, + kProcessCallAllocStack, + /// @brief Open a specific handle (can be used as sel to call methods related to it.) + kProcessCallOpenHandle, + kProcessCallCloseHandle, + /// @brief Number of process calls. + kProcessCallsCount = 7, +}; + +#include + +class SystemException { + public: + explicit SystemException() = default; + virtual ~SystemException() = default; + + public: + CA_COPY_DEFAULT(SystemException); + + public: + virtual const char *Name() = 0; + virtual const char *Reason() = 0; + +}; + +/// @brief Object exception +/// Throws when the object isn't found. +class ObjectNotFoundException : public SystemException { + public: + explicit ObjectNotFoundException() = default; + virtual ~ObjectNotFoundException() = default; + + public: + CA_COPY_DEFAULT(ObjectNotFoundException); + + public: + const char *Name() override { return "ObjectNotFoundException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{ + "System.Core: ObjectNotFoundException: Catastrophic failure!"}; +}; + +/// @brief pointer exception +/// Throws when the object isn't found. +class PointerException : public SystemException { + public: + explicit PointerException() = default; + virtual ~PointerException() = default; + + public: + CA_COPY_DEFAULT(PointerException); + + public: + const char *Name() override { return "PointerException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{ + "System.Core: PointerException: Catastrophic failure!"}; +}; + +/// @brief pointer exception +/// Throws when the object isn't found. +class NullPointerException : public SystemException { + public: + explicit NullPointerException() = default; + virtual ~NullPointerException() = default; + + public: + CA_COPY_DEFAULT(NullPointerException); + + public: + const char *Name() override { return "NullPointerException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{ + "System.Core: NullPointerException: Catastrophic failure!"}; +}; + +#define kObjectGlobalNamespaceSystem "HCORE_ROOT\\" +#define kObjectGlobalNamespaceUser "HCORE_USER_ROOT\\" + +enum { + kObjectTypeProcess, + kObjectTypeFile, + kObjectTypeDevice, + kObjectTypeNetwork, + kObjectTypeInvalid, + KObjectTypeUserDefined = 0xCF, + kObjectTypeCount = 5, +}; + +/** + * @brief GUID type, something you can also find in CFKit. + * @author AMlal El Mahrouss + */ +typedef struct GUID final { + DWordType Data1; + WordType Data2; + WordType Data3; + ByteType Data4[8]; +} GUIDType, *PtrGUIDType; + +/// \brief Object handle. +/// \author Amlal El Mahrouss +typedef struct Object final { + CharacterTypeUTF8 ObjectName[255]; + DWordType ObjectType; + CharacterTypeUTF8 ObjectNamespace[255]; + + VoidType(*Release)(struct Object* Self); + IntPtrType(*Invoke)(struct Object* Self, DWordType Sel, ...); + VoidType(*Query)(struct Object* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); +} Object, *ObjectPtr; + +#define object_cast reinterpret_cast + +CA_EXTERN_C ObjectPtr HcGetInstanceObject(void); + +CA_INLINE ObjectPtr kApplicationObject; diff --git a/Public/Developer/System.Core/Headers/File.hxx b/Public/Developer/System.Core/Headers/File.hxx new file mode 100644 index 00000000..06c2a22e --- /dev/null +++ b/Public/Developer/System.Core/Headers/File.hxx @@ -0,0 +1,105 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#ifndef __FILE_API__ +#define __FILE_API__ + +#include + +namespace System { +class FileInterface; +class DirectoryInterface; + +typedef IntPtrType SymlinkType; +typedef IntPtrType FileType; +typedef IntPtrType DirectoryType; +typedef IntPtrType FSRef; + +enum { + kErrorNoSuchPath = -44, + kErrorNotAFile = -45, + kErrorNotADirectory = -46, + kErrorDirectory = -47, + kErrorBrokenSymlink = -48, +}; + +/// @brief System file interface + +class FileInterface final { + public: + explicit FileInterface(const char *path) { + mHandle = kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle, + 0, path); + } + + ~FileInterface() { + kApplicationObject->Invoke(kApplicationObject, kProcessCallCloseHandle, 0, + mHandle); + } + + public: + CA_COPY_DEFAULT(FileInterface); + + public: + PtrVoidType Read(UIntPtrType off, SizeType sz) { + return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, 2, + off, sz); + } + PtrVoidType Read(SizeType sz) { + return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, 3, + sz); + } + + void Write(PtrVoidType buf, UIntPtrType off, SizeType sz) { + kApplicationObject->Invoke(kApplicationObject, mHandle, 4, buf, off, sz); + } + void Write(PtrVoidType buf, SizeType sz) { + kApplicationObject->Invoke(kApplicationObject, mHandle, 5, buf, sz); + } + + void Seek(UIntPtrType off) { + kApplicationObject->Invoke(kApplicationObject, mHandle, 5); + } + void Rewind() { kApplicationObject->Invoke(kApplicationObject, mHandle, 6); } + + public: + const char *MIME(); + void MIME(const char *mime); + + private: + FileType mHandle; +}; + +typedef FileInterface *FilePtr; + +/// @brief file exception +/// Throws when the file isn't found or invalid. +class FileException : public SystemException { + public: + explicit FileException() = default; + virtual ~FileException() = default; + + public: + CA_COPY_DEFAULT(FileException); + + public: + const char *Name() override { return "FileException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{"System.Core: FileException: Catastrophic failure!"}; +}; + +inline IntPtrType MakeSymlink(const char *from, const char *outputWhere) { + CA_MUST_PASS(from); + CA_MUST_PASS(outputWhere); + + return kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle, 1, + from); +} +} // namespace System + +#endif // ifndef __FILE_API__ diff --git a/Public/Developer/System.Core/Headers/Heap.hxx b/Public/Developer/System.Core/Headers/Heap.hxx new file mode 100644 index 00000000..c134ca4e --- /dev/null +++ b/Public/Developer/System.Core/Headers/Heap.hxx @@ -0,0 +1,64 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include + +namespace System { +class HeapException; +class HeapInterface; + +typedef PtrVoidType PtrHeapType; + +enum { + kHeapExpandable = 2, + kHeapNoExecute = 4, + kHeapShared = 6, + kHeapReadOnly = 8, + kHeapNoFlags = 0 +}; + +class HeapInterface final { + private: + explicit HeapInterface(); + + public: + ~HeapInterface(); + + public: + CA_COPY_DEFAULT(HeapInterface); + + public: + static HeapInterface *Shared() noexcept; + + public: + void Delete(PtrHeapType me) noexcept; + SizeType Size(PtrHeapType me) noexcept; + PtrHeapType New(const SizeType &sz, + const DWordType flags = kHeapNoFlags); +}; + + +/// @brief heap exception +/// Throws when the heap pointer isn't found or invalid. +class HeapException : public SystemException { + public: + explicit HeapException() = default; + virtual ~HeapException() = default; + + public: + CA_COPY_DEFAULT(HeapException); + + public: + const char *Name() override { return "HeapException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{"System.Core: HeapException: Catastrophic failure!"}; +}; + +} // namespace System diff --git a/Public/Developer/System.Core/Headers/Hint.hxx b/Public/Developer/System.Core/Headers/Hint.hxx new file mode 100644 index 00000000..86faf455 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Hint.hxx @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#define _Input +#define _Output + +#define _Optional + +#define _StrictCheckInput +#define _StrictCheckOutput + +#define _InOut +#define _StrictInOut diff --git a/Public/Developer/System.Core/Headers/Thread.hxx b/Public/Developer/System.Core/Headers/Thread.hxx new file mode 100644 index 00000000..df803860 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Thread.hxx @@ -0,0 +1,23 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +// +// Created by Amlal on 3/18/24 +// + +#ifndef __THREAD_API__ +#define __THREAD_API__ + +#include + +/// @brief Thread Information Block, which holds information about the running +/// thread. +typedef QWordType ThreadRef; + +/// @brief Main application thread. +CA_EXTERN_C ThreadRef kMainThread; + +#endif // __THREAD_API__ diff --git a/Public/Developer/System.Core/Headers/Window/Dialog.hxx b/Public/Developer/System.Core/Headers/Window/Dialog.hxx new file mode 100644 index 00000000..3e445532 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Window/Dialog.hxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include diff --git a/Public/Developer/System.Core/Headers/Window/Image.hxx b/Public/Developer/System.Core/Headers/Window/Image.hxx new file mode 100644 index 00000000..2a02b434 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Window/Image.hxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + diff --git a/Public/Developer/System.Core/Headers/Window/Menu.hxx b/Public/Developer/System.Core/Headers/Window/Menu.hxx new file mode 100644 index 00000000..2a02b434 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Window/Menu.hxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + diff --git a/Public/Developer/System.Core/Headers/Window/Rsrc.hxx b/Public/Developer/System.Core/Headers/Window/Rsrc.hxx new file mode 100644 index 00000000..2a02b434 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Window/Rsrc.hxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + diff --git a/Public/Developer/System.Core/Headers/Window/TrueType.hxx b/Public/Developer/System.Core/Headers/Window/TrueType.hxx new file mode 100644 index 00000000..62ed1255 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Window/TrueType.hxx @@ -0,0 +1,7 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once diff --git a/Public/Developer/System.Core/Headers/Window/Window.hxx b/Public/Developer/System.Core/Headers/Window/Window.hxx new file mode 100644 index 00000000..1a8c6cf6 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Window/Window.hxx @@ -0,0 +1,38 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include + +/// @file Window.hxx +/// @brief Tracker window manager. +/// @author Amlal El Mahrouss. + +typedef float PositionType; + +/// @brief A point, can represent the size, position of a window. +typedef struct _Point { + PositionType X, Y; +} Point; + +/// @brief Tracker Graphics port. +typedef struct _GraphicsPort { + WordType windowPort; + WordType windowKind; + BooleanType windowVisible; + BooleanType windowMaximized; + BooleanType windowMinimized; + BooleanType windowMoving; + BooleanType windowDisableClose; + BooleanType windowDisableMinimize; + Point windowPosition; + Point windowSize; + BooleanType windowInvalidate; + DWordType windowClearColor; + WordType menuPort; + WordType parentPort; +} GraphicsPort; diff --git a/Public/Developer/System.Core/Makefile b/Public/Developer/System.Core/Makefile new file mode 100644 index 00000000..28ce0bea --- /dev/null +++ b/Public/Developer/System.Core/Makefile @@ -0,0 +1,20 @@ +################################################## +# (C) Mahrouss Logic, 2024, all rights reserved. +# This is the System.Graphics Makefile. +################################################## + +CC=x86_64-w64-mingw32-g++ +CCFLAGS=-shared -ffreestanding -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17 +OUTPUT=System.Core.lib + +.PHONY: build-core-amd64 +build-core-amd64: + $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard Sources/*.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT) + +.PHONY: all +all: build-core + @echo "[System.Core.dll] Build done." + +.PHONY: clean +clean: + rm -f *.o diff --git a/Public/Developer/System.Core/RISCV/.gitkeep b/Public/Developer/System.Core/RISCV/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Public/Developer/System.Core/ReadMe.md b/Public/Developer/System.Core/ReadMe.md new file mode 100644 index 00000000..3867dd3d --- /dev/null +++ b/Public/Developer/System.Core/ReadMe.md @@ -0,0 +1,8 @@ +# System.Core +## Core System API. + +Currently contains: +- Heap API. +- File API. +- Data types. +- Threading API. \ No newline at end of file diff --git a/Public/Developer/System.Core/Sources/Heap.cxx b/Public/Developer/System.Core/Sources/Heap.cxx new file mode 100644 index 00000000..18106f41 --- /dev/null +++ b/Public/Developer/System.Core/Sources/Heap.cxx @@ -0,0 +1,83 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include + +/// @brief Allocate from the user's heap. +/// @param refObj Process object. +/// @param sz size of object. +/// @param flags flags. +/// @return +CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, + DWordType flags) { + CA_MUST_PASS(sz); + CA_MUST_PASS(flags); + + return (PtrVoidType)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags); +} + +/// @brief Free pointer from the user's heap. +/// @param refObj Process object. +/// @param ptr the pointer to free. +CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr) { + CA_MUST_PASS(ptr); + CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr)); +} + +/// @brief Get pointer size. +/// @param refObj Process object. +/// @param ptr the pointer to find. +/// @return the size. +CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr) { + CA_MUST_PASS(ptr); + return refObj->Invoke(refObj, kProcessCallSizePtr, ptr); +} + +/// @brief Check if the pointer exists. +/// @param refObj Process object. +/// @param ptr the pointer to check. +/// @return if it exists +CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr) { + CA_MUST_PASS(ptr); + return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr); +} + +using namespace System; + +/// @brief Shared instance of the heap. +/// @return +HeapInterface* HeapInterface::Shared() noexcept { + static HeapInterface* heap = nullptr; + + if (!heap) { + heap = new HeapInterface(); + } + + return heap; +} + +HeapInterface::HeapInterface() { + CA_MUST_PASS(HcProcessHeapExists(kApplicationObject, (PtrVoidType)this)); +} + +HeapInterface::~HeapInterface() { delete this; } + +void HeapInterface::Delete(PtrHeapType me) noexcept { + CA_MUST_PASS(me); + HcFreeProcessHeap(kApplicationObject, me); +} + +SizeType HeapInterface::Size(PtrHeapType me) noexcept { + CA_MUST_PASS(me); + return HcProcessHeapSize(kApplicationObject, me); +} + +PtrHeapType HeapInterface::New(const SizeType& sz, const DWordType flags) { + SizeType _sz = sz; + if (!_sz) ++_sz; + + return HcAllocateProcessHeap(kApplicationObject, _sz, flags); +} diff --git a/Public/Developer/System.Core/Sources/LibEntrypoint.cxx b/Public/Developer/System.Core/Sources/LibEntrypoint.cxx new file mode 100644 index 00000000..b874ef55 --- /dev/null +++ b/Public/Developer/System.Core/Sources/LibEntrypoint.cxx @@ -0,0 +1,14 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#include + +/// @brief Inits the DLL. +/// @return if it was succesful or not. +DWordType __DllMain(VoidType) { + kApplicationObject = HcGetInstanceObject(); + CA_MUST_PASS(kApplicationObject); + + return 0; +} \ No newline at end of file diff --git a/Public/Developer/System.Core/Sources/New+Delete.cxx b/Public/Developer/System.Core/Sources/New+Delete.cxx new file mode 100644 index 00000000..98674a73 --- /dev/null +++ b/Public/Developer/System.Core/Sources/New+Delete.cxx @@ -0,0 +1,55 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include +#include + +#define kAllocationTypes 2 + +enum HcAllocationKind { + kStandardAllocation = 0xC, + kArrayAllocation = 0xD, +}; + +CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, + DWordType flags); +CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr); +CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr); +CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr); + +typedef SizeType size_t; + +void* operator new[](size_t sz) { + if (sz == 0) ++sz; + + return HcAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation); +} + +void* operator new(size_t sz) { + if (sz == 0) ++sz; + + return HcAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation); +} + +void operator delete[](void* ptr) { + if (ptr == nullptr) return; + + HcFreeProcessHeap(kApplicationObject, ptr); +} + +void operator delete(void* ptr) { + if (ptr == nullptr) return; + + HcFreeProcessHeap(kApplicationObject, ptr); +} + +void operator delete(void* ptr, size_t sz) { + if (ptr == nullptr) return; + + (void)sz; + + HcFreeProcessHeap(kApplicationObject, ptr); +} diff --git a/Public/Developer/System.Core/compile_flags.txt b/Public/Developer/System.Core/compile_flags.txt new file mode 100644 index 00000000..6e721e73 --- /dev/null +++ b/Public/Developer/System.Core/compile_flags.txt @@ -0,0 +1,4 @@ +-I./ +-I../ +-I../../../Private +-std=c++20 diff --git a/Public/Documentation/BUG_LIST.TXT b/Public/Documentation/BUG_LIST.TXT deleted file mode 100644 index 6075a6ac..00000000 --- a/Public/Documentation/BUG_LIST.TXT +++ /dev/null @@ -1 +0,0 @@ -- PS/2 Mouse doesn't raise interrupt on qemu q35, pc machines. [WontFix] \ No newline at end of file diff --git a/Public/Documentation/DESIGN.DRAWIO b/Public/Documentation/DESIGN.DRAWIO deleted file mode 100644 index 759a7df9..00000000 --- a/Public/Documentation/DESIGN.DRAWIO +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Public/Documentation/SPECIFICATION.TXT b/Public/Documentation/SPECIFICATION.TXT deleted file mode 100644 index ce6c9893..00000000 --- a/Public/Documentation/SPECIFICATION.TXT +++ /dev/null @@ -1,53 +0,0 @@ -=================================== -0: General Information -=================================== - -- ABI and Format: PEF/PE32+. -- Kernel architecture: Microkernel. -- Language: C++/(Assembly (AMD64, X64000, X86S, ARM64)) - -=================================== -1: The NewKernel -=================================== - -- Drive/Device Abstraction. -- SMP, Preemptive Multi Threading. -- Separation of Files/Devices. -- Networking. -- Hardware Abstraction Layer. -- Native Filesystem support (NewFS, FAT32 and HCFS). -- Program Loaders. -- Thread Local Storage. -- Semaphore, Locks, Timers. -- Canary mechanisms. -- Dynamic Libraries. -- Cross Platform. -- Permission Selectors. - -=================================== -2: The Filesystem -=================================== - -- Catalog based with forks. -- Large storage support. -- Long file names. -- UNIX path style. - -================================== -3: Common naming conventions: -================================== - -- Kernel -> ke_init_x -- RunTime -> rt_copy_mem -- Hal -> hal_foo_bar - -=================================== -4: The NewBoot -=================================== - -- Capable of booting from a network drive. -- Loads a PE file which is the kernel -- Sanity checks, based on the number of sections. -- Handover compliant. -- Does check for a valid invalid of HCore (useful in the case of recovering) - diff --git a/Public/Documentation/Specs.md b/Public/Documentation/Specs.md new file mode 100644 index 00000000..1d1e2d3a --- /dev/null +++ b/Public/Documentation/Specs.md @@ -0,0 +1,53 @@ +=================================== +# 0: General Information +=================================== + +- ABI and Format: PEF/PE32+. +- Kernel architecture: Microkernel. +- Language: C++/(Assembly (AMD64, X64000, X86S, ARM64)) + +=================================== +# 1: The NewKernel +=================================== + +- Drive/Device Abstraction. +- SMP, Preemptive Multi Threading. +- Separation of Files/Devices. +- Networking. +- Hardware Abstraction Layer. +- Native Filesystem support (NewFS, FAT32 and HCFS). +- Program Loaders. +- Thread Local Storage. +- Semaphore, Locks, Timers. +- Canary mechanisms. +- Dynamic Libraries. +- Cross Platform. +- Permission Selectors. + +=================================== +# 2: The Filesystem +=================================== + +- Catalog based with forks. +- Large storage support. +- Long file names. +- UNIX path style. + +================================== +# 3: Common naming conventions: +================================== + +- Kernel -> ke_init_x +- RunTime -> rt_copy_mem +- Hal -> hal_foo_bar + +=================================== +# 4: The NewBoot +=================================== + +- Capable of booting from a network drive. +- Loads a PE file which is the kernel +- Sanity checks, based on the number of sections. +- Handover compliant. +- Does check for a valid invalid of HCore (useful in the case of recovering) + diff --git a/Public/Documentation/TODO_LIST.TXT b/Public/Documentation/TODO_LIST.TXT deleted file mode 100644 index b7fc4926..00000000 --- a/Public/Documentation/TODO_LIST.TXT +++ /dev/null @@ -1,25 +0,0 @@ -- We need preemptive multi-threading. [ X ] -- We then need sync primitives. [ X ] -- We also need a system library for the OS. [ X ] -- We need a bootloader for AMD64 [ X ] - - Implement Boot Services [ X ] - - Design Handover [ X ] - - Load kernel into memory [ X ] - - Fix bug in kernel loader, which causes a 06 #UD. [ X ] - - Load Kernel [ X ] - - Add IDT [ X ] - - AHCI driver [ WiP ] -- Context switch x87/SSE/AVX registers [ X ] -- Framebuffer [ X ] -- AHCI support [ ] -- HCore API and HCore Forms. [ ] -- Make installer form class [ ] - -Status: - -NewBoot.exe: Working. -NewKernel.exe: New Filesystem in progress. - -Prioritize: -NewBoot.exe: Protocol and API. -NewKernel.exe: Complying to specs. diff --git a/Public/Documentation/Todo.md b/Public/Documentation/Todo.md new file mode 100644 index 00000000..1e625233 --- /dev/null +++ b/Public/Documentation/Todo.md @@ -0,0 +1,21 @@ +- We need preemptive multi-threading. [ X ] +- We then need sync primitives. [ X ] +- We also need a system library for the OS. [ X ] +- We need a bootloader for AMD64 [ X ] + - Implement Boot Services [ X ] + - Design Handover [ X ] + - Load kernel into memory [ X ] + - Fix bug in kernel loader, which causes a 06 #UD. [ X ] + - Load Kernel [ X ] + - Add IDT [ X ] + - AHCI driver [ WiP ] +- Context switch x87/SSE/AVX registers [ X ] +- Framebuffer [ X ] +- AHCI support [ ] +- Make installer [ ] + +Status: + +NewBoot.exe: Need to boot from EPM partition. +NewKernel.exe: New Filesystem in progress. + diff --git a/Public/Documentation/compile_flags.txt b/Public/Documentation/compile_flags.txt deleted file mode 100644 index 21296223..00000000 --- a/Public/Documentation/compile_flags.txt +++ /dev/null @@ -1,5 +0,0 @@ --nostdlib --ffreestanding --std=c++20 --I./SDK/ --I../Private diff --git a/Public/Documentation/kernel-design.drawio b/Public/Documentation/kernel-design.drawio new file mode 100644 index 00000000..759a7df9 --- /dev/null +++ b/Public/Documentation/kernel-design.drawio @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Public/SDK/.gitkeep b/Public/SDK/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Public/SDK/System.Core/.gitkeep b/Public/SDK/System.Core/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Public/SDK/System.Core/AMD64/HCoreAssemblyRoutines.s b/Public/SDK/System.Core/AMD64/HCoreAssemblyRoutines.s deleted file mode 100644 index a61d6d1f..00000000 --- a/Public/SDK/System.Core/AMD64/HCoreAssemblyRoutines.s +++ /dev/null @@ -1,24 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -.section .text - -.globl HcGetInstanceObject -.globl __assert_chk_fail - -/* @brief Process object getter */ -/* @throws: ApptError: appartement error. */ -HcGetInstanceObject: - mov $0x10, %rcx /* sysGetProcessObject */ - int $0x21 - - /* rax gets saved and returned. */ - ret - -__assert_chk_fail: - mov $0x11, %rcx /* sysTerminateCurrentProcess */ - int $0x21 - - ret - diff --git a/Public/SDK/System.Core/ARM64/.gitkeep b/Public/SDK/System.Core/ARM64/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Public/SDK/System.Core/Headers/Defines.hxx b/Public/SDK/System.Core/Headers/Defines.hxx deleted file mode 100644 index 867dac76..00000000 --- a/Public/SDK/System.Core/Headers/Defines.hxx +++ /dev/null @@ -1,250 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#ifndef __cplusplus -#error This API is meant to be used with C++. -#endif - -#ifdef CA_MUST_PASS -#undef CA_MUST_PASS -#endif - -#ifdef _DEBUG -#define CA_MUST_PASS(e) { if (!e) { __assert_chk_fail() } } -#else -#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) -#endif - -#ifdef __cplusplus - -#define CA_EXTERN_C extern "C" - -#else - -#define CA_EXTERN_C extern - -#endif - -CA_EXTERN_C void __assert_chk_fail(void); - -#define CA_STDCALL __attribute__((stdcall)) -#define CA_CDECL __attribute__((cdecl)) -#define CA_MSCALL __attribute__((ms_abi)) - -#define PACKED __attribute__((packed)) - -#define CA_PASCAL CA_STDCALL - -typedef __UINT8_TYPE__ ByteType; -typedef __UINT16_TYPE__ WordType; -typedef __UINT32_TYPE__ DWordType; -typedef __UINT64_TYPE__ QWordType; -typedef __SIZE_TYPE__ SizeType; - -typedef char CharacterTypeUTF8; -typedef CharacterTypeUTF8* PtrCharacterType; - -typedef void* PtrVoidType; -typedef void VoidType; - -typedef __UINTPTR_TYPE__ UIntPtrType; -typedef __INTPTR_TYPE__ IntPtrType; -typedef __UINT64_TYPE__ UInt64Type; -typedef __INT64_TYPE__ Int64Type; -typedef __UINT32_TYPE__ UInt32Type; -typedef __INT32_TYPE__ Int32Type; - -typedef CharacterTypeUTF8 BooleanType; - -#define CA_COPY_DELETE(KLASS) \ - KLASS &operator=(const KLASS &) = delete; \ - KLASS(const KLASS &) = delete; - - -#define CA_COPY_DEFAULT(KLASS) \ - KLASS &operator=(const KLASS &) = default; \ - KLASS(const KLASS &) = default; - - -#define CA_MOVE_DELETE(KLASS) \ - KLASS &operator=(KLASS &&) = delete; \ - KLASS(KLASS &&) = delete; - - -#define CA_MOVE_DEFAULT(KLASS) \ - KLASS &operator=(KLASS &&) = default; \ - KLASS(KLASS &&) = default; - - -#define Yes 1 -#define No 0 - -#define CA_PTR * - -#define CA_FAR __far -#define CA_NEAR __near - -#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)e) - -#ifdef __x86_64__ -# define _M_AMD64 2 -#endif - -#ifdef __aarch64__ -# define _M_AARCH64 3 -#endif - -#ifdef __powerpc64__ -# define _M_PPC64 4 -#endif - -#ifdef __64x0__ -# define _M_64000 5 -#endif - -#ifdef __riscv__ -# define _M_RISCV 6 -#endif - -#define CA_STATIC static -#define CA_INLINE inline -#define CA_CONST const - -#ifdef __cplusplus -#define CA_CONSTEXPR constexpr -#else -#define CA_CONSTEXPR -#endif // __cplusplus - -enum HcProcessCall { - kProcessCallAllocPtr = 1, - kProcessCallFreePtr, - kProcessCallSizePtr, - kProcessCallCheckPtr, - kProcessCallAllocStack, - /// @brief Open a specific handle (can be used as sel to call methods related to it.) - kProcessCallOpenHandle, - kProcessCallCloseHandle, - /// @brief Number of process calls. - kProcessCallsCount = 7, -}; - -#include - -class SystemException { - public: - explicit SystemException() = default; - virtual ~SystemException() = default; - - public: - CA_COPY_DEFAULT(SystemException); - - public: - virtual const char *Name() = 0; - virtual const char *Reason() = 0; - -}; - -/// @brief Object exception -/// Throws when the object isn't found. -class ObjectNotFoundException : public SystemException { - public: - explicit ObjectNotFoundException() = default; - virtual ~ObjectNotFoundException() = default; - - public: - CA_COPY_DEFAULT(ObjectNotFoundException); - - public: - const char *Name() override { return "ObjectNotFoundException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: ObjectNotFoundException: Catastrophic failure!"}; -}; - -/// @brief pointer exception -/// Throws when the object isn't found. -class PointerException : public SystemException { - public: - explicit PointerException() = default; - virtual ~PointerException() = default; - - public: - CA_COPY_DEFAULT(PointerException); - - public: - const char *Name() override { return "PointerException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: PointerException: Catastrophic failure!"}; -}; - -/// @brief pointer exception -/// Throws when the object isn't found. -class NullPointerException : public SystemException { - public: - explicit NullPointerException() = default; - virtual ~NullPointerException() = default; - - public: - CA_COPY_DEFAULT(NullPointerException); - - public: - const char *Name() override { return "NullPointerException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: NullPointerException: Catastrophic failure!"}; -}; - -#define kObjectGlobalNamespaceSystem "HCORE_ROOT\\" -#define kObjectGlobalNamespaceUser "HCORE_USER_ROOT\\" - -enum { - kObjectTypeProcess, - kObjectTypeFile, - kObjectTypeDevice, - kObjectTypeNetwork, - kObjectTypeInvalid, - KObjectTypeUserDefined = 0xCF, - kObjectTypeCount = 5, -}; - -/** - * @brief GUID type, something you can also find in CFKit. - * @author AMlal El Mahrouss - */ -typedef struct GUID final { - DWordType Data1; - WordType Data2; - WordType Data3; - ByteType Data4[8]; -} GUIDType, *PtrGUIDType; - -/// \brief Object handle. -/// \author Amlal El Mahrouss -typedef struct Object final { - CharacterTypeUTF8 ObjectName[255]; - DWordType ObjectType; - CharacterTypeUTF8 ObjectNamespace[255]; - - VoidType(*Release)(struct Object* Self); - IntPtrType(*Invoke)(struct Object* Self, DWordType Sel, ...); - VoidType(*Query)(struct Object* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); -} Object, *ObjectPtr; - -#define object_cast reinterpret_cast - -CA_EXTERN_C ObjectPtr HcGetInstanceObject(void); - -CA_INLINE ObjectPtr kApplicationObject; diff --git a/Public/SDK/System.Core/Headers/File.hxx b/Public/SDK/System.Core/Headers/File.hxx deleted file mode 100644 index 60c37cc6..00000000 --- a/Public/SDK/System.Core/Headers/File.hxx +++ /dev/null @@ -1,103 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#ifndef __FILE_API__ -#define __FILE_API__ - -#include - -namespace System { -class FileInterface; -class DirectoryInterface; - -typedef IntPtrType SymlinkType; -typedef IntPtrType FileType; -typedef IntPtrType DirectoryType; - -enum { - kErrorNoSuchPath = -44, - kErrorNotAFile = -45, - kErrorNotADirectory = -46, - kErrorDirectory = -47, - kErrorBrokenSymlink = -48, -}; - -/// @brief System file interface -class FileInterface final { - public: - explicit FileInterface(const char *path) { - mHandle = kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle, - 0, path); - } - - ~FileInterface() { - kApplicationObject->Invoke(kApplicationObject, kProcessCallCloseHandle, 0, - mHandle); - } - - public: - CA_COPY_DEFAULT(FileInterface); - - public: - PtrVoidType Read(UIntPtrType off, SizeType sz) { - return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, 2, - off, sz); - } - PtrVoidType Read(SizeType sz) { - return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, 3, - sz); - } - - void Write(PtrVoidType buf, UIntPtrType off, SizeType sz) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 4, buf, off, sz); - } - void Write(PtrVoidType buf, SizeType sz) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 5, buf, sz); - } - - void Seek(UIntPtrType off) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 5); - } - void Rewind() { kApplicationObject->Invoke(kApplicationObject, mHandle, 6); } - - public: - const char *MIME(); - void MIME(const char *mime); - - private: - FileType mHandle; -}; - -typedef FileInterface *FilePtr; - -/// @brief file exception -/// Throws when the file isn't found or invalid. -class FileException : public SystemException { - public: - explicit FileException() = default; - virtual ~FileException() = default; - - public: - CA_COPY_DEFAULT(FileException); - - public: - const char *Name() override { return "FileException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{"System.Core: FileException: Catastrophic failure!"}; -}; - -inline IntPtrType MakeSymlink(const char *from, const char *outputWhere) { - CA_MUST_PASS(from); - CA_MUST_PASS(outputWhere); - - return kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle, 1, - from); -} -} // namespace System - -#endif // ifndef __FILE_API__ diff --git a/Public/SDK/System.Core/Headers/FormatManager/ODF.hxx b/Public/SDK/System.Core/Headers/FormatManager/ODF.hxx deleted file mode 100644 index 266726bf..00000000 --- a/Public/SDK/System.Core/Headers/FormatManager/ODF.hxx +++ /dev/null @@ -1,41 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#ifndef __ODF__ -#define __ODF__ - -#include - -/** - * @brief Open Document Format - * @file ODF.hxx - */ - -/// @brief four-character code for ODF. -#define kFourCCLength_ODF 4 - -/// @brief Document file header. -typedef struct ODFFileHeader { - CharacterTypeUTF8 f_Ident[kFourCCLength_ODF]; - - Int32Type f_DocumentKind; - Int32Type f_DocumentSize; - - Int64Type f_MetaForkOffset; - Int64Type f_DocumentForkOffset; - - CharacterTypeUTF8 f_Padding[4]; -} PACKED ODFFileHeader; - -/// @brief ODF Fork header -typedef struct ODFForkHeader { - CharacterTypeUTF8 f_MetadataName[255]; - - Int32Type f_MetadataKind; - Int32Type f_MetadataSize; - - CharacterTypeUTF8 f_Padding; -} PACKED ODFForkHeader; - -#endif // !__ODF__ \ No newline at end of file diff --git a/Public/SDK/System.Core/Headers/FormatManager/XIFF.hxx b/Public/SDK/System.Core/Headers/FormatManager/XIFF.hxx deleted file mode 100644 index 2531abce..00000000 --- a/Public/SDK/System.Core/Headers/FormatManager/XIFF.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#ifndef __XIFF__ -#define __XIFF__ - -/** --------------------------------------------------- - - * THIS FILE CONTAINS CODE FOR THE eXtended Information File Format. - * XIFF is used to make setup programs/audio/video files. - -------------------------------------------------------- */ - -#include - -/// @brief four-character code for XIFF. -#define kFourCCLength_XIFF 4 - -#define kXIFFContainerVideo "XVFF" -#define kXIFFContainerAudio "XAFF" -#define kXIFFContainerInstaller "XNFF" -#define kXIFFContainerGeneric "XIFF" -#define kXIFFContainerBinary "XBFF" - -/*** - * @brief Generic XIFF header - * Used by XIFF based containers. - */ - -struct PACKED XiffHeader final { - ByteType f_Magic[kFourCCLength_XIFF]; // XIFF string (includes \0) - DWordType f_Size; // overall size of header (XiffHeader) in bytes - DWordType f_FormatType; // format type. generic - ByteType f_SpecificMag[kFourCCLength_XIFF]; // The sub header magic - DWordType f_SpecificSize; // length of the format data - DWordType f_SpecificFormatType; // format type. generic -}; - -typedef struct XiffHeader XiffHeader; - -#endif // ifndef __XIFF__ diff --git a/Public/SDK/System.Core/Headers/Heap.hxx b/Public/SDK/System.Core/Headers/Heap.hxx deleted file mode 100644 index 06f5d38e..00000000 --- a/Public/SDK/System.Core/Headers/Heap.hxx +++ /dev/null @@ -1,77 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include - -namespace System { -class HeapException; -class HeapInterface; - -typedef PtrVoidType PtrHeapType; - -enum { - kHeapExpandable = 2, - kHeapNoExecute = 4, - kHeapShared = 6, - kHeapReadOnly = 8, - kHeapNoFlags = 0 -}; - -class HeapInterface final { - private: - explicit HeapInterface(); - - public: - ~HeapInterface(); - - public: - CA_COPY_DEFAULT(HeapInterface); - - public: - static HeapInterface *Shared() noexcept; - - public: - void Delete(PtrHeapType me) noexcept; - SizeType Size(PtrHeapType me) noexcept; - PtrHeapType New(const SizeType &sz, - const DWordType flags = kHeapNoFlags); -}; - - -/// @brief heap exception -/// Throws when the heap pointer isn't found or invalid. -class HeapException : public SystemException { - public: - explicit HeapException() = default; - virtual ~HeapException() = default; - - public: - CA_COPY_DEFAULT(HeapException); - - public: - const char *Name() override { return "HeapException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{"System.Core: HeapException: Catastrophic failure!"}; -}; - -} // namespace System - -#define kAllocationTypes 2 - -enum HcAllocationKind { - kStandardAllocation = 0xC, - kArrayAllocation = 0xD, -}; - -CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, - DWordType flags); -CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr); -CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr); -CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr); \ No newline at end of file diff --git a/Public/SDK/System.Core/Headers/Hint.hxx b/Public/SDK/System.Core/Headers/Hint.hxx deleted file mode 100644 index 86faf455..00000000 --- a/Public/SDK/System.Core/Headers/Hint.hxx +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#define _Input -#define _Output - -#define _Optional - -#define _StrictCheckInput -#define _StrictCheckOutput - -#define _InOut -#define _StrictInOut diff --git a/Public/SDK/System.Core/Headers/Thread.hxx b/Public/SDK/System.Core/Headers/Thread.hxx deleted file mode 100644 index 7b586cd1..00000000 --- a/Public/SDK/System.Core/Headers/Thread.hxx +++ /dev/null @@ -1,27 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -// -// Created by Amlal on 3/18/24 -// - -#ifndef __THREAD_API__ -#define __THREAD_API__ - -#include - -namespace System { -/// @brief Thread Information Block, which holds information about the running -/// thread. -typedef PtrVoidType PtrThread; - -/// @brief Main application thread. -CA_EXTERN_C PtrThread kMainThread; - -class ThreadInterface; -} // namespace System - -#endif // __THREAD_API__ diff --git a/Public/SDK/System.Core/Headers/UIManager/Dialog.hxx b/Public/SDK/System.Core/Headers/UIManager/Dialog.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UIManager/Dialog.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UIManager/Image.hxx b/Public/SDK/System.Core/Headers/UIManager/Image.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UIManager/Image.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UIManager/Menu.hxx b/Public/SDK/System.Core/Headers/UIManager/Menu.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UIManager/Menu.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx b/Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UIManager/TrueType.hxx b/Public/SDK/System.Core/Headers/UIManager/TrueType.hxx deleted file mode 100644 index 62ed1255..00000000 --- a/Public/SDK/System.Core/Headers/UIManager/TrueType.hxx +++ /dev/null @@ -1,7 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once diff --git a/Public/SDK/System.Core/Headers/UIManager/Window.hxx b/Public/SDK/System.Core/Headers/UIManager/Window.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UIManager/Window.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Makefile b/Public/SDK/System.Core/Makefile deleted file mode 100644 index 13fdf960..00000000 --- a/Public/SDK/System.Core/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -################################################## -# (C) Mahrouss Logic, 2024, all rights reserved. -# This is the System.Graphics Makefile. -################################################## - -CC=x86_64-w64-mingw32-g++ -CCFLAGS=-shared -ffreestanding -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17 -OUTPUT=System.Core.dll - -.PHONY: build-core-amd64 -build-core-amd64: - $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard Sources/*.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT) - -.PHONY: all -all: build-core - @echo "[System.Core.dll] Build done." - -.PHONY: clean -clean: - rm -f *.o diff --git a/Public/SDK/System.Core/RISCV/.gitkeep b/Public/SDK/System.Core/RISCV/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Public/SDK/System.Core/ReadMe.md b/Public/SDK/System.Core/ReadMe.md deleted file mode 100644 index 3867dd3d..00000000 --- a/Public/SDK/System.Core/ReadMe.md +++ /dev/null @@ -1,8 +0,0 @@ -# System.Core -## Core System API. - -Currently contains: -- Heap API. -- File API. -- Data types. -- Threading API. \ No newline at end of file diff --git a/Public/SDK/System.Core/Sources/Heap.cxx b/Public/SDK/System.Core/Sources/Heap.cxx deleted file mode 100644 index 18106f41..00000000 --- a/Public/SDK/System.Core/Sources/Heap.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include - -/// @brief Allocate from the user's heap. -/// @param refObj Process object. -/// @param sz size of object. -/// @param flags flags. -/// @return -CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, - DWordType flags) { - CA_MUST_PASS(sz); - CA_MUST_PASS(flags); - - return (PtrVoidType)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags); -} - -/// @brief Free pointer from the user's heap. -/// @param refObj Process object. -/// @param ptr the pointer to free. -CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr) { - CA_MUST_PASS(ptr); - CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr)); -} - -/// @brief Get pointer size. -/// @param refObj Process object. -/// @param ptr the pointer to find. -/// @return the size. -CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr) { - CA_MUST_PASS(ptr); - return refObj->Invoke(refObj, kProcessCallSizePtr, ptr); -} - -/// @brief Check if the pointer exists. -/// @param refObj Process object. -/// @param ptr the pointer to check. -/// @return if it exists -CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr) { - CA_MUST_PASS(ptr); - return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr); -} - -using namespace System; - -/// @brief Shared instance of the heap. -/// @return -HeapInterface* HeapInterface::Shared() noexcept { - static HeapInterface* heap = nullptr; - - if (!heap) { - heap = new HeapInterface(); - } - - return heap; -} - -HeapInterface::HeapInterface() { - CA_MUST_PASS(HcProcessHeapExists(kApplicationObject, (PtrVoidType)this)); -} - -HeapInterface::~HeapInterface() { delete this; } - -void HeapInterface::Delete(PtrHeapType me) noexcept { - CA_MUST_PASS(me); - HcFreeProcessHeap(kApplicationObject, me); -} - -SizeType HeapInterface::Size(PtrHeapType me) noexcept { - CA_MUST_PASS(me); - return HcProcessHeapSize(kApplicationObject, me); -} - -PtrHeapType HeapInterface::New(const SizeType& sz, const DWordType flags) { - SizeType _sz = sz; - if (!_sz) ++_sz; - - return HcAllocateProcessHeap(kApplicationObject, _sz, flags); -} diff --git a/Public/SDK/System.Core/Sources/LibEntrypoint.cxx b/Public/SDK/System.Core/Sources/LibEntrypoint.cxx deleted file mode 100644 index b874ef55..00000000 --- a/Public/SDK/System.Core/Sources/LibEntrypoint.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#include - -/// @brief Inits the DLL. -/// @return if it was succesful or not. -DWordType __DllMain(VoidType) { - kApplicationObject = HcGetInstanceObject(); - CA_MUST_PASS(kApplicationObject); - - return 0; -} \ No newline at end of file diff --git a/Public/SDK/System.Core/Sources/New+Delete.cxx b/Public/SDK/System.Core/Sources/New+Delete.cxx deleted file mode 100644 index 678aacce..00000000 --- a/Public/SDK/System.Core/Sources/New+Delete.cxx +++ /dev/null @@ -1,42 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include -#include - -typedef SizeType size_t; - -void* operator new[](size_t sz) { - if (sz == 0) ++sz; - - return HcAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation); -} - -void* operator new(size_t sz) { - if (sz == 0) ++sz; - - return HcAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation); -} - -void operator delete[](void* ptr) { - if (ptr == nullptr) return; - - HcFreeProcessHeap(kApplicationObject, ptr); -} - -void operator delete(void* ptr) { - if (ptr == nullptr) return; - - HcFreeProcessHeap(kApplicationObject, ptr); -} - -void operator delete(void* ptr, size_t sz) { - if (ptr == nullptr) return; - - (void)sz; - - HcFreeProcessHeap(kApplicationObject, ptr); -} diff --git a/Public/SDK/System.Core/compile_flags.txt b/Public/SDK/System.Core/compile_flags.txt deleted file mode 100644 index 6e721e73..00000000 --- a/Public/SDK/System.Core/compile_flags.txt +++ /dev/null @@ -1,4 +0,0 @@ --I./ --I../ --I../../../Private --std=c++20 -- cgit v1.2.3