ReactOS  0.4.15-dev-1033-gd7d716a
ke.h File Reference

Go to the source code of this file.

Classes

struct  _KPCR
 

Macros

#define PASSIVE_LEVEL   0
 
#define LOW_LEVEL   0
 
#define APC_LEVEL   1
 
#define DISPATCH_LEVEL   2
 
#define CMCI_LEVEL   5
 
#define CLOCK_LEVEL   13
 
#define IPI_LEVEL   14
 
#define DRS_LEVEL   14
 
#define POWER_LEVEL   14
 
#define PROFILE_LEVEL   15
 
#define HIGH_LEVEL   15
 
#define KI_USER_SHARED_DATA   0xFFFFF78000000000ULL
 
#define SharedUserData   ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
 
#define SharedInterruptTime   (KI_USER_SHARED_DATA + 0x8)
 
#define SharedSystemTime   (KI_USER_SHARED_DATA + 0x14)
 
#define SharedTickCount   (KI_USER_SHARED_DATA + 0x320)
 
#define PAGE_SIZE   0x1000
 
#define PAGE_SHIFT   12L
 
#define EFLAG_SIGN   0x8000
 
#define EFLAG_ZERO   0x4000
 
#define EFLAG_SELECT   (EFLAG_SIGN | EFLAG_ZERO)
 
#define KeQueryInterruptTime()   (*(volatile ULONG64*)SharedInterruptTime)
 
#define KeQuerySystemTime(CurrentCount)   *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
 
#define KeQueryTickCount(CurrentCount)   *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
 
#define KeGetDcacheFillSize()   1L
 
#define YieldProcessor   _mm_pause
 
#define MemoryBarrier   __faststorefence
 
#define FastFence   __faststorefence
 
#define LoadFence   _mm_lfence
 
#define MemoryFence   _mm_mfence
 
#define StoreFence   _mm_sfence
 
#define LFENCE_ACQUIRE()   LoadFence()
 
#define KeMemoryBarrierWithoutFence()   _ReadWriteBarrier()
 
#define KeRaiseIrql(a, b)   *(b) = KfRaiseIrql(a)
 
#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
 
#define DbgRaiseAssertionFailure   __int2c
 
#define PAUSE_PROCESSOR   YieldProcessor();
 
#define KERNEL_STACK_SIZE   0x6000
 
#define KERNEL_LARGE_STACK_SIZE   0x12000
 
#define KERNEL_LARGE_STACK_COMMIT   KERNEL_STACK_SIZE
 
#define KERNEL_MCA_EXCEPTION_STACK_SIZE   0x2000
 
#define EXCEPTION_READ_FAULT   0
 
#define EXCEPTION_WRITE_FAULT   1
 
#define EXCEPTION_EXECUTE_FAULT   8
 
#define CONTEXT_AMD64   0x100000
 
#define CONTEXT_CONTROL   (CONTEXT_AMD64 | 0x1L)
 
#define CONTEXT_INTEGER   (CONTEXT_AMD64 | 0x2L)
 
#define CONTEXT_SEGMENTS   (CONTEXT_AMD64 | 0x4L)
 
#define CONTEXT_FLOATING_POINT   (CONTEXT_AMD64 | 0x8L)
 
#define CONTEXT_DEBUG_REGISTERS   (CONTEXT_AMD64 | 0x10L)
 
#define CONTEXT_FULL   (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
 
#define CONTEXT_ALL   (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
 
#define CONTEXT_XSTATE   (CONTEXT_AMD64 | 0x40L)
 
#define CONTEXT_EXCEPTION_ACTIVE   0x8000000
 
#define CONTEXT_SERVICE_ACTIVE   0x10000000
 
#define CONTEXT_EXCEPTION_REQUEST   0x40000000
 
#define CONTEXT_EXCEPTION_REPORTING   0x80000000
 
#define INITIAL_MXCSR   0x1f80
 
#define INITIAL_FPCSR   0x027f
 
#define PCR_MINOR_VERSION   1
 
#define PCR_MAJOR_VERSION   1
 

Typedefs

typedef XSAVE_FORMAT XMM_SAVE_AREA32
 
typedef XSAVE_FORMATPXMM_SAVE_AREA32
 
typedef struct _KPCR KPCR
 
typedef struct _KPCRPKPCR
 

Functions

 $if (_WDMDDK_) typedef struct _KFLOATING_SAVE
 
FORCEINLINE VOID KeMemoryBarrier (VOID)
 
 _IRQL_requires_max_ (HIGH_LEVEL) _IRQL_saves_ FORCEINLINE KIRQL KeGetCurrentIrql(VOID)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) _IRQL_saves_ _IRQL_raises_(DISPATCH_LEVEL) FORCEINLINE KIRQL KeRaiseIrqlToDpcLevel(VOID)
 
