ReactOS  0.4.14-dev-599-g2d4d3f5
wmi.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/wmi/wmi.c
5  * PURPOSE: I/O Windows Management Instrumentation (WMI) Support
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define INITGUID
13 #include <wmiguid.h>
14 #include <wmidata.h>
15 #include <wmistr.h>
16 
17 #include "wmip.h"
18 
19 #define NDEBUG
20 #include <debug.h>
21 
22 typedef PVOID PWMI_LOGGER_INFORMATION; // FIXME
23 
24 typedef enum _WMI_CLOCK_TYPE
25 {
33 
34 /* FUNCTIONS *****************************************************************/
35 
36 BOOLEAN
37 NTAPI
39  VOID)
40 {
41  UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"\\Driver\\WMIxWDM");
43 
44  /* Initialize the GUID object type */
46  if (!NT_SUCCESS(Status))
47  {
48  DPRINT1("WmipInitializeGuidObjectType() failed: 0x%lx\n", Status);
49  return FALSE;
50  }
51 
52  /* Create the WMI driver */
53  Status = IoCreateDriver(&DriverName, WmipDriverEntry);
54  if (!NT_SUCCESS(Status))
55  {
56  DPRINT1("Failed to create WMI driver: 0x%lx\n", Status);
57  return FALSE;
58  }
59 
60  return TRUE;
61 }
62 
63 /*
64  * @unimplemented
65  */
67 NTAPI
69  IN ULONG Action)
70 {
71  DPRINT("IoWMIRegistrationControl() called for DO %p, requesting %lu action, returning success\n",
73 
74  return STATUS_SUCCESS;
75 }
76 
77 /*
78  * @unimplemented
79  */
81 NTAPI
85 {
88 }
89 
90 /*
91  * @unimplemented
92  */
94 NTAPI
96  IN PUNICODE_STRING SymbolicLinkName OPTIONAL,
97  IN BOOLEAN CombineNames,
98  OUT PUNICODE_STRING SuggestedInstanceName)
99 {
101  return STATUS_NOT_IMPLEMENTED;
102 }
103 
104 /*
105  * @unimplemented
106  */
107 NTSTATUS
108 NTAPI
109 IoWMIWriteEvent(IN PVOID WnodeEventItem)
110 {
111  DPRINT1("IoWMIWriteEvent() called for WnodeEventItem %p, returning success\n",
112  WnodeEventItem);
113 
114  /* Free the buffer if we are returning success */
115  if (WnodeEventItem != NULL)
116  ExFreePool(WnodeEventItem);
117 
118  return STATUS_SUCCESS;
119 }
120 
121 /*
122  * @unimplemented
123  */
124 NTSTATUS
125 NTAPI
127  _In_ LPCGUID DataBlockGuid,
129  _Out_ PVOID *DataBlockObject)
130 {
131  HANDLE GuidObjectHandle;
133 
134  /* Open the GIOD object */
135  Status = WmipOpenGuidObject(DataBlockGuid,
137  KernelMode,
138  &GuidObjectHandle,
139  DataBlockObject);
140  if (!NT_SUCCESS(Status))
141  {
142  DPRINT1("WmipOpenGuidObject failed: 0x%lx\n", Status);
143  return Status;
144  }
145 
146 
147  return STATUS_SUCCESS;
148 }
149 
150 /*
151  * @unimplemented
152  */
153 NTSTATUS
154 NTAPI
156  IN PVOID DataBlockObject,
157  IN OUT ULONG *InOutBufferSize,
158  OUT PVOID OutBuffer)
159 {
160  PWMIP_GUID_OBJECT GuidObject;
162 
163 
164  Status = ObReferenceObjectByPointer(DataBlockObject,
167  KernelMode);
168  if (!NT_SUCCESS(Status))
169  {
170  return Status;
171  }
172 
173  GuidObject = DataBlockObject;
174 
175  /* Huge HACK! */
176  if (IsEqualGUID(&GuidObject->Guid, &MSSmBios_RawSMBiosTables_GUID))
177  {
178  Status = WmipQueryRawSMBiosTables(InOutBufferSize, OutBuffer);
179  }
180  else
181  {
183  }
184 
185  ObDereferenceObject(DataBlockObject);
186 
187  return Status;
188 }
189 
190 /*
191  * @unimplemented
192  */
193 NTSTATUS
194 NTAPI
195 IoWMIQueryAllDataMultiple(IN PVOID *DataBlockObjectList,
197  IN OUT ULONG *InOutBufferSize,
198  OUT PVOID OutBuffer)
199 {
201  return STATUS_NOT_IMPLEMENTED;
202 }
203 
204 /*
205  * @unimplemented
206  */
207 NTSTATUS
208 NTAPI
211  IN OUT ULONG *InOutBufferSize,
212  OUT PVOID OutBuffer)
213 {
215  return STATUS_NOT_IMPLEMENTED;
216 }
217 
218 /*
219  * @unimplemented
220  */
221 NTSTATUS
222 NTAPI
224  IN PUNICODE_STRING InstanceNames,
226  IN OUT ULONG *InOutBufferSize,
227  OUT PVOID OutBuffer)
228 {
230  return STATUS_NOT_IMPLEMENTED;
231 }
232 
233 /*
234  * @unimplemented
235  */
236 NTSTATUS
237 NTAPI
240  IN ULONG Version,
241  IN ULONG ValueBufferSize,
242  IN PVOID ValueBuffer)
243 {
245  return STATUS_NOT_IMPLEMENTED;
246 }
247 
248 /*
249  * @unimplemented
250  */
251 NTSTATUS
252 NTAPI
253 IoWMISetSingleItem(IN PVOID DataBlockObject,
256  IN ULONG Version,
257  IN ULONG ValueBufferSize,
258  IN PVOID ValueBuffer)
259 {
261  return STATUS_NOT_IMPLEMENTED;
262 }
263 
264 /*
265  * @unimplemented
266  */
267 NTSTATUS
268 NTAPI
269 IoWMIExecuteMethod(IN PVOID DataBlockObject,
271  IN ULONG MethodId,
274  IN OUT PUCHAR InOutBuffer)
275 {
277  return STATUS_NOT_IMPLEMENTED;
278 }
279 
280 /*
281  * @unimplemented
282  */
283 NTSTATUS
284 NTAPI
287  IN PVOID Context)
288 {
290  return STATUS_NOT_IMPLEMENTED;
291 }
292 
293 /*
294  * @unimplemented
295  */
296 NTSTATUS
297 NTAPI
301 {
303  return STATUS_NOT_IMPLEMENTED;
304 }
305 
306 /*
307  * @unimplemented
308  */
309 NTSTATUS
310 NTAPI
314 {
316  return STATUS_NOT_IMPLEMENTED;
317 }
318 
319 /*
320  * @unimplemented
321  */
322 NTSTATUS
323 NTAPI
325  OUT PVOID TraceInformation,
329 {
331  return STATUS_NOT_IMPLEMENTED;
332 }
333 
334 /*
335  * @unimplemented
336  */
337 NTSTATUS
338 __cdecl
340  IN ULONG MessageFlags,
341  IN LPGUID MessageGuid,
343  IN ...)
344 {
346  return STATUS_NOT_IMPLEMENTED;
347 }
348 
349 /*
350  * @unimplemented
351  */
352 NTSTATUS
353 NTAPI
355  IN ULONG MessageFlags,
356  IN LPGUID MessageGuid,
358  IN va_list MessageArgList)
359 {
361  return STATUS_NOT_IMPLEMENTED;
362 }
363 
364 NTSTATUS
365 NTAPI
367 {
369  return STATUS_NOT_IMPLEMENTED;
370 }
371 
372 LONG64
373 FASTCALL
375  IN PVOID Context)
376 {
378  return STATUS_NOT_IMPLEMENTED;
379 }
380 
381 NTSTATUS
382 NTAPI
384 {
386  return STATUS_NOT_IMPLEMENTED;
387 }
388 
389 NTSTATUS
390 NTAPI
392 {
394  return STATUS_NOT_IMPLEMENTED;
395 }
396 
397 NTSTATUS
398 NTAPI
400 {
402  return STATUS_NOT_IMPLEMENTED;
403 }
404 
405 NTSTATUS
406 FASTCALL
408 {
410  return STATUS_NOT_IMPLEMENTED;
411 }
412 
413 NTSTATUS
414 NTAPI
416 {
418  return STATUS_NOT_IMPLEMENTED;
419 }
420 
421 /*
422  * @unimplemented
423  */
424 NTSTATUS
425 NTAPI
426 NtTraceEvent(IN ULONG TraceHandle,
427  IN ULONG Flags,
428  IN ULONG TraceHeaderLength,
429  IN struct _EVENT_TRACE_HEADER* TraceHeader)
430 {
432  return STATUS_NOT_IMPLEMENTED;
433 }
434 
435 /*Eof*/
#define IN
Definition: typedefs.h:38
NTSTATUS NTAPI WmiTraceMessageVa(IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPGUID MessageGuid, IN USHORT MessageNumber, IN va_list MessageArgList)
Definition: wmi.c:354
NTSTATUS NTAPI IoWMISetSingleItem(IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN ULONG DataItemId, IN ULONG Version, IN ULONG ValueBufferSize, IN PVOID ValueBuffer)
Definition: wmi.c:253
enum _TRACE_INFORMATION_CLASS TRACE_INFORMATION_CLASS
#define TRUE
Definition: types.h:120
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
ULONG64 TRACEHANDLE
Definition: evntrace.h:40
#define __cdecl
Definition: accygwin.h:79
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP _In_ ULONG _In_ ULONG DataItemId
Definition: classpnp.h:419
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS NTAPI IoWMISetNotificationCallback(IN PVOID Object, IN WMI_NOTIFICATION_CALLBACK Callback, IN PVOID Context)
Definition: wmi.c:285
NTSTATUS FASTCALL WmiTraceFastEvent(IN PWNODE_HEADER Wnode)
Definition: wmi.c:407
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoWMIAllocateInstanceIds(IN GUID *Guid, IN ULONG InstanceCount, OUT ULONG *FirstInstanceId)
Definition: wmi.c:82
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
Definition: classpnp.h:429
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
NTSTATUS NTAPI IoWMIWriteEvent(IN PVOID WnodeEventItem)
Definition: wmi.c:109
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1122
#define FASTCALL
Definition: nt_native.h:50
NTSTATUS NTAPI IoWMIQueryAllDataMultiple(IN PVOID *DataBlockObjectList, IN ULONG ObjectCount, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:195
_In_ ULONG _Out_ ULONG * FirstInstanceId
Definition: iofuncs.h:1319
NTSTATUS NTAPI WmiStopTrace(IN PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:399
LONG64 FASTCALL WmiGetClock(IN WMI_CLOCK_TYPE ClockType, IN PVOID Context)
Definition: wmi.c:374
NTSTATUS NTAPI IoWMIQuerySingleInstance(IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:209
HANDLE FileHandle
Definition: stats.c:38
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NTAPI WmiStartTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:391
NTSTATUS NTAPI IoWMIHandleToInstanceName(IN PVOID DataBlockObject, IN HANDLE FileHandle, OUT PUNICODE_STRING InstanceName)
Definition: wmi.c:298
LONG ObjectCount
Definition: comsup.c:7
NTSTATUS NTAPI IoWMIQueryAllData(IN PVOID DataBlockObject, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:155
unsigned char BOOLEAN
static GUID * Guid
Definition: apphelp.c:93
smooth NULL
Definition: ftsmooth.c:416
#define _Out_
Definition: no_sal2.h:323
char * va_list
Definition: acmsvcex.h:78
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:383
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
_In_ PIRP _In_ ULONG _In_ ULONG MethodId
Definition: classpnp.h:429
int64_t LONG64
Definition: typedefs.h:66
const GUID MSSmBios_RawSMBiosTables_GUID
Definition: hwhacks.c:20
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG InBufferSize
Definition: classpnp.h:429
NTSTATUS NTAPI WmipInitializeGuidObjectType(VOID)
Definition: guidobj.c:113
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS __cdecl WmiTraceMessage(IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPGUID MessageGuid, IN USHORT MessageNumber, IN ...)
Definition: wmi.c:339
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
NTSTATUS NTAPI WmiQueryTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:383
NTSTATUS NTAPI WmiQueryTraceInformation(IN TRACE_INFORMATION_CLASS TraceInformationClass, OUT PVOID TraceInformation, IN ULONG TraceInformationLength, OUT PULONG RequiredLength OPTIONAL, IN PVOID Buffer OPTIONAL)
Definition: wmi.c:324
static IUnknown Object
Definition: main.c:512
static const WCHAR L[]
Definition: oid.c:1250
enum _WMI_CLOCK_TYPE WMI_CLOCK_TYPE
NTSTATUS NTAPI IoWMISuggestInstanceName(IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN PUNICODE_STRING SymbolicLinkName OPTIONAL, IN BOOLEAN CombineNames, OUT PUNICODE_STRING SuggestedInstanceName)
Definition: wmi.c:95
NTSTATUS NTAPI IoWMISetSingleInstance(IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN ULONG Version, IN ULONG ValueBufferSize, IN PVOID ValueBuffer)
Definition: wmi.c:238
_WMI_CLOCK_TYPE
Definition: wmi.c:24
Status
Definition: gdiplustypes.h:24
#define _In_
Definition: no_sal2.h:204
NTSTATUS NTAPI IoWMIOpenBlock(_In_ LPCGUID DataBlockGuid, _In_ ULONG DesiredAccess, _Out_ PVOID *DataBlockObject)
Definition: wmi.c:126
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL, IN PDRIVER_INITIALIZE InitializationFunction)
Definition: driver.c:1683
unsigned short USHORT
Definition: pedump.c:61
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:29
#define WMIGUID_QUERY
Definition: wmistr.h:159
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
_Must_inspect_result_ typedef _In_ ULONG _In_ ULONG MessageNumber
Definition: iotypes.h:3947
unsigned int * PULONG
Definition: retypes.h:1
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define DPRINT1
Definition: precomp.h:8
#define WmipGuidObjectType
Definition: ObTypes.c:136
NTSTATUS NTAPI WmipOpenGuidObject(_In_ LPCGUID Guid, _In_ ACCESS_MASK DesiredAccess, _In_ KPROCESSOR_MODE AccessMode, _Out_ PHANDLE OutGuidObjectHandle, _Outptr_ PVOID *OutGuidObject)
Definition: guidobj.c:216
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1162
NTSTATUS NTAPI IoWMIDeviceObjectToInstanceName(IN PVOID DataBlockObject, IN PDEVICE_OBJECT DeviceObject, OUT PUNICODE_STRING InstanceName)
Definition: wmi.c:311
#define OUT
Definition: typedefs.h:39
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
FWMI_NOTIFICATION_CALLBACK * WMI_NOTIFICATION_CALLBACK
Definition: iotypes.h:3128
_In_ ULONG InstanceCount
Definition: iofuncs.h:1319
#define UNIMPLEMENTED
Definition: debug.h:114
BOOLEAN NTAPI WmiInitialize(VOID)
Definition: wmi.c:38
NTSTATUS NTAPI WmipQueryRawSMBiosTables(_Inout_ ULONG *InOutBufferSize, _Out_opt_ PVOID OutBuffer)
Definition: smbios.c:219
NTSTATUS NTAPI WmiFlushTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:366
NTSTATUS NTAPI NtTraceEvent(IN ULONG TraceHandle, IN ULONG Flags, IN ULONG TraceHeaderLength, IN struct _EVENT_TRACE_HEADER *TraceHeader)
Definition: wmi.c:426
PVOID PWMI_LOGGER_INFORMATION
Definition: wmi.c:22
NTSTATUS NTAPI IoWMIExecuteMethod(IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN ULONG MethodId, IN ULONG InBufferSize, IN OUT PULONG OutBufferSize, IN OUT PUCHAR InOutBuffer)
Definition: wmi.c:269
return STATUS_SUCCESS
Definition: btrfs.c:2938
LPFNPSPCALLBACK Callback
Definition: desk.c:111
_In_ ULONG TraceInformationLength
Definition: wmifuncs.h:29
NTSTATUS NTAPI WmiUpdateTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:415
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
NTSTATUS NTAPI IoWMIQuerySingleInstanceMultiple(IN PVOID *DataBlockObjectList, IN PUNICODE_STRING InstanceNames, IN ULONG ObjectCount, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:223
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68