ReactOS  0.4.15-dev-3302-ga37d9a4
fatinit.c File Reference
#include "fatprocs.h"
Include dependency graph for fatinit.c:

Go to the source code of this file.

Macros

#define COMPATIBILITY_MODE_KEY_NAME   L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\FileSystem"
 
#define COMPATIBILITY_MODE_VALUE_NAME   L"Win31FileSystem"
 
#define CODE_PAGE_INVARIANCE_VALUE_NAME   L"FatDisableCodePageInvariance"
 
#define KEY_WORK_AREA
 
#define REGISTRY_HARDWARE_DESCRIPTION_W   L"\\Registry\\Machine\\Hardware\\DESCRIPTION\\System"
 
#define REGISTRY_MACHINE_IDENTIFIER_W   L"Identifier"
 
#define FUJITSU_FMR_NAME_W   L"FUJITSU FMR-"
 

Functions

NTSTATUS NTAPI DriverEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
 
 _Function_class_ (DRIVER_UNLOAD)
 
NTSTATUS FatGetCompatibilityModeValue (IN PUNICODE_STRING ValueName, IN OUT PULONG Value)
 
BOOLEAN FatIsFujitsuFMR ()
 

Variables

DRIVER_INITIALIZE DriverEntry
 

Macro Definition Documentation

◆ CODE_PAGE_INVARIANCE_VALUE_NAME

#define CODE_PAGE_INVARIANCE_VALUE_NAME   L"FatDisableCodePageInvariance"

◆ COMPATIBILITY_MODE_KEY_NAME

#define COMPATIBILITY_MODE_KEY_NAME   L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\FileSystem"

◆ COMPATIBILITY_MODE_VALUE_NAME

#define COMPATIBILITY_MODE_VALUE_NAME   L"Win31FileSystem"

◆ FUJITSU_FMR_NAME_W

#define FUJITSU_FMR_NAME_W   L"FUJITSU FMR-"

◆ KEY_WORK_AREA

#define KEY_WORK_AREA
Value:
sizeof(ULONG)) + 64)
struct _KEY_VALUE_FULL_INFORMATION KEY_VALUE_FULL_INFORMATION
unsigned int ULONG
Definition: retypes.h:1

◆ REGISTRY_HARDWARE_DESCRIPTION_W

#define REGISTRY_HARDWARE_DESCRIPTION_W   L"\\Registry\\Machine\\Hardware\\DESCRIPTION\\System"

◆ REGISTRY_MACHINE_IDENTIFIER_W

#define REGISTRY_MACHINE_IDENTIFIER_W   L"Identifier"

Function Documentation

◆ _Function_class_()

_Function_class_ ( DRIVER_UNLOAD  )

Definition at line 27 of file fatinit.c.