FORCEINLINE KIRQL KeRaiseIrqlToSynchLevel (VOID)
 
FORCEINLINE PKTHREAD KeGetCurrentThread (VOID)
 
 _Always_ (_Post_satisfies_(return<=0)) _Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL) _Kernel_float_saved_ _At_(*FloatSave
 
 _Kernel_requires_resource_not_held_ (FloatState) _Kernel_acquires_resource_(FloatState)) FORCEINLINE NTSTATUS KeSaveFloatingPointState(_Out_ PKFLOATING_SAVE FloatSave)
 
 _Success_ (1) _Kernel_float_restored_ _At_(*FloatSave
 
 _Kernel_requires_resource_held_ (FloatState) _Kernel_releases_resource_(FloatState)) FORCEINLINE NTSTATUS KeRestoreFloatingPointState(_In_ PKFLOATING_SAVE FloatSave)
 
FORCEINLINE ULONG KeGetCurrentProcessorIndex (VOID)
 
$endif $if (_NTDDK_) typedef struct DECLSPEC_ALIGN(16) _CONTEXT
 
FORCEINLINE PKPCR KeGetPcr (VOID)
 
FORCEINLINE ULONG KeGetCurrentProcessorNumber (VOID)
 

Variables

 KFLOATING_SAVE
 
PKFLOATING_SAVE
 
 CONTEXT
 

Macro Definition Documentation

◆ APC_LEVEL

#define APC_LEVEL   1

◆ CLOCK_LEVEL

#define CLOCK_LEVEL   13

◆ CMCI_LEVEL

#define CMCI_LEVEL   5

◆ CONTEXT_ALL

◆ CONTEXT_AMD64

#define CONTEXT_AMD64   0x100000

◆ CONTEXT_CONTROL

#define CONTEXT_CONTROL   (CONTEXT_AMD64 | 0x1L)

◆ CONTEXT_DEBUG_REGISTERS

#define CONTEXT_DEBUG_REGISTERS   (CONTEXT_AMD64 | 0x10L)

◆ CONTEXT_EXCEPTION_ACTIVE

#define CONTEXT_EXCEPTION_ACTIVE   0x8000000

◆ CONTEXT_EXCEPTION_REPORTING

#define CONTEXT_EXCEPTION_REPORTING   0x80000000

◆ CONTEXT_EXCEPTION_REQUEST

#define CONTEXT_EXCEPTION_REQUEST   0x40000000

◆ CONTEXT_FLOATING_POINT

#define CONTEXT_FLOATING_POINT   (CONTEXT_AMD64 | 0x8L)

◆ CONTEXT_FULL

◆ CONTEXT_INTEGER

#define CONTEXT_INTEGER   (CONTEXT_AMD64 | 0x2L)

◆ CONTEXT_SEGMENTS

#define CONTEXT_SEGMENTS   (CONTEXT_AMD64 | 0x4L)

◆ CONTEXT_SERVICE_ACTIVE

#define CONTEXT_SERVICE_ACTIVE   0x10000000

◆ CONTEXT_XSTATE

#define CONTEXT_XSTATE   (CONTEXT_AMD64 | 0x40L)

◆ DbgRaiseAssertionFailure

#define DbgRaiseAssertionFailure   __int2c

Definition at line 173 of file ke.h.

◆ DISPATCH_LEVEL

#define DISPATCH_LEVEL   2

◆ DRS_LEVEL

#define DRS_LEVEL   14

◆ EFLAG_SELECT

#define EFLAG_SELECT   (EFLAG_SIGN | EFLAG_ZERO)

◆ EFLAG_SIGN

#define EFLAG_SIGN   0x8000

◆ EFLAG_ZERO

#define EFLAG_ZERO   0x4000

◆ EXCEPTION_EXECUTE_FAULT

#define EXCEPTION_EXECUTE_FAULT   8

◆ EXCEPTION_READ_FAULT

#define EXCEPTION_READ_FAULT   0

◆ EXCEPTION_WRITE_FAULT

#define EXCEPTION_WRITE_FAULT   1

◆ FastFence

#define FastFence   __faststorefence

Definition at line 50 of file ke.h.

◆ HIGH_LEVEL

#define HIGH_LEVEL   15

◆ INITIAL_FPCSR

#define INITIAL_FPCSR   0x027f

◆ INITIAL_MXCSR

#define INITIAL_MXCSR   0x1f80

◆ IPI_LEVEL

#define IPI_LEVEL   14

◆ KeFlushIoBuffers

#define KeFlushIoBuffers (   _Mdl,
  _ReadOperation,
  _DmaOperation 
)

Definition at line 170 of file ke.h.

◆ KeGetDcacheFillSize

#define KeGetDcacheFillSize ( )    1L

Definition at line 46 of file ke.h.

◆ KeMemoryBarrierWithoutFence

