mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 04:20:46 +00:00
Implemented ObOpenObjectByName()
svn path=/trunk/; revision=1545
This commit is contained in:
parent
3676b49d28
commit
86c7503953
6 changed files with 118 additions and 53 deletions
|
@ -8,6 +8,14 @@
|
||||||
*/
|
*/
|
||||||
VOID STDCALL ObDereferenceObject(PVOID Object);
|
VOID STDCALL ObDereferenceObject(PVOID Object);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
POBJECT_TYPE ObjectType,
|
||||||
|
ULONG Unknown3, /* ?? */
|
||||||
|
KPROCESSOR_MODE AccessMode,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
PACCESS_STATE PassedAccessState,
|
||||||
|
PHANDLE Handle);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Performs access validation on an object handle and if access
|
* FUNCTION: Performs access validation on an object handle and if access
|
||||||
* is granted returns a pointer to the object's body
|
* is granted returns a pointer to the object's body
|
||||||
|
|
|
@ -80,7 +80,7 @@ NTSTATUS STDCALL NtClearEvent (IN HANDLE EventHandle)
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID*)&Event,
|
(PVOID*)&Event,
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -111,34 +111,24 @@ NTSTATUS STDCALL NtCreateEvent (OUT PHANDLE EventHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtOpenEvent (OUT PHANDLE EventHandle,
|
NTSTATUS STDCALL
|
||||||
IN ACCESS_MASK DesiredAccess,
|
NtOpenEvent(OUT PHANDLE EventHandle,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKEVENT Event;
|
|
||||||
|
|
||||||
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
|
DPRINT("ObjectName '%wZ'\n", ObjectAttributes->ObjectName);
|
||||||
ObjectAttributes->Attributes,
|
|
||||||
NULL,
|
|
||||||
DesiredAccess,
|
|
||||||
ExEventObjectType,
|
|
||||||
UserMode,
|
|
||||||
NULL,
|
|
||||||
(PVOID*)&Event);
|
|
||||||
if (Status != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = ObCreateHandle(PsGetCurrentProcess(),
|
Status = ObOpenObjectByName(ObjectAttributes,
|
||||||
Event,
|
ExEventObjectType,
|
||||||
DesiredAccess,
|
0,
|
||||||
FALSE,
|
UserMode,
|
||||||
EventHandle);
|
DesiredAccess,
|
||||||
ObDereferenceObject(Event);
|
NULL,
|
||||||
|
EventHandle);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,7 +212,7 @@ NTSTATUS STDCALL NtResetEvent(HANDLE EventHandle,
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID*)&Event,
|
(PVOID*)&Event,
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -246,13 +236,11 @@ NTSTATUS STDCALL NtSetEvent(IN HANDLE EventHandle,
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID*)&Event,
|
(PVOID*)&Event,
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
KeSetEvent(Event,EVENT_INCREMENT,FALSE);
|
KeSetEvent(Event,EVENT_INCREMENT,FALSE);
|
||||||
|
|
||||||
|
|
||||||
ObDereferenceObject(Event);
|
ObDereferenceObject(Event);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntoskrnl.def,v 1.94 2001/01/14 15:36:32 ekohl Exp $
|
; $Id: ntoskrnl.def,v 1.95 2001/01/20 18:33:31 ekohl Exp $
|
||||||
;
|
;
|
||||||
; reactos/ntoskrnl/ntoskrnl.def
|
; reactos/ntoskrnl/ntoskrnl.def
|
||||||
;
|
;
|
||||||
|
@ -555,7 +555,7 @@ ObDereferenceObject@4
|
||||||
;ObGetObjectSecurity@12
|
;ObGetObjectSecurity@12
|
||||||
;ObInsertObject@24
|
;ObInsertObject@24
|
||||||
ObMakeTemporaryObject@4
|
ObMakeTemporaryObject@4
|
||||||
;ObOpenObjectByName@28
|
ObOpenObjectByName@28
|
||||||
;ObOpenObjectByPointer@28
|
;ObOpenObjectByPointer@28
|
||||||
;ObQueryNameString@16
|
;ObQueryNameString@16
|
||||||
;ObQueryObjectAuditingByHandle@8
|
;ObQueryObjectAuditingByHandle@8
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntoskrnl.edf,v 1.81 2001/01/14 15:36:32 ekohl Exp $
|
; $Id: ntoskrnl.edf,v 1.82 2001/01/20 18:33:31 ekohl Exp $
|
||||||
;
|
;
|
||||||
; reactos/ntoskrnl/ntoskrnl.def
|
; reactos/ntoskrnl/ntoskrnl.def
|
||||||
;
|
;
|
||||||
|
@ -555,7 +555,7 @@ ObDereferenceObject=ObDereferenceObject@4
|
||||||
;ObGetObjectSecurity=ObGetObjectSecurity@12
|
;ObGetObjectSecurity=ObGetObjectSecurity@12
|
||||||
;ObInsertObject=ObInsertObject@24
|
;ObInsertObject=ObInsertObject@24
|
||||||
ObMakeTemporaryObject=ObMakeTemporaryObject@4
|
ObMakeTemporaryObject=ObMakeTemporaryObject@4
|
||||||
;ObOpenObjectByName=ObOpenObjectByName@28
|
ObOpenObjectByName=ObOpenObjectByName@28
|
||||||
;ObOpenObjectByPointer=ObOpenObjectByPointer@28
|
;ObOpenObjectByPointer=ObOpenObjectByPointer@28
|
||||||
;ObQueryNameString=ObQueryNameString@16
|
;ObQueryNameString=ObQueryNameString@16
|
||||||
;ObQueryObjectAuditingByHandle=ObQueryObjectAuditingByHandle@8
|
;ObQueryObjectAuditingByHandle=ObQueryObjectAuditingByHandle@8
|
||||||
|
|
|
@ -26,14 +26,15 @@ PDIRECTORY_OBJECT NameSpaceRoot = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS **************************************************************/
|
/* FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
NTSTATUS STDCALL
|
||||||
ULONG Attributes,
|
ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||||
PACCESS_STATE PassedAccessState,
|
ULONG Attributes,
|
||||||
ACCESS_MASK DesiredAccess,
|
PACCESS_STATE PassedAccessState,
|
||||||
POBJECT_TYPE ObjectType,
|
ACCESS_MASK DesiredAccess,
|
||||||
KPROCESSOR_MODE AccessMode,
|
POBJECT_TYPE ObjectType,
|
||||||
PVOID ParseContext,
|
KPROCESSOR_MODE AccessMode,
|
||||||
PVOID* ObjectPtr)
|
PVOID ParseContext,
|
||||||
|
PVOID* ObjectPtr)
|
||||||
{
|
{
|
||||||
PVOID Object = NULL;
|
PVOID Object = NULL;
|
||||||
UNICODE_STRING RemainingPath;
|
UNICODE_STRING RemainingPath;
|
||||||
|
@ -42,7 +43,7 @@ NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
ObjectPath,
|
ObjectPath,
|
||||||
0,
|
Attributes,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
Status = ObFindObject(&ObjectAttributes,
|
Status = ObFindObject(&ObjectAttributes,
|
||||||
|
@ -51,12 +52,15 @@ NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||||
ObjectType);
|
ObjectType);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
CHECKPOINT;
|
||||||
|
DPRINT("RemainingPath.Buffer '%S' Object %p\n", RemainingPath.Buffer, Object);
|
||||||
|
|
||||||
if (RemainingPath.Buffer != NULL ||
|
if (RemainingPath.Buffer != NULL || Object == NULL)
|
||||||
Object == NULL)
|
|
||||||
{
|
{
|
||||||
|
CHECKPOINT;
|
||||||
|
DPRINT("Object %p\n", Object);
|
||||||
*ObjectPtr = NULL;
|
*ObjectPtr = NULL;
|
||||||
RtlFreeUnicodeString (&RemainingPath);
|
RtlFreeUnicodeString (&RemainingPath);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
@ -66,6 +70,77 @@ NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* NAME EXPORTED
|
||||||
|
* ObOpenObjectByName
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
* Obtain a handle to an existing object.
|
||||||
|
*
|
||||||
|
* ARGUMENTS
|
||||||
|
* ObjectAttributes
|
||||||
|
* ...
|
||||||
|
* ObjectType
|
||||||
|
* ...
|
||||||
|
* Unknown3
|
||||||
|
* ???
|
||||||
|
* AccessMode
|
||||||
|
* ...
|
||||||
|
* DesiredAccess
|
||||||
|
* ...
|
||||||
|
* PassedAccessState
|
||||||
|
* ...
|
||||||
|
* Handle
|
||||||
|
* Handle to close.
|
||||||
|
*
|
||||||
|
* RETURN VALUE
|
||||||
|
* Status.
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
POBJECT_TYPE ObjectType,
|
||||||
|
ULONG Unknown3, /* ?? */
|
||||||
|
KPROCESSOR_MODE AccessMode,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
PACCESS_STATE PassedAccessState,
|
||||||
|
PHANDLE Handle)
|
||||||
|
{
|
||||||
|
UNICODE_STRING RemainingPath;
|
||||||
|
PVOID Object = NULL;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("ObOpenObjectByName()\n");
|
||||||
|
|
||||||
|
Status = ObFindObject(ObjectAttributes,
|
||||||
|
&Object,
|
||||||
|
&RemainingPath,
|
||||||
|
ObjectType);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RemainingPath.Buffer != NULL ||
|
||||||
|
Object == NULL)
|
||||||
|
{
|
||||||
|
RtlFreeUnicodeString(&RemainingPath);
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = ObCreateHandle(PsGetCurrentProcess(),
|
||||||
|
Object,
|
||||||
|
DesiredAccess,
|
||||||
|
FALSE,
|
||||||
|
Handle);
|
||||||
|
|
||||||
|
ObDereferenceObject(Object);
|
||||||
|
RtlFreeUnicodeString(&RemainingPath);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL ObAddEntryDirectory(PDIRECTORY_OBJECT Parent,
|
VOID STDCALL ObAddEntryDirectory(PDIRECTORY_OBJECT Parent,
|
||||||
POBJECT Object,
|
POBJECT Object,
|
||||||
PWSTR Name)
|
PWSTR Name)
|
||||||
|
@ -95,7 +170,7 @@ PVOID ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
|
||||||
PLIST_ENTRY current = DirectoryObject->head.Flink;
|
PLIST_ENTRY current = DirectoryObject->head.Flink;
|
||||||
POBJECT_HEADER current_obj;
|
POBJECT_HEADER current_obj;
|
||||||
|
|
||||||
DPRINT("ObDirLookup(dir %x, name %S)\n",DirectoryObject, Name);
|
DPRINT("ObFindEntryDirectory(dir %x, name %S)\n",DirectoryObject, Name);
|
||||||
|
|
||||||
if (Name[0]==0)
|
if (Name[0]==0)
|
||||||
{
|
{
|
||||||
|
@ -133,7 +208,6 @@ PVOID ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
|
||||||
}
|
}
|
||||||
DPRINT("%s() = NULL\n",__FUNCTION__);
|
DPRINT("%s() = NULL\n",__FUNCTION__);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: object.c,v 1.29 2000/10/22 16:36:53 ekohl Exp $
|
/* $Id: object.c,v 1.30 2001/01/20 18:33:05 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -150,17 +150,12 @@ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
|
||||||
if ((ObjectAttributes->RootDirectory == NULL) && (Path[0] != '\\'))
|
if ((ObjectAttributes->RootDirectory == NULL) && (Path[0] != '\\'))
|
||||||
{
|
{
|
||||||
|
ObDereferenceObject(CurrentObject);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Path)
|
if (Path)
|
||||||
{
|
{
|
||||||
// if ( Path[0] != '\\' )
|
|
||||||
// {
|
|
||||||
// RtlCreateUnicodeString (&PathString, L"\\");
|
|
||||||
// RtlAppendUnicodeToString (&PathString, Path);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
RtlCreateUnicodeString (&PathString, Path);
|
RtlCreateUnicodeString (&PathString, Path);
|
||||||
current = PathString.Buffer;
|
current = PathString.Buffer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue