diff --git a/ntoskrnl/include/internal/i386/ke.h b/ntoskrnl/include/internal/i386/ke.h index dacc0a816d7..c40cf711482 100644 --- a/ntoskrnl/include/internal/i386/ke.h +++ b/ntoskrnl/include/internal/i386/ke.h @@ -196,6 +196,11 @@ typedef union _KTRAP_EXIT_SKIP_BITS #define PFX_FLAG_REPNE 0x00020000 #define PFX_FLAG_REP 0x00040000 +// +// VDM State Pointer +// +extern const PULONG KiNtVdmState; + // // VDM Helper Macros // @@ -218,8 +223,22 @@ typedef union _KTRAP_EXIT_SKIP_BITS // more time, this way we don't redefine ALL opcode handlers to have 3 parameters, // which would be forcing stack usage in all other scenarios. // -#define KiVdmSetVdmEFlags(x) InterlockedOr((PLONG)KiNtVdmState, (x)); -#define KiVdmClearVdmEFlags(x) InterlockedAnd((PLONG)KiNtVdmState, ~(x)) +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif +FORCEINLINE ULONG KiVdmSetVdmEFlags(ULONG EFlags) +{ + return InterlockedOr((PLONG)KiNtVdmState, EFlags); +} +FORCEINLINE ULONG KiVdmClearVdmEFlags(ULONG EFlags) +{ + return InterlockedAnd((PLONG)KiNtVdmState, ~EFlags); +} +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #define KiCallVdmHandler(x) KiVdmOpcode##x(TrapFrame, Flags) #define KiCallVdmPrefixHandler(x) KiVdmOpcodePrefix(TrapFrame, Flags | x) #define KiVdmUnhandledOpcode(x) \ diff --git a/ntoskrnl/include/internal/vdm.h b/ntoskrnl/include/internal/vdm.h index 81e47a64944..9d3e7adc874 100644 --- a/ntoskrnl/include/internal/vdm.h +++ b/ntoskrnl/include/internal/vdm.h @@ -42,12 +42,6 @@ // #define TRAMPOLINE_BOP 0xFEC4C4 -// -// VDM State Pointer -// -#define VdmState \ - (PULONG)FIXED_NTVDMSTATE_LINEAR_PC_AT - // // VDM Event Types // diff --git a/ntoskrnl/ke/i386/v86vdm.c b/ntoskrnl/ke/i386/v86vdm.c index b4790d146f6..0cf2674b489 100644 --- a/ntoskrnl/ke/i386/v86vdm.c +++ b/ntoskrnl/ke/i386/v86vdm.c @@ -652,7 +652,7 @@ Ke386CallBios(IN ULONG Int, VdmTib->Size = sizeof(VDM_TIB); /* Set a blank VDM state */ - *VdmState = 0; + *KiNtVdmState = 0; /* Copy the context */ RtlCopyMemory(&VdmTib->VdmContext, Context, ContextSize); diff --git a/ntoskrnl/vdm/vdmexec.c b/ntoskrnl/vdm/vdmexec.c index 8d8ce7a248a..8fc626865ed 100644 --- a/ntoskrnl/vdm/vdmexec.c +++ b/ntoskrnl/vdm/vdmexec.c @@ -193,7 +193,7 @@ VdmpStartExecution(VOID) Interrupts = (BOOLEAN)(VdmTib->VdmContext.EFlags & EFLAGS_INTERRUPT_MASK); /* We don't support full VDM yet, this shouldn't happen */ - ASSERT(*VdmState == 0); + ASSERT(*KiNtVdmState == 0); ASSERT(VdmTib->VdmContext.EFlags & EFLAGS_V86_MASK); /* Check if VME is supported and V86 mode was enabled */ @@ -219,12 +219,12 @@ VdmpStartExecution(VOID) if (VdmTib->VdmContext.EFlags & EFLAGS_INTERRUPT_MASK) { /* Enable them as well */ - InterlockedOr((PLONG)VdmState, EFLAGS_INTERRUPT_MASK); + InterlockedOr((PLONG)KiNtVdmState, EFLAGS_INTERRUPT_MASK); } else { /* Disable them */ - InterlockedAnd((PLONG)VdmState, ~EFLAGS_INTERRUPT_MASK); + InterlockedAnd((PLONG)KiNtVdmState, ~EFLAGS_INTERRUPT_MASK); } /* Enable the interrupt flag */ @@ -300,7 +300,7 @@ VdmEndExecution(IN PKTRAP_FRAME TrapFrame, { /* Set the EFLAGS based on our software copy of EFLAGS */ VdmTib->VdmContext.EFlags = (VdmTib->VdmContext.EFlags & ~EFLAGS_INTERRUPT_MASK) | - (*VdmState & EFLAGS_INTERRUPT_MASK); + (*KiNtVdmState & EFLAGS_INTERRUPT_MASK); } }