ReactOS 0.4.16-dev-197-g92996da
init.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Drivers
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/sac/driver/init.c
5 * PURPOSE: Driver for the Server Administration Console (SAC) for EMS
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "sacdrv.h"
12
13/* FUNCTIONS ******************************************************************/
14
19{
20 HEADLESS_RSP_QUERY_INFO HeadlessInformation;
21 SIZE_T InfoSize = sizeof(HeadlessInformation);
23 UNICODE_STRING DriverName;
25 PSAC_DEVICE_EXTENSION DeviceExtension;
26 PAGED_CODE();
27 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering.\n");
28
29 /* Check if EMS is enabled in the kernel */
31 NULL,
32 0,
33 &HeadlessInformation,
34 &InfoSize);
35 if ((HeadlessInformation.PortType != HeadlessUndefinedPortType) &&
36 ((HeadlessInformation.PortType != HeadlessSerialPort) ||
37 (HeadlessInformation.Serial.TerminalAttached)))
38 {
39 /* It is, so create the device */
40 RtlInitUnicodeString(&DriverName, L"\\Device\\SAC");
43 &DriverName,
46 FALSE,
48 if (NT_SUCCESS(Status))
49 {
50 /* Setup the device extension */
51 DeviceExtension = DeviceObject->DeviceExtension;
52 DeviceExtension->Initialized = FALSE;
53
54 /* Initialize the driver object */
55 RtlFillMemoryUlong(DriverObject->MajorFunction,
56 RTL_NUMBER_OF(DriverObject->MajorFunction),
60 DriverObject->FastIoDispatch = NULL;
61 DriverObject->DriverUnload = UnloadHandler;
62
63 /* Initialize driver data */
65 {
66 /* Initialize device data */
68 {
69 /* We're all good, register a shutdown notification */
71 return Status;
72 }
73 }
74
75 /* One of the initializations failed, bail out */
77 }
78 else
79 {
80 /* Print a debug statement if enabled */
81 SAC_DBG(SAC_DBG_INIT, "unable to create device object: %X\n", Status);
82 }
83
84 /* Free any data we may have allocated and exit with failure */
86 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting with status 0x%x\n", Status);
87 return Status;
88 }
89
90 /* EMS is not enabled */
92}
#define PAGED_CODE()
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
BOOLEAN NTAPI InitializeDeviceData(IN PDEVICE_OBJECT DeviceObject)
Definition: data.c:216
VOID NTAPI FreeGlobalData(VOID)
Definition: data.c:100
BOOLEAN NTAPI InitializeGlobalData(IN PUNICODE_STRING RegistryPath, IN PDRIVER_OBJECT DriverObject)
Definition: data.c:374
NTSTATUS NTAPI DispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:21
NTSTATUS NTAPI DispatchShutdownControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:29
Status
Definition: gdiplustypes.h:25
@ HeadlessCmdQueryInformation
Definition: hdl.h:144
@ HeadlessUndefinedPortType
Definition: hdl.h:155
@ HeadlessSerialPort
Definition: hdl.h:156
NTSTATUS NTAPI HeadlessDispatch(IN HEADLESS_CMD Command, IN PVOID InputBuffer, IN SIZE_T InputBufferSize, OUT PVOID OutputBuffer, OUT PSIZE_T OutputBufferSize)
Definition: hdlsterm.c:570
#define RtlFillMemoryUlong(dst, len, val)
Definition: mkhive.h:55
_In_ PDRIVER_UNLOAD UnloadHandler
Definition: ndis.h:4688
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
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
NTSTATUS NTAPI IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1694
#define STATUS_PORT_DISCONNECTED
Definition: ntstatus.h:291
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_UNKNOWN
Definition: winioctl.h:79
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
#define SAC_DBG_INIT
Definition: sacdrv.h:34
struct _HEADLESS_RSP_QUERY_INFO::@1785::@1787 Serial
HEADLESS_TERM_PORT_TYPE PortType
Definition: hdl.h:170
BOOLEAN Initialized
Definition: sacdrv.h:509
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_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
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:188
#define IRP_MJ_SHUTDOWN