-
-
[求助]camera upper filter driver
-
发表于:
2012-2-22 22:05
4990
-
[求助]camera upper filter driver
想挂上usbvideo来截获stream,现可以获得数据,但是数据貌似不对。
获得数据是在完成例程里完成的!
这个是在deviceiocontrol里判断IOCTL_KS_READ_STREAM
}else if (IOCTL_KS_READ_STREAM == _lngCode)
{
status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp);
if (!NT_SUCCESS (status)) {
Irp->IoStatus.Status = status;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return status;
}
IoCopyCurrentIrpStackLocationToNext(Irp);
IoSetCompletionRoutine(
Irp,
FilterFidoDeviceIoCompletionRoutineReadStream,
deviceExtension,
TRUE,
TRUE,
TRUE
);
status = IoCallDriver(deviceExtension->NextLowerDriver, Irp);
Irp->IoStatus.Status = status;
IoReleaseRemoveLock(&deviceExtension->RemoveLock ,Irp);
return status;
完成例程的代码是这样的:
NTSTATUS
FilterFidoDeviceIoCompletionRoutineReadStream(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
PDEVICE_EXTENSION event;
PVOID _LpMdlAddress;
PIO_STACK_LOCATION _IrpStack;
ULONG _lngLength;
ULONG _trueLength;
ULONG _lngOutLength;
ULONG _i;
PKSSTREAM_HEADER _Stream_Header=NULL;
_IrpStack = IoGetCurrentIrpStackLocation(Irp);
event = (PDEVICE_EXTENSION)Context;
_lngLength =_IrpStack->Parameters.DeviceIoControl.InputBufferLength;
_trueLength =Irp->IoStatus.Information;
_lngOutLength = _IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
if (NULL != Irp->AssociatedIrp.SystemBuffer)
{
//DbgPrint("SystemBuffer Many!!!\n");
//for (_i = 0; _i <_trueLength ;++_i)
//{
// if (_i % 10 == 0)
// {
// ((UCHAR*)Irp->AssociatedIrp.SystemBuffer)[_i] = 0;
// }
//}
// _asm
// {
// int 3
// }
}
if (NULL != Irp->UserBuffer)
{
//DbgPrint("UserBuffer Many!!!\n");
// _try
// {
// ProbeForRead(Irp->UserBuffer ,_trueLength ,4);
// _Stream_Header = (PKSSTREAM_HEADER)Irp->UserBuffer;
// DbgPrint("%d ,%p ",_Stream_Header->Size ,_Stream_Header->Data);
//for (_i = 0; _i <_trueLength ;++_i)
// {
//if (_i % 10 == 0)
//{
// ((UCHAR*)Irp->UserBuffer)[_i] = 0;
//}
// }
// }
// _except(EXCEPTION_EXECUTE_HANDLER)
// {
// DbgPrint("UserBuffer is Error!!!\n");
// }
}
if (NULL != Irp->MdlAddress)
{
_LpMdlAddress = MmGetSystemAddressForMdlSafe(Irp->MdlAddress ,NormalPagePriority);
DbgPrint("Length of:%d\n" ,_trueLength);
if (NULL != _LpMdlAddress && _trueLength != 0)
{
_Stream_Header = (PKSSTREAM_HEADER)_LpMdlAddress;
DbgPrint("%d ,%p ",_Stream_Header->Size ,_Stream_Header->Data);
//DBG_Dump((UCHAR*)_LpMdlAddress ,10);
//DbgPrint("Modify!!!!\n");
//for (_i = 0; _i <_trueLength ;++_i)
//{
//if (_i % 10 == 0)
//{
// ((UCHAR*)_LpMdlAddress)[_i] = 0;
//}
//}
}
}else
{
DbgPrint("Other Buffer!!!");
}
if (Irp->PendingReturned ==TRUE)
{
IoMarkIrpPending(Irp);
}
return STATUS_CONTINUE_COMPLETION;
}
在网络上的资料里看到MdlBuffer里的结构就是KSSTREAM_HEADER
但是调试发现我获得的是错误的KSSTREAM_HEADER
不知道哪位大牛是否知道这个KSSTREAM_HEADER结构到底在哪里?或者怎样去获得?
谢谢!!!
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课