From 69d628dd02df81e64dfd9a2e730a44c5c5a0e5a8 Mon Sep 17 00:00:00 2001 From: Amlal Date: Fri, 13 Sep 2024 10:52:28 +0200 Subject: DDK: Export DDK symbols by default. ADD: Add ZWM (ZKA Window Manager). META: The rest are refactors. Signed-off-by: Amlal --- dev/CRT/build.json | 20 ------------------- dev/CRT/crt.json | 20 +++++++++++++++++++ dev/DDK/KernelStd.h | 21 ++++++++++++++++---- dev/DDK/build.json | 23 ---------------------- dev/DDK/ddk.json | 24 +++++++++++++++++++++++ dev/SCI/build.json | 21 -------------------- dev/SCI/sci.json | 21 ++++++++++++++++++++ dev/ZKA/Modules/CoreCG/WindowRenderer.hxx | 32 +++++++++++++++++++++++++------ dev/ZWM/.keepme | 0 dev/ZWM/Sources/zwm_main.cxx | 32 +++++++++++++++++++++++++++++++ dev/ZWM/zwm.json | 22 +++++++++++++++++++++ 11 files changed, 162 insertions(+), 74 deletions(-) delete mode 100644 dev/CRT/build.json create mode 100644 dev/CRT/crt.json delete mode 100644 dev/DDK/build.json create mode 100644 dev/DDK/ddk.json delete mode 100644 dev/SCI/build.json create mode 100644 dev/SCI/sci.json create mode 100644 dev/ZWM/.keepme create mode 100644 dev/ZWM/Sources/zwm_main.cxx create mode 100644 dev/ZWM/zwm.json diff --git a/dev/CRT/build.json b/dev/CRT/build.json deleted file mode 100644 index d91b6131..00000000 --- a/dev/CRT/build.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-g++", - "compiler_std": "c++20", - "headers_path": ["../", "./"], - "sources_path": ["Sources/*.cxx"], - "output_name": "ndkcrt.dll", - "compiler_flags": [ - "-ffreestanding", - "-shared", - "-fno-rtti", - "-fno-exceptions", - " -Wl,--subsystem=17" - ], - "cpp_macros": [ - "__CRT_AMD64__", - "cCRTVersion=0x0100", - "cEFSVersionHighest=0x0100", - "cEFSVersionLowest=0x0100" - ] -} diff --git a/dev/CRT/crt.json b/dev/CRT/crt.json new file mode 100644 index 00000000..d91b6131 --- /dev/null +++ b/dev/CRT/crt.json @@ -0,0 +1,20 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["../", "./"], + "sources_path": ["Sources/*.cxx"], + "output_name": "ndkcrt.dll", + "compiler_flags": [ + "-ffreestanding", + "-shared", + "-fno-rtti", + "-fno-exceptions", + " -Wl,--subsystem=17" + ], + "cpp_macros": [ + "__CRT_AMD64__", + "cCRTVersion=0x0100", + "cEFSVersionHighest=0x0100", + "cEFSVersionLowest=0x0100" + ] +} diff --git a/dev/DDK/KernelStd.h b/dev/DDK/KernelStd.h index da15f269..4270229b 100644 --- a/dev/DDK/KernelStd.h +++ b/dev/DDK/KernelStd.h @@ -13,15 +13,28 @@ #include #if defined(__cplusplus) -#define DK_EXTERN extern "C" +#define DK_EXTERN extern "C" __declspec(dllexport) #define nil nullptr +#undef NULL +#define NULL 0 #define DK_FINAL final #else -#define DK_EXTERN extern +#define DK_EXTERN extern __declspec(dllexport) #define nil ((void*)0) +#undef NULL +#define NULL ((void*)0) #define DK_FINAL #endif // defined(__cplusplus) +#ifndef __DDK__ +#undef DK_EXTERN +#if defined(__cplusplus) +#define DK_EXTERN extern "C" __declspec(dllimport) +#else +#define DK_EXTERN __declspec(dllimport) +#endif +#endif + #define ATTRIBUTE(X) __attribute__((X)) #ifndef __NEWOSKRNL__ @@ -33,9 +46,9 @@ struct DDK_OBJECT_MANIFEST; struct DDK_OBJECT_MANIFEST DK_FINAL { - char* p_name; + char* p_name; int32_t p_kind; - void* p_object; + void* p_object; }; /// \brief DDK status structure (__at_enable, __at_disable...) diff --git a/dev/DDK/build.json b/dev/DDK/build.json deleted file mode 100644 index a9a3b895..00000000 --- a/dev/DDK/build.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-gcc", - "compiler_std": "c++20", - "headers_path": ["../", "./"], - "sources_path": ["*.c", "*.cxx", "*.S"], - "output_name": "ddk.dll", - "compiler_flags": [ - "-ffreestanding", - "-shared", - "-std=c17", - "-std=c++20", - "-fno-rtti", - "-fno-exceptions", - " -Wl,--subsystem=17" - ], - "cpp_macros": [ - "__NEWOSKRNL__", - "__DDK_AMD64__", - "cDDKVersionHighest=0x0100", - "cDDKVersionLowest=0x0100", - "cDDKVersion=0x0100" - ] -} diff --git a/dev/DDK/ddk.json b/dev/DDK/ddk.json new file mode 100644 index 00000000..b930f99c --- /dev/null +++ b/dev/DDK/ddk.json @@ -0,0 +1,24 @@ +{ + "compiler_path": "x86_64-w64-mingw32-gcc", + "compiler_std": "c++20", + "headers_path": ["../", "./"], + "sources_path": ["*.c", "*.cxx", "*.S"], + "output_name": "ddk.dll", + "compiler_flags": [ + "-ffreestanding", + "-shared", + "-std=c17", + "-std=c++20", + "-fno-rtti", + "-fno-exceptions", + " -Wl,--subsystem=17" + ], + "cpp_macros": [ + "__NEWOSKRNL__", + "__DDK_AMD64__", + "__DDK__", + "cDDKVersionHighest=0x0100", + "cDDKVersionLowest=0x0100", + "cDDKVersion=0x0100" + ] +} diff --git a/dev/SCI/build.json b/dev/SCI/build.json deleted file mode 100644 index 0c367bd6..00000000 --- a/dev/SCI/build.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-g++", - "compiler_std": "c++20", - "headers_path": ["../"], - "sources_path": ["Sources/*.cxx"], - "output_name": "sci.dll", - "compiler_flags": [ - "-fPIC", - "-ffreestanding", - "-shared", - "-fno-rtti", - "-fno-exceptions", - "-Wl,--subsystem=17" - ], - "cpp_macros": [ - "__SCI_IMPL__", - "cSCIVersion=0x0100", - "cSCIVersionHighest=0x0100", - "cSCIVersionLowest=0x0100" - ] -} diff --git a/dev/SCI/sci.json b/dev/SCI/sci.json new file mode 100644 index 00000000..0c367bd6 --- /dev/null +++ b/dev/SCI/sci.json @@ -0,0 +1,21 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["../"], + "sources_path": ["Sources/*.cxx"], + "output_name": "sci.dll", + "compiler_flags": [ + "-fPIC", + "-ffreestanding", + "-shared", + "-fno-rtti", + "-fno-exceptions", + "-Wl,--subsystem=17" + ], + "cpp_macros": [ + "__SCI_IMPL__", + "cSCIVersion=0x0100", + "cSCIVersionHighest=0x0100", + "cSCIVersionLowest=0x0100" + ] +} diff --git a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx index 153cb64f..8dab7925 100644 --- a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx +++ b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx @@ -53,12 +53,23 @@ namespace CG typedef struct UI_WINDOW_STRUCT UI_WINDOW_STRUCT; - inline Void CGDrawBackground() noexcept + /// \brief Draw background (either image or solid color) + inline Void CGDrawBackground(UInt32* raw_bmp, SizeT width, SizeT height) noexcept { CGInit(); - CGDrawInRegion(CGColor(0x45, 0x00, 0x06), CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(), - 0, 0); + if (!raw_bmp) + { + const auto cColorBackground = CGColor(0x45, 0x00, 0x06); + + CGDrawInRegion(cColorBackground, CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(), + 0, 0); + } + else + { + CGDrawBitMapInRegion(raw_bmp, height, width, + 0, 0); + } CGFini(); } @@ -98,19 +109,28 @@ namespace CG return wnd; } - inline bool CGDestroyWindow(struct UI_WINDOW_STRUCT* wnd) + /// \brief Destroys a window and it's contents. + inline Bool CGDestroyWindow(struct UI_WINDOW_STRUCT* wnd) { if (wnd) { - delete wnd; - if (!mm_is_valid_heap(wnd)) { wnd = nullptr; return true; } + wnd->w_needs_repaint = No; + + for (SizeT index = 0UL; index < wnd->w_child_count; ++index) + { + CGDestroyWindow(wnd->w_child_elements[index]); + } + + delete wnd; wnd = nullptr; + + return true; } return false; diff --git a/dev/ZWM/.keepme b/dev/ZWM/.keepme new file mode 100644 index 00000000..e69de29b diff --git a/dev/ZWM/Sources/zwm_main.cxx b/dev/ZWM/Sources/zwm_main.cxx new file mode 100644 index 00000000..38d441bd --- /dev/null +++ b/dev/ZWM/Sources/zwm_main.cxx @@ -0,0 +1,32 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + FILE: IFSMain.cxx + PURPOSE: HPFS IFS entrypoint. + +------------------------------------------- */ + +#include +#include + +static uint32_t cGPUIndexHW = 0U; +static struct DDK_OBJECT_MANIFEST* cGPUObject = nullptr; + +/** @brief ZWM main, ZWM acts a proxy to the Installed GPU Driver. */ +int32_t ModuleMain(void) +{ + int index_gpu = 0; + struct DDK_OBJECT_MANIFEST* gpu_object = nullptr; + + while (!gpu_object) + { + gpu_object = KernelGetObject(index_gpu, "GPU_OBJECT"); + ++index_gpu; + } + + cGPUIndexHW = index_gpu; + cGPUObject = gpu_object; + + return 0; +} diff --git a/dev/ZWM/zwm.json b/dev/ZWM/zwm.json new file mode 100644 index 00000000..2f759c56 --- /dev/null +++ b/dev/ZWM/zwm.json @@ -0,0 +1,22 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["../"], + "sources_path": ["Sources/*.cxx"], + "output_name": "zwm.sys", + "compiler_flags": [ + "-fPIC", + "-ffreestanding", + "-shared", + "-fno-rtti", + "-fno-exceptions", + "-Wl,--subsystem=17" + ], + "cpp_macros": [ + "__ZWM_IMPL__", + "__NEWOSKRNL__", + "cZWMVersion=0x0100", + "cZWMVersionHighest=0x0100", + "cZWMVersionLowest=0x0100" + ] +} -- cgit v1.2.3