ReactOS  0.4.15-dev-3439-g2693a26
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 50 of file ntfs.c.

52 {
57  HANDLE DriverKey = NULL;
58 
59  TRACE_(NTFS, "DriverEntry(%p, '%wZ')\n", DriverObject, RegistryPath);
60 
62  sizeof(NTFS_GLOBAL_DATA),
63  &DeviceName,
65  0,
66  FALSE,
67  &DeviceObject);
68  if (!NT_SUCCESS(Status))
69  {
70  WARN_(NTFS, "IoCreateDevice failed with status: %lx\n", Status);
71  return Status;
72  }
73 
74  /* Initialize global data */
75  NtfsGlobalData = DeviceObject->DeviceExtension;
77 
81 
83 
85 
86  // Read registry to determine if write support should be enabled
90  NULL,
91  NULL);
92 
93  Status = ZwOpenKey(&DriverKey, KEY_READ, &Attributes);
94  if (NT_SUCCESS(Status))
95  {
99  ULONG ValueLength = sizeof(Buffer);
101 
102  RtlInitUnicodeString(&ValueName, L"MyDataDoesNotMatterSoEnableExperimentalWriteSupportForEveryNTFSVolume");
103 
104  Status = ZwQueryValueKey(DriverKey,
105  &ValueName,
107  Value,
108  ValueLength,
109  &ResultLength);
110 
111  if (NT_SUCCESS(Status) && Value->Data[0] == TRUE)
112  {
113  DPRINT1("\tEnabling write support on ALL NTFS volumes!\n");
115  }
116 
117  ZwClose(DriverKey);
118  }
119 
120  /* Keep trace of Driver Object */
122 
123  /* Initialize IRP functions array */
125 
126  /* Initialize CC functions array */
131 
136  DriverObject->FastIoDispatch = &NtfsGlobalData->FastIoDispatch;
137 
138  /* Initialize lookaside list for IRP contexts */
140  NULL, NULL, 0, sizeof(NTFS_IRP_CONTEXT), TAG_IRP_CTXT, 0);
141  /* Initialize lookaside list for FCBs */
143  NULL, NULL, 0, sizeof(NTFS_FCB), TAG_FCB, 0);
144  /* Initialize lookaside list for attributes contexts */
146  NULL, NULL, 0, sizeof(NTFS_ATTR_CONTEXT), TAG_ATT_CTXT, 0);
147 
148  /* Driver can't be unloaded */
149  DriverObject->DriverUnload = NULL;
150 
152 
153  /* Register file system */
156 
157  return STATUS_SUCCESS;
158 }
FAST_IO_WRITE NtfsFastIoWrite
Definition: ntfs.h:916
#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:36
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define L(x)
Definition: ntvdm.h:50
_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:114
_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:914
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
ULONG Type
Definition: ntfs.h:95
PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead
Definition: cctypes.h:42
FAST_IO_READ NtfsFastIoRead
Definition: ntfs.h:915
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:148
#define TAG_IRP_CTXT
Definition: ntfs.h:15
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1735
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1736
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:1734
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:1733
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
VOID NTAPI NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject)
Definition: ntfs.c:170
#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 170 of file ntfs.c.

171 {
172  DriverObject->MajorFunction[IRP_MJ_CREATE] = NtfsFsdDispatch;
173  DriverObject->MajorFunction[IRP_MJ_CLOSE] = NtfsFsdDispatch;
174  DriverObject->MajorFunction[IRP_MJ_CLEANUP] = NtfsFsdDispatch;
175  DriverObject->MajorFunction[IRP_MJ_READ] = NtfsFsdDispatch;
176  DriverObject->MajorFunction[IRP_MJ_WRITE] = NtfsFsdDispatch;
184 
185  return;
186 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_SET_VOLUME_INFORMATION
DRIVER_DISPATCH NtfsFsdDispatch
Definition: ntfs.h:892
#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