mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
NtOpenKey modified to correctly behave when wrong input params are given (according to WINE tests).
svn path=/trunk/; revision=14968
This commit is contained in:
parent
ed23d5951d
commit
8460c6e770
1 changed files with 20 additions and 6 deletions
|
@ -1115,6 +1115,10 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
||||||
ObjectAttributes,
|
ObjectAttributes,
|
||||||
ObjectAttributes ? ObjectAttributes->ObjectName : NULL);
|
ObjectAttributes ? ObjectAttributes->ObjectName : NULL);
|
||||||
|
|
||||||
|
/* Check place for result handle, if it's null - return immediately */
|
||||||
|
if (KeyHandle == NULL)
|
||||||
|
return(STATUS_INVALID_PARAMETER);
|
||||||
|
|
||||||
PreviousMode = ExGetPreviousMode();
|
PreviousMode = ExGetPreviousMode();
|
||||||
|
|
||||||
if(PreviousMode != KernelMode)
|
if(PreviousMode != KernelMode)
|
||||||
|
@ -1137,6 +1141,10 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* WINE checks for the length also */
|
||||||
|
/*if (ObjectAttributes->ObjectName->Length > MAX_NAME_LENGTH)
|
||||||
|
return(STATUS_BUFFER_OVERFLOW);*/
|
||||||
|
|
||||||
RemainingPath.Buffer = NULL;
|
RemainingPath.Buffer = NULL;
|
||||||
Status = ObFindObject(ObjectAttributes,
|
Status = ObFindObject(ObjectAttributes,
|
||||||
&Object,
|
&Object,
|
||||||
|
@ -1144,7 +1152,10 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
||||||
CmiKeyType);
|
CmiKeyType);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
DPRINT("ObFindObject() returned 0x%08lx\n", Status);
|
||||||
|
Status = STATUS_INVALID_HANDLE; /* Because ObFindObject returns STATUS_UNSUCCESSFUL */
|
||||||
|
hKey = *KeyHandle; /* Preserve hkResult value */
|
||||||
|
goto openkey_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERIFY_KEY_OBJECT((PKEY_OBJECT) Object);
|
VERIFY_KEY_OBJECT((PKEY_OBJECT) Object);
|
||||||
|
@ -1155,7 +1166,9 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Object);
|
ObDereferenceObject(Object);
|
||||||
RtlFreeUnicodeString(&RemainingPath);
|
RtlFreeUnicodeString(&RemainingPath);
|
||||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
Status = STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
hKey = NULL;
|
||||||
|
goto openkey_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlFreeUnicodeString(&RemainingPath);
|
RtlFreeUnicodeString(&RemainingPath);
|
||||||
|
@ -1164,7 +1177,9 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
||||||
if (((PKEY_OBJECT)Object)->Flags & KO_MARKED_FOR_DELETE)
|
if (((PKEY_OBJECT)Object)->Flags & KO_MARKED_FOR_DELETE)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Object);
|
ObDereferenceObject(Object);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
hKey = NULL;
|
||||||
|
goto openkey_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = ObCreateHandle(PsGetCurrentProcess(),
|
Status = ObCreateHandle(PsGetCurrentProcess(),
|
||||||
|
@ -1175,10 +1190,9 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
||||||
ObDereferenceObject(Object);
|
ObDereferenceObject(Object);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
hKey = NULL;
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
openkey_cleanup:
|
||||||
_SEH_TRY
|
_SEH_TRY
|
||||||
{
|
{
|
||||||
*KeyHandle = hKey;
|
*KeyHandle = hKey;
|
||||||
|
|
Loading…
Reference in a new issue