2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/io/wmidrv.c
5 * PURPOSE: I/O Windows Management Instrumentation (WMI) Support
6 * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
9 /* INCLUDES *****************************************************************/
18 PDEVICE_OBJECT WmipServiceDeviceObject
;
19 PDEVICE_OBJECT WmipAdminDeviceObject
;
20 FAST_IO_DISPATCH WmipFastIoDispatch
;
23 /* FUNCTIONS *****************************************************************/
25 DRIVER_DISPATCH WmipOpenCloseCleanup
;
26 DRIVER_DISPATCH WmipIoControl
;
27 DRIVER_DISPATCH WmipSystemControl
;
28 DRIVER_DISPATCH WmipShutdown
;
33 _In_ PDEVICE_OBJECT DeviceObject
,
38 /* No work to do, just return success */
39 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
40 Irp
->IoStatus
.Information
= 0;
41 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
42 return STATUS_SUCCESS
;
48 _Inout_ PDEVICE_OBJECT DeviceObject
,
51 UNIMPLEMENTED_DBGBREAK();
52 return STATUS_NOT_IMPLEMENTED
;
58 _Inout_ PDEVICE_OBJECT DeviceObject
,
61 UNIMPLEMENTED_DBGBREAK();
62 return STATUS_NOT_IMPLEMENTED
;
68 _Inout_ PDEVICE_OBJECT DeviceObject
,
71 UNIMPLEMENTED_DBGBREAK();
72 return STATUS_NOT_IMPLEMENTED
;
75 _Function_class_(FAST_IO_DEVICE_CONTROL
)
79 WmipFastIoDeviceControl(
80 _In_ PFILE_OBJECT FileObject
,
82 _In_opt_ PVOID InputBuffer
,
83 _In_ ULONG InputBufferLength
,
84 _Out_opt_ PVOID OutputBuffer
,
85 _In_ ULONG OutputBufferLength
,
86 _In_ ULONG IoControlCode
,
87 _Out_ PIO_STATUS_BLOCK IoStatus
,
88 _In_ PDEVICE_OBJECT DeviceObject
)
90 UNIMPLEMENTED_DBGBREAK();
96 WmipDockUndockEventCallback(
97 _In_ PVOID NotificationStructure
,
98 _Inout_opt_ PVOID Context
)
100 UNIMPLEMENTED_DBGBREAK();
101 return STATUS_NOT_IMPLEMENTED
;
104 _Function_class_(DRIVER_INITIALIZE
)
109 _In_ PDRIVER_OBJECT DriverObject
,
110 _In_ PUNICODE_STRING RegistryPath
)
112 static UNICODE_STRING ServiceDeviceName
= RTL_CONSTANT_STRING(L
"\\Device\\WMIDataDevice");
113 static UNICODE_STRING ServiceDosDeviceName
= RTL_CONSTANT_STRING(L
"\\DosDevices\\WMIDataDevice");
114 static UNICODE_STRING AdminDeviceName
= RTL_CONSTANT_STRING(L
"\\Device\\WMIAdminDevice");
115 static UNICODE_STRING AdminDosDeviceName
= RTL_CONSTANT_STRING(L
"\\DosDevices\\WMIAdminDevice");
119 /* Create the service device object */
120 Status
= IoCreateDevice(DriverObject
,
124 FILE_DEVICE_SECURE_OPEN
,
126 &WmipServiceDeviceObject
);
127 if (!NT_SUCCESS(Status
))
129 DPRINT1("Failed to create service device: 0x%lx\n", Status
);
133 /* Create a symbolic link for the service device */
134 Status
= IoCreateSymbolicLink(&ServiceDosDeviceName
, &ServiceDeviceName
);
135 if (!NT_SUCCESS(Status
))
137 DPRINT1("IoCreateSymbolicLink() failed: 0x%lx\n", Status
);
138 IoDeleteDevice(WmipServiceDeviceObject
);
142 /* Create the admin device object */
143 Status
= IoCreateDevice(DriverObject
,
147 FILE_DEVICE_SECURE_OPEN
,
149 &WmipAdminDeviceObject
);
150 if (!NT_SUCCESS(Status
))
152 DPRINT1("Failed to create admin device: 0x%lx\n", Status
);
153 IoDeleteDevice(WmipServiceDeviceObject
);
154 IoDeleteSymbolicLink(&ServiceDosDeviceName
);
158 /* Create a symbolic link for the admin device */
159 Status
= IoCreateSymbolicLink(&AdminDosDeviceName
, &AdminDeviceName
);
160 if (!NT_SUCCESS(Status
))
162 DPRINT1("IoCreateSymbolicLink() failed: 0x%lx\n", Status
);
163 IoDeleteSymbolicLink(&ServiceDosDeviceName
);
164 IoDeleteDevice(WmipServiceDeviceObject
);
165 IoDeleteDevice(WmipAdminDeviceObject
);
169 /* Initialize dispatch routines */
170 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = WmipOpenCloseCleanup
;
171 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = WmipOpenCloseCleanup
;
172 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = WmipIoControl
;
173 DriverObject
->MajorFunction
[IRP_MJ_CLEANUP
] = WmipOpenCloseCleanup
;
174 DriverObject
->MajorFunction
[IRP_MJ_SYSTEM_CONTROL
] = WmipSystemControl
;
175 DriverObject
->MajorFunction
[IRP_MJ_SHUTDOWN
] = WmipShutdown
;
177 /* Initialize fast dispatch */
178 RtlZeroMemory(&WmipFastIoDispatch
, sizeof(WmipFastIoDispatch
));
179 WmipFastIoDispatch
.SizeOfFastIoDispatch
= sizeof(WmipFastIoDispatch
);
180 WmipFastIoDispatch
.FastIoDeviceControl
= WmipFastIoDeviceControl
;
181 DriverObject
->FastIoDispatch
= &WmipFastIoDispatch
;
183 /* Register the WMI service device */
184 IoWMIRegistrationControl(WmipServiceDeviceObject
, WMIREG_ACTION_REGISTER
);
186 /* Register a shutdown notification */
187 IoRegisterShutdownNotification(WmipServiceDeviceObject
);
189 /* Initialization is done */
190 WmipServiceDeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
191 WmipAdminDeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
193 return STATUS_SUCCESS
;