How to get newly mounted volume Label using filter driver
Hi all,
i used IRP_MJ_FILE_SYSTEM_CONTROL to monitor IRP_MN_MOUNT_VOLUME requests:
what should i do?!
Hi all,
i used IRP_MJ_FILE_SYSTEM_CONTROL to monitor IRP_MN_MOUNT_VOLUME requests:
Code: Select all
and here is my CompletionRoutine :NTSTATUS FsFilterFsControl(
__in PDEVICE_OBJECT DeviceObject,
__in PIRP Irp
)
{
OBJECT_NAME_INFORMATION ONI;
ULONG len;
PIO_STACK_LOCATION irpSp = NULL;
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION nextLoc;
PFSFILTER_DEVICE_EXTENSION pDevExt = (PFSFILTER_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
irpSp = IoGetCurrentIrpStackLocation(Irp);
switch(irpSp->MinorFunction)
{
case IRP_MN_MOUNT_VOLUME:
DbgPrint("Mounting...");
dev[i] = irpSp->Parameters.MountVolume.Vpb->RealDevice;
i=(i+1)%5;
//if(ObQueryNameString(irpSp->Parameters.MountVolume.Vpb->RealDevice,&ONI,sizeof(ONI),&len)==STATUS_SUCCESS)
//DbgPrint("\nVOLUME : %wZ\n",ONI.Name);
nextLoc = IoGetNextIrpStackLocation(Irp);
*nextLoc= *(IoGetCurrentIrpStackLocation(Irp));
IoSetCompletionRoutine(
Irp,
CompletionRoutine,
irpSp->Parameters.MountVolume.Vpb->RealDevice,//DeviceObject,//
TRUE,
TRUE,
TRUE
);
nIrpsToComplete= nIrpsToComplete + 1;
ntStatus= IoCallDriver(
pDevExt->AttachedToDeviceObject,
Irp
);
break;
default:
return FsFilterDispatchPassThrough(DeviceObject, Irp);
break;
}
return ntStatus;
}
Code: Select all
But it always says... not mounted...NTSTATUS CompletionRoutine( IN PDEVICE_OBJECT pDeviceObject,
IN PIRP pIrp,
IN PVOID Context
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION irpSp = NULL;
irpSp = IoGetCurrentIrpStackLocation(pIrp);
DbgPrint("\nCroutine\n");if(IsVolumeMounted(pDeviceObject))
DbgPrint("\n%wZ\n",pDeviceObject->Vpb->VolumeLabel);
else
DbgPrint("\nNotMounted!\n");
//DbgPrint("\n%wZ\n",irpSp->Parameters.MountVolume.Vpb->VolumeLabel);
/*for(j=0;j<5;j++)if(dev[j]!=NULL)if(IsVolumeMounted(dev[j]))
DbgPrint("\n%wZ\n",dev[j]->Vpb->VolumeLabel);
else
DbgPrint("\nNotMounted!\n");*/
if((*pIrp).PendingReturned)
{
IoMarkIrpPending(pIrp);
}
nIrpsToComplete = nIrpsToComplete - 1;
return ntStatus;
}
what should i do?!