ReactOS 0.4.15-dev-8222-g9164419
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 PAGED_CODE()
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_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 FsRecNtfsFsControl().

◆ FsRecNtfsFsControl()

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

Definition at line 52 of file ntfs.c.

54{
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,
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,
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,
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}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
INT Offset2
Definition: FsRtlDissect.c:14
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
BOOLEAN NTAPI FsRecIsNtfsVolume(IN PPACKED_BOOT_SECTOR BootSector, IN ULONG BytesPerSector, IN PLARGE_INTEGER NumberOfSectors)
Definition: ntfs.c:21
#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 FsRecGetDeviceSectors(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, OUT PLARGE_INTEGER SectorCount)
Definition: blockdev.c:24
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
ULONG SectorCount
Definition: part_xbox.c:31
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().