mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 07:41:51 +00:00
[NTFS] - Disable write support by default. Enable it via the registry.
[BOOTDATA] - Add a commented-out section to hivesys.inf which can add the required key to enable NTFS write support. svn path=/branches/GSoC_2016/NTFS/; revision=74685
This commit is contained in:
parent
7f762aac01
commit
037d88201d
5 changed files with 75 additions and 4 deletions
|
@ -1605,6 +1605,8 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","Group",0x00000000,"File System"
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","ImagePath",0x00020000,"system32\drivers\ntfs.sys"
|
HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","ImagePath",0x00020000,"system32\drivers\ntfs.sys"
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","Start",0x00010001,0x00000003
|
HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","Start",0x00010001,0x00000003
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","Type",0x00010001,0x00000002
|
HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","Type",0x00010001,0x00000002
|
||||||
|
; un-comment the line below to enable EXPERIMENTAL write-support on NTFS volumes:
|
||||||
|
;HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","MyDataDoesNotMatterSoEnableExperimentalWriteSupportForEveryNTFSVolume",0x00010001,0x00000001
|
||||||
|
|
||||||
; Null device driver
|
; Null device driver
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\Null","ErrorControl",0x00010001,0x00000000
|
HKLM,"SYSTEM\CurrentControlSet\Services\Null","ErrorControl",0x00010001,0x00000000
|
||||||
|
|
|
@ -486,6 +486,13 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
||||||
LARGE_INTEGER Zero;
|
LARGE_INTEGER Zero;
|
||||||
Zero.QuadPart = 0;
|
Zero.QuadPart = 0;
|
||||||
|
|
||||||
|
if (!NtfsGlobalData->EnableWriteSupport)
|
||||||
|
{
|
||||||
|
DPRINT1("NTFS write-support is EXPERIMENTAL and is disabled by default!\n");
|
||||||
|
NtfsCloseFile(DeviceExt, FileObject);
|
||||||
|
return STATUS_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: check for appropriate access
|
// TODO: check for appropriate access
|
||||||
|
|
||||||
ExAcquireResourceExclusiveLite(&(Fcb->MainResource), TRUE);
|
ExAcquireResourceExclusiveLite(&(Fcb->MainResource), TRUE);
|
||||||
|
@ -545,7 +552,14 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
||||||
RequestedDisposition == FILE_OPEN_IF ||
|
RequestedDisposition == FILE_OPEN_IF ||
|
||||||
RequestedDisposition == FILE_OVERWRITE_IF ||
|
RequestedDisposition == FILE_OVERWRITE_IF ||
|
||||||
RequestedDisposition == FILE_SUPERSEDE)
|
RequestedDisposition == FILE_SUPERSEDE)
|
||||||
{
|
{
|
||||||
|
if (!NtfsGlobalData->EnableWriteSupport)
|
||||||
|
{
|
||||||
|
DPRINT1("NTFS write-support is EXPERIMENTAL and is disabled by default!\n");
|
||||||
|
NtfsCloseFile(DeviceExt, FileObject);
|
||||||
|
return STATUS_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the file record on disk
|
// Create the file record on disk
|
||||||
Status = NtfsCreateFileRecord(DeviceExt, FileObject);
|
Status = NtfsCreateFileRecord(DeviceExt, FileObject);
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,15 @@ NtfsDispatch(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MJ_SET_INFORMATION:
|
case IRP_MJ_SET_INFORMATION:
|
||||||
Status = NtfsSetInformation(IrpContext);
|
if (!NtfsGlobalData->EnableWriteSupport)
|
||||||
|
{
|
||||||
|
DPRINT1("NTFS write-support is EXPERIMENTAL and is disabled by default!\n");
|
||||||
|
Status = STATUS_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = NtfsSetInformation(IrpContext);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MJ_DIRECTORY_CONTROL:
|
case IRP_MJ_DIRECTORY_CONTROL:
|
||||||
|
@ -98,7 +106,15 @@ NtfsDispatch(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MJ_WRITE:
|
case IRP_MJ_WRITE:
|
||||||
Status = NtfsWrite(IrpContext);
|
if (!NtfsGlobalData->EnableWriteSupport)
|
||||||
|
{
|
||||||
|
DPRINT1("NTFS write-support is EXPERIMENTAL and is disabled by default!\n");
|
||||||
|
Status = STATUS_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = NtfsWrite(IrpContext);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MJ_CLOSE:
|
case IRP_MJ_CLOSE:
|
||||||
|
|
|
@ -58,6 +58,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
||||||
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(DEVICE_NAME);
|
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(DEVICE_NAME);
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
OBJECT_ATTRIBUTES Attributes;
|
||||||
|
HANDLE DriverKey = NULL;
|
||||||
|
|
||||||
TRACE_(NTFS, "DriverEntry(%p, '%wZ')\n", DriverObject, RegistryPath);
|
TRACE_(NTFS, "DriverEntry(%p, '%wZ')\n", DriverObject, RegistryPath);
|
||||||
|
|
||||||
|
@ -84,6 +86,42 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
||||||
|
|
||||||
ExInitializeResourceLite(&NtfsGlobalData->Resource);
|
ExInitializeResourceLite(&NtfsGlobalData->Resource);
|
||||||
|
|
||||||
|
NtfsGlobalData->EnableWriteSupport = FALSE;
|
||||||
|
|
||||||
|
// Read registry to determine if write support should be enabled
|
||||||
|
InitializeObjectAttributes(&Attributes,
|
||||||
|
RegistryPath,
|
||||||
|
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = ZwOpenKey(&DriverKey, KEY_READ, &Attributes);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
UNICODE_STRING ValueName;
|
||||||
|
UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
|
||||||
|
PKEY_VALUE_PARTIAL_INFORMATION Value = (PKEY_VALUE_PARTIAL_INFORMATION)Buffer;
|
||||||
|
ULONG ValueLength = sizeof(Buffer);
|
||||||
|
ULONG ResultLength;
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&ValueName, L"MyDataDoesNotMatterSoEnableExperimentalWriteSupportForEveryNTFSVolume");
|
||||||
|
|
||||||
|
Status = ZwQueryValueKey(DriverKey,
|
||||||
|
&ValueName,
|
||||||
|
KeyValuePartialInformation,
|
||||||
|
Value,
|
||||||
|
ValueLength,
|
||||||
|
&ResultLength);
|
||||||
|
|
||||||
|
if (NT_SUCCESS(Status) && Value->Data[0] == TRUE)
|
||||||
|
{
|
||||||
|
DPRINT1("\tEnabling write support on ALL NTFS volumes!\n");
|
||||||
|
NtfsGlobalData->EnableWriteSupport = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZwClose(DriverKey);
|
||||||
|
}
|
||||||
|
|
||||||
/* Keep trace of Driver Object */
|
/* Keep trace of Driver Object */
|
||||||
NtfsGlobalData->DriverObject = DriverObject;
|
NtfsGlobalData->DriverObject = DriverObject;
|
||||||
|
|
||||||
|
@ -118,7 +156,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
||||||
IoRegisterFileSystem(NtfsGlobalData->DeviceObject);
|
IoRegisterFileSystem(NtfsGlobalData->DeviceObject);
|
||||||
ObReferenceObject(NtfsGlobalData->DeviceObject);
|
ObReferenceObject(NtfsGlobalData->DeviceObject);
|
||||||
|
|
||||||
return Status;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,7 @@ typedef struct
|
||||||
FAST_IO_DISPATCH FastIoDispatch;
|
FAST_IO_DISPATCH FastIoDispatch;
|
||||||
NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
|
NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
|
||||||
NPAGED_LOOKASIDE_LIST FcbLookasideList;
|
NPAGED_LOOKASIDE_LIST FcbLookasideList;
|
||||||
|
BOOLEAN EnableWriteSupport;
|
||||||
} NTFS_GLOBAL_DATA, *PNTFS_GLOBAL_DATA;
|
} NTFS_GLOBAL_DATA, *PNTFS_GLOBAL_DATA;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue