|
如何禁止刻录光驱刻录呢?
我在注册表{4D36E965-E325-11CE-BFC1-08002BE10318}这个位置挂载一个过滤驱动,
首先尝试禁用IRP_MJ_WRITE,失败。用Nero仍然可以将文件刻录到光盘上。
然后我用Dbgview发现,驱动不断进入IRP_MJ_SCSI,然后我在SCSI的派遣函数理禁用操作码为SCSIOP_WRITE的操作,重新测试,发现还是可以将文件刻录到光盘上。代码如下:
#pragma LOCKEDCODE
NTSTATUS DispatchForSCSI(IN PDEVICE_OBJECT fido, IN PIRP Irp)
{
KdPrint((DRIVERNAME " - Enter DispatchForSCSI \n"));
NTSTATUS status;
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fido->DeviceExtension;
status = IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
if (!NT_SUCCESS(status))
return CompleteRequest(Irp, status, 0);
PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation( Irp );
PSCSI_REQUEST_BLOCK CurSrb = irpStack->Parameters.Scsi.Srb;
PCDB cdb = (PCDB)CurSrb->Cdb;
UCHAR opCode = cdb->CDB6GENERIC.OperationCode;
if(opCode == SCSIOP_WRITE)
{
KdPrint((DRIVERNAME " - OperationCode is SCSIOP_WRITE \n"));
Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
Irp->IoStatus.Information = 0;
IoCompleteRequest( Irp, IO_NO_INCREMENT );
IoReleaseRemoveLock(&pdx->RemoveLock, Irp);
return STATUS_ACCESS_DENIED;
}
IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(pdx->LowerDeviceObject, Irp);
IoReleaseRemoveLock(&pdx->RemoveLock, Irp);
return status;
}
在上次刻录时我发现,刻录文件时,反复进入IRP_MJ_SCSI 和 IRP_MJ_DEVICE_CONTROL的派遣函数。
我想知道如何获取IRP_MJ_DEVICE_CONTROL的操作码?
还有,最重要的,有人做过相关的东西吗?该如何禁止刻录光驱刻录光盘? |
|