Author: janderwald
Date: Thu Jul 30 16:20:13 2009
New Revision: 42302
URL:
http://svn.reactos.org/svn/reactos?rev=42302&view=rev
Log:
- Implement KsAcquireResetValue, KsCompletePendingRequest, KsAllocateExtraData
Modified:
trunk/reactos/drivers/ksfilter/ks/api.c
trunk/reactos/drivers/ksfilter/ks/device.c
trunk/reactos/drivers/ksfilter/ks/filter.c
trunk/reactos/drivers/ksfilter/ks/irp.c
Modified: trunk/reactos/drivers/ksfilter/ks/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/api.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/api.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/api.c [iso-8859-1] Thu Jul 30 16:20:13 2009
@@ -10,7 +10,7 @@
#include "priv.h"
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
NTSTATUS
@@ -19,8 +19,40 @@
IN PIRP Irp,
OUT KSRESET* ResetValue)
{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ PIO_STACK_LOCATION IoStack;
+ KSRESET* Value;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ /* get current irp stack */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ /* check if there is reset value provided */
+ if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KSRESET))
+ return STATUS_INVALID_PARAMETER;
+
+ if (Irp->RequestorMode == UserMode)
+ {
+ /* need to probe the buffer */
+ _SEH2_TRY
+ {
+ ProbeForRead(IoStack->Parameters.DeviceIoControl.Type3InputBuffer,
sizeof(KSRESET), sizeof(UCHAR));
+ Value = (KSRESET*)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
+ *ResetValue = *Value;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ /* Exception, get the error code */
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ }
+ else
+ {
+ Value = (KSRESET*)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
+ *ResetValue = *Value;
+ }
+
+ return Status;
}
/*
@@ -1551,10 +1583,8 @@
}
}
-
-
-/*
- @unimplemented
+/*
+ @implemented
*/
KSDDKAPI
VOID
@@ -1562,7 +1592,35 @@
KsCompletePendingRequest(
IN PIRP Irp)
{
+ PIO_STACK_LOCATION IoStack;
+
+ /* get current irp stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ /* sanity check */
+ ASSERT(Irp->IoStatus.Status != STATUS_PENDING);
+
+ if (IoStack->MajorFunction != IRP_MJ_CLOSE)
+ {
+ /* can be completed immediately */
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return;
+ }
+
+ /* did close operation fail */
+ if (!NT_SUCCESS(Irp->IoStatus.Status))
+ {
+ /* closing failed, complete irp */
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return;
+ }
+
+ /* FIXME
+ * delete object / device header
+ * remove dead pin / filter instance
+ */
UNIMPLEMENTED
+
}
/*
Modified: trunk/reactos/drivers/ksfilter/ks/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/device…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/device.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/device.c [iso-8859-1] Thu Jul 30 16:20:13 2009
@@ -597,32 +597,22 @@
/* increment create item reference count */
InterlockedIncrement(&CreateItemEntry->ReferenceCount);
}
-
- /* acquire list lock */
- IKsDevice_fnReleaseDevice((IKsDevice*)&DeviceHeader->lpVtblIKsDevice);
-
- return Status;
}
/* acquire list lock */
IKsDevice_fnReleaseDevice((IKsDevice*)&DeviceHeader->lpVtblIKsDevice);
- DPRINT1("No item found for Request %p\n",
IoStack->FileObject->FileName.Buffer);
-
- Irp->IoStatus.Information = 0;
- /* set return status */
- Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_UNSUCCESSFUL;
-
- /* release lock */
- IKsDevice_fnRelease((IKsDevice*)&DeviceHeader->lpVtblIKsDevice);
-
- Irp->IoStatus.Information = 0;
- /* set return status */
- Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_UNSUCCESSFUL;
+ if (Status != STATUS_PENDING)
+ {
+ Irp->IoStatus.Information = 0;
+ /* set return status */
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+
+ return Status;
+
+
}
/*
Modified: trunk/reactos/drivers/ksfilter/ks/filter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/filter…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/filter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/filter.c [iso-8859-1] Thu Jul 30 16:20:13 2009
@@ -430,7 +430,7 @@
Status =
This->Factory->FilterDescriptor->Dispatch->Close(&This->Filter, Irp);
}
- if (Status != STATUS_PENDING)
+ if (NT_SUCCESS(Status) && Status != STATUS_PENDING)
{
/* save the result */
Irp->IoStatus.Status = Status;
@@ -439,9 +439,6 @@
/* remove our instance from the filter factory */
This->FilterFactory->lpVtbl->RemoveFilterInstance(This->FilterFactory,
Filter);
-
- /* now release the acquired interface */
- Filter->lpVtbl->Release(Filter);
/* free object header */
KsFreeObjectHeader(This->ObjectHeader);
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] Thu Jul 30 16:20:13 2009
@@ -594,7 +594,7 @@
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
NTSTATUS
@@ -604,8 +604,60 @@
IN ULONG ExtraSize,
OUT PVOID* ExtraBuffer)
{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ PIO_STACK_LOCATION IoStack;
+ ULONG Count, Index;
+ PUCHAR Buffer, BufferOrg;
+ PKSSTREAM_HEADER Header;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ /* get current irp stack */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ /* sanity check */
+ ASSERT(IoStack->Parameters.DeviceIoControl.InputBufferLength >=
sizeof(KSSTREAM_HEADER));
+
+ /* get total length */
+ Count = IoStack->Parameters.DeviceIoControl.InputBufferLength /
sizeof(KSSTREAM_HEADER);
+
+ /* allocate buffer */
+ Buffer = BufferOrg = AllocateItem(NonPagedPool, Count * (sizeof(KSSTREAM_HEADER) +
ExtraSize));
+ if (!Buffer)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ _SEH2_TRY
+ {
+ /* get input buffer */
+ Header =
(PKSSTREAM_HEADER)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
+ for(Index = 0; Index < Count; Index++)
+ {
+ /* copy stream header */
+ RtlMoveMemory(Buffer, Header, sizeof(KSSTREAM_HEADER));
+
+ /* move to next header */
+ Header++;
+ /* increment output buffer offset */
+ Buffer += sizeof(KSSTREAM_HEADER) + ExtraSize;
+ }
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ /* Exception, get the error code */
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
+ if (!NT_SUCCESS(Status))
+ {
+ /* free buffer on exception */
+ FreeItem(Buffer);
+ return Status;
+ }
+
+ /* store result */
+ *ExtraBuffer = BufferOrg;
+
+ /* done */
+ return STATUS_SUCCESS;
}
/*