阅读:1228回复:6
WDM 如何读数据
我用bulkusb的例子,建立了一个WDM的驱动,并且通过CreateFile获得了end point 的句柄,我用readfile读他,返回成功并且返回读到了80个字节,可是参数中传入的buffer没有被改动。是不是我应该手动把数据考出来呢??USB中是用的DIRECT方式,不是user buffer的方式。我想数据应该在MDL中,不知道是不是,也不知道如何得到他??各位请帮帮忙??
|
|
沙发#
发布于:2002-11-14 18:48
direct 或者 buffer 方式只是驱程中处里数句的方式,最中都会拷到用户换冲里的
|
|
|
板凳#
发布于:2002-11-14 18:58
不需要我手动去拷贝吗,那么为什么readfile参数中的buffer没有被改动到啊?
|
|
地板#
发布于:2002-11-14 19:52
不好意思,我再说详细一点:
我用DDK下的bulkusb想改一个自己的驱动用来在USB上读一点数据。 现在的情况是初始化好像正确了,我也可以用CreateFile来取得USB的句柄了,也可以访问end point 了。问题是我用ReadFile读数据的时候,我传入的buffer,没有任何改动??是为什么呢?? 以下是关于我的USB的情况: 它是一个U盘,有三个end point(包括end point 0在内)我是访问的end point 1. |
|
地下室#
发布于:2002-11-14 20:37
你的意思是没有传倒driver的缓冲区里?
|
|
|
5楼#
发布于:2002-11-14 20:41
不是,是我在
status = ReadFile(hPipe, inBuffer, inCount, &bR, NULL); 时返回的inBuffer没有值或者说没有变化。而status显示正确,bR返回值是80 |
|
6楼#
发布于:2002-11-14 20:45
在driver里我读数据的代码是这样的:
nextStack = IoGetNextIrpStackLocation(Irp); BULKUSB_ASSERT(nextStack != NULL); // // pass the URB to the USB driver stack // nextStack->Parameters.Others.Argument1 = urb; nextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; nextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; IoSetCompletionRoutine( Irp, // irp to use BulkUsb_SimpleReadWrite_Complete, // routine to call when irp is done DeviceObject, // we pass our FDO as context to pass routine TRUE, // call on success TRUE, // call on error TRUE); // call on cancel // // Call IoCallDriver to send the irp to the usb port. // BULKUSB_KdPrint ( DBGLVL_HIGH, (\" BulkUsb_SingleUrbReadWrite about to IoCallDriver\\n\")); BulkUsb_IncrementIoCount(DeviceObject); ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp ); |
|