diff --git a/reactos/include/ddk/obfuncs.h b/reactos/include/ddk/obfuncs.h index e920a65d2c5..53fc93263b7 100644 --- a/reactos/include/ddk/obfuncs.h +++ b/reactos/include/ddk/obfuncs.h @@ -1,17 +1,16 @@ /* OBJECT MANAGER ************************************************************/ -NTSTATUS STDCALL ObCreateObject(PHANDLE Handle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes, - POBJECT_TYPE Type, - PVOID *Object); +NTSTATUS STDCALL +ObCreateObject(PHANDLE Handle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes, + POBJECT_TYPE Type, + PVOID *Object); -VOID -FASTCALL +VOID FASTCALL ObfDereferenceObject(IN PVOID Object); -VOID -FASTCALL +VOID FASTCALL ObfReferenceObject(IN PVOID Object); #define ObDereferenceObject(Object) \ @@ -20,25 +19,34 @@ ObfReferenceObject(IN PVOID Object); #define ObReferenceObject(Object) \ ObfReferenceObject(Object) -VOID -STDCALL -ObMakeTemporaryObject(PVOID ObjectBody); +NTSTATUS STDCALL +ObInsertObject(PVOID Object, + PACCESS_STATE PassedAccessState, + ACCESS_MASK DesiredAccess, + ULONG AdditionalReferences, + PVOID* ReferencedObject, + PHANDLE Handle); -NTSTATUS STDCALL ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, - IN POBJECT_TYPE ObjectType, - IN PVOID ParseContext, - IN KPROCESSOR_MODE AccessMode, - IN ACCESS_MASK DesiredAccess, - IN PACCESS_STATE PassedAccessState, - OUT PHANDLE Handle); +VOID STDCALL +ObMakeTemporaryObject(IN PVOID ObjectBody); -NTSTATUS STDCALL ObOpenObjectByPointer(IN PVOID Object, - IN ULONG HandleAttributes, - IN PACCESS_STATE PassedAccessState, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_TYPE ObjectType, - IN KPROCESSOR_MODE AccessMode, - OUT PHANDLE Handle); +NTSTATUS STDCALL +ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, + IN POBJECT_TYPE ObjectType, + IN PVOID ParseContext, + IN KPROCESSOR_MODE AccessMode, + IN ACCESS_MASK DesiredAccess, + IN PACCESS_STATE PassedAccessState, + OUT PHANDLE Handle); + +NTSTATUS STDCALL +ObOpenObjectByPointer(IN PVOID Object, + IN ULONG HandleAttributes, + IN PACCESS_STATE PassedAccessState, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType, + IN KPROCESSOR_MODE AccessMode, + OUT PHANDLE Handle); /* * FUNCTION: Performs access validation on an object handle and if access @@ -54,12 +62,13 @@ NTSTATUS STDCALL ObOpenObjectByPointer(IN PVOID Object, * information about the handle * RETURNS: Status */ -NTSTATUS STDCALL ObReferenceObjectByHandle(HANDLE Handle, - ACCESS_MASK DesiredAccess, - POBJECT_TYPE ObjectType, - KPROCESSOR_MODE AccessMode, - PVOID* Object, - POBJECT_HANDLE_INFORMATION HandleInfo); +NTSTATUS STDCALL +ObReferenceObjectByHandle(HANDLE Handle, + ACCESS_MASK DesiredAccess, + POBJECT_TYPE ObjectType, + KPROCESSOR_MODE AccessMode, + PVOID* Object, + POBJECT_HANDLE_INFORMATION HandleInfo); /* * FUNCTION: Increments the reference count for a given object @@ -70,17 +79,19 @@ NTSTATUS STDCALL ObReferenceObjectByHandle(HANDLE Handle, * AccessMode = Access mode to use for the security check * RETURNS: Status */ -NTSTATUS STDCALL ObReferenceObjectByPointer(PVOID Object, - ACCESS_MASK DesiredAccess, - POBJECT_TYPE ObjectType, - KPROCESSOR_MODE AccessMode); +NTSTATUS STDCALL +ObReferenceObjectByPointer(PVOID Object, + ACCESS_MASK DesiredAccess, + POBJECT_TYPE ObjectType, + KPROCESSOR_MODE AccessMode); -NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath, - ULONG Attributes, - PACCESS_STATE PassedAccessState, - ACCESS_MASK DesiredAccess, - POBJECT_TYPE ObjectType, - KPROCESSOR_MODE AccessMode, - PVOID ParseContext, - PVOID* ObjectPtr); +NTSTATUS STDCALL +ObReferenceObjectByName(PUNICODE_STRING ObjectPath, + ULONG Attributes, + PACCESS_STATE PassedAccessState, + ACCESS_MASK DesiredAccess, + POBJECT_TYPE ObjectType, + KPROCESSOR_MODE AccessMode, + PVOID ParseContext, + PVOID* ObjectPtr); diff --git a/reactos/ntoskrnl/cm/registry.c b/reactos/ntoskrnl/cm/registry.c index a4a8ef6a460..120880d97c9 100644 --- a/reactos/ntoskrnl/cm/registry.c +++ b/reactos/ntoskrnl/cm/registry.c @@ -1,4 +1,4 @@ -/* $Id: registry.c,v 1.67 2002/01/03 11:09:35 hbirr Exp $ +/* $Id: registry.c,v 1.68 2002/02/19 00:09:22 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -83,10 +82,9 @@ DPRINT("Creating root\n"); CmiKeyType, (PVOID*)&NewKey); CmiRootKey = NewKey; - ObAddEntryDirectory(NameSpaceRoot, CmiRootKey, L"Registry"); Status = ObReferenceObjectByHandle(RootKeyHandle, STANDARD_RIGHTS_REQUIRED, - ObDirectoryType, + CmiKeyType, UserMode, (PVOID*)&CmiRootKey, NULL); @@ -106,12 +104,10 @@ DPRINT("Creating root\n"); /* Create initial predefined symbolic links */ /* HKEY_LOCAL_MACHINE */ - RtlInitUnicodeString(&RootKeyName, REG_MACHINE_KEY_NAME); DPRINT("Creating HKLM\n"); - InitializeObjectAttributes(&ObjectAttributes, &RootKeyName, 0, NULL, NULL); Status=ObCreateObject(&KeyHandle, STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + NULL, CmiKeyType, (PVOID*)&NewKey); Status = CmiAddSubKey(CmiVolatileFile, @@ -134,12 +130,10 @@ DPRINT("Creating HKLM\n"); CmiMachineKey=NewKey; /* HKEY_USERS */ - RtlInitUnicodeString(&RootKeyName, REG_USERS_KEY_NAME); DPRINT("Creating HKU\n"); - InitializeObjectAttributes(&ObjectAttributes, &RootKeyName, 0, NULL, NULL); Status=ObCreateObject(&KeyHandle, STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + NULL, CmiKeyType, (PVOID*)&NewKey); Status = CmiAddSubKey(CmiVolatileFile, @@ -162,11 +156,9 @@ DPRINT("Creating HKU\n"); CmiUserKey=NewKey; /* Create '\\Registry\\Machine\\HARDWARE' key. */ - RtlInitUnicodeString(&RootKeyName, REG_HARDWARE_KEY_NAME); - InitializeObjectAttributes(&ObjectAttributes, &RootKeyName, 0, NULL, NULL); Status=ObCreateObject(&KeyHandle, STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + NULL, CmiKeyType, (PVOID*)&NewKey); Status = CmiAddSubKey(CmiVolatileFile, @@ -189,11 +181,9 @@ DPRINT("Creating HKU\n"); CmiHardwareKey=NewKey; /* Create '\\Registry\\Machine\\HARDWARE\\DESCRIPTION' key. */ - RtlInitUnicodeString(&RootKeyName, REG_DESCRIPTION_KEY_NAME); - InitializeObjectAttributes(&ObjectAttributes, &RootKeyName, 0, NULL, NULL); Status=ObCreateObject(&KeyHandle, STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + NULL, CmiKeyType, (PVOID*)&NewKey); Status = CmiAddSubKey(CmiVolatileFile, @@ -215,11 +205,9 @@ DPRINT("Creating HKU\n"); CmiAddKeyToList(CmiHardwareKey,NewKey); /* Create '\\Registry\\Machine\\HARDWARE\\DEVICEMAP' key. */ - RtlInitUnicodeString(&RootKeyName, REG_DEVICEMAP_KEY_NAME); - InitializeObjectAttributes(&ObjectAttributes, &RootKeyName, 0, NULL, NULL); Status=ObCreateObject(&KeyHandle, STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + NULL, CmiKeyType, (PVOID*)&NewKey); Status = CmiAddSubKey(CmiVolatileFile, @@ -241,11 +229,9 @@ DPRINT("Creating HKU\n"); CmiAddKeyToList(CmiHardwareKey,NewKey); /* Create '\\Registry\\Machine\\HARDWARE\\RESOURCEMAP' key. */ - RtlInitUnicodeString(&RootKeyName, REG_RESOURCEMAP_KEY_NAME); - InitializeObjectAttributes(&ObjectAttributes, &RootKeyName, 0, NULL, NULL); Status=ObCreateObject(&KeyHandle, STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + NULL, //&ObjectAttributes, CmiKeyType, (PVOID*)&NewKey); Status = CmiAddSubKey(CmiVolatileFile, diff --git a/reactos/ntoskrnl/ex/win32k.c b/reactos/ntoskrnl/ex/win32k.c index 78425b9a7cd..432266024fc 100644 --- a/reactos/ntoskrnl/ex/win32k.c +++ b/reactos/ntoskrnl/ex/win32k.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #define NDEBUG @@ -98,24 +97,6 @@ ExpWinStaObjectCreate(PVOID ObjectBody, return Status; } - Status = ObReferenceObjectByPointer( - Parent, - STANDARD_RIGHTS_REQUIRED, - ObDirectoryType, - UserMode); - if (!NT_SUCCESS(Status)) - { - RtlDestroyAtomTable(WinSta->AtomTable); - RtlFreeUnicodeString(&WinSta->Name); - return Status; - } - - ObAddEntryDirectory( - Parent, - ObjectBody, - (RemainingPath + 1)); - ObDereferenceObject(Parent); - DPRINT("Window station successfully created. Name (%wZ)\n", &WinSta->Name); return STATUS_SUCCESS; diff --git a/reactos/ntoskrnl/include/internal/ob.h b/reactos/ntoskrnl/include/internal/ob.h index d1f24bbc0f6..c6ce969562f 100644 --- a/reactos/ntoskrnl/include/internal/ob.h +++ b/reactos/ntoskrnl/include/internal/ob.h @@ -13,7 +13,7 @@ struct _EPROCESS; -typedef struct +typedef struct { CSHORT Type; CSHORT Size; @@ -51,43 +51,24 @@ enum OBJTYP_MAX, }; -BOOL ObAddObjectToNameSpace(PUNICODE_STRING path, POBJECT_HEADER Object); -VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type); -NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object, - PWSTR* UnparsedSection, ULONG Attributes); -VOID ObRemoveEntry(POBJECT_HEADER Header); -NTSTATUS ObPerformRetentionChecks(POBJECT_HEADER Header); +#define OBJECT_ALLOC_SIZE(type) (type->NonpagedPoolCharge+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER)) + + +extern PDIRECTORY_OBJECT NameSpaceRoot; -/* - * FUNCTION: Creates an entry within a directory - * ARGUMENTS: - * parent = Parent directory - * object = Header of the object to add - */ -VOID ObCreateEntry(PDIRECTORY_OBJECT parent, POBJECT_HEADER object); POBJECT_HEADER BODY_TO_HEADER(PVOID body); PVOID HEADER_TO_BODY(POBJECT_HEADER obj); -#define OBJECT_ALLOC_SIZE(type) (type->NonpagedPoolCharge+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER)) +VOID ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent, + POBJECT_HEADER Header, + PWSTR Name); +VOID ObpRemoveEntryDirectory(POBJECT_HEADER Header); -/* - * PURPOSE: Defines a handle - */ -typedef struct -{ - PVOID ObjectBody; - ACCESS_MASK GrantedAccess; - BOOLEAN Inherit; -} HANDLE_REP, *PHANDLE_REP; +NTSTATUS ObPerformRetentionChecks(POBJECT_HEADER Header); -PHANDLE_REP ObTranslateHandle(struct _EPROCESS* Process, HANDLE h); -extern PDIRECTORY_OBJECT NameSpaceRoot; -VOID STDCALL ObAddEntryDirectory(PDIRECTORY_OBJECT Parent, - POBJECT Object, - PWSTR Name); NTSTATUS ObCreateHandle(struct _EPROCESS* Process, PVOID ObjectBody, ACCESS_MASK GrantedAccess, @@ -104,14 +85,7 @@ ULONG ObGetReferenceCount(PVOID Object); ULONG ObGetHandleCount(PVOID Object); VOID ObCloseAllHandles(struct _EPROCESS* Process); VOID ObDeleteHandleTable(struct _EPROCESS* Process); -PVOID ObDeleteHandle(struct _EPROCESS* Process, +PVOID ObDeleteHandle(struct _EPROCESS* Process, HANDLE Handle); -NTSTATUS STDCALL -ObInsertObject(PVOID Object, - PACCESS_STATE PassedAccessState, - ACCESS_MASK DesiredAccess, - ULONG AdditionalReferences, - PVOID* ReferencedObject, - PHANDLE Handle); #endif /* __INCLUDE_INTERNAL_OBJMGR_H */ diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index ccaa70a2c82..5c8fbb8bd5d 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -1,4 +1,4 @@ -/* $Id: device.c,v 1.34 2001/09/16 13:19:32 chorns Exp $ +/* $Id: device.c,v 1.35 2002/02/19 00:09:22 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -592,10 +591,6 @@ IopCreateDevice(PVOID ObjectBody, return(STATUS_UNSUCCESSFUL); } - if (Parent != NULL && RemainingPath != NULL) - { - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - } return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/io/symlink.c b/reactos/ntoskrnl/io/symlink.c index 705d8296e09..e8a08d7c901 100644 --- a/reactos/ntoskrnl/io/symlink.c +++ b/reactos/ntoskrnl/io/symlink.c @@ -1,4 +1,4 @@ -/* $Id: symlink.c,v 1.23 2001/12/05 01:40:24 dwelch Exp $ +/* $Id: symlink.c,v 1.24 2002/02/19 00:09:22 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,7 +13,7 @@ #include #include -#include +//#include #include #define NDEBUG @@ -62,14 +62,7 @@ IopCreateSymbolicLink(PVOID Object, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - if ((Parent != NULL) - && (RemainingPath != NULL)) - { - ObAddEntryDirectory(Parent, - Object, - RemainingPath + 1); - } - return(STATUS_SUCCESS); + return(STATUS_SUCCESS); } @@ -214,12 +207,22 @@ NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes) { +#if 0 NTSTATUS Status; PVOID Object; +#endif - DPRINT("NtOpenSymbolicLinkObject (Name %wZ)\n", - ObjectAttributes->ObjectName); + DPRINT("NtOpenSymbolicLinkObject (Name %wZ)\n", + ObjectAttributes->ObjectName); + return(ObOpenObjectByName(ObjectAttributes, + IoSymbolicLinkType, + NULL, + UserMode, + DesiredAccess, + NULL, + LinkHandle)); +#if 0 Status = ObReferenceObjectByName( ObjectAttributes->ObjectName, ObjectAttributes->Attributes, @@ -248,6 +251,7 @@ NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, } return STATUS_SUCCESS; +#endif } diff --git a/reactos/ntoskrnl/ldr/loader.c b/reactos/ntoskrnl/ldr/loader.c index d76e0482431..d20c0290113 100644 --- a/reactos/ntoskrnl/ldr/loader.c +++ b/reactos/ntoskrnl/ldr/loader.c @@ -1,4 +1,4 @@ -/* $Id: loader.c,v 1.99 2002/02/12 12:30:46 jfilby Exp $ +/* $Id: loader.c,v 1.100 2002/02/19 00:09:23 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -1017,10 +1016,6 @@ LdrCreateModule(PVOID ObjectBody, { return STATUS_UNSUCCESSFUL; } - if (Parent != NULL && RemainingPath != NULL) - { - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath + 1); - } return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/lpc/create.c b/reactos/ntoskrnl/lpc/create.c index 3ae5adfc004..b759110a644 100644 --- a/reactos/ntoskrnl/lpc/create.c +++ b/reactos/ntoskrnl/lpc/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.6 2001/12/02 23:34:42 dwelch Exp $ +/* $Id: create.c,v 1.7 2002/02/19 00:09:23 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -12,7 +12,6 @@ /* INCLUDES *****************************************************************/ #include -#include #include #include @@ -61,8 +60,6 @@ NiCreatePort (PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - NTSTATUS Status; - if (RemainingPath == NULL) { return (STATUS_SUCCESS); @@ -73,20 +70,6 @@ NiCreatePort (PVOID ObjectBody, return (STATUS_UNSUCCESSFUL); } - Status = ObReferenceObjectByPointer (Parent, - STANDARD_RIGHTS_REQUIRED, - ObDirectoryType, - UserMode); - if (!NT_SUCCESS(Status)) - { - return (Status); - } - - ObAddEntryDirectory (Parent, - ObjectBody, - (RemainingPath + 1)); - ObDereferenceObject (Parent); - return (STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index daefe79f11f..f18e0260ba0 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: section.c,v 1.76 2002/01/09 03:00:21 dwelch Exp $ +/* $Id: section.c,v 1.77 2002/02/19 00:09:23 ekohl Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/section.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -1529,8 +1528,6 @@ MmpCreateSection(PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - NTSTATUS Status; - DPRINT("MmpCreateDevice(ObjectBody %x, Parent %x, RemainingPath %S)\n", ObjectBody, Parent, RemainingPath); @@ -1544,18 +1541,6 @@ MmpCreateSection(PVOID ObjectBody, return(STATUS_UNSUCCESSFUL); } - Status = ObReferenceObjectByPointer(Parent, - STANDARD_RIGHTS_REQUIRED, - ObDirectoryType, - UserMode); - if (!NT_SUCCESS(Status)) - { - return(Status); - } - - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - ObDereferenceObject(Parent); - return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/nt/evtpair.c b/reactos/ntoskrnl/nt/evtpair.c index bbf556a3262..ac5567f5280 100644 --- a/reactos/ntoskrnl/nt/evtpair.c +++ b/reactos/ntoskrnl/nt/evtpair.c @@ -1,4 +1,4 @@ -/* $Id: evtpair.c,v 1.10 2001/12/05 01:40:25 dwelch Exp $ +/* $Id: evtpair.c,v 1.11 2002/02/19 00:09:24 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -12,7 +12,6 @@ /* INCLUDES *****************************************************************/ #include -#include #include #include @@ -38,19 +37,15 @@ NtpCreateEventPair(PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - DPRINT("NtpCreateEventPair(ObjectBody %x, Parent %x, RemainingPath %S)\n", - ObjectBody, Parent, RemainingPath); - - if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) - { - return(STATUS_UNSUCCESSFUL); - } - - if (Parent != NULL && RemainingPath != NULL) - { - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - } - return(STATUS_SUCCESS); + DPRINT("NtpCreateEventPair(ObjectBody %x, Parent %x, RemainingPath %S)\n", + ObjectBody, Parent, RemainingPath); + + if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) + { + return(STATUS_UNSUCCESSFUL); + } + + return(STATUS_SUCCESS); } VOID NtInitializeEventPairImplementation(VOID) diff --git a/reactos/ntoskrnl/nt/mutant.c b/reactos/ntoskrnl/nt/mutant.c index 43e367ae796..2f1f627b77e 100644 --- a/reactos/ntoskrnl/nt/mutant.c +++ b/reactos/ntoskrnl/nt/mutant.c @@ -31,7 +31,6 @@ #include #include #include -#include #define NDEBUG #include @@ -61,10 +60,6 @@ NtpCreateMutant(PVOID ObjectBody, return(STATUS_UNSUCCESSFUL); } - if (Parent != NULL && RemainingPath != NULL) - { - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - } return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/nt/ntevent.c b/reactos/ntoskrnl/nt/ntevent.c index 38363ddc838..496bc621740 100644 --- a/reactos/ntoskrnl/nt/ntevent.c +++ b/reactos/ntoskrnl/nt/ntevent.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -57,19 +56,15 @@ NtpCreateEvent(PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - DPRINT("NtpCreateEvent(ObjectBody %x, Parent %x, RemainingPath %S)\n", - ObjectBody, Parent, RemainingPath); - - if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) - { - return(STATUS_UNSUCCESSFUL); - } - - if (Parent != NULL && RemainingPath != NULL) - { - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - } - return(STATUS_SUCCESS); + DPRINT("NtpCreateEvent(ObjectBody %x, Parent %x, RemainingPath %S)\n", + ObjectBody, Parent, RemainingPath); + + if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) + { + return(STATUS_UNSUCCESSFUL); + } + + return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/nt/ntsem.c b/reactos/ntoskrnl/nt/ntsem.c index c275f299faa..e61a292335c 100644 --- a/reactos/ntoskrnl/nt/ntsem.c +++ b/reactos/ntoskrnl/nt/ntsem.c @@ -1,4 +1,4 @@ -/* $Id: ntsem.c,v 1.14 2001/12/05 01:40:25 dwelch Exp $ +/* $Id: ntsem.c,v 1.15 2002/02/19 00:09:24 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -39,20 +38,15 @@ NtpCreateSemaphore(PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - - DPRINT("NtpCreateSemaphore(ObjectBody %x, Parent %x, RemainingPath %S)\n", - ObjectBody, Parent, RemainingPath); - - if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) - { - return(STATUS_UNSUCCESSFUL); - } - - if (Parent != NULL && RemainingPath != NULL) - { - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - } - return(STATUS_SUCCESS); + DPRINT("NtpCreateSemaphore(ObjectBody %x, Parent %x, RemainingPath %S)\n", + ObjectBody, Parent, RemainingPath); + + if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) + { + return(STATUS_UNSUCCESSFUL); + } + + return(STATUS_SUCCESS); } VOID NtInitializeSemaphoreImplementation(VOID) diff --git a/reactos/ntoskrnl/nt/nttimer.c b/reactos/ntoskrnl/nt/nttimer.c index e3a80e3f20d..2e4aed29d0c 100644 --- a/reactos/ntoskrnl/nt/nttimer.c +++ b/reactos/ntoskrnl/nt/nttimer.c @@ -1,4 +1,4 @@ -/* $Id: nttimer.c,v 1.13 2001/12/05 01:40:25 dwelch Exp $ +/* $Id: nttimer.c,v 1.14 2002/02/19 00:09:24 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -52,19 +51,15 @@ NtpCreateTimer(PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - DPRINT("NtpCreateTimer(ObjectBody %x, Parent %x, RemainingPath %S)\n", - ObjectBody, Parent, RemainingPath); - - if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) - { - return(STATUS_UNSUCCESSFUL); - } - - if (Parent != NULL && RemainingPath != NULL) - { - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - } - return(STATUS_SUCCESS); + DPRINT("NtpCreateTimer(ObjectBody %x, Parent %x, RemainingPath %S)\n", + ObjectBody, Parent, RemainingPath); + + if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) + { + return(STATUS_UNSUCCESSFUL); + } + + return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index e6be29642d9..bb72f51b771 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.def,v 1.126 2002/01/27 01:11:23 dwelch Exp $ +; $Id: ntoskrnl.def,v 1.127 2002/02/19 00:09:21 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -575,7 +575,6 @@ ObReferenceObjectByName@32 ObReferenceObjectByPointer@16 ;ObReleaseObjectSecurity@8 ;ObSetSecurityDescriptorInfo@24 -ObAddEntryDirectory@12 ;PfxFindPrefix ;PfxInitialize ;PfxInsertPrefix diff --git a/reactos/ntoskrnl/ntoskrnl.edf b/reactos/ntoskrnl/ntoskrnl.edf index 8ac35b690d9..4fd7fd01612 100644 --- a/reactos/ntoskrnl/ntoskrnl.edf +++ b/reactos/ntoskrnl/ntoskrnl.edf @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.edf,v 1.112 2002/01/27 01:11:23 dwelch Exp $ +; $Id: ntoskrnl.edf,v 1.113 2002/02/19 00:09:21 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -575,7 +575,6 @@ ObReferenceObjectByName=ObReferenceObjectByName@32 ObReferenceObjectByPointer=ObReferenceObjectByPointer@16 ;ObReleaseObjectSecurity=ObReleaseObjectSecurity@8 ;ObSetSecurityDescriptorInfo=ObSetSecurityDescriptorInfo@24 -ObAddEntryDirectory=ObAddEntryDirectory@12 ;PfxFindPrefix ;PfxInitialize ;PfxInsertPrefix diff --git a/reactos/ntoskrnl/ob/handle.c b/reactos/ntoskrnl/ob/handle.c index 8a5412a2ffc..a62b227091c 100644 --- a/reactos/ntoskrnl/ob/handle.c +++ b/reactos/ntoskrnl/ob/handle.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: handle.c,v 1.34 2001/12/31 19:06:48 dwelch Exp $ +/* $Id: handle.c,v 1.35 2002/02/19 00:09:24 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -40,8 +40,19 @@ /* TYPES *******************************************************************/ +/* + * PURPOSE: Defines a handle + */ +typedef struct +{ + PVOID ObjectBody; + ACCESS_MASK GrantedAccess; + BOOLEAN Inherit; +} HANDLE_REP, *PHANDLE_REP; + #define HANDLE_BLOCK_ENTRIES ((PAGESIZE-sizeof(LIST_ENTRY))/sizeof(HANDLE_REP)) + /* * PURPOSE: Defines a page's worth of handles */ @@ -51,6 +62,7 @@ typedef struct HANDLE_REP handles[HANDLE_BLOCK_ENTRIES]; } HANDLE_BLOCK, *PHANDLE_BLOCK; + /* GLOBALS *******************************************************************/ #define TAG_HANDLE_TABLE TAG('H', 'T', 'B', 'L') @@ -657,7 +669,7 @@ NTSTATUS STDCALL NtClose(HANDLE Handle) return(STATUS_SUCCESS); } -NTSTATUS STDCALL +NTSTATUS STDCALL ObInsertObject(PVOID Object, PACCESS_STATE PassedAccessState, ACCESS_MASK DesiredAccess, @@ -671,6 +683,5 @@ ObInsertObject(PVOID Object, FALSE, Handle)); } - /* EOF */ diff --git a/reactos/ntoskrnl/ob/namespc.c b/reactos/ntoskrnl/ob/namespc.c index eaced98ca7a..adabcb35a8f 100644 --- a/reactos/ntoskrnl/ob/namespc.c +++ b/reactos/ntoskrnl/ob/namespc.c @@ -1,4 +1,4 @@ -/* $Id: namespc.c,v 1.27 2001/12/05 01:40:25 dwelch Exp $ +/* $Id: namespc.c,v 1.28 2002/02/19 00:09:24 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -149,27 +149,43 @@ ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes, } -VOID STDCALL -ObAddEntryDirectory(PDIRECTORY_OBJECT Parent, - POBJECT Object, - PWSTR Name) +VOID +ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent, + POBJECT_HEADER Header, + PWSTR Name) /* * FUNCTION: Add an entry to a namespace directory * ARGUMENTS: - * parent = directory to add in - * name = Name to give the entry - * Object = Header of the object to add the entry for + * Parent = directory to add in + * Header = Header of the object to add the entry for + * Name = Name to give the entry */ { - KIRQL oldlvl; - POBJECT_HEADER Header = BODY_TO_HEADER(Object); + KIRQL oldlvl; - RtlCreateUnicodeString(&Header->Name, Name); - Header->Parent = Parent; + RtlCreateUnicodeString(&Header->Name, Name); + Header->Parent = Parent; - KeAcquireSpinLock(&Parent->Lock, &oldlvl); - InsertTailList(&Parent->head, &Header->Entry); - KeReleaseSpinLock(&Parent->Lock, oldlvl); + KeAcquireSpinLock(&Parent->Lock, &oldlvl); + InsertTailList(&Parent->head, &Header->Entry); + KeReleaseSpinLock(&Parent->Lock, oldlvl); +} + +VOID +ObpRemoveEntryDirectory(POBJECT_HEADER Header) +/* + * FUNCTION: Remove an entry from a namespace directory + * ARGUMENTS: + * Header = Header of the object to remove + */ +{ + KIRQL oldlvl; + + DPRINT("ObpRemoveEntryDirectory(Header %x)\n",Header); + + KeAcquireSpinLock(&(Header->Parent->Lock),&oldlvl); + RemoveEntryList(&(Header->Entry)); + KeReleaseSpinLock(&(Header->Parent->Lock),oldlvl); } PVOID @@ -284,23 +300,20 @@ ObpCreateDirectory(PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - PDIRECTORY_OBJECT DirectoryObject = (PDIRECTORY_OBJECT)ObjectBody; - - DPRINT("ObpCreateDirectory(ObjectBody %x, Parent %x, RemainingPath %S)\n", - ObjectBody, Parent, RemainingPath); - - if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) - { - return(STATUS_UNSUCCESSFUL); - } - - if (Parent != NULL && RemainingPath != NULL) - { - ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); - } - InitializeListHead(&DirectoryObject->head); - KeInitializeSpinLock(&DirectoryObject->Lock); - return(STATUS_SUCCESS); + PDIRECTORY_OBJECT DirectoryObject = (PDIRECTORY_OBJECT)ObjectBody; + + DPRINT("ObpCreateDirectory(ObjectBody %x, Parent %x, RemainingPath %S)\n", + ObjectBody, Parent, RemainingPath); + + if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) + { + return(STATUS_UNSUCCESSFUL); + } + + InitializeListHead(&DirectoryObject->head); + KeInitializeSpinLock(&DirectoryObject->Lock); + + return(STATUS_SUCCESS); } VOID ObInit(VOID) @@ -339,14 +352,4 @@ VOID ObInit(VOID) (PVOID*)&NameSpaceRoot); } -VOID ObRemoveEntry(POBJECT_HEADER Header) -{ - KIRQL oldlvl; - - DPRINT("ObRemoveEntry(Header %x)\n",Header); - - KeAcquireSpinLock(&(Header->Parent->Lock),&oldlvl); - RemoveEntryList(&(Header->Entry)); - KeReleaseSpinLock(&(Header->Parent->Lock),oldlvl); -} - +/* EOF */ diff --git a/reactos/ntoskrnl/ob/object.c b/reactos/ntoskrnl/ob/object.c index 2a7722b5136..c77e1cd6cf8 100644 --- a/reactos/ntoskrnl/ob/object.c +++ b/reactos/ntoskrnl/ob/object.c @@ -1,4 +1,4 @@ -/* $Id: object.c,v 1.41 2002/02/08 02:57:07 chorns Exp $ +/* $Id: object.c,v 1.42 2002/02/19 00:09:25 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -233,75 +233,95 @@ ObCreateObject(PHANDLE Handle, POBJECT_TYPE Type, PVOID *Object) { - PVOID Parent = NULL; - UNICODE_STRING RemainingPath; - POBJECT_HEADER Header; - NTSTATUS Status; - - assert_irql(APC_LEVEL); - - DPRINT("ObCreateObject(Handle %x, ObjectAttributes %x, Type %x)\n"); - if (ObjectAttributes != NULL && - ObjectAttributes->ObjectName != NULL) - { - DPRINT("ObjectAttributes->ObjectName->Buffer %S\n", - ObjectAttributes->ObjectName->Buffer); - } - - if (ObjectAttributes != NULL && - ObjectAttributes->ObjectName != NULL) - { - Status = ObFindObject(ObjectAttributes, - &Parent, - &RemainingPath, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT("ObFindObject() failed! (Status 0x%x)\n", Status); - return(Status); - } - } - else - { - RtlInitUnicodeString (&RemainingPath, NULL); - } + PVOID Parent = NULL; + UNICODE_STRING RemainingPath; + POBJECT_HEADER Header; + POBJECT_HEADER ParentHeader = NULL; + NTSTATUS Status; - RtlMapGenericMask(&DesiredAccess, - Type->Mapping); + assert_irql(APC_LEVEL); - Header = (POBJECT_HEADER)ExAllocatePoolWithTag(NonPagedPool, - OBJECT_ALLOC_SIZE(Type), - Type->Tag); - ObInitializeObject(Header, - Handle, - DesiredAccess, - Type, - ObjectAttributes); - if ((Header->ObjectType != NULL) && - (Header->ObjectType->Create != NULL)) - { - DPRINT("Calling %x\n", Header->ObjectType->Create); - Status = Header->ObjectType->Create(HEADER_TO_BODY(Header), - Parent, - RemainingPath.Buffer, - ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - if (Parent) - { - ObDereferenceObject( Parent ); - } - RtlFreeUnicodeString( &Header->Name ); - RtlFreeUnicodeString( &RemainingPath ); - ExFreePool( Header ); - return(Status); - } - } - RtlFreeUnicodeString( &RemainingPath ); - *Object = HEADER_TO_BODY(Header); - return(STATUS_SUCCESS); + DPRINT("ObCreateObject(Handle %x, ObjectAttributes %x, Type %x)\n", + Handle, ObjectAttributes, Type); + if (ObjectAttributes != NULL && + ObjectAttributes->ObjectName != NULL) + { + DPRINT("ObjectAttributes->ObjectName->Buffer %S\n", + ObjectAttributes->ObjectName->Buffer); + } + + if (ObjectAttributes != NULL && + ObjectAttributes->ObjectName != NULL) + { + Status = ObFindObject(ObjectAttributes, + &Parent, + &RemainingPath, + NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT("ObFindObject() failed! (Status 0x%x)\n", Status); + return(Status); + } + } + else + { + RtlInitUnicodeString(&RemainingPath, NULL); + } + + RtlMapGenericMask(&DesiredAccess, + Type->Mapping); + + Header = (POBJECT_HEADER)ExAllocatePoolWithTag(NonPagedPool, + OBJECT_ALLOC_SIZE(Type), + Type->Tag); + ObInitializeObject(Header, + Handle, + DesiredAccess, + Type, + ObjectAttributes); + + if (Parent != NULL) + { + ParentHeader = BODY_TO_HEADER(Parent); + } + + if (ParentHeader != NULL && + ParentHeader->ObjectType == ObDirectoryType && + RemainingPath.Buffer != NULL) + { + ObpAddEntryDirectory(Parent, + Header, + RemainingPath.Buffer+1); + } + + if ((Header->ObjectType != NULL) && + (Header->ObjectType->Create != NULL)) + { + DPRINT("Calling %x\n", Header->ObjectType->Create); + Status = Header->ObjectType->Create(HEADER_TO_BODY(Header), + Parent, + RemainingPath.Buffer, + ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + if (Parent) + { + ObDereferenceObject(Parent); + } + RtlFreeUnicodeString(&Header->Name); + RtlFreeUnicodeString(&RemainingPath); + ExFreePool(Header); + return(Status); + } + } + RtlFreeUnicodeString( &RemainingPath ); + + *Object = HEADER_TO_BODY(Header); + + return(STATUS_SUCCESS); } + NTSTATUS STDCALL ObReferenceObjectByPointer(PVOID ObjectBody, ACCESS_MASK DesiredAccess, @@ -415,7 +435,7 @@ NTSTATUS ObPerformRetentionChecks(POBJECT_HEADER Header) } if (Header->Name.Buffer != NULL) { - ObRemoveEntry(Header); + ObpRemoveEntryDirectory(Header); RtlFreeUnicodeString( &Header->Name ); } DPRINT("ObPerformRetentionChecks() = Freeing object\n");