https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a84912594754b52343d5ca...
commit a84912594754b52343d5cac0426adbaba764d2bf Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Tue Mar 8 05:32:17 2022 +0100 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Sun May 8 04:15:52 2022 +0200
[NDK][XDK] Improve some HAL-related definitions.
- Add more accurate definitions for the values of HAL_DISPATCH_VERSION and HAL_PRIVATE_DISPATCH_VERSION. See https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/hal/hal_d... and https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/hal/hal_p...
- Make the conditionals for HalDispatchTable definition MS-WDK-compatible, and do the same for HalPrivateDispatchTable.
- Remove MinGW-only non-MS-WDK-compatible PHAL_DISPATCH_TABLE and PHAL_PRIVATE_DISPATCH_TABLE definitions.
- Remove hackish #define _NTSYSTEM_ in the wdm.h header. --- sdk/include/ndk/haltypes.h | 17 ++++++++++++++--- sdk/include/xdk/haltypes.h | 25 ++++++++++++++++++------- sdk/include/xdk/ntddk.template.h | 2 ++ sdk/include/xdk/wdm.template.h | 9 ++------- 4 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/sdk/include/ndk/haltypes.h b/sdk/include/ndk/haltypes.h index 125158b4210..e5f2edc48eb 100644 --- a/sdk/include/ndk/haltypes.h +++ b/sdk/include/ndk/haltypes.h @@ -153,9 +153,20 @@ BOOLEAN );
// -// Hal Private dispatch Table +// HAL Private dispatch Table // +// See Version table at: +// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/hal/hal_p... +// +#if (NTDDI_VERSION < NTDDI_WINXP) +#define HAL_PRIVATE_DISPATCH_VERSION 1 +#elif (NTDDI_VERSION < NTDDI_LONGHORN) #define HAL_PRIVATE_DISPATCH_VERSION 2 +#elif (NTDDI_VERSION >= NTDDI_LONGHORN) +#define HAL_PRIVATE_DISPATCH_VERSION 5 +#else +/* Not yet defined */ +#endif typedef struct _HAL_PRIVATE_DISPATCH { ULONG Version; @@ -257,7 +268,7 @@ typedef struct _BUS_HANDLER // // Kernel Exports // -#if (defined(_NTDRIVER_) || defined(_NTHAL_)) && !defined(_BLDR_) +#if !defined(_NTSYSTEM_) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)) extern NTSYSAPI PHAL_PRIVATE_DISPATCH HalPrivateDispatchTable; #define HALPRIVATEDISPATCH ((PHAL_PRIVATE_DISPATCH)&HalPrivateDispatchTable) #else @@ -268,7 +279,7 @@ extern NTSYSAPI HAL_PRIVATE_DISPATCH HalPrivateDispatchTable; // // HAL Exports // -extern PUCHAR NTHALAPI KdComPortInUse; +extern NTHALAPI PUCHAR KdComPortInUse;
// // HAL Constants diff --git a/sdk/include/xdk/haltypes.h b/sdk/include/xdk/haltypes.h index 4ba2b36c7b6..5497d8408e1 100644 --- a/sdk/include/xdk/haltypes.h +++ b/sdk/include/xdk/haltypes.h @@ -269,16 +269,27 @@ typedef struct { #endif } HAL_DISPATCH, *PHAL_DISPATCH;
-#ifdef _NTSYSTEM_ -extern HAL_DISPATCH HalDispatchTable; -#define HALDISPATCH (&HalDispatchTable) -#else +#if !defined(_NTSYSTEM_) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)) __CREATE_NTOS_DATA_IMPORT_ALIAS(HalDispatchTable) -extern PHAL_DISPATCH HalDispatchTable; -#define HALDISPATCH HalDispatchTable +extern PHAL_DISPATCH HalDispatchTable; +#define HALDISPATCH HalDispatchTable +#else +extern HAL_DISPATCH HalDispatchTable; +#define HALDISPATCH (&HalDispatchTable) +#endif + +// See Version table at: +// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/hal/hal_d... +#if (NTDDI_VERSION < NTDDI_WIN2K) +#define HAL_DISPATCH_VERSION 1 +#elif (NTDDI_VERSION < NTDDI_WINXP) +#define HAL_DISPATCH_VERSION 2 +#elif (NTDDI_VERSION < NTDDI_WIN7) +#define HAL_DISPATCH_VERSION 3 +#else +#define HAL_DISPATCH_VERSION 4 #endif
-#define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */ #define HalDispatchTableVersion HALDISPATCH->Version #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation diff --git a/sdk/include/xdk/ntddk.template.h b/sdk/include/xdk/ntddk.template.h index 35eb73c4aaf..dc2ff5ff5d0 100644 --- a/sdk/include/xdk/ntddk.template.h +++ b/sdk/include/xdk/ntddk.template.h @@ -65,12 +65,14 @@ extern "C" {
typedef GUID UUID;
+/* Forward declarations */ struct _LOADER_PARAMETER_BLOCK; struct _CREATE_DISK; struct _DRIVE_LAYOUT_INFORMATION_EX; struct _SET_PARTITION_INFORMATION_EX; struct _DISK_GEOMETRY_EX;
+/* Structures not exposed to drivers */ typedef struct _BUS_HANDLER *PBUS_HANDLER; typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; #if defined(_NTHAL_INCLUDED_) diff --git a/sdk/include/xdk/wdm.template.h b/sdk/include/xdk/wdm.template.h index 1623e00a081..956bd6ce2ac 100644 --- a/sdk/include/xdk/wdm.template.h +++ b/sdk/include/xdk/wdm.template.h @@ -91,12 +91,9 @@ $define(USHORT=USHORT) #define NTKERNELAPI DECLSPEC_IMPORT #else #define NTKERNELAPI -#ifndef _NTSYSTEM_ -#define _NTSYSTEM_ -#endif #endif
-/* for statically-linked ntoskrnl_vista library */ +/* For statically-linked ntoskrnl_vista library */ #if defined(NTKRNLVISTA) #define NTKRNLVISTAAPI #else @@ -117,7 +114,7 @@ $define(USHORT=USHORT) #define POINTER_ALIGNMENT #endif
-/* Helper macro to enable gcc's extension. */ +/* Helper macro to enable gcc's extension */ #ifndef __GNU_EXTENSION #ifdef __GNUC__ #define __GNU_EXTENSION __extension__ @@ -196,8 +193,6 @@ struct _IO_RESOURCE_DESCRIPTOR;
/* Structures not exposed to drivers */ typedef struct _OBJECT_TYPE *POBJECT_TYPE; -typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE; -typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; typedef struct _EPROCESS *PEPROCESS; typedef struct _ETHREAD *PETHREAD;