HLK Camera Property fails with STATUS_BAD_CONFIGURATION

hi,
I have a HLK test for camera properties (ev compensatin)
that fails with status_bad_configuration this is not a status I return.
my GetProperty handler is called and I see in my logs that the handler
returns with status success, but yet the test fails with the bad
confguration

my Get Handler is the following:

NTSTATUS CCaptureFilter::GetEvCompensation(IN PIRP Irp,
IN PKSPROPERTY Property,
OUT PVOID Data)
{
PAGED_CODE();
NTSTATUS Status = STATUS_SUCCESS;
ASSERT(Irp);
ASSERT(Property);

PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(Irp);
ULONG ulOutputBufferLength =
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength;

ULONG ulExpectedLength = sizeof(KSCAMERA_EXTENDEDPROP_HEADER) +
sizeof(KSCAMERA_EXTENDEDPROP_EVCOMPENSATION);

if (ulOutputBufferLength == 0)
{
Irp->IoStatus.Information = ulExpectedLength;
Status = STATUS_BUFFER_OVERFLOW;
}
else if (ulOutputBufferLength < ulExpectedLength)
{
Status = STATUS_BUFFER_TOO_SMALL;
}
else if (Data && ulOutputBufferLength >= ulExpectedLength)
{
PKSCAMERA_EXTENDEDPROP_HEADER pKsExtPropHeader =
(PKSCAMERA_EXTENDEDPROP_HEADER)Data;
ASSERT(pKsExtPropHeader->Version == 1);
ASSERT(pKsExtPropHeader->PinId ==
KSCAMERA_EXTENDEDPROP_FILTERSCOPE);

pKsExtPropHeader->Size = ulExpectedLength;
pKsExtPropHeader->Result= 0;
pKsExtPropHeader->Flags = KSCAMERA_EXTENDEDPROP_EVCOMP_SIXTHSTEP;
pKsExtPropHeader->Capability =
KSCAMERA_EXTENDEDPROP_EVCOMP_SIXTHSTEP;

PKSCAMERA_EXTENDEDPROP_EVCOMPENSATION pEvCompensation \
= (PKSCAMERA_EXTENDEDPROP_EVCOMPENSATION)(pKsExtPropHeader + 1);
pEvCompensation->Mode = 0; // Unused. Must be 0.
pEvCompensation->Min = (LONG)-1;
pEvCompensation->Max = (LONG)0;
pEvCompensation->Value = 0;

Irp->IoStatus.Information = ulExpectedLength;
}
else
{
Status = STATUS_INVALID_PARAMETER;
}

TRACE_FUNC(status);
return Status;
}

On Nov 27, 2015, at 12:57 AM, NtDev mm wrote:
>
> NTSTATUS CCaptureFilter::GetEvCompensation(IN PIRP Irp,
> IN PKSPROPERTY Property,
> OUT PVOID Data)
> {
> PAGED_CODE();
> NTSTATUS Status = STATUS_SUCCESS;
> ASSERT(Irp);
> ASSERT(Property);
>
> PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(Irp);
> ULONG ulOutputBufferLength = pIrpStack->Parameters.DeviceIoControl.OutputBufferLength;
>
> ULONG ulExpectedLength = sizeof(KSCAMERA_EXTENDEDPROP_HEADER) + sizeof(KSCAMERA_EXTENDEDPROP_EVCOMPENSATION);
>
> if (ulOutputBufferLength == 0)
> {
> Irp->IoStatus.Information = ulExpectedLength;
> Status = STATUS_BUFFER_OVERFLOW;
> }
> else if (ulOutputBufferLength < ulExpectedLength)
> {
> Status = STATUS_BUFFER_TOO_SMALL;
> }

I don’t have direct experience with the EVCompensation properties yet, but assuming you set up your property descriptor tables properly, none of that validation is necessary. The AVStream framework will do all of that for you, so that the structure you get is guaranteed to be large enough.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.