zhoujiamurong
驱动小牛
驱动小牛
  • 注册日期2006-03-20
  • 最后登录2009-05-06
  • 粉丝4
  • 关注0
  • 积分1081分
  • 威望360点
  • 贡献值0点
  • 好评度215点
  • 原创分0分
  • 专家分0分
阅读:3917回复:2

请教关于 IoCopyCurrentIrpStackLocationToNext( Irp )

楼主#
更多 发布于:2008-03-07 16:27
查到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 )
zhoujiamurong
驱动小牛
驱动小牛
  • 注册日期2006-03-20
  • 最后登录2009-05-06
  • 粉丝4
  • 关注0
  • 积分1081分
  • 威望360点
  • 贡献值0点
  • 好评度215点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2008-03-11 14:50
Re:请教关于 IoCopyCurrentIrpStackLocationToNext(
非常感谢,研究中...
zhiqiang0071
驱动牛犊
驱动牛犊
  • 注册日期2007-07-15
  • 最后登录2010-01-26
  • 粉丝1
  • 关注0
  • 积分0分
  • 威望14点
  • 贡献值0点
  • 好评度13点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2008-03-10 18:15
一下是我对IoCopyCurrentIrpStackLocationToNext( Irp )的理解:
在一个IRP向下传递的过程中,下层的堆栈是未初始化的,所以在IoCopyCurrentIrpStackLocationToNext( Irp )宏定义中用 RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); 将当前堆栈的参数拷贝到下一个堆栈,并将在随后设置完成例程。当然,你如果不想设置完成例程,可以使用IoSkipCurrentIrpStackLocation( Irp )跳过当前堆栈。还有,如果你想设置下层堆栈的参数,可以使用IoSetNextIrpStackLocation(Irp ),详细的描述在附件中。
附件名称/大小 下载次数 最后更新
Different ways of handling IRPs.rar (164KB)  101 2008-03-10 18:15
游客

返回顶部