Added attributes to object parse method.

svn path=/trunk/; revision=1882
This commit is contained in:
Eric Kohl 2001-05-05 09:33:16 +00:00
parent ab494baccd
commit 7c469f9c46
6 changed files with 287 additions and 279 deletions

View file

@ -1,6 +1,6 @@
#ifndef _INCLUDE_DDK_OBTYPES_H
#define _INCLUDE_DDK_OBTYPES_H
/* $Id: obtypes.h,v 1.11 2001/03/07 16:48:40 dwelch Exp $ */
/* $Id: obtypes.h,v 1.12 2001/05/05 09:30:28 ekohl Exp $ */
struct _DIRECTORY_OBJECT;
struct _OBJECT_ATTRIBUTES;
@ -92,7 +92,8 @@ typedef struct _OBJECT_TYPE
PVOID *NextObject,
PUNICODE_STRING FullPath,
PWSTR *Path,
struct _OBJECT_TYPE* ObjectType);
struct _OBJECT_TYPE* ObjectType,
ULONG Attributes);
/*
*/

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.57 2001/05/01 23:08:18 chorns Exp $
/* $Id: registry.c,v 1.58 2001/05/05 09:31:19 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -220,7 +220,8 @@ static NTSTATUS CmiObjectParse(PVOID ParsedObject,
PVOID *NextObject,
PUNICODE_STRING FullPath,
PWSTR *Path,
POBJECT_TYPE ObjectType);
POBJECT_TYPE ObjectType,
ULONG Attribute);
static NTSTATUS CmiObjectCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
@ -229,7 +230,9 @@ static NTSTATUS CmiObjectCreate(PVOID ObjectBody,
static VOID CmiObjectDelete(PVOID DeletedObject);
static VOID CmiAddKeyToList(PKEY_OBJECT ParentKey,PKEY_OBJECT NewKey);
static NTSTATUS CmiRemoveKeyFromList(PKEY_OBJECT NewKey);
static PKEY_OBJECT CmiScanKeyList(PKEY_OBJECT Parent,PCHAR KeyNameBuf);
static PKEY_OBJECT CmiScanKeyList(PKEY_OBJECT Parent,
PCHAR KeyNameBuf,
ULONG Attributes);
static PREGISTRY_FILE CmiCreateRegistry(PWSTR Filename);
static ULONG CmiGetMaxNameLength(PREGISTRY_FILE RegistryFile,
PKEY_BLOCK KeyBlock);
@ -244,7 +247,8 @@ static NTSTATUS CmiScanForSubKey(IN PREGISTRY_FILE RegistryFile,
OUT PKEY_BLOCK *SubKeyBlock,
OUT BLOCK_OFFSET *BlockOffset,
IN PCHAR KeyName,
IN ACCESS_MASK DesiredAccess);
IN ACCESS_MASK DesiredAccess,
IN ULONG Attributes);
static NTSTATUS CmiAddSubKey(IN PREGISTRY_FILE RegistryFile,
IN PKEY_OBJECT Parent,
OUT PKEY_OBJECT SubKey,
@ -2060,7 +2064,8 @@ static NTSTATUS CmiObjectParse(PVOID ParsedObject,
PVOID *NextObject,
PUNICODE_STRING FullPath,
PWSTR *Path,
POBJECT_TYPE ObjectType)
POBJECT_TYPE ObjectType,
ULONG Attributes)
{
CHAR cPath[MAX_PATH];
PWSTR end;
@ -2091,9 +2096,8 @@ static NTSTATUS CmiObjectParse(PVOID ParsedObject,
wcstombs(cPath,(*Path),wcslen((*Path)));
cPath[wcslen( (*Path))]=0;
}
/* FIXME : we must treat the OBJ_CASE_INSENTIVE Flag */
/* ... but actually CmiObjectParse don't receive this information */
FoundObject = CmiScanKeyList(ParsedKey,cPath);
FoundObject = CmiScanKeyList(ParsedKey,cPath,Attributes);
if (FoundObject == NULL)
{
Status = CmiScanForSubKey(ParsedKey->RegistryFile,
@ -2101,7 +2105,8 @@ static NTSTATUS CmiObjectParse(PVOID ParsedObject,
&SubKeyBlock,
&BlockOffset,
cPath,
0);
0,
Attributes);
if(!NT_SUCCESS(Status) || SubKeyBlock == NULL)
{
if (end != NULL)
@ -2258,7 +2263,9 @@ CmiRemoveKeyFromList(PKEY_OBJECT KeyToRemove)
}
static PKEY_OBJECT
CmiScanKeyList(PKEY_OBJECT Parent,PCHAR KeyName)
CmiScanKeyList(PKEY_OBJECT Parent,
PCHAR KeyName,
ULONG Attributes)
{
KIRQL OldIrql;
PKEY_OBJECT CurKey;
@ -2270,8 +2277,8 @@ CmiScanKeyList(PKEY_OBJECT Parent,PCHAR KeyName)
for (Index=0; Index < Parent->NumberOfSubKeys; Index++)
{
CurKey=Parent->SubKeys[Index];
/* FIXME : perhaps we must not ignore case if NtCreateKey has not been */
/* called with OBJ_CASE_INSENSITIVE flag ? */
if (Attributes & OBJ_CASE_INSENSITIVE)
{
if( NameSize == CurKey->NameSize
&& !_strnicmp(KeyName,CurKey->Name,NameSize))
{
@ -2279,6 +2286,16 @@ CmiScanKeyList(PKEY_OBJECT Parent,PCHAR KeyName)
return CurKey;
}
}
else
{
if( NameSize == CurKey->NameSize
&& !strncmp(KeyName,CurKey->Name,NameSize))
{
KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
return CurKey;
}
}
}
KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
return NULL;
@ -2585,7 +2602,8 @@ CmiScanForSubKey(IN PREGISTRY_FILE RegistryFile,
OUT PKEY_BLOCK *SubKeyBlock,
OUT BLOCK_OFFSET *BlockOffset,
IN PCHAR KeyName,
IN ACCESS_MASK DesiredAccess)
IN ACCESS_MASK DesiredAccess,
IN ULONG Attributes)
{
ULONG Idx;
PHASH_TABLE_BLOCK HashBlock;
@ -2602,8 +2620,8 @@ CmiScanForSubKey(IN PREGISTRY_FILE RegistryFile,
for (Idx = 0; Idx < KeyBlock->NumberOfSubKeys
&& Idx < HashBlock->HashTableSize; Idx++)
{
/* FIXME : perhaps we must not ignore case if NtCreateKey has not been */
/* called with OBJ_CASE_INSENSITIVE flag ? */
if (Attributes & OBJ_CASE_INSENSITIVE)
{
if (HashBlock->Table[Idx].KeyOffset != 0 &&
HashBlock->Table[Idx].KeyOffset != -1 &&
!_strnicmp(KeyName, (PCHAR) &HashBlock->Table[Idx].HashValue, 4))
@ -2623,6 +2641,28 @@ CmiScanForSubKey(IN PREGISTRY_FILE RegistryFile,
}
}
}
else
{
if (HashBlock->Table[Idx].KeyOffset != 0 &&
HashBlock->Table[Idx].KeyOffset != -1 &&
!strncmp(KeyName, (PCHAR) &HashBlock->Table[Idx].HashValue, 4))
{
CurSubKeyBlock = CmiGetBlock(RegistryFile,
HashBlock->Table[Idx].KeyOffset,NULL);
if ( CurSubKeyBlock->NameSize == KeyLength
&& !_strnicmp(KeyName, CurSubKeyBlock->Name, KeyLength))
{
*SubKeyBlock = CurSubKeyBlock;
*BlockOffset = HashBlock->Table[Idx].KeyOffset;
break;
}
else
{
CmiReleaseBlock(RegistryFile, CurSubKeyBlock);
}
}
}
}
CmiReleaseBlock(RegistryFile, HashBlock);

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.40 2001/05/01 23:08:19 chorns Exp $
/* $Id: create.c,v 1.41 2001/05/05 09:32:36 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel

View file

@ -1,4 +1,4 @@
/* $Id: symlink.c,v 1.19 2001/03/07 16:48:42 dwelch Exp $
/* $Id: symlink.c,v 1.20 2001/05/05 09:32:36 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -57,24 +57,19 @@ static GENERIC_MAPPING IopSymbolicLinkMapping = {
* REVISIONS
*/
NTSTATUS
IopCreateSymbolicLink (
PVOID Object,
IopCreateSymbolicLink(PVOID Object,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes
)
POBJECT_ATTRIBUTES ObjectAttributes)
{
if ( (Parent != NULL)
&& (RemainingPath != NULL)
)
if ((Parent != NULL)
&& (RemainingPath != NULL))
{
ObAddEntryDirectory(
Parent,
ObAddEntryDirectory(Parent,
Object,
RemainingPath + 1
);
RemainingPath + 1);
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
@ -91,13 +86,12 @@ IopCreateSymbolicLink (
* REVISIONS
*/
NTSTATUS
IopParseSymbolicLink (
PVOID Object,
IopParseSymbolicLink(PVOID Object,
PVOID * NextObject,
PUNICODE_STRING FullPath,
PWSTR * RemainingPath,
POBJECT_TYPE ObjectType
)
POBJECT_TYPE ObjectType,
ULONG Attributes)
{
NTSTATUS Status;
PSYMLNK_OBJECT SymlinkObject = (PSYMLNK_OBJECT) Object;
@ -117,16 +111,14 @@ IopParseSymbolicLink (
return STATUS_SUCCESS;
}
Status = ObReferenceObjectByName(
SymlinkObject->Target.ObjectName,
Status = ObReferenceObjectByName(SymlinkObject->Target.ObjectName,
0,
NULL,
STANDARD_RIGHTS_REQUIRED,
NULL,
UserMode,
NULL,
& ReturnedObject
);
&ReturnedObject);
if (NT_SUCCESS(Status))
{
*NextObject = ReturnedObject;
@ -136,17 +128,21 @@ IopParseSymbolicLink (
/* build the expanded path */
TargetPath.MaximumLength = SymlinkObject->TargetName.Length + sizeof(WCHAR);
if (RemainingPath && *RemainingPath)
TargetPath.MaximumLength += (wcslen (*RemainingPath) * sizeof(WCHAR));
{
TargetPath.MaximumLength += (wcslen(*RemainingPath) * sizeof(WCHAR));
}
TargetPath.Length = TargetPath.MaximumLength - sizeof(WCHAR);
TargetPath.Buffer = ExAllocatePoolWithTag (NonPagedPool,
TargetPath.Buffer = ExAllocatePoolWithTag(NonPagedPool,
TargetPath.MaximumLength,
TAG_SYMLINK_TTARGET);
wcscpy (TargetPath.Buffer, SymlinkObject->TargetName.Buffer);
wcscpy(TargetPath.Buffer, SymlinkObject->TargetName.Buffer);
if (RemainingPath && *RemainingPath)
wcscat (TargetPath.Buffer, *RemainingPath);
{
wcscat(TargetPath.Buffer, *RemainingPath);
}
/* transfer target path buffer into FullPath */
RtlFreeUnicodeString (FullPath);
RtlFreeUnicodeString(FullPath);
FullPath->Length = TargetPath.Length;
FullPath->MaximumLength = TargetPath.MaximumLength;
FullPath->Buffer = TargetPath.Buffer;
@ -212,13 +208,10 @@ VOID IoInitSymbolicLinkImplementation (VOID)
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtOpenSymbolicLinkObject (
OUT PHANDLE LinkHandle,
NTSTATUS STDCALL
NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
)
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
NTSTATUS Status;
PVOID Object;
@ -270,41 +263,34 @@ NtOpenSymbolicLinkObject (
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtQuerySymbolicLinkObject (
IN HANDLE LinkHandle,
NTSTATUS STDCALL
NtQuerySymbolicLinkObject(IN HANDLE LinkHandle,
IN OUT PUNICODE_STRING LinkTarget,
OUT PULONG ReturnedLength OPTIONAL
)
OUT PULONG ReturnedLength OPTIONAL)
{
PSYMLNK_OBJECT SymlinkObject;
NTSTATUS Status;
Status = ObReferenceObjectByHandle(
LinkHandle,
Status = ObReferenceObjectByHandle(LinkHandle,
SYMBOLIC_LINK_QUERY,
IoSymbolicLinkType,
UserMode,
(PVOID *) & SymlinkObject,
NULL
);
if (Status != STATUS_SUCCESS)
(PVOID *)&SymlinkObject,
NULL);
if (!NT_SUCCESS(Status))
{
return Status;
return(Status);
}
RtlCopyUnicodeString(
LinkTarget,
SymlinkObject->Target.ObjectName
);
RtlCopyUnicodeString(LinkTarget,
SymlinkObject->Target.ObjectName);
if (ReturnedLength != NULL)
{
*ReturnedLength = SymlinkObject->Target.Length;
}
ObDereferenceObject(SymlinkObject);
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
@ -321,17 +307,12 @@ NtQuerySymbolicLinkObject (
* REVISIONS
*
*/
NTSTATUS
STDCALL
IoCreateUnprotectedSymbolicLink (
PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName
)
NTSTATUS STDCALL
IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName)
{
return IoCreateSymbolicLink(
SymbolicLinkName,
DeviceName
);
return IoCreateSymbolicLink(SymbolicLinkName,
DeviceName);
}
@ -348,12 +329,9 @@ IoCreateUnprotectedSymbolicLink (
* REVISIONS
*
*/
NTSTATUS
STDCALL
IoCreateSymbolicLink (
PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName
)
NTSTATUS STDCALL
IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName)
{
OBJECT_ATTRIBUTES ObjectAttributes;
PSYMLNK_OBJECT SymbolicLink;
@ -424,11 +402,8 @@ IoCreateSymbolicLink (
* REVISIONS
*
*/
NTSTATUS
STDCALL
IoDeleteSymbolicLink (
PUNICODE_STRING SymbolicLinkName
)
NTSTATUS STDCALL
IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName)
{
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE Handle;
@ -471,33 +446,26 @@ IoDeleteSymbolicLink (
* REVISIONS
*
*/
NTSTATUS
STDCALL
NtCreateSymbolicLinkObject (
OUT PHANDLE SymbolicLinkHandle,
NTSTATUS STDCALL
NtCreateSymbolicLinkObject(OUT PHANDLE SymbolicLinkHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN PUNICODE_STRING DeviceName
)
IN PUNICODE_STRING DeviceName)
{
PSYMLNK_OBJECT SymbolicLink;
assert_irql(PASSIVE_LEVEL);
DPRINT(
"NtCreateSymbolicLinkObject(SymbolicLinkHandle %p, DesiredAccess %ul, ObjectAttributes %p, DeviceName %S)\n",
DPRINT("NtCreateSymbolicLinkObject(SymbolicLinkHandle %p, DesiredAccess %ul, ObjectAttributes %p, DeviceName %S)\n",
SymbolicLinkHandle,
DesiredAccess,
ObjectAttributes,
DeviceName->Buffer
);
DeviceName->Buffer);
SymbolicLink = ObCreateObject(
SymbolicLinkHandle,
SymbolicLink = ObCreateObject(SymbolicLinkHandle,
DesiredAccess,
ObjectAttributes,
IoSymbolicLinkType
);
IoSymbolicLinkType);
if (SymbolicLink == NULL)
{
return STATUS_UNSUCCESSFUL;
@ -510,24 +478,20 @@ NtCreateSymbolicLinkObject (
ExAllocatePoolWithTag(NonPagedPool,
SymbolicLink->TargetName.MaximumLength,
TAG_SYMLINK_TARGET);
RtlCopyUnicodeString(
& (SymbolicLink->TargetName),
DeviceName
);
RtlCopyUnicodeString(&SymbolicLink->TargetName,
DeviceName);
DPRINT("DeviceName %S\n", SymbolicLink->TargetName.Buffer);
InitializeObjectAttributes(
& (SymbolicLink->Target),
& (SymbolicLink->TargetName),
InitializeObjectAttributes(&SymbolicLink->Target,
&SymbolicLink->TargetName,
0,
NULL,
NULL
);
NULL);
DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
ObDereferenceObject( SymbolicLink );
return STATUS_SUCCESS;
ObDereferenceObject(SymbolicLink);
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: namespc.c,v 1.22 2001/05/04 21:44:21 ea Exp $
/* $Id: namespc.c,v 1.23 2001/05/05 09:33:16 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -149,7 +149,8 @@ ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
}
VOID STDCALL ObAddEntryDirectory(PDIRECTORY_OBJECT Parent,
VOID STDCALL
ObAddEntryDirectory(PDIRECTORY_OBJECT Parent,
POBJECT Object,
PWSTR Name)
/*
@ -171,7 +172,8 @@ VOID STDCALL ObAddEntryDirectory(PDIRECTORY_OBJECT Parent,
KeReleaseSpinLock(&Parent->Lock, oldlvl);
}
PVOID ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
PVOID
ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
PWSTR Name,
ULONG Attributes)
{
@ -219,13 +221,12 @@ PVOID ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
}
NTSTATUS
ObpParseDirectory (
PVOID Object,
ObpParseDirectory(PVOID Object,
PVOID * NextObject,
PUNICODE_STRING FullPath,
PWSTR * Path,
POBJECT_TYPE ObjectType
)
POBJECT_TYPE ObjectType,
ULONG Attributes)
{
PWSTR end;
PVOID FoundObject;
@ -246,7 +247,7 @@ ObpParseDirectory (
*end = 0;
}
FoundObject = ObpFindEntryDirectory(Object, (*Path)+1, 0);
FoundObject = ObpFindEntryDirectory(Object, (*Path)+1, Attributes);
if (FoundObject == NULL)
{
@ -277,7 +278,8 @@ ObpParseDirectory (
return STATUS_SUCCESS;
}
NTSTATUS ObpCreateDirectory(PVOID ObjectBody,
NTSTATUS
ObpCreateDirectory(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes)

View file

@ -1,4 +1,4 @@
/* $Id: object.c,v 1.36 2001/05/01 23:08:20 chorns Exp $
/* $Id: object.c,v 1.37 2001/05/05 09:33:16 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -185,7 +185,8 @@ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
&NextObject,
&PathString,
&current,
ObjectType);
ObjectType,
ObjectAttributes->Attributes);
if (Status == STATUS_REPARSE)
{
/* reparse the object path */