ReactOS 0.4.15-dev-7994-gb388cb6
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;
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,
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}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI FsRecIsFatxVolume(IN PFATX_BOOT_SECTOR BootSector)
Definition: fatx.c:33
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
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
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
Status
Definition: gdiplustypes.h:25
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:645
#define L(x)
Definition: ntvdm.h:50
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_In_ ULONG SectorSize
Definition: halfuncs.h:291
#define IRP_MN_LOAD_FILE_SYSTEM
Definition: iotypes.h:4406
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4404

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}
#define TRUE
Definition: types.h:120
BYTE SectorsPerCluster
Definition: fatfs.h:76
_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:409

Referenced by FsRecFatxFsControl().