From a46ee938fac9185902092d46627b7a9857d91267 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Mon, 5 Jun 2006 06:31:42 +0000 Subject: [PATCH] - Rename ObpCreateTypeObject to ObCreateObjectType and fix definition. The latter is actually exported in NT, and there's no reason not to export it while having our own internally renamed version. - Added stub exports for ObCloseHandle, ObReferenceSecurityDesciptor, ObSetHandleAttributes, ObSetSecurityObjectByPointer so that someday someone can know what needs to be implemented. - Removed ObGetObjectPointerCount. It is not exported in newer OSes and was always undocumented. - Move ObQueryObjecctAuditingByHandle to security.c and optimized it not to attach to the system process, as well as to cache the handle table instead of dereferencing the owner process all the time. svn path=/trunk/; revision=22232 --- reactos/include/ndk/obfuncs.h | 9 ++ reactos/ntoskrnl/cm/registry.c | 3 +- reactos/ntoskrnl/ex/callback.c | 2 +- reactos/ntoskrnl/ex/event.c | 2 +- reactos/ntoskrnl/ex/evtpair.c | 2 +- reactos/ntoskrnl/ex/mutant.c | 2 +- reactos/ntoskrnl/ex/profile.c | 2 +- reactos/ntoskrnl/ex/sem.c | 2 +- reactos/ntoskrnl/ex/timer.c | 2 +- reactos/ntoskrnl/ex/win32k.c | 12 +- reactos/ntoskrnl/include/internal/ob.h | 8 -- reactos/ntoskrnl/io/driver.c | 2 +- reactos/ntoskrnl/io/iocomp.c | 2 +- reactos/ntoskrnl/io/iomgr.c | 8 +- reactos/ntoskrnl/lpc/port.c | 4 +- reactos/ntoskrnl/mm/section.c | 2 +- reactos/ntoskrnl/ntoskrnl.def | 19 ++- reactos/ntoskrnl/ob/obhandle.c | 58 -------- reactos/ntoskrnl/ob/obinit.c | 4 +- reactos/ntoskrnl/ob/oblife.c | 179 +++++++++++++------------ reactos/ntoskrnl/ob/obname.c | 2 +- reactos/ntoskrnl/ob/obref.c | 11 -- reactos/ntoskrnl/ob/security.c | 65 +++++++++ reactos/ntoskrnl/ob/symlink.c | 2 +- reactos/ntoskrnl/ps/job.c | 2 +- reactos/ntoskrnl/ps/psmgr.c | 4 +- reactos/ntoskrnl/se/token.c | 2 +- 27 files changed, 213 insertions(+), 199 deletions(-) diff --git a/reactos/include/ndk/obfuncs.h b/reactos/include/ndk/obfuncs.h index 17ef7ae3531..3e8c5fda753 100644 --- a/reactos/include/ndk/obfuncs.h +++ b/reactos/include/ndk/obfuncs.h @@ -44,6 +44,15 @@ ObCreateObject( OUT PVOID *Object ); +NTSTATUS +NTAPI +ObCreateObjectType( + IN PUNICODE_STRING TypeName, + IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, + IN PVOID Reserved, + OUT POBJECT_TYPE *ObjectType +); + NTKERNELAPI ULONG NTAPI diff --git a/reactos/ntoskrnl/cm/registry.c b/reactos/ntoskrnl/cm/registry.c index b2c6948dc2c..e827f208b00 100644 --- a/reactos/ntoskrnl/cm/registry.c +++ b/reactos/ntoskrnl/cm/registry.c @@ -22,6 +22,7 @@ #pragma alloc_text(INIT, CmInit2) #endif +#define ObGetObjectPointerCount(x) OBJECT_TO_OBJECT_HEADER(x)->PointerCount /* GLOBALS ******************************************************************/ @@ -373,7 +374,7 @@ CmInitializeRegistry(VOID) ObjectTypeInitializer.SecurityProcedure = CmiObjectSecurity; ObjectTypeInitializer.QueryNameProcedure = CmiObjectQueryName; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &CmiKeyType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &CmiKeyType); /* Initialize the hive list */ InitializeListHead(&CmiHiveListHead); diff --git a/reactos/ntoskrnl/ex/callback.c b/reactos/ntoskrnl/ex/callback.c index caf8743f169..c0c7adca428 100644 --- a/reactos/ntoskrnl/ex/callback.c +++ b/reactos/ntoskrnl/ex/callback.c @@ -97,7 +97,7 @@ ExpInitializeCallbacks(VOID) ObjectTypeInitializer.GenericMapping = ExpCallbackMapping; ObjectTypeInitializer.PoolType = NonPagedPool; - Status = ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExCallbackObjectType); + Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExCallbackObjectType); /* Fail if it wasn't created successfully */ if (!NT_SUCCESS(Status)) diff --git a/reactos/ntoskrnl/ex/event.c b/reactos/ntoskrnl/ex/event.c index a233112fbff..dffb13fc045 100644 --- a/reactos/ntoskrnl/ex/event.c +++ b/reactos/ntoskrnl/ex/event.c @@ -53,7 +53,7 @@ ExpInitializeEventImplementation(VOID) ObjectTypeInitializer.GenericMapping = ExpEventMapping; ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExEventObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventObjectType); } /* diff --git a/reactos/ntoskrnl/ex/evtpair.c b/reactos/ntoskrnl/ex/evtpair.c index 7d066bee339..ddffa8ec4df 100644 --- a/reactos/ntoskrnl/ex/evtpair.c +++ b/reactos/ntoskrnl/ex/evtpair.c @@ -49,7 +49,7 @@ ExpInitializeEventPairImplementation(VOID) ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = EVENT_PAIR_ALL_ACCESS; ObjectTypeInitializer.UseDefaultObject = TRUE; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExEventPairObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventPairObjectType); } NTSTATUS diff --git a/reactos/ntoskrnl/ex/mutant.c b/reactos/ntoskrnl/ex/mutant.c index 7e420782044..ceb2cfc2d56 100644 --- a/reactos/ntoskrnl/ex/mutant.c +++ b/reactos/ntoskrnl/ex/mutant.c @@ -68,7 +68,7 @@ ExpInitializeMutantImplementation(VOID) ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.DeleteProcedure = ExpDeleteMutant; ObjectTypeInitializer.ValidAccessMask = MUTANT_ALL_ACCESS; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExMutantObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExMutantObjectType); } /* diff --git a/reactos/ntoskrnl/ex/profile.c b/reactos/ntoskrnl/ex/profile.c index 8bc069048b9..cbee7ca7c03 100644 --- a/reactos/ntoskrnl/ex/profile.c +++ b/reactos/ntoskrnl/ex/profile.c @@ -82,7 +82,7 @@ ExpInitializeProfileImplementation(VOID) ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.DeleteProcedure = ExpDeleteProfile; ObjectTypeInitializer.ValidAccessMask = PROFILE_ALL_ACCESS; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExProfileObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExProfileObjectType); } NTSTATUS diff --git a/reactos/ntoskrnl/ex/sem.c b/reactos/ntoskrnl/ex/sem.c index fc441b9a143..0719c255a8e 100644 --- a/reactos/ntoskrnl/ex/sem.c +++ b/reactos/ntoskrnl/ex/sem.c @@ -55,7 +55,7 @@ ExpInitializeSemaphoreImplementation(VOID) ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK; ObjectTypeInitializer.ValidAccessMask = SEMAPHORE_ALL_ACCESS; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExSemaphoreObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExSemaphoreObjectType); } /* diff --git a/reactos/ntoskrnl/ex/timer.c b/reactos/ntoskrnl/ex/timer.c index e3047a38e54..e45058a1290 100644 --- a/reactos/ntoskrnl/ex/timer.c +++ b/reactos/ntoskrnl/ex/timer.c @@ -249,7 +249,7 @@ ExpInitializeTimerImplementation(VOID) ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = TIMER_ALL_ACCESS; ObjectTypeInitializer.DeleteProcedure = ExpDeleteTimer; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExTimerType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExTimerType); /* Initialize the Wait List and Lock */ KeInitializeSpinLock(&ExpWakeListLock); diff --git a/reactos/ntoskrnl/ex/win32k.c b/reactos/ntoskrnl/ex/win32k.c index fbe251beb4b..431cedf1d06 100644 --- a/reactos/ntoskrnl/ex/win32k.c +++ b/reactos/ntoskrnl/ex/win32k.c @@ -137,9 +137,10 @@ ExpWin32kInit(VOID) ObjectTypeInitializer.OpenProcedure = ExpWinStaObjectOpen; ObjectTypeInitializer.DeleteProcedure = ExpWinStaObjectDelete; ObjectTypeInitializer.ParseProcedure = ExpWinStaObjectParse; - ObpCreateTypeObject(&ObjectTypeInitializer, - &Name, - &ExWindowStationObjectType); + ObCreateObjectType(&Name, + &ObjectTypeInitializer, + NULL, + &ExWindowStationObjectType); /* Create desktop object type */ RtlInitUnicodeString(&Name, L"Desktop"); @@ -147,7 +148,10 @@ ExpWin32kInit(VOID) ObjectTypeInitializer.OpenProcedure = NULL; ObjectTypeInitializer.DeleteProcedure = ExpDesktopDelete; ObjectTypeInitializer.ParseProcedure = NULL; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExDesktopObjectType); + ObCreateObjectType(&Name, + &ObjectTypeInitializer, + NULL, + &ExDesktopObjectType); } /* EOF */ diff --git a/reactos/ntoskrnl/include/internal/ob.h b/reactos/ntoskrnl/include/internal/ob.h index 5c64719e355..9b54fb52d5b 100644 --- a/reactos/ntoskrnl/include/internal/ob.h +++ b/reactos/ntoskrnl/include/internal/ob.h @@ -114,14 +114,6 @@ ObpSetHandleAttributes( IN PVOID Context ); -NTSTATUS -STDCALL -ObpCreateTypeObject( - struct _OBJECT_TYPE_INITIALIZER *ObjectTypeInitializer, - PUNICODE_STRING TypeName, - POBJECT_TYPE *ObjectType -); - ULONG NTAPI ObGetObjectHandleCount(PVOID Object); diff --git a/reactos/ntoskrnl/io/driver.c b/reactos/ntoskrnl/io/driver.c index 41311653429..01f8b8c1a4c 100644 --- a/reactos/ntoskrnl/io/driver.c +++ b/reactos/ntoskrnl/io/driver.c @@ -129,7 +129,7 @@ IopInitDriverImplementation(VOID) ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.DeleteProcedure = IopDeleteDriver; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoDriverObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &IoDriverObjectType); InitializeListHead(&DriverReinitListHead); KeInitializeSpinLock(&DriverReinitListLock); diff --git a/reactos/ntoskrnl/io/iocomp.c b/reactos/ntoskrnl/io/iocomp.c index d61a6d9c0a6..e069c21bb9a 100644 --- a/reactos/ntoskrnl/io/iocomp.c +++ b/reactos/ntoskrnl/io/iocomp.c @@ -216,7 +216,7 @@ IopInitIoCompletionImplementation(VOID) ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.GenericMapping = IopCompletionMapping; ObjectTypeInitializer.DeleteProcedure = IopDeleteIoCompletion; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoCompletionType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &IoCompletionType); } NTSTATUS diff --git a/reactos/ntoskrnl/io/iomgr.c b/reactos/ntoskrnl/io/iomgr.c index 5d92c555335..0fd2759ee3e 100644 --- a/reactos/ntoskrnl/io/iomgr.c +++ b/reactos/ntoskrnl/io/iomgr.c @@ -210,16 +210,16 @@ IoInit (VOID) ObjectTypeInitializer.ValidAccessMask = FILE_ALL_ACCESS; ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.GenericMapping = IopFileMapping; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoDeviceObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &IoDeviceObjectType); /* Do the Adapter Type */ RtlInitUnicodeString(&Name, L"Adapter"); - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoAdapterObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &IoAdapterObjectType); /* Do the Controller Type */ RtlInitUnicodeString(&Name, L"Controller"); ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(CONTROLLER_OBJECT); - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoControllerObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &IoControllerObjectType); /* Initialize the File object type */ RtlInitUnicodeString(&Name, L"File"); @@ -230,7 +230,7 @@ IoInit (VOID) ObjectTypeInitializer.SecurityProcedure = IopSecurityFile; ObjectTypeInitializer.QueryNameProcedure = IopQueryNameFile; ObjectTypeInitializer.UseDefaultObject = FALSE; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoFileObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &IoFileObjectType); /* * Create the '\Driver' object directory diff --git a/reactos/ntoskrnl/lpc/port.c b/reactos/ntoskrnl/lpc/port.c index fec68bbb8d9..affb8be8057 100644 --- a/reactos/ntoskrnl/lpc/port.c +++ b/reactos/ntoskrnl/lpc/port.c @@ -56,8 +56,8 @@ LpcpInitSystem (VOID) ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.CloseProcedure = LpcpClosePort; ObjectTypeInitializer.DeleteProcedure = LpcpDeletePort; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &LpcPortObjectType); - + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &LpcPortObjectType); + LpcpNextMessageId = 0; ExInitializeFastMutex (& LpcpLock); diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index ba98ca48825..6a2bf11e73a 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -2202,7 +2202,7 @@ MmInitSectionImplementation(VOID) ObjectTypeInitializer.GenericMapping = MmpSectionMapping; ObjectTypeInitializer.DeleteProcedure = MmpDeleteSection; ObjectTypeInitializer.CloseProcedure = MmpCloseSection; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &MmSectionObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &MmSectionObjectType); return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index 962554c9149..f10224f55c8 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -830,13 +830,20 @@ NtVdmControl@8 NtW32Call@20 NtWaitForSingleObject@12 NtWriteFile@36 + +; +; Object Manager ObAssignSecurity@16 ;ObCheckCreateObjectAccess@28 ;ObCheckObjectAccess@20 +;ObCloseHandle@4 ObCreateObject@36 +ObCreateObjectType@16 +ObDereferenceObject@4 ObDereferenceSecurityDescriptor@8 +@ObfDereferenceObject@4 ObFindHandleForObject@20 -ObGetObjectPointerCount@4 +@ObfReferenceObject@4 ObGetObjectSecurity@12 ObInsertObject@24 ObLogSecurityDescriptor@12 @@ -845,14 +852,18 @@ ObOpenObjectByName@28 ObOpenObjectByPointer@28 ObQueryNameString@16 ObQueryObjectAuditingByHandle@8 -@ObfDereferenceObject@4 -@ObfReferenceObject@4 ObReferenceObjectByHandle@24 ObReferenceObjectByName@32 ObReferenceObjectByPointer@16 +;ObReferenceSecurityDescriptor@8 ObReleaseObjectSecurity@8 -ObDereferenceObject@4 +;ObSetHandleAttributes@12 ;ObSetSecurityDescriptorInfo@24 +;ObSetSecurityObjectByPointer@12 + +; +; +; ;PfxFindPrefix ;PfxInitialize ;PfxInsertPrefix diff --git a/reactos/ntoskrnl/ob/obhandle.c b/reactos/ntoskrnl/ob/obhandle.c index a53449d8f5d..acf5634e204 100644 --- a/reactos/ntoskrnl/ob/obhandle.c +++ b/reactos/ntoskrnl/ob/obhandle.c @@ -592,64 +592,6 @@ ObpCreateHandle(PVOID ObjectBody, return STATUS_UNSUCCESSFUL; } - -/* -* @implemented -*/ -NTSTATUS STDCALL -ObQueryObjectAuditingByHandle(IN HANDLE Handle, - OUT PBOOLEAN GenerateOnClose) -{ - PHANDLE_TABLE_ENTRY HandleEntry; - PEPROCESS Process, CurrentProcess; - KAPC_STATE ApcState; - BOOLEAN AttachedToProcess = FALSE; - NTSTATUS Status = STATUS_SUCCESS; - - PAGED_CODE(); - - DPRINT("ObQueryObjectAuditingByHandle(Handle %p)\n", Handle); - - CurrentProcess = PsGetCurrentProcess(); - - KeEnterCriticalRegion(); - - if(ObIsKernelHandle(Handle, ExGetPreviousMode())) - { - Process = PsInitialSystemProcess; - Handle = ObKernelHandleToHandle(Handle); - - if (Process != CurrentProcess) - { - KeStackAttachProcess(&Process->Pcb, - &ApcState); - AttachedToProcess = TRUE; - } - } - else - Process = CurrentProcess; - - HandleEntry = ExMapHandleToPointer(Process->ObjectTable, - Handle); - if(HandleEntry != NULL) - { - *GenerateOnClose = (HandleEntry->ObAttributes & EX_HANDLE_ENTRY_AUDITONCLOSE) != 0; - - ExUnlockHandleTableEntry(Process->ObjectTable, - HandleEntry); - } - else - Status = STATUS_INVALID_HANDLE; - - if (AttachedToProcess) - { - KeUnstackDetachProcess(&ApcState); - } - - KeLeaveCriticalRegion(); - - return Status; -} /* PUBLIC FUNCTIONS *********************************************************/ ULONG diff --git a/reactos/ntoskrnl/ob/obinit.c b/reactos/ntoskrnl/ob/obinit.c index 1e5a4d5766c..7f9cc8f348a 100644 --- a/reactos/ntoskrnl/ob/obinit.c +++ b/reactos/ntoskrnl/ob/obinit.c @@ -158,7 +158,7 @@ ObInit(VOID) ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.GenericMapping = ObpTypeMapping; ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(OBJECT_TYPE); - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ObTypeObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObTypeObjectType); /* Create the Directory Type */ DPRINT("Creating Directory Type\n"); @@ -170,7 +170,7 @@ ObInit(VOID) ObjectTypeInitializer.MaintainTypeList = FALSE; ObjectTypeInitializer.GenericMapping = ObpDirectoryMapping; ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(OBJECT_DIRECTORY); - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ObDirectoryType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObDirectoryType); /* Create security descriptor */ RtlCreateSecurityDescriptor(&SecurityDescriptor, diff --git a/reactos/ntoskrnl/ob/oblife.c b/reactos/ntoskrnl/ob/oblife.c index 3a1ab23e8b9..bce18ed9966 100644 --- a/reactos/ntoskrnl/ob/oblife.c +++ b/reactos/ntoskrnl/ob/oblife.c @@ -549,11 +549,98 @@ ObpAllocateObject(IN POBJECT_CREATE_INFORMATION ObjectCreateInfo, return STATUS_SUCCESS; } +/* PUBLIC FUNCTIONS **********************************************************/ + NTSTATUS NTAPI -ObpCreateTypeObject(IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, - IN PUNICODE_STRING TypeName, - OUT POBJECT_TYPE *ObjectType) +ObCreateObject(IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, + IN POBJECT_TYPE Type, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN OUT PVOID ParseContext OPTIONAL, + IN ULONG ObjectSize, + IN ULONG PagedPoolCharge OPTIONAL, + IN ULONG NonPagedPoolCharge OPTIONAL, + OUT PVOID *Object) +{ + NTSTATUS Status; + POBJECT_CREATE_INFORMATION ObjectCreateInfo; + UNICODE_STRING ObjectName; + POBJECT_HEADER Header; + DPRINT("ObCreateObject(Type %p ObjectAttributes %p, Object %p)\n", + Type, ObjectAttributes, Object); + + /* Allocate a capture buffer */ + ObjectCreateInfo = ObpAllocateCapturedAttributes(LookasideCreateInfoList); + if (!ObjectCreateInfo) return STATUS_INSUFFICIENT_RESOURCES; + + /* Capture all the info */ + Status = ObpCaptureObjectAttributes(ObjectAttributes, + ObjectAttributesAccessMode, + FALSE, + ObjectCreateInfo, + &ObjectName); + if (NT_SUCCESS(Status)) + { + /* Validate attributes */ + if (Type->TypeInfo.InvalidAttributes & + ObjectCreateInfo->Attributes) + { + /* Fail */ + Status = STATUS_INVALID_PARAMETER; + } + else + { + /* Save the pool charges */ + ObjectCreateInfo->PagedPoolCharge = PagedPoolCharge; + ObjectCreateInfo->NonPagedPoolCharge = NonPagedPoolCharge; + + /* Allocate the Object */ + Status = ObpAllocateObject(ObjectCreateInfo, + &ObjectName, + Type, + ObjectSize + sizeof(OBJECT_HEADER), + AccessMode, + &Header); + if (NT_SUCCESS(Status)) + { + /* Return the Object */ + *Object = &Header->Body; + + /* Check if this is a permanent object */ + if (Header->Flags & OB_FLAG_PERMANENT) + { + /* Do the privilege check */ + if (!SeSinglePrivilegeCheck(SeCreatePermanentPrivilege, + ObjectAttributesAccessMode)) + { + /* Fail */ + ObpDeallocateObject(*Object); + Status = STATUS_PRIVILEGE_NOT_HELD; + } + } + + /* Return status */ + return Status; + } + } + + /* Release the Capture Info, we don't need it */ + ObpReleaseCapturedAttributes(ObjectCreateInfo); + if (ObjectName.Buffer) ObpReleaseCapturedName(&ObjectName); + } + + /* We failed, so release the Buffer */ + ObpFreeCapturedAttributes(ObjectCreateInfo, LookasideCreateInfoList); + return Status; +} + +NTSTATUS +NTAPI +ObCreateObjectType(IN PUNICODE_STRING TypeName, + IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, + IN PVOID Reserved, + OUT POBJECT_TYPE *ObjectType) { POBJECT_HEADER Header; POBJECT_TYPE LocalObjectType; @@ -675,92 +762,6 @@ ObpCreateTypeObject(IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, return Status; } -/* PUBLIC FUNCTIONS **********************************************************/ - -NTSTATUS -NTAPI -ObCreateObject(IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, - IN POBJECT_TYPE Type, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN KPROCESSOR_MODE AccessMode, - IN OUT PVOID ParseContext OPTIONAL, - IN ULONG ObjectSize, - IN ULONG PagedPoolCharge OPTIONAL, - IN ULONG NonPagedPoolCharge OPTIONAL, - OUT PVOID *Object) -{ - NTSTATUS Status; - POBJECT_CREATE_INFORMATION ObjectCreateInfo; - UNICODE_STRING ObjectName; - POBJECT_HEADER Header; - DPRINT("ObCreateObject(Type %p ObjectAttributes %p, Object %p)\n", - Type, ObjectAttributes, Object); - - /* Allocate a capture buffer */ - ObjectCreateInfo = ObpAllocateCapturedAttributes(LookasideCreateInfoList); - if (!ObjectCreateInfo) return STATUS_INSUFFICIENT_RESOURCES; - - /* Capture all the info */ - Status = ObpCaptureObjectAttributes(ObjectAttributes, - ObjectAttributesAccessMode, - FALSE, - ObjectCreateInfo, - &ObjectName); - if (NT_SUCCESS(Status)) - { - /* Validate attributes */ - if (Type->TypeInfo.InvalidAttributes & - ObjectCreateInfo->Attributes) - { - /* Fail */ - Status = STATUS_INVALID_PARAMETER; - } - else - { - /* Save the pool charges */ - ObjectCreateInfo->PagedPoolCharge = PagedPoolCharge; - ObjectCreateInfo->NonPagedPoolCharge = NonPagedPoolCharge; - - /* Allocate the Object */ - Status = ObpAllocateObject(ObjectCreateInfo, - &ObjectName, - Type, - ObjectSize + sizeof(OBJECT_HEADER), - AccessMode, - &Header); - if (NT_SUCCESS(Status)) - { - /* Return the Object */ - *Object = &Header->Body; - - /* Check if this is a permanent object */ - if (Header->Flags & OB_FLAG_PERMANENT) - { - /* Do the privilege check */ - if (!SeSinglePrivilegeCheck(SeCreatePermanentPrivilege, - ObjectAttributesAccessMode)) - { - /* Fail */ - ObpDeallocateObject(*Object); - Status = STATUS_PRIVILEGE_NOT_HELD; - } - } - - /* Return status */ - return Status; - } - } - - /* Release the Capture Info, we don't need it */ - ObpReleaseCapturedAttributes(ObjectCreateInfo); - if (ObjectName.Buffer) ObpReleaseCapturedName(&ObjectName); - } - - /* We failed, so release the Buffer */ - ObpFreeCapturedAttributes(ObjectCreateInfo, LookasideCreateInfoList); - return Status; -} - /*++ * @name NtQueryObject * @implemented NT4 diff --git a/reactos/ntoskrnl/ob/obname.c b/reactos/ntoskrnl/ob/obname.c index ee539680e76..fca1d43ac5a 100644 --- a/reactos/ntoskrnl/ob/obname.c +++ b/reactos/ntoskrnl/ob/obname.c @@ -329,7 +329,7 @@ Next: /* PUBLIC FUNCTIONS *********************************************************/ -NTSTATUS +NTSTATUS STDCALL ObQueryNameString(IN PVOID Object, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, diff --git a/reactos/ntoskrnl/ob/obref.c b/reactos/ntoskrnl/ob/obref.c index 44b386d94d8..1589c14d24c 100644 --- a/reactos/ntoskrnl/ob/obref.c +++ b/reactos/ntoskrnl/ob/obref.c @@ -69,17 +69,6 @@ ObFastReplaceObject(IN PEX_FAST_REF FastRef, /* PUBLIC FUNCTIONS *********************************************************/ -ULONG -NTAPI -ObGetObjectPointerCount(PVOID Object) -{ - PAGED_CODE(); - ASSERT(Object); - - /* Get the header and return the pointer count */ - return OBJECT_TO_OBJECT_HEADER(Object)->PointerCount; -} - VOID FASTCALL ObfReferenceObject(IN PVOID Object) diff --git a/reactos/ntoskrnl/ob/security.c b/reactos/ntoskrnl/ob/security.c index ee04aaab776..5ac2140d8cc 100644 --- a/reactos/ntoskrnl/ob/security.c +++ b/reactos/ntoskrnl/ob/security.c @@ -463,4 +463,69 @@ ObDereferenceSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, DPRINT1("ObDereferenceSecurityDescriptor is not implemented!\n"); } +/*++ +* @name ObQueryObjectAuditingByHandle +* @implemented NT5 +* +* The ObDereferenceSecurityDescriptor routine +* +* @param SecurityDescriptor +* +* +* @param Count +* +* +* @return STATUS_SUCCESS or appropriate error value. +* +* @remarks None. +* +*--*/ +NTSTATUS +NTAPI +ObQueryObjectAuditingByHandle(IN HANDLE Handle, + OUT PBOOLEAN GenerateOnClose) +{ + PHANDLE_TABLE_ENTRY HandleEntry; + PVOID HandleTable; + NTSTATUS Status = STATUS_SUCCESS; + PAGED_CODE(); + + /* Check if we're dealing with a kernel handle */ + if (ObIsKernelHandle(Handle, ExGetPreviousMode())) + { + /* Use the kernel table and convert the handle */ + HandleTable = ObpKernelHandleTable; + Handle = ObKernelHandleToHandle(Handle); + } + else + { + /* Use the process's handle table */ + HandleTable = PsGetCurrentProcess()->ObjectTable; + } + + /* Enter a critical region while we touch the handle table */ + KeEnterCriticalRegion(); + + /* Map the handle */ + HandleEntry = ExMapHandleToPointer(HandleTable, Handle); + if(HandleEntry) + { + /* Check if the flag is set */ + *GenerateOnClose = (HandleEntry->ObAttributes & + EX_HANDLE_ENTRY_AUDITONCLOSE) != 0; + + /* Unlock the entry */ + ExUnlockHandleTableEntry(HandleTable, HandleEntry); + } + else + { + /* Otherwise, fail */ + Status = STATUS_INVALID_HANDLE; + } + + /* Leave the critical region and return the status */ + KeLeaveCriticalRegion(); + return Status; +} + /* EOF */ diff --git a/reactos/ntoskrnl/ob/symlink.c b/reactos/ntoskrnl/ob/symlink.c index ec145b42525..e0f0f8981c2 100644 --- a/reactos/ntoskrnl/ob/symlink.c +++ b/reactos/ntoskrnl/ob/symlink.c @@ -194,7 +194,7 @@ ObInitSymbolicLinkImplementation(VOID) ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.ParseProcedure = ObpParseSymbolicLink; ObjectTypeInitializer.DeleteProcedure = ObpDeleteSymbolicLink; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ObSymbolicLinkType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObSymbolicLinkType); } /* PUBLIC FUNCTIONS **********************************************************/ diff --git a/reactos/ntoskrnl/ps/job.c b/reactos/ntoskrnl/ps/job.c index 2b3f9e9a931..9c59db7a43f 100644 --- a/reactos/ntoskrnl/ps/job.c +++ b/reactos/ntoskrnl/ps/job.c @@ -81,7 +81,7 @@ PsInitJobManagment ( VOID ) ObjectTypeInitializer.ValidAccessMask = JOB_OBJECT_ALL_ACCESS; ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.DeleteProcedure = PiDeleteJob; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &PsJobType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsJobType); InitializeListHead(&PsJobListHead); ExInitializeFastMutex(&PsJobListLock); diff --git a/reactos/ntoskrnl/ps/psmgr.c b/reactos/ntoskrnl/ps/psmgr.c index 562f6192e25..f2b59e83dd9 100644 --- a/reactos/ntoskrnl/ps/psmgr.c +++ b/reactos/ntoskrnl/ps/psmgr.c @@ -122,7 +122,7 @@ PsInitThreadManagment(VOID) ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = THREAD_ALL_ACCESS; ObjectTypeInitializer.DeleteProcedure = PspDeleteThread; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &PsThreadType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsThreadType); PsInitializeIdleOrFirstThread(PsInitialSystemProcess, &FirstThread, NULL, KernelMode, TRUE); FirstThread->Tcb.State = Running; @@ -163,7 +163,7 @@ PsInitProcessManagment(VOID) ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = PROCESS_ALL_ACCESS; ObjectTypeInitializer.DeleteProcedure = PspDeleteProcess; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &PsProcessType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsProcessType); InitializeListHead(&PsActiveProcessHead); ExInitializeFastMutex(&PspActiveProcessMutex); diff --git a/reactos/ntoskrnl/se/token.c b/reactos/ntoskrnl/se/token.c index 1818a2f72b4..7192f501daf 100644 --- a/reactos/ntoskrnl/se/token.c +++ b/reactos/ntoskrnl/se/token.c @@ -591,7 +591,7 @@ SepInitializeTokenImplementation(VOID) ObjectTypeInitializer.ValidAccessMask = TOKEN_ALL_ACCESS; ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.DeleteProcedure = SepDeleteToken; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &SepTokenObjectType); + ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &SepTokenObjectType); }