Author: janderwald
Date: Mon Oct 18 22:21:00 2010
New Revision: 49199
URL:
http://svn.reactos.org/svn/reactos?rev=49199&view=rev
Log:
[KS]
- Fix KSPROPERTY_PIN_CATEGORY handler when no category is provided
- Fix KSPROPERTY_PIN_NAME handler when there is no name provided. Use fallback pin
category. If there is no category provided, fail with correct error code
- Fix KSPROPERTY_TOPOLOGY_NAME handler by checking if there is a node name provided. If
not use node type as fallback.
- Return correct error code when property request id is out of bounds
Modified:
trunk/reactos/drivers/ksfilter/ks/connectivity.c
trunk/reactos/drivers/ksfilter/ks/topology.c
Modified: trunk/reactos/drivers/ksfilter/ks/connectivity.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/connec…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/connectivity.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/connectivity.c [iso-8859-1] Mon Oct 18 22:21:00
2010
@@ -330,6 +330,7 @@
NTSTATUS Status = STATUS_NOT_SUPPORTED;
ULONG Count;
const PKSDATARANGE* DataRanges;
+ LPGUID Guid;
IoStack = IoGetCurrentIrpStackLocation(Irp);
Buffer = Irp->UserBuffer;
@@ -509,48 +510,77 @@
case KSPROPERTY_PIN_CATEGORY:
+ if (!Descriptor->Category)
+ {
+ /* no pin category */
+ return STATUS_NOT_FOUND;
+ }
+
+ /* check size */
Size = sizeof(GUID);
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
{
+ /* buffer too small */
Irp->IoStatus.Information = Size;
Status = STATUS_BUFFER_TOO_SMALL;
break;
}
- if (Descriptor->Category)
- {
- RtlMoveMemory(Buffer, Descriptor->Category, sizeof(GUID));
- }
-
+
+ /* copy category guid */
+ RtlMoveMemory(Buffer, Descriptor->Category, sizeof(GUID));
+
+ /* save result */
Status = STATUS_SUCCESS;
Irp->IoStatus.Information = Size;
break;
case KSPROPERTY_PIN_NAME:
- if (!Descriptor->Name)
- {
+
+ if (Descriptor->Name)
+ {
+ /* use pin name */
+ Guid = (LPGUID)Descriptor->Name;
+ }
+ else
+ {
+ /* use pin category as fallback */
+ Guid = (LPGUID)Descriptor->Category;
+ }
+
+ if (!Guid)
+ {
+ /* no friendly name available */
+ return STATUS_NOT_FOUND;
+ }
+
+ /* read friendly name category name */
+ Status = KspReadMediaCategory(Guid, &KeyInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ /* failed to read category */
Irp->IoStatus.Information = 0;
- Status = STATUS_SUCCESS;
- break;
- }
-
- Status = KspReadMediaCategory((LPGUID)Descriptor->Name, &KeyInfo);
- if (!NT_SUCCESS(Status))
- {
- Irp->IoStatus.Information = 0;
- break;
- }
-
+ break;
+ }
+
+ /* store required length */
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
+ /* check if buffer is too small */
if (KeyInfo->DataLength + sizeof(WCHAR) >
IoStack->Parameters.DeviceIoControl.OutputBufferLength)
{
+ /* buffer too small */
Status = STATUS_BUFFER_OVERFLOW;
FreeItem(KeyInfo);
break;
}
+ /* copy result */
RtlMoveMemory(Irp->UserBuffer, &KeyInfo->Data,
KeyInfo->DataLength);
+
+ /* null terminate name */
((LPWSTR)Irp->UserBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] =
L'\0';
+
+ /* free key info */
FreeItem(KeyInfo);
break;
case KSPROPERTY_PIN_PROPOSEDATAFORMAT:
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] Mon Oct 18 22:21:00 2010
@@ -151,6 +151,7 @@
PIO_STACK_LOCATION IoStack;
NTSTATUS Status;
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
+ LPGUID Guid;
IoStack = IoGetCurrentIrpStackLocation(Irp);
@@ -177,37 +178,60 @@
case KSPROPERTY_TOPOLOGY_NAME:
Node = (KSP_NODE*)Property;
+ /* check for invalid node id */
if (Node->NodeId >= Topology->TopologyNodesCount)
{
+ /* invalid node id */
Irp->IoStatus.Information = 0;
Status = STATUS_INVALID_PARAMETER;
break;
}
- Status =
KspReadMediaCategory((LPGUID)&Topology->TopologyNodesNames[Node->NodeId],
&KeyInfo);
+ /* check if there is a name supplied */
+ if
(!IsEqualGUIDAligned(&Topology->TopologyNodesNames[Node->NodeId],
&GUID_NULL))
+ {
+ /* node name has been supplied */
+ Guid = (LPGUID)&Topology->TopologyNodesNames[Node->NodeId];
+ }
+ else
+ {
+ /* fallback to topology node type */
+ Guid = (LPGUID)&Topology->TopologyNodes[Node->NodeId];
+ }
+
+ /* read topology node name */
+ Status = KspReadMediaCategory(Guid, &KeyInfo);
if (!NT_SUCCESS(Status))
{
Irp->IoStatus.Information = 0;
break;
}
+ /* store result size */
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
+ /* check for buffer overflow */
if (KeyInfo->DataLength + sizeof(WCHAR) >
IoStack->Parameters.DeviceIoControl.OutputBufferLength)
{
+ /* buffer too small */
Status = STATUS_BUFFER_OVERFLOW;
FreeItem(KeyInfo);
break;
}
+ /* copy result buffer */
RtlMoveMemory(Irp->UserBuffer, &KeyInfo->Data,
KeyInfo->DataLength);
+
+ /* zero terminate it */
((LPWSTR)Irp->UserBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] =
L'\0';
+
+ /* free key info */
FreeItem(KeyInfo);
break;
default:
Irp->IoStatus.Information = 0;
- Status = STATUS_NOT_IMPLEMENTED;
+ Status = STATUS_NOT_FOUND;
}