From c06ef435fb64d7b8b48596ec2fa325bd526fbb25 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 28 Jan 2001 17:42:56 +0000 Subject: [PATCH] Added mapping of access rights svn path=/trunk/; revision=1579 --- reactos/include/ntos/ps.h | 53 ++++++++++++++++++++------------- reactos/include/ntos/security.h | 32 ++++++++++++++------ reactos/ntoskrnl/io/file.c | 10 +------ reactos/ntoskrnl/io/iomgr.c | 16 +++++++++- reactos/ntoskrnl/io/symlink.c | 11 +++++-- reactos/ntoskrnl/lpc/port.c | 9 +++++- reactos/ntoskrnl/ob/namespc.c | 13 ++++++-- reactos/ntoskrnl/ps/process.c | 36 +++++++++++----------- reactos/ntoskrnl/ps/thread.c | 8 ++++- reactos/ntoskrnl/se/token.c | 8 ++++- 10 files changed, 132 insertions(+), 64 deletions(-) diff --git a/reactos/include/ntos/ps.h b/reactos/include/ntos/ps.h index f1dc0684cac..c9e817195f4 100644 --- a/reactos/include/ntos/ps.h +++ b/reactos/include/ntos/ps.h @@ -13,28 +13,41 @@ #ifndef __INCLUDE_PS_H #define __INCLUDE_PS_H -#define THREAD_ALL_ACCESS (0x1f03ffL) -#define THREAD_DIRECT_IMPERSONATION (512) -#define THREAD_GET_CONTEXT (8) -#define THREAD_IMPERSONATE (256) -#define THREAD_QUERY_INFORMATION (64) -#define THREAD_SET_CONTEXT (16) -#define THREAD_SET_INFORMATION (32) -#define THREAD_SET_THREAD_TOKEN (128) -#define THREAD_SUSPEND_RESUME (2) -#define THREAD_TERMINATE (1) +/* Thread access rights */ +#define THREAD_TERMINATE (0x0001L) +#define THREAD_SUSPEND_RESUME (0x0002L) +#define THREAD_GET_CONTEXT (0x0008L) +#define THREAD_SET_CONTEXT (0x0010L) +#define THREAD_SET_INFORMATION (0x0020L) +#define THREAD_QUERY_INFORMATION (0x0040L) +#define THREAD_SET_THREAD_TOKEN (0x0080L) +#define THREAD_IMPERSONATE (0x0100L) +#define THREAD_DIRECT_IMPERSONATION (0x0200L) -#define PROCESS_ALL_ACCESS (0x1f0fffL) -#define PROCESS_CREATE_PROCESS (128) -#define PROCESS_CREATE_THREAD (2) -#define PROCESS_DUP_HANDLE (64) -#define PROCESS_QUERY_INFORMATION (1024) -#define PROCESS_SET_INFORMATION (512) -#define PROCESS_TERMINATE (1) -#define PROCESS_VM_OPERATION (8) -#define PROCESS_VM_READ (16) -#define PROCESS_VM_WRITE (32) +#define THREAD_ALL_ACCESS (0x1f03ffL) +#define THREAD_READ (0x020048L) +#define THREAD_WRITE (0x020037L) +#define THREAD_EXECUTE (0x120000L) +/* Process access rights */ +#define PROCESS_TERMINATE (0x0001L) +#define PROCESS_CREATE_THREAD (0x0002L) +#define PROCESS_SET_SESSIONID (0x0004L) +#define PROCESS_VM_OPERATION (0x0008L) +#define PROCESS_VM_READ (0x0010L) +#define PROCESS_VM_WRITE (0x0020L) +#define PROCESS_DUP_HANDLE (0x0040L) +#define PROCESS_CREATE_PROCESS (0x0080L) +#define PROCESS_SET_QUOTA (0x0100L) +#define PROCESS_SET_INFORMATION (0x0200L) +#define PROCESS_QUERY_INFORMATION (0x0400L) + +#define PROCESS_ALL_ACCESS (0x1f0fffL) +#define PROCESS_READ (0x020410L) +#define PROCESS_WRITE (0x020bebL) +#define PROCESS_EXECUTE (0x120000L) + +/* Thread priorities */ #define THREAD_PRIORITY_ABOVE_NORMAL (1) #define THREAD_PRIORITY_BELOW_NORMAL (-1) #define THREAD_PRIORITY_HIGHEST (2) diff --git a/reactos/include/ntos/security.h b/reactos/include/ntos/security.h index 05e12ea1c0f..7b6ec10e887 100644 --- a/reactos/include/ntos/security.h +++ b/reactos/include/ntos/security.h @@ -5,25 +5,39 @@ #include /* ACCESS_MASK */ -#define MAXIMUM_ALLOWED (0x2000000L) -#define GENERIC_ALL (0x10000000L) -#define GENERIC_EXECUTE (0x20000000L) +#define MAXIMUM_ALLOWED (0x2000000L) +#define GENERIC_ALL (0x10000000L) +#define GENERIC_EXECUTE (0x20000000L) #define SECURITY_STATIC_TRACKING (0) #define SECURITY_DYNAMIC_TRACKING (1) /* Standard rights */ #define STANDARD_RIGHTS_REQUIRED (0xf0000L) -#define STANDARD_RIGHTS_WRITE (0x20000L) -#define STANDARD_RIGHTS_READ (0x20000L) -#define STANDARD_RIGHTS_EXECUTE (0x20000L) -#define STANDARD_RIGHTS_ALL (0x1f0000L) -#define SPECIFIC_RIGHTS_ALL (0xffffL) +#define STANDARD_RIGHTS_WRITE (0x20000L) +#define STANDARD_RIGHTS_READ (0x20000L) +#define STANDARD_RIGHTS_EXECUTE (0x20000L) +#define STANDARD_RIGHTS_ALL (0x1f0000L) +#define SPECIFIC_RIGHTS_ALL (0xffffL) +/* Token rights */ +#define TOKEN_ASSIGN_PRIMARY (0x0001L) +#define TOKEN_DUPLICATE (0x0002L) +#define TOKEN_IMPERSONATE (0x0004L) +#define TOKEN_QUERY (0x0008L) +#define TOKEN_QUERY_SOURCE (0x0010L) +#define TOKEN_ADJUST_PRIVILEGES (0x0020L) +#define TOKEN_ADJUST_GROUPS (0x0040L) +#define TOKEN_ADJUST_DEFAULT (0x0080L) + +#define TOKEN_ALL_ACCESS (0xf00ffL) +#define TOKEN_READ (0x20008L) +#define TOKEN_WRITE (0x200e0L) +#define TOKEN_EXECUTE (0x20000L) typedef BOOL SECURITY_CONTEXT_TRACKING_MODE; -typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION; +typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION; typedef enum _TOKEN_INFORMATION_CLASS { TokenUser = 1, diff --git a/reactos/ntoskrnl/io/file.c b/reactos/ntoskrnl/io/file.c index ca9c6c15a85..adcb95c3f4c 100644 --- a/reactos/ntoskrnl/io/file.c +++ b/reactos/ntoskrnl/io/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.11 2000/09/03 14:49:17 ekohl Exp $ +/* $Id: file.c,v 1.12 2001/01/28 17:37:48 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -204,14 +204,6 @@ NtSetInformationFile ( } -PGENERIC_MAPPING -STDCALL -IoGetFileObjectGenericMapping(VOID) -{ - UNIMPLEMENTED; -} - - NTSTATUS STDCALL NtQueryAttributesFile ( diff --git a/reactos/ntoskrnl/io/iomgr.c b/reactos/ntoskrnl/io/iomgr.c index cbca1bdfe21..dfce0ccf632 100644 --- a/reactos/ntoskrnl/io/iomgr.c +++ b/reactos/ntoskrnl/io/iomgr.c @@ -1,4 +1,4 @@ -/* $Id: iomgr.c,v 1.16 2000/10/05 19:15:50 ekohl Exp $ +/* $Id: iomgr.c,v 1.17 2001/01/28 17:37:48 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -32,6 +32,11 @@ ULONG EXPORTED IoWriteOperationCount = 0; /* FIXME: unknown type */ ULONG EXPORTED IoWriteTransferCount = 0; /* FIXME: unknown type */ ULONG EXPORTED IoStatisticsLock = 0; /* FIXME: unknown type */ +static GENERIC_MAPPING IopFileMapping = {FILE_GENERIC_READ, + FILE_GENERIC_WRITE, + FILE_GENERIC_EXECUTE, + FILE_ALL_ACCESS}; + /* FUNCTIONS ****************************************************************/ VOID IopCloseFile(PVOID ObjectBody, ULONG HandleCount) @@ -121,6 +126,7 @@ VOID IoInit (VOID) IoDeviceObjectType->MaxHandles = ULONG_MAX; IoDeviceObjectType->PagedPoolCharge = 0; IoDeviceObjectType->NonpagedPoolCharge = sizeof (DEVICE_OBJECT); + IoDeviceObjectType->Mapping = &IopFileMapping; IoDeviceObjectType->Dump = NULL; IoDeviceObjectType->Open = NULL; IoDeviceObjectType->Close = NULL; @@ -151,6 +157,7 @@ VOID IoInit (VOID) IoFileObjectType->MaxHandles = ULONG_MAX; IoFileObjectType->PagedPoolCharge = 0; IoFileObjectType->NonpagedPoolCharge = sizeof(FILE_OBJECT); + IoFileObjectType->Mapping = &IopFileMapping; IoFileObjectType->Dump = NULL; IoFileObjectType->Open = NULL; IoFileObjectType->Close = IopCloseFile; @@ -245,4 +252,11 @@ VOID IoInit (VOID) &DeviceName); } + +PGENERIC_MAPPING STDCALL +IoGetFileObjectGenericMapping(VOID) +{ + return &IopFileMapping; +} + /* EOF */ diff --git a/reactos/ntoskrnl/io/symlink.c b/reactos/ntoskrnl/io/symlink.c index 4a7fe5a5b0f..09893a14759 100644 --- a/reactos/ntoskrnl/io/symlink.c +++ b/reactos/ntoskrnl/io/symlink.c @@ -1,4 +1,4 @@ -/* $Id: symlink.c,v 1.17 2000/10/22 16:36:50 ekohl Exp $ +/* $Id: symlink.c,v 1.18 2001/01/28 17:37:48 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -30,6 +30,12 @@ typedef struct POBJECT_TYPE IoSymbolicLinkType = NULL; +static GENERIC_MAPPING IopSymbolicLinkMapping = { + STANDARD_RIGHTS_READ|SYMBOLIC_LINK_QUERY, + STANDARD_RIGHTS_WRITE, + STANDARD_RIGHTS_EXECUTE|SYMBOLIC_LINK_QUERY, + SYMBOLIC_LINK_ALL_ACCESS}; + /* FUNCTIONS *****************************************************************/ @@ -171,6 +177,7 @@ VOID IoInitSymbolicLinkImplementation (VOID) IoSymbolicLinkType->MaxHandles = ULONG_MAX; IoSymbolicLinkType->PagedPoolCharge = 0; IoSymbolicLinkType->NonpagedPoolCharge = sizeof (SYMLNK_OBJECT); + IoSymbolicLinkType->Mapping = &IopSymbolicLinkMapping; IoSymbolicLinkType->Dump = NULL; IoSymbolicLinkType->Open = NULL; IoSymbolicLinkType->Close = NULL; @@ -180,7 +187,7 @@ VOID IoInitSymbolicLinkImplementation (VOID) IoSymbolicLinkType->QueryName = NULL; IoSymbolicLinkType->OkayToClose = NULL; IoSymbolicLinkType->Create = IopCreateSymbolicLink; - + RtlInitUnicodeString(&IoSymbolicLinkType->TypeName, L"SymbolicLink"); } diff --git a/reactos/ntoskrnl/lpc/port.c b/reactos/ntoskrnl/lpc/port.c index d1d33f1cf67..b9980d0d894 100644 --- a/reactos/ntoskrnl/lpc/port.c +++ b/reactos/ntoskrnl/lpc/port.c @@ -1,4 +1,4 @@ -/* $Id: port.c,v 1.3 2000/10/22 16:36:51 ekohl Exp $ +/* $Id: port.c,v 1.4 2001/01/28 17:38:12 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -30,6 +30,12 @@ POBJECT_TYPE ExPortType = NULL; ULONG EiNextLpcMessageId = 0; +static GENERIC_MAPPING ExpPortMapping = { + STANDARD_RIGHTS_READ, + STANDARD_RIGHTS_WRITE, + 0, + PORT_ALL_ACCESS}; + /* FUNCTIONS *****************************************************************/ @@ -45,6 +51,7 @@ NTSTATUS NiInitPort (VOID) ExPortType->TotalHandles = 0; ExPortType->PagedPoolCharge = 0; ExPortType->NonpagedPoolCharge = sizeof(EPORT); + ExPortType->Mapping = &ExpPortMapping; ExPortType->Dump = NULL; ExPortType->Open = NULL; ExPortType->Close = NiClosePort; diff --git a/reactos/ntoskrnl/ob/namespc.c b/reactos/ntoskrnl/ob/namespc.c index 3a23f25d8a0..def67d5253a 100644 --- a/reactos/ntoskrnl/ob/namespc.c +++ b/reactos/ntoskrnl/ob/namespc.c @@ -24,6 +24,12 @@ POBJECT_TYPE ObDirectoryType = NULL; PDIRECTORY_OBJECT NameSpaceRoot = NULL; +static GENERIC_MAPPING ObpDirectoryMapping = { + STANDARD_RIGHTS_READ|DIRECTORY_QUERY|DIRECTORY_TRAVERSE, + STANDARD_RIGHTS_WRITE|DIRECTORY_CREATE_OBJECT|DIRECTORY_CREATE_SUBDIRECTORY, + STANDARD_RIGHTS_EXECUTE|DIRECTORY_QUERY|DIRECTORY_TRAVERSE, + DIRECTORY_ALL_ACCESS}; + /* FUNCTIONS **************************************************************/ NTSTATUS STDCALL @@ -83,8 +89,8 @@ DPRINT("Object %p\n", Object); * ... * ObjectType * ... - * Unknown3 - * ??? + * ParseContext + * ... * AccessMode * ... * DesiredAccess @@ -100,7 +106,7 @@ DPRINT("Object %p\n", Object); NTSTATUS STDCALL ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_TYPE ObjectType, - ULONG Unknown3, /* ?? */ + PVOID ParseContext, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PACCESS_STATE PassedAccessState, @@ -308,6 +314,7 @@ VOID ObInit(VOID) ObDirectoryType->MaxHandles = ULONG_MAX; ObDirectoryType->PagedPoolCharge = 0; ObDirectoryType->NonpagedPoolCharge = sizeof(DIRECTORY_OBJECT); + ObDirectoryType->Mapping = &ObpDirectoryMapping; ObDirectoryType->Dump = NULL; ObDirectoryType->Open = NULL; ObDirectoryType->Close = NULL; diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index f36a36a11b9..24f4e4b988a 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.55 2001/01/21 14:54:29 dwelch Exp $ +/* $Id: process.c,v 1.56 2001/01/28 17:38:40 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -39,6 +39,11 @@ static LIST_ENTRY PsProcessListHead; static KSPIN_LOCK PsProcessListLock; static ULONG PiNextProcessUniqueId = 0; +static GENERIC_MAPPING PiProcessMapping = {PROCESS_READ, + PROCESS_WRITE, + PROCESS_EXECUTE, + PROCESS_ALL_ACCESS}; + /* FUNCTIONS *****************************************************************/ @@ -176,6 +181,7 @@ VOID PsInitProcessManagment(VOID) PsProcessType->MaxHandles = ULONG_MAX; PsProcessType->PagedPoolCharge = 0; PsProcessType->NonpagedPoolCharge = sizeof(EPROCESS); + PsProcessType->Mapping = &PiProcessMapping; PsProcessType->Dump = NULL; PsProcessType->Open = NULL; PsProcessType->Close = NULL; @@ -799,10 +805,9 @@ NTSTATUS STDCALL NtSetInformationProcess(IN HANDLE ProcessHandle, } -#if 0 /********************************************************************** * NAME INTERNAL - * PiSnapshotProcessTable + * PiQuerySystemProcessInformation * * DESCRIPTION * Compute the size of a process+thread snapshot as @@ -816,13 +821,13 @@ NTSTATUS STDCALL NtSetInformationProcess(IN HANDLE ProcessHandle, * We assume (sizeof (PVOID) == sizeof (ULONG)) holds. */ NTSTATUS -STDCALL -PiSnapshotProcessTable ( - IN PVOID SnapshotBuffer, - IN ULONG Size, - IN PULONG pRequiredSize - ) +PiQuerySystemProcessInformation(PVOID Buffer, + ULONG Size, + PULONG ReqSize) { + return STATUS_NOT_IMPLEMENTED; + +#if 0 KIRQL OldIrql; PLIST_ENTRY CurrentEntryP; PEPROCESS CurrentP; @@ -839,13 +844,10 @@ PiSnapshotProcessTable ( PSYSTEM_THREAD_INFO pInfoT = NULL; - /* - * Lock the process list. - */ - KeAcquireSpinLock ( - & PsProcessListLock, - & OldIrql - ); + /* Lock the process list. */ + KeAcquireSpinLock(&PsProcessListLock, + &OldIrql); + /* * Scan the process list. Since the * list is circular, the guard is false @@ -1010,7 +1012,7 @@ PiSnapshotProcessTable ( pInfoP->RelativeOffset = 0L; /* OK */ return STATUS_SUCCESS; -} #endif +} /* EOF */ diff --git a/reactos/ntoskrnl/ps/thread.c b/reactos/ntoskrnl/ps/thread.c index 8b6f7ab0584..33511123467 100644 --- a/reactos/ntoskrnl/ps/thread.c +++ b/reactos/ntoskrnl/ps/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.67 2001/01/21 14:54:30 dwelch Exp $ +/* $Id: thread.c,v 1.68 2001/01/28 17:38:40 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -49,6 +49,11 @@ ULONG PiNrRunnableThreads = 0; static PETHREAD CurrentThread = NULL; +static GENERIC_MAPPING PiThreadMapping = {THREAD_READ, + THREAD_WRITE, + THREAD_EXECUTE, + THREAD_ALL_ACCESS}; + /* FUNCTIONS ***************************************************************/ PKTHREAD STDCALL KeGetCurrentThread(VOID) @@ -273,6 +278,7 @@ PsInitThreadManagment(VOID) PsThreadType->MaxHandles = 0; PsThreadType->PagedPoolCharge = 0; PsThreadType->NonpagedPoolCharge = sizeof(ETHREAD); + PsThreadType->Mapping = &PiThreadMapping; PsThreadType->Dump = NULL; PsThreadType->Open = NULL; PsThreadType->Close = PiCloseThread; diff --git a/reactos/ntoskrnl/se/token.c b/reactos/ntoskrnl/se/token.c index 6205110fe70..07d27622205 100644 --- a/reactos/ntoskrnl/se/token.c +++ b/reactos/ntoskrnl/se/token.c @@ -1,4 +1,4 @@ -/* $Id: token.c,v 1.8 2000/07/01 22:38:15 ekohl Exp $ +/* $Id: token.c,v 1.9 2001/01/28 17:42:56 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -21,6 +21,11 @@ POBJECT_TYPE EXPORTED SeTokenType = NULL; +static GENERIC_MAPPING SepTokenMapping = {TOKEN_READ, + TOKEN_WRITE, + TOKEN_EXECUTE, + TOKEN_ALL_ACCESS}; + /* FUNCTIONS *****************************************************************/ VOID SepFreeProxyData(PVOID ProxyData) @@ -227,6 +232,7 @@ VOID SeInitializeTokenManager(VOID) SeTokenType->TotalHandles = 0; SeTokenType->PagedPoolCharge = 0; SeTokenType->NonpagedPoolCharge = 0; + SeTokenType->Mapping = &SepTokenMapping; SeTokenType->Dump = NULL; SeTokenType->Open = NULL; SeTokenType->Close = NULL;