#define KeMemoryBarrierWithoutFence ( )    _ReadWriteBarrier()

Definition at line 66 of file ke.h.

◆ KeQueryInterruptTime

#define KeQueryInterruptTime ( )    (*(volatile ULONG64*)SharedInterruptTime)

Definition at line 37 of file ke.h.

◆ KeQuerySystemTime

#define KeQuerySystemTime (   CurrentCount)    *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime

Definition at line 40 of file ke.h.

◆ KeQueryTickCount

#define KeQueryTickCount (   CurrentCount)    *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount

Definition at line 43 of file ke.h.

◆ KeRaiseIrql

#define KeRaiseIrql (   a,
  b 
)    *(b) = KfRaiseIrql(a)

Definition at line 102 of file ke.h.

◆ KERNEL_LARGE_STACK_COMMIT

#define KERNEL_LARGE_STACK_COMMIT   KERNEL_STACK_SIZE

◆ KERNEL_LARGE_STACK_SIZE

#define KERNEL_LARGE_STACK_SIZE   0x12000

◆ KERNEL_MCA_EXCEPTION_STACK_SIZE

#define KERNEL_MCA_EXCEPTION_STACK_SIZE   0x2000

◆ KERNEL_STACK_SIZE

#define KERNEL_STACK_SIZE   0x6000

◆ KI_USER_SHARED_DATA

#define KI_USER_SHARED_DATA   0xFFFFF78000000000ULL

◆ LFENCE_ACQUIRE

#define LFENCE_ACQUIRE ( )    LoadFence()

Definition at line 54 of file ke.h.

◆ LoadFence

#define LoadFence   _mm_lfence

Definition at line 51 of file ke.h.

◆ LOW_LEVEL

#define LOW_LEVEL   0

◆ MemoryBarrier

#define MemoryBarrier   __faststorefence

Definition at line 49 of file ke.h.

◆ MemoryFence

#define MemoryFence   _mm_mfence

Definition at line 52 of file ke.h.

◆ PAGE_SHIFT

#define PAGE_SHIFT   12L

◆ PAGE_SIZE

#define PAGE_SIZE   0x1000

◆ PASSIVE_LEVEL

#define PASSIVE_LEVEL   0

◆ PAUSE_PROCESSOR

#define PAUSE_PROCESSOR   YieldProcessor();

◆ PCR_MAJOR_VERSION

#define PCR_MAJOR_VERSION   1

Definition at line 287 of file ke.h.

◆ PCR_MINOR_VERSION

#define PCR_MINOR_VERSION   1

Definition at line 286 of file ke.h.

◆ POWER_LEVEL

#define POWER_LEVEL   14

◆ PROFILE_LEVEL

#define PROFILE_LEVEL   15

◆ SharedInterruptTime

#define SharedInterruptTime   (KI_USER_SHARED_DATA + 0x8)

◆ SharedSystemTime

#define SharedSystemTime   (KI_USER_SHARED_DATA + 0x14)

◆ SharedTickCount

#define SharedTickCount   (KI_USER_SHARED_DATA + 0x320)

◆ SharedUserData

◆ StoreFence

#define StoreFence   _mm_sfence

Definition at line 53 of file ke.h.

◆ YieldProcessor

#define YieldProcessor   _mm_pause

Definition at line 48 of file ke.h.

Typedef Documentation

◆ KPCR

typedef struct _KPCR KPCR

◆ PKPCR

typedef struct _KPCR * PKPCR

◆ PXMM_SAVE_AREA32

Definition at line 35 of file ke.h.

◆ XMM_SAVE_AREA32

Definition at line 35 of file ke.h.

Function Documentation

◆ $if() [1/2]

$if ( _WDMDDK_  )

Kernel definitions for AMD64

Definition at line 1 of file ke.h.

