mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- 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
This commit is contained in:
parent
0aeaea0fb7
commit
a46ee938fa
27 changed files with 213 additions and 199 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -329,7 +329,7 @@ Next:
|
|||
|
||||
/* PUBLIC FUNCTIONS *********************************************************/
|
||||
|
||||
NTSTATUS
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ObQueryNameString(IN PVOID Object,
|
||||
OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -463,4 +463,69 @@ ObDereferenceSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|||
DPRINT1("ObDereferenceSecurityDescriptor is not implemented!\n");
|
||||
}
|
||||
|
||||
/*++
|
||||
* @name ObQueryObjectAuditingByHandle
|
||||
* @implemented NT5
|
||||
*
|
||||
* The ObDereferenceSecurityDescriptor routine <FILLMEIN>
|
||||
*
|
||||
* @param SecurityDescriptor
|
||||
* <FILLMEIN>
|
||||
*
|
||||
* @param Count
|
||||
* <FILLMEIN>
|
||||
*
|
||||
* @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 */
|
||||
|
|
|
@ -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 **********************************************************/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue