From 895c98c856bb0320b6d44dcedec195adc39b64b2 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 25 Sep 2003 20:09:56 +0000 Subject: [PATCH] Replaced ObRosCreateObject() by ObCreateObject() and ObInsertObject(). Fixed ObCreateObject() and ObInsertObject(). svn path=/trunk/; revision=6140 --- reactos/include/ddk/obfuncs.h | 11 ++ reactos/include/ntos/obtypes.h | 3 +- reactos/include/ntos/zwtypes.h | 7 -- reactos/ntoskrnl/cm/ntfunc.c | 22 +++- reactos/ntoskrnl/cm/registry.c | 45 +++++---- reactos/ntoskrnl/cm/regobj.c | 10 +- reactos/ntoskrnl/include/internal/ob.h | 2 +- reactos/ntoskrnl/io/create.c | 43 +++++--- reactos/ntoskrnl/io/device.c | 39 ++++--- reactos/ntoskrnl/io/iocomp.c | 37 +++++-- reactos/ntoskrnl/lpc/connect.c | 39 +++++-- reactos/ntoskrnl/lpc/create.c | 27 ++++- reactos/ntoskrnl/mm/section.c | 105 +++++++++++++++---- reactos/ntoskrnl/nt/evtpair.c | 24 ++++- reactos/ntoskrnl/nt/mutant.c | 21 +++- reactos/ntoskrnl/nt/ntevent.c | 21 +++- reactos/ntoskrnl/nt/ntsem.c | 26 +++-- reactos/ntoskrnl/nt/nttimer.c | 21 +++- reactos/ntoskrnl/nt/profile.c | 22 +++- reactos/ntoskrnl/ntoskrnl.def | 5 +- reactos/ntoskrnl/ntoskrnl.edf | 5 +- reactos/ntoskrnl/ob/dirobj.c | 46 ++++++--- reactos/ntoskrnl/ob/handle.c | 27 +++-- reactos/ntoskrnl/ob/namespc.c | 32 ++++-- reactos/ntoskrnl/ob/object.c | 134 ++++++++----------------- reactos/ntoskrnl/ob/symlink.c | 24 ++++- reactos/ntoskrnl/ps/create.c | 24 ++++- reactos/ntoskrnl/ps/process.c | 38 +++++-- reactos/ntoskrnl/se/token.c | 59 ++++++++--- reactos/subsys/win32k/ntuser/winsta.c | 52 ++++++++-- 30 files changed, 671 insertions(+), 300 deletions(-) diff --git a/reactos/include/ddk/obfuncs.h b/reactos/include/ddk/obfuncs.h index 663a64ecce4..cfca99a462c 100644 --- a/reactos/include/ddk/obfuncs.h +++ b/reactos/include/ddk/obfuncs.h @@ -8,6 +8,17 @@ ObAssignSecurity(IN PACCESS_STATE AccessState, IN PVOID Object, IN POBJECT_TYPE Type); +NTSTATUS STDCALL +ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, + IN POBJECT_TYPE ObjectType, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN OUT PVOID ParseContext OPTIONAL, + IN ULONG ObjectSize, + IN ULONG PagedPoolCharge OPTIONAL, + IN ULONG NonPagedPoolCharge OPTIONAL, + OUT PVOID *Object); + VOID FASTCALL ObfDereferenceObject(IN PVOID Object); diff --git a/reactos/include/ntos/obtypes.h b/reactos/include/ntos/obtypes.h index cf4fd5afa72..36e6f1df889 100755 --- a/reactos/include/ntos/obtypes.h +++ b/reactos/include/ntos/obtypes.h @@ -1,6 +1,6 @@ #ifndef _INCLUDE_DDK_OBTYPES_H #define _INCLUDE_DDK_OBTYPES_H -/* $Id: obtypes.h,v 1.3 2003/06/02 10:02:16 ekohl Exp $ */ +/* $Id: obtypes.h,v 1.4 2003/09/25 20:00:25 ekohl Exp $ */ struct _DIRECTORY_OBJECT; struct _OBJECT_ATTRIBUTES; @@ -160,6 +160,7 @@ typedef struct _OBJECT_HEADER LONG HandleCount; BOOLEAN CloseInProcess; BOOLEAN Permanent; + BOOLEAN Inherit; struct _DIRECTORY_OBJECT* Parent; POBJECT_TYPE ObjectType; diff --git a/reactos/include/ntos/zwtypes.h b/reactos/include/ntos/zwtypes.h index 2b0e877ecf2..3d503727ab4 100755 --- a/reactos/include/ntos/zwtypes.h +++ b/reactos/include/ntos/zwtypes.h @@ -1689,13 +1689,6 @@ typedef struct _KINTERRUPT *PKINTERRUPT; #endif /* __USE_W32API */ -NTSTATUS STDCALL -ObRosCreateObject(OUT PHANDLE Handle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN POBJECT_TYPE Type, - OUT PVOID *Object); - /* BEGIN REACTOS ONLY */ typedef enum _TRAVERSE_METHOD { diff --git a/reactos/ntoskrnl/cm/ntfunc.c b/reactos/ntoskrnl/cm/ntfunc.c index 503c944c069..0e6fb267cb1 100644 --- a/reactos/ntoskrnl/cm/ntfunc.c +++ b/reactos/ntoskrnl/cm/ntfunc.c @@ -103,16 +103,32 @@ NtCreateKey(OUT PHANDLE KeyHandle, DPRINT("RemainingPath %S ParentObject %x\n", RemainingPath.Buffer, Object); - Status = ObRosCreateObject(KeyHandle, - DesiredAccess, - NULL, + Status = ObCreateObject(ExGetPreviousMode(), CmiKeyType, + NULL, + ExGetPreviousMode(), + NULL, + sizeof(KEY_OBJECT), + 0, + 0, (PVOID*)&KeyObject); if (!NT_SUCCESS(Status)) { return(Status); } + Status = ObInsertObject((PVOID)KeyObject, + NULL, + DesiredAccess, + 0, + NULL, + KeyHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(KeyObject); + return(Status); + } + KeyObject->ParentKey = Object; if (CreateOptions & REG_OPTION_VOLATILE) diff --git a/reactos/ntoskrnl/cm/registry.c b/reactos/ntoskrnl/cm/registry.c index 7f452d19c5b..228f23bc20f 100644 --- a/reactos/ntoskrnl/cm/registry.c +++ b/reactos/ntoskrnl/cm/registry.c @@ -1,4 +1,4 @@ -/* $Id: registry.c,v 1.107 2003/07/21 21:53:51 royce Exp $ +/* $Id: registry.c,v 1.108 2003/09/25 20:03:11 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -290,18 +290,22 @@ CmInitializeRegistry(VOID) /* Create '\Registry' key. */ RtlInitUnicodeString(&KeyName, REG_ROOT_KEY_NAME); InitializeObjectAttributes(&ObjectAttributes, &KeyName, 0, NULL, NULL); - Status = ObRosCreateObject(&RootKeyHandle, - STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, - CmiKeyType, - (PVOID *) &RootKey); + Status = ObCreateObject(KernelMode, + CmiKeyType, + &ObjectAttributes, + KernelMode, + NULL, + sizeof(KEY_OBJECT), + 0, + 0, + (PVOID *) &RootKey); assert(NT_SUCCESS(Status)); - Status = ObReferenceObjectByHandle(RootKeyHandle, - STANDARD_RIGHTS_REQUIRED, - CmiKeyType, - KernelMode, - (PVOID *)&RootKey, - NULL); + Status = ObInsertObject(RootKey, + NULL, + STANDARD_RIGHTS_REQUIRED, + 0, + NULL, + &RootKeyHandle); assert(NT_SUCCESS(Status)); RootKey->RegistryHive = CmiVolatileHive; RootKey->BlockOffset = CmiVolatileHive->HiveHeader->RootKeyCell; @@ -544,19 +548,18 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes, DPRINT("RemainingPath %wZ ParentKey %p\n", &RemainingPath, ParentKey); - Status = ObRosCreateObject(NULL, - STANDARD_RIGHTS_REQUIRED, - NULL, + Status = ObCreateObject(KernelMode, CmiKeyType, + NULL, + KernelMode, + NULL, + sizeof(KEY_OBJECT), + 0, + 0, (PVOID*)&NewKey); if (!NT_SUCCESS(Status)) { - return Status; - } - - if (!NT_SUCCESS(Status)) - { - DPRINT1 ("ObRosCreateObject() failed (Status %lx)\n", Status); + DPRINT1 ("ObCreateObject() failed (Status %lx)\n", Status); ObDereferenceObject (ParentKey); return Status; } diff --git a/reactos/ntoskrnl/cm/regobj.c b/reactos/ntoskrnl/cm/regobj.c index 9c6d25cbc74..70838701ca4 100644 --- a/reactos/ntoskrnl/cm/regobj.c +++ b/reactos/ntoskrnl/cm/regobj.c @@ -147,10 +147,14 @@ CmiObjectParse(PVOID ParsedObject, /* Create new key object and put into linked list */ DPRINT("CmiObjectParse: %s\n", Path); - Status = ObRosCreateObject(NULL, - STANDARD_RIGHTS_REQUIRED, - NULL, + Status = ObCreateObject(KernelMode, CmiKeyType, + NULL, + KernelMode, + NULL, + sizeof(KEY_OBJECT), + 0, + 0, (PVOID*)&FoundObject); if (!NT_SUCCESS(Status)) { diff --git a/reactos/ntoskrnl/include/internal/ob.h b/reactos/ntoskrnl/include/internal/ob.h index 23d67938295..353e4c14d16 100644 --- a/reactos/ntoskrnl/include/internal/ob.h +++ b/reactos/ntoskrnl/include/internal/ob.h @@ -63,7 +63,7 @@ enum }; -#define OBJECT_ALLOC_SIZE(type) (type->NonpagedPoolCharge+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER)) +#define OBJECT_ALLOC_SIZE(ObjectSize) ((ObjectSize)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER)) extern PDIRECTORY_OBJECT NameSpaceRoot; diff --git a/reactos/ntoskrnl/io/create.c b/reactos/ntoskrnl/io/create.c index cbb17232a2f..cdbf0b04058 100644 --- a/reactos/ntoskrnl/io/create.c +++ b/reactos/ntoskrnl/io/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.67 2003/07/11 01:23:14 royce Exp $ +/* $Id: create.c,v 1.68 2003/09/25 20:04:27 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -211,7 +211,6 @@ PFILE_OBJECT STDCALL IoCreateStreamFileObject(PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject) { - HANDLE FileHandle; PFILE_OBJECT CreatedFileObject; NTSTATUS Status; @@ -220,10 +219,14 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject, assert_irql(PASSIVE_LEVEL); - Status = ObRosCreateObject(&FileHandle, - STANDARD_RIGHTS_REQUIRED, - NULL, + Status = ObCreateObject(KernelMode, IoFileObjectType, + NULL, + KernelMode, + NULL, + sizeof(FILE_OBJECT), + 0, + 0, (PVOID*)&CreatedFileObject); if (!NT_SUCCESS(Status)) { @@ -247,9 +250,7 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject, // shouldn't we initialize the lock event, and several other things here too? KeInitializeEvent(&CreatedFileObject->Event, NotificationEvent, FALSE); - ZwClose(FileHandle); - - return(CreatedFileObject); + return CreatedFileObject; } @@ -354,16 +355,34 @@ IoCreateFile(OUT PHANDLE FileHandle, *FileHandle = 0; - Status = ObRosCreateObject(FileHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), IoFileObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(FILE_OBJECT), + 0, + 0, (PVOID*)&FileObject); if (!NT_SUCCESS(Status)) { - DPRINT("ObRosCreateObject() failed! (Status %lx)\n", Status); + DPRINT("ObCreateObject() failed! (Status %lx)\n", Status); return(Status); } + + Status = ObInsertObject ((PVOID)FileObject, + NULL, + DesiredAccess, + 0, + NULL, + FileHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT("ObInsertObject() failed! (Status %lx)\n", Status); + ObDereferenceObject (FileObject); + return(Status); + } + if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT) { FileObject->Flags |= (FO_ALERTABLE_IO | FO_SYNCHRONOUS_IO); diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index 38691368335..12ceb30ddd2 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -1,4 +1,4 @@ -/* $Id: device.c,v 1.59 2003/09/25 15:54:42 navaraf Exp $ +/* $Id: device.c,v 1.60 2003/09/25 20:04:27 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -281,7 +281,6 @@ IopCreateDriverObject(PDRIVER_OBJECT *DriverObject, ULONG DriverImageSize) { PDRIVER_OBJECT Object; - HANDLE DriverHandle = 0; ULONG i; WCHAR NameBuffer[MAX_PATH]; UNICODE_STRING DriverName; @@ -314,19 +313,21 @@ IopCreateDriverObject(PDRIVER_OBJECT *DriverObject, NULL, NULL); - /* Create module object */ - Status = ObRosCreateObject(&DriverHandle, - STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + /* Create driver object */ + Status = ObCreateObject(KernelMode, IoDriverObjectType, + &ObjectAttributes, + KernelMode, + NULL, + sizeof(DRIVER_OBJECT), + 0, + 0, (PVOID*)&Object); if (!NT_SUCCESS(Status)) { return(Status); } - NtClose(DriverHandle); - /* Create driver extension */ Object->DriverExtension = (PDRIVER_EXTENSION) ExAllocatePoolWithTag(NonPagedPool, @@ -763,18 +764,26 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, if (DeviceName != NULL) { InitializeObjectAttributes(&ObjectAttributes,DeviceName,0,NULL,NULL); - Status = ObRosCreateObject(NULL, - 0, - &ObjectAttributes, + Status = ObCreateObject(KernelMode, IoDeviceObjectType, + &ObjectAttributes, + KernelMode, + NULL, + sizeof(DEVICE_OBJECT), + 0, + 0, (PVOID*)&CreatedDeviceObject); } else { - Status = ObRosCreateObject(NULL, - 0, - NULL, + Status = ObCreateObject(KernelMode, IoDeviceObjectType, + NULL, + KernelMode, + NULL, + sizeof(DEVICE_OBJECT), + 0, + 0, (PVOID*)&CreatedDeviceObject); } @@ -782,7 +791,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, if (!NT_SUCCESS(Status)) { - DPRINT("IoCreateDevice() ObRosCreateObject failed, status: 0x%08X\n", Status); + DPRINT("IoCreateDevice() ObCreateObject failed, status: 0x%08X\n", Status); return(Status); } diff --git a/reactos/ntoskrnl/io/iocomp.c b/reactos/ntoskrnl/io/iocomp.c index dddc777259b..635fabadf73 100644 --- a/reactos/ntoskrnl/io/iocomp.c +++ b/reactos/ntoskrnl/io/iocomp.c @@ -114,20 +114,37 @@ NtCreateIoCompletion( { PKQUEUE Queue; NTSTATUS Status; - - Status = ObRosCreateObject(IoCompletionHandle, - DesiredAccess, - ObjectAttributes, - ExIoCompletionType, - (PVOID*)&Queue); - if (NT_SUCCESS(Status)) + Status = ObCreateObject(ExGetPreviousMode(), + ExIoCompletionType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(KQUEUE), + 0, + 0, + (PVOID*)&Queue); + if (!NT_SUCCESS(Status)) { - (void) KeInitializeQueue(Queue, NumberOfConcurrentThreads); - ObDereferenceObject(Queue); + return Status; } - return Status; + Status = ObInsertObject ((PVOID)Queue, + NULL, + DesiredAccess, + 0, + NULL, + IoCompletionHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(Queue); + return Status; + } + + KeInitializeQueue(Queue, NumberOfConcurrentThreads); + ObDereferenceObject(Queue); + + return STATUS_SUCCESS; /* CompletionPort = NULL OR ExistingCompletionPort diff --git a/reactos/ntoskrnl/lpc/connect.c b/reactos/ntoskrnl/lpc/connect.c index 842f15c00de..bcccf5e04b1 100644 --- a/reactos/ntoskrnl/lpc/connect.c +++ b/reactos/ntoskrnl/lpc/connect.c @@ -1,4 +1,4 @@ -/* $Id: connect.c,v 1.19 2003/08/07 11:47:33 silverblade Exp $ +/* $Id: connect.c,v 1.20 2003/09/25 20:04:59 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -63,10 +63,14 @@ EiConnectPort(IN PEPORT* ConnectedPort, /* * Create a port to represent our side of the connection */ - Status = ObRosCreateObject (NULL, - PORT_ALL_ACCESS, - NULL, + Status = ObCreateObject (KernelMode, ExPortType, + NULL, + KernelMode, + NULL, + sizeof(EPORT), + 0, + 0, (PVOID*)&OurPort); if (!NT_SUCCESS(Status)) { @@ -548,10 +552,14 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, */ if (AcceptIt) { - Status = ObRosCreateObject(ServerPortHandle, - PORT_ALL_ACCESS, - NULL, + Status = ObCreateObject(ExGetPreviousMode(), ExPortType, + NULL, + ExGetPreviousMode(), + NULL, + sizeof(EPORT), + 0, + 0, (PVOID*)&OurPort); if (!NT_SUCCESS(Status)) { @@ -559,9 +567,24 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, ObDereferenceObject(NamedPort); return(Status); } + + Status = ObInsertObject ((PVOID)OurPort, + NULL, + PORT_ALL_ACCESS, + 0, + NULL, + ServerPortHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(OurPort); + ExFreePool(CReply); + ObDereferenceObject(NamedPort); + return(Status); + } + NiInitializePort(OurPort); } - + /* * Dequeue the connection request */ diff --git a/reactos/ntoskrnl/lpc/create.c b/reactos/ntoskrnl/lpc/create.c index adda022a4a2..727455b2723 100644 --- a/reactos/ntoskrnl/lpc/create.c +++ b/reactos/ntoskrnl/lpc/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.12 2003/07/11 01:23:15 royce Exp $ +/* $Id: create.c,v 1.13 2003/09/25 20:04:59 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -112,17 +112,34 @@ NtCreatePort (PHANDLE PortHandle, { return (Status); } + /* Ask Ob to create the object */ - Status = ObRosCreateObject (PortHandle, - PORT_ALL_ACCESS, - ObjectAttributes, + Status = ObCreateObject (ExGetPreviousMode(), ExPortType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(EPORT), + 0, + 0, (PVOID*)&Port); if (!NT_SUCCESS(Status)) { return (Status); } - + + Status = ObInsertObject ((PVOID)Port, + NULL, + PORT_ALL_ACCESS, + 0, + NULL, + PortHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject (Port); + return (Status); + } + Status = NiInitializePort (Port); Port->MaxConnectInfoLength = 260; /* FIXME: use a macro! */ Port->MaxDataLength = 328; /* FIXME: use a macro! */ diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 8a64c0e620e..e577b72ef01 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.127 2003/08/20 00:02:31 dwelch Exp $ +/* $Id: section.c,v 1.128 2003/09/25 20:05:44 ekohl Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/section.c @@ -2201,16 +2201,32 @@ MmCreatePageFileSection(PHANDLE SectionHandle, /* * Create the section */ - Status = ObRosCreateObject(SectionHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), MmSectionObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(SECTION_OBJECT), + 0, + 0, (PVOID*)&Section); if (!NT_SUCCESS(Status)) { return(Status); } - + + Status = ObInsertObject ((PVOID)Section, + NULL, + DesiredAccess, + 0, + NULL, + SectionHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(Section); + return(Status); + } + /* * Initialize it */ @@ -2296,16 +2312,32 @@ MmCreateDataFileSection(PHANDLE SectionHandle, /* * Create the section */ - Status = ObRosCreateObject(SectionHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), MmSectionObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(SECTION_OBJECT), + 0, + 0, (PVOID*)&Section); if (!NT_SUCCESS(Status)) { return(Status); } - + + Status = ObInsertObject ((PVOID)Section, + NULL, + DesiredAccess, + 0, + NULL, + SectionHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(Section); + return(Status); + } + /* * Initialize it */ @@ -2654,11 +2686,15 @@ MmCreateImageSection(PHANDLE SectionHandle, /* * Create the section */ - Status = ObRosCreateObject(SectionHandle, - DesiredAccess, - ObjectAttributes, - MmSectionObjectType, - (PVOID*)&Section); + Status = ObCreateObject (ExGetPreviousMode(), + MmSectionObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(SECTION_OBJECT), + 0, + 0, + (PVOID*)&Section); if (!NT_SUCCESS(Status)) { ObDereferenceObject(FileObject); @@ -2666,6 +2702,20 @@ MmCreateImageSection(PHANDLE SectionHandle, return(Status); } + Status = ObInsertObject ((PVOID)Section, + NULL, + DesiredAccess, + 0, + NULL, + SectionHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(Section); + ObDereferenceObject(FileObject); + ExFreePool(ImageSections); + return(Status); + } + /* * Initialize it */ @@ -2840,17 +2890,34 @@ MmCreateImageSection(PHANDLE SectionHandle, /* * Create the section */ - Status = ObRosCreateObject(SectionHandle, - DesiredAccess, - ObjectAttributes, - MmSectionObjectType, - (PVOID*)&Section); + Status = ObCreateObject (ExGetPreviousMode(), + MmSectionObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(SECTION_OBJECT), + 0, + 0, + (PVOID*)&Section); if (!NT_SUCCESS(Status)) { ObDereferenceObject(FileObject); return(Status); } + Status = ObInsertObject ((PVOID)Section, + NULL, + DesiredAccess, + 0, + NULL, + SectionHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(Section); + ObDereferenceObject(FileObject); + return(Status); + } + /* * Initialize it */ diff --git a/reactos/ntoskrnl/nt/evtpair.c b/reactos/ntoskrnl/nt/evtpair.c index ec95a722233..5eed79b39ad 100644 --- a/reactos/ntoskrnl/nt/evtpair.c +++ b/reactos/ntoskrnl/nt/evtpair.c @@ -1,4 +1,4 @@ -/* $Id: evtpair.c,v 1.16 2003/09/14 09:18:04 hbirr Exp $ +/* $Id: evtpair.c,v 1.17 2003/09/25 20:06:32 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -101,23 +101,37 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle, NTSTATUS Status; DPRINT("NtCreateEventPair()\n"); - Status = ObRosCreateObject(EventPairHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), ExEventPairObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(KEVENT_PAIR), + 0, + 0, (PVOID*)&EventPair); if (!NT_SUCCESS(Status)) { return(Status); } + KeInitializeEvent(&EventPair->LowEvent, SynchronizationEvent, FALSE); KeInitializeEvent(&EventPair->HighEvent, SynchronizationEvent, FALSE); + + Status = ObInsertObject ((PVOID)EventPair, + NULL, + DesiredAccess, + 0, + NULL, + EventPairHandle); + ObDereferenceObject(EventPair); - return(STATUS_SUCCESS); + + return Status; } diff --git a/reactos/ntoskrnl/nt/mutant.c b/reactos/ntoskrnl/nt/mutant.c index 47589c84027..0c7b3b5ca46 100644 --- a/reactos/ntoskrnl/nt/mutant.c +++ b/reactos/ntoskrnl/nt/mutant.c @@ -114,20 +114,33 @@ NtCreateMutant(OUT PHANDLE MutantHandle, PKMUTEX Mutant; NTSTATUS Status; - Status = ObRosCreateObject(MutantHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), ExMutantObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(KMUTANT), + 0, + 0, (PVOID*)&Mutant); if (!NT_SUCCESS(Status)) { return(Status); } + KeInitializeMutant(Mutant, InitialOwner); + + Status = ObInsertObject ((PVOID)Mutant, + NULL, + DesiredAccess, + 0, + NULL, + MutantHandle); + ObDereferenceObject(Mutant); - return(STATUS_SUCCESS); + return Status; } diff --git a/reactos/ntoskrnl/nt/ntevent.c b/reactos/ntoskrnl/nt/ntevent.c index f4b8126300d..51aa1ec4a59 100644 --- a/reactos/ntoskrnl/nt/ntevent.c +++ b/reactos/ntoskrnl/nt/ntevent.c @@ -150,10 +150,14 @@ NtCreateEvent(OUT PHANDLE UnsafeEventHandle, ObjectAttributes = NULL; } - Status = ObRosCreateObject(&EventHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), ExEventObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(KEVENT), + 0, + 0, (PVOID*)&Event); if (!NT_SUCCESS(Status)) { @@ -162,7 +166,18 @@ NtCreateEvent(OUT PHANDLE UnsafeEventHandle, KeInitializeEvent(Event, ManualReset ? NotificationEvent : SynchronizationEvent, InitialState); + + Status = ObInsertObject ((PVOID)Event, + NULL, + DesiredAccess, + 0, + NULL, + &EventHandle); ObDereferenceObject(Event); + if (!NT_SUCCESS(Status)) + { + return Status; + } Status = MmCopyToCaller(UnsafeEventHandle, &EventHandle, sizeof(HANDLE)); if (!NT_SUCCESS(Status)) diff --git a/reactos/ntoskrnl/nt/ntsem.c b/reactos/ntoskrnl/nt/ntsem.c index 5e4797ed0ca..58a4ab3d8ac 100644 --- a/reactos/ntoskrnl/nt/ntsem.c +++ b/reactos/ntoskrnl/nt/ntsem.c @@ -1,4 +1,4 @@ -/* $Id: ntsem.c,v 1.18 2003/06/07 12:23:14 chorns Exp $ +/* $Id: ntsem.c,v 1.19 2003/09/25 20:06:32 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -85,21 +85,35 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle, { PKSEMAPHORE Semaphore; NTSTATUS Status; - - Status = ObRosCreateObject(SemaphoreHandle, - DesiredAccess, - ObjectAttributes, + + Status = ObCreateObject(ExGetPreviousMode(), ExSemaphoreType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(KSEMAPHORE), + 0, + 0, (PVOID*)&Semaphore); if (!NT_SUCCESS(Status)) { return(Status); } + KeInitializeSemaphore(Semaphore, InitialCount, MaximumCount); + + Status = ObInsertObject ((PVOID)Semaphore, + NULL, + DesiredAccess, + 0, + NULL, + SemaphoreHandle); + ObDereferenceObject(Semaphore); - return(STATUS_SUCCESS); + + return Status; } diff --git a/reactos/ntoskrnl/nt/nttimer.c b/reactos/ntoskrnl/nt/nttimer.c index 9f72c5efd1f..c7d8a6deaed 100644 --- a/reactos/ntoskrnl/nt/nttimer.c +++ b/reactos/ntoskrnl/nt/nttimer.c @@ -1,4 +1,4 @@ -/* $Id: nttimer.c,v 1.19 2003/06/07 12:23:14 chorns Exp $ +/* $Id: nttimer.c,v 1.20 2003/09/25 20:06:32 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -192,10 +192,14 @@ NtCreateTimer(OUT PHANDLE TimerHandle, NTSTATUS Status; DPRINT("NtCreateTimer()\n"); - Status = ObRosCreateObject(TimerHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), ExTimerType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(NTTIMER), + 0, + 0, (PVOID*)&Timer); if (!NT_SUCCESS(Status)) return Status; @@ -209,9 +213,16 @@ NtCreateTimer(OUT PHANDLE TimerHandle, Timer->Running = FALSE; + Status = ObInsertObject ((PVOID)Timer, + NULL, + DesiredAccess, + 0, + NULL, + TimerHandle); + ObDereferenceObject(Timer); - return(STATUS_SUCCESS); + return Status; } diff --git a/reactos/ntoskrnl/nt/profile.c b/reactos/ntoskrnl/nt/profile.c index 7263ef3e730..5b17cabebc5 100644 --- a/reactos/ntoskrnl/nt/profile.c +++ b/reactos/ntoskrnl/nt/profile.c @@ -458,10 +458,14 @@ NtCreateProfile(OUT PHANDLE UnsafeProfileHandle, /* * Create the object */ - Status = ObRosCreateObject(&ProfileHandle, - STANDARD_RIGHTS_ALL, - NULL, + Status = ObCreateObject(ExGetPreviousMode(), ExProfileObjectType, + NULL, + ExGetPreviousMode(), + NULL, + sizeof(KPROFILE), + 0, + 0, (PVOID*)&Profile); if (!NT_SUCCESS(Status)) { @@ -487,6 +491,18 @@ NtCreateProfile(OUT PHANDLE UnsafeProfileHandle, */ KiInsertProfile(Profile); + Status = ObInsertObject ((PVOID)Profile, + NULL, + STANDARD_RIGHTS_ALL, + 0, + NULL, + &ProfileHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject (Profile); + return Status; + } + /* * Copy the created handle back to the caller */ diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index 0396be01c04..d8ace06c010 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.def,v 1.166 2003/09/25 18:29:45 navaraf Exp $ +; $Id: ntoskrnl.def,v 1.167 2003/09/25 20:02:09 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -611,11 +611,10 @@ ObAssignSecurity@16 ;ObCheckCreateObjectAccess@28 ;ObCheckObjectAccess@20 ObCreateObject@36 -ObRosCreateObject@20 ;ObFindHandleForObject@20 ObGetObjectPointerCount@4 ObGetObjectSecurity@12 -;ObInsertObject@24 +ObInsertObject@24 ObMakeTemporaryObject@4 ObOpenObjectByName@28 ObOpenObjectByPointer@28 diff --git a/reactos/ntoskrnl/ntoskrnl.edf b/reactos/ntoskrnl/ntoskrnl.edf index 7852c136590..6a2ad560963 100644 --- a/reactos/ntoskrnl/ntoskrnl.edf +++ b/reactos/ntoskrnl/ntoskrnl.edf @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.edf,v 1.153 2003/09/25 15:54:42 navaraf Exp $ +; $Id: ntoskrnl.edf,v 1.154 2003/09/25 20:02:09 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -612,11 +612,10 @@ ObAssignSecurity=ObAssignSecurity@16 ;ObCheckCreateObjectAccess=ObCheckCreateObjectAccess@28 ;ObCheckObjectAccess=ObCheckObjectAccess@20 ObCreateObject=ObCreateObject@36 -ObRosCreateObject=ObRosCreateObject@20 ;ObFindHandleForObject=ObFindHandleForObject@20 ObGetObjectPointerCount=ObGetObjectPointerCount@4 ObGetObjectSecurity=ObGetObjectSecurity@12 -;ObInsertObject=ObInsertObject@24 +ObInsertObject=ObInsertObject@24 ObMakeTemporaryObject=ObMakeTemporaryObject@4 ObOpenObjectByName=ObOpenObjectByName@28 ObOpenObjectByPointer=ObOpenObjectByPointer@28 diff --git a/reactos/ntoskrnl/ob/dirobj.c b/reactos/ntoskrnl/ob/dirobj.c index 39a37338a3c..361937e4171 100644 --- a/reactos/ntoskrnl/ob/dirobj.c +++ b/reactos/ntoskrnl/ob/dirobj.c @@ -1,4 +1,4 @@ -/* $Id: dirobj.c,v 1.19 2003/09/03 20:15:02 ekohl Exp $ +/* $Id: dirobj.c,v 1.20 2003/09/25 20:07:46 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -332,19 +332,39 @@ NtCreateDirectoryObject (OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes) { - PDIRECTORY_OBJECT dir; + PDIRECTORY_OBJECT DirectoryObject; + NTSTATUS Status; - DPRINT("NtCreateDirectoryObject(DirectoryHandle %x, " - "DesiredAccess %x, ObjectAttributes %x, " - "ObjectAttributes->ObjectName %S)\n", - DirectoryHandle, DesiredAccess, ObjectAttributes, - ObjectAttributes->ObjectName); - - return(ObRosCreateObject(DirectoryHandle, - DesiredAccess, - ObjectAttributes, - ObDirectoryType, - (PVOID*)&dir)); + DPRINT("NtCreateDirectoryObject(DirectoryHandle %x, " + "DesiredAccess %x, ObjectAttributes %x, " + "ObjectAttributes->ObjectName %wZ)\n", + DirectoryHandle, DesiredAccess, ObjectAttributes, + ObjectAttributes->ObjectName); + + Status = ObCreateObject (ExGetPreviousMode(), + ObDirectoryType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(DIRECTORY_OBJECT), + 0, + 0, + (PVOID*)&DirectoryObject); + if (!NT_SUCCESS(Status)) + { + return Status; + } + + Status = ObInsertObject ((PVOID)DirectoryObject, + NULL, + DesiredAccess, + 0, + NULL, + DirectoryHandle); + + ObDereferenceObject(DirectoryObject); + + return Status; } /* EOF */ diff --git a/reactos/ntoskrnl/ob/handle.c b/reactos/ntoskrnl/ob/handle.c index cc3527cf9c8..891cbeafa6f 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.50 2003/09/14 09:19:07 hbirr Exp $ +/* $Id: handle.c,v 1.51 2003/09/25 20:07:46 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -774,17 +774,26 @@ NTSTATUS STDCALL NtClose(HANDLE Handle) * @implemented */ NTSTATUS STDCALL -ObInsertObject(PVOID Object, - PACCESS_STATE PassedAccessState, - ACCESS_MASK DesiredAccess, - ULONG AdditionalReferences, - PVOID* ReferencedObject, - PHANDLE Handle) +ObInsertObject(IN PVOID Object, + IN PACCESS_STATE PassedAccessState OPTIONAL, + IN ACCESS_MASK DesiredAccess, + IN ULONG AdditionalReferences, + OUT PVOID* ReferencedObject OPTIONAL, + OUT PHANDLE Handle) { + POBJECT_HEADER ObjectHeader; + ACCESS_MASK Access; + + Access = DesiredAccess; + ObjectHeader = BODY_TO_HEADER(Object); + + RtlMapGenericMask(&Access, + ObjectHeader->ObjectType->Mapping); + return(ObCreateHandle(PsGetCurrentProcess(), Object, - DesiredAccess, - FALSE, + Access, + ObjectHeader->Inherit, Handle)); } diff --git a/reactos/ntoskrnl/ob/namespc.c b/reactos/ntoskrnl/ob/namespc.c index 5ef6b2065d9..820356fccba 100644 --- a/reactos/ntoskrnl/ob/namespc.c +++ b/reactos/ntoskrnl/ob/namespc.c @@ -1,4 +1,4 @@ -/* $Id: namespc.c,v 1.39 2003/07/10 21:34:29 royce Exp $ +/* $Id: namespc.c,v 1.40 2003/09/25 20:07:46 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -399,10 +399,14 @@ ObInit(VOID) L"ObjectType"); /* create root directory */ - ObRosCreateObject(NULL, - STANDARD_RIGHTS_REQUIRED, - NULL, + ObCreateObject(KernelMode, ObDirectoryType, + NULL, + KernelMode, + NULL, + sizeof(DIRECTORY_OBJECT), + 0, + 0, (PVOID*)&NameSpaceRoot); /* create '\ObjectTypes' directory */ @@ -413,10 +417,14 @@ ObInit(VOID) OBJ_PERMANENT, NULL, NULL); - ObRosCreateObject(NULL, - STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + ObCreateObject(KernelMode, ObDirectoryType, + &ObjectAttributes, + KernelMode, + NULL, + sizeof(DIRECTORY_OBJECT), + 0, + 0, NULL); ObpCreateTypeObject(ObDirectoryType); @@ -447,10 +455,14 @@ ObpCreateTypeObject(POBJECT_TYPE ObjectType) OBJ_PERMANENT, NULL, NULL); - Status = ObRosCreateObject(NULL, - STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + Status = ObCreateObject(KernelMode, ObTypeObjectType, + &ObjectAttributes, + KernelMode, + NULL, + sizeof(TYPE_OBJECT), + 0, + 0, (PVOID*)&TypeObject); if (NT_SUCCESS(Status)) { diff --git a/reactos/ntoskrnl/ob/object.c b/reactos/ntoskrnl/ob/object.c index 3cf417ed2b9..8e7c4302527 100644 --- a/reactos/ntoskrnl/ob/object.c +++ b/reactos/ntoskrnl/ob/object.c @@ -1,4 +1,4 @@ -/* $Id: object.c,v 1.68 2003/09/25 05:12:24 vizzini Exp $ +/* $Id: object.c,v 1.69 2003/09/25 20:07:46 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -40,46 +40,6 @@ POBJECT_HEADER BODY_TO_HEADER(PVOID body) } -/********************************************************************** - * NAME PRIVATE - * ObInitializeObject - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - */ -VOID ObInitializeObject(POBJECT_HEADER ObjectHeader, - PHANDLE Handle, - ACCESS_MASK DesiredAccess, - POBJECT_TYPE Type, - POBJECT_ATTRIBUTES ObjectAttributes) -{ - ObjectHeader->HandleCount = 0; - ObjectHeader->RefCount = 1; - ObjectHeader->ObjectType = Type; - if (ObjectAttributes != NULL && - ObjectAttributes->Attributes & OBJ_PERMANENT) - { - ObjectHeader->Permanent = TRUE; - } - else - { - ObjectHeader->Permanent = FALSE; - } - RtlInitUnicodeString(&(ObjectHeader->Name),NULL); - if (Handle != NULL) - { - ObCreateHandle(PsGetCurrentProcess(), - HEADER_TO_BODY(ObjectHeader), - DesiredAccess, - ObjectAttributes && (ObjectAttributes->Attributes & OBJ_INHERIT) ? TRUE : FALSE, - Handle); - } -} - - /********************************************************************** * NAME PRIVATE * ObFindObject@16 @@ -351,21 +311,26 @@ ObQueryNameString (IN PVOID Object, /********************************************************************** * NAME EXPORTED - * ObRosCreateObject@20 + * ObCreateObject@36 * * DESCRIPTION * * ARGUMENTS * - * NOTE - * Internal ReactOS function * RETURN VALUE + * Status + * + * @implemented */ NTSTATUS STDCALL -ObRosCreateObject (OUT PHANDLE Handle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, +ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, IN POBJECT_TYPE Type, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN OUT PVOID ParseContext OPTIONAL, + IN ULONG ObjectSize, + IN ULONG PagedPoolCharge OPTIONAL, + IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object) { PVOID Parent = NULL; @@ -378,7 +343,7 @@ ObRosCreateObject (OUT PHANDLE Handle, assert_irql(APC_LEVEL); - DPRINT("ObRosCreateObject(Handle %x, ObjectAttributes %x, Type %x)\n", + DPRINT("ObCreateObject(Handle %x, ObjectAttributes %x, Type %x)\n", Handle, ObjectAttributes, Type); if (ObjectAttributes != NULL && @@ -400,17 +365,37 @@ ObRosCreateObject (OUT PHANDLE Handle, RtlInitUnicodeString(&RemainingPath, NULL); } - RtlMapGenericMask(&DesiredAccess, - Type->Mapping); - Header = (POBJECT_HEADER)ExAllocatePoolWithTag(NonPagedPool, - OBJECT_ALLOC_SIZE(Type), + OBJECT_ALLOC_SIZE(ObjectSize), Type->Tag); - ObInitializeObject(Header, - NULL, - DesiredAccess, - Type, - ObjectAttributes); + if (Header == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + /* Initialize the object header */ + Header->HandleCount = 0; + Header->RefCount = 1; + Header->ObjectType = Type; + if (ObjectAttributes != NULL && + ObjectAttributes->Attributes & OBJ_PERMANENT) + { + Header->Permanent = TRUE; + } + else + { + Header->Permanent = FALSE; + } + + if (ObjectAttributes != NULL && + ObjectAttributes->Attributes & OBJ_INHERIT) + { + Header->Inherit = TRUE; + } + else + { + Header->Inherit = FALSE; + } + + RtlInitUnicodeString(&(Header->Name),NULL); if (Parent != NULL) { @@ -463,44 +448,9 @@ ObRosCreateObject (OUT PHANDLE Handle, *Object = HEADER_TO_BODY(Header); } - if (Handle != NULL) - { - ObCreateHandle(PsGetCurrentProcess(), - *Object, - DesiredAccess, - ObjectAttributes && (ObjectAttributes->Attributes & OBJ_INHERIT) ? TRUE : FALSE, - Handle); - } - return(STATUS_SUCCESS); } -/********************************************************************** - * NAME EXPORTED - * ObCreateObject@36 - * - * DESCRIPTION - * - * ARGUMENTS - * - * RETURN VALUE - * - * @unimplemented - */ -NTSTATUS STDCALL -ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, - IN POBJECT_TYPE ObjectType, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN KPROCESSOR_MODE AccessMode, - IN OUT PVOID ParseContext OPTIONAL, - IN ULONG ObjectSize, - IN ULONG PagedPoolCharge OPTIONAL, - IN ULONG NonPagedPoolCharge OPTIONAL, - OUT PVOID *Object) -{ - UNIMPLEMENTED - return STATUS_NOT_IMPLEMENTED; -} /* * @implemented diff --git a/reactos/ntoskrnl/ob/symlink.c b/reactos/ntoskrnl/ob/symlink.c index 5dd49f21566..969fdd286a9 100644 --- a/reactos/ntoskrnl/ob/symlink.c +++ b/reactos/ntoskrnl/ob/symlink.c @@ -1,4 +1,4 @@ -/* $Id: symlink.c,v 1.3 2003/09/03 15:12:16 ekohl Exp $ +/* $Id: symlink.c,v 1.4 2003/09/25 20:07:46 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -228,16 +228,32 @@ NtCreateSymbolicLinkObject(OUT PHANDLE SymbolicLinkHandle, ObjectAttributes, DeviceName); - Status = ObRosCreateObject(SymbolicLinkHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), ObSymbolicLinkType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(SYMLNK_OBJECT), + 0, + 0, (PVOID*)&SymbolicLink); if (!NT_SUCCESS(Status)) { return(Status); } + Status = ObInsertObject ((PVOID)SymbolicLink, + NULL, + DesiredAccess, + 0, + NULL, + SymbolicLinkHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject (SymbolicLink); + return Status; + } + SymbolicLink->TargetName.Length = 0; SymbolicLink->TargetName.MaximumLength = ((wcslen(DeviceName->Buffer) + 1) * sizeof(WCHAR)); diff --git a/reactos/ntoskrnl/ps/create.c b/reactos/ntoskrnl/ps/create.c index 9f4d3959fb5..846dc160409 100644 --- a/reactos/ntoskrnl/ps/create.c +++ b/reactos/ntoskrnl/ps/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.66 2003/09/14 10:50:29 hbirr Exp $ +/* $Id: create.c,v 1.67 2003/09/25 20:08:36 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -370,16 +370,32 @@ PsInitializeThread(HANDLE ProcessHandle, /* * Create and initialize thread */ - Status = ObRosCreateObject(ThreadHandle, - DesiredAccess, - ThreadAttributes, + Status = ObCreateObject(UserMode, PsThreadType, + ThreadAttributes, + UserMode, + NULL, + sizeof(ETHREAD), + 0, + 0, (PVOID*)&Thread); if (!NT_SUCCESS(Status)) { return(Status); } + Status = ObInsertObject ((PVOID)Thread, + NULL, + DesiredAccess, + 0, + NULL, + ThreadHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject (Thread); + return Status; + } + DPRINT("Thread = %x\n",Thread); PiNrThreads++; diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index 49e76b32269..883660e6133 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.115 2003/09/14 10:52:33 hbirr Exp $ +/* $Id: process.c,v 1.116 2003/09/25 20:08:36 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -269,10 +269,14 @@ PsInitProcessManagment(VOID) /* * Initialize the system process */ - Status = ObRosCreateObject(NULL, - PROCESS_ALL_ACCESS, - NULL, + Status = ObCreateObject(KernelMode, PsProcessType, + NULL, + KernelMode, + NULL, + sizeof(EPROCESS), + 0, + 0, (PVOID*)&PsInitialSystemProcess); if (!NT_SUCCESS(Status)) { @@ -593,18 +597,36 @@ NtCreateProcess(OUT PHANDLE ProcessHandle, return(Status); } - Status = ObRosCreateObject(ProcessHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), PsProcessType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(EPROCESS), + 0, + 0, (PVOID*)&Process); if (!NT_SUCCESS(Status)) { ObDereferenceObject(ParentProcess); - DPRINT("ObRosCreateObject() = %x\n",Status); + DPRINT("ObCreateObject() = %x\n",Status); return(Status); } + Status = ObInsertObject ((PVOID)Process, + NULL, + DesiredAccess, + 0, + NULL, + ProcessHandle); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject (Process); + ObDereferenceObject (ParentProcess); + DPRINT("ObInsertObject() = %x\n",Status); + return Status; + } + KeInitializeDispatcherHeader(&Process->Pcb.DispatcherHeader, InternalProcessType, sizeof(EPROCESS), diff --git a/reactos/ntoskrnl/se/token.c b/reactos/ntoskrnl/se/token.c index 13a701439c9..15486f68d15 100644 --- a/reactos/ntoskrnl/se/token.c +++ b/reactos/ntoskrnl/se/token.c @@ -1,4 +1,4 @@ -/* $Id: token.c,v 1.26 2003/07/11 01:23:16 royce Exp $ +/* $Id: token.c,v 1.27 2003/09/25 20:09:11 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -145,14 +145,18 @@ SepDuplicateToken(PACCESS_TOKEN Token, PACCESS_TOKEN AccessToken; - Status = ObRosCreateObject(0, - TOKEN_ALL_ACCESS, - ObjectAttributes, + Status = ObCreateObject(PreviousMode, SepTokenObjectType, + ObjectAttributes, + PreviousMode, + NULL, + sizeof(ACCESS_TOKEN), + 0, + 0, (PVOID*)&AccessToken); if (!NT_SUCCESS(Status)) { - DPRINT1("ObRosCreateObject() failed (Status %lx)\n"); + DPRINT1("ObCreateObject() failed (Status %lx)\n"); return(Status); } @@ -1061,11 +1065,19 @@ SepCreateSystemProcessToken(struct _EPROCESS* Process) /* * Initialize the token */ - Status = ObRosCreateObject(NULL, - TOKEN_ALL_ACCESS, - NULL, - SepTokenObjectType, - (PVOID*)&AccessToken); + Status = ObCreateObject(KernelMode, + SepTokenObjectType, + NULL, + KernelMode, + NULL, + sizeof(ACCESS_TOKEN), + 0, + 0, + (PVOID*)&AccessToken); + if (!NT_SUCCESS(Status)) + { + return(Status); + } Status = NtAllocateLocallyUniqueId(&AccessToken->TokenId); if (!NT_SUCCESS(Status)) @@ -1277,17 +1289,34 @@ NtCreateToken(OUT PHANDLE UnsafeTokenHandle, if (!NT_SUCCESS(Status)) return(Status); - Status = ObRosCreateObject(&TokenHandle, - DesiredAccess, - ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), SepTokenObjectType, + ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(ACCESS_TOKEN), + 0, + 0, (PVOID*)&AccessToken); if (!NT_SUCCESS(Status)) { - DPRINT1("ObRosCreateObject() failed (Status %lx)\n"); + DPRINT1("ObCreateObject() failed (Status %lx)\n"); return(Status); } + Status = ObInsertObject ((PVOID)AccessToken, + NULL, + DesiredAccess, + 0, + NULL, + &TokenHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ObInsertObject() failed (Status %lx)\n"); + ObDereferenceObject (AccessToken); + return Status; + } + RtlCopyLuid(&AccessToken->TokenSource.SourceIdentifier, &TokenSource->SourceIdentifier); memcpy(AccessToken->TokenSource.SourceName, @@ -1309,7 +1338,7 @@ NtCreateToken(OUT PHANDLE UnsafeTokenHandle, /* * Normally we would just point these members into the variable information - * area; however, our ObRosCreateObject() call can't allocate a variable information + * area; however, our ObCreateObject() call can't allocate a variable information * area, so we allocate them seperately and provide a destroy function. */ diff --git a/reactos/subsys/win32k/ntuser/winsta.c b/reactos/subsys/win32k/ntuser/winsta.c index 2dcf3a146c6..755c8e62677 100644 --- a/reactos/subsys/win32k/ntuser/winsta.c +++ b/reactos/subsys/win32k/ntuser/winsta.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: winsta.c,v 1.35 2003/09/24 18:39:34 weiden Exp $ +/* $Id: winsta.c,v 1.36 2003/09/25 20:09:56 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -332,10 +332,14 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName, DPRINT("Creating window station (%wZ)\n", &WindowStationName); - Status = ObRosCreateObject(&WinSta, - STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), ExWindowStationObjectType, + &ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(WINSTATION_OBJECT), + 0, + 0, (PVOID*)&WinStaObject); if (!NT_SUCCESS(Status)) { @@ -344,6 +348,20 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName, return (HWINSTA)0; } + Status = ObInsertObject ((PVOID)WinStaObject, + NULL, + STANDARD_RIGHTS_REQUIRED, + 0, + NULL, + &WinSta); + if (!NT_SUCCESS(Status)) + { + DPRINT("Failed creating window station (%wZ)\n", &WindowStationName); + SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); + ObDereferenceObject(WinStaObject); + return (HWINSTA)0; + } + WinStaObject->HandleTable = ObmCreateHandleTable(); if (!WinStaObject->HandleTable) { @@ -674,10 +692,14 @@ NtUserCreateDesktop(PUNICODE_STRING lpszDesktopName, DPRINT("Status for open operation (0x%X)\n", Status); - Status = ObRosCreateObject(&Desktop, - STANDARD_RIGHTS_REQUIRED, - &ObjectAttributes, + Status = ObCreateObject(ExGetPreviousMode(), ExDesktopObjectType, + &ObjectAttributes, + ExGetPreviousMode(), + NULL, + sizeof(DESKTOP_OBJECT), + 0, + 0, (PVOID*)&DesktopObject); if (!NT_SUCCESS(Status)) { @@ -685,7 +707,7 @@ NtUserCreateDesktop(PUNICODE_STRING lpszDesktopName, SetLastNtError(STATUS_UNSUCCESSFUL); return((HDESK)0); } - + /* Initialize some local (to win32k) desktop state. */ DesktopObject->ActiveMessageQueue = NULL; DesktopObject->DesktopWindow = @@ -693,6 +715,20 @@ NtUserCreateDesktop(PUNICODE_STRING lpszDesktopName, DesktopWindowClass, 640, 480); + Status = ObInsertObject ((PVOID)DesktopObject, + NULL, + STANDARD_RIGHTS_REQUIRED, + 0, + NULL, + &Desktop); + ObDereferenceObject(DesktopObject); + if (!NT_SUCCESS(Status)) + { + DPRINT("Failed to create desktop handle\n"); + SetLastNtError(STATUS_UNSUCCESSFUL); + return((HDESK)0); + } + return((HDESK)Desktop); }