From bf9cac8a676f1d570e4520f75617384487296432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 23 Feb 2024 22:53:36 +0100 Subject: [PATCH] [SDK:NDK/XDK] Remove x86 KeGetPcr() definition from the DDK (#6526) The official MS DDK/WDK does not expose KeGetPcr() for x86, so do not expose it there as well. Use instead the private NDK definition. If it were exposed in the DDK/WDK, it would have to be a multiprocessor-compatible definition. Note that the broken definition was working only in single-processor mode, using the PCR static memory pointer value. The official MS DDK/WDK exposes KeGetPcr() as an alias to such a PCR value only for IA64, MIPS and PPC, which is of course not great. --- sdk/include/ndk/i386/ketypes.h | 4 +++- sdk/include/xdk/x86/ke.h | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sdk/include/ndk/i386/ketypes.h b/sdk/include/ndk/i386/ketypes.h index 4d77e015b02..757fd4e82d4 100644 --- a/sdk/include/ndk/i386/ketypes.h +++ b/sdk/include/ndk/i386/ketypes.h @@ -75,8 +75,10 @@ Author: #define K0IPCR ((ULONG_PTR)(KIP0PCRADDRESS)) #define PCR ((KPCR *)K0IPCR) #if defined(CONFIG_SMP) || defined(NT_BUILD) -#undef KeGetPcr +//#undef KeGetPcr #define KeGetPcr() ((KPCR *)__readfsdword(FIELD_OFFSET(KPCR, SelfPcr))) +#else +#define KeGetPcr() PCR #endif // diff --git a/sdk/include/xdk/x86/ke.h b/sdk/include/xdk/x86/ke.h index b367a93d1b5..713eff15061 100644 --- a/sdk/include/xdk/x86/ke.h +++ b/sdk/include/xdk/x86/ke.h @@ -283,8 +283,6 @@ typedef struct _CONTEXT { } CONTEXT; #include "poppack.h" -#define KeGetPcr() PCR - #define PCR_MINOR_VERSION 1 #define PCR_MAJOR_VERSION 1 @@ -325,6 +323,18 @@ typedef struct _KPCR { ULONG HalReserved[16]; } KPCR, *PKPCR; +/* NOTE: This macro is not exposed in the DDK/WDK for _M_IX86. + * If it were, this would be its definition. */ +#if 0 +// #define KeGetPcr() ((PKPCR)__readfsdword(FIELD_OFFSET(KPCR, SelfPcr))) +FORCEINLINE +PKPCR +KeGetPcr(VOID) +{ + return (PKPCR)__readfsdword(FIELD_OFFSET(KPCR, SelfPcr)); +} +#endif + #if (NTDDI_VERSION >= NTDDI_WIN7) _CRT_DEPRECATE_TEXT("KeGetCurrentProcessorNumber is deprecated. Use KeGetCurrentProcessorNumberEx or KeGetCurrentProcessorIndex instead.") #endif