NTSTATUS Status = STATUS_NOT_SUPPORTED;
ULONG Count;
const PKSDATARANGE* DataRanges;
+ LPGUID Guid;
IoStack = IoGetCurrentIrpStackLocation(Irp);
Buffer = Irp->UserBuffer;
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)
{
- Irp->IoStatus.Information = 0;
- Status = STATUS_SUCCESS;
- break;
+ /* 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;
}
- Status = KspReadMediaCategory((LPGUID)Descriptor->Name, &KeyInfo);
+ /* read friendly name category name */
+ Status = KspReadMediaCategory(Guid, &KeyInfo);
if (!NT_SUCCESS(Status))
{
+ /* failed to read category */
Irp->IoStatus.Information = 0;
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:
PIO_STACK_LOCATION IoStack;
NTSTATUS Status;
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
+ LPGUID Guid;
IoStack = IoGetCurrentIrpStackLocation(Irp);
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;
}