Part 1 of <many> ntoskrnl header cleanups

svn path=/trunk/; revision=17844
This commit is contained in:
Alex Ionescu 2005-09-13 23:28:21 +00:00
parent 10f2fdca23
commit 11272023e5
27 changed files with 644 additions and 361 deletions

View file

@ -147,6 +147,13 @@ typedef enum _KTHREAD_STATE
DeferredReady,
} KTHREAD_STATE, *PKTHREAD_STATE;
typedef enum _KPROCESS_STATE
{
ProcessInMemory,
ProcessOutOfMemory,
ProcessInTransition,
} KPROCESS_STATE, *PKPROCESS_STATE;
/* FUNCTION TYPES ************************************************************/
#ifdef NTOS_MODE_USER

View file

@ -56,6 +56,11 @@ extern NTSYSAPI POBJECT_TYPE PsProcessType;
#define PROCESS_PRIORITY_CLASS_BELOW_NORMAL 5
#define PROCESS_PRIORITY_CLASS_ABOVE_NORMAL 6
/* Process base priorities */
#define PROCESS_PRIORITY_IDLE 3
#define PROCESS_PRIORITY_NORMAL 8
#define PROCESS_PRIORITY_NORMAL_FOREGROUND 9
/* Global Flags */
#define FLG_STOP_ON_EXCEPTION 0x00000001
#define FLG_SHOW_LDR_SNAPS 0x00000002

View file

@ -200,6 +200,7 @@ NTSTATUS
ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation);
NTSTATUS
NTAPI
ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId);
VOID

View file

@ -416,6 +416,75 @@ KeRosGetStackFrames(
VOID
KiSetSystemTime(PLARGE_INTEGER NewSystemTime);
/* Emulate cli/sti instructions */
#define KV86M_EMULATE_CLI_STI (0x1)
/* Allow the v86 mode code to access i/o ports */
#define KV86M_ALLOW_IO_PORT_ACCESS (0x2)
typedef struct _KV86M_REGISTERS
{
/*
* General purpose registers
*/
ULONG Ebp;
ULONG Edi;
ULONG Esi;
ULONG Edx;
ULONG Ecx;
ULONG Ebx;
ULONG Eax;
ULONG Ds;
ULONG Es;
ULONG Fs;
ULONG Gs;
/*
* Control registers
*/
ULONG Eip;
ULONG Cs;
ULONG Eflags;
ULONG Esp;
ULONG Ss;
/*
* Control structures
*/
ULONG RecoveryAddress;
UCHAR RecoveryInstruction[4];
ULONG Vif;
ULONG Flags;
PNTSTATUS PStatus;
} KV86M_REGISTERS, *PKV86M_REGISTERS;
typedef struct _KV86M_TRAP_FRAME
{
KTRAP_FRAME Tf;
ULONG SavedExceptionStack;
/*
* These are put on the top of the stack by the routine that entered
* v86 mode so the exception handlers can find the control information
*/
struct _KV86M_REGISTERS* regs;
ULONG orig_ebp;
} KV86M_TRAP_FRAME, *PKV86M_TRAP_FRAME;
NTSTATUS
STDCALL
Ke386CallBios(
UCHAR Int,
PKV86M_REGISTERS Regs
);
ULONG
KeV86Exception(
ULONG ExceptionNr,
PKTRAP_FRAME Tf,
ULONG address
);
#define MAXIMUM_PROCESSORS 32
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_KE_H */

View file

@ -888,4 +888,13 @@ VOID MiStartPagerThread(VOID);
VOID MiStopPagerThread(VOID);
NTSTATUS FASTCALL
MiQueryVirtualMemory (IN HANDLE ProcessHandle,
IN PVOID Address,
IN CINT VirtualMemoryInformationClass,
OUT PVOID VirtualMemoryInformation,
IN ULONG Length,
OUT PULONG ResultLength);
#endif

View file

@ -10,105 +10,6 @@ struct _EJOB;
extern LCID PsDefaultThreadLocaleId;
extern LCID PsDefaultSystemLocaleId;
/* Top level irp definitions. */
#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
#define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
#define PROCESS_STATE_TERMINATED (1)
#define PROCESS_STATE_ACTIVE (2)
VOID PiInitDefaultLocale(VOID);
VOID PiInitProcessManager(VOID);
VOID PiShutdownProcessManager(VOID);
VOID PsInitThreadManagment(VOID);
VOID PsInitProcessManagment(VOID);
VOID PsInitIdleThread(VOID);
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus);
VOID PsTerminateCurrentThread(NTSTATUS ExitStatus);
VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus);
VOID PsReleaseThread(PETHREAD Thread);
VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext);
VOID PsBeginThreadWithContextInternal(VOID);
VOID PiKillMostProcesses(VOID);
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus);
VOID PiInitApcManagement(VOID);
VOID STDCALL PiDeleteThread(PVOID ObjectBody);
VOID PsReapThreads(VOID);
VOID PsInitializeThreadReaper(VOID);
VOID PsQueueThreadReap(PETHREAD Thread);
NTSTATUS
PsInitializeThread(PEPROCESS Process,
PETHREAD* ThreadPtr,
POBJECT_ATTRIBUTES ObjectAttributes,
KPROCESSOR_MODE AccessMode,
BOOLEAN First);
PACCESS_TOKEN STDCALL PsReferenceEffectiveToken(PETHREAD Thread,
PTOKEN_TYPE TokenType,
PUCHAR b,
PSECURITY_IMPERSONATION_LEVEL Level);
NTSTATUS STDCALL PsOpenTokenOfProcess(HANDLE ProcessHandle,
PACCESS_TOKEN* Token);
VOID
STDCALL
PspTerminateProcessThreads(PEPROCESS Process,
NTSTATUS ExitStatus);
NTSTATUS PsSuspendThread(PETHREAD Thread, PULONG PreviousCount);
NTSTATUS PsResumeThread(PETHREAD Thread, PULONG PreviousCount);
NTSTATUS
STDCALL
PspAssignPrimaryToken(PEPROCESS Process,
HANDLE TokenHandle);
VOID STDCALL PsExitSpecialApc(PKAPC Apc,
PKNORMAL_ROUTINE *NormalRoutine,
PVOID *NormalContext,
PVOID *SystemArgument1,
PVOID *SystemArgument2);
NTSTATUS
STDCALL
PspInitializeProcessSecurity(PEPROCESS Process,
PEPROCESS Parent OPTIONAL);
VOID
STDCALL
PspSystemThreadStartup(PKSTART_ROUTINE StartRoutine,
PVOID StartContext);
NTSTATUS
PsInitializeIdleOrFirstThread (
PEPROCESS Process,
PETHREAD* ThreadPtr,
PKSTART_ROUTINE StartRoutine,
KPROCESSOR_MODE AccessMode,
BOOLEAN First);
/*
* Internal thread priorities, added by Phillip Susi
* TODO: rebalence these to make use of all priorities... the ones above 16
* can not all be used right now
*/
#define PROCESS_PRIO_IDLE 3
#define PROCESS_PRIO_NORMAL 8
#define PROCESS_PRIO_HIGH 13
#define PROCESS_PRIO_RT 18
VOID STDCALL PiDeleteProcess(PVOID ObjectBody);
VOID
STDCALL
PspReapRoutine(PVOID Context);
VOID
STDCALL
PspExitThread(NTSTATUS ExitStatus);
extern LIST_ENTRY PspReaperListHead;
extern WORK_QUEUE_ITEM PspReaperWorkItem;
extern BOOLEAN PspReaping;
@ -119,38 +20,273 @@ extern FAST_MUTEX PspActiveProcessMutex;
extern LARGE_INTEGER ShortPsLockDelay, PsLockTimeout;
extern EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock;
/* Top level irp definitions. */
#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
#define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
#define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8
#define MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT 8
VOID
NTAPI
PiInitDefaultLocale(VOID);
VOID
NTAPI
PiInitProcessManager(VOID);
VOID
NTAPI
PiShutdownProcessManager(VOID);
VOID
NTAPI
PsInitThreadManagment(VOID);
VOID
NTAPI
PsInitProcessManagment(VOID);
VOID
NTAPI
PsInitIdleThread(VOID);
VOID
NTAPI
PiTerminateProcessThreads(
PEPROCESS Process,
NTSTATUS ExitStatus
);
VOID
NTAPI
PsTerminateCurrentThread(NTSTATUS ExitStatus);
VOID
NTAPI
PsTerminateOtherThread(
PETHREAD Thread,
NTSTATUS ExitStatus
);
VOID
NTAPI
PsReleaseThread(PETHREAD Thread);
VOID
NTAPI
PsBeginThread(
PKSTART_ROUTINE StartRoutine,
PVOID StartContext
);
VOID
NTAPI
PsBeginThreadWithContextInternal(VOID);
VOID
NTAPI
PiKillMostProcesses(VOID);
NTSTATUS
STDCALL
PiTerminateProcess(
PEPROCESS Process,
NTSTATUS ExitStatus
);
VOID
NTAPI
PiInitApcManagement(VOID);
VOID
STDCALL
PspTerminateThreadByPointer(PETHREAD Thread,
NTSTATUS ExitStatus);
PiDeleteThread(PVOID ObjectBody);
VOID PsUnfreezeOtherThread(PETHREAD Thread);
VOID PsFreezeOtherThread(PETHREAD Thread);
VOID PsFreezeProcessThreads(PEPROCESS Process);
VOID PsUnfreezeProcessThreads(PEPROCESS Process);
ULONG PsEnumThreadsByProcess(PEPROCESS Process);
PEPROCESS STDCALL PsGetNextProcess(PEPROCESS OldProcess);
VOID
NTAPI
PsReapThreads(VOID);
VOID
NTAPI
PsInitializeThreadReaper(VOID);
VOID
NTAPI
PsQueueThreadReap(PETHREAD Thread);
NTSTATUS
NTAPI
PsInitializeThread(
PEPROCESS Process,
PETHREAD* ThreadPtr,
POBJECT_ATTRIBUTES ObjectAttributes,
KPROCESSOR_MODE AccessMode,
BOOLEAN First
);
PACCESS_TOKEN
STDCALL
PsReferenceEffectiveToken(
PETHREAD Thread,
PTOKEN_TYPE TokenType,
PUCHAR b,
PSECURITY_IMPERSONATION_LEVEL Level
);
NTSTATUS
STDCALL
PsOpenTokenOfProcess(
HANDLE ProcessHandle,
PACCESS_TOKEN* Token
);
VOID
STDCALL
PspTerminateProcessThreads(
PEPROCESS Process,
NTSTATUS ExitStatus
);
NTSTATUS
NTAPI
PsSuspendThread(
PETHREAD Thread,
PULONG PreviousCount
);
NTSTATUS
NTAPI
PsResumeThread(
PETHREAD Thread,
PULONG PreviousCount
);
NTSTATUS
STDCALL
PspAssignPrimaryToken(
PEPROCESS Process,
HANDLE TokenHandle
);
VOID
STDCALL
PsExitSpecialApc(
PKAPC Apc,
PKNORMAL_ROUTINE *NormalRoutine,
PVOID *NormalContext,
PVOID *SystemArgument1,
PVOID *SystemArgument2
);
NTSTATUS
STDCALL
PspInitializeProcessSecurity(
PEPROCESS Process,
PEPROCESS Parent OPTIONAL
);
VOID
STDCALL
PspSystemThreadStartup(
PKSTART_ROUTINE StartRoutine,
PVOID StartContext
);
NTSTATUS
NTAPI
PsInitializeIdleOrFirstThread(
PEPROCESS Process,
PETHREAD* ThreadPtr,
PKSTART_ROUTINE StartRoutine,
KPROCESSOR_MODE AccessMode,
BOOLEAN First
);
VOID
STDCALL
PiDeleteProcess(PVOID ObjectBody);
VOID
STDCALL
PspReapRoutine(PVOID Context);
VOID
STDCALL
PspExitThread(NTSTATUS ExitStatus);
VOID
STDCALL
PspTerminateThreadByPointer(
PETHREAD Thread,
NTSTATUS ExitStatus
);
VOID
NTAPI
PsUnfreezeOtherThread(PETHREAD Thread);
VOID
NTAPI
PsFreezeOtherThread(PETHREAD Thread);
VOID
NTAPI
PsFreezeProcessThreads(PEPROCESS Process);
VOID
NTAPI
PsUnfreezeProcessThreads(PEPROCESS Process);
ULONG
NTAPI
PsEnumThreadsByProcess(PEPROCESS Process);
PEPROCESS
STDCALL
PsGetNextProcess(PEPROCESS OldProcess);
VOID
NTAPI
PsApplicationProcessorInit(VOID);
VOID
NTAPI
PsPrepareForApplicationProcessorInit(ULONG Id);
VOID STDCALL
VOID
STDCALL
PsIdleThreadMain(PVOID Context);
VOID STDCALL
PiSuspendThreadRundownRoutine(PKAPC Apc);
VOID STDCALL
PiSuspendThreadKernelRoutine(PKAPC Apc,
PKNORMAL_ROUTINE* NormalRoutine,
PVOID* NormalContext,
PVOID* SystemArgument1,
PVOID* SystemArguemnt2);
VOID STDCALL
PiSuspendThreadNormalRoutine(PVOID NormalContext,
PVOID SystemArgument1,
PVOID SystemArgument2);
VOID
STDCALL
PiSuspendThreadRundownRoutine(PKAPC Apc);
VOID
STDCALL
PiSuspendThreadKernelRoutine(
PKAPC Apc,
PKNORMAL_ROUTINE* NormalRoutine,
PVOID* NormalContext,
PVOID* SystemArgument1,
PVOID* SystemArguemnt2
);
VOID
STDCALL
PiSuspendThreadNormalRoutine(
PVOID NormalContext,
PVOID SystemArgument1,
PVOID SystemArgument2
);
VOID
NTAPI
PsInitialiseSuspendImplementation(VOID);
NTSTATUS
STDCALL
PspExitProcess(PEPROCESS Process);
@ -163,37 +299,52 @@ VOID
STDCALL
PspDeleteThread(PVOID ObjectBody);
extern LONG PiNrThreadsAwaitingReaping;
NTSTATUS
PsInitWin32Thread (PETHREAD Thread);
NTAPI
PsInitWin32Thread(PETHREAD Thread);
VOID
PsTerminateWin32Process (PEPROCESS Process);
NTAPI
PsTerminateWin32Process(PEPROCESS Process);
VOID
PsTerminateWin32Thread (PETHREAD Thread);
NTAPI
PsTerminateWin32Thread(PETHREAD Thread);
VOID
NTAPI
PsInitialiseW32Call(VOID);
VOID
STDCALL
PspRunCreateThreadNotifyRoutines(PETHREAD, BOOLEAN);
PspRunCreateThreadNotifyRoutines(
PETHREAD,
BOOLEAN
);
VOID
STDCALL
PspRunCreateProcessNotifyRoutines(PEPROCESS, BOOLEAN);
PspRunCreateProcessNotifyRoutines(
PEPROCESS,
BOOLEAN
);
VOID
STDCALL
PspRunLegoRoutine(IN PKTHREAD Thread);
VOID INIT_FUNCTION PsInitJobManagment(VOID);
VOID
NTAPI
INIT_FUNCTION
PsInitJobManagment(VOID);
VOID
STDCALL
PspInheritQuota(PEPROCESS Process, PEPROCESS ParentProcess);
PspInheritQuota(
PEPROCESS Process,
PEPROCESS ParentProcess
);
VOID
STDCALL
@ -214,17 +365,15 @@ NTSTATUS
STDCALL
PspGetSystemDllEntryPoints(VOID);
/* CLIENT ID */
NTSTATUS
NTAPI
PsLockProcess(
PEPROCESS Process,
BOOLEAN Timeout
);
NTSTATUS PsLockProcess(PEPROCESS Process, BOOLEAN Timeout);
VOID PsUnlockProcess(PEPROCESS Process);
#define ETHREAD_TO_KTHREAD(pEThread) (&(pEThread)->Tcb)
#define KTHREAD_TO_ETHREAD(pKThread) (CONTAINING_RECORD((pKThread), ETHREAD, Tcb))
#define EPROCESS_TO_KPROCESS(pEProcess) (&(pEProcess)->Pcb)
#define KPROCESS_TO_EPROCESS(pKProcess) (CONTAINING_RECORD((pKProcess), EPROCESS, Pcb))
#define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8
#define MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT 8
VOID
NTAPI
PsUnlockProcess(PEPROCESS Process);
#endif /* __INCLUDE_INTERNAL_PS_H */

