ReactOS 0.4.15-dev-7958-gcd0bb1a
ntoskrnl.h
Go to the documentation of this file.
1#pragma once
2
3#include <section_attribs.h>
4
5
6
7#ifdef _NTOSKRNL_
8
9#ifndef _ARM_
10#define KeGetCurrentThread _KeGetCurrentThread
11#define KeGetPreviousMode _KeGetPreviousMode
12#endif
13#undef PsGetCurrentProcess
14#define PsGetCurrentProcess _PsGetCurrentProcess
15
16#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
17
18//
19// We are very lazy on ARM -- we just import intrinsics
20// Question: Why wasn't this done for x86 too? (see fastintrlck.asm)
21//
22#define InterlockedDecrement _InterlockedDecrement
23#define InterlockedDecrement16 _InterlockedDecrement16
24#define InterlockedIncrement _InterlockedIncrement
25#define InterlockedIncrement16 _InterlockedIncrement16
26#define InterlockedCompareExchange _InterlockedCompareExchange
27#define InterlockedCompareExchange16 _InterlockedCompareExchange16
28#define InterlockedCompareExchange64 _InterlockedCompareExchange64
29#define InterlockedExchange _InterlockedExchange
30#define InterlockedExchangeAdd _InterlockedExchangeAdd
31#define InterlockedOr _InterlockedOr
32#define InterlockedAnd _InterlockedAnd
33
34//
35// Use inlined versions of fast/guarded mutex routines
36//
37#define ExEnterCriticalRegionAndAcquireFastMutexUnsafe _ExEnterCriticalRegionAndAcquireFastMutexUnsafe
38#define ExReleaseFastMutexUnsafeAndLeaveCriticalRegion _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion
39#define ExAcquireFastMutex _ExAcquireFastMutex
40#define ExReleaseFastMutex _ExReleaseFastMutex
41#define ExAcquireFastMutexUnsafe _ExAcquireFastMutexUnsafe
42#define ExReleaseFastMutexUnsafe _ExReleaseFastMutexUnsafe
43#define ExTryToAcquireFastMutex _ExTryToAcquireFastMutex
44
45#define KeInitializeGuardedMutex _KeInitializeGuardedMutex
46#define KeAcquireGuardedMutex _KeAcquireGuardedMutex
47#define KeReleaseGuardedMutex _KeReleaseGuardedMutex
48#define KeAcquireGuardedMutexUnsafe _KeAcquireGuardedMutexUnsafe
49#define KeReleaseGuardedMutexUnsafe _KeReleaseGuardedMutexUnsafe
50#define KeTryToAcquireGuardedMutex _KeTryToAcquireGuardedMutex
51
52#include "tag.h"
53#include "ke.h"
54#include "ob.h"
55#include "mm.h"
56#include "ex.h"
57#include "cm.h"
58#include "ps.h"
59#include "cc.h"
60#include "io.h"
61#include "po.h"
62#include "se.h"
63#include "ldr.h"
64#ifndef _WINKD_
65#include "kd.h"
66#endif
67#include "kd64.h"
68#include "fsrtl.h"
69#include "lpc.h"
70#include "rtl.h"
71#include "dbgk.h"
72#include "spinlock.h"
73#include "test.h"
74#include "inbv.h"
75#include "vdm.h"
76#include "hal.h"
77#include "hdl.h"
78#include "icif.h"
79#include "arch/intrin_i.h"
80#include <arbiter.h>
81
82/*
83 * Use IsPointerOffset to test whether a pointer should be interpreted as an offset
84 * or as a pointer
85 */
86#if defined(_X86_) || defined(_M_AMD64) || defined(_MIPS_) || defined(_PPC_) || defined(_ARM_)
87
88/* for x86 and x86-64 the MSB is 1 so we can simply test on that */
89#define IsPointerOffset(Ptr) ((LONG_PTR)(Ptr) >= 0)
90
91#elif defined(_IA64_)
92
93/* on Itanium if the 24 most significant bits are set, we're not dealing with
94 offsets anymore. */
95#define IsPointerOffset(Ptr) (((ULONG_PTR)(Ptr) & 0xFFFFFF0000000000ULL) == 0)
96
97#else
98#error IsPointerOffset() needs to be defined for this architecture
99#endif
100
101#endif
102
103#ifndef _WIN64
105
108C_ASSERT(FIELD_OFFSET(KTHREAD, SystemAffinityActive) == FIELD_OFFSET(KTHREAD, WaitBlock) + FIELD_OFFSET(KWAIT_BLOCK, SpareByte));
110C_ASSERT(FIELD_OFFSET(KTHREAD, ApcQueueable) == FIELD_OFFSET(KTHREAD, ApcState.UserApcPending) + 1);
111C_ASSERT(FIELD_OFFSET(KTHREAD, ApcQueueable) == 0x3F);
112C_ASSERT(FIELD_OFFSET(KTHREAD, NextProcessor) == 0x40);
113C_ASSERT(FIELD_OFFSET(KTHREAD, DeferredProcessor) == 0x41);
114C_ASSERT(FIELD_OFFSET(KTHREAD, AdjustReason) == 0x42);
117C_ASSERT(FIELD_OFFSET(KTHREAD, SwapBusy) == 0x05D);
120C_ASSERT(FIELD_OFFSET(KTHREAD, ThreadFlags) == 0x0A0);
121C_ASSERT(FIELD_OFFSET(KTHREAD, WaitBlock) == 0x0A8);
122C_ASSERT(FIELD_OFFSET(KTHREAD, WaitBlockFill0) == 0x0A8);
123C_ASSERT(FIELD_OFFSET(KTHREAD, QueueListEntry) == 0x108);
126C_ASSERT(FIELD_OFFSET(KTHREAD, ResourceIndex) == FIELD_OFFSET(KTHREAD, WaitBlock) + 2*sizeof(KWAIT_BLOCK) + FIELD_OFFSET(KWAIT_BLOCK, SpareByte));
127C_ASSERT(FIELD_OFFSET(KTHREAD, LargeStack) == FIELD_OFFSET(KTHREAD, WaitBlock) + 3*sizeof(KWAIT_BLOCK) + FIELD_OFFSET(KWAIT_BLOCK, SpareByte));
131C_ASSERT(FIELD_OFFSET(KTHREAD, FreezeCount) == FIELD_OFFSET(KTHREAD, SavedApcState.UserApcPending) + 1);
132C_ASSERT(FIELD_OFFSET(KTHREAD, Quantum) == FIELD_OFFSET(KTHREAD, SuspendApc.SpareByte0));
133C_ASSERT(FIELD_OFFSET(KTHREAD, QuantumReset) == FIELD_OFFSET(KTHREAD, SuspendApc.SpareByte1));
134C_ASSERT(FIELD_OFFSET(KTHREAD, KernelTime) == FIELD_OFFSET(KTHREAD, SuspendApc.SpareLong0));
135C_ASSERT(FIELD_OFFSET(KTHREAD, TlsArray) == FIELD_OFFSET(KTHREAD, SuspendApc.SystemArgument1));
136C_ASSERT(FIELD_OFFSET(KTHREAD, LegoData) == FIELD_OFFSET(KTHREAD, SuspendApc.SystemArgument2));
138C_ASSERT(sizeof(KTHREAD) == 0x1B8);
139
141
169
170/* Platform specific checks */
175#endif
static SERVICE_TABLE_ENTRYW ServiceTable[2]
Definition: eventlog.c:24
_Out_ PKIRQL Irql
Definition: csq.h:179
#define C_ASSERT(e)
Definition: intsafe.h:73
#define KTHREAD_INITIAL_STACK
Definition: asm.h:50
#define SIZEOF_FX_SAVE_AREA
Definition: asm.h:29
#define KPCR_SELF
Definition: asm.h:64
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:453
#define KPCR_SYSTEM_CALLS
Definition: asm.h:196
#define KPCR_PRCB_NEXT_THREAD
Definition: asm.h:179
#define KPCR_PRCB_DPC_STACK
Definition: asm.h:199
#define KPROCESS_DIRECTORY_TABLE_BASE
Definition: asm.h:122
#define KTHREAD_SERVICE_TABLE
Definition: asm.h:106
#define KPCR_PRCB_DATA
Definition: asm.h:177
#define KPCR_PRCB_DEFERRED_READY_LIST_HEAD
Definition: asm.h:208
#define KTHREAD_APCSTATE_PROCESS
Definition: asm.h:95
#define KPCR_PRCB_DPC_LAST_COUNT
Definition: asm.h:204
#define KPCR_PRCB_DPC_REQUEST_RATE
Definition: asm.h:201
#define KPCR_PRCB_IDLE_SCHEDULE
Definition: asm.h:207
#define KPCR_PRCB_DPC_COUNT
Definition: asm.h:198
#define KTHREAD_TEB
Definition: asm.h:92
#define KPCR_PRCB_PRCB_LOCK
Definition: asm.h:184
#define KPROCESS_IOPM_OFFSET
Definition: asm.h:127
#define KPCR_EXCEPTION_LIST
Definition: asm.h:156
#define KPCR_CURRENT_THREAD
Definition: asm.h:178
#define KPCR_IDR
Definition: asm.h:168
#define KPCR_PRCB_TIMER_REQUEST
Definition: asm.h:205
#define KPCR_PRCB_MAXIMUM_DPC_QUEUE_DEPTH
Definition: asm.h:200
#define KPROCESS_LDT_DESCRIPTOR0
Definition: asm.h:123
#define KPCR_PRCB_DPC_INTERRUPT_REQUESTED
Definition: asm.h:202
#define KTHREAD_NPX_STATE
Definition: asm.h:100
#define KTSS_ESP0
Definition: asm.h:64
#define KPCR_PRCB_DPC_QUEUE_DEPTH
Definition: asm.h:197
#define KPCR_PRCB_QUANTUM_END
Definition: asm.h:206
#define KPCR_PRCB_POWER_STATE_IDLE_FUNCTION
Definition: asm.h:209
#define KTHREAD_PREVIOUS_MODE
Definition: asm.h:107
#define KTHREAD_KERNEL_STACK
Definition: asm.h:93
#define KPCR_IRQL
Definition: asm.h:165
#define KPCR_IRR
Definition: asm.h:166
#define KTHREAD_CALLBACK_STACK
Definition: asm.h:112
#define KTSS_IOMAPBASE
Definition: asm.h:83
#define KPCR_NPX_THREAD
Definition: asm.h:185
#define KTHREAD_TRAP_FRAME
Definition: asm.h:111
#define KPCR_PRCB_DPC_ROUTINE_ACTIVE
Definition: asm.h:203
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1765
Definition: ke.h:294
Definition: ketypes.h:844
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3034
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103