Implemented ObOpenObjectByName()

svn path=/trunk/; revision=1545
This commit is contained in:
Eric Kohl 2001-01-20 18:34:34 +00:00
parent 3676b49d28
commit 86c7503953
6 changed files with 118 additions and 53 deletions

View file

@ -8,6 +8,14 @@
*/
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
* is granted returns a pointer to the object's body

View file

@ -80,7 +80,7 @@ NTSTATUS STDCALL NtClearEvent (IN HANDLE EventHandle)
UserMode,
(PVOID*)&Event,
NULL);
if (Status != STATUS_SUCCESS)
if (!NT_SUCCESS(Status))
{
return(Status);
}
@ -111,34 +111,24 @@ NTSTATUS STDCALL NtCreateEvent (OUT PHANDLE EventHandle,
}
NTSTATUS STDCALL NtOpenEvent (OUT PHANDLE EventHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
NTSTATUS STDCALL
NtOpenEvent(OUT PHANDLE EventHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
NTSTATUS Status;
PKEVENT Event;
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
ObjectAttributes->Attributes,
NULL,
DesiredAccess,
ExEventObjectType,
UserMode,
NULL,
(PVOID*)&Event);
if (Status != STATUS_SUCCESS)
{
return(Status);
}
DPRINT("ObjectName '%wZ'\n", ObjectAttributes->ObjectName);
Status = ObCreateHandle(PsGetCurrentProcess(),
Event,
DesiredAccess,
FALSE,
EventHandle);
ObDereferenceObject(Event);
Status = ObOpenObjectByName(ObjectAttributes,
ExEventObjectType,
0,
UserMode,
DesiredAccess,
NULL,
EventHandle);
return(STATUS_SUCCESS);
return(Status);
}
@ -222,7 +212,7 @@ NTSTATUS STDCALL NtResetEvent(HANDLE EventHandle,
UserMode,
(PVOID*)&Event,
NULL);
if (Status != STATUS_SUCCESS)
if (!NT_SUCCESS(Status))
{
return(Status);
}
@ -246,13 +236,11 @@ NTSTATUS STDCALL NtSetEvent(IN HANDLE EventHandle,
UserMode,
(PVOID*)&Event,
NULL);
if (Status != STATUS_SUCCESS)
if (!NT_SUCCESS(Status))
{
return(Status);
}
KeSetEvent(Event,EVENT_INCREMENT,FALSE);
ObDereferenceObject(Event);
return(STATUS_SUCCESS);
}

View file

@ -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
;
@ -555,7 +555,7 @@ ObDereferenceObject@4
;ObGetObjectSecurity@12
;ObInsertObject@24
ObMakeTemporaryObject@4
;ObOpenObjectByName@28
ObOpenObjectByName@28
;ObOpenObjectByPointer@28
;ObQueryNameString@16
;ObQueryObjectAuditingByHandle@8

View file

@ -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
;
@ -555,7 +555,7 @@ ObDereferenceObject=ObDereferenceObject@4
;ObGetObjectSecurity=ObGetObjectSecurity@12
;ObInsertObject=ObInsertObject@24
ObMakeTemporaryObject=ObMakeTemporaryObject@4
;ObOpenObjectByName=ObOpenObjectByName@28
ObOpenObjectByName=ObOpenObjectByName@28
;ObOpenObjectByPointer=ObOpenObjectByPointer@28
;ObQueryNameString=ObQueryNameString@16
;ObQueryObjectAuditingByHandle=ObQueryObjectAuditingByHandle@8

View file

@ -26,14 +26,15 @@ PDIRECTORY_OBJECT NameSpaceRoot = NULL;
/* FUNCTIONS **************************************************************/
NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
ULONG Attributes,
PACCESS_STATE PassedAccessState,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode,
PVOID ParseContext,
PVOID* ObjectPtr)
NTSTATUS STDCALL
ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
ULONG Attributes,
PACCESS_STATE PassedAccessState,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode,
PVOID ParseContext,
PVOID* ObjectPtr)
{
PVOID Object = NULL;
UNICODE_STRING RemainingPath;
@ -42,7 +43,7 @@ NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
InitializeObjectAttributes(&ObjectAttributes,
ObjectPath,
0,
Attributes,
NULL,
NULL);
Status = ObFindObject(&ObjectAttributes,
@ -51,12 +52,15 @@ NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
ObjectType);
if (!NT_SUCCESS(Status))
{
return(STATUS_UNSUCCESSFUL);
return(Status);
}
CHECKPOINT;
DPRINT("RemainingPath.Buffer '%S' Object %p\n", RemainingPath.Buffer, Object);
if (RemainingPath.Buffer != NULL ||
Object == NULL)
if (RemainingPath.Buffer != NULL || Object == NULL)
{
CHECKPOINT;
DPRINT("Object %p\n", Object);
*ObjectPtr = NULL;
RtlFreeUnicodeString (&RemainingPath);
return(STATUS_UNSUCCESSFUL);
@ -66,6 +70,77 @@ NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
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,
POBJECT Object,
PWSTR Name)
@ -95,7 +170,7 @@ PVOID ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
PLIST_ENTRY current = DirectoryObject->head.Flink;
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)
{
@ -133,7 +208,6 @@ PVOID ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
}
DPRINT("%s() = NULL\n",__FUNCTION__);
return(NULL);
}
NTSTATUS

View file

@ -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
* PROJECT: ReactOS kernel
@ -150,17 +150,12 @@ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
if ((ObjectAttributes->RootDirectory == NULL) && (Path[0] != '\\'))
{
ObDereferenceObject(CurrentObject);
return(STATUS_UNSUCCESSFUL);
}
if (Path)
{
// if ( Path[0] != '\\' )
// {
// RtlCreateUnicodeString (&PathString, L"\\");
// RtlAppendUnicodeToString (&PathString, Path);
// }
// else
RtlCreateUnicodeString (&PathString, Path);
current = PathString.Buffer;
}