I am trying to create a filter driver to block file deletion operations, but I can't identify the IRP message on deleting files.
I worked with the code below; it works in windows 7 but not in windows version 8 or later.
if (pIrp->MajorFunction==IRP_MJ_WRITE || pIrp->MajorFunction==IRP_MJ_SET_INFORMATION ||
pIrp->MajorFunction==IRP_MJ_SET_VOLUME_INFORMATION || pIrp->MajorFunction==IRP_MJ_SET_SECURITY ||
pIrp->MajorFunction==IRP_MJ_SET_QUOTA)
{
DbgPrint("fdrv :Read only operation block");
Irp->IoStatus.Status = STATUS_ACCESS_DENIED;//Deny Access
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_ACCESS_DENIED;
}
exist 2 ways to delete file
FILE_DELETE_ON_CLOSEoption (NtCreateFile,NtOpenFile,IoCreateFileorNtDeleteFilealso internal open file withFILE_DELETE_ON_CLOSE). in this case will beIRP_MJ_CREATEZwSetInformationFilewithFileDispositionInformationorFileDispositionInformationEx. in this case will beIRP_MJ_SET_INFORMATION--