[FASTFAT] Deny dismounting system volume or a volume with a pagefile

This commit is contained in:
Pierre Schweitzer 2018-05-16 21:44:47 +02:00
parent 7c3cff3a68
commit d37280efaa
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B
3 changed files with 13 additions and 0 deletions

View file

@ -778,6 +778,7 @@ VfatCreateFile(
if (PagingFileCreate)
{
pFcb->Flags |= FCB_IS_PAGE_FILE;
SetFlag(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE);
}
}
else
@ -897,6 +898,7 @@ VfatCreateFile(
else
{
pFcb->Flags |= FCB_IS_PAGE_FILE;
SetFlag(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE);
}
}
else

View file

@ -777,6 +777,10 @@ VfatMount(
}
VolumeFcb->Flags |= VCB_IS_DIRTY;
if (BooleanFlagOn(Vpb->RealDevice->Flags, DO_SYSTEM_BOOT_PARTITION))
{
SetFlag(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE);
}
FsRtlNotifyVolumeEvent(DeviceExt->FATFileObject, FSRTL_VOLUME_MOUNT);
FsRtlNotifyInitializeSync(&DeviceExt->NotifySync);
@ -1174,6 +1178,12 @@ VfatDismountVolume(
return STATUS_ACCESS_DENIED;
}
/* Deny dismount of boot volume */
if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE))
{
return STATUS_ACCESS_DENIED;
}
/* Race condition? */
if (BooleanFlagOn(DeviceExt->Flags, VCB_DISMOUNT_PENDING))
{

View file

@ -239,6 +239,7 @@ typedef union _DIR_ENTRY DIR_ENTRY, *PDIR_ENTRY;
#define VCB_VOLUME_LOCKED 0x0001
#define VCB_DISMOUNT_PENDING 0x0002
#define VCB_IS_FATX 0x0004
#define VCB_IS_SYS_OR_HAS_PAGE 0x0008
#define VCB_IS_DIRTY 0x4000 /* Volume is dirty */
#define VCB_CLEAR_DIRTY 0x8000 /* Clean dirty flag at shutdown */