Author: ion Date: Mon Jul 17 07:24:41 2006 New Revision: 23113
URL: http://svn.reactos.org/svn/reactos?rev=23113&view=rev Log: - Finish up implementation of NtQueryDirectoryObject by doing the final conversion.
Modified: trunk/reactos/ntoskrnl/ob/obdir.c
Modified: trunk/reactos/ntoskrnl/ob/obdir.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obdir.c?rev=231... ============================================================================== --- trunk/reactos/ntoskrnl/ob/obdir.c (original) +++ trunk/reactos/ntoskrnl/ob/obdir.c Mon Jul 17 07:24:41 2006 @@ -411,8 +411,6 @@ POBJECT_DIRECTORY Directory; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); ULONG SkipEntries = 0; - ULONG NextEntry = 0; - ULONG CopyBytes = 0; NTSTATUS Status = STATUS_SUCCESS; PVOID LocalBuffer; POBJECT_DIRECTORY_INFORMATION DirectoryInfo; @@ -423,6 +421,7 @@ POBJECT_HEADER ObjectHeader; POBJECT_HEADER_NAME_INFO ObjectNameInfo; UNICODE_STRING Name; + PWSTR p; PAGED_CODE();
/* Check if we need to do any probing */ @@ -573,19 +572,59 @@ /* Make sure we got success */ if (NT_SUCCESS(Status)) { - /* We need to parse all the entries and convert absolute to relative */ - DPRINT1("NOT FULLY IMPLEMENTED\n"); - Status = STATUS_INSUFFICIENT_RESOURCES; - - /* Copy the buffer */ - RtlMoveMemory(Buffer, - LocalBuffer, - (TotalLength <= BufferLength) ? - TotalLength : BufferLength); - - /* Check if the caller requested the return length and return it*/ - if (ReturnLength) *ReturnLength = TotalLength; - } + /* Clear the current pointer and set it */ + RtlZeroMemory(DirectoryInfo, sizeof(OBJECT_DIRECTORY_INFORMATION)); + DirectoryInfo++; + + /* Set the buffer here now and loop entries */ + p = (PWSTR)DirectoryInfo; + DirectoryInfo = LocalBuffer; + while (Count--) + { + /* Copy the name buffer */ + RtlMoveMemory(p, + DirectoryInfo->Name.Buffer, + DirectoryInfo->Name.Length); + + /* Now fixup the pointers */ + DirectoryInfo->Name.Buffer = (PVOID)((ULONG_PTR)Buffer + + ((ULONG_PTR)p - + (ULONG_PTR)LocalBuffer)); + + /* Advance in buffer and NULL-terminate */ + p = (PVOID)((ULONG_PTR)p + DirectoryInfo->Name.Length); + *p++ = UNICODE_NULL; + + /* Now copy the type name buffer */ + RtlMoveMemory(p, + DirectoryInfo->TypeName.Buffer, + DirectoryInfo->TypeName.Length); + + /* Now fixup the pointers */ + DirectoryInfo->TypeName.Buffer = (PVOID)((ULONG_PTR)Buffer + + ((ULONG_PTR)p - + (ULONG_PTR)LocalBuffer)); + + /* Advance in buffer and NULL-terminate */ + p = (PVOID)((ULONG_PTR)p + DirectoryInfo->TypeName.Length); + *p++ = UNICODE_NULL; + + /* Move to the next entry */ + DirectoryInfo++; + } + + /* Set the key */ + *Context = CurrentEntry; + } + + /* Copy the buffer */ + RtlMoveMemory(Buffer, + LocalBuffer, + (TotalLength <= BufferLength) ? + TotalLength : BufferLength); + + /* Check if the caller requested the return length and return it*/ + if (ReturnLength) *ReturnLength = TotalLength;
/* Dereference the directory and free our buffer */ ObDereferenceObject(Directory);