阅读:887回复:1
请帮我解释一下这个DispatchRead例程
NTSTATUS DispatchRead (
IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp ) { NTSTATUS status = STATUS_SUCCESS; PVOID userBuffer; //DebugView 输出 userBuffer 是一个字符串 PVOID 是什么数据类型? ULONG xferSize; // The stack location contains the user buffer info PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation( pIrp ); // Dig out the Device Extension from the Device object PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION) pDevObj->DeviceExtension; // Determine the length of the request xferSize = pIrpStack->Parameters.Read.Length; // Obtain user buffer pointer userBuffer = pIrp->AssociatedIrp.SystemBuffer; // Don't transfer more than the user's request xferSize = (xferSize < pDevExt->deviceBufferSize) ? xferSize : pDevExt->deviceBufferSize; // Now copy the pool buffer into user space // 把需要的读数据copy到 useBuffer 中 RtlCopyMemory( userBuffer, pDevExt->deviceBuffer, xferSize );//这样拷贝到内存中,API调用该例程,如何得到数据? userBuffer是一个指针码?在这里如果用pIrp->AssociatedIrp.SystemBuffer 代替userBuffer 可以? #ifdef DEBUGMSG DbgPrint( "\n*******************\n"); DbgPrint( "%d", pDevExt->deviceBufferSize); DbgPrint( "%s", pDevExt->deviceBuffer); DbgPrint( "\n*******************\n"); #endif // Free the temporary pool buffer ExFreePool( pDevExt->deviceBuffer );// 释放内存 读出之后就释放出来 pDevExt->deviceBuffer = NULL; pDevExt->deviceBufferSize = 0; // Now complete the IRP pIrp->IoStatus.Status = status; pIrp->IoStatus.Information = xferSize; // bytes xfered IoCompleteRequest( pIrp, IO_NO_INCREMENT ); return status; } |
|
最新喜欢:rhpeng |
沙发#
发布于:2005-01-25 12:13
//DebugView 输出 userBuffer 是一个字符串 PVOID 是什么数据类型?
是PVOID “void *”的意思 RtlCopyMemory( userBuffer, pDevExt->deviceBuffer, xferSize );//这样拷贝到内存中,API调用该例程,如何得到数据? userBuffer是一个指针码?在这里如果用pIrp->AssociatedIrp.SystemBuffer 代替userBuffer 可以? 对,userBuffer是一个指针 pIrp->AssociatedIrp.SystemBuffer 和userBuffer ,具体看使用什么方式 |
|
|