ReactOS  0.4.15-dev-5455-g015cd25
fatx.c File Reference
#include "fs_rec.h"
#include <debug.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for fatx.c:

Go to the source code of this file.

Classes

struct  _FATX_BOOT_SECTOR
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _FATX_BOOT_SECTOR FATX_BOOT_SECTOR
 
typedef struct _FATX_BOOT_SECTORPFATX_BOOT_SECTOR
 

Functions

BOOLEAN NTAPI FsRecIsFatxVolume (IN PFATX_BOOT_SECTOR BootSector)
 
NTSTATUS NTAPI FsRecFatxFsControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file fatx.c.

Typedef Documentation

◆ FATX_BOOT_SECTOR

◆ PFATX_BOOT_SECTOR

Function Documentation

◆ FsRecFatxFsControl()

NTSTATUS NTAPI FsRecFatxFsControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 66 of file fatx.c.

68 {
71  PDEVICE_OBJECT MountDevice;
72  PFATX_BOOT_SECTOR Bpb = NULL;
74  LARGE_INTEGER Offset = {{0, 0}};
75  BOOLEAN DeviceError = FALSE;
76  PAGED_CODE();
77 
78  /* Get the I/O Stack and check the function type */
80  switch (Stack->MinorFunction)
81  {
83 
84  /* Assume failure */
86 
87  /* Get the device object and request the sector size */
88  MountDevice = Stack->Parameters.MountVolume.DeviceObject;
89  if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
90  {
91  /* Try to read the BPB */
92  if (FsRecReadBlock(MountDevice,
93  &Offset,
94  512,
95  SectorSize,
96  (PVOID)&Bpb,
97  &DeviceError))
98  {
99  /* Check if it's an actual FAT volume */
100  if (FsRecIsFatxVolume(Bpb))
101  {
102  /* It is! */
104  }
105  }
106 
107  /* Free the boot sector if we have one */
108  ExFreePool(Bpb);
109  }
110 
111  break;
112 
114 
115  /* Load the file system */
117  L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\vfatfs");
118  break;
119 
120  default:
121 
122  /* Invalid request */
124  }
125 
126  /* Return Status */
127  return Status;
128 }
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MN_LOAD_FILE_SYSTEM
Definition: iotypes.h:4406
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:645
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
unsigned char BOOLEAN
Status
Definition: gdiplustypes.h:24
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4404
BOOLEAN NTAPI FsRecReadBlock(IN PDEVICE_OBJECT DeviceObject, IN PLARGE_INTEGER Offset, IN ULONG Length, IN ULONG SectorSize, IN OUT PVOID *Buffer, OUT PBOOLEAN DeviceError OPTIONAL)
Definition: blockdev.c:152
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define NULL
Definition: types.h:112
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG SectorSize
Definition: halfuncs.h:291
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
BOOLEAN NTAPI FsRecIsFatxVolume(IN PFATX_BOOT_SECTOR BootSector)
Definition: fatx.c:33
#define PAGED_CODE()

Referenced by FsRecFsControl().

◆ FsRecIsFatxVolume()

BOOLEAN NTAPI FsRecIsFatxVolume ( IN PFATX_BOOT_SECTOR  BootSector)

Definition at line 33 of file fatx.c.

34 {
36 
37  PAGED_CODE();
38 
39  if (BootSector->SysType[0] != 'F' ||
40  BootSector->SysType[1] != 'A' ||
41  BootSector->SysType[2] != 'T' ||
42  BootSector->SysType[3] != 'X')
43  {
44  /* Fail */
45  Result = FALSE;
46  }
47  else if (BootSector->SectorsPerCluster != 1 &&
55  {
56  /* Fail */
57  Result = FALSE;
58  }
59 
60  /* Return the result */
61  return Result;
62 }
BYTE SectorsPerCluster
Definition: fatfs.h:76
#define TRUE
Definition: types.h:120
#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
#define PAGED_CODE()

Referenced by FsRecFatxFsControl().