mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +00:00
- Get rid of the intriguing idea that exported/public APIs should have prototypes with inversed parameters (fix ObOpenObjectByName and all its callers).
- Isolate ObFindObject into CmFindObject for the registry routines. Because of their well-known abuse of Ob, it's better to give them their internal routine so that when/if Ob ever gets fixed to parse properly, it won't force a re-write of Cm's object routines. svn path=/trunk/; revision=22047
This commit is contained in:
parent
facb8f26f0
commit
340a5ed71a
22 changed files with 235 additions and 35 deletions
|
@ -9535,10 +9535,10 @@ DDKAPI
|
|||
ObOpenObjectByName(
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN POBJECT_TYPE ObjectType,
|
||||
IN OUT PVOID ParseContext OPTIONAL,
|
||||
IN KPROCESSOR_MODE AccessMode,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN PACCESS_STATE PassedAccessState,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN OUT PVOID ParseContext OPTIONAL,
|
||||
OUT PHANDLE Handle);
|
||||
|
||||
NTOSAPI
|
||||
|
|
|
@ -708,4 +708,15 @@ NTSTATUS
|
|||
CmiSaveTempHive (PREGISTRY_HIVE Hive,
|
||||
HANDLE FileHandle);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmFindObject(
|
||||
POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
||||
PUNICODE_STRING ObjectName,
|
||||
PVOID* ReturnedObject,
|
||||
PUNICODE_STRING RemainingPath,
|
||||
POBJECT_TYPE ObjectType,
|
||||
IN PACCESS_STATE AccessState,
|
||||
IN PVOID ParseContext
|
||||
);
|
||||
#endif /*__INCLUDE_CM_H*/
|
||||
|
|
|
@ -199,7 +199,6 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
KPROCESSOR_MODE PreviousMode;
|
||||
UNICODE_STRING CapturedClass = {0};
|
||||
HANDLE hKey;
|
||||
OBP_LOOKUP_CONTEXT Context;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -259,12 +258,11 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
goto Cleanup;
|
||||
}
|
||||
|
||||
Status = ObFindObject(&ObjectCreateInfo,
|
||||
Status = CmFindObject(&ObjectCreateInfo,
|
||||
&ObjectName,
|
||||
(PVOID*)&Object,
|
||||
&RemainingPath,
|
||||
CmiKeyType,
|
||||
&Context,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -1266,7 +1264,6 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
|||
OBJECT_CREATE_INFORMATION ObjectCreateInfo;
|
||||
REG_PRE_OPEN_KEY_INFORMATION PreOpenKeyInfo;
|
||||
REG_POST_OPEN_KEY_INFORMATION PostOpenKeyInfo;
|
||||
OBP_LOOKUP_CONTEXT Context;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -1330,12 +1327,11 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
|||
|
||||
RemainingPath.Buffer = NULL;
|
||||
|
||||
Status = ObFindObject(&ObjectCreateInfo,
|
||||
Status = CmFindObject(&ObjectCreateInfo,
|
||||
&ObjectName,
|
||||
(PVOID*)&Object,
|
||||
&RemainingPath,
|
||||
CmiKeyType,
|
||||
&Context,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
|
|
@ -704,7 +704,6 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
PWSTR SubName;
|
||||
UNICODE_STRING ObjectName;
|
||||
OBJECT_CREATE_INFORMATION ObjectCreateInfo;
|
||||
OBP_LOOKUP_CONTEXT Context;
|
||||
|
||||
DPRINT("CmiConnectHive(%p, %p) called.\n",
|
||||
KeyObjectAttributes, RegistryHive);
|
||||
|
@ -722,12 +721,11 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
return Status;
|
||||
}
|
||||
|
||||
Status = ObFindObject(&ObjectCreateInfo,
|
||||
Status = CmFindObject(&ObjectCreateInfo,
|
||||
&ObjectName,
|
||||
(PVOID*)&ParentKey,
|
||||
&RemainingPath,
|
||||
CmiKeyType,
|
||||
&Context,
|
||||
NULL,
|
||||
NULL);
|
||||
ObpReleaseCapturedAttributes(&ObjectCreateInfo);
|
||||
|
@ -857,8 +855,8 @@ CmiDisconnectHive (IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
|
||||
Status = ObOpenObjectByName (KeyObjectAttributes,
|
||||
CmiKeyType,
|
||||
NULL,
|
||||
KernelMode,
|
||||
NULL,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
NULL,
|
||||
&KeyHandle);
|
||||
|
|
|
@ -23,7 +23,202 @@ CmiGetLinkTarget(PREGISTRY_HIVE RegistryHive,
|
|||
PUNICODE_STRING TargetPath);
|
||||
|
||||
/* FUNCTONS *****************************************************************/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmFindObject(POBJECT_CREATE_INFORMATION ObjectCreateInfo,
|
||||
PUNICODE_STRING ObjectName,
|
||||
PVOID* ReturnedObject,
|
||||
PUNICODE_STRING RemainingPath,
|
||||
POBJECT_TYPE ObjectType,
|
||||
IN PACCESS_STATE AccessState,
|
||||
IN PVOID ParseContext)
|
||||
{
|
||||
PVOID NextObject;
|
||||
PVOID CurrentObject;
|
||||
PVOID RootObject;
|
||||
POBJECT_HEADER CurrentHeader;
|
||||
NTSTATUS Status;
|
||||
PWSTR current;
|
||||
UNICODE_STRING PathString;
|
||||
ULONG Attributes;
|
||||
UNICODE_STRING CurrentUs;
|
||||
OBP_LOOKUP_CONTEXT Context;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
DPRINT("CmindObject(ObjectCreateInfo %x, ReturnedObject %x, "
|
||||
"RemainingPath %x)\n",ObjectCreateInfo,ReturnedObject,RemainingPath);
|
||||
|
||||
RtlInitUnicodeString (RemainingPath, NULL);
|
||||
|
||||
if (ObjectCreateInfo->RootDirectory == NULL)
|
||||
{
|
||||
ObReferenceObjectByPointer(NameSpaceRoot,
|
||||
DIRECTORY_TRAVERSE,
|
||||
NULL,
|
||||
ObjectCreateInfo->ProbeMode);
|
||||
CurrentObject = NameSpaceRoot;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = ObReferenceObjectByHandle(ObjectCreateInfo->RootDirectory,
|
||||
0,
|
||||
NULL,
|
||||
ObjectCreateInfo->ProbeMode,
|
||||
&CurrentObject,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectName->Length == 0 ||
|
||||
ObjectName->Buffer[0] == UNICODE_NULL)
|
||||
{
|
||||
*ReturnedObject = CurrentObject;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (ObjectCreateInfo->RootDirectory == NULL &&
|
||||
ObjectName->Buffer[0] != L'\\')
|
||||
{
|
||||
ObDereferenceObject (CurrentObject);
|
||||
DPRINT1("failed\n");
|
||||
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 = ObjectCreateInfo->Attributes;
|
||||
if (ObjectType == ObSymbolicLinkType)
|
||||
Attributes |= OBJ_OPENLINK;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
CurrentHeader = OBJECT_TO_OBJECT_HEADER(CurrentObject);
|
||||
|
||||
/* Loop as long as we're dealing with a directory */
|
||||
while (CurrentHeader->Type == ObDirectoryType)
|
||||
{
|
||||
PWSTR Start, End;
|
||||
PVOID FoundObject;
|
||||
UNICODE_STRING StartUs;
|
||||
NextObject = NULL;
|
||||
|
||||
if (!current) goto Next;
|
||||
|
||||
Start = current;
|
||||
if (*Start == L'\\') Start++;
|
||||
|
||||
End = wcschr(Start, L'\\');
|
||||
if (End != NULL) *End = 0;
|
||||
|
||||
RtlInitUnicodeString(&StartUs, Start);
|
||||
Context.DirectoryLocked = TRUE;
|
||||
Context.Directory = CurrentObject;
|
||||
FoundObject = ObpLookupEntryDirectory(CurrentObject, &StartUs, Attributes, FALSE, &Context);
|
||||
if (FoundObject == NULL)
|
||||
{
|
||||
if (End != NULL)
|
||||
{
|
||||
*End = L'\\';
|
||||
}
|
||||
goto Next;
|
||||
}
|
||||
|
||||
ObReferenceObjectByPointer(FoundObject,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
NULL,
|
||||
UserMode);
|
||||
if (End != NULL)
|
||||
{
|
||||
*End = L'\\';
|
||||
current = End;
|
||||
}
|
||||
else
|
||||
{
|
||||
current = NULL;
|
||||
}
|
||||
|
||||
NextObject = FoundObject;
|
||||
|
||||
Next:
|
||||
if (NextObject == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
ObDereferenceObject(CurrentObject);
|
||||
CurrentObject = NextObject;
|
||||
CurrentHeader = OBJECT_TO_OBJECT_HEADER(CurrentObject);
|
||||
}
|
||||
|
||||
if (CurrentHeader->Type->TypeInfo.ParseProcedure == NULL)
|
||||
{
|
||||
DPRINT("Current object can't parse\n");
|
||||
break;
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&CurrentUs, current);
|
||||
Status = CurrentHeader->Type->TypeInfo.ParseProcedure(CurrentObject,
|
||||
CurrentHeader->Type,
|
||||
AccessState,
|
||||
ExGetPreviousMode(), // fixme: should be a parameter, since caller decides.
|
||||
Attributes,
|
||||
&PathString,
|
||||
&CurrentUs,
|
||||
ParseContext,
|
||||
NULL, // fixme: where do we get this from? captured OBP?
|
||||
&NextObject);
|
||||
current = CurrentUs.Buffer;
|
||||
if (Status == STATUS_REPARSE)
|
||||
{
|
||||
/* reparse the object path */
|
||||
NextObject = NameSpaceRoot;
|
||||
current = PathString.Buffer;
|
||||
|
||||
ObReferenceObjectByPointer(NextObject,
|
||||
DIRECTORY_TRAVERSE,
|
||||
NULL,
|
||||
ObjectCreateInfo->ProbeMode);
|
||||
}
|
||||
|
||||
|
||||
if (NextObject == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
ObDereferenceObject(CurrentObject);
|
||||
CurrentObject = NextObject;
|
||||
}
|
||||
|
||||
if (current)
|
||||
{
|
||||
RtlpCreateUnicodeString (RemainingPath, current, NonPagedPool);
|
||||
}
|
||||
|
||||
RtlFreeUnicodeString (&PathString);
|
||||
*ReturnedObject = CurrentObject;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
CmiObjectParse(IN PVOID ParsedObject,
|
||||
|
|
|
@ -205,8 +205,8 @@ ExCreateCallback(
|
|||
{
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
ExCallbackObjectType,
|
||||
NULL,
|
||||
KernelMode,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
&Handle);
|
||||
|
|
|
@ -212,8 +212,8 @@ NtOpenEvent(OUT PHANDLE EventHandle,
|
|||
/* Open the Object */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
ExEventObjectType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hEvent);
|
||||
|
|
|
@ -164,8 +164,8 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle,
|
|||
/* Open the Object */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
ExEventPairObjectType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hEventPair);
|
||||
|
|
|
@ -194,8 +194,8 @@ NtOpenMutant(OUT PHANDLE MutantHandle,
|
|||
/* Open the Object */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
ExMutantObjectType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hMutant);
|
||||
|
|
|
@ -188,8 +188,8 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle,
|
|||
/* Open the Object */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
ExSemaphoreObjectType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hSemaphore);
|
||||
|
|
|
@ -508,8 +508,8 @@ NtOpenTimer(OUT PHANDLE TimerHandle,
|
|||
/* Open the Timer */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
ExTimerType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hTimer);
|
||||
|
|
|
@ -930,9 +930,9 @@ IoCreateFile(OUT PHANDLE FileHandle,
|
|||
|
||||
/* First try to open an existing named object */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
NULL,
|
||||
NULL,
|
||||
AccessMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&LocalHandle);
|
||||
|
|
|
@ -322,8 +322,8 @@ NtOpenIoCompletion(OUT PHANDLE IoCompletionHandle,
|
|||
/* Open the Object */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
IoCompletionType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hIoCompletionHandle);
|
||||
|
|
|
@ -3463,8 +3463,8 @@ NtOpenSection(PHANDLE SectionHandle,
|
|||
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
MmSectionObjectType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hSection);
|
||||
|
|
|
@ -334,8 +334,8 @@ NtOpenDirectoryObject (OUT PHANDLE DirectoryHandle,
|
|||
/* Open the directory object */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
ObDirectoryType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hDirectory);
|
||||
|
|
|
@ -748,10 +748,10 @@ NTSTATUS
|
|||
NTAPI
|
||||
ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN POBJECT_TYPE ObjectType,
|
||||
IN OUT PVOID ParseContext,
|
||||
IN KPROCESSOR_MODE AccessMode,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN PACCESS_STATE PassedAccessState,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN OUT PVOID ParseContext,
|
||||
OUT PHANDLE Handle)
|
||||
{
|
||||
UNICODE_STRING RemainingPath;
|
||||
|
|
|
@ -403,8 +403,8 @@ NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle,
|
|||
/* Open the object */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
ObSymbolicLinkType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hLink);
|
||||
|
|
|
@ -413,8 +413,8 @@ NtOpenJobObject (
|
|||
{
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
PsJobType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hJob);
|
||||
|
|
|
@ -1004,8 +1004,8 @@ NtOpenProcess(OUT PHANDLE ProcessHandle,
|
|||
DPRINT("Opening by name\n");
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
PsProcessType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hProcess);
|
||||
|
|
|
@ -720,8 +720,8 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
|
|||
/* Open it */
|
||||
Status = ObOpenObjectByName(ObjectAttributes,
|
||||
PsThreadType,
|
||||
NULL,
|
||||
PreviousMode,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
NULL,
|
||||
&hThread);
|
||||
|
|
|
@ -345,8 +345,8 @@ IntParseDesktopPath(PEPROCESS Process,
|
|||
|
||||
Status = ObOpenObjectByName(&ObjectAttributes,
|
||||
ExWindowStationObjectType,
|
||||
NULL,
|
||||
KernelMode,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
(HANDLE*)hWinSta);
|
||||
|
@ -379,8 +379,8 @@ IntParseDesktopPath(PEPROCESS Process,
|
|||
|
||||
Status = ObOpenObjectByName(&ObjectAttributes,
|
||||
ExDesktopObjectType,
|
||||
NULL,
|
||||
KernelMode,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
(HANDLE*)hDesktop);
|
||||
|
@ -926,10 +926,10 @@ NtUserCreateDesktop(
|
|||
Status = ObOpenObjectByName(
|
||||
&ObjectAttributes,
|
||||
ExDesktopObjectType,
|
||||
(PVOID)&DummyContext,
|
||||
KernelMode,
|
||||
dwDesiredAccess,
|
||||
NULL,
|
||||
dwDesiredAccess,
|
||||
(PVOID)&DummyContext,
|
||||
(HANDLE*)&Desktop);
|
||||
if (!NT_SUCCESS(Status)) RETURN(NULL);
|
||||
if (Status == STATUS_OBJECT_NAME_EXISTS)
|
||||
|
@ -1129,8 +1129,8 @@ NtUserOpenDesktop(
|
|||
Status = ObOpenObjectByName(
|
||||
&ObjectAttributes,
|
||||
ExDesktopObjectType,
|
||||
NULL,
|
||||
KernelMode,
|
||||
NULL,
|
||||
dwDesiredAccess,
|
||||
NULL,
|
||||
(HANDLE*)&Desktop);
|
||||
|
|
|
@ -444,8 +444,8 @@ NtUserCreateWindowStation(
|
|||
Status = ObOpenObjectByName(
|
||||
&ObjectAttributes,
|
||||
ExWindowStationObjectType,
|
||||
NULL,
|
||||
KernelMode,
|
||||
NULL,
|
||||
dwDesiredAccess,
|
||||
NULL,
|
||||
(PVOID*)&WindowStation);
|
||||
|
@ -603,8 +603,8 @@ NtUserOpenWindowStation(
|
|||
Status = ObOpenObjectByName(
|
||||
&ObjectAttributes,
|
||||
ExWindowStationObjectType,
|
||||
NULL,
|
||||
UserMode,
|
||||
NULL,
|
||||
dwDesiredAccess,
|
||||
NULL,
|
||||
(PVOID*)&WindowStation);
|
||||
|
|
Loading…
Reference in a new issue