ReactOS  0.4.14-dev-50-g13bb5e2
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 
16 NTAPI
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.Serial.TerminalType != HeadlessUndefinedPortType) &&
36  ((HeadlessInformation.Serial.TerminalType != HeadlessSerialPort) ||
37  (HeadlessInformation.Serial.TerminalAttached)))
38  {
39  /* It is, so create the device */
40  RtlInitUnicodeString(&DriverName, L"\\Device\\SAC");
42  sizeof(SAC_DEVICE_EXTENSION),
43  &DriverName,
46  FALSE,
47  &DeviceObject);
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 */
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 }
NTSTATUS NTAPI DispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:21
#define IN
Definition: typedefs.h:38
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MJ_SHUTDOWN
BOOLEAN NTAPI InitializeGlobalData(IN PUNICODE_STRING RegistryPath, IN PDRIVER_OBJECT DriverObject)
Definition: data.c:371
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
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
uint32_t ULONG_PTR
Definition: typedefs.h:63
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
Definition: init.c:700
_In_ PDRIVER_UNLOAD UnloadHandler
Definition: ndis.h:4688
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define RtlFillMemoryUlong(dst, len, val)
Definition: mkhive.h:55
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI FreeGlobalData(VOID)
Definition: data.c:100
BOOLEAN Initialized
Definition: sacdrv.h:508
BOOLEAN NTAPI InitializeDeviceData(IN PDEVICE_OBJECT DeviceObject)
Definition: data.c:213
static const WCHAR L[]
Definition: oid.c:1250
#define SAC_DBG_INIT
Definition: sacdrv.h:34
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2180
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
Status
Definition: gdiplustypes.h:24
struct _HEADLESS_RSP_QUERY_INFO::@1712::@1714 Serial
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:182
NTSTATUS NTAPI DispatchShutdownControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:29
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define FILE_DEVICE_UNKNOWN
Definition: winioctl.h:139
NTSTATUS NTAPI IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1694
struct _FAST_IO_DISPATCH * FastIoDispatch
Definition: iotypes.h:2177
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2181
#define STATUS_PORT_DISCONNECTED
Definition: ntstatus.h:277
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52