satanli1982
驱动牛犊
驱动牛犊
  • 注册日期2004-03-07
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分7分
  • 威望3点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2161回复:2

请问怎样在filter driver中创建并发送设置文件FILE_BASIC_INFORMATION属性的IRP?

楼主#
更多 发布于:2004-05-26 18:18
我在程序中用如下方法却不行,请问问题出在哪里?先谢了~_~


BOOLEAN SetFileBasicInformation(PFILE_OBJECT FileObject,
PFILE_BASIC_INFORMATION BasicInformation,
PIO_STATUS_BLOCK IoStatusBlock)
{
PIRP irp;
PDEVICE_OBJECT fsdDevice = IoGetRelatedDeviceObject(FileObject);
KEVENT event;
PIO_STACK_LOCATION ioStackLocation;

//
// Allocate an irp for this request. This could also come from a
// private pool, for instance.
//
irp = IoAllocateIrp(fsdDevice->StackSize, FALSE);
if (!irp) {
//
// Failure!
//
return FALSE;
}
irp->AssociatedIrp.SystemBuffer = BasicInformation;
irp->UserEvent = &event;
irp->UserIosb = IoStatusBlock;
irp->Tail.Overlay.Thread = PsGetCurrentThread();
irp->Tail.Overlay.OriginalFileObject = FileObject;
irp->RequestorMode = KernelMode;
//
// Initialize the event
//
KeInitializeEvent(&event, SynchronizationEvent, FALSE);
//
// Set up the I/O stack location.
//
ioStackLocation = IoGetNextIrpStackLocation(irp);
ioStackLocation->MajorFunction = IRP_MJ_SET_INFORMATION;
ioStackLocation->DeviceObject = fsdDevice;
ioStackLocation->FileObject = FileObject;
ioStackLocation->Parameters.SetFile.Length = sizeof(FILE_BASIC_INFORMATION);
ioStackLocation->Parameters.SetFile.FileInformationClass = FileBasicInformation;
//
// Set the completion routine.
//
IoSetCompletionRoutine(irp, IoSetBasicInfoCompletion, 0, TRUE, TRUE, TRUE);
//
// Send it to the FSD
//
(void) IoCallDriver(fsdDevice, irp);
//
// Wait for the I/O
//
KeWaitForSingleObject(&event, Executive, KernelMode, TRUE, 0);
//
// Done!
//
return NT_SUCCESS( IoStatusBlock->Status );
}


NTSTATUS
IoSetBasicInfoCompletion(
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context
)
{
    //
    // Copy the status information back into the \"user\" IOSB.
    //
    *Irp->UserIosb = Irp->IoStatus;

    if( !NT_SUCCESS(Irp->IoStatus.Status) ) {

        DbgPrint((\"   ERROR ON IRP: \\n\"));
    }
    //
    // Set the user event - wakes up the mainline code doing this.
    //
    KeSetEvent(Irp->UserEvent, 0, FALSE);
    
    //
    // Free the IRP now that we are done with it.
    //
    IoFreeIrp(Irp);
    
    //
    // We return STATUS_MORE_PROCESSING_REQUIRED because this \"magic\" return value
    // tells the I/O Manager that additional processing will be done by this driver
    // to the IRP - in fact, it might (as it is in this case) already BE done - and
    // the IRP cannot be completed.
    //
    return STATUS_MORE_PROCESSING_REQUIRED;
}
satanli1982
驱动牛犊
驱动牛犊
  • 注册日期2004-03-07
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分7分
  • 威望3点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2004-05-27 11:42
大家帮忙呀,万分感谢!!!!!
sdddddfdg
驱动牛犊
驱动牛犊
  • 注册日期2012-06-16
  • 最后登录2012-06-22
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望21点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2012-06-16 16:05
这个论坛真垃圾
游客

返回顶部