Removed incorrect Create/DuplicationNotify callbacks and replaced by a more correct Open callback which is what a windows driver would get. This is needed because of some changes I'm trying to make to get Parse routines to work properly, so I had to add two hacks for now, they will be removed within 2-3 commits

svn path=/trunk/; revision=15293
This commit is contained in:
Alex Ionescu 2005-05-15 04:56:52 +00:00
parent 63d3f7d1a8
commit 036efb7e10
36 changed files with 195 additions and 332 deletions

View file

@ -71,11 +71,20 @@ typedef NTSTATUS STDCALL_FUNC
* Callbacks used for Win32 objects... this define won't be needed after the Object Manager
* rewrite -- Alex
*/
/* TEMPORARY HACK */
typedef NTSTATUS STDCALL_FUNC
(*OBJECT_CREATE_ROUTINE)(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
typedef NTSTATUS STDCALL_FUNC
(*OBJECT_OPEN_ROUTINE)(ULONG Reason,
PVOID ObjectBody,
PEPROCESS Process,
ULONG HandleCount,
ACCESS_MASK GrantedAccess);
typedef NTSTATUS STDCALL_FUNC
(*OBJECT_PARSE_ROUTINE)(PVOID Object,
@ -93,7 +102,7 @@ typedef PVOID STDCALL_FUNC
ULONG Attributes);
typedef struct _W32_OBJECT_CALLBACK {
OBJECT_CREATE_ROUTINE WinStaCreate;
OBJECT_OPEN_ROUTINE WinStaCreate;
OBJECT_PARSE_ROUTINE WinStaParse;
OBJECT_DELETE_ROUTINE WinStaDelete;
OBJECT_FIND_ROUTINE WinStaFind;

View file

@ -489,12 +489,6 @@ CmiObjectParse(IN PVOID ParsedObject,
IN OUT PWSTR *Path,
IN ULONG Attribute);
NTSTATUS STDCALL
CmiObjectCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes);
VOID STDCALL
CmiObjectDelete(PVOID DeletedObject);

View file

@ -225,13 +225,13 @@ NtCreateKey(OUT PHANDLE KeyHandle,
if (Disposition)
*Disposition = REG_OPENED_EXISTING_KEY;
Status = ObCreateHandle(PsGetCurrentProcess(),
Status = ObpCreateHandle(PsGetCurrentProcess(),
Object,
DesiredAccess,
TRUE,
KeyHandle);
DPRINT("ObCreateHandle failed Status 0x%x\n", Status);
DPRINT("ObpCreateHandle failed Status 0x%x\n", Status);
ObDereferenceObject(Object);
RtlFreeUnicodeString(&RemainingPath);
return Status;
@ -1182,7 +1182,7 @@ NtOpenKey(OUT PHANDLE KeyHandle,
goto openkey_cleanup;
}
Status = ObCreateHandle(PsGetCurrentProcess(),
Status = ObpCreateHandle(PsGetCurrentProcess(),
Object,
DesiredAccess,
TRUE,

View file

@ -366,8 +366,6 @@ CmInitializeRegistry(VOID)
CmiKeyType->Security = CmiObjectSecurity;
CmiKeyType->QueryName = CmiObjectQueryName;
CmiKeyType->OkayToClose = NULL;
CmiKeyType->Create = CmiObjectCreate;
CmiKeyType->DuplicationNotify = NULL;
RtlInitUnicodeString(&CmiKeyType->TypeName, L"Key");
ObpCreateTypeObject (CmiKeyType);

View file

@ -263,35 +263,6 @@ CmiObjectParse(PVOID ParsedObject,
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
CmiObjectCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes)
{
PKEY_OBJECT KeyObject = ObjectBody;
PWSTR Start;
KeyObject->ParentKey = Parent;
if (RemainingPath)
{
Start = RemainingPath;
if(*Start == L'\\')
Start++;
RtlpCreateUnicodeString(&KeyObject->Name,
Start, NonPagedPool);
}
else
{
RtlInitUnicodeString(&KeyObject->Name,
NULL);
}
return STATUS_SUCCESS;
}
VOID STDCALL
CmiObjectDelete(PVOID DeletedObject)
{

View file

@ -65,9 +65,7 @@ ExpInitializeCallbacks(VOID)
ExCallbackObjectType->Parse = NULL;
ExCallbackObjectType->Security = NULL;
ExCallbackObjectType->QueryName = NULL;
ExCallbackObjectType->DuplicationNotify = NULL;
ExCallbackObjectType->OkayToClose = NULL;
ExCallbackObjectType->Create = NULL;
ExCallbackObjectType->Mapping = &ExpCallbackMapping;
ExCallbackObjectType->NonpagedPoolCharge = sizeof(_INT_CALLBACK_OBJECT);
Status = ObpCreateTypeObject(ExCallbackObjectType);

View file

@ -55,8 +55,6 @@ ExpInitializeEventImplementation(VOID)
ExEventObjectType->Security = NULL;
ExEventObjectType->QueryName = NULL;
ExEventObjectType->OkayToClose = NULL;
ExEventObjectType->Create = NULL;
ExEventObjectType->DuplicationNotify = NULL;
ObpCreateTypeObject(ExEventObjectType);
}

View file

@ -52,8 +52,6 @@ ExpInitializeEventPairImplementation(VOID)
ExEventPairObjectType->Security = NULL;
ExEventPairObjectType->QueryName = NULL;
ExEventPairObjectType->OkayToClose = NULL;
ExEventPairObjectType->Create = NULL;
ExEventPairObjectType->DuplicationNotify = NULL;
ObpCreateTypeObject(ExEventPairObjectType);
}

View file

@ -68,11 +68,10 @@ ExpInitializeMutantImplementation(VOID)
ExMutantObjectType->Close = NULL;
ExMutantObjectType->Delete = ExpDeleteMutant;
ExMutantObjectType->Parse = NULL;
ExMutantObjectType->Open = NULL;
ExMutantObjectType->Security = NULL;
ExMutantObjectType->QueryName = NULL;
ExMutantObjectType->OkayToClose = NULL;
ExMutantObjectType->Create = NULL;
ExMutantObjectType->DuplicationNotify = NULL;
ObpCreateTypeObject(ExMutantObjectType);
}

View file

@ -94,10 +94,10 @@ ExpInitializeProfileImplementation(VOID)
ExProfileObjectType->Close = NULL;
ExProfileObjectType->Delete = ExpDeleteProfile;
ExProfileObjectType->Parse = NULL;
ExProfileObjectType->Open = NULL;
ExProfileObjectType->Security = NULL;
ExProfileObjectType->QueryName = NULL;
ExProfileObjectType->OkayToClose = NULL;
ExProfileObjectType->Create = NULL;
ObpCreateTypeObject(ExProfileObjectType);
}

View file

@ -54,8 +54,6 @@ ExpInitializeSemaphoreImplementation(VOID)
ExSemaphoreObjectType->Security = NULL;
ExSemaphoreObjectType->QueryName = NULL;
ExSemaphoreObjectType->OkayToClose = NULL;
ExSemaphoreObjectType->Create = NULL;
ExSemaphoreObjectType->DuplicationNotify = NULL;
ObpCreateTypeObject(ExSemaphoreObjectType);
}

View file

@ -244,10 +244,9 @@ ExpInitializeTimerImplementation(VOID)
ExTimerType->Delete = ExpDeleteTimer;
ExTimerType->Parse = NULL;
ExTimerType->Security = NULL;
ExTimerType->Open = NULL;
ExTimerType->QueryName = NULL;
ExTimerType->OkayToClose = NULL;
ExTimerType->Create = NULL;
ExTimerType->DuplicationNotify = NULL;
ObpCreateTypeObject(ExTimerType);
/* Initialize the Wait List and Lock */

View file

@ -39,7 +39,7 @@ static GENERIC_MAPPING ExpDesktopMapping = {
DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_WRITEOBJECTS
};
OBJECT_CREATE_ROUTINE ExpWindowStationObjectCreate = NULL;
OBJECT_OPEN_ROUTINE ExpWindowStationObjectOpen = NULL;
OBJECT_PARSE_ROUTINE ExpWindowStationObjectParse = NULL;
OBJECT_DELETE_ROUTINE ExpWindowStationObjectDelete = NULL;
OBJECT_FIND_ROUTINE ExpWindowStationObjectFind = NULL;
@ -50,16 +50,18 @@ OBJECT_DELETE_ROUTINE ExpDesktopObjectDelete = NULL;
NTSTATUS
STDCALL
ExpWinStaObjectCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes)
ExpWinStaObjectOpen(OB_OPEN_REASON Reason,
PVOID ObjectBody,
PEPROCESS Process,
ULONG HandleCount,
ACCESS_MASK GrantedAccess)
{
/* Call the Registered Callback */
return ExpWindowStationObjectCreate(ObjectBody,
Parent,
RemainingPath,
ObjectAttributes);
return ExpWindowStationObjectOpen(Reason,
ObjectBody,
Process,
HandleCount,
GrantedAccess);
}
VOID
@ -101,9 +103,9 @@ ExpWinStaObjectParse(PVOID Object,
NTSTATUS
STDCALL
ExpDesktopCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes)
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes)
{
/* Call the Registered Callback */
return ExpDesktopObjectCreate(ObjectBody,
@ -135,15 +137,13 @@ ExpWin32kInit(VOID)
ExWindowStationObjectType->NonpagedPoolCharge = sizeof(WINSTATION_OBJECT);
ExWindowStationObjectType->Mapping = &ExpWindowStationMapping;
ExWindowStationObjectType->Dump = NULL;
ExWindowStationObjectType->Open = NULL;
ExWindowStationObjectType->Open = ExpWinStaObjectOpen;
ExWindowStationObjectType->Close = NULL;
ExWindowStationObjectType->Delete = ExpWinStaObjectDelete;
ExWindowStationObjectType->Parse = ExpWinStaObjectParse;
ExWindowStationObjectType->Security = NULL;
ExWindowStationObjectType->QueryName = NULL;
ExWindowStationObjectType->OkayToClose = NULL;
ExWindowStationObjectType->Create = ExpWinStaObjectCreate;
ExWindowStationObjectType->DuplicationNotify = NULL;
RtlInitUnicodeString(&ExWindowStationObjectType->TypeName, L"WindowStation");
ObpCreateTypeObject(ExWindowStationObjectType);
@ -165,8 +165,7 @@ ExpWin32kInit(VOID)
ExDesktopObjectType->Security = NULL;
ExDesktopObjectType->QueryName = NULL;
ExDesktopObjectType->OkayToClose = NULL;
ExDesktopObjectType->Create = ExpDesktopCreate;
ExDesktopObjectType->DuplicationNotify = NULL;
RtlInitUnicodeString(&ExDesktopObjectType->TypeName, L"Desktop");
ObpCreateTypeObject(ExDesktopObjectType);
}

View file

@ -16,6 +16,15 @@
struct _EPROCESS;
typedef enum _OB_OPEN_REASON
{
ObCreateHandle,
ObOpenHandle,
ObDuplicateHandle,
ObInheritHandle,
ObMaxOpenReason
} OB_OPEN_REASON;
typedef struct
{
CSHORT Type;
@ -78,12 +87,6 @@ typedef struct _OBJECT_TYPE
*/
VOID STDCALL_FUNC (*Dump)(VOID);
/*
* PURPOSE: Opens the object
* NOTE: To be defined
*/
VOID STDCALL_FUNC (*Open)(VOID);
/*
* PURPOSE: Called to close an object if OkayToClose returns true
*/
@ -136,14 +139,11 @@ typedef struct _OBJECT_TYPE
*/
VOID STDCALL_FUNC (*OkayToClose)(VOID);
NTSTATUS STDCALL_FUNC (*Create)(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
VOID STDCALL_FUNC (*DuplicationNotify)(PEPROCESS DuplicateTo,
PEPROCESS DuplicateFrom,
PVOID Object);
NTSTATUS STDCALL_FUNC (*Open)(OB_OPEN_REASON Reason,
PVOID ObjectBody,
PEPROCESS Process,
ULONG HandleCount,
ACCESS_MASK GrantedAccess);
} OBJECT_TYPE;
@ -259,7 +259,7 @@ VOID
ObInitSymbolicLinkImplementation(VOID);
NTSTATUS ObCreateHandle(struct _EPROCESS* Process,
NTSTATUS ObpCreateHandle(struct _EPROCESS* Process,
PVOID ObjectBody,
ACCESS_MASK GrantedAccess,
BOOLEAN Inherit,

View file

@ -80,13 +80,6 @@ POBJECT_TYPE EXPORTED IoDriverObjectType = NULL;
/* DECLARATIONS ***************************************************************/
NTSTATUS STDCALL
IopCreateDriver(
PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes);
VOID STDCALL
IopDeleteDriver(PVOID ObjectBody);
@ -112,8 +105,6 @@ IopInitDriverImplementation(VOID)
IoDriverObjectType->Security = NULL;
IoDriverObjectType->QueryName = NULL;
IoDriverObjectType->OkayToClose = NULL;
IoDriverObjectType->Create = IopCreateDriver;
IoDriverObjectType->DuplicationNotify = NULL;
RtlInitUnicodeString(&IoDriverObjectType->TypeName, L"Driver");
ObpCreateTypeObject(IoDriverObjectType);
@ -138,46 +129,6 @@ IopInvalidDeviceRequest(
return STATUS_INVALID_DEVICE_REQUEST;
}
NTSTATUS STDCALL
IopCreateDriver(
PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes)
{
PDRIVER_OBJECT Object = ObjectBody;
ULONG i;
DPRINT("IopCreateDriver(ObjectBody %x, Parent %x, RemainingPath %S)\n",
ObjectBody, Parent, RemainingPath);
if (RemainingPath != NULL && wcschr(RemainingPath + 1, '\\') != NULL)
return STATUS_UNSUCCESSFUL;
/* Create driver extension */
Object->DriverExtension = (PDRIVER_EXTENSION)
ExAllocatePoolWithTag(
NonPagedPool,
sizeof(DRIVER_EXTENSION),
TAG_DRIVER_EXTENSION);
if (Object->DriverExtension == NULL)
{
return STATUS_NO_MEMORY;
}
RtlZeroMemory(Object->DriverExtension, sizeof(DRIVER_EXTENSION));
Object->Type = IO_TYPE_DRIVER;
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
Object->MajorFunction[i] = IopInvalidDeviceRequest;
Object->HardwareDatabase = &IopHardwareDatabaseKey;
return STATUS_SUCCESS;
}
VOID STDCALL
IopDeleteDriver(PVOID ObjectBody)
{
@ -217,6 +168,7 @@ IopCreateDriverObject(
UNICODE_STRING DriverName;
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
ULONG i;
PWSTR Buffer = NULL;
DPRINT("IopCreateDriverObject(%p '%wZ' %x %p %x)\n",
@ -269,6 +221,27 @@ IopCreateDriverObject(
{
return Status;
}
/* Create driver extension */
Object->DriverExtension = (PDRIVER_EXTENSION)
ExAllocatePoolWithTag(
NonPagedPool,
sizeof(DRIVER_EXTENSION),
TAG_DRIVER_EXTENSION);
if (Object->DriverExtension == NULL)
{
return STATUS_NO_MEMORY;
}
RtlZeroMemory(Object->DriverExtension, sizeof(DRIVER_EXTENSION));
Object->Type = IO_TYPE_DRIVER;
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
Object->MajorFunction[i] = IopInvalidDeviceRequest;
Object->HardwareDatabase = &IopHardwareDatabaseKey;
Object->DriverStart = DriverImageStart;
Object->DriverSize = DriverImageSize;

View file

@ -222,8 +222,6 @@ IopInitIoCompletionImplementation(VOID)
ExIoCompletionType->Security = NULL;
ExIoCompletionType->QueryName = NULL;
ExIoCompletionType->OkayToClose = NULL;
ExIoCompletionType->Create = NULL;
ExIoCompletionType->DuplicationNotify = NULL;
}
NTSTATUS

View file

@ -51,7 +51,7 @@ NPAGED_LOOKASIDE_LIST IoLargeIrpLookaside;
NPAGED_LOOKASIDE_LIST IoSmallIrpLookaside;
/* INIT FUNCTIONS ************************************************************/
VOID
INIT_FUNCTION
IoInitCancelHandling(VOID)
@ -217,8 +217,6 @@ IoInit (VOID)
IoDeviceObjectType->Security = NULL;
IoDeviceObjectType->QueryName = NULL;
IoDeviceObjectType->OkayToClose = NULL;
IoDeviceObjectType->Create = NULL;
IoDeviceObjectType->DuplicationNotify = NULL;
RtlInitUnicodeString(&IoDeviceObjectType->TypeName, L"Device");
@ -246,8 +244,6 @@ IoInit (VOID)
IoFileObjectType->Security = IopSecurityFile;
IoFileObjectType->QueryName = IopQueryNameFile;
IoFileObjectType->OkayToClose = NULL;
IoFileObjectType->Create = IopCreateFile;
IoFileObjectType->DuplicationNotify = NULL;
RtlInitUnicodeString(&IoFileObjectType->TypeName, L"File");

View file

@ -89,7 +89,7 @@ LdrLoadInitialProcess(PHANDLE ProcessHandle,
L"\\SystemRoot\\system32\\smss.exe");
Status = ObCreateHandle(
Status = ObpCreateHandle(
PsGetCurrentProcess(),
PsInitialSystemProcess,
PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION,

View file

@ -62,37 +62,6 @@ LpcpVerifyCreateParameters (IN PHANDLE PortHandle,
return (STATUS_SUCCESS);
}
/**********************************************************************
* NAME
* NiCreatePort/4
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*/
NTSTATUS STDCALL
NiCreatePort (PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes)
{
if (RemainingPath == NULL)
{
return (STATUS_SUCCESS);
}
if (wcschr(RemainingPath+1, '\\') != NULL)
{
return (STATUS_UNSUCCESSFUL);
}
return (STATUS_SUCCESS);
}
/**********************************************************************
* NAME EXPORTED
* NtCreatePort/5

View file

@ -54,9 +54,8 @@ LpcpInitSystem (VOID)
LpcPortObjectType->Parse = NULL;
LpcPortObjectType->Security = NULL;
LpcPortObjectType->QueryName = NULL;
LpcPortObjectType->Open = NULL;
LpcPortObjectType->OkayToClose = NULL;
LpcPortObjectType->Create = NiCreatePort;
LpcPortObjectType->DuplicationNotify = NULL;
ObpCreateTypeObject(LpcPortObjectType);

View file

@ -2068,27 +2068,6 @@ MmpCloseSection(PVOID ObjectBody,
ObjectBody, HandleCount, ObGetObjectPointerCount(ObjectBody));
}
NTSTATUS STDCALL
MmpCreateSection(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes)
{
DPRINT("MmpCreateSection(ObjectBody %x, Parent %x, RemainingPath %S)\n",
ObjectBody, Parent, RemainingPath);
if (RemainingPath == NULL)
{
return(STATUS_SUCCESS);
}
if (wcschr(RemainingPath+1, L'\\') != NULL)
{
return(STATUS_UNSUCCESSFUL);
}
return(STATUS_SUCCESS);
}
NTSTATUS INIT_FUNCTION
MmCreatePhysicalMemorySection(VOID)
{
@ -2145,11 +2124,10 @@ MmInitSectionImplementation(VOID)
MmSectionObjectType->Close = MmpCloseSection;
MmSectionObjectType->Delete = MmpDeleteSection;
MmSectionObjectType->Parse = NULL;
MmSectionObjectType->Open = NULL;
MmSectionObjectType->Security = NULL;
MmSectionObjectType->QueryName = NULL;
MmSectionObjectType->OkayToClose = NULL;
MmSectionObjectType->Create = MmpCreateSection;
MmSectionObjectType->DuplicationNotify = NULL;
/*
* NOTE: Do not register the section object type here because

View file

@ -475,6 +475,7 @@ NtCreateDirectoryObject (OUT PHANDLE DirectoryHandle,
0,
0,
(PVOID*)&Directory);
if(NT_SUCCESS(Status))
{
Status = ObInsertObject((PVOID)Directory,

View file

@ -459,11 +459,11 @@ NtDuplicateObject (IN HANDLE SourceProcessHandle,
ObjectType->Mapping);
}
}
Status = ObCreateHandle(TargetProcess,
ObjectBody,
DesiredAccess,
InheritHandle,
&hTarget);
Status = ObpCreateHandle(TargetProcess,
ObjectBody,
DesiredAccess,
InheritHandle,
&hTarget);
ObDereferenceObject(ObjectBody);
@ -586,7 +586,7 @@ ObKillProcess(PEPROCESS Process)
NTSTATUS
ObCreateHandle(PEPROCESS Process,
ObpCreateHandle(PEPROCESS Process,
PVOID ObjectBody,
ACCESS_MASK GrantedAccess,
BOOLEAN Inherit,
@ -605,7 +605,7 @@ ObCreateHandle(PEPROCESS Process,
PAGED_CODE();
DPRINT("ObCreateHandle(Process %x, obj %x)\n",Process,ObjectBody);
DPRINT("ObpCreateHandle(Process %x, obj %x)\n",Process,ObjectBody);
ASSERT(Process);
ASSERT(ObjectBody);
@ -941,7 +941,7 @@ ObInsertObject(IN PVOID Object,
Access = DesiredAccess;
ObjectHeader = BODY_TO_HEADER(Object);
return(ObCreateHandle(PsGetCurrentProcess(),
return(ObpCreateHandle(PsGetCurrentProcess(),
Object,
Access,
ObjectHeader->Inherit,

View file

@ -159,7 +159,7 @@ ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes,
return Status;
}
Status = ObCreateHandle(PsGetCurrentProcess(),
Status = ObpCreateHandle(PsGetCurrentProcess(),
Object,
DesiredAccess,
FALSE,
@ -238,6 +238,24 @@ ObpRemoveEntryDirectory(POBJECT_HEADER Header)
KeReleaseSpinLock(&(Header->Parent->Lock),oldlvl);
}
NTSTATUS
STDCALL
ObpCreateDirectory(OB_OPEN_REASON Reason,
PVOID ObjectBody,
PEPROCESS Process,
ULONG HandleCount,
ACCESS_MASK GrantedAccess)
{
PDIRECTORY_OBJECT Directory = ObjectBody;
if (Reason == ObCreateHandle)
{
InitializeListHead(&Directory->head);
KeInitializeSpinLock(&Directory->Lock);
}
return STATUS_SUCCESS;
}
PVOID
ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
@ -350,29 +368,6 @@ ObpParseDirectory(PVOID Object,
}
NTSTATUS STDCALL
ObpCreateDirectory(PVOID ObjectBody,
PVOID Parent,
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);
}
InitializeListHead(&DirectoryObject->head);
KeInitializeSpinLock(&DirectoryObject->Lock);
return(STATUS_SUCCESS);
}
VOID INIT_FUNCTION
ObInit(VOID)
/*
@ -405,8 +400,7 @@ ObInit(VOID)
ObDirectoryType->Security = NULL;
ObDirectoryType->QueryName = NULL;
ObDirectoryType->OkayToClose = NULL;
ObDirectoryType->Create = ObpCreateDirectory;
ObDirectoryType->DuplicationNotify = NULL;
ObDirectoryType->Open = ObpCreateDirectory;
RtlInitUnicodeString(&ObDirectoryType->TypeName,
L"Directory");
@ -430,8 +424,6 @@ ObInit(VOID)
ObTypeObjectType->Security = NULL;
ObTypeObjectType->QueryName = NULL;
ObTypeObjectType->OkayToClose = NULL;
ObTypeObjectType->Create = NULL;
ObTypeObjectType->DuplicationNotify = NULL;
RtlInitUnicodeString(&ObTypeObjectType->TypeName,
L"ObjectType");

View file

@ -22,7 +22,13 @@ typedef struct _RETENTION_CHECK_PARAMS
POBJECT_HEADER ObjectHeader;
} RETENTION_CHECK_PARAMS, *PRETENTION_CHECK_PARAMS;
/* TEMPORARY HACK. DO NOT REMOVE -- Alex */
NTSTATUS
STDCALL
ExpDesktopCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
/* FUNCTIONS ************************************************************/
NTSTATUS
@ -733,6 +739,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL,
RtlInitUnicodeString(&RemainingPath, NULL);
}
DPRINT("Allocating memory\n");
Header = (POBJECT_HEADER)ExAllocatePoolWithTag(NonPagedPool,
OBJECT_ALLOC_SIZE(ObjectSize),
Type->Tag);
@ -786,14 +793,39 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL,
ObjectAttached = TRUE;
}
DPRINT("About to call Create Routine\n");
if (Header->ObjectType->Create != NULL)
{
DPRINT("Calling %x\n", Header->ObjectType->Create);
Status = Header->ObjectType->Create(HEADER_TO_BODY(Header),
Parent,
RemainingPath.Buffer,
ObjectAttributes);
if ((Header->ObjectType == IoFileObjectType) ||
(Header->ObjectType == ExDesktopObjectType) ||
(Header->ObjectType->Open != NULL))
{
DPRINT("About to call Open Routine\n");
if (Header->ObjectType == IoFileObjectType)
{
/* TEMPORARY HACK. DO NOT TOUCH -- Alex */
DPRINT("Calling IopCreateFile\n");
Status = IopCreateFile(HEADER_TO_BODY(Header),
Parent,
RemainingPath.Buffer,
ObjectAttributes);
}
else if (Header->ObjectType == ExDesktopObjectType)
{
/* TEMPORARY HACK. DO NOT TOUCH -- Alex */
DPRINT("Calling ExpDesktopCreate\n");
Status = ExpDesktopCreate(HEADER_TO_BODY(Header),
Parent,
RemainingPath.Buffer,
ObjectAttributes);
}
else if (Header->ObjectType->Open != NULL)
{
DPRINT("Calling %x\n", Header->ObjectType->Open);
Status = Header->ObjectType->Open(ObCreateHandle,
HEADER_TO_BODY(Header),
NULL,
0,
0);
}
if (!NT_SUCCESS(Status))
{
if (ObjectAttached == TRUE)
@ -810,7 +842,8 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL,
DPRINT("Create Failed\n");
return Status;
}
}
}
RtlFreeUnicodeString(&RemainingPath);
SeCaptureSubjectContext(&SubjectContext);
@ -960,7 +993,7 @@ ObOpenObjectByPointer(IN POBJECT Object,
return Status;
}
Status = ObCreateHandle(PsGetCurrentProcess(),
Status = ObpCreateHandle(PsGetCurrentProcess(),
Object,
DesiredAccess,
(BOOLEAN)(HandleAttributes & OBJ_INHERIT),

View file

@ -31,29 +31,6 @@ static GENERIC_MAPPING ObpSymbolicLinkMapping = {
/* FUNCTIONS ****************************************************************/
/**********************************************************************
* NAME INTERNAL
* ObpCreateSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURNN VALUE
* Status.
*
* REVISIONS
*/
NTSTATUS STDCALL
ObpCreateSymbolicLink(PVOID Object,
PVOID Parent,
PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes)
{
return(STATUS_SUCCESS);
}
/**********************************************************************
* NAME INTERNAL
* ObpDeleteSymbolicLink
@ -175,10 +152,9 @@ ObInitSymbolicLinkImplementation (VOID)
ObSymbolicLinkType->Delete = ObpDeleteSymbolicLink;
ObSymbolicLinkType->Parse = ObpParseSymbolicLink;
ObSymbolicLinkType->Security = NULL;
ObSymbolicLinkType->Open = NULL;
ObSymbolicLinkType->QueryName = NULL;
ObSymbolicLinkType->OkayToClose = NULL;
ObSymbolicLinkType->Create = ObpCreateSymbolicLink;
ObSymbolicLinkType->DuplicationNotify = NULL;
RtlInitUnicodeString(&ObSymbolicLinkType->TypeName,
L"SymbolicLink");

View file

@ -78,8 +78,7 @@ PsInitJobManagment ( VOID )
PsJobType->Security = NULL;
PsJobType->QueryName = NULL;
PsJobType->OkayToClose = NULL;
PsJobType->Create = NULL;
PsJobType->DuplicationNotify = NULL;
PsJobType->Open = NULL;
RtlInitUnicodeString(&PsJobType->TypeName, L"Job");

View file

@ -97,8 +97,7 @@ PsInitThreadManagment(VOID)
PsThreadType->Security = NULL;
PsThreadType->QueryName = NULL;
PsThreadType->OkayToClose = NULL;
PsThreadType->Create = NULL;
PsThreadType->DuplicationNotify = NULL;
PsThreadType->Open = NULL;
RtlInitUnicodeString(&PsThreadType->TypeName, L"Thread");
@ -149,8 +148,7 @@ PsInitProcessManagment(VOID)
PsProcessType->Security = NULL;
PsProcessType->QueryName = NULL;
PsProcessType->OkayToClose = NULL;
PsProcessType->Create = NULL;
PsProcessType->DuplicationNotify = NULL;
PsProcessType->Open = NULL;
RtlInitUnicodeString(&PsProcessType->TypeName, L"Process");

View file

@ -99,7 +99,7 @@ NtOpenProcessTokenEx(IN HANDLE ProcessHandle,
&Token);
if(NT_SUCCESS(Status))
{
Status = ObCreateHandle(PsGetCurrentProcess(),
Status = ObpCreateHandle(PsGetCurrentProcess(),
Token,
DesiredAccess,
FALSE,

View file

@ -21,7 +21,7 @@ static PW32_THREAD_CALLBACK PspWin32ThreadCallback = NULL;
static ULONG PspWin32ProcessSize = 0;
static ULONG PspWin32ThreadSize = 0;
extern OBJECT_CREATE_ROUTINE ExpWindowStationObjectCreate;
extern OBJECT_OPEN_ROUTINE ExpWindowStationObjectOpen;
extern OBJECT_PARSE_ROUTINE ExpWindowStationObjectParse;
extern OBJECT_DELETE_ROUTINE ExpWindowStationObjectDelete;
extern OBJECT_FIND_ROUTINE ExpWindowStationObjectFind;
@ -92,7 +92,7 @@ PsEstablishWin32Callouts (PW32_PROCESS_CALLBACK W32ProcessCallback,
PspWin32ProcessSize = W32ProcessSize;
PspWin32ThreadSize = W32ThreadSize;
ExpWindowStationObjectCreate = W32ObjectCallback->WinStaCreate;
ExpWindowStationObjectOpen = W32ObjectCallback->WinStaCreate;
ExpWindowStationObjectParse = W32ObjectCallback->WinStaParse;
ExpWindowStationObjectDelete = W32ObjectCallback->WinStaDelete;
ExpWindowStationObjectFind = W32ObjectCallback->WinStaFind;

View file

@ -580,8 +580,7 @@ SepInitializeTokenImplementation(VOID)
SepTokenObjectType->Security = NULL;
SepTokenObjectType->QueryName = NULL;
SepTokenObjectType->OkayToClose = NULL;
SepTokenObjectType->Create = NULL;
SepTokenObjectType->DuplicationNotify = NULL;
SepTokenObjectType->Open = NULL;
RtlInitUnicodeString(&SepTokenObjectType->TypeName, L"Token");
ObpCreateTypeObject (SepTokenObjectType);

View file

@ -25,13 +25,12 @@ InitDesktopImpl(VOID);
NTSTATUS FASTCALL
CleanupDesktopImpl(VOID);
NTSTATUS
STDCALL
NTSTATUS STDCALL
IntDesktopObjectCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
VOID STDCALL
IntDesktopObjectDelete(PVOID DeletedObject);

View file

@ -25,10 +25,11 @@ CleanupWindowStationImpl(VOID);
NTSTATUS
STDCALL
IntWinStaObjectCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
IntWinStaObjectOpen(ULONG Reason,
PVOID ObjectBody,
PEPROCESS Process,
ULONG HandleCount,
ACCESS_MASK GrantedAccess);
VOID STDCALL
IntWinStaObjectDelete(PVOID DeletedObject);

View file

@ -39,12 +39,21 @@ typedef NTSTATUS (STDCALL *PW32_THREAD_CALLBACK)(
* Callbacks used for Win32 objects... this define won't be needed after the Object Manager
* rewrite -- Alex
*/
/* TEMPORARY HACK */
typedef NTSTATUS STDCALL_FUNC
(*OBJECT_CREATE_ROUTINE)(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
typedef NTSTATUS STDCALL_FUNC
(*OBJECT_OPEN_ROUTINE)(ULONG Reason,
PVOID ObjectBody,
PEPROCESS Process,
ULONG HandleCount,
ACCESS_MASK GrantedAccess);
typedef NTSTATUS STDCALL_FUNC
(*OBJECT_PARSE_ROUTINE)(PVOID Object,
PVOID *NextObject,
@ -61,7 +70,7 @@ typedef PVOID STDCALL_FUNC
ULONG Attributes);
typedef struct _W32_OBJECT_CALLBACK {
OBJECT_CREATE_ROUTINE WinStaCreate;
OBJECT_OPEN_ROUTINE WinStaCreate;
OBJECT_PARSE_ROUTINE WinStaParse;
OBJECT_DELETE_ROUTINE WinStaDelete;
OBJECT_FIND_ROUTINE WinStaFind;
@ -309,7 +318,7 @@ DllMain (
/*
* Register Object Manager Callbacks
*/
Win32kObjectCallbacks.WinStaCreate = IntWinStaObjectCreate;
Win32kObjectCallbacks.WinStaCreate = IntWinStaObjectOpen;
Win32kObjectCallbacks.WinStaParse = IntWinStaObjectParse;
Win32kObjectCallbacks.WinStaDelete = IntWinStaObjectDelete;
Win32kObjectCallbacks.WinStaFind = IntWinStaObjectFind;

View file

@ -77,6 +77,7 @@ IntDesktopObjectCreate(PVOID ObjectBody,
PDESKTOP_OBJECT Desktop = (PDESKTOP_OBJECT)ObjectBody;
UNICODE_STRING UnicodeString;
DPRINT("Creating desktop (0x%X) Name (%S)\n", Desktop, RemainingPath);
if (RemainingPath == NULL)
{
return STATUS_SUCCESS;
@ -89,7 +90,7 @@ IntDesktopObjectCreate(PVOID ObjectBody,
RtlInitUnicodeString(&UnicodeString, (RemainingPath + 1));
DPRINT("Creating desktop (0x%X) Name (%wZ)\n", Desktop, &UnicodeString);
KeInitializeSpinLock(&Desktop->Lock);
InitializeListHead(&Desktop->ShellHookWindows);

View file

@ -84,51 +84,31 @@ CleanupWindowStationImpl(VOID)
NTSTATUS
STDCALL
IntWinStaObjectCreate(PVOID ObjectBody,
PVOID Parent,
PWSTR RemainingPath,
struct _OBJECT_ATTRIBUTES* ObjectAttributes)
IntWinStaObjectOpen(ULONG Reason,
PVOID ObjectBody,
PEPROCESS Process,
ULONG HandleCount,
ACCESS_MASK GrantedAccess)
{
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)ObjectBody;
UNICODE_STRING UnicodeString;
NTSTATUS Status;
if (RemainingPath == NULL)
{
return STATUS_SUCCESS;
}
if (wcschr((RemainingPath + 1), '\\') != NULL)
{
return STATUS_UNSUCCESSFUL;
}
RtlInitUnicodeString(&UnicodeString, (RemainingPath + 1));
DPRINT("Creating window station (0x%X) Name (%wZ)\n", WinSta, &UnicodeString);
Status = RtlCreateUnicodeString(&WinSta->Name, UnicodeString.Buffer);
if (!NT_SUCCESS(Status))
if (Reason == ObCreateHandle)
{
return Status;
}
DPRINT("Creating window station (0x%X)\n", WinSta);
KeInitializeSpinLock(&WinSta->Lock);
KeInitializeSpinLock(&WinSta->Lock);
InitializeListHead(&WinSta->DesktopListHead);
InitializeListHead(&WinSta->DesktopListHead);
WinSta->AtomTable = NULL;
WinSta->AtomTable = NULL;
Status = RtlCreateAtomTable(37, &WinSta->AtomTable);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString(&WinSta->Name);
return Status;
}
Status = RtlCreateAtomTable(37, &WinSta->AtomTable);
WinSta->SystemMenuTemplate = (HANDLE)0;
WinSta->SystemMenuTemplate = (HANDLE)0;
DPRINT("Window station successfully created. Name (%wZ)\n", &WinSta->Name);
DPRINT("Window station successfully created.\n");
}
return STATUS_SUCCESS;
}
@ -508,6 +488,8 @@ NtUserCreateWindowStation(
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return 0;
}
WindowStationObject->Name = *lpszWindowStationName;
Status = ObInsertObject(
(PVOID)WindowStationObject,
@ -519,7 +501,7 @@ NtUserCreateWindowStation(
if (!NT_SUCCESS(Status))
{
DPRINT("Failed creating window station (%wZ)\n", &WindowStationName);
DPRINT1("Failed creating window station (%wZ)\n", &WindowStationName);
ExFreePool(WindowStationName.Buffer);
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
ObDereferenceObject(WindowStationObject);
@ -575,9 +557,8 @@ NtUserCreateWindowStation(
/* FIXME: Complain more loudly? */
}
DPRINT("Window station successfully created (%wZ)\n", &WindowStationName);
DPRINT("Window station successfully created (%wZ)\n", lpszWindowStationName);
ExFreePool(WindowStationName.Buffer);
return WindowStation;
}