mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
- Remove CmpFindObject hack and use ObFindObject with on-demand ObjectCreateInfo.
- Note that the code is still wrong and will be fixed soon. svn path=/trunk/; revision=16970
This commit is contained in:
parent
b0c4274c66
commit
178ec80139
3 changed files with 67 additions and 151 deletions
|
@ -744,11 +744,4 @@ NTSTATUS
|
||||||
CmiSaveTempHive (PREGISTRY_HIVE Hive,
|
CmiSaveTempHive (PREGISTRY_HIVE Hive,
|
||||||
HANDLE FileHandle);
|
HANDLE FileHandle);
|
||||||
|
|
||||||
/* TEMPORARY HACK UNTIL PROPER PARSE ROUTINES SOON. DO NOT REMOVE -- Alex */
|
|
||||||
NTSTATUS
|
|
||||||
CmpFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
|
|
||||||
PVOID* ReturnedObject,
|
|
||||||
PUNICODE_STRING RemainingPath,
|
|
||||||
POBJECT_TYPE ObjectType);
|
|
||||||
|
|
||||||
#endif /*__INCLUDE_CM_H*/
|
#endif /*__INCLUDE_CM_H*/
|
||||||
|
|
|
@ -30,138 +30,6 @@ FAST_MUTEX CmiCallbackLock;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
/* TEMPORARY HACK UNTIL PROPER PARSE ROUTINES SOON. DO NOT REMOVE -- Alex */
|
|
||||||
NTSTATUS
|
|
||||||
CmpFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
|
|
||||||
PVOID* ReturnedObject,
|
|
||||||
PUNICODE_STRING RemainingPath,
|
|
||||||
POBJECT_TYPE ObjectType)
|
|
||||||
{
|
|
||||||
PVOID NextObject;
|
|
||||||
PVOID CurrentObject;
|
|
||||||
PVOID RootObject;
|
|
||||||
POBJECT_HEADER CurrentHeader;
|
|
||||||
NTSTATUS Status;
|
|
||||||
PWSTR current;
|
|
||||||
UNICODE_STRING PathString;
|
|
||||||
ULONG Attributes;
|
|
||||||
PUNICODE_STRING ObjectName;
|
|
||||||
|
|
||||||
PAGED_CODE();
|
|
||||||
|
|
||||||
DPRINT("CmpFindObject(ObjectAttributes 0x%p, ReturnedObject 0x%p, "
|
|
||||||
"RemainingPath 0x%p)\n",ObjectAttributes,ReturnedObject,RemainingPath);
|
|
||||||
DPRINT("ObjectAttributes->ObjectName %wZ\n",
|
|
||||||
ObjectAttributes->ObjectName);
|
|
||||||
|
|
||||||
RtlInitUnicodeString (RemainingPath, NULL);
|
|
||||||
|
|
||||||
if (ObjectAttributes->RootDirectory == NULL)
|
|
||||||
{
|
|
||||||
ObReferenceObjectByPointer(NameSpaceRoot,
|
|
||||||
DIRECTORY_TRAVERSE,
|
|
||||||
NULL,
|
|
||||||
UserMode);
|
|
||||||
CurrentObject = NameSpaceRoot;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = ObReferenceObjectByHandle(ObjectAttributes->RootDirectory,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
UserMode,
|
|
||||||
&CurrentObject,
|
|
||||||
NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectName = ObjectAttributes->ObjectName;
|
|
||||||
if (ObjectName->Length == 0 ||
|
|
||||||
ObjectName->Buffer[0] == UNICODE_NULL)
|
|
||||||
{
|
|
||||||
*ReturnedObject = CurrentObject;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ObjectAttributes->RootDirectory == NULL &&
|
|
||||||
ObjectName->Buffer[0] != L'\\')
|
|
||||||
{
|
|
||||||
ObDereferenceObject (CurrentObject);
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a zero-terminated copy of the object name */
|
|
||||||
PathString.Length = ObjectName->Length;
|
|
||||||
PathString.MaximumLength = ObjectName->Length + sizeof(WCHAR);
|
|
||||||
PathString.Buffer = ExAllocatePool (NonPagedPool,
|
|
||||||
PathString.MaximumLength);
|
|
||||||
if (PathString.Buffer == NULL)
|
|
||||||
{
|
|
||||||
ObDereferenceObject (CurrentObject);
|
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlCopyMemory (PathString.Buffer,
|
|
||||||
ObjectName->Buffer,
|
|
||||||
ObjectName->Length);
|
|
||||||
PathString.Buffer[PathString.Length / sizeof(WCHAR)] = UNICODE_NULL;
|
|
||||||
|
|
||||||
current = PathString.Buffer;
|
|
||||||
|
|
||||||
RootObject = CurrentObject;
|
|
||||||
Attributes = ObjectAttributes->Attributes;
|
|
||||||
if (ObjectType == ObSymbolicLinkType)
|
|
||||||
Attributes |= OBJ_OPENLINK;
|
|
||||||
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
DPRINT("current %S\n",current);
|
|
||||||
CurrentHeader = BODY_TO_HEADER(CurrentObject);
|
|
||||||
|
|
||||||
DPRINT("Current ObjectType %wZ\n",
|
|
||||||
&CurrentHeader->Type->Name);
|
|
||||||
|
|
||||||
if (CurrentHeader->Type->TypeInfo.ParseProcedure == NULL)
|
|
||||||
{
|
|
||||||
DPRINT("Current object can't parse\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Status = CurrentHeader->Type->TypeInfo.ParseProcedure(CurrentObject,
|
|
||||||
&NextObject,
|
|
||||||
&PathString,
|
|
||||||
¤t,
|
|
||||||
Attributes);
|
|
||||||
if (Status == STATUS_REPARSE)
|
|
||||||
{
|
|
||||||
/* reparse the object path */
|
|
||||||
NextObject = NameSpaceRoot;
|
|
||||||
current = PathString.Buffer;
|
|
||||||
|
|
||||||
ObReferenceObjectByPointer(NextObject,
|
|
||||||
DIRECTORY_TRAVERSE,
|
|
||||||
NULL,
|
|
||||||
UserMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NextObject == NULL)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ObDereferenceObject(CurrentObject);
|
|
||||||
CurrentObject = NextObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current)
|
|
||||||
RtlpCreateUnicodeString (RemainingPath, current, NonPagedPool);
|
|
||||||
RtlFreeUnicodeString (&PathString);
|
|
||||||
*ReturnedObject = CurrentObject;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -322,6 +190,8 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVOID Object;
|
PVOID Object;
|
||||||
PWSTR Start;
|
PWSTR Start;
|
||||||
|
UNICODE_STRING ObjectName;
|
||||||
|
OBJECT_CREATE_INFORMATION ObjectCreateInfo;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
@ -331,10 +201,26 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
||||||
KeyHandle,
|
KeyHandle,
|
||||||
ObjectAttributes->RootDirectory);
|
ObjectAttributes->RootDirectory);
|
||||||
|
|
||||||
Status = CmpFindObject(ObjectAttributes,
|
/* Capture all the info */
|
||||||
&Object,
|
DPRINT("Capturing Create Info\n");
|
||||||
&RemainingPath,
|
Status = ObpCaptureObjectAttributes(ObjectAttributes,
|
||||||
CmiKeyType);
|
KeGetPreviousMode(),
|
||||||
|
CmiKeyType,
|
||||||
|
&ObjectCreateInfo,
|
||||||
|
&ObjectName);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("ObpCaptureObjectAttributes() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = ObFindObject(&ObjectCreateInfo,
|
||||||
|
&ObjectName,
|
||||||
|
(PVOID*)&Object,
|
||||||
|
&RemainingPath,
|
||||||
|
CmiKeyType);
|
||||||
|
ObpReleaseCapturedAttributes(&ObjectCreateInfo);
|
||||||
|
if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("CmpFindObject failed, Status: 0x%x\n", Status);
|
DPRINT("CmpFindObject failed, Status: 0x%x\n", Status);
|
||||||
|
@ -1238,6 +1124,8 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
||||||
PVOID Object;
|
PVOID Object;
|
||||||
HANDLE hKey;
|
HANDLE hKey;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
UNICODE_STRING ObjectName;
|
||||||
|
OBJECT_CREATE_INFORMATION ObjectCreateInfo;
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
@ -1277,11 +1165,28 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
||||||
/*if (ObjectAttributes->ObjectName->Length > MAX_NAME_LENGTH)
|
/*if (ObjectAttributes->ObjectName->Length > MAX_NAME_LENGTH)
|
||||||
return(STATUS_BUFFER_OVERFLOW);*/
|
return(STATUS_BUFFER_OVERFLOW);*/
|
||||||
|
|
||||||
|
/* Capture all the info */
|
||||||
|
DPRINT("Capturing Create Info\n");
|
||||||
|
Status = ObpCaptureObjectAttributes(ObjectAttributes,
|
||||||
|
PreviousMode,
|
||||||
|
CmiKeyType,
|
||||||
|
&ObjectCreateInfo,
|
||||||
|
&ObjectName);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("ObpCaptureObjectAttributes() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
RemainingPath.Buffer = NULL;
|
RemainingPath.Buffer = NULL;
|
||||||
Status = CmpFindObject(ObjectAttributes,
|
|
||||||
&Object,
|
Status = ObFindObject(&ObjectCreateInfo,
|
||||||
&RemainingPath,
|
&ObjectName,
|
||||||
CmiKeyType);
|
(PVOID*)&Object,
|
||||||
|
&RemainingPath,
|
||||||
|
CmiKeyType);
|
||||||
|
ObpReleaseCapturedAttributes(&ObjectCreateInfo);
|
||||||
|
if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("CmpFindObject() returned 0x%08lx\n", Status);
|
DPRINT("CmpFindObject() returned 0x%08lx\n", Status);
|
||||||
|
|
|
@ -695,14 +695,32 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
||||||
PKEY_OBJECT NewKey;
|
PKEY_OBJECT NewKey;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PWSTR SubName;
|
PWSTR SubName;
|
||||||
|
UNICODE_STRING ObjectName;
|
||||||
|
OBJECT_CREATE_INFORMATION ObjectCreateInfo;
|
||||||
|
|
||||||
DPRINT("CmiConnectHive(%p, %p) called.\n",
|
DPRINT("CmiConnectHive(%p, %p) called.\n",
|
||||||
KeyObjectAttributes, RegistryHive);
|
KeyObjectAttributes, RegistryHive);
|
||||||
|
|
||||||
|
/* Capture all the info */
|
||||||
|
DPRINT("Capturing Create Info\n");
|
||||||
|
Status = ObpCaptureObjectAttributes(KeyObjectAttributes,
|
||||||
|
KernelMode,
|
||||||
|
CmiKeyType,
|
||||||
|
&ObjectCreateInfo,
|
||||||
|
&ObjectName);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("ObpCaptureObjectAttributes() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
Status = CmpFindObject(KeyObjectAttributes,
|
Status = ObFindObject(&ObjectCreateInfo,
|
||||||
(PVOID*)&ParentKey,
|
&ObjectName,
|
||||||
&RemainingPath,
|
(PVOID*)&ParentKey,
|
||||||
CmiKeyType);
|
&RemainingPath,
|
||||||
|
CmiKeyType);
|
||||||
|
ObpReleaseCapturedAttributes(&ObjectCreateInfo);
|
||||||
|
if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
|
|
Loading…
Reference in a new issue