mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- Implement PcHandlePropertyWithTable
- Use PcHandlePropertyWithTable to handle IOCTL_KS_PROPERTY requests - Remove dead code svn path=/trunk/; revision=43223
This commit is contained in:
parent
5f9e1cd8f9
commit
3f5443deba
9 changed files with 116 additions and 507 deletions
|
@ -131,7 +131,29 @@ CPortFilterDMus::DeviceIoControl(
|
|||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
return PcPropertyHandler(Irp, m_Descriptor);
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
NTSTATUS Status;
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
|
||||
{
|
||||
DPRINT1("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Status = PcHandlePropertyWithTable(Irp, m_Descriptor->FilterPropertySetCount, m_Descriptor->FilterPropertySet, m_Descriptor);
|
||||
if (Status != STATUS_PENDING)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -89,6 +89,7 @@ CPortFilterTopology::DeviceIoControl(
|
|||
IN PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
NTSTATUS Status;
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
|
@ -102,9 +103,15 @@ CPortFilterTopology::DeviceIoControl(
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
PC_ASSERT(IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_PROPERTY);
|
||||
Status = PcHandlePropertyWithTable(Irp, m_Descriptor->FilterPropertySetCount, m_Descriptor->FilterPropertySet, m_Descriptor);
|
||||
if (Status != STATUS_PENDING)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
return Status;
|
||||
|
||||
return PcPropertyHandler(Irp, m_Descriptor);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -135,6 +135,7 @@ CPortFilterWaveCyclic::DeviceIoControl(
|
|||
IN PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
NTSTATUS Status;
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
|
@ -148,9 +149,14 @@ CPortFilterWaveCyclic::DeviceIoControl(
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
PC_ASSERT(IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_PROPERTY);
|
||||
|
||||
return PcPropertyHandler(Irp, m_Descriptor);
|
||||
Status = PcHandlePropertyWithTable(Irp, m_Descriptor->FilterPropertySetCount, m_Descriptor->FilterPropertySet, m_Descriptor);
|
||||
if (Status != STATUS_PENDING)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -136,7 +136,29 @@ CPortFilterWavePci::DeviceIoControl(
|
|||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
return PcPropertyHandler(Irp, m_Descriptor);
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
NTSTATUS Status;
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
|
||||
{
|
||||
DPRINT1("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Status = PcHandlePropertyWithTable(Irp, m_Descriptor->FilterPropertySetCount, m_Descriptor->FilterPropertySet, m_Descriptor);
|
||||
if (Status != STATUS_PENDING)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -140,7 +140,29 @@ CPortFilterWaveRT::DeviceIoControl(
|
|||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
return PcPropertyHandler(Irp, m_Descriptor);
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
NTSTATUS Status;
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
|
||||
{
|
||||
DPRINT1("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Status = PcHandlePropertyWithTable(Irp, m_Descriptor->FilterPropertySetCount, m_Descriptor->FilterPropertySet, m_Descriptor);
|
||||
if (Status != STATUS_PENDING)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -199,19 +199,13 @@ typedef struct
|
|||
PIN_INSTANCE_INFO * Instances;
|
||||
}KSPIN_FACTORY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG MaxKsPropertySetCount;
|
||||
ULONG FreeKsPropertySetOffset;
|
||||
PKSPROPERTY_SET Properties;
|
||||
}KSPROPERTY_SET_LIST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG InterfaceCount;
|
||||
GUID *Interfaces;
|
||||
KSPIN_FACTORY Factory;
|
||||
KSPROPERTY_SET_LIST FilterPropertySet;
|
||||
ULONG FilterPropertySetCount;
|
||||
PKSPROPERTY_SET FilterPropertySet;
|
||||
|
||||
PPCFILTER_DESCRIPTOR DeviceDescriptor;
|
||||
KSTOPOLOGY* Topology;
|
||||
|
|
|
@ -286,26 +286,6 @@ PcCreateItemDispatch(
|
|||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PcPropertyHandler(
|
||||
IN PIRP Irp,
|
||||
IN PSUBDEVICE_DESCRIPTOR Descriptor);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
FastPropertyHandler(
|
||||
IN PFILE_OBJECT FileObject,
|
||||
IN PKSPROPERTY UNALIGNED Property,
|
||||
IN ULONG PropertyLength,
|
||||
IN OUT PVOID UNALIGNED Data,
|
||||
IN ULONG DataLength,
|
||||
OUT PIO_STATUS_BLOCK IoStatus,
|
||||
IN ULONG PropertySetsCount,
|
||||
IN const KSPROPERTY_SET *PropertySet,
|
||||
IN PSUBDEVICE_DESCRIPTOR Descriptor,
|
||||
IN ISubdevice *SubDevice);
|
||||
|
||||
PDEVICE_OBJECT
|
||||
GetDeviceObject(
|
||||
IPortWaveCyclic* iface);
|
||||
|
@ -326,6 +306,14 @@ NTAPI
|
|||
NewIUnregisterPhysicalConnection(
|
||||
OUT PUNREGISTERPHYSICALCONNECTION *OutConnection);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PcHandlePropertyWithTable(
|
||||
IN PIRP Irp,
|
||||
IN ULONG PropertySetCount,
|
||||
IN PKSPROPERTY_SET PropertySet,
|
||||
IN PSUBDEVICE_DESCRIPTOR Descriptor);
|
||||
|
||||
#define DEFINE_KSPROPERTY_PINPROPOSEDATAFORMAT(PinSet,\
|
||||
PropGeneral, PropInstances, PropIntersection)\
|
||||
DEFINE_KSPROPERTY_TABLE(PinSet) {\
|
||||
|
|
|
@ -8,16 +8,6 @@
|
|||
|
||||
#include "private.hpp"
|
||||
|
||||
NTSTATUS
|
||||
FindPropertyHandler(
|
||||
IN PIO_STATUS_BLOCK IoStatus,
|
||||
IN PSUBDEVICE_DESCRIPTOR Descriptor,
|
||||
IN PKSPROPERTY Property,
|
||||
IN ULONG InputBufferLength,
|
||||
IN ULONG OutputBufferLength,
|
||||
OUT PVOID OutputBuffer,
|
||||
OUT PFNKSHANDLER *PropertyHandler);
|
||||
|
||||
NTSTATUS
|
||||
HandlePropertyInstances(
|
||||
IN PIO_STATUS_BLOCK IoStatus,
|
||||
|
@ -205,6 +195,8 @@ PinPropertyHandler(
|
|||
|
||||
// Get the IrpTarget
|
||||
IrpTarget = (IIrpTarget*)IoStack->FileObject->FsContext;
|
||||
PC_ASSERT(IrpTarget);
|
||||
|
||||
// Get the parent
|
||||
Status = IrpTarget->QueryInterface(IID_IPort, (PVOID*)&Port);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -273,148 +265,6 @@ PinPropertyHandler(
|
|||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
FastPropertyHandler(
|
||||
IN PFILE_OBJECT FileObject,
|
||||
IN PKSPROPERTY UNALIGNED Property,
|
||||
IN ULONG PropertyLength,
|
||||
IN OUT PVOID UNALIGNED Data,
|
||||
IN ULONG DataLength,
|
||||
OUT PIO_STATUS_BLOCK IoStatus,
|
||||
IN ULONG PropertySetsCount,
|
||||
IN const KSPROPERTY_SET *PropertySet,
|
||||
IN PSUBDEVICE_DESCRIPTOR Descriptor,
|
||||
IN ISubdevice *SubDevice)
|
||||
{
|
||||
PFNKSHANDLER PropertyHandler = NULL;
|
||||
NTSTATUS Status;
|
||||
KSP_PIN * Pin;
|
||||
ULONG Size, Index;
|
||||
PKSMULTIPLE_ITEM Item;
|
||||
|
||||
PC_ASSERT(Descriptor);
|
||||
|
||||
if (!IsEqualGUIDAligned(Property->Set, KSPROPSETID_Pin))
|
||||
{
|
||||
// the fast handler only supports pin properties atm*/
|
||||
DPRINT("Only KSPROPSETID_Pin is supported\n");
|
||||
IoStatus->Status = Status = STATUS_NOT_IMPLEMENTED;
|
||||
IoStatus->Information = 0;
|
||||
return Status;
|
||||
}
|
||||
|
||||
// property handler is used to verify input parameters
|
||||
Status = FindPropertyHandler(IoStatus, Descriptor, Property, PropertyLength, DataLength, Data, &PropertyHandler);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("FindPropertyHandler failed with %x\n", Status);
|
||||
IoStatus->Status = Status = Status;
|
||||
IoStatus->Information = 0;
|
||||
return Status;
|
||||
}
|
||||
|
||||
switch(Property->Id)
|
||||
{
|
||||
case KSPROPERTY_PIN_CTYPES:
|
||||
(*(PULONG)Data) = Descriptor->Factory.PinDescriptorCount;
|
||||
IoStatus->Information = sizeof(ULONG);
|
||||
IoStatus->Status = Status = STATUS_SUCCESS;
|
||||
break;
|
||||
case KSPROPERTY_PIN_DATAFLOW:
|
||||
Pin = (KSP_PIN*)Property;
|
||||
if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount)
|
||||
{
|
||||
IoStatus->Status = Status = STATUS_INVALID_PARAMETER;
|
||||
IoStatus->Information = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
*((KSPIN_DATAFLOW*)Data) = Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataFlow;
|
||||
IoStatus->Information = sizeof(KSPIN_DATAFLOW);
|
||||
IoStatus->Status = Status = STATUS_SUCCESS;
|
||||
break;
|
||||
case KSPROPERTY_PIN_COMMUNICATION:
|
||||
Pin = (KSP_PIN*)Property;
|
||||
if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount)
|
||||
{
|
||||
IoStatus->Status = Status = STATUS_INVALID_PARAMETER;
|
||||
IoStatus->Information = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
*((KSPIN_COMMUNICATION*)Data) = Descriptor->Factory.KsPinDescriptor[Pin->PinId].Communication;
|
||||
IoStatus->Status = Status = STATUS_SUCCESS;
|
||||
IoStatus->Information = sizeof(KSPIN_COMMUNICATION);
|
||||
break;
|
||||
case KSPROPERTY_PIN_DATARANGES:
|
||||
Pin = (KSP_PIN*)Property;
|
||||
if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount)
|
||||
{
|
||||
IoStatus->Status = Status = STATUS_INVALID_PARAMETER;
|
||||
IoStatus->Information = 0;
|
||||
break;
|
||||
}
|
||||
Size = sizeof(KSMULTIPLE_ITEM);
|
||||
for (Index = 0; Index < Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRangesCount; Index++)
|
||||
{
|
||||
Size += Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRanges[Index]->FormatSize;
|
||||
}
|
||||
|
||||
if (DataLength < Size)
|
||||
{
|
||||
IoStatus->Information = Size;
|
||||
IoStatus->Status = STATUS_BUFFER_TOO_SMALL;
|
||||
break;
|
||||
}
|
||||
|
||||
Item = (KSMULTIPLE_ITEM*)Data;
|
||||
Item->Size = Size;
|
||||
Item->Count = Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRangesCount;
|
||||
|
||||
Data = (PUCHAR)(Item +1);
|
||||
for (Index = 0; Index < Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRangesCount; Index++)
|
||||
{
|
||||
RtlMoveMemory(Data, Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRanges[Index], Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRanges[Index]->FormatSize);
|
||||
Data = ((PUCHAR)Data + Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRanges[Index]->FormatSize);
|
||||
}
|
||||
|
||||
IoStatus->Status = Status = STATUS_SUCCESS;
|
||||
IoStatus->Information = Size;
|
||||
break;
|
||||
|
||||
case KSPROPERTY_PIN_GLOBALCINSTANCES:
|
||||
Status = HandlePropertyInstances(IoStatus, Property, Data, Descriptor, TRUE);
|
||||
break;
|
||||
case KSPROPERTY_PIN_CINSTANCES:
|
||||
Status = HandlePropertyInstances(IoStatus, Property, Data, Descriptor, FALSE);
|
||||
break;
|
||||
case KSPROPERTY_PIN_NECESSARYINSTANCES:
|
||||
Status = HandleNecessaryPropertyInstances(IoStatus, Property, Data, Descriptor);
|
||||
break;
|
||||
|
||||
case KSPROPERTY_PIN_DATAINTERSECTION:
|
||||
Status = HandleDataIntersection(IoStatus, Property, Data, DataLength, Descriptor, SubDevice);
|
||||
break;
|
||||
case KSPROPERTY_PIN_PHYSICALCONNECTION:
|
||||
case KSPROPERTY_PIN_CONSTRAINEDDATARANGES:
|
||||
case KSPROPERTY_PIN_INTERFACES:
|
||||
case KSPROPERTY_PIN_MEDIUMS:
|
||||
case KSPROPERTY_PIN_CATEGORY:
|
||||
case KSPROPERTY_PIN_NAME:
|
||||
case KSPROPERTY_PIN_PROPOSEDATAFORMAT:
|
||||
UNIMPLEMENTED
|
||||
IoStatus->Status = Status = STATUS_NOT_IMPLEMENTED;
|
||||
IoStatus->Information = 0;
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED
|
||||
IoStatus->Status = Status = STATUS_NOT_IMPLEMENTED;
|
||||
IoStatus->Information = 0;
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
TopologyPropertyHandler(
|
||||
|
@ -428,245 +278,3 @@ TopologyPropertyHandler(
|
|||
|
||||
return KsTopologyPropertyHandler(Irp, Request, Data, Descriptor->Topology);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
FindPropertyHandler(
|
||||
IN PIO_STATUS_BLOCK IoStatus,
|
||||
IN PSUBDEVICE_DESCRIPTOR Descriptor,
|
||||
IN PKSPROPERTY Property,
|
||||
IN ULONG InputBufferLength,
|
||||
IN ULONG OutputBufferLength,
|
||||
OUT PVOID OutputBuffer,
|
||||
OUT PFNKSHANDLER *PropertyHandler)
|
||||
{
|
||||
ULONG Index, ItemIndex;
|
||||
PULONG Flags;
|
||||
PKSPROPERTY_DESCRIPTION Description;
|
||||
|
||||
for(Index = 0; Index < Descriptor->FilterPropertySet.FreeKsPropertySetOffset; Index++)
|
||||
{
|
||||
if (IsEqualGUIDAligned(Property->Set, *Descriptor->FilterPropertySet.Properties[Index].Set))
|
||||
{
|
||||
for(ItemIndex = 0; ItemIndex < Descriptor->FilterPropertySet.Properties[Index].PropertiesCount; ItemIndex++)
|
||||
{
|
||||
if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].PropertyId == Property->Id)
|
||||
{
|
||||
if (Property->Flags & KSPROPERTY_TYPE_SET)
|
||||
*PropertyHandler = Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].SetPropertyHandler;
|
||||
|
||||
if (Property->Flags & KSPROPERTY_TYPE_GET)
|
||||
*PropertyHandler = Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].GetPropertyHandler;
|
||||
|
||||
if (Property->Flags & KSPROPERTY_TYPE_BASICSUPPORT)
|
||||
{
|
||||
if (sizeof(ULONG) > OutputBufferLength)
|
||||
{
|
||||
// too small buffer
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// get output buffer
|
||||
Flags = (PULONG)OutputBuffer;
|
||||
|
||||
// clear flags
|
||||
*Flags = KSPROPERTY_TYPE_BASICSUPPORT;
|
||||
|
||||
if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].GetSupported)
|
||||
*Flags |= KSPROPERTY_TYPE_GET;
|
||||
|
||||
if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].SetSupported)
|
||||
*Flags |= KSPROPERTY_TYPE_SET;
|
||||
|
||||
IoStatus->Information = sizeof(ULONG);
|
||||
|
||||
if (OutputBufferLength >= sizeof(KSPROPERTY_DESCRIPTION))
|
||||
{
|
||||
// get output buffer
|
||||
Description = (PKSPROPERTY_DESCRIPTION)OutputBuffer;
|
||||
|
||||
// store result
|
||||
Description->DescriptionSize = sizeof(KSPROPERTY_DESCRIPTION);
|
||||
Description->PropTypeSet.Set = KSPROPTYPESETID_General;
|
||||
Description->PropTypeSet.Id = 0;
|
||||
Description->PropTypeSet.Flags = 0;
|
||||
Description->MembersListCount = 0;
|
||||
Description->Reserved = 0;
|
||||
|
||||
IoStatus->Information = sizeof(KSPROPERTY_DESCRIPTION);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].MinProperty > InputBufferLength)
|
||||
{
|
||||
// too small input buffer
|
||||
IoStatus->Information = Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].MinProperty;
|
||||
IoStatus->Status = STATUS_BUFFER_TOO_SMALL;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].MinData > OutputBufferLength)
|
||||
{
|
||||
// too small output buffer
|
||||
IoStatus->Information = Descriptor->FilterPropertySet.Properties[Index].PropertyItem[ItemIndex].MinData;
|
||||
IoStatus->Status = STATUS_BUFFER_TOO_SMALL;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
PcCountProperties(
|
||||
IN PIRP Irp,
|
||||
IN PSUBDEVICE_DESCRIPTOR Descriptor)
|
||||
{
|
||||
ULONG Properties;
|
||||
ULONG Index, Offset;
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
LPGUID Guid;
|
||||
|
||||
// count property items
|
||||
Properties = Descriptor->FilterPropertySet.FreeKsPropertySetOffset;
|
||||
|
||||
if (Descriptor->DeviceDescriptor->AutomationTable)
|
||||
{
|
||||
Properties = Descriptor->DeviceDescriptor->AutomationTable->PropertyCount;
|
||||
}
|
||||
|
||||
// get current irp stack
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
// store output size
|
||||
Irp->IoStatus.Information = sizeof(GUID) * Properties;
|
||||
|
||||
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GUID) * Properties)
|
||||
{
|
||||
// buffer too small
|
||||
Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
// get output buffer
|
||||
Guid = (LPGUID)Irp->UserBuffer;
|
||||
|
||||
|
||||
// copy property guids from filter
|
||||
Offset = 0;
|
||||
for(Index = 0; Index < Descriptor->FilterPropertySet.FreeKsPropertySetOffset; Index++)
|
||||
{
|
||||
RtlMoveMemory(&Guid[Offset], Descriptor->FilterPropertySet.Properties[Index].Set, sizeof(GUID));
|
||||
Offset++;
|
||||
}
|
||||
|
||||
if (Descriptor->DeviceDescriptor->AutomationTable)
|
||||
{
|
||||
// copy property guids from driver
|
||||
for(Index = 0; Index < Descriptor->DeviceDescriptor->AutomationTable->PropertyCount; Index++)
|
||||
{
|
||||
RtlMoveMemory(&Guid[Offset], Descriptor->DeviceDescriptor->AutomationTable->Properties[Index].Set, sizeof(GUID));
|
||||
Offset++;
|
||||
}
|
||||
}
|
||||
|
||||
// done
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PcPropertyHandler(
|
||||
IN PIRP Irp,
|
||||
IN PSUBDEVICE_DESCRIPTOR Descriptor)
|
||||
{
|
||||
ULONG Index;
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
PKSPROPERTY Property;
|
||||
PFNKSHANDLER PropertyHandler = NULL;
|
||||
UNICODE_STRING GuidString;
|
||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||
PPCPROPERTY_REQUEST PropertyRequest;
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
PC_ASSERT(Property);
|
||||
|
||||
if (IsEqualGUIDAligned(Property->Set, GUID_NULL) && Property->Id == 0 && Property->Flags == KSPROPERTY_TYPE_SETSUPPORT)
|
||||
{
|
||||
return PcCountProperties(Irp, Descriptor);
|
||||
}
|
||||
|
||||
|
||||
// check properties provided by the driver
|
||||
if (Descriptor->DeviceDescriptor->AutomationTable)
|
||||
{
|
||||
for(Index = 0; Index < Descriptor->DeviceDescriptor->AutomationTable->PropertyCount; Index++)
|
||||
{
|
||||
if (IsEqualGUID(*Descriptor->DeviceDescriptor->AutomationTable->Properties[Index].Set, Property->Set))
|
||||
{
|
||||
if (Descriptor->DeviceDescriptor->AutomationTable->Properties[Index].Id == Property->Id)
|
||||
{
|
||||
if(Descriptor->DeviceDescriptor->AutomationTable->Properties[Index].Flags & Property->Flags)
|
||||
{
|
||||
PropertyRequest = (PPCPROPERTY_REQUEST)ExAllocatePool(NonPagedPool, sizeof(PCPROPERTY_REQUEST));
|
||||
if (!PropertyRequest)
|
||||
{
|
||||
// no memory
|
||||
Irp->IoStatus.Information = 0;
|
||||
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
RtlZeroMemory(PropertyRequest, sizeof(PCPROPERTY_REQUEST));
|
||||
PropertyRequest->PropertyItem = &Descriptor->DeviceDescriptor->AutomationTable->Properties[Index];
|
||||
PropertyRequest->Verb = Property->Flags;
|
||||
PropertyRequest->Value = Irp->UserBuffer;
|
||||
PropertyRequest->ValueSize = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
|
||||
PropertyRequest->Irp = Irp;
|
||||
|
||||
DPRINT("Calling handler %p\n", Descriptor->DeviceDescriptor->AutomationTable->Properties[Index].Handler);
|
||||
Status = Descriptor->DeviceDescriptor->AutomationTable->Properties[Index].Handler(PropertyRequest);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status = FindPropertyHandler(&Irp->IoStatus, Descriptor, Property, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Irp->UserBuffer, &PropertyHandler);
|
||||
if (NT_SUCCESS(Status) && PropertyHandler)
|
||||
{
|
||||
// HACK
|
||||
KSPROPERTY_ITEM_IRP_STORAGE(Irp) = (const KSPROPERTY_ITEM*)Descriptor;
|
||||
DPRINT("Calling property handler %p\n", PropertyHandler);
|
||||
Status = PropertyHandler(Irp, Property, Irp->UserBuffer);
|
||||
}
|
||||
else if (!NT_SUCCESS(Status))
|
||||
{
|
||||
RtlStringFromGUID(Property->Set, &GuidString);
|
||||
DPRINT1("Unhandeled property: Set %S Id %u Flags %x InputLength %u OutputLength %u\n", GuidString.Buffer, Property->Id, Property->Flags, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength);
|
||||
RtlFreeUnicodeString(&GuidString);
|
||||
}
|
||||
|
||||
// the information member is set by the handler
|
||||
Irp->IoStatus.Status = Status;
|
||||
DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,18 @@ KsoGetIrpTargetFromIrp(
|
|||
return (IIrpTarget*)CreateItem->Context;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PcHandlePropertyWithTable(
|
||||
IN PIRP Irp,
|
||||
IN ULONG PropertySetCount,
|
||||
IN PKSPROPERTY_SET PropertySet,
|
||||
IN PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor)
|
||||
{
|
||||
KSPROPERTY_ITEM_IRP_STORAGE(Irp) = (PKSPROPERTY_ITEM)SubDeviceDescriptor;
|
||||
return KsPropertyHandler(Irp, PropertySetCount, PropertySet);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
PcAcquireFormatResources(
|
||||
|
@ -92,52 +104,6 @@ PcCaptureFormat(
|
|||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
AddToPropertyTable(
|
||||
IN OUT SUBDEVICE_DESCRIPTOR * Descriptor,
|
||||
IN KSPROPERTY_SET * FilterProperty)
|
||||
{
|
||||
if (Descriptor->FilterPropertySet.FreeKsPropertySetOffset >= Descriptor->FilterPropertySet.MaxKsPropertySetCount)
|
||||
{
|
||||
DPRINT1("FIXME\n");
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
RtlMoveMemory(&Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset],
|
||||
FilterProperty,
|
||||
sizeof(KSPROPERTY_SET));
|
||||
|
||||
if (FilterProperty->PropertiesCount)
|
||||
{
|
||||
Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].PropertyItem = (const KSPROPERTY_ITEM*)AllocateItem(NonPagedPool,
|
||||
sizeof(KSPROPERTY_ITEM) * FilterProperty->PropertiesCount,
|
||||
TAG_PORTCLASS);
|
||||
|
||||
if (!Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].PropertyItem)
|
||||
{
|
||||
Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].PropertiesCount = 0;
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
RtlMoveMemory((PVOID)Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].PropertyItem,
|
||||
FilterProperty->PropertyItem,
|
||||
sizeof(KSPROPERTY_ITEM) * FilterProperty->PropertiesCount);
|
||||
|
||||
}
|
||||
Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].Set = (const GUID *)AllocateItem(NonPagedPool, sizeof(GUID), TAG_PORTCLASS);
|
||||
if (!Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].Set)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
RtlCopyMemory((PVOID)Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].Set, FilterProperty->Set, sizeof(GUID));
|
||||
|
||||
// ignore fast io table for now
|
||||
Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].FastIoCount = 0;
|
||||
Descriptor->FilterPropertySet.Properties[Descriptor->FilterPropertySet.FreeKsPropertySetOffset].FastIoTable = NULL;
|
||||
|
||||
Descriptor->FilterPropertySet.FreeKsPropertySetOffset++;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PcCreateSubdeviceDescriptor(
|
||||
|
@ -157,8 +123,7 @@ PcCreateSubdeviceDescriptor(
|
|||
IN PPCFILTER_DESCRIPTOR FilterDescription)
|
||||
{
|
||||
SUBDEVICE_DESCRIPTOR * Descriptor;
|
||||
ULONG Index, SubIndex;
|
||||
PKSDATARANGE DataRange;
|
||||
ULONG Index;
|
||||
NTSTATUS Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
PPCPIN_DESCRIPTOR SrcDescriptor;
|
||||
|
||||
|
@ -182,16 +147,14 @@ PcCreateSubdeviceDescriptor(
|
|||
{
|
||||
/// FIXME
|
||||
/// handle driver properties
|
||||
Descriptor->FilterPropertySet.Properties = (PKSPROPERTY_SET)AllocateItem(NonPagedPool, sizeof(KSPROPERTY_SET) * FilterPropertiesCount, TAG_PORTCLASS);
|
||||
if (! Descriptor->FilterPropertySet.Properties)
|
||||
Descriptor->FilterPropertySet = (PKSPROPERTY_SET)AllocateItem(NonPagedPool, sizeof(KSPROPERTY_SET) * FilterPropertiesCount, TAG_PORTCLASS);
|
||||
if (! Descriptor->FilterPropertySet)
|
||||
goto cleanup;
|
||||
|
||||
Descriptor->FilterPropertySet.MaxKsPropertySetCount = FilterPropertiesCount;
|
||||
Descriptor->FilterPropertySetCount = FilterPropertiesCount;
|
||||
for(Index = 0; Index < FilterPropertiesCount; Index++)
|
||||
{
|
||||
Status = AddToPropertyTable(Descriptor, &FilterProperties[Index]);
|
||||
if (!NT_SUCCESS(Status))
|
||||
goto cleanup;
|
||||
RtlMoveMemory(&Descriptor->FilterPropertySet[Index], &FilterProperties[Index], sizeof(KSPROPERTY_SET));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,29 +217,6 @@ PcCreateSubdeviceDescriptor(
|
|||
{
|
||||
RtlMoveMemory(&Descriptor->Factory.KsPinDescriptor[Index], &SrcDescriptor->KsPinDescriptor, sizeof(KSPIN_DESCRIPTOR));
|
||||
|
||||
if (SrcDescriptor->KsPinDescriptor.DataRangesCount)
|
||||
{
|
||||
Descriptor->Factory.KsPinDescriptor[Index].DataRanges = (const PKSDATARANGE*)AllocateItem(NonPagedPool, SrcDescriptor->KsPinDescriptor.DataRangesCount * sizeof(PKSDATARANGE), TAG_PORTCLASS);
|
||||
if(!Descriptor->Factory.KsPinDescriptor[Index].DataRanges)
|
||||
goto cleanup;
|
||||
|
||||
for (SubIndex = 0; SubIndex < FilterDescription->Pins[Index].KsPinDescriptor.DataRangesCount; SubIndex++)
|
||||
{
|
||||
DataRange = (PKSDATARANGE)AllocateItem(NonPagedPool, SrcDescriptor->KsPinDescriptor.DataRanges[SubIndex]->FormatSize, TAG_PORTCLASS);
|
||||
if (!DataRange)
|
||||
goto cleanup;
|
||||
|
||||
RtlMoveMemory(DataRange,
|
||||
SrcDescriptor->KsPinDescriptor.DataRanges[SubIndex],
|
||||
SrcDescriptor->KsPinDescriptor.DataRanges[SubIndex]->FormatSize);
|
||||
|
||||
((PKSDATAFORMAT*)Descriptor->Factory.KsPinDescriptor[Index].DataRanges)[SubIndex] = DataRange;
|
||||
|
||||
}
|
||||
|
||||
Descriptor->Factory.KsPinDescriptor[Index].DataRangesCount = SrcDescriptor->KsPinDescriptor.DataRangesCount;
|
||||
}
|
||||
|
||||
Descriptor->Factory.Instances[Index].CurrentPinInstanceCount = 0;
|
||||
Descriptor->Factory.Instances[Index].MaxFilterInstanceCount = FilterDescription->Pins[Index].MaxFilterInstanceCount;
|
||||
Descriptor->Factory.Instances[Index].MaxGlobalInstanceCount = FilterDescription->Pins[Index].MaxGlobalInstanceCount;
|
||||
|
|
Loading…
Reference in a new issue