Author: ion Date: Thu May 25 08:17:29 2006 New Revision: 22037
URL: http://svn.reactos.ru/svn/reactos?rev=22037&view=rev Log: - Fix ObReferenceObjectByName and ObOpenObjectByName not to blissfully ignore the AccessState and ParseContext parameters. - Change ObFindObject's prototype to be able to accomodate these two parameters so that they can be sent to the parse routine.
Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c trunk/reactos/ntoskrnl/cm/registry.c trunk/reactos/ntoskrnl/include/internal/ob.h trunk/reactos/ntoskrnl/ob/obhandle.c trunk/reactos/ntoskrnl/ob/obname.c trunk/reactos/ntoskrnl/ob/obref.c
Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=220... ============================================================================== --- trunk/reactos/ntoskrnl/cm/ntfunc.c (original) +++ trunk/reactos/ntoskrnl/cm/ntfunc.c Thu May 25 08:17:29 2006 @@ -264,7 +264,9 @@ (PVOID*)&Object, &RemainingPath, CmiKeyType, - &Context); + &Context, + NULL, + NULL); if (!NT_SUCCESS(Status)) { PostCreateKeyInfo.Object = NULL; @@ -1333,7 +1335,9 @@ (PVOID*)&Object, &RemainingPath, CmiKeyType, - &Context); + &Context, + NULL, + NULL); if (!NT_SUCCESS(Status)) { DPRINT("CmpFindObject() returned 0x%08lx\n", Status);
Modified: trunk/reactos/ntoskrnl/cm/registry.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/cm/registry.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/cm/registry.c (original) +++ trunk/reactos/ntoskrnl/cm/registry.c Thu May 25 08:17:29 2006 @@ -727,7 +727,9 @@ (PVOID*)&ParentKey, &RemainingPath, CmiKeyType, - &Context); + &Context, + NULL, + NULL); ObpReleaseCapturedAttributes(&ObjectCreateInfo); if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); if (!NT_SUCCESS(Status))
Modified: trunk/reactos/ntoskrnl/include/internal/ob.h URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/include/internal/ob... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ob.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ob.h Thu May 25 08:17:29 2006 @@ -118,7 +118,9 @@ PVOID* ReturnedObject, PUNICODE_STRING RemainingPath, POBJECT_TYPE ObjectType, - POBP_LOOKUP_CONTEXT Context + POBP_LOOKUP_CONTEXT Context, + IN PACCESS_STATE AccessState, + IN PVOID ParseContext );
NTSTATUS
Modified: trunk/reactos/ntoskrnl/ob/obhandle.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/ob/obhandle.c (original) +++ trunk/reactos/ntoskrnl/ob/obhandle.c Thu May 25 08:17:29 2006 @@ -752,7 +752,8 @@ return Header->HandleCount; }
-NTSTATUS STDCALL +NTSTATUS +NTAPI ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, IN POBJECT_TYPE ObjectType, IN OUT PVOID ParseContext, @@ -767,43 +768,54 @@ OBJECT_CREATE_INFORMATION ObjectCreateInfo; NTSTATUS Status; OBP_LOOKUP_CONTEXT Context; - - PAGED_CODE(); - - DPRINT("ObOpenObjectByName(...)\n"); + AUX_DATA AuxData; + PGENERIC_MAPPING GenericMapping = NULL; + ACCESS_STATE AccessState; + PAGED_CODE();
/* Capture all the info */ - DPRINT("Capturing Create Info\n"); Status = ObpCaptureObjectAttributes(ObjectAttributes, - AccessMode, - ObjectType, - &ObjectCreateInfo, - &ObjectName); - if (!NT_SUCCESS(Status)) - { - DPRINT("ObpCaptureObjectAttributes() failed (Status %lx)\n", Status); - return Status; - } - + AccessMode, + ObjectType, + &ObjectCreateInfo, + &ObjectName); + if (!NT_SUCCESS(Status)) return Status; + + /* Check if we didn't get an access state */ + if (!PassedAccessState) + { + /* Try to get the generic mapping if we can */ + if (ObjectType) GenericMapping = &ObjectType->TypeInfo.GenericMapping; + + /* Use our built-in access state */ + PassedAccessState = &AccessState; + Status = SeCreateAccessState(&AccessState, + &AuxData, + DesiredAccess, + GenericMapping); + if (!NT_SUCCESS(Status)) goto Quickie; + } + + /* Get the security descriptor */ + if (ObjectCreateInfo.SecurityDescriptor) + { + /* Save it in the access state */ + PassedAccessState->SecurityDescriptor = + ObjectCreateInfo.SecurityDescriptor; + } + + /* Now do the lookup */ Status = ObFindObject(&ObjectCreateInfo, - &ObjectName, - &Object, - &RemainingPath, - ObjectType, - &Context); - if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); - if (!NT_SUCCESS(Status)) - { - DPRINT("ObFindObject() failed (Status %lx)\n", Status); - goto Cleanup; - } - - DPRINT("OBject: %p, Remaining Path: %wZ\n", Object, &RemainingPath); - if (Object == NULL) - { - Status = STATUS_UNSUCCESSFUL; - goto Cleanup; - } + &ObjectName, + &Object, + &RemainingPath, + ObjectType, + &Context, // Temporary Hack + PassedAccessState, + ParseContext); + if (!NT_SUCCESS(Status)) goto Cleanup; + + /* ROS Hack */ if (RemainingPath.Buffer != NULL) { if (wcschr(RemainingPath.Buffer + 1, L'\') == NULL) @@ -813,26 +825,37 @@ goto Cleanup; }
+ /* Create the actual handle now */ Status = ObpCreateHandle(Object, - DesiredAccess, - ObjectCreateInfo.Attributes, - Handle); + DesiredAccess, + ObjectCreateInfo.Attributes, + Handle);
Cleanup: - if (Object != NULL) - { - ObDereferenceObject(Object); - } + /* Dereference the object */ + if (Object) ObDereferenceObject(Object); + + /* ROS Hacl: Free the remaining path */ RtlFreeUnicodeString(&RemainingPath); + + /* Delete the access state */ + if (PassedAccessState == &AccessState) + { + SeDeleteAccessState(PassedAccessState); + } + + /* Release the object attributes and return status */ +Quickie: ObpReleaseCapturedAttributes(&ObjectCreateInfo); - + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); return Status; }
/* * @implemented */ -NTSTATUS STDCALL +NTSTATUS +NTAPI ObOpenObjectByPointer(IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState, @@ -842,28 +865,24 @@ OUT PHANDLE Handle) { NTSTATUS Status; - - PAGED_CODE(); - - DPRINT("ObOpenObjectByPointer()\n"); - + PAGED_CODE(); + + /* Reference the object */ Status = ObReferenceObjectByPointer(Object, - 0, - ObjectType, - AccessMode); - if (!NT_SUCCESS(Status)) - { - return Status; - } - + 0, + ObjectType, + AccessMode); + if (!NT_SUCCESS(Status)) return Status; + + /* Create the handle */ Status = ObpCreateHandle(Object, - DesiredAccess, - HandleAttributes, - Handle); - + DesiredAccess, + HandleAttributes, + Handle); + + /* ROS Hack: Dereference the object and return */ ObDereferenceObject(Object); - - return STATUS_SUCCESS; + return Status; }
NTSTATUS STDCALL @@ -921,11 +940,9 @@ PSECURITY_DESCRIPTOR NewSecurityDescriptor = NULL; SECURITY_SUBJECT_CONTEXT SubjectContext; OBP_LOOKUP_CONTEXT Context; - PAGED_CODE();
/* Get the Header and Create Info */ - DPRINT("ObInsertObject: %x\n", Object); Header = BODY_TO_HEADER(Object); ObjectCreateInfo = Header->ObjectCreateInfo; ObjectNameInfo = HEADER_TO_OBJECT_NAME(Header); @@ -939,7 +956,9 @@ &FoundObject, &RemainingPath, NULL, - &Context); + &Context, + NULL, + NULL); DPRINT("FoundObject: %x, Path: %wZ\n", FoundObject, &RemainingPath); if (!NT_SUCCESS(Status)) {
Modified: trunk/reactos/ntoskrnl/ob/obname.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obname.c?rev=220... ============================================================================== --- trunk/reactos/ntoskrnl/ob/obname.c (original) +++ trunk/reactos/ntoskrnl/ob/obname.c Thu May 25 08:17:29 2006 @@ -27,7 +27,9 @@ PVOID* ReturnedObject, PUNICODE_STRING RemainingPath, POBJECT_TYPE ObjectType, - POBP_LOOKUP_CONTEXT Context) + POBP_LOOKUP_CONTEXT Context, + IN PACCESS_STATE AccessState, + IN PVOID ParseContext) { PVOID NextObject; PVOID CurrentObject;
Modified: trunk/reactos/ntoskrnl/ob/obref.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obref.c?rev=2203... ============================================================================== --- trunk/reactos/ntoskrnl/ob/obref.c (original) +++ trunk/reactos/ntoskrnl/ob/obref.c Thu May 25 08:17:29 2006 @@ -188,7 +188,8 @@ return(STATUS_SUCCESS); }
-NTSTATUS STDCALL +NTSTATUS +NTAPI ObReferenceObjectByName(PUNICODE_STRING ObjectPath, ULONG Attributes, PACCESS_STATE PassedAccessState, @@ -204,50 +205,66 @@ OBJECT_CREATE_INFORMATION ObjectCreateInfo; NTSTATUS Status; OBP_LOOKUP_CONTEXT Context; - - PAGED_CODE(); + AUX_DATA AuxData; + ACCESS_STATE AccessState;
/* Capture the name */ - DPRINT("Capturing Name\n"); Status = ObpCaptureObjectName(&ObjectName, ObjectPath, AccessMode); - if (!NT_SUCCESS(Status)) - { - DPRINT("ObpCaptureObjectName() failed (Status %lx)\n", Status); - return Status; - } - - /* - * Create a fake ObjectCreateInfo structure. Note that my upcoming - * ObFindObject refactoring will remove the need for this hack. - */ + if (!NT_SUCCESS(Status)) return Status; + + /* Check if we didn't get an access state */ + if (!PassedAccessState) + { + /* Use our built-in access state */ + PassedAccessState = &AccessState; + Status = SeCreateAccessState(&AccessState, + &AuxData, + DesiredAccess, + &ObjectType->TypeInfo.GenericMapping); + if (!NT_SUCCESS(Status)) goto Quickie; + } + + /* + * Create a fake ObjectCreateInfo structure. Note that my upcoming + * ObFindObject refactoring will remove the need for this hack. + */ ObjectCreateInfo.RootDirectory = NULL; ObjectCreateInfo.Attributes = Attributes; - Status = ObFindObject(&ObjectCreateInfo, - &ObjectName, - &Object, - &RemainingPath, - ObjectType, - &Context); - - if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); - - if (!NT_SUCCESS(Status)) - { - return(Status); - } - DPRINT("RemainingPath.Buffer '%S' Object %p\n", RemainingPath.Buffer, Object); - + &ObjectName, + &Object, + &RemainingPath, + ObjectType, + &Context, + PassedAccessState, + ParseContext); + if (!NT_SUCCESS(Status)) goto Quickie; + + /* ROS Hack */ if (RemainingPath.Buffer != NULL || Object == NULL) { - DPRINT("Object %p\n", Object); *ObjectPtr = NULL; RtlFreeUnicodeString (&RemainingPath); - return(STATUS_OBJECT_NAME_NOT_FOUND); - } + Status = STATUS_OBJECT_NAME_NOT_FOUND; + goto Quickie; + } + + /* Return the object */ *ObjectPtr = Object; - RtlFreeUnicodeString (&RemainingPath); - return(STATUS_SUCCESS); + + /* ROS Hack: Free the remaining path */ + RtlFreeUnicodeString(&RemainingPath); + + /* Free the access state */ + if (PassedAccessState == &AccessState) + { + SeDeleteAccessState(PassedAccessState); + } + +Quickie: + /* Free the captured name if we had one, and return status */ + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); + return Status; }
NTSTATUS STDCALL