2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: services/null/null.c
5 * PURPOSE: NULL device driver
6 * PROGRAMMER: David Welch (welch@mcmail.com)
11 /* INCLUDES ****************************************************************/
13 #include <ddk/ntddk.h>
15 /* FUNCTIONS **************************************************************/
17 NTSTATUS
NullWrite(PIRP Irp
, PIO_STACK_LOCATION stk
)
19 Irp
->IoStatus
.Information
= stk
->Parameters
.Write
.Length
;
20 return(STATUS_SUCCESS
);
23 NTSTATUS
NullRead(PIRP Irp
, PIO_STACK_LOCATION stk
)
25 Irp
->IoStatus
.Information
= 0;
26 return(STATUS_END_OF_FILE
);
29 NTSTATUS
NullDispatch(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
31 * FUNCTION: Handles user mode requests
33 * DeviceObject = Device for request
34 * Irp = I/O request packet describing request
35 * RETURNS: Success or failure
38 PIO_STACK_LOCATION Stack
= IoGetCurrentIrpStackLocation(Irp
);
41 switch (Stack
->MajorFunction
)
45 status
= STATUS_SUCCESS
;
49 status
= NullWrite(Irp
,Stack
);
53 status
= NullRead(Irp
,Stack
);
57 status
= STATUS_NOT_IMPLEMENTED
;
60 Irp
->IoStatus
.Status
= status
;
61 IoCompleteRequest(Irp
,IO_NO_INCREMENT
);
65 NTSTATUS
NullUnload(PDRIVER_OBJECT DriverObject
)
67 return(STATUS_SUCCESS
);
71 DriverEntry(PDRIVER_OBJECT DriverObject
, PUNICODE_STRING RegistryPath
)
73 * FUNCTION: Called by the system to initalize the driver
75 * DriverObject = object describing this driver
76 * RegistryPath = path to our configuration entries
77 * RETURNS: Success or failure
80 PDEVICE_OBJECT DeviceObject
;
82 ANSI_STRING ansi_device_name
;
83 UNICODE_STRING device_name
;
85 DbgPrint("Null Device Driver 0.0.2\n");
87 RtlInitAnsiString(&ansi_device_name
,"\\Device\\NUL");
88 RtlAnsiStringToUnicodeString(&device_name
,&ansi_device_name
,TRUE
);
89 ret
= IoCreateDevice(DriverObject
,0,&device_name
,
90 FILE_DEVICE_NULL
,0,FALSE
,&DeviceObject
);
91 if (ret
!=STATUS_SUCCESS
)
96 DeviceObject
->Flags
=0;
97 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = NullDispatch
;
98 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = NullDispatch
;
99 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = NullDispatch
;
100 DriverObject
->MajorFunction
[IRP_MJ_READ
] = NullDispatch
;
101 DriverObject
->DriverUnload
= NullUnload
;
103 return(STATUS_SUCCESS
);