ReactOS  0.4.12-dev-918-g6c6e7b8
template.c File Reference
#include <ntddk.h>
#include <debug.h>
Include dependency graph for template.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 32 of file template.c.

Typedef Documentation

◆ PDEVICE_EXTENSION

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  _DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 239 of file template.c.

248 {
251  UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\BareFsd");
252 
253  DbgPrint("Bare FSD Template 0.0.1\n");
254 
255  DriverObject = _DriverObject;
256 
258  0,
259  &DeviceName,
261  0,
262  FALSE,
263  &DeviceObject);
264  if (!NT_SUCCESS(Status))
265  {
266  return(Status);
267  }
268 
269  DeviceObject->Flags=0;
277 
279 
280  return(STATUS_SUCCESS);
281 }
NTSTATUS NTAPI FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: template.c:156
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define DbgPrint
Definition: loader.c:25
#define FILE_DEVICE_FILE_SYSTEM
Definition: winioctl.h:114
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
NTSTATUS NTAPI FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: template.c:213
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_FILE_SYSTEM_CONTROL
NTSTATUS NTAPI FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: template.c:145
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: template.c:106
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2179
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define IRP_MJ_READ
Definition: rdpdr.c:46
VOID NTAPI IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:984
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2180
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
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
NTSTATUS NTAPI FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: template.c:125
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

◆ FsdClose()

NTSTATUS NTAPI FsdClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 106 of file template.c.