94 {
98  FS_FILTER_CALLBACKS FilterCallbacks;
100  ULONG Value;
101 
103 
104  //
105  // Create the device object for disks. To avoid problems with filters who
106  // know this name, we must keep it.
107  //
108 
111  0,
112  &UnicodeString,
114  0,
115  FALSE,
117 
118  if (!NT_SUCCESS( Status )) {
119  return Status;
120  }
121 
122  //
123  // Create the device object for "cdroms".
124  //
125 
126  RtlInitUnicodeString( &UnicodeString, L"\\FatCdrom" );
128  0,
129  &UnicodeString,
131  0,
132  FALSE,
134 
135  if (!NT_SUCCESS( Status )) {
137  return Status;
138  }
139 
140 #ifdef _MSC_VER
141 #pragma prefast( push )
142 #pragma prefast( disable:28155, "these are all correct" )
143 #pragma prefast( disable:28169, "these are all correct" )
144 #pragma prefast( disable:28175, "this is a filesystem, touching FastIoDispatch is allowed" )
145 #endif
146 
147  DriverObject->DriverUnload = FatUnload;
148 
149  //
150  // Note that because of the way data caching is done, we set neither
151  // the Direct I/O or Buffered I/O bit in DeviceObject->Flags. If
152  // data is not in the cache, or the request is not buffered, we may,
153  // set up for Direct I/O by hand.
154  //
155 
156  //
157  // Initialize the driver object with this driver's entry points.
158  //
159 
160  DriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH)FatFsdCreate;
161  DriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH)FatFsdClose;
162  DriverObject->MajorFunction[IRP_MJ_READ] = (PDRIVER_DISPATCH)FatFsdRead;
163  DriverObject->MajorFunction[IRP_MJ_WRITE] = (PDRIVER_DISPATCH)FatFsdWrite;
164  DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = (PDRIVER_DISPATCH)FatFsdQueryInformation;
165  DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = (PDRIVER_DISPATCH)FatFsdSetInformation;
166  DriverObject->MajorFunction[IRP_MJ_QUERY_EA] = (PDRIVER_DISPATCH)FatFsdQueryEa;
167  DriverObject->MajorFunction[IRP_MJ_SET_EA] = (PDRIVER_DISPATCH)FatFsdSetEa;
168  DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = (PDRIVER_DISPATCH)FatFsdFlushBuffers;
169  DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = (PDRIVER_DISPATCH)FatFsdQueryVolumeInformation;
170  DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = (PDRIVER_DISPATCH)FatFsdSetVolumeInformation;
171  DriverObject->MajorFunction[IRP_MJ_CLEANUP] = (PDRIVER_DISPATCH)FatFsdCleanup;
172  DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = (PDRIVER_DISPATCH)FatFsdDirectoryControl;
173  DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = (PDRIVER_DISPATCH)FatFsdFileSystemControl;
174  DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] = (PDRIVER_DISPATCH)FatFsdLockControl;
175  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = (PDRIVER_DISPATCH)FatFsdDeviceControl;
176  DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = (PDRIVER_DISPATCH)FatFsdShutdown;
177  DriverObject->MajorFunction[IRP_MJ_PNP] = (PDRIVER_DISPATCH)FatFsdPnp;
178 
179  DriverObject->FastIoDispatch = &FatFastIoDispatch;
180 
182 
184  FatFastIoDispatch.FastIoCheckIfPossible = FatFastIoCheckIfPossible; // CheckForFastIo
187  FatFastIoDispatch.FastIoQueryBasicInfo = FatFastQueryBasicInfo; // QueryBasicInfo
188  FatFastIoDispatch.FastIoQueryStandardInfo = FatFastQueryStdInfo; // QueryStandardInfo
189  FatFastIoDispatch.FastIoLock = FatFastLock; // Lock
190  FatFastIoDispatch.FastIoUnlockSingle = FatFastUnlockSingle; // UnlockSingle
191  FatFastIoDispatch.FastIoUnlockAll = FatFastUnlockAll; // UnlockAll
192  FatFastIoDispatch.FastIoUnlockAllByKey = FatFastUnlockAllByKey; // UnlockAllByKey
193  FatFastIoDispatch.FastIoQueryNetworkOpenInfo = FatFastQueryNetworkOpenInfo;
194  FatFastIoDispatch.AcquireForCcFlush = FatAcquireForCcFlush;
195  FatFastIoDispatch.ReleaseForCcFlush = FatReleaseForCcFlush;
200 
201 #ifdef _MSC_VER
202 #pragma prefast( pop )
203 #endif
204 
205  //
206  // Initialize the filter callbacks we use.
207  //
208 
209  RtlZeroMemory( &FilterCallbacks,
210  sizeof(FS_FILTER_CALLBACKS) );
211 
212  FilterCallbacks.SizeOfFsFilterCallbacks = sizeof(FS_FILTER_CALLBACKS);
213  FilterCallbacks.PreAcquireForSectionSynchronization = FatFilterCallbackAcquireForCreateSection;
214 
216  &FilterCallbacks );
217 
218  if (!NT_SUCCESS( Status )) {
219 
222  return Status;
223  }
224 
225  //
226  // Initialize the global data structures
227  //
228 
229  //
230  // The FatData record
231  //
232 
233  RtlZeroMemory( &FatData, sizeof(FAT_DATA));
234 
236  FatData.NodeByteSize = sizeof(FAT_DATA);
237 
239 
243 
244  //
245  // This list head keeps track of closes yet to be done.
246  //
247 
250 
252 
253  if (FatData.FatCloseItem == NULL) {
257  }
258 
259  //
260  // Allocate the zero page
261  //
262 
263  FatData.ZeroPage = ExAllocatePoolWithTag( NonPagedPoolNx, PAGE_SIZE, 'ZtaF' );
264  if (FatData.ZeroPage == NULL) {
268  }
270 
271 
272  //
273  // Now initialize our general purpose spinlock (gag) and figure out how
274  // deep and wide we want our delayed lists (along with fooling ourselves
275  // about the lookaside depths).
276  //
277 
279 
280  switch ( MmQuerySystemSize() ) {
281 
282  case MmSmallSystem:
283 
284  MaxDepth = 4;
286  break;
287 
288  case MmMediumSystem:
289 
290  MaxDepth = 8;
292  break;
293 
294  case MmLargeSystem:
295  default:
296 
297  MaxDepth = 16;
299  break;
300  }
301 
302 
303  //
304  // Initialize the cache manager callback routines
305  //
306 
307  FatData.CacheManagerCallbacks.AcquireForLazyWrite = &FatAcquireFcbForLazyWrite;
308  FatData.CacheManagerCallbacks.ReleaseFromLazyWrite = &FatReleaseFcbFromLazyWrite;
309  FatData.CacheManagerCallbacks.AcquireForReadAhead = &FatAcquireFcbForReadAhead;
310  FatData.CacheManagerCallbacks.ReleaseFromReadAhead = &FatReleaseFcbFromReadAhead;
311 
316 
317  //
318  // Set up global pointer to our process.
319  //
320 
322 
323  //
324  // Setup the number of processors we support for statistics as the current number
325  // running.
326  //
327 
328 #if (NTDDI_VERSION >= NTDDI_VISTA)
330 #else
332 #endif
333 
334 
335  //
336  // Read the registry to determine if we are in ChicagoMode.
337  //
338 
340  ValueName.Length = sizeof(COMPATIBILITY_MODE_VALUE_NAME) - sizeof(WCHAR);
341  ValueName.MaximumLength = sizeof(COMPATIBILITY_MODE_VALUE_NAME);
342 
344 
345  if (NT_SUCCESS(Status) && FlagOn(Value, 1)) {
346 
348 
349  } else {
350 
352  }
353 
354  //
355  // Read the registry to determine if we are going to generate LFNs
356  // for valid 8.3 names with extended characters.
357  //
358 
360  ValueName.Length = sizeof(CODE_PAGE_INVARIANCE_VALUE_NAME) - sizeof(WCHAR);
361  ValueName.MaximumLength = sizeof(CODE_PAGE_INVARIANCE_VALUE_NAME);
362 
364 
365  if (NT_SUCCESS(Status) && FlagOn(Value, 1)) {
366 
368 
369  } else {
370 
372  }
373 
374  //
375  // Initialize our global resource and fire up the lookaside lists.
376  //
377 
379 
381  NULL,
382  NULL,
384  sizeof(IRP_CONTEXT),
386  MaxDepth );
387 
389  NULL,
390  NULL,
392  sizeof(NON_PAGED_FCB),
394  MaxDepth );
395 
397  NULL,
398  NULL,
400  sizeof(ERESOURCE),
402  MaxDepth );
403 
407 
408  //
409  // Register the file system with the I/O system
410  //
411 
416 
417  //
418  // Find out if we are running an a FujitsuFMR machine.
419  //
420 
422 
423 #if (NTDDI_VERSION >= NTDDI_WIN8)
424 
425  //
426  // Find out global disk accounting state, cache the result
427  //
428 
429  FatDiskAccountingEnabled = PsIsDiskCountersEnabled();
430 
431 #endif
432 
433  //
434  // And return to our caller
435  //
436 
437  return( STATUS_SUCCESS );
438 }
#define TAG_FCB_NONPAGED
Definition: cdprocs.h:91
NODE_TYPE_CODE NodeTypeCode
Definition: fatstruc.h:38
PIO_WORKITEM FatCloseItem
Definition: fatstruc.h:145
PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle
Definition: iotypes.h:1740
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
PVOID CdromFileSystemDeviceObject
Definition: fatstruc.h:62
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PVOID ZeroPage
Definition: fatstruc.h:163
ULONG SizeOfFsFilterCallbacks
Definition: iotypes.h:7426
BOOLEAN FujitsuFMR
Definition: fatstruc.h:95
#define IRP_MJ_FLUSH_BUFFERS
CACHE_MANAGER_CALLBACKS CacheManagerCallbacks
Definition: fatstruc.h:159
BOOLEAN NTAPI FsRtlMdlReadCompleteDev(IN PFILE_OBJECT FileObject, IN PMDL MemoryDescriptorList, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1011
PDEVICE_OBJECT FatCdromFileSystemDeviceObject
Definition: fatdata.c:59
#define IRP_MJ_SHUTDOWN
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LOGICAL FatDiskAccountingEnabled
Definition: fatdata.c:129
BOOLEAN NTAPI FsRtlMdlWriteCompleteDev(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1198
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
KSPIN_LOCK GeneralSpinLock
Definition: fatstruc.h:152
PFAST_IO_MDL_READ MdlRead
Definition: iotypes.h:1749
#define IRP_MJ_SET_VOLUME_INFORMATION
SLIST_HEADER FatCloseContextSList
Definition: fatdata.c:106
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
ULONG FatMaxDelayedCloseCount
Definition: close.c:31
PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite
Definition: iotypes.h:1751
PFAST_IO_UNLOCK_ALL FastIoUnlockAll
Definition: iotypes.h:1741
#define POOL_NX_ALLOCATION
BOOLEAN ChicagoMode
Definition: fatstruc.h:87
PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo
Definition: iotypes.h:1747
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
BOOLEAN NTAPI FsRtlPrepareMdlWriteDev(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1272
NPAGED_LOOKASIDE_LIST FatNonPagedFcbLookasideList
Definition: fatdata.c:103
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
PFAST_IO_MDL_READ_COMPLETE MdlReadComplete
Definition: iotypes.h:1750
NPAGED_LOOKASIDE_LIST FatIrpContextLookasideList
Definition: fatdata.c:102
FAST_MUTEX FatCloseQueueMutex
Definition: fatdata.c:112
LIST_ENTRY DelayedCloseList
Definition: fatstruc.h:139
BOOLEAN CodePageInvariant
Definition: fatstruc.h:115
PFS_FILTER_CALLBACK PreAcquireForSectionSynchronization
Definition: iotypes.h:7428
ULONG NumberProcessors
Definition: fatstruc.h:81
#define FALSE
Definition: types.h:117
PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo
Definition: iotypes.h:1737
#define IRP_MJ_SET_EA
struct _FAST_IO_DISPATCH FAST_IO_DISPATCH
#define PsGetCurrentProcess
Definition: psfuncs.h:17
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
NTKRNLVISTAAPI ULONG NTAPI KeQueryActiveProcessorCount(OUT PKAFFINITY ActiveProcessors OPTIONAL)
Definition: ke.c:15
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
BOOLEAN NTAPI FatNoOpAcquire(IN PVOID Fcb, IN BOOLEAN Wait)
Definition: resrcsup.c:795
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
PDRIVER_OBJECT DriverObject
Definition: fatstruc.h:55
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
BOOLEAN NTAPI FsRtlMdlReadDev(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1025
#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 IRP_MJ_QUERY_EA
FAT_DATA FatData
Definition: fatdata.c:56
PDEVICE_OBJECT FatDiskFileSystemDeviceObject
Definition: fatdata.c:58
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KEVENT FatReserveEvent
Definition: fatdata.c:123
#define IRP_MJ_FILE_SYSTEM_CONTROL
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
MM_SYSTEMSIZE NTAPI MmQuerySystemSize(VOID)
Definition: mmsup.c:257
PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite
Definition: cctypes.h:39
PEPROCESS OurProcess
Definition: fatstruc.h:75
PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey
Definition: iotypes.h:1742
struct _FAT_DATA FAT_DATA
NPAGED_LOOKASIDE_LIST FatEResourceLookasideList
Definition: fatdata.c:104
PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead
Definition: cctypes.h:41
NTSTATUS FatGetCompatibilityModeValue(IN PUNICODE_STRING ValueName, IN OUT PULONG Value)
Definition: fatinit.c:483
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NODE_BYTE_SIZE NodeByteSize
Definition: fatstruc.h:39
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
NTSTATUS NTAPI FsRtlRegisterFileSystemFilterCallbacks(PDRIVER_OBJECT FilterDriverObject, PFS_FILTER_CALLBACKS Callbacks)
Definition: fastio.c:2003
PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush
Definition: iotypes.h:1759
PFAST_IO_LOCK FastIoLock
Definition: iotypes.h:1739
#define TAG_ERESOURCE
Definition: nodetype.h:154
VOID NTAPI FatNoOpRelease(IN PVOID Fcb)
Definition: resrcsup.c:842
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
static const WCHAR L[]
Definition: oid.c:1250
PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead
Definition: cctypes.h:42
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define COMPATIBILITY_MODE_VALUE_NAME
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FAT_NTC_DATA_HEADER
Definition: nodetype.h:27
FAST_IO_DISPATCH FatFastIoDispatch
Definition: fatdata.c:96
struct _FS_FILTER_CALLBACKS FS_FILTER_CALLBACKS
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
#define TAG_IRP_CONTEXT
Definition: cdprocs.h:97
LIST_ENTRY VcbQueue
Definition: fatstruc.h:49
#define CODE_PAGE_INVARIANCE_VALUE_NAME
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1735
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
DRIVER_DISPATCH * PDRIVER_DISPATCH
Definition: iotypes.h:2262
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1736
unsigned short USHORT
Definition: pedump.c:61
#define FAT_MAX_DELAYED_CLOSES
Definition: fatdata.h:108
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
ERESOURCE Resource
Definition: fatstruc.h:68
#define NULL
Definition: types.h:112
PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo
Definition: iotypes.h:1738
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
BOOLEAN NTAPI FsRtlCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:64
BOOLEAN NTAPI FsRtlCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:264
VOID NTAPI IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:987
PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete
Definition: iotypes.h:1752
#define IRP_MJ_CLEANUP
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
Definition: winioctl.h:109
#define ObReferenceObject
Definition: obfuncs.h:204
#define ExInitializeSListHead
PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite
Definition: cctypes.h:40
ULONG ERESOURCE
Definition: env_spec_w32.h:594
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
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 IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define POOL_RAISE_IF_ALLOCATION_FAILURE
#define STATUS_SUCCESS
Definition: shellext.h:65
LIST_ENTRY AsyncCloseList
Definition: fatstruc.h:132
BOOLEAN FatIsFujitsuFMR()
Definition: fatinit.c:624
PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush
Definition: iotypes.h:1760
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 MaxDepth
Definition: acpixf.h:635
PVOID DiskFileSystemDeviceObject
Definition: fatstruc.h:61
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
ULONG SizeOfFastIoDispatch
Definition: iotypes.h:1733
CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks
Definition: fatstruc.h:160

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PUNICODE_STRING  RegistryPath 
)

Definition at line 1606 of file isapnp.c.

1609 {
1610  DPRINT("%s(%p, %wZ)\n", __FUNCTION__, DriverObject, RegistryPath);
1611 
1612  DriverObject->MajorFunction[IRP_MJ_CREATE] = IsaCreateClose;
1613  DriverObject->MajorFunction[IRP_MJ_CLOSE] = IsaCreateClose;
1614  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IsaForwardOrIgnore;
1615  DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IsaForwardOrIgnore;
1616  DriverObject->MajorFunction[IRP_MJ_PNP] = IsaPnp;
1617  DriverObject->MajorFunction[IRP_MJ_POWER] = IsaPower;
1618  DriverObject->DriverExtension->AddDevice = IsaAddDevice;
1619 
1620  /* FIXME: Fix SDK headers */
1621 #if 0
1623 #endif
1624 
1626  InitializeListHead(&BusListHead);
1627 
1628  /* FIXME: Fix SDK headers */
1629 #if 0
1631 #endif
1632 
1633  return STATUS_SUCCESS;
1634 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define TRUE
Definition: types.h:120
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
KEVENT BusSyncEvent
Definition: isapnp.c:21
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define _No_competing_thread_end_
#define IRP_MJ_SYSTEM_CONTROL
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define _No_competing_thread_begin_
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define __FUNCTION__
Definition: types.h:112
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

◆ FatGetCompatibilityModeValue()

NTSTATUS FatGetCompatibilityModeValue ( IN PUNICODE_STRING  ValueName,
IN OUT PULONG  Value 
)

Definition at line 483 of file fatinit.c.

511 {
512  HANDLE Handle;
514  ULONG RequestLength;
519  PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
520 
522  KeyName.Length = sizeof(COMPATIBILITY_MODE_KEY_NAME) - sizeof(WCHAR);
523  KeyName.MaximumLength = sizeof(COMPATIBILITY_MODE_KEY_NAME);
524 
526  &KeyName,
528  NULL,
529  NULL);
530 
531  Status = ZwOpenKey(&Handle,
532  KEY_READ,
534 
535  if (!NT_SUCCESS(Status)) {
536 
537  return Status;
538  }
539 
540  RequestLength = KEY_WORK_AREA;
541 
542  KeyValueInformation = (PKEY_VALUE_FULL_INFORMATION)Buffer;
543 
544  while (1) {
545 
546  Status = ZwQueryValueKey(Handle,
547  ValueName,
549  KeyValueInformation,
550  RequestLength,
551  &ResultLength);
552 
554 
556 
557  //
558  // Try to get a buffer big enough.
559  //
560 
561  if (KeyValueInformation != (PKEY_VALUE_FULL_INFORMATION)Buffer) {
562 
563  ExFreePool(KeyValueInformation);
564  }
565 
566  RequestLength += 256;
567 
568  KeyValueInformation = (PKEY_VALUE_FULL_INFORMATION)
570  RequestLength,
571  ' taF');
572 
573  if (!KeyValueInformation) {
574 
575  ZwClose(Handle);
576  return STATUS_NO_MEMORY;
577  }
578 
579  } else {
580 
581  break;
582  }
583  }
584 
585  ZwClose(Handle);
586 
587  if (NT_SUCCESS(Status)) {
588 
589  if (KeyValueInformation->DataLength != 0) {
590 
591  PULONG DataPtr;
592 
593  //
594  // Return contents to the caller.
595  //
596 
597  DataPtr = (PULONG)
598  ((PUCHAR)KeyValueInformation + KeyValueInformation->DataOffset);
599  *Value = *DataPtr;
600 
601  } else {
602 
603  //
604  // Treat as if no value was found
605  //
606 
608  }
609  }
610 
611  if (KeyValueInformation != (PKEY_VALUE_FULL_INFORMATION)Buffer) {
612 
613  ExFreePool(KeyValueInformation);
614  }
615 
616  return Status;
617 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define KEY_WORK_AREA
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
_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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define COMPATIBILITY_MODE_KEY_NAME
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
unsigned char UCHAR
Definition: xmlstorage.h:181
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned int ULONG
Definition: retypes.h:1
#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
struct _KEY_VALUE_FULL_INFORMATION * PKEY_VALUE_FULL_INFORMATION
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NT_ASSERT
Definition: rtlfuncs.h:3310

◆ FatIsFujitsuFMR()

BOOLEAN FatIsFujitsuFMR ( )

Definition at line 624 of file fatinit.c.

642 {
643  BOOLEAN Result;
644  HANDLE Handle;
646  ULONG RequestLength;
652  PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
653 
654  //
655  // Set default as PC/AT
656  //
657 
659  KeyName.Length = sizeof(REGISTRY_HARDWARE_DESCRIPTION_W) - sizeof(WCHAR);
660  KeyName.MaximumLength = sizeof(REGISTRY_HARDWARE_DESCRIPTION_W);
661 
663  &KeyName,
665  NULL,
666  NULL);
667 
668  Status = ZwOpenKey(&Handle,
669  KEY_READ,
671 
672  if (!NT_SUCCESS(Status)) {
673 
674  return FALSE;
675  }
676 
678  ValueName.Length = sizeof(REGISTRY_MACHINE_IDENTIFIER_W) - sizeof(WCHAR);
679  ValueName.MaximumLength = sizeof(REGISTRY_MACHINE_IDENTIFIER_W);
680 
681  RequestLength = KEY_WORK_AREA;
682 
683  KeyValueInformation = (PKEY_VALUE_FULL_INFORMATION)Buffer;
684 
685  while (1) {
686 
687  Status = ZwQueryValueKey(Handle,
688  &ValueName,
690  KeyValueInformation,
691  RequestLength,
692  &ResultLength);
693 
694  // NT_ASSERT( Status != STATUS_BUFFER_OVERFLOW );
695 
697 
698  //
699  // Try to get a buffer big enough.
700  //
701 
702  if (KeyValueInformation != (PKEY_VALUE_FULL_INFORMATION)Buffer) {
703 
704  ExFreePool(KeyValueInformation);
705  }
706 
707  RequestLength += 256;
708 
709  KeyValueInformation = (PKEY_VALUE_FULL_INFORMATION)
710  ExAllocatePoolWithTag(PagedPool, RequestLength, ' taF');
711 
712  if (!KeyValueInformation) {
713 
714  ZwClose(Handle);
715  return FALSE;
716  }
717 
718  } else {
719 
720  break;
721  }
722  }
723 
724  ZwClose(Handle);
725 
726  if (NT_SUCCESS(Status) &&
727  (KeyValueInformation->DataLength >= sizeof(FUJITSU_FMR_NAME_W)) &&
728  (RtlCompareMemory((PUCHAR)KeyValueInformation + KeyValueInformation->DataOffset,
730  sizeof(FUJITSU_FMR_NAME_W) - sizeof(WCHAR)) ==
731  sizeof(FUJITSU_FMR_NAME_W) - sizeof(WCHAR))) {
732 
733  Result = TRUE;
734 
735  } else {
736 
737  Result = FALSE;
738  }
739 
740  if (KeyValueInformation != (PKEY_VALUE_FULL_INFORMATION)Buffer) {
741 
742  ExFreePool(KeyValueInformation);
743  }
744 
745  return Result;
746 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define KEY_WORK_AREA
#define REGISTRY_MACHINE_IDENTIFIER_W
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define FUJITSU_FMR_NAME_W
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
unsigned char UCHAR
Definition: xmlstorage.h:181
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
#define REGISTRY_HARDWARE_DESCRIPTION_W
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned int ULONG
Definition: retypes.h:1
#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
struct _KEY_VALUE_FULL_INFORMATION * PKEY_VALUE_FULL_INFORMATION
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

Variable Documentation

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 18 of file fatinit.c.