ReactOS  0.4.15-dev-1384-g878186b
ntfs.c File Reference
#include "ntfs.h"
#include <debug.h>
Include dependency graph for ntfs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 
VOID NTAPI NtfsInitializeFunctionPointers (PDRIVER_OBJECT DriverObject)
 

Variables

PNTFS_GLOBAL_DATA NtfsGlobalData = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 31 of file ntfs.c.

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 55 of file ntfs.c.

57 {
62  HANDLE DriverKey = NULL;
63 
64  TRACE_(NTFS, "DriverEntry(%p, '%wZ')\n", DriverObject, RegistryPath);
65 
67  sizeof(NTFS_GLOBAL_DATA),
68  &DeviceName,
70  0,
71  FALSE,
72  &DeviceObject);
73  if (!NT_SUCCESS(Status))
74  {
75  WARN_(NTFS, "IoCreateDevice failed with status: %lx\n", Status);
76  return Status;
77  }
78 
79  /* Initialize global data */
80  NtfsGlobalData = DeviceObject->DeviceExtension;
82 
86 
88 
90 
91  // Read registry to determine if write support should be enabled
95  NULL,
96  NULL);
97 
98  Status = ZwOpenKey(&DriverKey, KEY_READ, &Attributes);
99  if (NT_SUCCESS(Status))
100  {
102  UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
104  ULONG ValueLength = sizeof(Buffer);
106 
107  RtlInitUnicodeString(&ValueName, L"MyDataDoesNotMatterSoEnableExperimentalWriteSupportForEveryNTFSVolume");
108 
109  Status = ZwQueryValueKey(DriverKey,
110  &ValueName,
112  Value,
113  ValueLength,
114  &ResultLength);
115 
116  if (NT_SUCCESS(Status) && Value->Data[0] == TRUE)
117  {
118  DPRINT1("\tEnabling write support on ALL NTFS volumes!\n");
120  }
121 
122  ZwClose(DriverKey);
123  }
124 
125  /* Keep trace of Driver Object */
127 
128  /* Initialize IRP functions array */
130 
131  /* Initialize CC functions array */
136 
141  DriverObject->FastIoDispatch = &NtfsGlobalData->FastIoDispatch;
142 
143  /* Initialize lookaside list for IRP contexts */
145  NULL, NULL, 0, sizeof(NTFS_IRP_CONTEXT), TAG_IRP_CTXT, 0);
146  /* Initialize lookaside list for FCBs */
148  NULL, NULL, 0, sizeof(NTFS_FCB), TAG_FCB, 0);
149  /* Initialize lookaside list for attributes contexts */
151  NULL, NULL, 0, sizeof(NTFS_ATTR_CONTEXT), TAG_ATT_CTXT, 0);
152 
153  /* Driver can't be unloaded */
154  DriverObject->DriverUnload = NULL;
155 
157 
158  /* Register file system */
161 
162  return STATUS_SUCCESS;
163 }
FAST_IO_WRITE NtfsFastIoWrite
Definition: ntfs.h:912
#define TAG_FCB
Definition: vfat.h:547
PDRIVER_OBJECT DriverObject
Definition: ntfs.h:147
#define NTFS_TYPE_GLOBAL_DATA
Definition: ntfs.h:91
#define TAG_ATT_CTXT
Definition: ntfs.h:16
NPAGED_LOOKASIDE_LIST AttrCtxtLookasideList
Definition: ntfs.h:154
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NPAGED_LOOKASIDE_LIST FcbLookasideList
Definition: ntfs.h:153
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
Definition: cdstruc.h:902
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
VOID NTAPI NtfsRelLazyWrite(PVOID Context)
Definition: fastio.c:51
BOOLEAN NTAPI NtfsAcqReadAhead(PVOID Context, BOOLEAN Wait)
Definition: fastio.c:60
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:41
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define FALSE
Definition: types.h:117
ERESOURCE Resource
Definition: ntfs.h:146
struct _FAST_IO_DISPATCH FAST_IO_DISPATCH
Definition: bufpool.h:45
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:113
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
FAST_IO_CHECK_IF_POSSIBLE NtfsFastIoCheckIfPossible
Definition: ntfs.h:910
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:218
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite
Definition: cctypes.h:39
PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead
Definition: cctypes.h:41
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
ULONG Type
Definition: ntfs.h:95
PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead
Definition: cctypes.h:42
FAST_IO_READ NtfsFastIoRead
Definition: ntfs.h:911
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:148
#define TAG_IRP_CTXT
Definition: ntfs.h:15
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1715
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1716
NPAGED_LOOKASIDE_LIST IrpContextLookasideList
Definition: ntfs.h:152
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks
Definition: ntfs.h:149
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI NtfsRelReadAhead(PVOID Context)
Definition: fastio.c:72
NTFSIDENTIFIER Identifier
Definition: ntfs.h:145
VOID NTAPI IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:987
#define ObReferenceObject
Definition: obfuncs.h:204
PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite
Definition: cctypes.h:40
FAST_IO_DISPATCH FastIoDispatch
Definition: ntfs.h:151
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible
Definition: iotypes.h:1714
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define DEVICE_NAME
Definition: ext2fs.h:137
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOLEAN NTAPI NtfsAcqLazyWrite(PVOID Context, BOOLEAN Wait)
Definition: fastio.c:39
#define WARN_(ch,...)
Definition: debug.h:157
BOOLEAN EnableWriteSupport
Definition: ntfs.h:155
ULONG Size
Definition: ntfs.h:96
ULONG SizeOfFastIoDispatch
Definition: iotypes.h:1713
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
VOID NTAPI NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject)
Definition: ntfs.c:175
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:271

◆ NtfsInitializeFunctionPointers()

VOID NTAPI NtfsInitializeFunctionPointers ( PDRIVER_OBJECT  DriverObject)

Definition at line 175 of file ntfs.c.

176 {
177  DriverObject->MajorFunction[IRP_MJ_CREATE] = NtfsFsdDispatch;
178  DriverObject->MajorFunction[IRP_MJ_CLOSE] = NtfsFsdDispatch;
179  DriverObject->MajorFunction[IRP_MJ_CLEANUP] = NtfsFsdDispatch;
180  DriverObject->MajorFunction[IRP_MJ_READ] = NtfsFsdDispatch;
181  DriverObject->MajorFunction[IRP_MJ_WRITE] = NtfsFsdDispatch;
189 
190  return;
191 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_SET_VOLUME_INFORMATION
DRIVER_DISPATCH NtfsFsdDispatch
Definition: ntfs.h:888
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_CLEANUP
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by DriverEntry().

Variable Documentation

◆ NtfsGlobalData