ReactOS 0.4.15-dev-7953-g1f49173
filesystem.c File Reference
#include <ntddk.h>
#include <debug.h>
Include dependency graph for filesystem.c:

Go to the source code of this file.

Classes

struct  DEVICE_EXTENSION
 

Macros

#define NDEBUG
 

Typedefs

typedef struct DEVICE_EXTENSIONPDEVICE_EXTENSION
 

Functions

NTSTATUS NTAPI FsdCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
 
NTSTATUS NTAPI FsdOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PWSTR FileName)
 
BOOLEAN NTAPI FsdHasFileSystem (PDEVICE_OBJECT DeviceToMount)
 
NTSTATUS NTAPI FsdMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
 
NTSTATUS NTAPI FsdReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PVOID Buffer, ULONG Length, ULONG Offset)
 
NTSTATUS NTAPI FsdClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI FsdCreate (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI FsdWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI FsdRead (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS FsdMount (PDEVICE_OBJECT DeviceToMount)
 
NTSTATUS NTAPI FsdFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath)
 

Variables

static PDRIVER_OBJECT DriverObject
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 31 of file filesystem.c.

Typedef Documentation

◆ PDEVICE_EXTENSION

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  _DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 238 of file filesystem.c.

247{
250 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\BareFsd");
251
252 DbgPrint("Bare FSD Template 0.0.1\n");
253
254 DriverObject = _DriverObject;
255
257 0,
258 &DeviceName,
260 0,
261 FALSE,
262 &DeviceObject);
263 if (!NT_SUCCESS(Status))
264 {
265 return(Status);
266 }
267
268 DeviceObject->Flags=0;
269 DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsdClose;
270 DriverObject->MajorFunction[IRP_MJ_CREATE] = FsdCreate;
271 DriverObject->MajorFunction[IRP_MJ_READ] = FsdRead;
272 DriverObject->MajorFunction[IRP_MJ_WRITE] = FsdWrite;
275 DriverObject->DriverUnload = NULL;
276
278
279 return(STATUS_SUCCESS);
280}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
NTSTATUS NTAPI FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filesystem.c:144
NTSTATUS NTAPI FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filesystem.c:105
NTSTATUS NTAPI FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filesystem.c:124
NTSTATUS NTAPI FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filesystem.c:155
NTSTATUS NTAPI FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: filesystem.c:212
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
VOID NTAPI IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:987
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_FILE_SYSTEM
Definition: winioctl.h:115
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_FILE_SYSTEM_CONTROL

◆ FsdClose()

NTSTATUS NTAPI FsdClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 105 of file filesystem.c.

107{
109 PFILE_OBJECT FileObject = Stack->FileObject;
110 PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
112
113 Status = FsdCloseFile(DeviceExtension,FileObject);
114
115 Irp->IoStatus.Status = Status;
116 Irp->IoStatus.Information = 0;
117
119 return(Status);
120}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
Definition: filesystem.c:46
#define IoCompleteRequest
Definition: irp.c:1240
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
#define IO_NO_INCREMENT
Definition: iotypes.h:598
* PFILE_OBJECT
Definition: iotypes.h:1998

Referenced by DriverEntry().

◆ FsdCloseFile()

NTSTATUS NTAPI FsdCloseFile ( PDEVICE_EXTENSION  DeviceExt,
PFILE_OBJECT  FileObject 
)

Definition at line 46 of file filesystem.c.

51{
52 return(STATUS_SUCCESS);
53}

Referenced by FsdClose().

◆ FsdCreate()

NTSTATUS NTAPI FsdCreate ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 124 of file filesystem.c.

126{
128 PFILE_OBJECT FileObject = Stack->FileObject;
130 PDEVICE_EXTENSION DeviceExt;
131
132 DeviceExt = DeviceObject->DeviceExtension;
133 Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
134
135 Irp->IoStatus.Status = Status;
136 Irp->IoStatus.Information = 0;
137
139 return(Status);
140}
NTSTATUS NTAPI FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PWSTR FileName)
Definition: filesystem.c:57

Referenced by DriverEntry().

◆ FsdFileSystemControl()

NTSTATUS NTAPI FsdFileSystemControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 212 of file filesystem.c.

