ReactOS  0.4.15-dev-2721-g5912c11
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
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
110 {
111  PWNODE_HEADER Header = WnodeEventItem;
112 
113  if(!Header)
114  {
115  DPRINT1("Got NULL Item!\n");
117  }
118 
119  DPRINT1("IoWMIWriteEvent() called for WnodeEventItem %p (Flags = 0x%08lx), returning success\n",
120  WnodeEventItem, Header->Flags);
121 
122  if (Header->Flags & WNODE_FLAG_TRACED_GUID)
123  {
124  // Never free WnodeEventItem in this case.
125  DPRINT("IoWMIWriteEvent(): Flags has WNODE_FLAG_TRACED_GUID\n");
126  return STATUS_SUCCESS;
127  }
128 
129  /* Free the buffer if we are returning success */
130  ExFreePool(WnodeEventItem);
131 
132  return STATUS_SUCCESS;
133 }
134 
135 /*
136  * @unimplemented
137  */
138 NTSTATUS
139 NTAPI
141  _In_ LPCGUID DataBlockGuid,
143  _Out_ PVOID *DataBlockObject)
144 {
145  HANDLE GuidObjectHandle;
147 
148  /* Open the GIOD object */
149  Status = WmipOpenGuidObject(DataBlockGuid,
151  KernelMode,
152  &GuidObjectHandle,
153  DataBlockObject);
154  if (!NT_SUCCESS(Status))
155  {
156  DPRINT1("WmipOpenGuidObject failed: 0x%lx\n", Status);
157  return Status;
158  }
159 
160 
161  return STATUS_SUCCESS;
162 }
163 
164 /*
165  * @unimplemented
166  */
167 NTSTATUS
168 NTAPI
170  IN PVOID DataBlockObject,
171  IN OUT ULONG *InOutBufferSize,
173 {
174  PWMIP_GUID_OBJECT GuidObject;
176 
177 
178  Status = ObReferenceObjectByPointer(DataBlockObject,
181  KernelMode);
182  if (!NT_SUCCESS(Status))
183  {
184  return Status;
185  }
186 
187  GuidObject = DataBlockObject;
188 
189  /* Huge HACK! */
190  if (IsEqualGUID(&GuidObject->Guid, &MSSmBios_RawSMBiosTables_GUID))
191  {
192  Status = WmipQueryRawSMBiosTables(InOutBufferSize, OutBuffer);
193  }
194  else
195  {
197  }
198 
199  ObDereferenceObject(DataBlockObject);
200 
201  return Status;
202 }
203 
204 /*
205  * @unimplemented
206  */
207 NTSTATUS
208 NTAPI
209 IoWMIQueryAllDataMultiple(IN PVOID *DataBlockObjectList,
211  IN OUT ULONG *InOutBufferSize,
213 {
215  return STATUS_NOT_IMPLEMENTED;
216 }
217 
218 /*
219  * @unimplemented
220  */
221 NTSTATUS
222 NTAPI
225  IN OUT ULONG *InOutBufferSize,
227 {
229  return STATUS_NOT_IMPLEMENTED;
230 }
231 
232 /*
233  * @unimplemented
234  */
235 NTSTATUS
236 NTAPI
238  IN PUNICODE_STRING InstanceNames,
240  IN OUT ULONG *InOutBufferSize,
242 {
244  return STATUS_NOT_IMPLEMENTED;
245 }
246 
247 /*
248  * @unimplemented
249  */
250 NTSTATUS
251 NTAPI
254  IN ULONG Version,
255  IN ULONG ValueBufferSize,
256  IN PVOID ValueBuffer)
257 {
259  return STATUS_NOT_IMPLEMENTED;
260 }
261 
262 /*
263  * @unimplemented
264  */
265 NTSTATUS
266 NTAPI
267 IoWMISetSingleItem(IN PVOID DataBlockObject,
270  IN ULONG Version,
271  IN ULONG ValueBufferSize,
272  IN PVOID ValueBuffer)
273 {
275  return STATUS_NOT_IMPLEMENTED;
276 }
277 
278 /*
279  * @unimplemented
280  */
281 NTSTATUS
282 NTAPI
283 IoWMIExecuteMethod(IN PVOID DataBlockObject,
285  IN ULONG MethodId,
288  IN OUT PUCHAR InOutBuffer)
289 {
291  return STATUS_NOT_IMPLEMENTED;
292 }
293 
294 /*
295  * @unimplemented
296  */
297 NTSTATUS
298 NTAPI
301  IN PVOID Context)
302 {
304  return STATUS_NOT_IMPLEMENTED;
305 }
306 
307 /*
308  * @unimplemented
309  */
310 NTSTATUS
311 NTAPI
315 {
317  return STATUS_NOT_IMPLEMENTED;
318 }
319 
320 /*
321  * @unimplemented
322  */
323 NTSTATUS
324 NTAPI
328 {
330  return STATUS_NOT_IMPLEMENTED;
331 }
332 
333 /*
334  * @unimplemented
335  */
336 NTSTATUS
337 NTAPI
339  OUT PVOID TraceInformation,
343 {
345  return STATUS_NOT_IMPLEMENTED;
346 }
347 
348 /*
349  * @unimplemented
350  */
351 NTSTATUS
352 __cdecl
354  IN ULONG MessageFlags,
355  IN LPGUID MessageGuid,
357  IN ...)
358 {
360  return STATUS_NOT_IMPLEMENTED;
361 }
362 
363 /*
364  * @unimplemented
365  */
366 NTSTATUS
367 NTAPI
369  IN ULONG MessageFlags,
370  IN LPGUID MessageGuid,
372  IN va_list MessageArgList)
373 {
375  return STATUS_NOT_IMPLEMENTED;
376 }
377 
378 NTSTATUS
379 NTAPI
381 {
383  return STATUS_NOT_IMPLEMENTED;
384 }
385 
386 LONG64
387 FASTCALL
389  IN PVOID Context)
390 {
392  return STATUS_NOT_IMPLEMENTED;
393 }
394 
395 NTSTATUS
396 NTAPI
398 {
400  return STATUS_NOT_IMPLEMENTED;
401 }
402 
403 NTSTATUS
404 NTAPI
406 {
408  return STATUS_NOT_IMPLEMENTED;
409 }
410 
411 NTSTATUS
412 NTAPI
414 {
416  return STATUS_NOT_IMPLEMENTED;
417 }
418 
419 NTSTATUS
420 FASTCALL
422 {
424  return STATUS_NOT_IMPLEMENTED;
425 }
426 
427 NTSTATUS
428 NTAPI
430 {
432  return STATUS_NOT_IMPLEMENTED;
433 }
434 
435 /*
436  * @unimplemented
437  */
438 NTSTATUS
439 NTAPI
440 NtTraceEvent(IN ULONG TraceHandle,
441  IN ULONG Flags,
442  IN ULONG TraceHeaderLength,
443  IN struct _EVENT_TRACE_HEADER* TraceHeader)
444 {
446  return STATUS_NOT_IMPLEMENTED;
447 }
448 
449 /*Eof*/
#define IN
Definition: typedefs.h:39
return STATUS_NOT_SUPPORTED
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
NTSTATUS NTAPI WmiTraceMessageVa(IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPGUID MessageGuid, IN USHORT MessageNumber, IN va_list MessageArgList)
Definition: wmi.c:368
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:267
enum _TRACE_INFORMATION_CLASS TRACE_INFORMATION_CLASS
ULONG64 TRACEHANDLE
Definition: evntrace.h:40
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
#define __cdecl
Definition: accygwin.h:79
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS NTAPI IoWMISetNotificationCallback(IN PVOID Object, IN WMI_NOTIFICATION_CALLBACK Callback, IN PVOID Context)
Definition: wmi.c:299
NTSTATUS FASTCALL WmiTraceFastEvent(IN PWNODE_HEADER Wnode)
Definition: wmi.c:421
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoWMIAllocateInstanceIds(IN GUID *Guid, IN ULONG InstanceCount, OUT ULONG *FirstInstanceId)
Definition: wmi.c:82
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
#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:209
_In_ ULONG _Out_ ULONG * FirstInstanceId
Definition: iofuncs.h:1323
NTSTATUS NTAPI WmiStopTrace(IN PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:413
LONG64 FASTCALL WmiGetClock(IN WMI_CLOCK_TYPE ClockType, IN PVOID Context)
Definition: wmi.c:388
NTSTATUS NTAPI IoWMIQuerySingleInstance(IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:223
HANDLE FileHandle
Definition: stats.c:38
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
Definition: Header.h:8
NTSTATUS NTAPI WmiStartTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:405
NTSTATUS NTAPI IoWMIHandleToInstanceName(IN PVOID DataBlockObject, IN HANDLE FileHandle, OUT PUNICODE_STRING InstanceName)
Definition: wmi.c:312
LONG ObjectCount
Definition: comsup.c:7
NTSTATUS NTAPI IoWMIQueryAllData(IN PVOID DataBlockObject, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:169
unsigned char BOOLEAN
#define _Out_
Definition: no_sal2.h:160
char * va_list
Definition: acmsvcex.h:78
NTSTATUS NTAPI IoCreateDriver(_In_opt_ PUNICODE_STRING DriverName, _In_ PDRIVER_INITIALIZE InitializationFunction)
Definition: driver.c:1535
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:381
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
Status
Definition: gdiplustypes.h:24
_In_ ULONG DataItemId
Definition: wdfwmi.h:123
int64_t LONG64
Definition: typedefs.h:68
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
const GUID MSSmBios_RawSMBiosTables_GUID
Definition: hwhacks.c:20
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
NTSTATUS NTAPI WmipInitializeGuidObjectType(VOID)
Definition: guidobj.c:113
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:760
NTSTATUS __cdecl WmiTraceMessage(IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPGUID MessageGuid, IN USHORT MessageNumber, IN ...)
Definition: wmi.c:353
#define ObDereferenceObject
Definition: obfuncs.h:203
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
NTSTATUS NTAPI WmiQueryTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:397
#define _Inout_
Definition: no_sal2.h:162
_In_ ULONG MethodId
Definition: wdfwmi.h:142
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:338
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:252
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_WMI_CLOCK_TYPE
Definition: wmi.c:24
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
#define _In_
Definition: no_sal2.h:158
NTSTATUS NTAPI IoWMIOpenBlock(_In_ LPCGUID DataBlockGuid, _In_ ULONG DesiredAccess, _Out_ PVOID *DataBlockObject)
Definition: wmi.c:140
#define WNODE_FLAG_TRACED_GUID
Definition: wmistr.h:43
unsigned short USHORT
Definition: pedump.c:61
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:506
#define WMIGUID_QUERY
Definition: wmistr.h:159
_Must_inspect_result_ typedef _In_ ULONG _In_ ULONG MessageNumber
Definition: iotypes.h:4303
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:29
unsigned int * PULONG
Definition: retypes.h:1
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
NTSTATUS NTAPI IoWMIWriteEvent(_Inout_ PVOID WnodeEventItem)
Definition: wmi.c:109
#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:217
_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:325
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
FWMI_NOTIFICATION_CALLBACK * WMI_NOTIFICATION_CALLBACK
Definition: iotypes.h:3484
_In_ ULONG InstanceCount
Definition: iofuncs.h:1323
#define UNIMPLEMENTED
Definition: debug.h:115
BOOLEAN NTAPI WmiInitialize(VOID)
Definition: wmi.c:38
NTSTATUS NTAPI WmipQueryRawSMBiosTables(_Inout_ ULONG *InOutBufferSize, _Out_opt_ PVOID OutBuffer)
Definition: smbios.c:219
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI WmiFlushTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:380
#define DPRINT
Definition: sndvol32.h:71
NTSTATUS NTAPI NtTraceEvent(IN ULONG TraceHandle, IN ULONG Flags, IN ULONG TraceHeaderLength, IN struct _EVENT_TRACE_HEADER *TraceHeader)
Definition: wmi.c:440
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:283
_In_ ULONG TraceInformationLength
Definition: wmifuncs.h:29
NTSTATUS NTAPI WmiUpdateTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:429
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3736
NTSTATUS NTAPI IoWMIQuerySingleInstanceMultiple(IN PVOID *DataBlockObjectList, IN PUNICODE_STRING InstanceNames, IN ULONG ObjectCount, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:237
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68