Author: janderwald
Date: Fri Jul 31 12:10:26 2009
New Revision: 42310
URL:
http://svn.reactos.org/svn/reactos?rev=42310&view=rev
Log:
- Partly Implement KsRegisterFilterWithNoKSPins
- Implement _KsEdit
Modified:
trunk/reactos/drivers/ksfilter/ks/api.c
trunk/reactos/drivers/ksfilter/ks/bag.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] Fri Jul 31 12:10:26 2009
@@ -1848,23 +1848,6 @@
KSDDKAPI
NTSTATUS
NTAPI
-_KsEdit(
- IN KSOBJECT_BAG ObjectBag,
- IN OUT PVOID* PointerToPointerToItem,
- IN ULONG NewSize,
- IN ULONG OldSize,
- IN ULONG Tag)
-{
- UNIMPLEMENTED
- return STATUS_UNSUCCESSFUL;
-}
-
-/*
- @unimplemented
-*/
-KSDDKAPI
-NTSTATUS
-NTAPI
KsGetBusEnumIdentifier(
IN PIRP Irp)
{
@@ -2093,6 +2076,62 @@
IN KSPIN_MEDIUM* MediumList,
IN GUID* CategoryList OPTIONAL)
{
+ ULONG Size, Index;
+ NTSTATUS Status;
+ PWSTR SymbolicLinkList;
+ //PUCHAR Buffer;
+ HANDLE hKey;
+ UNICODE_STRING InterfaceString;
+ //UNICODE_STRING FilterData = RTL_CONSTANT_STRING(L"FilterData");
+
+ if (!InterfaceClassGUID || !PinCount || !PinDirection || !MediumList)
+ {
+ /* all these parameters are required */
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* calculate filter data value size */
+ Size = PinCount * sizeof(KSPIN_MEDIUM);
+ if (CategoryList)
+ {
+ /* add category list */
+ Size += PinCount * sizeof(GUID);
+ }
+
+ /* FIXME generate filter data blob */
UNIMPLEMENTED
- return STATUS_UNSUCCESSFUL;
-}
+
+ /* get symbolic link list */
+ Status = IoGetDeviceInterfaces(InterfaceClassGUID, DeviceObject,
DEVICE_INTERFACE_INCLUDE_NONACTIVE, &SymbolicLinkList);
+ if (NT_SUCCESS(Status))
+ {
+ /* initialize first symbolic link */
+ RtlInitUnicodeString(&InterfaceString, SymbolicLinkList);
+
+ /* open first device interface registry key */
+ Status = IoOpenDeviceInterfaceRegistryKey(&InterfaceString, GENERIC_WRITE,
&hKey);
+
+ if (NT_SUCCESS(Status))
+ {
+ /* write filter data */
+ //Status = ZwSetValueKey(hKey, &FilterData, 0, REG_BINARY, Buffer,
Size);
+
+ /* close the key */
+ ZwClose(hKey);
+ }
+
+ if (PinCount)
+ {
+ /* update medium cache */
+ for(Index = 0; Index < PinCount; Index++)
+ {
+ KsCacheMedium(&InterfaceString, &MediumList[Index],
PinDirection[Index]);
+ }
+ }
+
+ /* free the symbolic link list */
+ ExFreePool(SymbolicLinkList);
+ }
+
+ return Status;
+}
Modified: trunk/reactos/drivers/ksfilter/ks/bag.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/bag.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/bag.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/bag.c [iso-8859-1] Fri Jul 31 12:10:26 2009
@@ -298,5 +298,94 @@
FreeItem(Bag);
}
-
-
+/*
+ @implemented
+*/
+KSDDKAPI
+NTSTATUS
+NTAPI
+_KsEdit(
+ IN KSOBJECT_BAG ObjectBag,
+ IN OUT PVOID* PointerToPointerToItem,
+ IN ULONG NewSize,
+ IN ULONG OldSize,
+ IN ULONG Tag)
+{
+ PKSIOBJECT_BAG Bag;
+ PKSIOBJECT_BAG_ENTRY BagEntry;
+ PVOID Item;
+ NTSTATUS Status;
+
+ /* get real object bag */
+ Bag = (PKSIOBJECT_BAG)ObjectBag;
+
+ /* acquire bag mutex */
+ KeWaitForSingleObject(Bag->BagMutex, Executive, KernelMode, FALSE, NULL);
+
+
+ if (*PointerToPointerToItem)
+ {
+ /* search object bag for this entry */
+ BagEntry = KspFindObjectBagItem(&Bag->ObjectList,
*PointerToPointerToItem);
+ }
+ else
+ {
+ /* pointer to null, allocate new entry */
+ BagEntry = NULL;
+ }
+
+ if (!BagEntry || NewSize > OldSize)
+ {
+ /* entry does not exist or new entry must be allocated */
+ Item = AllocateItem(NonPagedPool, NewSize);
+
+ if (!Item)
+ {
+ /* not enough resources */
+ KeReleaseMutex(Bag->BagMutex, FALSE);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* now add the item to the object bag */
+ Status = KsAddItemToObjectBag((KSOBJECT_BAG)Bag, Item, NULL);
+ /* check for success */
+ if (!NT_SUCCESS(Status))
+ {
+ /* failed to add item */
+ FreeItem(Item);
+ KeReleaseMutex(Bag->BagMutex, FALSE);
+ return Status;
+ }
+
+ if (*PointerToPointerToItem)
+ {
+ /* object exists */
+ if (OldSize >= NewSize)
+ {
+ /* copy old contents */
+ RtlMoveMemory(Item, *PointerToPointerToItem, NewSize);
+ }
+ else
+ {
+ /* copy new contents */
+ RtlMoveMemory(Item, *PointerToPointerToItem, OldSize);
+ }
+ }
+
+ if (BagEntry)
+ {
+ /* remove old entry */
+ KsRemoveItemFromObjectBag(ObjectBag, BagEntry->Item, TRUE);
+ }
+
+ /* store item */
+ *PointerToPointerToItem = Item;
+ }
+
+ /* release bag mutex */
+ KeReleaseMutex(Bag->BagMutex, FALSE);
+
+ return STATUS_SUCCESS;
+}
+
+