mirror of
https://github.com/reactos/reactos.git
synced 2024-07-28 07:08:59 +00:00
[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 svn path=/trunk/; revision=49199
This commit is contained in:
parent
54374ca72e
commit
619ab27e1d
|
@ -330,6 +330,7 @@ KspPinPropertyHandler(
|
||||||
NTSTATUS Status = STATUS_NOT_SUPPORTED;
|
NTSTATUS Status = STATUS_NOT_SUPPORTED;
|
||||||
ULONG Count;
|
ULONG Count;
|
||||||
const PKSDATARANGE* DataRanges;
|
const PKSDATARANGE* DataRanges;
|
||||||
|
LPGUID Guid;
|
||||||
|
|
||||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
Buffer = Irp->UserBuffer;
|
Buffer = Irp->UserBuffer;
|
||||||
|
@ -509,48 +510,77 @@ KspPinPropertyHandler(
|
||||||
|
|
||||||
case KSPROPERTY_PIN_CATEGORY:
|
case KSPROPERTY_PIN_CATEGORY:
|
||||||
|
|
||||||
|
if (!Descriptor->Category)
|
||||||
|
{
|
||||||
|
/* no pin category */
|
||||||
|
return STATUS_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check size */
|
||||||
Size = sizeof(GUID);
|
Size = sizeof(GUID);
|
||||||
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
|
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
|
||||||
{
|
{
|
||||||
|
/* buffer too small */
|
||||||
Irp->IoStatus.Information = Size;
|
Irp->IoStatus.Information = Size;
|
||||||
Status = STATUS_BUFFER_TOO_SMALL;
|
Status = STATUS_BUFFER_TOO_SMALL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Descriptor->Category)
|
|
||||||
{
|
|
||||||
RtlMoveMemory(Buffer, Descriptor->Category, sizeof(GUID));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* copy category guid */
|
||||||
|
RtlMoveMemory(Buffer, Descriptor->Category, sizeof(GUID));
|
||||||
|
|
||||||
|
/* save result */
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = Size;
|
Irp->IoStatus.Information = Size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KSPROPERTY_PIN_NAME:
|
case KSPROPERTY_PIN_NAME:
|
||||||
if (!Descriptor->Name)
|
|
||||||
|
if (Descriptor->Name)
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Information = 0;
|
/* use pin name */
|
||||||
Status = STATUS_SUCCESS;
|
Guid = (LPGUID)Descriptor->Name;
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* use pin category as fallback */
|
||||||
|
Guid = (LPGUID)Descriptor->Category;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = KspReadMediaCategory((LPGUID)Descriptor->Name, &KeyInfo);
|
if (!Guid)
|
||||||
|
{
|
||||||
|
/* no friendly name available */
|
||||||
|
return STATUS_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read friendly name category name */
|
||||||
|
Status = KspReadMediaCategory(Guid, &KeyInfo);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
/* failed to read category */
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* store required length */
|
||||||
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
|
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
|
||||||
|
|
||||||
|
/* check if buffer is too small */
|
||||||
if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
|
if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
|
||||||
{
|
{
|
||||||
|
/* buffer too small */
|
||||||
Status = STATUS_BUFFER_OVERFLOW;
|
Status = STATUS_BUFFER_OVERFLOW;
|
||||||
FreeItem(KeyInfo);
|
FreeItem(KeyInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* copy result */
|
||||||
RtlMoveMemory(Irp->UserBuffer, &KeyInfo->Data, KeyInfo->DataLength);
|
RtlMoveMemory(Irp->UserBuffer, &KeyInfo->Data, KeyInfo->DataLength);
|
||||||
|
|
||||||
|
/* null terminate name */
|
||||||
((LPWSTR)Irp->UserBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
|
((LPWSTR)Irp->UserBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
|
||||||
|
|
||||||
|
/* free key info */
|
||||||
FreeItem(KeyInfo);
|
FreeItem(KeyInfo);
|
||||||
break;
|
break;
|
||||||
case KSPROPERTY_PIN_PROPOSEDATAFORMAT:
|
case KSPROPERTY_PIN_PROPOSEDATAFORMAT:
|
||||||
|
|
|
@ -151,6 +151,7 @@ KsTopologyPropertyHandler(
|
||||||
PIO_STACK_LOCATION IoStack;
|
PIO_STACK_LOCATION IoStack;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
|
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
|
||||||
|
LPGUID Guid;
|
||||||
|
|
||||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
|
@ -177,37 +178,60 @@ KsTopologyPropertyHandler(
|
||||||
case KSPROPERTY_TOPOLOGY_NAME:
|
case KSPROPERTY_TOPOLOGY_NAME:
|
||||||
Node = (KSP_NODE*)Property;
|
Node = (KSP_NODE*)Property;
|
||||||
|
|
||||||
|
/* check for invalid node id */
|
||||||
if (Node->NodeId >= Topology->TopologyNodesCount)
|
if (Node->NodeId >= Topology->TopologyNodesCount)
|
||||||
{
|
{
|
||||||
|
/* invalid node id */
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_INVALID_PARAMETER;
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
break;
|
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))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* store result size */
|
||||||
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
|
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
|
||||||
|
|
||||||
|
/* check for buffer overflow */
|
||||||
if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
|
if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
|
||||||
{
|
{
|
||||||
|
/* buffer too small */
|
||||||
Status = STATUS_BUFFER_OVERFLOW;
|
Status = STATUS_BUFFER_OVERFLOW;
|
||||||
FreeItem(KeyInfo);
|
FreeItem(KeyInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* copy result buffer */
|
||||||
RtlMoveMemory(Irp->UserBuffer, &KeyInfo->Data, KeyInfo->DataLength);
|
RtlMoveMemory(Irp->UserBuffer, &KeyInfo->Data, KeyInfo->DataLength);
|
||||||
|
|
||||||
|
/* zero terminate it */
|
||||||
((LPWSTR)Irp->UserBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
|
((LPWSTR)Irp->UserBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
|
||||||
|
|
||||||
|
/* free key info */
|
||||||
FreeItem(KeyInfo);
|
FreeItem(KeyInfo);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = STATUS_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue