mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
Update KPROCESS structure to latest version and document all its fields on the Wiki page. Move Kernel Structures to ke.h from ps.h, remove stuff from ntifs.h that shouldnt be there
svn path=/trunk/; revision=15027
This commit is contained in:
parent
b36a075a86
commit
5267e6247e
13 changed files with 253 additions and 280 deletions
|
@ -179,6 +179,38 @@ typedef struct _KIRQ_TRAPFRAME
|
||||||
ULONG Eflags;
|
ULONG Eflags;
|
||||||
} KIRQ_TRAPFRAME, *PKIRQ_TRAPFRAME;
|
} KIRQ_TRAPFRAME, *PKIRQ_TRAPFRAME;
|
||||||
|
|
||||||
|
typedef struct _KGDTENTRY {
|
||||||
|
USHORT LimitLow;
|
||||||
|
USHORT BaseLow;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
UCHAR BaseMid;
|
||||||
|
UCHAR Flags1;
|
||||||
|
UCHAR Flags2;
|
||||||
|
UCHAR BaseHi;
|
||||||
|
} Bytes;
|
||||||
|
struct {
|
||||||
|
ULONG BaseMid : 8;
|
||||||
|
ULONG Type : 5;
|
||||||
|
ULONG Dpl : 2;
|
||||||
|
ULONG Pres : 1;
|
||||||
|
ULONG LimitHi : 4;
|
||||||
|
ULONG Sys : 1;
|
||||||
|
ULONG Reserved_0 : 1;
|
||||||
|
ULONG Default_Big : 1;
|
||||||
|
ULONG Granularity : 1;
|
||||||
|
ULONG BaseHi : 8;
|
||||||
|
} Bits;
|
||||||
|
} HighWord;
|
||||||
|
} KGDTENTRY, *PKGDTENTRY;
|
||||||
|
|
||||||
|
typedef struct _KIDTENTRY {
|
||||||
|
USHORT Offset;
|
||||||
|
USHORT Selector;
|
||||||
|
USHORT Access;
|
||||||
|
USHORT ExtendedOffset;
|
||||||
|
} KIDTENTRY, *PKIDTENTRY;
|
||||||
|
|
||||||
extern ULONG Ke386CacheAlignment;
|
extern ULONG Ke386CacheAlignment;
|
||||||
|
|
||||||
struct _KPCR;
|
struct _KPCR;
|
||||||
|
|
|
@ -29,6 +29,191 @@
|
||||||
|
|
||||||
#include "arch/ke.h"
|
#include "arch/ke.h"
|
||||||
|
|
||||||
|
/* INTERNAL KERNEL TYPES ****************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASM__
|
||||||
|
|
||||||
|
#ifndef __USE_W32API
|
||||||
|
|
||||||
|
typedef struct _KPROCESS *PKPROCESS;
|
||||||
|
|
||||||
|
#endif /* __USE_W32API */
|
||||||
|
|
||||||
|
typedef struct _HARDWARE_PTE_X86 {
|
||||||
|
ULONG Valid : 1;
|
||||||
|
ULONG Write : 1;
|
||||||
|
ULONG Owner : 1;
|
||||||
|
ULONG WriteThrough : 1;
|
||||||
|
ULONG CacheDisable : 1;
|
||||||
|
ULONG Accessed : 1;
|
||||||
|
ULONG Dirty : 1;
|
||||||
|
ULONG LargePage : 1;
|
||||||
|
ULONG Global : 1;
|
||||||
|
ULONG CopyOnWrite : 1;
|
||||||
|
ULONG Prototype : 1;
|
||||||
|
ULONG reserved : 1;
|
||||||
|
ULONG PageFrameNumber : 20;
|
||||||
|
} HARDWARE_PTE_X86, *PHARDWARE_PTE_X86;
|
||||||
|
|
||||||
|
typedef struct _WOW64_PROCESS
|
||||||
|
{
|
||||||
|
PVOID Wow64;
|
||||||
|
} WOW64_PROCESS, *PWOW64_PROCESS;
|
||||||
|
|
||||||
|
#include <pshpack1.h>
|
||||||
|
|
||||||
|
typedef struct _KTHREAD
|
||||||
|
{
|
||||||
|
/* For waiting on thread exit */
|
||||||
|
DISPATCHER_HEADER DispatcherHeader; /* 00 */
|
||||||
|
|
||||||
|
/* List of mutants owned by the thread */
|
||||||
|
LIST_ENTRY MutantListHead; /* 10 */
|
||||||
|
PVOID InitialStack; /* 18 */
|
||||||
|
ULONG_PTR StackLimit; /* 1C */
|
||||||
|
|
||||||
|
/* Pointer to the thread's environment block in user memory */
|
||||||
|
struct _TEB *Teb; /* 20 */
|
||||||
|
|
||||||
|
/* Pointer to the thread's TLS array */
|
||||||
|
PVOID TlsArray; /* 24 */
|
||||||
|
PVOID KernelStack; /* 28 */
|
||||||
|
UCHAR DebugActive; /* 2C */
|
||||||
|
|
||||||
|
/* Thread state (one of THREAD_STATE_xxx constants below) */
|
||||||
|
UCHAR State; /* 2D */
|
||||||
|
BOOLEAN Alerted[2]; /* 2E */
|
||||||
|
UCHAR Iopl; /* 30 */
|
||||||
|
UCHAR NpxState; /* 31 */
|
||||||
|
CHAR Saturation; /* 32 */
|
||||||
|
CHAR Priority; /* 33 */
|
||||||
|
KAPC_STATE ApcState; /* 34 */
|
||||||
|
ULONG ContextSwitches; /* 4C */
|
||||||
|
LONG WaitStatus; /* 50 */
|
||||||
|
KIRQL WaitIrql; /* 54 */
|
||||||
|
CHAR WaitMode; /* 55 */
|
||||||
|
UCHAR WaitNext; /* 56 */
|
||||||
|
UCHAR WaitReason; /* 57 */
|
||||||
|
union { /* 58 */
|
||||||
|
PKWAIT_BLOCK WaitBlockList; /* 58 */
|
||||||
|
PKGATE GateObject; /* 58 */
|
||||||
|
}; /* 58 */
|
||||||
|
LIST_ENTRY WaitListEntry; /* 5C */
|
||||||
|
ULONG WaitTime; /* 64 */
|
||||||
|
CHAR BasePriority; /* 68 */
|
||||||
|
UCHAR DecrementCount; /* 69 */
|
||||||
|
UCHAR PriorityDecrement; /* 6A */
|
||||||
|
CHAR Quantum; /* 6B */
|
||||||
|
KWAIT_BLOCK WaitBlock[4]; /* 6C */
|
||||||
|
PVOID LegoData; /* CC */
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
USHORT KernelApcDisable;
|
||||||
|
USHORT SpecialApcDisable;
|
||||||
|
};
|
||||||
|
ULONG CombinedApcDisable; /* D0 */
|
||||||
|
};
|
||||||
|
KAFFINITY UserAffinity; /* D4 */
|
||||||
|
UCHAR SystemAffinityActive;/* D8 */
|
||||||
|
UCHAR PowerState; /* D9 */
|
||||||
|
UCHAR NpxIrql; /* DA */
|
||||||
|
UCHAR Pad[1]; /* DB */
|
||||||
|
PVOID ServiceTable; /* DC */
|
||||||
|
PKQUEUE Queue; /* E0 */
|
||||||
|
KSPIN_LOCK ApcQueueLock; /* E4 */
|
||||||
|
KTIMER Timer; /* E8 */
|
||||||
|
LIST_ENTRY QueueListEntry; /* 110 */
|
||||||
|
KAFFINITY Affinity; /* 118 */
|
||||||
|
UCHAR Preempted; /* 11C */
|
||||||
|
UCHAR ProcessReadyQueue; /* 11D */
|
||||||
|
UCHAR KernelStackResident; /* 11E */
|
||||||
|
UCHAR NextProcessor; /* 11F */
|
||||||
|
PVOID CallbackStack; /* 120 */
|
||||||
|
struct _W32THREAD *Win32Thread; /* 124 */
|
||||||
|
struct _KTRAP_FRAME *TrapFrame; /* 128 */
|
||||||
|
PKAPC_STATE ApcStatePointer[2]; /* 12C */
|
||||||
|
UCHAR EnableStackSwap; /* 134 */
|
||||||
|
UCHAR LargeStack; /* 135 */
|
||||||
|
UCHAR ResourceIndex; /* 136 */
|
||||||
|
UCHAR PreviousMode; /* 137 */
|
||||||
|
ULONG KernelTime; /* 138 */
|
||||||
|
ULONG UserTime; /* 13C */
|
||||||
|
KAPC_STATE SavedApcState; /* 140 */
|
||||||
|
UCHAR Alertable; /* 158 */
|
||||||
|
UCHAR ApcStateIndex; /* 159 */
|
||||||
|
UCHAR ApcQueueable; /* 15A */
|
||||||
|
UCHAR AutoAlignment; /* 15B */
|
||||||
|
PVOID StackBase; /* 15C */
|
||||||
|
KAPC SuspendApc; /* 160 */
|
||||||
|
KSEMAPHORE SuspendSemaphore; /* 190 */
|
||||||
|
LIST_ENTRY ThreadListEntry; /* 1A4 */
|
||||||
|
CHAR FreezeCount; /* 1AC */
|
||||||
|
UCHAR SuspendCount; /* 1AD */
|
||||||
|
UCHAR IdealProcessor; /* 1AE */
|
||||||
|
UCHAR DisableBoost; /* 1AF */
|
||||||
|
UCHAR QuantumReset; /* 1B0 */
|
||||||
|
} KTHREAD;
|
||||||
|
|
||||||
|
#include <poppack.h>
|
||||||
|
|
||||||
|
typedef struct _KEXECUTE_OPTIONS
|
||||||
|
{
|
||||||
|
UCHAR ExecuteDisable:1;
|
||||||
|
UCHAR ExecuteEnable:1;
|
||||||
|
UCHAR DisableThunkEmulation:1;
|
||||||
|
UCHAR Permanent:1;
|
||||||
|
UCHAR ExecuteDispatchEnable:1;
|
||||||
|
UCHAR ImageDispatchEnable:1;
|
||||||
|
UCHAR Spare:2;
|
||||||
|
} KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME: KPROCESS
|
||||||
|
* DESCRIPTION: Internal Kernel Process Structure.
|
||||||
|
* PORTABILITY: Architecture Dependent.
|
||||||
|
* KERNEL VERSION: 5.2
|
||||||
|
* DOCUMENTATION: http://reactos.com/wiki/index.php/KPROCESS
|
||||||
|
*/
|
||||||
|
typedef struct _KPROCESS
|
||||||
|
{
|
||||||
|
DISPATCHER_HEADER Header; /* 000 */
|
||||||
|
LIST_ENTRY ProfileListHead; /* 010 */
|
||||||
|
PHYSICAL_ADDRESS DirectoryTableBase; /* 018 */
|
||||||
|
KGDTENTRY LdtDescriptor; /* 020 */
|
||||||
|
KIDTENTRY Int21Descriptor; /* 028 */
|
||||||
|
USHORT IopmOffset; /* 030 */
|
||||||
|
UCHAR Iopl; /* 032 */
|
||||||
|
UCHAR Unused; /* 033 */
|
||||||
|
ULONG ActiveProcessors; /* 034 */
|
||||||
|
ULONG KernelTime; /* 038 */
|
||||||
|
ULONG UserTime; /* 03C */
|
||||||
|
LIST_ENTRY ReadyListHead; /* 040 */
|
||||||
|
LIST_ENTRY SwapListEntry; /* 048 */
|
||||||
|
PVOID VdmTrapcHandler; /* 04C */
|
||||||
|
LIST_ENTRY ThreadListHead; /* 050 */
|
||||||
|
KSPIN_LOCK ProcessLock; /* 058 */
|
||||||
|
KAFFINITY Affinity; /* 05C */
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
ULONG AutoAlignment:1; /* 060.0 */
|
||||||
|
ULONG DisableBoost:1; /* 060.1 */
|
||||||
|
ULONG DisableQuantum:1; /* 060.2 */
|
||||||
|
ULONG ReservedFlags:29; /* 060.3 */
|
||||||
|
};
|
||||||
|
ULONG ProcessFlags; /* 060 */
|
||||||
|
};
|
||||||
|
CHAR BasePriority; /* 064 */
|
||||||
|
CHAR QuantumReset; /* 065 */
|
||||||
|
UCHAR State; /* 066 */
|
||||||
|
UCHAR ThreadSeed; /* 067 */
|
||||||
|
UCHAR PowerState; /* 068 */
|
||||||
|
UCHAR IdealNode; /* 069 */
|
||||||
|
UCHAR Visited; /* 06A */
|
||||||
|
KEXECUTE_OPTIONS Flags; /* 06B */
|
||||||
|
ULONG StackCount; /* 06C */
|
||||||
|
LIST_ENTRY ProcessListEntry; /* 070 */
|
||||||
|
} KPROCESS;
|
||||||
|
|
||||||
/* INTERNAL KERNEL FUNCTIONS ************************************************/
|
/* INTERNAL KERNEL FUNCTIONS ************************************************/
|
||||||
|
|
||||||
#ifdef __USE_W32API
|
#ifdef __USE_W32API
|
||||||
|
@ -36,9 +221,6 @@ struct _KPROCESS* KeGetCurrentProcess(VOID);
|
||||||
VOID KeSetGdtSelector(ULONG Entry, ULONG Value1, ULONG Value2);
|
VOID KeSetGdtSelector(ULONG Entry, ULONG Value1, ULONG Value2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __ASM__
|
|
||||||
|
|
||||||
struct _KTHREAD;
|
|
||||||
struct _KIRQ_TRAPFRAME;
|
struct _KIRQ_TRAPFRAME;
|
||||||
struct _KPCR;
|
struct _KPCR;
|
||||||
struct _KPRCB;
|
struct _KPRCB;
|
||||||
|
@ -82,6 +264,10 @@ typedef enum _KTHREAD_STATE {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __USE_W32API
|
||||||
|
#define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->ProcessorNumber)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* threadsch.c ********************************************************************/
|
/* threadsch.c ********************************************************************/
|
||||||
|
|
||||||
/* Thread Scheduler Functions */
|
/* Thread Scheduler Functions */
|
||||||
|
|
|
@ -42,110 +42,12 @@ struct _EJOB;
|
||||||
#ifndef __ASM__
|
#ifndef __ASM__
|
||||||
|
|
||||||
#include <internal/mm.h>
|
#include <internal/mm.h>
|
||||||
|
#include <internal/ke.h>
|
||||||
#include <napi/teb.h>
|
#include <napi/teb.h>
|
||||||
|
|
||||||
#ifndef KeGetCurrentProcessorNumber
|
|
||||||
#define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->ProcessorNumber)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern LCID PsDefaultThreadLocaleId;
|
extern LCID PsDefaultThreadLocaleId;
|
||||||
extern LCID PsDefaultSystemLocaleId;
|
extern LCID PsDefaultSystemLocaleId;
|
||||||
|
|
||||||
#include <pshpack1.h>
|
|
||||||
|
|
||||||
typedef struct _KTHREAD
|
|
||||||
{
|
|
||||||
/* For waiting on thread exit */
|
|
||||||
DISPATCHER_HEADER DispatcherHeader; /* 00 */
|
|
||||||
|
|
||||||
/* List of mutants owned by the thread */
|
|
||||||
LIST_ENTRY MutantListHead; /* 10 */
|
|
||||||
PVOID InitialStack; /* 18 */
|
|
||||||
ULONG_PTR StackLimit; /* 1C */
|
|
||||||
|
|
||||||
/* Pointer to the thread's environment block in user memory */
|
|
||||||
PTEB Teb; /* 20 */
|
|
||||||
|
|
||||||
/* Pointer to the thread's TLS array */
|
|
||||||
PVOID TlsArray; /* 24 */
|
|
||||||
PVOID KernelStack; /* 28 */
|
|
||||||
UCHAR DebugActive; /* 2C */
|
|
||||||
|
|
||||||
/* Thread state (one of THREAD_STATE_xxx constants below) */
|
|
||||||
UCHAR State; /* 2D */
|
|
||||||
BOOLEAN Alerted[2]; /* 2E */
|
|
||||||
UCHAR Iopl; /* 30 */
|
|
||||||
UCHAR NpxState; /* 31 */
|
|
||||||
CHAR Saturation; /* 32 */
|
|
||||||
CHAR Priority; /* 33 */
|
|
||||||
KAPC_STATE ApcState; /* 34 */
|
|
||||||
ULONG ContextSwitches; /* 4C */
|
|
||||||
LONG WaitStatus; /* 50 */
|
|
||||||
KIRQL WaitIrql; /* 54 */
|
|
||||||
CHAR WaitMode; /* 55 */
|
|
||||||
UCHAR WaitNext; /* 56 */
|
|
||||||
UCHAR WaitReason; /* 57 */
|
|
||||||
union { /* 58 */
|
|
||||||
PKWAIT_BLOCK WaitBlockList; /* 58 */
|
|
||||||
PKGATE GateObject; /* 58 */
|
|
||||||
}; /* 58 */
|
|
||||||
LIST_ENTRY WaitListEntry; /* 5C */
|
|
||||||
ULONG WaitTime; /* 64 */
|
|
||||||
CHAR BasePriority; /* 68 */
|
|
||||||
UCHAR DecrementCount; /* 69 */
|
|
||||||
UCHAR PriorityDecrement; /* 6A */
|
|
||||||
CHAR Quantum; /* 6B */
|
|
||||||
KWAIT_BLOCK WaitBlock[4]; /* 6C */
|
|
||||||
PVOID LegoData; /* CC */
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
USHORT KernelApcDisable;
|
|
||||||
USHORT SpecialApcDisable;
|
|
||||||
};
|
|
||||||
ULONG CombinedApcDisable; /* D0 */
|
|
||||||
};
|
|
||||||
KAFFINITY UserAffinity; /* D4 */
|
|
||||||
UCHAR SystemAffinityActive;/* D8 */
|
|
||||||
UCHAR PowerState; /* D9 */
|
|
||||||
UCHAR NpxIrql; /* DA */
|
|
||||||
UCHAR Pad[1]; /* DB */
|
|
||||||
SSDT_ENTRY *ServiceTable; /* DC */
|
|
||||||
PKQUEUE Queue; /* E0 */
|
|
||||||
KSPIN_LOCK ApcQueueLock; /* E4 */
|
|
||||||
KTIMER Timer; /* E8 */
|
|
||||||
LIST_ENTRY QueueListEntry; /* 110 */
|
|
||||||
KAFFINITY Affinity; /* 118 */
|
|
||||||
UCHAR Preempted; /* 11C */
|
|
||||||
UCHAR ProcessReadyQueue; /* 11D */
|
|
||||||
UCHAR KernelStackResident; /* 11E */
|
|
||||||
UCHAR NextProcessor; /* 11F */
|
|
||||||
PVOID CallbackStack; /* 120 */
|
|
||||||
struct _W32THREAD *Win32Thread; /* 124 */
|
|
||||||
struct _KTRAP_FRAME *TrapFrame; /* 128 */
|
|
||||||
PKAPC_STATE ApcStatePointer[2]; /* 12C */
|
|
||||||
UCHAR EnableStackSwap; /* 134 */
|
|
||||||
UCHAR LargeStack; /* 135 */
|
|
||||||
UCHAR ResourceIndex; /* 136 */
|
|
||||||
UCHAR PreviousMode; /* 137 */
|
|
||||||
ULONG KernelTime; /* 138 */
|
|
||||||
ULONG UserTime; /* 13C */
|
|
||||||
KAPC_STATE SavedApcState; /* 140 */
|
|
||||||
UCHAR Alertable; /* 158 */
|
|
||||||
UCHAR ApcStateIndex; /* 159 */
|
|
||||||
UCHAR ApcQueueable; /* 15A */
|
|
||||||
UCHAR AutoAlignment; /* 15B */
|
|
||||||
PVOID StackBase; /* 15C */
|
|
||||||
KAPC SuspendApc; /* 160 */
|
|
||||||
KSEMAPHORE SuspendSemaphore; /* 190 */
|
|
||||||
LIST_ENTRY ThreadListEntry; /* 1A4 */
|
|
||||||
CHAR FreezeCount; /* 1AC */
|
|
||||||
UCHAR SuspendCount; /* 1AD */
|
|
||||||
UCHAR IdealProcessor; /* 1AE */
|
|
||||||
UCHAR DisableBoost; /* 1AF */
|
|
||||||
} KTHREAD;
|
|
||||||
|
|
||||||
#include <poppack.h>
|
|
||||||
|
|
||||||
/* Top level irp definitions. */
|
/* Top level irp definitions. */
|
||||||
#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
|
#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
|
||||||
#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
|
#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
|
||||||
|
@ -219,105 +121,12 @@ typedef struct _ETHREAD
|
||||||
|
|
||||||
#include <poppack.h>
|
#include <poppack.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef __USE_W32API
|
#ifndef __USE_W32API
|
||||||
|
|
||||||
typedef struct _ETHREAD *PETHREAD;
|
typedef struct _ETHREAD *PETHREAD;
|
||||||
|
|
||||||
#endif /* __USE_W32API */
|
#endif /* __USE_W32API */
|
||||||
|
|
||||||
|
|
||||||
typedef struct _KPROCESS
|
|
||||||
{
|
|
||||||
/* So it's possible to wait for the process to terminate */
|
|
||||||
DISPATCHER_HEADER DispatcherHeader; /* 000 */
|
|
||||||
/*
|
|
||||||
* Presumably a list of profile objects associated with this process,
|
|
||||||
* currently unused.
|
|
||||||
*/
|
|
||||||
LIST_ENTRY ProfileListHead; /* 010 */
|
|
||||||
/*
|
|
||||||
* We use the first member of this array to hold the physical address of
|
|
||||||
* the page directory for this process.
|
|
||||||
*/
|
|
||||||
PHYSICAL_ADDRESS DirectoryTableBase; /* 018 */
|
|
||||||
/*
|
|
||||||
* Presumably a descriptor for the process's LDT, currently unused.
|
|
||||||
*/
|
|
||||||
ULONG LdtDescriptor[2]; /* 020 */
|
|
||||||
/*
|
|
||||||
* Virtual Dos Machine flag.
|
|
||||||
*/
|
|
||||||
ULONG NtVdmFlag; /* 028 */
|
|
||||||
ULONG VdmUnused; /* 02C */
|
|
||||||
/* Is the i/o permission map enabled for the process. */
|
|
||||||
USHORT IopmOffset; /* 030 */
|
|
||||||
/*
|
|
||||||
* Presumably I/O privilege level to be used for this process, currently
|
|
||||||
* unused.
|
|
||||||
*/
|
|
||||||
UCHAR Iopl; /* 032 */
|
|
||||||
/* Set if this process is a virtual dos machine? */
|
|
||||||
UCHAR VdmFlag; /* 033 */
|
|
||||||
/* Bitmask of the processors being used by this process's threads? */
|
|
||||||
ULONG ActiveProcessors; /* 034 */
|
|
||||||
/* Aggregate of the time this process's threads have spent in kernel mode? */
|
|
||||||
ULONG KernelTime; /* 038 */
|
|
||||||
/* Aggregate of the time this process's threads have spent in user mode? */
|
|
||||||
ULONG UserTime; /* 03C */
|
|
||||||
/* List of this process's threads that are ready for execution? */
|
|
||||||
LIST_ENTRY ReadyListHead; /* 040 */
|
|
||||||
/* List of this process's threads that have their stacks swapped out? */
|
|
||||||
LIST_ENTRY SwapListEntry; /* 048 */
|
|
||||||
/* List of this process's threads? */
|
|
||||||
LIST_ENTRY ThreadListHead; /* 050 */
|
|
||||||
/* Maybe a lock for this data structure, the type is assumed. */
|
|
||||||
KSPIN_LOCK ProcessLock; /* 058 */
|
|
||||||
/* Default affinity mask for this process's threads? */
|
|
||||||
ULONG Affinity; /* 05C */
|
|
||||||
/* Count of the stacks allocated for this process's threads? */
|
|
||||||
USHORT StackCount; /* 060 */
|
|
||||||
/* Base priority for this process's threads? */
|
|
||||||
KPRIORITY BasePriority; /* 062 */
|
|
||||||
/* Default quantum for this process's threads */
|
|
||||||
UCHAR ThreadQuantum; /* 063 */
|
|
||||||
/* Unknown. */
|
|
||||||
UCHAR AutoAlignment; /* 064 */
|
|
||||||
/* Process execution state, currently either active or terminated. */
|
|
||||||
UCHAR State; /* 065 */
|
|
||||||
/* Seed for generating thread ids for this process's threads? */
|
|
||||||
UCHAR ThreadSeed; /* 066 */
|
|
||||||
/* Disable priority boosts? */
|
|
||||||
UCHAR DisableBoost; /* 067 */
|
|
||||||
} KPROCESS;
|
|
||||||
|
|
||||||
#ifndef __USE_W32API
|
|
||||||
|
|
||||||
typedef struct _KPROCESS *PKPROCESS;
|
|
||||||
|
|
||||||
typedef struct _HARDWARE_PTE_X86 {
|
|
||||||
ULONG Valid : 1;
|
|
||||||
ULONG Write : 1;
|
|
||||||
ULONG Owner : 1;
|
|
||||||
ULONG WriteThrough : 1;
|
|
||||||
ULONG CacheDisable : 1;
|
|
||||||
ULONG Accessed : 1;
|
|
||||||
ULONG Dirty : 1;
|
|
||||||
ULONG LargePage : 1;
|
|
||||||
ULONG Global : 1;
|
|
||||||
ULONG CopyOnWrite : 1;
|
|
||||||
ULONG Prototype : 1;
|
|
||||||
ULONG reserved : 1;
|
|
||||||
ULONG PageFrameNumber : 20;
|
|
||||||
} HARDWARE_PTE_X86, *PHARDWARE_PTE_X86;
|
|
||||||
|
|
||||||
typedef struct _WOW64_PROCESS
|
|
||||||
{
|
|
||||||
PVOID Wow64;
|
|
||||||
} WOW64_PROCESS, *PWOW64_PROCESS;
|
|
||||||
|
|
||||||
#endif /* __USE_W32API */
|
|
||||||
|
|
||||||
struct _EPROCESS
|
struct _EPROCESS
|
||||||
{
|
{
|
||||||
/* Microkernel specific process state. */
|
/* Microkernel specific process state. */
|
||||||
|
|
|
@ -444,8 +444,9 @@ KiQuantumEnd(VOID)
|
||||||
|
|
||||||
/* Check if Quantum expired */
|
/* Check if Quantum expired */
|
||||||
if (CurrentThread->Quantum <= 0) {
|
if (CurrentThread->Quantum <= 0) {
|
||||||
/* Set the new Quantum */
|
|
||||||
CurrentThread->Quantum = Process->ThreadQuantum;
|
/* Reset the new Quantum */
|
||||||
|
CurrentThread->Quantum = CurrentThread->QuantumReset;
|
||||||
|
|
||||||
/* Calculate new priority */
|
/* Calculate new priority */
|
||||||
OldPriority = CurrentThread->Priority;
|
OldPriority = CurrentThread->Priority;
|
||||||
|
|
|
@ -259,7 +259,7 @@ KeSetEventBoostPriority(IN PKEVENT Event,
|
||||||
if ARGUMENT_PRESENT(Thread) *Thread = WaitingThread;
|
if ARGUMENT_PRESENT(Thread) *Thread = WaitingThread;
|
||||||
|
|
||||||
/* Reset the Quantum and Unwait the Thread */
|
/* Reset the Quantum and Unwait the Thread */
|
||||||
WaitingThread->Quantum = WaitingThread->ApcState.Process->ThreadQuantum;
|
WaitingThread->Quantum = WaitingThread->QuantumReset;
|
||||||
KiAbortWaitThread(WaitingThread, STATUS_SUCCESS, EVENT_INCREMENT);
|
KiAbortWaitThread(WaitingThread, STATUS_SUCCESS, EVENT_INCREMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ NtSetLdtEntries (ULONG Selector1,
|
||||||
|
|
||||||
KeAcquireSpinLock(&LdtLock, &oldIrql);
|
KeAcquireSpinLock(&LdtLock, &oldIrql);
|
||||||
|
|
||||||
LdtDescriptor = (PUSHORT) &KeGetCurrentProcess()->LdtDescriptor[0];
|
LdtDescriptor = (PUSHORT) &KeGetCurrentProcess()->LdtDescriptor;
|
||||||
LdtBase = LdtDescriptor[1] |
|
LdtBase = LdtDescriptor[1] |
|
||||||
((LdtDescriptor[2] & 0xff) << 16) |
|
((LdtDescriptor[2] & 0xff) << 16) |
|
||||||
((LdtDescriptor[3] & ~0xff) << 16);
|
((LdtDescriptor[3] & ~0xff) << 16);
|
||||||
|
|
|
@ -688,7 +688,8 @@ KeV86Exception(ULONG ExceptionNr, PKTRAP_FRAME Tf, ULONG address)
|
||||||
|
|
||||||
VTf = (PKV86M_TRAP_FRAME)Tf;
|
VTf = (PKV86M_TRAP_FRAME)Tf;
|
||||||
|
|
||||||
if(KeGetCurrentProcess()->NtVdmFlag)
|
/* FIXME: This should use ->VdmObjects */
|
||||||
|
if(KeGetCurrentProcess()->Unused)
|
||||||
{
|
{
|
||||||
VTf->regs->PStatus = (PNTSTATUS) ExceptionNr;
|
VTf->regs->PStatus = (PNTSTATUS) ExceptionNr;
|
||||||
if(ExceptionNr != 14) return 1;
|
if(ExceptionNr != 14) return 1;
|
||||||
|
@ -799,7 +800,8 @@ KeV86Exception(ULONG ExceptionNr, PKTRAP_FRAME Tf, ULONG address)
|
||||||
Tf->ErrorCode);
|
Tf->ErrorCode);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
if(KeGetCurrentProcess()->NtVdmFlag)
|
/* FIXME: This should use ->VdmObjects */
|
||||||
|
if(KeGetCurrentProcess()->Unused)
|
||||||
{
|
{
|
||||||
VTf->regs->PStatus = (PNTSTATUS) STATUS_NONCONTINUABLE_EXCEPTION;
|
VTf->regs->PStatus = (PNTSTATUS) STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -64,9 +64,12 @@ NTSTATUS STDCALL NtVdmControl(ULONG ControlCode,
|
||||||
sizeof(KV86M_REGISTERS));
|
sizeof(KV86M_REGISTERS));
|
||||||
if(!NT_SUCCESS(ret)) return ret;
|
if(!NT_SUCCESS(ret)) return ret;
|
||||||
|
|
||||||
KeGetCurrentProcess()->NtVdmFlag = 1;
|
/* FIXME: This should use ->VdmObjects */
|
||||||
|
KeGetCurrentProcess()->Unused = 1;
|
||||||
Ki386RetToV86Mode(&V86Registers, &V86Registers);
|
Ki386RetToV86Mode(&V86Registers, &V86Registers);
|
||||||
KeGetCurrentProcess()->NtVdmFlag = 0;
|
|
||||||
|
/* FIXME: This should use ->VdmObjects */
|
||||||
|
KeGetCurrentProcess()->Unused = 0;
|
||||||
|
|
||||||
ret = MmCopyToCaller(ControlData,
|
ret = MmCopyToCaller(ControlData,
|
||||||
&V86Registers,
|
&V86Registers,
|
||||||
|
|
|
@ -272,7 +272,7 @@ KiUnblockThread(PKTHREAD Thread,
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Thread->Quantum = Thread->ApcState.Process->ThreadQuantum;
|
Thread->Quantum = Thread->QuantumReset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WaitStatus != NULL) {
|
if (WaitStatus != NULL) {
|
||||||
|
@ -771,7 +771,8 @@ KeInitializeThread(PKPROCESS Process,
|
||||||
/* Setup scheduler Fields based on Parent */
|
/* Setup scheduler Fields based on Parent */
|
||||||
DPRINT("Thread context created, setting Scheduler Data\n");
|
DPRINT("Thread context created, setting Scheduler Data\n");
|
||||||
Thread->BasePriority = Process->BasePriority;
|
Thread->BasePriority = Process->BasePriority;
|
||||||
Thread->Quantum = Process->ThreadQuantum;
|
Thread->Quantum = Process->QuantumReset;
|
||||||
|
Thread->QuantumReset = Process->QuantumReset;
|
||||||
Thread->Affinity = Process->Affinity;
|
Thread->Affinity = Process->Affinity;
|
||||||
Thread->Priority = Process->BasePriority;
|
Thread->Priority = Process->BasePriority;
|
||||||
Thread->UserAffinity = Process->Affinity;
|
Thread->UserAffinity = Process->Affinity;
|
||||||
|
|
|
@ -73,7 +73,7 @@ KeInitializeProcess(PKPROCESS Process,
|
||||||
DPRINT("KeInitializeProcess. Process: %x, DirectoryTableBase: %x\n", Process, DirectoryTableBase);
|
DPRINT("KeInitializeProcess. Process: %x, DirectoryTableBase: %x\n", Process, DirectoryTableBase);
|
||||||
|
|
||||||
/* Initialize the Dispatcher Header */
|
/* Initialize the Dispatcher Header */
|
||||||
KeInitializeDispatcherHeader(&Process->DispatcherHeader,
|
KeInitializeDispatcherHeader(&Process->Header,
|
||||||
ProcessObject,
|
ProcessObject,
|
||||||
sizeof(KPROCESS),
|
sizeof(KPROCESS),
|
||||||
FALSE);
|
FALSE);
|
||||||
|
@ -81,7 +81,7 @@ KeInitializeProcess(PKPROCESS Process,
|
||||||
/* Initialize Scheduler Data, Disable Alignment Faults and Set the PDE */
|
/* Initialize Scheduler Data, Disable Alignment Faults and Set the PDE */
|
||||||
Process->Affinity = Affinity;
|
Process->Affinity = Affinity;
|
||||||
Process->BasePriority = Priority;
|
Process->BasePriority = Priority;
|
||||||
Process->ThreadQuantum = 6;
|
Process->QuantumReset = 6;
|
||||||
Process->DirectoryTableBase = DirectoryTableBase;
|
Process->DirectoryTableBase = DirectoryTableBase;
|
||||||
Process->AutoAlignment = TRUE;
|
Process->AutoAlignment = TRUE;
|
||||||
Process->IopmOffset = 0xFFFF;
|
Process->IopmOffset = 0xFFFF;
|
||||||
|
@ -104,11 +104,11 @@ KeSetProcess(PKPROCESS Process,
|
||||||
OldIrql = KeAcquireDispatcherDatabaseLock();
|
OldIrql = KeAcquireDispatcherDatabaseLock();
|
||||||
|
|
||||||
/* Get Old State */
|
/* Get Old State */
|
||||||
OldState = Process->DispatcherHeader.SignalState;
|
OldState = Process->Header.SignalState;
|
||||||
|
|
||||||
/* Signal the Process */
|
/* Signal the Process */
|
||||||
Process->DispatcherHeader.SignalState = TRUE;
|
Process->Header.SignalState = TRUE;
|
||||||
if ((OldState == 0) && IsListEmpty(&Process->DispatcherHeader.WaitListHead) != TRUE) {
|
if ((OldState == 0) && IsListEmpty(&Process->Header.WaitListHead) != TRUE) {
|
||||||
|
|
||||||
/* Satisfy waits */
|
/* Satisfy waits */
|
||||||
KiWaitTest((PVOID)Process, Increment);
|
KiWaitTest((PVOID)Process, Increment);
|
||||||
|
@ -198,19 +198,12 @@ KiAttachProcess(PKTHREAD Thread, PKPROCESS Process, KIRQL ApcLock, PRKAPC_STATE
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
KiSwapProcess(PKPROCESS NewProcess, PKPROCESS OldProcess)
|
KiSwapProcess(PKPROCESS NewProcess,
|
||||||
|
PKPROCESS OldProcess)
|
||||||
{
|
{
|
||||||
//PKPCR Pcr = KeGetCurrentKpcr();
|
/* FIXME: Write this in ASM. Much easier */
|
||||||
|
|
||||||
/* Do they have an LDT? */
|
|
||||||
if ((NewProcess->LdtDescriptor) || (OldProcess->LdtDescriptor)) {
|
|
||||||
|
|
||||||
/* FIXME : SWitch GDT/IDT */
|
|
||||||
}
|
|
||||||
DPRINT("Switching CR3 to: %x\n", NewProcess->DirectoryTableBase.u.LowPart);
|
DPRINT("Switching CR3 to: %x\n", NewProcess->DirectoryTableBase.u.LowPart);
|
||||||
Ke386SetPageTableDirectory(NewProcess->DirectoryTableBase.u.LowPart);
|
Ke386SetPageTableDirectory(NewProcess->DirectoryTableBase.u.LowPart);
|
||||||
|
|
||||||
/* FIXME: Set IopmOffset in TSS */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -203,7 +203,7 @@ NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process)
|
||||||
|
|
||||||
DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process);
|
DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process);
|
||||||
|
|
||||||
LdtDescriptor = (PUSHORT) &Process->Pcb.LdtDescriptor[0];
|
LdtDescriptor = (PUSHORT) &Process->Pcb.LdtDescriptor;
|
||||||
LdtBase = LdtDescriptor[1] |
|
LdtBase = LdtDescriptor[1] |
|
||||||
((LdtDescriptor[2] & 0xff) << 16) |
|
((LdtDescriptor[2] & 0xff) << 16) |
|
||||||
((LdtDescriptor[3] & ~0xff) << 16);
|
((LdtDescriptor[3] & ~0xff) << 16);
|
||||||
|
|
|
@ -182,14 +182,12 @@ PsInitProcessManagment(VOID)
|
||||||
|
|
||||||
PsIdleProcess->Pcb.Affinity = 0xFFFFFFFF;
|
PsIdleProcess->Pcb.Affinity = 0xFFFFFFFF;
|
||||||
PsIdleProcess->Pcb.IopmOffset = 0xffff;
|
PsIdleProcess->Pcb.IopmOffset = 0xffff;
|
||||||
PsIdleProcess->Pcb.LdtDescriptor[0] = 0;
|
|
||||||
PsIdleProcess->Pcb.LdtDescriptor[1] = 0;
|
|
||||||
PsIdleProcess->Pcb.BasePriority = PROCESS_PRIO_IDLE;
|
PsIdleProcess->Pcb.BasePriority = PROCESS_PRIO_IDLE;
|
||||||
PsIdleProcess->Pcb.ThreadQuantum = 6;
|
PsIdleProcess->Pcb.QuantumReset = 6;
|
||||||
InitializeListHead(&PsIdleProcess->Pcb.ThreadListHead);
|
InitializeListHead(&PsIdleProcess->Pcb.ThreadListHead);
|
||||||
InitializeListHead(&PsIdleProcess->ThreadListHead);
|
InitializeListHead(&PsIdleProcess->ThreadListHead);
|
||||||
InitializeListHead(&PsIdleProcess->ProcessListEntry);
|
InitializeListHead(&PsIdleProcess->ProcessListEntry);
|
||||||
KeInitializeDispatcherHeader(&PsIdleProcess->Pcb.DispatcherHeader,
|
KeInitializeDispatcherHeader(&PsIdleProcess->Pcb.Header,
|
||||||
ProcessObject,
|
ProcessObject,
|
||||||
sizeof(EPROCESS),
|
sizeof(EPROCESS),
|
||||||
FALSE);
|
FALSE);
|
||||||
|
@ -217,14 +215,13 @@ PsInitProcessManagment(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* System threads may run on any processor. */
|
/* System threads may run on any processor. */
|
||||||
|
RtlZeroMemory(PsInitialSystemProcess, sizeof(EPROCESS));
|
||||||
PsInitialSystemProcess->Pcb.Affinity = 0xFFFFFFFF;
|
PsInitialSystemProcess->Pcb.Affinity = 0xFFFFFFFF;
|
||||||
PsInitialSystemProcess->Pcb.IopmOffset = 0xffff;
|
PsInitialSystemProcess->Pcb.IopmOffset = 0xffff;
|
||||||
PsInitialSystemProcess->Pcb.LdtDescriptor[0] = 0;
|
|
||||||
PsInitialSystemProcess->Pcb.LdtDescriptor[1] = 0;
|
|
||||||
PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL;
|
PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL;
|
||||||
PsInitialSystemProcess->Pcb.ThreadQuantum = 6;
|
PsInitialSystemProcess->Pcb.QuantumReset = 6;
|
||||||
InitializeListHead(&PsInitialSystemProcess->Pcb.ThreadListHead);
|
InitializeListHead(&PsInitialSystemProcess->Pcb.ThreadListHead);
|
||||||
KeInitializeDispatcherHeader(&PsInitialSystemProcess->Pcb.DispatcherHeader,
|
KeInitializeDispatcherHeader(&PsInitialSystemProcess->Pcb.Header,
|
||||||
ProcessObject,
|
ProcessObject,
|
||||||
sizeof(EPROCESS),
|
sizeof(EPROCESS),
|
||||||
FALSE);
|
FALSE);
|
||||||
|
@ -234,8 +231,6 @@ PsInitProcessManagment(VOID)
|
||||||
&PsInitialSystemProcess->AddressSpace);
|
&PsInitialSystemProcess->AddressSpace);
|
||||||
|
|
||||||
KeInitializeEvent(&PsInitialSystemProcess->LockEvent, SynchronizationEvent, FALSE);
|
KeInitializeEvent(&PsInitialSystemProcess->LockEvent, SynchronizationEvent, FALSE);
|
||||||
PsInitialSystemProcess->LockCount = 0;
|
|
||||||
PsInitialSystemProcess->LockOwner = NULL;
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
KProcess->DirectoryTableBase =
|
KProcess->DirectoryTableBase =
|
||||||
|
|
|
@ -464,7 +464,6 @@ extern PACL SeSystemDefaultDacl;
|
||||||
|
|
||||||
typedef PVOID PEJOB;
|
typedef PVOID PEJOB;
|
||||||
typedef PVOID OPLOCK, *POPLOCK;
|
typedef PVOID OPLOCK, *POPLOCK;
|
||||||
typedef PVOID PWOW64_PROCESS;
|
|
||||||
|
|
||||||
typedef struct _CACHE_MANAGER_CALLBACKS *PCACHE_MANAGER_CALLBACKS;
|
typedef struct _CACHE_MANAGER_CALLBACKS *PCACHE_MANAGER_CALLBACKS;
|
||||||
typedef struct _EPROCESS_QUOTA_BLOCK *PEPROCESS_QUOTA_BLOCK;
|
typedef struct _EPROCESS_QUOTA_BLOCK *PEPROCESS_QUOTA_BLOCK;
|
||||||
|
@ -530,22 +529,6 @@ typedef enum _OBJECT_INFO_CLASS {
|
||||||
ObjectProtectionInfo
|
ObjectProtectionInfo
|
||||||
} OBJECT_INFO_CLASS;
|
} OBJECT_INFO_CLASS;
|
||||||
|
|
||||||
typedef struct _HARDWARE_PTE_X86 {
|
|
||||||
ULONG Valid : 1;
|
|
||||||
ULONG Write : 1;
|
|
||||||
ULONG Owner : 1;
|
|
||||||
ULONG WriteThrough : 1;
|
|
||||||
ULONG CacheDisable : 1;
|
|
||||||
ULONG Accessed : 1;
|
|
||||||
ULONG Dirty : 1;
|
|
||||||
ULONG LargePage : 1;
|
|
||||||
ULONG Global : 1;
|
|
||||||
ULONG CopyOnWrite : 1;
|
|
||||||
ULONG Prototype : 1;
|
|
||||||
ULONG reserved : 1;
|
|
||||||
ULONG PageFrameNumber : 20;
|
|
||||||
} HARDWARE_PTE_X86, *PHARDWARE_PTE_X86;
|
|
||||||
|
|
||||||
typedef struct _KAPC_STATE {
|
typedef struct _KAPC_STATE {
|
||||||
LIST_ENTRY ApcListHead[2];
|
LIST_ENTRY ApcListHead[2];
|
||||||
PKPROCESS Process;
|
PKPROCESS Process;
|
||||||
|
@ -554,38 +537,6 @@ typedef struct _KAPC_STATE {
|
||||||
BOOLEAN UserApcPending;
|
BOOLEAN UserApcPending;
|
||||||
} KAPC_STATE, *PKAPC_STATE, *__restrict PRKAPC_STATE;
|
} KAPC_STATE, *PKAPC_STATE, *__restrict PRKAPC_STATE;
|
||||||
|
|
||||||
typedef struct _KGDTENTRY {
|
|
||||||
USHORT LimitLow;
|
|
||||||
USHORT BaseLow;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
UCHAR BaseMid;
|
|
||||||
UCHAR Flags1;
|
|
||||||
UCHAR Flags2;
|
|
||||||
UCHAR BaseHi;
|
|
||||||
} Bytes;
|
|
||||||
struct {
|
|
||||||
ULONG BaseMid : 8;
|
|
||||||
ULONG Type : 5;
|
|
||||||
ULONG Dpl : 2;
|
|
||||||
ULONG Pres : 1;
|
|
||||||
ULONG LimitHi : 4;
|
|
||||||
ULONG Sys : 1;
|
|
||||||
ULONG Reserved_0 : 1;
|
|
||||||
ULONG Default_Big : 1;
|
|
||||||
ULONG Granularity : 1;
|
|
||||||
ULONG BaseHi : 8;
|
|
||||||
} Bits;
|
|
||||||
} HighWord;
|
|
||||||
} KGDTENTRY, *PKGDTENTRY;
|
|
||||||
|
|
||||||
typedef struct _KIDTENTRY {
|
|
||||||
USHORT Offset;
|
|
||||||
USHORT Selector;
|
|
||||||
USHORT Access;
|
|
||||||
USHORT ExtendedOffset;
|
|
||||||
} KIDTENTRY, *PKIDTENTRY;
|
|
||||||
|
|
||||||
#if (VER_PRODUCTBUILD >= 2600)
|
#if (VER_PRODUCTBUILD >= 2600)
|
||||||
|
|
||||||
typedef struct _MMSUPPORT_FLAGS {
|
typedef struct _MMSUPPORT_FLAGS {
|
||||||
|
|
Loading…
Reference in a new issue