diff --git a/reactos/include/ddk/winddk.h b/reactos/include/ddk/winddk.h index 5240ef84272..1c13d8ced3d 100644 --- a/reactos/include/ddk/winddk.h +++ b/reactos/include/ddk/winddk.h @@ -458,6 +458,9 @@ typedef struct _KUSER_SHARED_DATA LARGE_INTEGER SystemExpirationDate; ULONG SuiteMask; BOOLEAN KdDebuggerEnabled; +#if (NTDDI_VERSION >= NTDDI_WINXPSP2) + UCHAR NXSupportPolicy; +#endif volatile ULONG ActiveConsoleId; volatile ULONG DismountCount; ULONG ComPlusPackage; @@ -475,9 +478,29 @@ typedef struct _KUSER_SHARED_DATA volatile ULONG64 TickCountQuad; }; ULONG Cookie; +#if (NTDDI_VERSION >= NTDDI_WS03) LONGLONG ConsoleSessionForegroundProcessId; ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; - ULONG UserModeGlobalLogging; +#endif +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + USHORT UserModeGlobalLogger[8]; + ULONG HeapTracingPid[2]; + ULONG CritSecTracingPid[2]; + union + { + ULONG SharedDataFlags; + struct + { + ULONG DbgErrorPortPresent:1; + ULONG DbgElevationEnabled:1; + ULONG DbgVirtEnabled:1; + ULONG DbgInstallerDetectEnabled:1; + ULONG SpareBits:28; + }; + }; + ULONG ImageFileExecutionOptions; + KAFFINITY ActiveProcessorAffinity; +#endif } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; /* diff --git a/reactos/include/ndk/ketypes.h b/reactos/include/ndk/ketypes.h index 5510e35d732..ca11ac4341d 100644 --- a/reactos/include/ndk/ketypes.h +++ b/reactos/include/ndk/ketypes.h @@ -87,6 +87,8 @@ Author: #define KF_3DNOW 0x00004000 #define KF_AMDK6MTRR 0x00008000 #define KF_XMMI64 0x00010000 +#define KF_NX_DISABLED 0x00400000 +#define KF_NX_ENABLED 0x00800000 // // KPCR Access for non-IA64 builds diff --git a/reactos/ntoskrnl/ke/i386/cpu.c b/reactos/ntoskrnl/ke/i386/cpu.c index e8f88e0bebb..23366d4f632 100644 --- a/reactos/ntoskrnl/ke/i386/cpu.c +++ b/reactos/ntoskrnl/ke/i386/cpu.c @@ -303,7 +303,7 @@ KiGetFeatureBits(VOID) } else { - /* Familes below 5 don't support PGE, PSE or CMOV at all */ + /* Families below 5 don't support PGE, PSE or CMOV at all */ Reg[3] &= ~(0x08 | 0x2000 | 0x8000); /* They also don't support advanced CPUID functions. */ diff --git a/reactos/ntoskrnl/ke/i386/kiinit.c b/reactos/ntoskrnl/ke/i386/kiinit.c index cf3a3b5356b..ad1bb5f2181 100644 --- a/reactos/ntoskrnl/ke/i386/kiinit.c +++ b/reactos/ntoskrnl/ke/i386/kiinit.c @@ -8,6 +8,7 @@ /* INCLUDES *****************************************************************/ +#define NTDDI_VERSION NTDDI_WS03SP1 #include #define NDEBUG #include @@ -318,6 +319,36 @@ KiInitializeKernel(IN PKPROCESS InitProcess, /* Save feature bits */ Prcb->FeatureBits = FeatureBits; + /* Set the default NX policy (opt-in) */ + SharedUserData->NXSupportPolicy = 2; + + /* Check if NPX is always on */ + if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=ALWAYSON")) + { + /* Set it always on */ + SharedUserData->NXSupportPolicy = 1; + KeFeatureBits |= KF_NX_ENABLED; + } + else if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTOUT")) + { + /* Set it in opt-out mode */ + SharedUserData->NXSupportPolicy = 3; + KeFeatureBits |= KF_NX_ENABLED; + } + else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTIN")) || + (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE"))) + { + /* Set the feature bits */ + KeFeatureBits |= KF_NX_ENABLED; + } + else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=ALWAYSOFF")) || + (strstr(KeLoaderBlock->LoadOptions, "EXECUTE"))) + { + /* Set disabled mode */ + SharedUserData->NXSupportPolicy = 0; + KeFeatureBits |= KF_NX_DISABLED; + } + /* Save CPU state */ KiSaveProcessorControlState(&Prcb->ProcessorState);