Author: janderwald
Date: Wed Feb 18 14:05:33 2009
New Revision: 39668
URL:
http://svn.reactos.org/svn/reactos?rev=39668&view=rev
Log:
- Fix implementation of KsAddObjectCreateItemToDeviceHeader
- Hackplement KsAllocateObjectCreateItem
- Fix implementation of KsAllocateObjectHeader and store the result either in the passed
irp or device header
- Implement Reading / Writing / DeviceIoControl / Flush / QuerySecurity / SetSecurity
operation using the object file header
- Implement KsSynchronousIoControlDevice function
Modified:
trunk/reactos/drivers/ksfilter/ks/irp.c
trunk/reactos/drivers/ksfilter/ks/kstypes.h
trunk/reactos/drivers/ksfilter/ks/misc.c
trunk/reactos/drivers/ksfilter/ks/priv.h
trunk/reactos/drivers/ksfilter/ks/topology.c
Modified: trunk/reactos/drivers/ksfilter/ks/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/irp.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] Wed Feb 18 14:05:33 2009
@@ -61,98 +61,118 @@
IN PSECURITY_DESCRIPTOR SecurityDescriptor)
{
PKSIDEVICE_HEADER Header;
- PKSOBJECT_CREATE_ITEM ItemList;
- PKSIOBJECT_HEADER ObjectList;
+ ULONG FreeIndex, Index;
Header = (PKSIDEVICE_HEADER)DevHeader;
+ DPRINT1("KsAddObjectCreateItemToDeviceHeader entered\n");
+
+ /* check if a device header has been provided */
if (!DevHeader)
return STATUS_INVALID_PARAMETER_1;
+ /* check if a create item has been provided */
if (!Create)
return STATUS_INVALID_PARAMETER_2;
+ /* check if a object class has been provided */
if (!ObjectClass)
return STATUS_INVALID_PARAMETER_4;
- if (Header->FreeIndex >= Header->MaxItems &&
Header->ItemsListProvided)
- return STATUS_ALLOTTED_SPACE_EXCEEDED;
-
- if (Header->FreeIndex >= Header->MaxItems)
- {
- ItemList = ExAllocatePoolWithTag(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM) *
(Header->MaxItems + 1), TAG('H','D','S','K'));
- if (!ItemList)
+ FreeIndex = (ULONG)-1;
+ /* now scan the list and check for a free item */
+ for(Index = 0; Index < Header->MaxItems; Index++)
+ {
+ if (!Header->ItemList[Index].bCreated)
+ {
+ if (FreeIndex == (ULONG)-1)
+ FreeIndex = Index;
+
+ continue;
+ }
+ else if (!wcsicmp(ObjectClass,
Header->ItemList[Index].CreateItem.ObjectClass.Buffer))
+ {
+ /* the same object class already exists */
+ return STATUS_OBJECT_NAME_COLLISION;
+ }
+ }
+ /* found a free index */
+ if (FreeIndex == (ULONG)-1)
+ {
+ /* allocate a new device entry */
+ PDEVICE_ITEM Item = ExAllocatePoolWithTag(NonPagedPool, sizeof(DEVICE_ITEM) *
(Header->MaxItems + 1), TAG_DEVICE_HEADER);
+ if (!Item)
return STATUS_INSUFFICIENT_RESOURCES;
- ObjectList = ExAllocatePoolWithTag(PagedPool, sizeof(KSIOBJECT_HEADER) *
(Header->MaxItems + 1), TAG('H','D','S','K'));
- if (!ObjectList)
- {
- ExFreePoolWithTag(ItemList,
TAG('H','D','S','K'));
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- RtlMoveMemory(ItemList, Header->ItemsList, Header->MaxItems *
sizeof(KSOBJECT_CREATE_ITEM));
- ExFreePoolWithTag(Header->ItemsList,
TAG('H','D','S','K'));
-
- RtlMoveMemory(ObjectList, Header->ObjectList, Header->MaxItems *
sizeof(KSIOBJECT_HEADER));
- ExFreePoolWithTag(Header->ObjectList,
TAG('H','D','S','K'));
-
+ RtlMoveMemory(Item, Header->ItemList, Header->MaxItems *
sizeof(DEVICE_ITEM));
+ ExFreePoolWithTag(Header->ItemList, TAG_DEVICE_HEADER);
+
+ Header->ItemList = Item;
+ FreeIndex = Header->MaxItems;
Header->MaxItems++;
- Header->ItemsList = ItemList;
- }
-
- if (Header->FreeIndex < Header->MaxItems)
- {
- Header->ItemsList[Header->FreeIndex].Context = Context;
- Header->ItemsList[Header->FreeIndex].Create = Create;
- Header->ItemsList[Header->FreeIndex].Flags = 0;
- RtlInitUnicodeString(&Header->ItemsList[Header->FreeIndex].ObjectClass,
ObjectClass);
- Header->ItemsList[Header->FreeIndex].SecurityDescriptor =
SecurityDescriptor;
-
- Header->FreeIndex++;
- return STATUS_SUCCESS;
- }
-
- return STATUS_ALLOTTED_SPACE_EXCEEDED;
+ }
+
+ /* store the new item */
+ Header->ItemList[FreeIndex].bCreated = TRUE;
+ Header->ItemList[FreeIndex].CreateItem.Create = Create;
+ Header->ItemList[FreeIndex].CreateItem.Context = Context;
+ RtlInitUnicodeString(&Header->ItemList[FreeIndex].CreateItem.ObjectClass,
ObjectClass);
+ Header->ItemList[FreeIndex].CreateItem.SecurityDescriptor = SecurityDescriptor;
+ Header->ItemList[FreeIndex].CreateItem.Flags = 0;
+ return STATUS_SUCCESS;
}
/*
@implemented
*/
-KSDDKAPI NTSTATUS NTAPI
+KSDDKAPI
+NTSTATUS
+NTAPI
KsAllocateDeviceHeader(
OUT KSDEVICE_HEADER* OutHeader,
IN ULONG ItemsCount,
IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL)
{
+ ULONG Index = 0;
PKSIDEVICE_HEADER Header;
if (!OutHeader)
return STATUS_INVALID_PARAMETER;
- Header = ExAllocatePoolWithTag(PagedPool, sizeof(KSIDEVICE_HEADER),
TAG('H','D','S','K'));
-
+ /* allocate a device header */
+ Header = ExAllocatePoolWithTag(PagedPool, sizeof(KSIDEVICE_HEADER),
TAG_DEVICE_HEADER);
+
+ /* check for success */
if (!Header)
return STATUS_INSUFFICIENT_RESOURCES;
+ /* clear all memory */
RtlZeroMemory(Header, sizeof(KSIDEVICE_HEADER));
- if (ItemsCount)
- {
- Header->ObjectList = ExAllocatePoolWithTag(PagedPool, sizeof(KSIOBJECT_HEADER)
* ItemsCount, TAG('H','D','S','K'));
- if (!Header->ObjectList)
+ /* initialize spin lock */
+ KeInitializeSpinLock(&Header->ItemListLock);
+
+ /* are there any create items provided */
+ if (ItemsCount && ItemsList)
+ {
+ /* allocate space for device item list */
+ Header->ItemList = ExAllocatePoolWithTag(NonPagedPool, sizeof(DEVICE_ITEM) *
ItemsCount, TAG_DEVICE_HEADER);
+ if (!Header->ItemList)
{
- ExFreePoolWithTag(Header,
TAG('H','D','S','K'));
+ ExFreePoolWithTag(Header, TAG_DEVICE_HEADER);
return STATUS_INSUFFICIENT_RESOURCES;
}
- RtlZeroMemory(Header->ObjectList, sizeof(KSIOBJECT_HEADER) * ItemsCount);
- }
-
- Header->MaxItems = ItemsCount;
- Header->FreeIndex = 0;
- Header->ItemsList = ItemsList;
- Header->ItemsListProvided = (ItemsList != NULL) ? TRUE : FALSE;
-
+ RtlZeroMemory(Header->ItemList, sizeof(DEVICE_ITEM) * ItemsCount);
+
+ for(Index = 0; Index < ItemsCount; Index++)
+ {
+ /* copy provided create items */
+ RtlMoveMemory(&Header->ItemList[Index], &ItemsList[Index],
sizeof(KSOBJECT_CREATE_ITEM));
+ }
+ Header->MaxItems = ItemsCount;
+ }
+
+ /* store result */
*OutHeader = Header;
return STATUS_SUCCESS;
@@ -185,25 +205,31 @@
//FIXME
//handle ItemFreeCallback
//
-
- UNIMPLEMENTED
- return STATUS_UNSUCCESSFUL;
-}
-
-
-/*
- @unimplemented
-*/
-KSDDKAPI VOID NTAPI
+ if (AllocateEntry && ItemFreeCallback)
+ DPRINT1("Ignoring ItemFreeCallback\n");
+
+ return KsAddObjectCreateItemToDeviceHeader(DevHeader, CreateItem->Create,
CreateItem->Context, CreateItem->ObjectClass.Buffer,
CreateItem->SecurityDescriptor);
+}
+
+
+/*
+ @implemented
+*/
+KSDDKAPI
+VOID
+NTAPI
KsFreeDeviceHeader(
- IN KSDEVICE_HEADER Header)
-{
- if (!Header)
+ IN KSDEVICE_HEADER DevHeader)
+{
+ PKSIDEVICE_HEADER Header;
+
+ Header = (PKSIDEVICE_HEADER)DevHeader;
+
+ if (!DevHeader)
return;
- /* TODO: Free content first */
-
- ExFreePoolWithTag(Header, TAG('H','D','S','K'));
+ ExFreePoolWithTag(Header->ItemList, TAG_DEVICE_HEADER);
+ ExFreePoolWithTag(Header, TAG_DEVICE_HEADER);
}
/*
@@ -239,8 +265,11 @@
IN PIRP Irp,
IN KSDISPATCH_TABLE* Table)
{
+ PIO_STACK_LOCATION IoStack;
+ PDEVICE_EXTENSION DeviceExtension;
PKSIDEVICE_HEADER DeviceHeader;
- ULONG Index;
+ PKSIOBJECT_HEADER ObjectHeader;
+ WCHAR ObjectClass[50];
if (!Header)
return STATUS_INVALID_PARAMETER_1;
@@ -248,14 +277,75 @@
if (!Irp)
return STATUS_INVALID_PARAMETER_4;
- DeviceHeader = (PKSIDEVICE_HEADER)Irp->Tail.Overlay.DriverContext[3];
- Index = (ULONG)Irp->Tail.Overlay.DriverContext[2];
-
- RtlCopyMemory(&DeviceHeader->ObjectList[Index].DispatchTable, Table,
sizeof(KSDISPATCH_TABLE));
- DeviceHeader->ObjectList[Index].CreateItem = ItemsList;
- DeviceHeader->ObjectList[Index].Initialized = TRUE;
-
- *Header = &DeviceHeader->ObjectList[Index];
+ if (!Table)
+ return STATUS_INVALID_PARAMETER_5;
+
+ /* get current stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+ /* get device extension */
+ DeviceExtension = (PDEVICE_EXTENSION)IoStack->DeviceObject->DeviceExtension;
+ /* get device header */
+ DeviceHeader = DeviceExtension->DeviceHeader;
+
+ ObjectClass[0] = L'\0';
+ /* check for an file object */
+ if (IoStack->FileObject != NULL)
+ {
+ /* validate the file name */
+ if (IoStack->FileObject->FileName.Length >= 38)
+ {
+ RtlMoveMemory(ObjectClass, IoStack->FileObject->FileName.Buffer, 38 *
sizeof(WCHAR));
+ ObjectClass[38] = L'\0';
+ DPRINT1("ObjectClass %S\n", ObjectClass);
+ }
+ }
+ /* allocate the object header */
+ ObjectHeader = ExAllocatePoolWithTag(NonPagedPool, sizeof(KSIOBJECT_HEADER),
TAG_DEVICE_HEADER);
+ if (!ObjectHeader)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* initialize object header */
+ RtlZeroMemory(ObjectHeader, sizeof(KSIOBJECT_HEADER));
+
+ /* do we have a name */
+ if (ObjectClass[0])
+ {
+ ObjectHeader->ObjectClass = ExAllocatePoolWithTag(NonPagedPool, 40 *
sizeof(WCHAR), TAG_DEVICE_HEADER);
+ if (ObjectHeader->ObjectClass)
+ {
+ wcscpy(ObjectHeader->ObjectClass, ObjectClass);
+ }
+ }
+
+ /* copy dispatch table */
+ RtlCopyMemory(&ObjectHeader->DispatchTable, Table, sizeof(KSDISPATCH_TABLE));
+ /* store create items */
+ if (ItemsCount && ItemsList)
+ {
+ ObjectHeader->ItemCount = ItemsCount;
+ ObjectHeader->CreateItem = ItemsList;
+ }
+
+ /* was the request for a pin/clock/node */
+ if (IoStack->FileObject)
+ {
+ /* store the object in the file object */
+ ASSERT(IoStack->FileObject->FsContext == NULL);
+ IoStack->FileObject->FsContext = ObjectHeader;
+ }
+ else
+ {
+ /* the object header is for device */
+ ASSERT(DeviceHeader->DeviceIndex < DeviceHeader->MaxItems);
+ DeviceHeader->ItemList[DeviceHeader->DeviceIndex].ObjectHeader =
ObjectHeader;
+ }
+
+ /* store result */
+ *Header = ObjectHeader;
+
+
+ DPRINT1("KsAllocateObjectHeader ObjectClass %S FileObject %p, ObjectHeader
%p\n", ObjectClass, IoStack->FileObject, ObjectHeader);
+
return STATUS_SUCCESS;
}
@@ -263,15 +353,14 @@
/*
@unimplemented
*/
-KSDDKAPI VOID NTAPI
+KSDDKAPI
+VOID
+NTAPI
KsFreeObjectHeader(
IN PVOID Header)
{
- ExFreePoolWithTag(Header, TAG('H','O','S','K'));
-
- /* TODO */
-
- UNIMPLEMENTED;
+
+
}
/*
@@ -568,33 +657,34 @@
PDEVICE_EXTENSION DeviceExtension;
PKSIDEVICE_HEADER DeviceHeader;
ULONG Index;
- NTSTATUS Status;
-
+ NTSTATUS Status = STATUS_SUCCESS;
+ KIRQL OldLevel;
+
+ DPRINT1("KS / CREATE\n");
+ /* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
-
+ /* get device extension */
DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ /* get device header */
DeviceHeader = DeviceExtension->DeviceHeader;
- DPRINT1("KS / Create\n");
-
- /* first call all create handlers */
- for(Index = 0; Index < DeviceHeader->FreeIndex; Index++)
- {
- KSCREATE_ITEM_IRP_STORAGE(Irp) = &DeviceHeader->ItemsList[Index];
-
- Irp->Tail.Overlay.DriverContext[3] = (PVOID)DeviceHeader;
- Irp->Tail.Overlay.DriverContext[2] = (PVOID)Index;
-
- DeviceHeader->ObjectList[Index].Initialized = FALSE;
- Status = DeviceHeader->ItemsList[Index].Create(DeviceObject, Irp);
- if (!NT_SUCCESS(Status))
+ /* acquire list lock */
+ KeAcquireSpinLock(&DeviceHeader->ItemListLock, &OldLevel);
+ /* loop all device items */
+ for(Index = 0; Index < DeviceHeader->MaxItems; Index++)
+ {
+ if (DeviceHeader->ItemList[Index].bCreated &&
DeviceHeader->ItemList[Index].ObjectHeader == NULL)
{
- DeviceHeader->ObjectList[Index].Initialized = FALSE;
+ DeviceHeader->DeviceIndex = Index;
+ /* set object create item */
+ KSCREATE_ITEM_IRP_STORAGE(Irp) =
&DeviceHeader->ItemList[Index].CreateItem;
+ Status = DeviceHeader->ItemList[Index].CreateItem.Create(DeviceObject,
Irp);
}
}
-
- return STATUS_SUCCESS;
+ /* release lock */
+ KeReleaseSpinLock(&DeviceHeader->ItemListLock, OldLevel);
+ return Status;
}
static NTAPI
@@ -604,148 +694,193 @@
IN PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
- PDEVICE_EXTENSION DeviceExtension;
- PKSIDEVICE_HEADER DeviceHeader;
- ULONG Index;
- NTSTATUS Status;
+ PKSIOBJECT_HEADER ObjectHeader;
+
+ /* get current stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
DPRINT1("KS / CLOSE\n");
+ if (IoStack->FileObject && IoStack->FileObject->FsContext)
+ {
+ ObjectHeader = (PKSIOBJECT_HEADER) IoStack->FileObject->FsContext;
+
+ KSCREATE_ITEM_IRP_STORAGE(Irp) = ObjectHeader->CreateItem;
+ return ObjectHeader->DispatchTable.Close(DeviceObject, Irp);
+ }
+ else
+ {
+ DPRINT1("Expected Object Header\n");
+ return STATUS_SUCCESS;
+ }
+}
+
+static NTAPI
+NTSTATUS
+KsDeviceControl(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PIO_STACK_LOCATION IoStack;
+ PKSIOBJECT_HEADER ObjectHeader;
+
+ /* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
- DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
- DeviceHeader = DeviceExtension->DeviceHeader;
-
- for(Index = 0; Index < DeviceHeader->FreeIndex; Index++)
- {
- if (DeviceHeader->ObjectList[Index].Initialized)
- {
- Status = DeviceHeader->ObjectList->DispatchTable.Close(DeviceObject,
Irp);
- DeviceHeader->ObjectList[Index].Initialized = FALSE;
- }
- }
-
- return STATUS_SUCCESS;
+ DPRINT1("KS / DeviceControl\n");
+ if (IoStack->FileObject && IoStack->FileObject->FsContext)
+ {
+ ObjectHeader = (PKSIOBJECT_HEADER) IoStack->FileObject->FsContext;
+
+ KSCREATE_ITEM_IRP_STORAGE(Irp) = ObjectHeader->CreateItem;
+ return ObjectHeader->DispatchTable.DeviceIoControl(DeviceObject, Irp);
+ }
+ else
+ {
+ DPRINT1("Expected Object Header\n");
+ KeBugCheckEx(0, 0, 0, 0, 0);
+ return STATUS_SUCCESS;
+ }
}
static NTAPI
NTSTATUS
-KsDeviceControl(
+KsRead(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
- PDEVICE_EXTENSION DeviceExtension;
- PKSIDEVICE_HEADER DeviceHeader;
- ULONG Index;
- NTSTATUS Status;
-
+ PKSIOBJECT_HEADER ObjectHeader;
+
+ /* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
- DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
- DeviceHeader = DeviceExtension->DeviceHeader;
-
- DPRINT1("KS / DeviceControl NumDevices %x\n", DeviceHeader->FreeIndex);
-
- for(Index = 0; Index < DeviceHeader->FreeIndex; Index++)
- {
- if (DeviceHeader->ObjectList[Index].Initialized)
- {
- DPRINT1("Calling DeviceIoControl\n");
- Status =
DeviceHeader->ObjectList->DispatchTable.DeviceIoControl(DeviceObject, Irp);
- }
- }
-
- return STATUS_SUCCESS;
+ DPRINT1("KS / Read\n");
+ if (IoStack->FileObject && IoStack->FileObject->FsContext)
+ {
+ ObjectHeader = (PKSIOBJECT_HEADER) IoStack->FileObject->FsContext;
+
+ KSCREATE_ITEM_IRP_STORAGE(Irp) = ObjectHeader->CreateItem;
+ return ObjectHeader->DispatchTable.Read(DeviceObject, Irp);
+ }
+ else
+ {
+ DPRINT1("Expected Object Header\n");
+ KeBugCheckEx(0, 0, 0, 0, 0);
+ return STATUS_SUCCESS;
+ }
}
static NTAPI
NTSTATUS
-KsRead(
+KsWrite(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
- PDEVICE_EXTENSION DeviceExtension;
- PKSIDEVICE_HEADER DeviceHeader;
- ULONG Index;
- NTSTATUS Status;
-
+ PKSIOBJECT_HEADER ObjectHeader;
+
+ /* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
- DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
- DeviceHeader = DeviceExtension->DeviceHeader;
-
- DPRINT1("KS / Read\n");
-
- for(Index = 0; Index < DeviceHeader->FreeIndex; Index++)
- {
- if (DeviceHeader->ObjectList[Index].Initialized)
- {
- Status = DeviceHeader->ObjectList->DispatchTable.Read(DeviceObject,
Irp);
- }
- }
-
- return STATUS_SUCCESS;
+ DPRINT1("KS / Write\n");
+ if (IoStack->FileObject && IoStack->FileObject->FsContext)
+ {
+ ObjectHeader = (PKSIOBJECT_HEADER) IoStack->FileObject->FsContext;
+
+ KSCREATE_ITEM_IRP_STORAGE(Irp) = ObjectHeader->CreateItem;
+ return ObjectHeader->DispatchTable.Write(DeviceObject, Irp);
+ }
+ else
+ {
+ DPRINT1("Expected Object Header\n");
+ KeBugCheckEx(0, 0, 0, 0, 0);
+ return STATUS_SUCCESS;
+ }
}
static NTAPI
NTSTATUS
-KsWrite(
+KsFlushBuffers(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
- PDEVICE_EXTENSION DeviceExtension;
- PKSIDEVICE_HEADER DeviceHeader;
- ULONG Index;
- NTSTATUS Status;
-
+ PKSIOBJECT_HEADER ObjectHeader;
+
+ /* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
- DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
- DeviceHeader = DeviceExtension->DeviceHeader;
-
- DPRINT1("KS / Write\n");
-
- for(Index = 0; Index < DeviceHeader->FreeIndex; Index++)
- {
- if (DeviceHeader->ObjectList[Index].Initialized)
- {
- Status = DeviceHeader->ObjectList->DispatchTable.Write(DeviceObject,
Irp);
- }
- }
- return STATUS_SUCCESS;
+ DPRINT1("KS / FlushBuffers\n");
+ if (IoStack->FileObject && IoStack->FileObject->FsContext)
+ {
+ ObjectHeader = (PKSIOBJECT_HEADER) IoStack->FileObject->FsContext;
+
+ KSCREATE_ITEM_IRP_STORAGE(Irp) = ObjectHeader->CreateItem;
+ return ObjectHeader->DispatchTable.Flush(DeviceObject, Irp);
+ }
+ else
+ {
+ DPRINT1("Expected Object Header\n");
+ KeBugCheckEx(0, 0, 0, 0, 0);
+ return STATUS_SUCCESS;
+ }
}
static NTAPI
NTSTATUS
-KsFlushBuffers(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- DPRINT1("KS / FlushBuffers\n");
- return STATUS_UNSUCCESSFUL;
+KsQuerySecurity(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PIO_STACK_LOCATION IoStack;
+ PKSIOBJECT_HEADER ObjectHeader;
+
+ /* get current stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ DPRINT1("KS / QuerySecurity\n");
+ if (IoStack->FileObject && IoStack->FileObject->FsContext)
+ {
+ ObjectHeader = (PKSIOBJECT_HEADER) IoStack->FileObject->FsContext;
+
+ KSCREATE_ITEM_IRP_STORAGE(Irp) = ObjectHeader->CreateItem;
+ return ObjectHeader->DispatchTable.QuerySecurity(DeviceObject, Irp);
+ }
+ else
+ {
+ DPRINT1("Expected Object Header\n");
+ KeBugCheckEx(0, 0, 0, 0, 0);
+ return STATUS_SUCCESS;
+ }
}
static NTAPI
NTSTATUS
-KsQuerySecurity(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- DPRINT1("KS / QuerySecurity\n");
- return STATUS_UNSUCCESSFUL;
-}
-
-static NTAPI
-NTSTATUS
KsSetSecurity(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
+ PIO_STACK_LOCATION IoStack;
+ PKSIOBJECT_HEADER ObjectHeader;
+
+ /* get current stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
DPRINT1("KS / SetSecurity\n");
- return STATUS_UNSUCCESSFUL;
+ if (IoStack->FileObject && IoStack->FileObject->FsContext)
+ {
+ ObjectHeader = (PKSIOBJECT_HEADER) IoStack->FileObject->FsContext;
+
+ KSCREATE_ITEM_IRP_STORAGE(Irp) = ObjectHeader->CreateItem;
+ return ObjectHeader->DispatchTable.SetSecurity(DeviceObject, Irp);
+ }
+ else
+ {
+ DPRINT1("Expected Object Header\n");
+ KeBugCheckEx(0, 0, 0, 0, 0);
+ return STATUS_SUCCESS;
+ }
}
/*
Modified: trunk/reactos/drivers/ksfilter/ks/kstypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/kstype…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/kstypes.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/kstypes.h [iso-8859-1] Wed Feb 18 14:05:33 2009
@@ -1,25 +1,34 @@
#ifndef KSTYPES_H__
#define KSTYPES_H__
+
+struct KSIDEVICE_HEADER;
typedef struct
{
KSDISPATCH_TABLE DispatchTable;
- LIST_ENTRY ListEntry;
- ACCESS_MASK AccessMask;
+ LPWSTR ObjectClass;
+ ULONG ItemCount;
PKSOBJECT_CREATE_ITEM CreateItem;
- BOOL Initialized;
}KSIOBJECT_HEADER, *PKSIOBJECT_HEADER;
typedef struct
{
- ULONG MaxItems;
- ULONG FreeIndex;
- PKSOBJECT_CREATE_ITEM ItemsList;
- PKSIOBJECT_HEADER ObjectList;
- UCHAR ItemsListProvided;
- PDEVICE_OBJECT LowerDeviceObject;
+ BOOL bCreated;
+ PKSIOBJECT_HEADER ObjectHeader;
+ KSOBJECT_CREATE_ITEM CreateItem;
+}DEVICE_ITEM, *PDEVICE_ITEM;
+
+typedef struct
+{
+ USHORT MaxItems;
+ DEVICE_ITEM *ItemList;
+
+ ULONG DeviceIndex;
+ KSPIN_LOCK ItemListLock;
+
+ PDEVICE_OBJECT NextDeviceObject;
ERESOURCE SecurityLock;
}KSIDEVICE_HEADER, *PKSIDEVICE_HEADER;
Modified: trunk/reactos/drivers/ksfilter/ks/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/misc.c…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/misc.c [iso-8859-1] Wed Feb 18 14:05:33 2009
@@ -228,9 +228,11 @@
}
/*
- @unimplemented
-*/
-KSDDKAPI NTSTATUS NTAPI
+ @implemented
+*/
+KSDDKAPI
+NTSTATUS
+NTAPI
KsSynchronousIoControlDevice(
IN PFILE_OBJECT FileObject,
IN KPROCESSOR_MODE RequestorMode,
@@ -238,11 +240,43 @@
IN PVOID InBuffer,
IN ULONG InSize,
OUT PVOID OutBuffer,
- IN ULONG OUtSize,
+ IN ULONG OutSize,
OUT PULONG BytesReturned)
{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ PDEVICE_OBJECT DeviceObject;
+ KEVENT Event;
+ PIRP Irp;
+ IO_STATUS_BLOCK IoStatusBlock;
+ PIO_STACK_LOCATION IoStack;
+ NTSTATUS Status;
+
+ /* check for valid file object */
+ if (!FileObject)
+ return STATUS_INVALID_PARAMETER;
+
+ /* get device object to send the request to */
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ if (!DeviceObject)
+ return STATUS_UNSUCCESSFUL;
+
+ /* initialize the event */
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ /* create the irp */
+ Irp = IoBuildDeviceIoControlRequest(IoControl, DeviceObject, InBuffer, InSize,
OutBuffer, OutSize, FALSE, &Event, &IoStatusBlock);
+
+ /* HACK */
+ IoStack = IoGetNextIrpStackLocation(Irp);
+ IoStack->FileObject = FileObject;
+
+ Status = IoCallDriver(DeviceObject, Irp);
+ if (Status == STATUS_PENDING)
+ {
+ KeWaitForSingleObject(&Event, Executive, RequestorMode, FALSE, NULL);
+ }
+
+ *BytesReturned = IoStatusBlock.Information;
+ return IoStatusBlock.Status;
}
Modified: trunk/reactos/drivers/ksfilter/ks/priv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/priv.h…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/priv.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/priv.h [iso-8859-1] Wed Feb 18 14:05:33 2009
@@ -1,10 +1,11 @@
#ifndef PRIV_H__
#define PRIV_H__
+#include <ntifs.h>
#include <ntddk.h>
#include <debug.h>
+#include <portcls.h>
#include <ks.h>
-#include <portcls.h>
#include <kcom.h>
#include "ksfunc.h"
@@ -12,7 +13,7 @@
#include "ksiface.h"
-
+#define TAG_DEVICE_HEADER TAG('H','D','S','K')
Modified: trunk/reactos/drivers/ksfilter/ks/topology.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/topolo…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/topology.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/topology.c [iso-8859-1] Wed Feb 18 14:05:33 2009
@@ -52,7 +52,8 @@
NULL,
IO_NO_PARAMETER_CHECKING | IO_FORCE_ACCESS_CHECK);
- ExFreePool(Name.Buffer);
+ // HACK HACK HACK HACK
+ //ExFreePool(Name.Buffer);
return Status;
}