我正在使用以下代码解析http://msdn.microsoft.com/en-us/library/windows/hardware/ff540352(v=vs.85).aspx中定义的_URB_BULK_OR_INTERRUPT_TRANSFER数据包:
//parse URB Packet
/*
_URB_HEADER {
USHORT Length;
USHORT Function;
USBD_STATUS Status;
PVOID UsbdDeviceHandle;
ULONG UsbdFlags;
}*/
//start header parse
UInt16 urb_length = rdr.ReadUInt16();
UInt16 urb_function = rdr.ReadUInt16();
UInt32 urb_status = rdr.ReadUInt32();
rdr.ReadBytes(System.IntPtr.Size);
UInt32 UsbdFlags = rdr.ReadUInt32();
//end header parse
//.. skip code to check if it a _URB_BULK_OR_INTERRUPT_TRANSFER
// but assuming it is parse it
/*struct _URB_BULK_OR_INTERRUPT_TRANSFER {
struct URB_HEADER Hdr;//covered above
USBD_PIPE_HANDLE PipeHandle;
ULONG TransferFlags;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL;
struct URB *UrbLink;
struct URB_HCD_AREA hca;
}*/
rdr.ReadBytes(System.IntPtr.Size);
UInt32 TransferFlags = rdr.ReadUInt32();
UInt32 TransferBufferLength = rdr.ReadUInt32();
byte[] ptr_bytes = rdr.ReadBytes(System.IntPtr.Size);
System.IntPtr ptr_transfer_buffer = new System.IntPtr(BitConverter.ToUInt32(ptr_bytes, 0));
ptr_bytes = rdr.ReadBytes(System.IntPtr.Size);
System.IntPtr mdl_transfer_buffer = new System.IntPtr(BitConverter.ToUInt32(ptr_bytes, 0))
在读取所有值时检查所有值,大多数值似乎都是合理的,直到PMDL无效指针。这最终是一个大的负数而不是0(NULL)或有效地址。任何人都可以指出我正确的方向为什么会发生这种情况?谢谢。
答案 0 :(得分:1)
我不太明白你的问题...... TransferBufferMDL用于DirectIO情况,而TransferBuffer用于缓冲IO。
所以这两个中的一个永远是无效的。
希望这有帮助!
答案 1 :(得分:1)
MDL对象是仅在内核模式下可用的内存描述符。由于用户/内核模式拆分,x86系统上超过2 GB的虚拟地址(没有3GB交换机)位于内核虚拟地址空间中。