chrysanth
驱动牛犊
驱动牛犊
  • 注册日期2007-05-02
  • 最后登录2010-02-02
  • 粉丝0
  • 关注0
  • 积分9分
  • 威望129点
  • 贡献值0点
  • 好评度61点
  • 原创分0分
  • 专家分0分
阅读:1872回复:2

IoGetNextIrpStackLocation(irp);

楼主#
更多 发布于:2007-09-19 09:12
下面代码中  IoGetNextIrpStackLocation(irp);  是创建这个IRP么?   Thanks.

//----------------------------------------------------------------------
//
// FilemonQueryFile
//
// This function retrieves the "standard" information for the
// underlying file system, asking for the filename in particular.
//
//----------------------------------------------------------------------
BOOLEAN
FilemonQueryFile(
    PDEVICE_OBJECT DeviceObject,
    PFILE_OBJECT FileObject,
    FILE_INFORMATION_CLASS FileInformationClass,
    PVOID FileQueryBuffer,
    ULONG FileQueryBufferLength
    )
{
    PIRP irp;
    KEVENT event;
    IO_STATUS_BLOCK IoStatusBlock;
    PIO_STACK_LOCATION ioStackLocation;

    DbgPrint(("Getting file name for %x\n", FileObject));

    //
    // Initialize the event
    //
    KeInitializeEvent(&event, SynchronizationEvent, FALSE);

    //
    // Allocate an irp for this request.  This could also come from a
    // private pool, for instance.
    //
    irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
    if(!irp) {

        //
        // Failure!
        //
        return FALSE;
    }
  
    //
    // Build the IRP's main body
    //  
    irp->AssociatedIrp.SystemBuffer = FileQueryBuffer;
    irp->UserEvent = &event;
    irp->UserIosb = &IoStatusBlock;
    irp->Tail.Overlay.Thread = PsGetCurrentThread();
    irp->Tail.Overlay.OriginalFileObject = FileObject;
    irp->RequestorMode = KernelMode;
    irp->Flags = 0;

    //
    // Set up the I/O stack location.
    //
    ioStackLocation = IoGetNextIrpStackLocation(irp);
    ioStackLocation->MajorFunction = IRP_MJ_QUERY_INFORMATION;
    ioStackLocation->DeviceObject = DeviceObject;
    ioStackLocation->FileObject = FileObject;
    ioStackLocation->Parameters.QueryFile.Length = FileQueryBufferLength;
    ioStackLocation->Parameters.QueryFile.FileInformationClass = FileInformationClass;

    //
    // Set the completion routine.
    //
    IoSetCompletionRoutine(irp, FilemonQueryFileComplete, 0, TRUE, TRUE, TRUE);

    //
    // Send it to the FSD
    //
    (void) IoCallDriver(DeviceObject, irp);

    //
    // Wait for the I/O
    //
    KeWaitForSingleObject(&event, Executive, KernelMode, TRUE, 0);

    //
    // Done! Note that since our completion routine frees the IRP we cannot
    // touch the IRP now.
    //
    return NT_SUCCESS( IoStatusBlock.Status );
}
devil209
驱动牛犊
驱动牛犊
  • 注册日期2007-01-25
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分732分
  • 威望94点
  • 贡献值0点
  • 好评度73点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2007-09-20 00:01
是设置iostacklocation,你看看IoGetNextIrpStackLocation(irp)的代码就知道了。
abc13271552
驱动小牛
驱动小牛
  • 注册日期2007-08-13
  • 最后登录2023-12-05
  • 粉丝0
  • 关注0
  • 积分34分
  • 威望552点
  • 贡献值0点
  • 好评度160点
  • 原创分0分
  • 专家分0分
  • 社区居民
板凳#
发布于:2007-09-20 08:55
构造后,向下传吧
驱网无线,快乐无限
游客

返回顶部