[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_dispatch.htm
  and https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/hal/hal_private_dispatch.htm

- 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.
This commit is contained in:
Hermès Bélusca-Maïto 2022-03-08 05:32:17 +01:00
parent 39b8d45592
commit a849125947
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 36 additions and 17 deletions

View file

@ -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_private_dispatch.htm
//
#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

View file

@ -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
#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_dispatch.htm
#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

View file

@ -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_)

View file

@ -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;