View file

@ -83,114 +83,178 @@ extern PSECURITY_DESCRIPTOR SePublicOpenUnrestrictedSd;
extern PSECURITY_DESCRIPTOR SeSystemDefaultSd;
extern PSECURITY_DESCRIPTOR SeUnrestrictedSd;
/* Functions */
BOOLEAN SeInit1(VOID);
BOOLEAN SeInit2(VOID);
BOOLEAN SeInitSRM(VOID);
VOID SepInitLuid(VOID);
VOID SepInitPrivileges(VOID);
BOOLEAN SepInitSecurityIDs(VOID);
BOOLEAN SepInitDACLs(VOID);
BOOLEAN SepInitSDs(VOID);
VOID SeDeassignPrimaryToken(struct _EPROCESS *Process);
NTSTATUS STDCALL
SepCreateImpersonationTokenDacl(PTOKEN Token,
PTOKEN PrimaryToken,
PACL *Dacl);
VOID SepInitializeTokenImplementation(VOID);
PTOKEN STDCALL SepCreateSystemProcessToken(VOID);
NTSTATUS SeExchangePrimaryToken(struct _EPROCESS* Process,
PACCESS_TOKEN NewToken,
PACCESS_TOKEN* OldTokenP);
NTSTATUS
SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
ULONG PrivilegeCount,
KPROCESSOR_MODE PreviousMode,
PLUID_AND_ATTRIBUTES AllocatedMem,
ULONG AllocatedLength,
POOL_TYPE PoolType,
ULONG d,
PLUID_AND_ATTRIBUTES* Dest,
PULONG Length);
VOID
SeReleaseLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Privilege,
KPROCESSOR_MODE PreviousMode,
ULONG a);
BOOLEAN
NTAPI
SeInit1(VOID);
BOOLEAN
SepPrivilegeCheck(PTOKEN Token,
PLUID_AND_ATTRIBUTES Privileges,
ULONG PrivilegeCount,
ULONG PrivilegeControl,
KPROCESSOR_MODE PreviousMode);
NTAPI
SeInit2(VOID);
BOOLEAN
NTAPI
SeInitSRM(VOID);
VOID
NTAPI
SepInitLuid(VOID);
VOID
NTAPI
SepInitPrivileges(VOID);
BOOLEAN
NTAPI
SepInitSecurityIDs(VOID);
BOOLEAN
NTAPI
SepInitDACLs(VOID);
BOOLEAN
NTAPI
SepInitSDs(VOID);
VOID
NTAPI
SeDeassignPrimaryToken(struct _EPROCESS *Process);
NTSTATUS
STDCALL
SepDuplicateToken(PTOKEN Token,
POBJECT_ATTRIBUTES ObjectAttributes,
BOOLEAN EffectiveOnly,
TOKEN_TYPE TokenType,
SECURITY_IMPERSONATION_LEVEL Level,
KPROCESSOR_MODE PreviousMode,
PTOKEN* NewAccessToken);
NTSTATUS
SepCaptureSecurityQualityOfService(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
IN BOOLEAN CaptureIfKernel,
OUT PSECURITY_QUALITY_OF_SERVICE *CapturedSecurityQualityOfService,
OUT PBOOLEAN Present);
SepCreateImpersonationTokenDacl(
PTOKEN Token,
PTOKEN PrimaryToken,
PACL *Dacl
);
VOID
SepReleaseSecurityQualityOfService(IN PSECURITY_QUALITY_OF_SERVICE CapturedSecurityQualityOfService OPTIONAL,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel);
NTAPI
SepInitializeTokenImplementation(VOID);
PTOKEN
STDCALL
SepCreateSystemProcessToken(VOID);
NTSTATUS
SepCaptureSid(IN PSID InputSid,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
IN BOOLEAN CaptureIfKernel,
OUT PSID *CapturedSid);
VOID
SepReleaseSid(IN PSID CapturedSid,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel);
NTAPI
SeExchangePrimaryToken(
struct _EPROCESS* Process,
PACCESS_TOKEN NewToken,
PACCESS_TOKEN* OldTokenP
);
NTSTATUS
SepCaptureAcl(IN PACL InputAcl,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
IN BOOLEAN CaptureIfKernel,
OUT PACL *CapturedAcl);
NTAPI
SeCaptureLuidAndAttributesArray(
PLUID_AND_ATTRIBUTES Src,
ULONG PrivilegeCount,
KPROCESSOR_MODE PreviousMode,
PLUID_AND_ATTRIBUTES AllocatedMem,
ULONG AllocatedLength,
POOL_TYPE PoolType,
ULONG d,
PLUID_AND_ATTRIBUTES* Dest,
PULONG Length
);
VOID
SepReleaseAcl(IN PACL CapturedAcl,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel);
NTAPI
SeReleaseLuidAndAttributesArray(
PLUID_AND_ATTRIBUTES Privilege,
KPROCESSOR_MODE PreviousMode,
ULONG a
);
BOOLEAN
NTAPI
SepPrivilegeCheck(
PTOKEN Token,
PLUID_AND_ATTRIBUTES Privileges,
ULONG PrivilegeCount,
ULONG PrivilegeControl,
KPROCESSOR_MODE PreviousMode
);
NTSTATUS
STDCALL
SeDefaultObjectMethod(PVOID Object,
SECURITY_OPERATION_CODE OperationType,
SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR NewSecurityDescriptor,
PULONG ReturnLength,
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
POOL_TYPE PoolType,
PGENERIC_MAPPING GenericMapping);
SepDuplicateToken(
PTOKEN Token,
POBJECT_ATTRIBUTES ObjectAttributes,
BOOLEAN EffectiveOnly,
TOKEN_TYPE TokenType,
SECURITY_IMPERSONATION_LEVEL Level,
KPROCESSOR_MODE PreviousMode,
PTOKEN* NewAccessToken
);
NTSTATUS
NTAPI
SepCaptureSecurityQualityOfService(
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
IN BOOLEAN CaptureIfKernel,
OUT PSECURITY_QUALITY_OF_SERVICE *CapturedSecurityQualityOfService,
OUT PBOOLEAN Present
);
VOID
NTAPI
SepReleaseSecurityQualityOfService(
IN PSECURITY_QUALITY_OF_SERVICE CapturedSecurityQualityOfService OPTIONAL,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel
);
NTSTATUS
NTAPI
SepCaptureSid(
IN PSID InputSid,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
IN BOOLEAN CaptureIfKernel,
OUT PSID *CapturedSid
);
VOID
NTAPI
SepReleaseSid(
IN PSID CapturedSid,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel
);
NTSTATUS
NTAPI
SepCaptureAcl(
IN PACL InputAcl,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
IN BOOLEAN CaptureIfKernel,
OUT PACL *CapturedAcl
);
VOID
NTAPI
SepReleaseAcl(
IN PACL CapturedAcl,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel
);
NTSTATUS
STDCALL
SeDefaultObjectMethod(
PVOID Object,
SECURITY_OPERATION_CODE OperationType,
SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR NewSecurityDescriptor,
PULONG ReturnLength,
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
POOL_TYPE PoolType,
PGENERIC_MAPPING GenericMapping
);
#define SepAcquireTokenLockExclusive(Token) \
do { \

View file

@ -1,48 +1,39 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_TEST_H
#define __NTOSKRNL_INCLUDE_INTERNAL_TEST_H
typedef VOID STDCALL
typedef VOID
STDCALL
PExFreePool(PVOID Block);
typedef PMDL STDCALL
PMmCreateMdl(PMDL Mdl,
PVOID Base,
ULONG Length);
typedef PMDL
STDCALL
PMmCreateMdl(
PMDL Mdl,
PVOID Base,
ULONG Length
);
typedef VOID STDCALL
PMmProbeAndLockPages(PMDL Mdl,
KPROCESSOR_MODE AccessMode,
LOCK_OPERATION Operation);
typedef VOID
STDCALL
PMmProbeAndLockPages(
PMDL Mdl,
KPROCESSOR_MODE AccessMode,
LOCK_OPERATION Operation
);
typedef VOID FASTCALL
typedef VOID
FASTCALL
PObDereferenceObject(PVOID Object);
typedef NTSTATUS STDCALL
PObReferenceObjectByHandle(HANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode,
PVOID* Object,
POBJECT_HANDLE_INFORMATION HandleInformation);
NTSTATUS STDCALL
MiLockVirtualMemory(HANDLE ProcessHandle,
PVOID BaseAddress,
ULONG NumberOfBytesToLock,
PULONG NumberOfBytesLocked,
PObReferenceObjectByHandle pObReferenceObjectByHandle,
PMmCreateMdl pMmCreateMdl,
PObDereferenceObject pObDereferenceObject,
PMmProbeAndLockPages pMmProbeAndLockPages,
PExFreePool pExFreePool);
NTSTATUS FASTCALL
MiQueryVirtualMemory (IN HANDLE ProcessHandle,
IN PVOID Address,
IN CINT VirtualMemoryInformationClass,
OUT PVOID VirtualMemoryInformation,
IN ULONG Length,
OUT PULONG ResultLength);
typedef NTSTATUS
STDCALL
PObReferenceObjectByHandle(
HANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode,
PVOID* Object,
POBJECT_HANDLE_INFORMATION HandleInformation
);
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_TEST_H */

View file

@ -10,73 +10,6 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_V86M_H
#define __NTOSKRNL_INCLUDE_INTERNAL_V86M_H
/* Emulate cli/sti instructions */
#define KV86M_EMULATE_CLI_STI (0x1)
/* Allow the v86 mode code to access i/o ports */
#define KV86M_ALLOW_IO_PORT_ACCESS (0x2)
typedef struct _KV86M_REGISTERS
{
/*
* General purpose registers
*/
ULONG Ebp;
ULONG Edi;
ULONG Esi;
ULONG Edx;
ULONG Ecx;
ULONG Ebx;
ULONG Eax;
ULONG Ds;
ULONG Es;
ULONG Fs;
ULONG Gs;
/*
* Control registers
*/
ULONG Eip;
ULONG Cs;
ULONG Eflags;
ULONG Esp;
ULONG Ss;
/*
* Control structures
*/
ULONG RecoveryAddress;
UCHAR RecoveryInstruction[4];
ULONG Vif;
ULONG Flags;
PNTSTATUS PStatus;
} KV86M_REGISTERS, *PKV86M_REGISTERS;
typedef struct _KV86M_TRAP_FRAME
{
KTRAP_FRAME Tf;
ULONG SavedExceptionStack;
/*
* These are put on the top of the stack by the routine that entered
* v86 mode so the exception handlers can find the control information
*/
struct _KV86M_REGISTERS* regs;
ULONG orig_ebp;
} KV86M_TRAP_FRAME, *PKV86M_TRAP_FRAME;
NTSTATUS
STDCALL
Ke386CallBios(
UCHAR Int,
PKV86M_REGISTERS Regs
);
ULONG
KeV86Exception(
ULONG ExceptionNr,
PKTRAP_FRAME Tf,
ULONG address
);
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_V86M_H */

View file

@ -194,7 +194,7 @@ KdbpOverwriteInstruction(
/* Attach to the process */
if (CurrentProcess != Process)
{
KeStackAttachProcess(EPROCESS_TO_KPROCESS(Process), &ApcState);
KeStackAttachProcess(&Process->Pcb, &ApcState);
}
/* Make the page writeable if it is read only. */
@ -1066,7 +1066,7 @@ KdbpAttachToThread(
}
if (KdbOriginalProcess != Process)
{
KeStackAttachProcess(EPROCESS_TO_KPROCESS(Process), &KdbApcState);
KeStackAttachProcess(&Process->Pcb, &KdbApcState);
}
KdbCurrentProcess = Process;
}

View file

@ -1080,8 +1080,8 @@ KdbpCmdProc(ULONG Argc, PCHAR Argv[])
str2 = "";
}
State = ((Process->Pcb.State == PROCESS_STATE_TERMINATED) ? "Terminated" :
((Process->Pcb.State == PROCESS_STATE_ACTIVE) ? "Active" : "Unknown"));
State = ((Process->Pcb.State == ProcessInMemory) ? "In Memory" :
((Process->Pcb.State == ProcessOutOfMemory) ? "Out of Memory" : "In Transition"));
KdbpPrint(" %s0x%08x %-10s %s%s\n",
str1,
@ -1134,8 +1134,8 @@ KdbpCmdProc(ULONG Argc, PCHAR Argv[])
}
}
State = ((Process->Pcb.State == PROCESS_STATE_TERMINATED) ? "Terminated" :
((Process->Pcb.State == PROCESS_STATE_ACTIVE) ? "Active" : "Unknown"));
State = ((Process->Pcb.State == ProcessInMemory) ? "In Memory" :
((Process->Pcb.State == ProcessOutOfMemory) ? "Out of Memory" : "In Transition"));
KdbpPrint("%s"
" PID: 0x%08x\n"
" State: %s (0x%x)\n"

View file

@ -527,7 +527,7 @@ KdbSymFreeProcessSymbols(IN PEPROCESS Process)
CurrentProcess = PsGetCurrentProcess();
if (CurrentProcess != Process)
{
KeAttachProcess(EPROCESS_TO_KPROCESS(Process));
KeAttachProcess(&Process->Pcb);
}
Peb = Process->Peb;
ASSERT(Peb);

View file

@ -85,7 +85,7 @@ KeInitializeProcess(PKPROCESS Process,
Process->DirectoryTableBase = DirectoryTableBase;
Process->AutoAlignment = TRUE;
Process->IopmOffset = 0xFFFF;
Process->State = PROCESS_STATE_ACTIVE;
Process->State = ProcessInMemory;
/* Initialize the Thread List */
InitializeListHead(&Process->ThreadListHead);

View file

@ -46,7 +46,9 @@ typedef struct
KSPIN_LOCK CallbackStackListLock;
static LIST_ENTRY CallbackStackListHead;
VOID INIT_FUNCTION
VOID
INIT_FUNCTION
NTAPI
PsInitialiseW32Call(VOID)
{
InitializeListHead(&CallbackStackListHead);
@ -227,7 +229,7 @@ KeUserModeCallback(IN ULONG RoutineIndex,
SavedState.SavedCallbackStack = Thread->Tcb.CallbackStack;
SavedState.SavedExceptionStack = (PVOID)KeGetCurrentKPCR()->TSS->Esp0;
if ((Thread->Tcb.NpxState & NPX_STATE_VALID) &&
ETHREAD_TO_KTHREAD(Thread) != KeGetCurrentPrcb()->NpxThread)
&Thread->Tcb != KeGetCurrentPrcb()->NpxThread)
{
RtlCopyMemory((char*)NewStack + StackSize - sizeof(FX_SAVE_AREA),
(char*)SavedState.SavedInitialStack - sizeof(FX_SAVE_AREA),

View file

@ -51,6 +51,7 @@ PsIdleThreadMain(PVOID Context)
* creation until I can merge my fix for properly creating them.
*/
NTSTATUS
NTAPI
PsInitializeIdleOrFirstThread(PEPROCESS Process,
PETHREAD* ThreadPtr,
PKSTART_ROUTINE StartRoutine,
@ -93,6 +94,7 @@ PsInitializeIdleOrFirstThread(PEPROCESS Process,
*/
VOID
INIT_FUNCTION
NTAPI
PsInitIdleThread(VOID)
{
PETHREAD IdleThread;

View file

@ -57,6 +57,7 @@ PiDeleteJob ( PVOID ObjectBody )
VOID
INIT_FUNCTION
NTAPI
PsInitJobManagment ( VOID )
{
UNICODE_STRING Name;
@ -81,6 +82,7 @@ PsInitJobManagment ( VOID )
}
NTSTATUS
NTAPI
PspAssignProcessToJob (
PEPROCESS Process,
PEJOB Job)
@ -90,6 +92,7 @@ PspAssignProcessToJob (
}
NTSTATUS
NTAPI
PspTerminateJobObject (
PEJOB Job,
KPROCESSOR_MODE AccessMode,

View file

@ -40,7 +40,9 @@ static LANGID PsInstallUILanguageId = 0;
* Returns:
* None.
*/
VOID INIT_FUNCTION
VOID
INIT_FUNCTION
NTAPI
PiInitDefaultLocale(VOID)
{
OBJECT_ATTRIBUTES ObjectAttributes;

View file

@ -30,6 +30,7 @@ LARGE_INTEGER ShortPsLockDelay, PsLockTimeout;
/* INTERNAL FUNCTIONS *****************************************************************/
NTSTATUS
NTAPI
PsLockProcess(PEPROCESS Process, BOOLEAN Timeout)
{
ULONG Attempts = 0;
@ -88,6 +89,7 @@ PsLockProcess(PEPROCESS Process, BOOLEAN Timeout)
}
VOID
NTAPI
PsUnlockProcess(PEPROCESS Process)
{
PAGED_CODE();
@ -331,7 +333,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
/* Now initialize the Kernel Process */
DPRINT("Initialzing Kernel Process\n");
KeInitializeProcess(&Process->Pcb,
PROCESS_PRIO_NORMAL,
PROCESS_PRIORITY_NORMAL,
Affinity,
DirectoryTableBase);

View file

@ -49,14 +49,18 @@ VOID STDCALL PspKillMostProcesses();
/* FUNCTIONS ***************************************************************/
VOID PiShutdownProcessManager(VOID)
VOID
NTAPI
PiShutdownProcessManager(VOID)
{
DPRINT("PiShutdownProcessManager()\n");
PspKillMostProcesses();
}
VOID INIT_FUNCTION
VOID
INIT_FUNCTION
NTAPI
PiInitProcessManager(VOID)
{
PsInitJobManagment();
@ -68,6 +72,7 @@ PiInitProcessManager(VOID)
VOID
INIT_FUNCTION
NTAPI
PsInitClientIDManagment(VOID)
{
PspCidTable = ExCreateHandleTable(NULL);
@ -76,6 +81,7 @@ PsInitClientIDManagment(VOID)
VOID
INIT_FUNCTION
NTAPI
PsInitThreadManagment(VOID)
/*
* FUNCTION: Initialize thread managment
@ -118,6 +124,7 @@ PsInitThreadManagment(VOID)
VOID
INIT_FUNCTION
NTAPI
PsInitProcessManagment(VOID)
{
PKPROCESS KProcess;
@ -179,7 +186,7 @@ PsInitProcessManagment(VOID)
PsIdleProcess->Pcb.Affinity = 0xFFFFFFFF;
PsIdleProcess->Pcb.IopmOffset = 0xffff;
PsIdleProcess->Pcb.BasePriority = PROCESS_PRIO_IDLE;
PsIdleProcess->Pcb.BasePriority = PROCESS_PRIORITY_IDLE;
PsIdleProcess->Pcb.QuantumReset = 6;
InitializeListHead(&PsIdleProcess->Pcb.ThreadListHead);
InitializeListHead(&PsIdleProcess->ThreadListHead);
@ -215,7 +222,7 @@ PsInitProcessManagment(VOID)
RtlZeroMemory(PsInitialSystemProcess, sizeof(EPROCESS));
PsInitialSystemProcess->Pcb.Affinity = KeActiveProcessors;
PsInitialSystemProcess->Pcb.IopmOffset = 0xffff;
PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL;
PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIORITY_NORMAL;
PsInitialSystemProcess->Pcb.QuantumReset = 6;
InitializeListHead(&PsInitialSystemProcess->Pcb.ThreadListHead);
KeInitializeDispatcherHeader(&PsInitialSystemProcess->Pcb.Header,

View file

@ -61,6 +61,7 @@ PsEstablishWin32Callouts(PW32_CALLOUT_DATA CalloutData)
}
NTSTATUS
NTAPI
PsInitWin32Thread (PETHREAD Thread)
{
PEPROCESS Process;
@ -89,6 +90,7 @@ PsInitWin32Thread (PETHREAD Thread)
VOID
NTAPI
PsTerminateWin32Process (PEPROCESS Process)
{
if (Process->Win32Process == NULL)
@ -105,6 +107,7 @@ PsTerminateWin32Process (PEPROCESS Process)
VOID
NTAPI
PsTerminateWin32Thread (PETHREAD Thread)
{
if (Thread->Tcb.Win32Thread != NULL)
@ -278,7 +281,7 @@ NtCallbackReturn (PVOID Result,
*/
KeRaiseIrql(HIGH_LEVEL, &oldIrql);
if ((Thread->Tcb.NpxState & NPX_STATE_VALID) &&
ETHREAD_TO_KTHREAD(Thread) != KeGetCurrentPrcb()->NpxThread)
&Thread->Tcb != KeGetCurrentPrcb()->NpxThread)
{
RtlCopyMemory((char*)InitialStack - sizeof(FX_SAVE_AREA),
(char*)Thread->Tcb.InitialStack - sizeof(FX_SAVE_AREA),

View file

@ -26,7 +26,9 @@ PACL SeUnrestrictedDacl = NULL;
/* FUNCTIONS ****************************************************************/
BOOLEAN INIT_FUNCTION
BOOLEAN
INIT_FUNCTION
NTAPI
SepInitDACLs(VOID)
{
ULONG AclLength;
@ -261,6 +263,7 @@ SepCreateImpersonationTokenDacl(PTOKEN Token,
}
NTSTATUS
NTAPI
SepCaptureAcl(IN PACL InputAcl,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
@ -347,6 +350,7 @@ SepCaptureAcl(IN PACL InputAcl,
}
VOID
NTAPI
SepReleaseAcl(IN PACL CapturedAcl,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel)

View file

@ -20,7 +20,9 @@ static LARGE_INTEGER LuidValue;
/* FUNCTIONS *****************************************************************/
VOID INIT_FUNCTION
VOID
INIT_FUNCTION
NTAPI
SepInitLuid(VOID)
{
LUID DummyLuidValue = SYSTEM_LUID;
@ -32,6 +34,7 @@ SepInitLuid(VOID)
NTSTATUS
NTAPI
ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
{
LARGE_INTEGER NewLuid, PrevLuid;

View file

@ -47,7 +47,9 @@ LUID SeEnableDelegationPrivilege;
/* FUNCTIONS ***************************************************************/
VOID INIT_FUNCTION
VOID
INIT_FUNCTION
NTAPI
SepInitPrivileges (VOID)
{
SeCreateTokenPrivilege.LowPart = SE_CREATE_TOKEN_PRIVILEGE;
@ -106,6 +108,7 @@ SepInitPrivileges (VOID)
BOOLEAN
NTAPI
SepPrivilegeCheck (PTOKEN Token,
PLUID_AND_ATTRIBUTES Privileges,
ULONG PrivilegeCount,
@ -166,6 +169,7 @@ SepPrivilegeCheck (PTOKEN Token,
NTSTATUS
NTAPI
SeCaptureLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Src,
ULONG PrivilegeCount,
KPROCESSOR_MODE PreviousMode,
@ -221,6 +225,7 @@ SeCaptureLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Src,
VOID
NTAPI
SeReleaseLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Privilege,
KPROCESSOR_MODE PreviousMode,
ULONG a)

View file

@ -24,7 +24,9 @@ PSECURITY_DESCRIPTOR SeUnrestrictedSd = NULL;
/* FUNCTIONS ***************************************************************/
BOOLEAN INIT_FUNCTION
BOOLEAN
INIT_FUNCTION
NTAPI
SepInitSDs(VOID)
{
/* Create PublicDefaultSd */
@ -180,6 +182,7 @@ SeSetWorldSecurityDescriptor(SECURITY_INFORMATION SecurityInformation,
NTSTATUS
NTAPI
SepCaptureSecurityQualityOfService(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
@ -331,6 +334,7 @@ SepCaptureSecurityQualityOfService(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIO
VOID
NTAPI
SepReleaseSecurityQualityOfService(IN PSECURITY_QUALITY_OF_SERVICE CapturedSecurityQualityOfService OPTIONAL,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel)

View file

@ -29,7 +29,9 @@ static BOOLEAN SepInitExports(VOID);
/* FUNCTIONS ****************************************************************/
BOOLEAN INIT_FUNCTION
BOOLEAN
INIT_FUNCTION
NTAPI
SeInit1(VOID)
{
SepInitLuid();
@ -55,7 +57,9 @@ SeInit1(VOID)
}
BOOLEAN INIT_FUNCTION
BOOLEAN
INIT_FUNCTION
NTAPI
SeInit2(VOID)
{
SepInitializeTokenImplementation();
@ -65,6 +69,7 @@ SeInit2(VOID)
BOOLEAN
NTAPI
SeInitSRM(VOID)
{
OBJECT_ATTRIBUTES ObjectAttributes;

View file

@ -56,7 +56,9 @@ PSID SeAnonymousLogonSid = NULL;
/* FUNCTIONS ****************************************************************/
BOOLEAN INIT_FUNCTION
BOOLEAN
INIT_FUNCTION
NTAPI
SepInitSecurityIDs(VOID)
{
ULONG SidLength0;
@ -221,6 +223,7 @@ SepInitSecurityIDs(VOID)
}
NTSTATUS
NTAPI
SepCaptureSid(IN PSID InputSid,
IN KPROCESSOR_MODE AccessMode,
IN POOL_TYPE PoolType,
@ -309,6 +312,7 @@ SepCaptureSid(IN PSID InputSid,
}
VOID
NTAPI
SepReleaseSid(IN PSID CapturedSid,
IN KPROCESSOR_MODE AccessMode,
IN BOOLEAN CaptureIfKernel)

View file

@ -68,18 +68,23 @@ static const INFORMATION_CLASS_INFO SeTokenInformationClass[] = {
/* FUNCTIONS *****************************************************************/
VOID SepFreeProxyData(PVOID ProxyData)
VOID
NTAPI
SepFreeProxyData(PVOID ProxyData)
{
UNIMPLEMENTED;
}
NTSTATUS SepCopyProxyData(PVOID* Dest, PVOID Src)
NTSTATUS
NTAPI
SepCopyProxyData(PVOID* Dest, PVOID Src)
{
UNIMPLEMENTED;
return(STATUS_NOT_IMPLEMENTED);
}
NTSTATUS
NTAPI
SeExchangePrimaryToken(PEPROCESS Process,
PACCESS_TOKEN NewTokenP,
PACCESS_TOKEN* OldTokenP)
@ -109,6 +114,7 @@ SeExchangePrimaryToken(PEPROCESS Process,
}
VOID
NTAPI
SeDeassignPrimaryToken(PEPROCESS Process)
{
PTOKEN OldToken;
@ -138,6 +144,7 @@ RtlLengthSidAndAttributes(ULONG Count,
NTSTATUS
NTAPI
SepFindPrimaryGroupAndDefaultOwner(PTOKEN Token,
PSID PrimaryGroup,
PSID DefaultOwner)
@ -557,7 +564,9 @@ SepDeleteToken(PVOID ObjectBody)
}
VOID INIT_FUNCTION
VOID
INIT_FUNCTION
NTAPI
SepInitializeTokenImplementation(VOID)
{
UNICODE_STRING Name;