31 {
32  ULONG Dummy;
struct _KFLOATING_SAVE KFLOATING_SAVE
struct _KFLOATING_SAVE * PKFLOATING_SAVE
unsigned int ULONG
Definition: retypes.h:1

◆ $if() [2/2]

$endif $if ( _NTDDK_  )

Definition at line 176 of file ke.h.

215  {
216  ULONG64 P1Home;
217  ULONG64 P2Home;
218  ULONG64 P3Home;
219  ULONG64 P4Home;
220  ULONG64 P5Home;
221  ULONG64 P6Home;
222  ULONG ContextFlags;
223  ULONG MxCsr;
224  USHORT SegCs;
225  USHORT SegDs;
226  USHORT SegEs;
227  USHORT SegFs;
228  USHORT SegGs;
229  USHORT SegSs;
230  ULONG EFlags;
231  ULONG64 Dr0;
232  ULONG64 Dr1;
233  ULONG64 Dr2;
234  ULONG64 Dr3;
235  ULONG64 Dr6;
236  ULONG64 Dr7;
237  ULONG64 Rax;
238  ULONG64 Rcx;
239  ULONG64 Rdx;
240  ULONG64 Rbx;
241  ULONG64 Rsp;
242  ULONG64 Rbp;
243  ULONG64 Rsi;
244  ULONG64 Rdi;
245  ULONG64 R8;
246  ULONG64 R9;
247  ULONG64 R10;
248  ULONG64 R11;
249  ULONG64 R12;
250  ULONG64 R13;
251  ULONG64 R14;
252  ULONG64 R15;
253  ULONG64 Rip;
254  union {
255  XMM_SAVE_AREA32 FltSave;
256  struct {
257  M128A Header[2];
258  M128A Legacy[8];
259  M128A Xmm0;
260  M128A Xmm1;
261  M128A Xmm2;
262  M128A Xmm3;
263  M128A Xmm4;
264  M128A Xmm5;
265  M128A Xmm6;
266  M128A Xmm7;
267  M128A Xmm8;
268  M128A Xmm9;
269  M128A Xmm10;
270  M128A Xmm11;
271  M128A Xmm12;
272  M128A Xmm13;
273  M128A Xmm14;
274  M128A Xmm15;
275  } DUMMYSTRUCTNAME;
276  } DUMMYUNIONNAME;
277  M128A VectorRegister[26];
278  ULONG64 VectorControl;
279  ULONG64 DebugControl;
280  ULONG64 LastBranchToRip;
281  ULONG64 LastBranchFromRip;
282  ULONG64 LastExceptionToRip;
283  ULONG64 LastExceptionFromRip;
284 } CONTEXT;
M128A
Definition: ketypes.h:918
#define DUMMYUNIONNAME
Definition: ntbasedef.h:32
Definition: Header.h:8
unsigned __int64 ULONG64
Definition: imports.h:198
struct _CONTEXT CONTEXT
unsigned short USHORT
Definition: pedump.c:61
XSAVE_FORMAT XMM_SAVE_AREA32
Definition: ke.h:35
unsigned int ULONG
Definition: retypes.h:1
#define DUMMYSTRUCTNAME
Definition: ntbasedef.h:58

◆ _Always_()

_Always_ ( _Post_satisfies_(return<=0)  )

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( HIGH_LEVEL  )

Definition at line 68 of file ke.h.

73 {
74  return (KIRQL)__readcr8();
75 }
__INTRIN_INLINE unsigned long __readcr8(void)
Definition: intrin_x86.h:1735
UCHAR KIRQL
Definition: env_spec_w32.h:591

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 104 of file ke.h.

111 {
112  return KfRaiseIrql(DISPATCH_LEVEL);
113 }
#define DISPATCH_LEVEL
NTKERNELAPI KIRQL NTAPI KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187

◆ _Kernel_requires_resource_held_()

_Kernel_requires_resource_held_ ( FloatState  )

Definition at line 145 of file ke.h.

150 {
151  UNREFERENCED_PARAMETER(FloatSave);
152  return STATUS_SUCCESS;
153 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ _Kernel_requires_resource_not_held_()

_Kernel_requires_resource_not_held_ ( FloatState  )

Definition at line 133 of file ke.h.

138 {
139  UNREFERENCED_PARAMETER(FloatSave);
140  return STATUS_SUCCESS;
141 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ _Success_()

_Success_ ( )

◆ KeGetCurrentProcessorIndex()

FORCEINLINE ULONG KeGetCurrentProcessorIndex ( VOID  )

Definition at line 158 of file ke.h.

159 {
160  return __readgsdword(0x1a4);
161 }

◆ KeGetCurrentProcessorNumber()

◆ KeGetCurrentThread()

FORCEINLINE PKTHREAD KeGetCurrentThread ( VOID  )

Definition at line 124 of file ke.h.

125 {
126  return (struct _KTHREAD *)__readgsqword(0x188);
127 }

◆ KeGetPcr()

FORCEINLINE PKPCR KeGetPcr ( VOID  )

Definition at line 327 of file ke.h.

328 {
329  return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
330 }
Definition: ke.h:289
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by KeGetCurrentProcessorNumber(), KeGetCurrentThread(), KeQueryInterruptHandler(), and KeRegisterInterruptHandler().

◆ KeMemoryBarrier()

◆ KeRaiseIrqlToSynchLevel()

FORCEINLINE KIRQL KeRaiseIrqlToSynchLevel ( VOID  )

Definition at line 117 of file ke.h.

118 {
119  return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2
120 }
NTKERNELAPI KIRQL NTAPI KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187

Variable Documentation

◆ CONTEXT

Definition at line 284 of file ke.h.

◆ KFLOATING_SAVE

Definition at line 33 of file ke.h.

◆ PKFLOATING_SAVE

Definition at line 33 of file ke.h.