ReactOS  0.4.15-dev-1384-g878186b
null.c File Reference
#include <wdm.h>
Include dependency graph for null.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI NullQueryFileInformation (OUT PVOID Buffer, IN PULONG Length, IN FILE_INFORMATION_CLASS InformationClass)
 
BOOLEAN NTAPI NullRead (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI NullWrite (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI NullDispatch (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI NullUnload (IN PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 

Variables

FAST_IO_DISPATCH FastIoDispatch
 

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 170 of file null.c.

172 {
175  UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\Null");
176 
177  PAGED_CODE();
178 
180 
181  /* Page the driver */
183 
184  /* Create the Null device */
186  0,
187  &DeviceName,
190  FALSE,
191  &DeviceObject);
192  if (!NT_SUCCESS(Status))
193  return Status;
194 
195  /* Register driver routines */
196  DriverObject->MajorFunction[IRP_MJ_CLOSE] = NullDispatch;
197  DriverObject->MajorFunction[IRP_MJ_CREATE] = NullDispatch;
198  DriverObject->MajorFunction[IRP_MJ_WRITE] = NullDispatch;
199  DriverObject->MajorFunction[IRP_MJ_READ] = NullDispatch;
202  DriverObject->DriverUnload = NullUnload;
203 
204  /* Initialize the fast I/O dispatch table */
207 
208  /* Setup our pointers */
211  DriverObject->FastIoDispatch = &FastIoDispatch;
212 
213  /* Return success */
214  return STATUS_SUCCESS;
215 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
BOOLEAN NTAPI NullRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: null.c:47
NTSTATUS NTAPI NullDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: null.c:85
#define FILE_DEVICE_NULL
Definition: winioctl.h:126
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
NTSTATUS NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
Definition: null.c:170
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3385
BOOLEAN NTAPI NullWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: null.c:66
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
static const WCHAR L[]
Definition: oid.c:1250
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1715
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1716
FAST_IO_DISPATCH FastIoDispatch
Definition: null.c:15
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
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 RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI NullUnload(IN PDRIVER_OBJECT DriverObject)
Definition: null.c:160
ULONG SizeOfFastIoDispatch
Definition: iotypes.h:1713
#define PAGED_CODE()
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

◆ NullDispatch()

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

Definition at line 85 of file null.c.

87 {
91  ULONG Length;
92 
93  PAGED_CODE();
94 
95  /* Get the file object and check what kind of request this is */
96  FileObject = IoStack->FileObject;
97  switch (IoStack->MajorFunction)
98  {
99  case IRP_MJ_CREATE:
100  case IRP_MJ_CLOSE:
101 
102  /* Check if this is synch I/O */
103  if (FileObject->Flags & FO_SYNCHRONOUS_IO)
104  {
105  /* Set distinguished value for Cc */
106  FileObject->PrivateCacheMap = (PVOID)1;
107  }
108 
109  /* Complete successfully */
110  Irp->IoStatus.Status = STATUS_SUCCESS;
111  Irp->IoStatus.Information = 0;
112  break;
113 
114  case IRP_MJ_READ:
115 
116  /* Return as if we read the entire file */
117  Irp->IoStatus.Status = STATUS_END_OF_FILE;
118  Irp->IoStatus.Information = 0;
119  break;
120 
121  case IRP_MJ_WRITE:
122 
123  /* Return as if we wrote the entire request */
124  Irp->IoStatus.Status = STATUS_SUCCESS;
125  Irp->IoStatus.Information = IoStack->Parameters.Write.Length;
126  break;
127 
128  case IRP_MJ_LOCK_CONTROL:
129 
130  /* Dummy */
131  Irp->IoStatus.Status = STATUS_SUCCESS;
132  Irp->IoStatus.Information = 0;
133  break;
134 
136 
137  /* Get the length inputted and do the request */
138  Length = IoStack->Parameters.QueryFile.Length;
139  Irp->IoStatus.Status = NullQueryFileInformation(Irp->AssociatedIrp.
140  SystemBuffer,
141  &Length,
142  IoStack->
143  Parameters.
144  QueryFile.
146 
147  /* Return the actual length */
148  Irp->IoStatus.Information = Length;
149  break;
150  }
151 
152  /* Complete the request */
153  Status = Irp->IoStatus.Status;
155  return Status;
156 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:863
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NullQueryFileInformation(OUT PVOID Buffer, IN PULONG Length, IN FILE_INFORMATION_CLASS InformationClass)
Definition: null.c:21
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
#define STATUS_END_OF_FILE
Definition: shellext.h:67
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1756
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void * PVOID
Definition: retypes.h:9
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
* PFILE_OBJECT
Definition: iotypes.h:1978
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:3148
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
#define PAGED_CODE()

Referenced by DriverEntry().

◆ NullQueryFileInformation()

NTSTATUS NTAPI NullQueryFileInformation ( OUT PVOID  Buffer,
IN PULONG  Length,
IN FILE_INFORMATION_CLASS  InformationClass 
)

Definition at line 21 of file null.c.

24 {
25  PFILE_STANDARD_INFORMATION StandardInfo = Buffer;
26 
27  PAGED_CODE();
28 
29  /* We only support one class */
31  {
32  /* Fail */
34  }
35 
36  /* Fill out the information */
37  RtlZeroMemory(StandardInfo, sizeof(FILE_STANDARD_INFORMATION));
38  StandardInfo->NumberOfLinks = 1;
39 
40  /* Return the length and success */
42  return STATUS_SUCCESS;
43 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
#define FileStandardInformation
Definition: propsheet.cpp:61
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1714
#define PAGED_CODE()

Referenced by NullDispatch().

◆ NullRead()

BOOLEAN NTAPI NullRead ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN ULONG  Length,
IN BOOLEAN  Wait,
IN ULONG  LockKey,
OUT PVOID  Buffer,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 47 of file null.c.

55 {
56  PAGED_CODE();
57 
58  /* Complete successfully */
59  IoStatus->Status = STATUS_END_OF_FILE;
60  IoStatus->Information = 0;
61  return TRUE;
62 }
#define TRUE
Definition: types.h:120
#define STATUS_END_OF_FILE
Definition: shellext.h:67
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
#define PAGED_CODE()

Referenced by DriverEntry().

◆ NullUnload()

VOID NTAPI NullUnload ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 160 of file null.c.

161 {
162  PDEVICE_OBJECT DeviceObject = DriverObject->DeviceObject;
163 
164  /* Delete the Null device */
166 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251

Referenced by DriverEntry().

◆ NullWrite()

BOOLEAN NTAPI NullWrite ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN ULONG  Length,
IN BOOLEAN  Wait,
IN ULONG  LockKey,
IN PVOID  Buffer,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 66 of file null.c.

74 {
75  PAGED_CODE();
76 
77  /* Complete successfully */
78  IoStatus->Status = STATUS_SUCCESS;
79  IoStatus->Information = Length;
80  return TRUE;
81 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define TRUE
Definition: types.h:120
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
#define STATUS_SUCCESS
Definition: shellext.h:65
#define PAGED_CODE()

Referenced by DriverEntry().

Variable Documentation

◆ FastIoDispatch