108 {
113 
114  Status = FsdCloseFile(DeviceExtension,FileObject);
115 
116  Irp->IoStatus.Status = Status;
117  Irp->IoStatus.Information = 0;
118 
120  return(Status);
121 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
* PFILE_OBJECT
Definition: iotypes.h:1954
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
NTSTATUS NTAPI FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
Definition: template.c:47
#define IO_NO_INCREMENT
Definition: iotypes.h:565

Referenced by DriverEntry().

◆ FsdCloseFile()

NTSTATUS NTAPI FsdCloseFile ( PDEVICE_EXTENSION  DeviceExt,
PFILE_OBJECT  FileObject 
)

Definition at line 47 of file template.c.

52 {
53  return(STATUS_SUCCESS);
54 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by FsdClose().

◆ FsdCreate()

NTSTATUS NTAPI FsdCreate ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 125 of file template.c.

127 {
131  PDEVICE_EXTENSION DeviceExt;
132 
133  DeviceExt = DeviceObject->DeviceExtension;
134  Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
135 
136  Irp->IoStatus.Status = Status;
137  Irp->IoStatus.Information = 0;
138 
140  return(Status);
141 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
* PFILE_OBJECT
Definition: iotypes.h:1954
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
#define IO_NO_INCREMENT
Definition: iotypes.h:565
NTSTATUS NTAPI FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PWSTR FileName)
Definition: template.c:58

Referenced by DriverEntry().

◆ FsdFileSystemControl()

NTSTATUS NTAPI FsdFileSystemControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 213 of file template.c.

215 {
217  PVPB vpb = Stack->Parameters.Mount.Vpb;
218  PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
220 
221  if (FsdHasFileSystem(DeviceToMount))
222  {
223  Status = FsdMount(DeviceToMount);
224  }
225  else
226  {
228  }
229 
230  Irp->IoStatus.Status = Status;
231  Irp->IoStatus.Information = 0;
232 
234  return(Status);
235 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
NTSTATUS FsdMount(PDEVICE_OBJECT DeviceToMount)
Definition: template.c:183
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
Definition: iotypes.h:166
#define IO_NO_INCREMENT
Definition: iotypes.h:565
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
BOOLEAN NTAPI FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount)
Definition: template.c:70

Referenced by DriverEntry().

◆ FsdHasFileSystem()

BOOLEAN NTAPI FsdHasFileSystem ( PDEVICE_OBJECT  DeviceToMount)

Definition at line 70 of file template.c.

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

Referenced by FsdFileSystemControl().

◆ FsdMount()

NTSTATUS FsdMount ( PDEVICE_OBJECT  DeviceToMount)

Definition at line 183 of file template.c.

184 {
186  PDEVICE_EXTENSION DeviceExt;
187 
189  sizeof(DEVICE_EXTENSION),
190  NULL,
192  0,
193  FALSE,
194  &DeviceObject);
196  DeviceExt = (PVOID)DeviceObject->DeviceExtension;
197 
198  FsdMountDevice(DeviceExt,
199  DeviceToMount);
200 
201  DeviceExt->StorageDevice = DeviceToMount;
202  DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject;
203  DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice;
204  DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED;
205  DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1;
207 
208  return(STATUS_SUCCESS);
209 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define FILE_DEVICE_FILE_SYSTEM
Definition: winioctl.h:114
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void * PVOID
Definition: retypes.h:9
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI FsdMountDevice(PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
Definition: template.c:81
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
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define VPB_MOUNTED
Definition: iotypes.h:1763

Referenced by FsdFileSystemControl().

◆ FsdMountDevice()

NTSTATUS NTAPI FsdMountDevice ( PDEVICE_EXTENSION  DeviceExt,
PDEVICE_OBJECT  DeviceToMount 
)

Definition at line 81 of file template.c.

86 {
87  return(STATUS_SUCCESS);
88 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by FsdMount().

◆ FsdOpenFile()

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

Definition at line 58 of file template.c.

64 {
65  return(STATUS_SUCCESS);
66 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by FsdCreate().

◆ FsdRead()

NTSTATUS NTAPI FsdRead ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 156 of file template.c.

158 {
159  ULONG Length;
160  PVOID Buffer;
161  ULONG Offset;
166 
167  DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
168 
169  Length = Stack->Parameters.Read.Length;
170  Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
171  Offset = Stack->Parameters.Read.ByteOffset.LowPart;
172 
174 
175  Irp->IoStatus.Status = Status;
176  Irp->IoStatus.Information = Length;
178  return(Status);
179 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PVOID Buffer, ULONG Length, ULONG Offset)
Definition: template.c:92
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1954
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define MmGetSystemAddressForMdl(Mdl)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by DriverEntry().

◆ FsdReadFile()

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

Definition at line 92 of file template.c.

100 {
101  return(STATUS_SUCCESS);
102 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by FsdRead().

◆ FsdWrite()

NTSTATUS NTAPI FsdWrite ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 145 of file template.c.

147 {
148  DPRINT("FsdWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
149 
150  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
151  Irp->IoStatus.Information = 0;
152  return(STATUS_UNSUCCESSFUL);
153 }
_In_ PIRP Irp
Definition: csq.h:116
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by DriverEntry().

Variable Documentation

◆ DriverObject

PDRIVER_OBJECT DriverObject
static

Definition at line 42 of file template.c.

Referenced by $endif(), _Dispatch_type_(), _Function_class_(), AddControllers(), AddDevice(), AddDeviceInternal(), AfdUnload(), BeepUnload(), Bus_AddDevice(), CdInitializeGlobalData(), CdRomAddDevice(), CdRomCreateDeviceObject(), CdRomUnload(), CdUnload(), ClassAddDevice(), ClassCreateDeviceObject(), ClassGetDriverExtension(), ClassInitialize(), ClassInitializeEx(), ClassUnload(), CmBattAddAcAdapter(), CmBattAddBattery(), CmBattAddDevice(), CmBattCreateFdo(), CmBattUnload(), CompBattAddDevice(), ConDrvCreateController(), ConDrvDeleteController(), ConDrvUnload(), CreateCdRomDeviceObject(), CreateClassDeviceObject(), CreateDiskDeviceObject(), CHCDController::CreateFDO(), CreateFlopDeviceObject(), CreateGreenFdo(), CHubController::CreatePDO(), CreateSoundDevice(), CreateSoundDeviceWithDefaultName(), CreateTestDevices(), DECLARE_INTERFACE_(), disk_arrival(), DiskAddDevice(), DiskCreateFdo(), DiskUnload(), DriverEntry(), DriverUnload(), enqueue_pnp_callback(), EnumerateSubkey(), FdcAddDevice(), FindScsiDisks(), FltpSetupCommunicationObjects(), FltRegisterFilter(), FreeBT_AddDevice(), FsdMount(), FsRecRegisterFs(), FsRecUnload(), GreenAddDevice(), GreenDispatch(), HalAssignSlotResources(), HalpAddDevice(), HalpAssignSlotResources(), HalpDriverEntry(), HalpReportDetectedDevices(), HDA_AddDevice(), HidClassAddDevice(), CHCDController::Initialize(), CHubController::Initialize(), InitializeGlobalData(), InitializeSoundBlaster(), IntVideoPortAddDevice(), IntVideoPortCreateAdapterDeviceObject(), IntVideoPortFilterResourceRequirements(), IntVideoPortPnPStartDevice(), IoAllocateDriverObjectExtension(), IoAllocateErrorLogEntry(), IoAssignResources(), IoCreateDevice(), IoCreateDriver(), IoDeleteDriver(), IoEnumerateDeviceObjectList(), IofCallDriver(), IoGetDriverObjectExtension(), IopActionInitChildServices(), IopAttachFilterDriversCallback(), IopCreateDriver(), IopDeleteDriver(), IopEditDeviceList(), IopGetDriverObject(), IopInitializeBootDrivers(), IopInitializeBuiltinDriver(), IopInitializeDevice(), IopInitializeDriverModule(), IopLoadUnloadDriver(), IopLogWorker(), IopUnloadDevice(), IopUnloadDriver(), IoRegisterBootDriverReinitialization(), IoRegisterDriverReinitialization(), IoRegisterFsRegistrationChange(), IoRegisterPlugPlayNotification(), IoReportDetectedDevice(), IoUnregisterFsRegistrationChange(), IsaAddDevice(), KbdHid_AddDevice(), KeyboardAddDevice(), KMix_AddDevice(), KoDriverInitialize(), KopAddDevice(), KsAddDevice(), KsCreateDevice(), KsInitializeDriver(), KsSetMajorFunctionHandler(), LoadBootDeviceDriver(), main(), MmIsDriverVerifying(), MouHid_AddDevice(), MountMgrUnload(), MupUnload(), NdisAllocateGenericObject(), NdisIAddDevice(), NtfsInitializeFunctionPointers(), NtLoadDriver(), NullUnload(), PcAddAdapterDevice(), PciAddDevice(), PciAssignSlotResources(), PciDriverUnload(), PciIdeXAddDevice(), PciIdeXInitialize(), PcInitializeAdapterDriver(), PciUnload(), PciVerifierInit(), PcmciaAddDevice(), PcmciaUnload(), PipCallDriverAddDevice(), PnpRootAddDevice(), PnpRootCreateDevice(), PnpRootDriverEntry(), PortAddDevice(), PortUnload(), ProcessorAddDevice(), RamdiskAddDevice(), RawFsDriverEntry(), ReportGreenPdo(), RxDriverEntry(), RxInitializeDispatchVectors(), RxRegisterMinirdr(), ScreenAddDevice(), ScsiCdRomFindDevices(), ScsiClassAddDevice(), ScsiClassCreateDeviceObject(), ScsiClassInitialize(), ScsiFlopAddDevice(), ScsiFlopUnload(), ScsiPortInitialize(), SearchForLegacyDrivers(), SerenumAddDevice(), SerialAddDevice(), SerialAddDeviceInternal(), SermouseAddDevice(), SetupDispatchAndCallbacksTables(), SpiGetPciConfigData(), StorPortInitialize(), StreamClassAddDevice(), StreamClassRegisterAdapter(), SwAddDevice(), SysAudio_AddDevice(), SysAudioRegisterNotifications(), TestDeviceCreateDelete(), TestDriverObject(), TestEntry(), TestFltRegisterFilter(), TestUnload(), UDFCreateFsDeviceObject(), UDFInitializeFunctionPointers(), Unload(), UnloadHandler(), USBCCGP_AddDevice(), USBH_AddDevice(), USBHUB_AddDevice(), USBLIB_AddDevice(), USBPORT_AddDevice(), USBPORT_FindMiniPort(), USBPORT_RegisterUSBPortDriver(), USBPORT_Unload(), USBSTOR_AddDevice(), VcdUnload(), VfdCreateDevice(), VfdReinitialize(), VfdUnloadDriver(), ViCreateDevice(), ViCreateDriveAndMountImage(), ViCreateDriveLetter(), VideoPortGetAccessRanges(), VideoPortInitialize(), ViLoadImagesFromRegistry(), volume_arrival(), volume_removal(), and WdmaudAddDevice().