驱动小牛
![]() |
阅读:3917回复:2
请教关于 IoCopyCurrentIrpStackLocationToNext( Irp )
查到DDK的宏定义,发现它的结果只是(Irp)->Tail.Overlay.CurrentStackLocation - 1的指向位置也变成了(Irp)->Tail.Overlay.CurrentStackLocation 指向位置,是不是下一个StackLocation都是可以随便改啊?还是说下一个都是空的随便用?不会出问题么?
//++ // // VOID // IoCopyCurrentIrpStackLocationToNext( // IN PIRP Irp // ) // // Routine Description: // // This routine is invoked to copy the IRP stack arguments and file // pointer from the current IrpStackLocation to the next // in an I/O Request Packet (IRP). // // If the caller wants to call IoCallDriver with a completion routine // but does not wish to change the arguments otherwise, // the caller first calls IoCopyCurrentIrpStackLocationToNext, // then IoSetCompletionRoutine, then IoCallDriver. // // Arguments: // // Irp - Pointer to the I/O Request Packet. // // Return Value: // // None. // //-- #define IoCopyCurrentIrpStackLocationToNext( Irp ) { \ PIO_STACK_LOCATION irpSp; \ PIO_STACK_LOCATION nextIrpSp; \ irpSp = IoGetCurrentIrpStackLocation( (Irp) ); \ nextIrpSp = IoGetNextIrpStackLocation( (Irp) ); \ RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \ nextIrpSp->Control = 0; } 而 #define IoGetCurrentIrpStackLocation( Irp ) ( (Irp)->Tail.Overlay.CurrentStackLocation ) #define IoGetNextIrpStackLocation( Irp ) (\ (Irp)->Tail.Overlay.CurrentStackLocation - 1 ) |
驱动小牛
![]() |
沙发#
发布于:2008-03-11 14:50
Re:请教关于 IoCopyCurrentIrpStackLocationToNext(
非常感谢,研究中... |
板凳#
发布于:2008-03-10 18:15
一下是我对IoCopyCurrentIrpStackLocationToNext( Irp )的理解:
在一个IRP向下传递的过程中,下层的堆栈是未初始化的,所以在IoCopyCurrentIrpStackLocationToNext( Irp )宏定义中用 RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); 将当前堆栈的参数拷贝到下一个堆栈,并将在随后设置完成例程。当然,你如果不想设置完成例程,可以使用IoSkipCurrentIrpStackLocation( Irp )跳过当前堆栈。还有,如果你想设置下层堆栈的参数,可以使用IoSetNextIrpStackLocation(Irp ),详细的描述在附件中。 |
|
|