ReactOS  0.4.14-dev-1314-gacf135d
ntfs.c File Reference
#include "fs_rec.h"
#include <debug.h>
Include dependency graph for ntfs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI FsRecIsNtfsVolume (IN PPACKED_BOOT_SECTOR BootSector, IN ULONG BytesPerSector, IN PLARGE_INTEGER NumberOfSectors)
 
NTSTATUS NTAPI FsRecNtfsFsControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file ntfs.c.

Function Documentation

◆ FsRecIsNtfsVolume()

BOOLEAN NTAPI FsRecIsNtfsVolume ( IN PPACKED_BOOT_SECTOR  BootSector,
IN ULONG  BytesPerSector,
IN PLARGE_INTEGER  NumberOfSectors 
)

Definition at line 21 of file ntfs.c.

24 {
25  /* Assume failure */
27 
28  UNREFERENCED_PARAMETER(BytesPerSector);
29  UNREFERENCED_PARAMETER(NumberOfSectors);
30 
31  PAGED_CODE();
32 
33  if ((BootSector->Oem[0] == 'N') &&
34  (BootSector->Oem[1] == 'T') &&
35  (BootSector->Oem[2] == 'F') &&
36  (BootSector->Oem[3] == 'S') &&
37  (BootSector->Oem[4] == ' ') &&
38  (BootSector->Oem[5] == ' ') &&
39  (BootSector->Oem[6] == ' ') &&
40  (BootSector->Oem[7] == ' '))
41  {
42  /* Success */
43  Result = TRUE;
44  }
45 
46  /* Return the result */
47  return Result;
48 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
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

Referenced by FsRecNtfsFsControl().

◆ FsRecNtfsFsControl()

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

Definition at line 52 of file ntfs.c.

54 {
55  PIO_STACK_LOCATION Stack;
57  PDEVICE_OBJECT MountDevice;
60  LARGE_INTEGER Offset = {{0, 0}}, Offset2, Offset3, SectorCount;
61  PAGED_CODE();
62 
63  /* Get the I/O Stack and check the function type */
65  switch (Stack->MinorFunction)
66  {
68 
69  /* Assume failure */
71 
72  /* Get the device object and request the sector size */
73  MountDevice = Stack->Parameters.MountVolume.DeviceObject;
74  if ((FsRecGetDeviceSectorSize(MountDevice, &SectorSize)) &&
76  {
77  /* Setup other offsets to try */
78  Offset2.QuadPart = SectorCount.QuadPart >> 1;
79  Offset2.QuadPart *= SectorSize;
80  Offset3.QuadPart = (SectorCount.QuadPart - 1) * SectorSize;
81 
82  /* Try to read the BPB */
83  if (FsRecReadBlock(MountDevice,
84  &Offset,
85  512,
86  SectorSize,
87  (PVOID)&Bpb,
88  NULL))
89  {
90  /* Check if it's an actual NTFS volume */
92  {
93  /* It is! */
95  }
96  }
97  else if (FsRecReadBlock(MountDevice,
98  &Offset2,
99  512,
100  SectorSize,
101  (PVOID)&Bpb,
102  NULL))
103  {
104  /* Check if it's an actual NTFS volume */
106  {
107  /* It is! */
109  }
110  }
111  else if (FsRecReadBlock(MountDevice,
112  &Offset3,
113  512,
114  SectorSize,
115  (PVOID)&Bpb,
116  NULL))
117  {
118  /* Check if it's an actual NTFS volume */
120  {
121  /* It is! */
123  }
124  }
125 
126  /* Free the boot sector if we have one */
127  ExFreePool(Bpb);
128  }
129  break;
130 
132 
133  /* Load the file system */
135  L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Ntfs");
136  break;
137 
138  default:
139 
140  /* Invalid request */
142  }
143 
144  /* Return Status */
145  return Status;
146 }
_In_ PIRP Irp
Definition: csq.h:116
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:4050
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
BOOLEAN NTAPI FsRecIsNtfsVolume(IN PPACKED_BOOT_SECTOR BootSector, IN ULONG BytesPerSector, IN PLARGE_INTEGER NumberOfSectors)
Definition: ntfs.c:21
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:631
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
smooth NULL
Definition: ftsmooth.c:416
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4048
BOOLEAN NTAPI FsRecGetDeviceSectors(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, OUT PLARGE_INTEGER SectorCount)
Definition: blockdev.c:24
static const WCHAR L[]
Definition: oid.c:1250
ULONG SectorCount
Definition: part_xbox.c:31
Status
Definition: gdiplustypes.h:24
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 PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
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
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
INT Offset2
Definition: FsRtlDissect.c:14
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FsRecFsControl().