214{
216 PVPB vpb = Stack->Parameters.Mount.Vpb;
217 PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
219
220 if (FsdHasFileSystem(DeviceToMount))
221 {
222 Status = FsdMount(DeviceToMount);
223 }
224 else
225 {
227 }
228
229 Irp->IoStatus.Status = Status;
230 Irp->IoStatus.Information = 0;
231
233 return(Status);
234}
BOOLEAN NTAPI FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount)
Definition: filesystem.c:69
NTSTATUS FsdMount(PDEVICE_OBJECT DeviceToMount)
Definition: filesystem.c:182
Definition: iotypes.h:189
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173

Referenced by DriverEntry().

◆ FsdHasFileSystem()

BOOLEAN NTAPI FsdHasFileSystem ( PDEVICE_OBJECT  DeviceToMount)

Definition at line 69 of file filesystem.c.

74{
75 return(TRUE);
76}
#define TRUE
Definition: types.h:120

Referenced by FsdFileSystemControl().

◆ FsdMount()

NTSTATUS FsdMount ( PDEVICE_OBJECT  DeviceToMount)

Definition at line 182 of file filesystem.c.

183{
185 PDEVICE_EXTENSION DeviceExt;
186
188 sizeof(DEVICE_EXTENSION),
189 NULL,
191 0,
192 FALSE,
193 &DeviceObject);
194 DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
195 DeviceExt = (PVOID)DeviceObject->DeviceExtension;
196
197 FsdMountDevice(DeviceExt,
198 DeviceToMount);
199
200 DeviceExt->StorageDevice = DeviceToMount;
201 DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject;
202 DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice;
203 DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED;
204 DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1;
205 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
206
207 return(STATUS_SUCCESS);
208}
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
NTSTATUS NTAPI FsdMountDevice(PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
Definition: filesystem.c:80
void * PVOID
Definition: typedefs.h:50
#define VPB_MOUNTED
Definition: iotypes.h:1807

Referenced by FsdFileSystemControl().

◆ FsdMountDevice()

NTSTATUS NTAPI FsdMountDevice ( PDEVICE_EXTENSION  DeviceExt,
PDEVICE_OBJECT  DeviceToMount 
)

Definition at line 80 of file filesystem.c.

85{
86 return(STATUS_SUCCESS);
87}

Referenced by FsdMount().

◆ FsdOpenFile()

NTSTATUS NTAPI FsdOpenFile ( PDEVICE_EXTENSION  DeviceExt,
PFILE_OBJECT  FileObject,
PWSTR  FileName 
)

Definition at line 57 of file filesystem.c.

63{
64 return(STATUS_SUCCESS);
65}

Referenced by FsdCreate().

◆ FsdRead()

NTSTATUS NTAPI FsdRead ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 155 of file filesystem.c.

157{
162 PFILE_OBJECT FileObject = Stack->FileObject;
163 PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
165
166 DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
167
168 Length = Stack->Parameters.Read.Length;
169 Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
170 Offset = Stack->Parameters.Read.ByteOffset.LowPart;
171
173
174 Irp->IoStatus.Status = Status;
175 Irp->IoStatus.Information = Length;
177 return(Status);
178}
Definition: bufpool.h:45
NTSTATUS NTAPI FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PVOID Buffer, ULONG Length, ULONG Offset)
Definition: filesystem.c:91
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define DPRINT
Definition: sndvol32.h:71
uint32_t ULONG
Definition: typedefs.h:59
#define MmGetSystemAddressForMdl(Mdl)

Referenced by DriverEntry().

◆ FsdReadFile()

NTSTATUS NTAPI FsdReadFile ( PDEVICE_EXTENSION  DeviceExt,
PFILE_OBJECT  FileObject,
PVOID  Buffer,
ULONG  Length,
ULONG  Offset 
)

Definition at line 91 of file filesystem.c.

99{
100 return(STATUS_SUCCESS);
101}

Referenced by FsdRead().

◆ FsdWrite()

NTSTATUS NTAPI FsdWrite ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 144 of file filesystem.c.

146{
147 DPRINT("FsdWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
148
149 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
150 Irp->IoStatus.Information = 0;
151 return(STATUS_UNSUCCESSFUL);
152}
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by DriverEntry().

Variable Documentation

◆ DriverObject

Definition at line 41 of file filesystem.c.