ReactOS 0.4.15-dev-7994-gb388cb6
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{
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 PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
Status
Definition: gdiplustypes.h:25
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
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 L(x)
Definition: ntvdm.h:50
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
VOID NTAPI NullUnload(IN PDRIVER_OBJECT DriverObject)
Definition: null.c:160
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
FAST_IO_DISPATCH FastIoDispatch
Definition: null.c:15
NTSTATUS NTAPI NullDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: null.c:85
#define FILE_DEVICE_NULL
Definition: winioctl.h:127
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define STATUS_SUCCESS
Definition: shellext.h:65
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1736
ULONG SizeOfFastIoDispatch
Definition: iotypes.h:1733
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1735
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3557
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_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 _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

◆ NullDispatch()

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

Definition at line 85 of file null.c.

87{
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
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->
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}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PIRP Irp
Definition: csq.h:116
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI NullQueryFileInformation(OUT PVOID Buffer, IN PULONG Length, IN FILE_INFORMATION_CLASS InformationClass)
Definition: null.c:21
#define STATUS_END_OF_FILE
Definition: shellext.h:67
struct _IO_STACK_LOCATION::@3979::@3984 Write
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
union _IO_STACK_LOCATION::@1564 Parameters
struct _IO_STACK_LOCATION::@3979::@3988 QueryFile
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
#define IO_NO_INCREMENT
Definition: iotypes.h:598
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1776

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{
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}
Definition: bufpool.h:45
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1713
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define FileStandardInformation
Definition: propsheet.cpp:61

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 */
60 IoStatus->Information = 0;
61 return TRUE;
62}
#define TRUE
Definition: types.h:120
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159

Referenced by DriverEntry().

◆ NullUnload()

VOID NTAPI NullUnload ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 160 of file null.c.

161{
163
164 /* Delete the Null device */
166}
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}

Referenced by DriverEntry().

Variable Documentation

◆ FastIoDispatch