From 06aa2bb31b811742985a32199159124a3a45cb80 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 8 Mar 2023 05:25:37 +0200 Subject: [PATCH] Changed "struct KernelCallback" to be an union --- DAPI.hpp | 109 +++++++++++++++++++++++++++++-------------------------- Fex.hpp | 4 +- 2 files changed, 59 insertions(+), 54 deletions(-) diff --git a/DAPI.hpp b/DAPI.hpp index d206f40..0c7431e 100644 --- a/DAPI.hpp +++ b/DAPI.hpp @@ -119,67 +119,72 @@ enum CallbackReason InputReason, }; -struct KernelCallback +union KernelCallback { - CallbackReason Reason; - void *RawPtr; - unsigned long RawData; - - /** @brief When the kernel wants to send a packet. */ struct { - struct - { - unsigned char *Data; - unsigned long Length; - } Send; + CallbackReason Reason; + void *RawPtr; + unsigned long RawData; + /** @brief When the kernel wants to send a packet. */ struct { - char Name[128]; - unsigned long MAC; - } Fetch; - } NetworkCallback; - - /** @brief When the kernel wants to write to disk. */ - struct - { - struct - { - unsigned long Sector; - unsigned long SectorCount; - unsigned char Port; - unsigned char *Buffer; - bool Write; - } RW; - - struct - { - unsigned char Ports; - int BytesPerSector; - } Fetch; - } DiskCallback; - - struct - { - struct - { - unsigned long X; - unsigned long Y; - unsigned long Z; struct { - bool Left; - bool Right; - bool Middle; - } Buttons; - } Mouse; - } InputCallback; + unsigned char *Data; + unsigned long Length; + } Send; - struct - { - unsigned char Vector; - } InterruptInfo; + struct + { + char Name[128]; + unsigned long MAC; + } Fetch; + } NetworkCallback; + + /** @brief When the kernel wants to write to disk. */ + struct + { + struct + { + unsigned long Sector; + unsigned long SectorCount; + unsigned char Port; + unsigned char *Buffer; + bool Write; + } RW; + + struct + { + unsigned char Ports; + int BytesPerSector; + } Fetch; + } DiskCallback; + + /** @brief When the kernel wants to get mouse position / keyboard key */ + struct + { + struct + { + unsigned long X; + unsigned long Y; + unsigned long Z; + struct + { + bool Left; + bool Right; + bool Middle; + } Buttons; + } Mouse; + } InputCallback; + + struct + { + unsigned char Vector; + } InterruptInfo; + }; + unsigned long raw; } __attribute__((packed)); #endif // !__FENNIX_DRIVER_API_H__ diff --git a/Fex.hpp b/Fex.hpp index 6d36e19..68ceec5 100644 --- a/Fex.hpp +++ b/Fex.hpp @@ -58,7 +58,7 @@ struct Fex int (*EntryPoint)(void *); } __attribute__((packed)); -struct KernelCallback; +union KernelCallback; struct FexExtended { @@ -73,7 +73,7 @@ struct FexExtended enum FexDriverType Type : 4; enum FexDriverInputTypes TypeFlags : 4; bool OverrideOnConflict : 1; - int (*Callback)(struct KernelCallback *); + int (*Callback)(union KernelCallback *); struct DriverBind {