kissfire
驱动牛犊
驱动牛犊
  • 注册日期2004-09-09
  • 最后登录2006-01-05
  • 粉丝0
  • 关注0
  • 积分12分
  • 威望3点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:972回复:0

串口过滤驱动的READ问题

楼主#
更多 发布于:2004-10-12 10:02
我做了一个串口过滤驱动,想要拦截串口接收的第一位为1的字节,我在过滤驱动中的READ例程中的处理:

NTSTATUS status;
KEVENT event;
PUCHAR RByte;
ULONG Rlenth;
UCHAR Rcount;
PUCHAR TempBuffer;
UCHAR Count0;
KeInitializeEvent (&event, NotificationEvent, FALSE);
IoCopyCurrentIrpStackLocationToNext (Irp);
IoSetCompletionRoutine (Irp,
  Serenum_FEDO_ReadComplete,
                     &event,
                       TRUE,
                      FALSE,
                      FALSE);
status = IoCallDriver (((PFDO_DEVICE_DATA)DeviceObject->DeviceExtension)->TopOfStack, Irp);

if (STATUS_PENDING == status) {//2
// wait for it...
status = KeWaitForSingleObject (&event,
                             Executive,
                            KernelMode,
                            FALSE, // Not allertable
                             NULL); // No timeout structure
ASSERT (STATUS_SUCCESS == status);
status = Irp->IoStatus.Status;
}//2

if (NT_SUCCESS(status)) {//3
RByte = (UCHAR*)Irp->AssociatedIrp.SystemBuffer;
Rlenth = Irp->IoStatus.Information;
TempBuffer = ExAllocatePool( PagedPool, Rlenth);
RtlZeroMemory(TempBuffer,Rlenth);
Count0 = 0;
for(Rcount=0;Rcount<Rlenth;Rcount++)
{//4
  if( *(RByte+Rcount) < 0x80 )
  {//5
   *(TempBuffer+Count0) = *(RByte+Rcount);
   Count0++;
   }//5
}//
RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer,Rlenth);
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,TempBuffer,Count0);

ExFreePool(TempBuffer);
Irp->IoStatus.Information = Count0;
}
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return status;

结果无论我发送什么,我接收到的全是一系列相同的字节0x34

并且接收到的字节数也不会变化。请各位老大帮忙看看。150分重谢!
游客

返回顶部