Author: janderwald
Date: Wed Feb 18 19:11:59 2009
New Revision: 39673
URL:
http://svn.reactos.org/svn/reactos?rev=39673&view=rev
Log:
- Implement KsAddIrpToCancelableQueue and KsRemoveIrpFromCancelableQueue
Modified:
trunk/reactos/drivers/ksfilter/ks/irp.c
trunk/reactos/drivers/ksfilter/ks/kstypes.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 19:11:59 2009
@@ -18,9 +18,11 @@
}
/*
- @unimplemented
-*/
-KSDDKAPI VOID NTAPI
+ @implemented
+*/
+KSDDKAPI
+VOID
+NTAPI
KsAddIrpToCancelableQueue(
IN OUT PLIST_ENTRY QueueHead,
IN PKSPIN_LOCK SpinLock,
@@ -28,7 +30,26 @@
IN KSLIST_ENTRY_LOCATION ListLocation,
IN PDRIVER_CANCEL DriverCancel OPTIONAL)
{
- UNIMPLEMENTED;
+ PQUEUE_ENTRY Entry;
+
+ if (!QueueHead || !SpinLock || !Irp)
+ return;
+
+ Entry = ExAllocatePool(NonPagedPool, sizeof(QUEUE_ENTRY));
+ if (!Entry)
+ return;
+
+ ///FIXME
+ // setup cancel routine
+ //
+
+ Entry->Irp = Irp;
+
+ if (ListLocation == KsListEntryTail)
+ ExInterlockedInsertTailList(QueueHead, &Entry->Entry, SpinLock);
+ else
+ ExInterlockedInsertHeadList(QueueHead, &Entry->Entry, SpinLock);
+
}
/*
@@ -607,18 +628,60 @@
}
/*
- @unimplemented
-*/
-KSDDKAPI PIRP NTAPI
+ @implemented
+*/
+KSDDKAPI
+PIRP
+NTAPI
KsRemoveIrpFromCancelableQueue(
IN OUT PLIST_ENTRY QueueHead,
IN PKSPIN_LOCK SpinLock,
IN KSLIST_ENTRY_LOCATION ListLocation,
IN KSIRP_REMOVAL_OPERATION RemovalOperation)
{
- UNIMPLEMENTED;
- return NULL;
- /*return STATUS_UNSUCCESSFUL; */
+ PQUEUE_ENTRY Entry = NULL;
+ PIRP Irp;
+ KIRQL OldIrql;
+
+ if (!QueueHead || !SpinLock)
+ return NULL;
+
+ if (ListLocation != KsListEntryTail && ListLocation != KsListEntryHead)
+ return NULL;
+
+ if (RemovalOperation != KsAcquireOnly && RemovalOperation !=
KsAcquireAndRemove)
+ return NULL;
+
+ KeAcquireSpinLock(SpinLock, &OldIrql);
+
+ if (!IsListEmpty(QueueHead))
+ {
+ if (RemovalOperation == KsAcquireOnly)
+ {
+ if (ListLocation == KsListEntryHead)
+ Entry = (PQUEUE_ENTRY)QueueHead->Flink;
+ else
+ Entry = (PQUEUE_ENTRY)QueueHead->Blink;
+ }
+ else if (RemovalOperation == KsAcquireAndRemove)
+ {
+ if (ListLocation == KsListEntryTail)
+ Entry = (PQUEUE_ENTRY)RemoveTailList(QueueHead);
+ else
+ Entry = (PQUEUE_ENTRY)RemoveHeadList(QueueHead);
+ }
+ }
+ KeReleaseSpinLock(SpinLock, OldIrql);
+
+ if (!Entry)
+ return NULL;
+
+ Irp = Entry->Irp;
+
+ if (RemovalOperation == KsAcquireAndRemove)
+ ExFreePool(Entry);
+
+ return Irp;
}
/*
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 19:11:59 2009
@@ -39,6 +39,11 @@
}DEVICE_EXTENSION, *PDEVICE_EXTENSION;
+typedef struct
+{
+ LIST_ENTRY Entry;
+ PIRP Irp;
+}QUEUE_ENTRY, *PQUEUE_ENTRY;
#endif
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 19:11:59 2009
@@ -40,7 +40,7 @@
Status = IoCreateFile(NodeHandle,
DesiredAccess,
&ObjectAttributes,
- &IoStatusBlock,
+ &IoStatusBlock,
NULL,
0,
0,