ReactOS 0.4.16-dev-319-g6cf4263
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
23
24typedef enum _WMI_CLOCK_TYPE
25{
33
34/* FUNCTIONS *****************************************************************/
35
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 */
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 */
85{
88}
89
90/*
91 * @unimplemented
92 */
97 IN BOOLEAN CombineNames,
98 OUT PUNICODE_STRING SuggestedInstanceName)
99{
102}
103
104/*
105 * @unimplemented
106 */
108NTAPI
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 */
139NTAPI
141 _In_ LPCGUID DataBlockGuid,
143 _Out_ PVOID *DataBlockObject)
144{
145 HANDLE GuidObjectHandle;
147
148 /* Open the GIOD object */
149 Status = WmipOpenGuidObject(DataBlockGuid,
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 */
168NTAPI
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! */
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 */
208NTAPI
209IoWMIQueryAllDataMultiple(IN PVOID *DataBlockObjectList,
211 IN OUT ULONG *InOutBufferSize,
213{
216}
217
218/*
219 * @unimplemented
220 */
222NTAPI
225 IN OUT ULONG *InOutBufferSize,
227{
230}
231
232/*
233 * @unimplemented
234 */
236NTAPI
238 IN PUNICODE_STRING InstanceNames,
240 IN OUT ULONG *InOutBufferSize,
242{
245}
246
247/*
248 * @unimplemented
249 */
251NTAPI
255 IN ULONG ValueBufferSize,
256 IN PVOID ValueBuffer)
257{
260}
261
262/*
263 * @unimplemented
264 */
266NTAPI
271 IN ULONG ValueBufferSize,
272 IN PVOID ValueBuffer)
273{
276}
277
278/*
279 * @unimplemented
280 */
282NTAPI
288 IN OUT PUCHAR InOutBuffer)
289{
292}
293
294/*
295 * @unimplemented
296 */
298NTAPI
302{
305}
306
307/*
308 * @unimplemented
309 */
311NTAPI
315{
318}
319
320/*
321 * @unimplemented
322 */
324NTAPI
328{
331}
332
333/*
334 * @unimplemented
335 */
337NTAPI
339 OUT PVOID TraceInformation,
343{
346}
347
348/*
349 * @unimplemented
350 */
354 IN ULONG MessageFlags,
355 IN LPGUID MessageGuid,
357 IN ...)
358{
361}
362
363/*
364 * @unimplemented
365 */
367NTAPI
369 IN ULONG MessageFlags,
370 IN LPGUID MessageGuid,
372 IN va_list MessageArgList)
373{
376}
377
379NTAPI
381{
384}
385
386LONG64
390{
393}
394
396NTAPI
398{
401}
402
404NTAPI
406{
409}
410
412NTAPI
414{
417}
418
422{
425}
426
428NTAPI
430{
433}
434
435/*
436 * @unimplemented
437 */
439NTAPI
441 IN ULONG Flags,
442 IN ULONG TraceHeaderLength,
443 IN struct _EVENT_TRACE_HEADER* TraceHeader)
444{
447}
448
449/*Eof*/
#define WmipGuidObjectType
Definition: ObTypes.c:131
unsigned char BOOLEAN
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
Definition: bufpool.h:45
Definition: Header.h:9
LONG ObjectCount
Definition: comsup.c:7
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
ULONG64 TRACEHANDLE
Definition: evntrace.h:40
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1163
#define WmiQueryTraceInformation
Definition: fxwmicompat.h:64
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI WmipInitializeGuidObjectType(VOID)
Definition: guidobj.c:113
NTSTATUS NTAPI WmipOpenGuidObject(_In_ LPCGUID Guid, _In_ ACCESS_MASK DesiredAccess, _In_ KPROCESSOR_MODE AccessMode, _Out_ PHANDLE OutGuidObjectHandle, _Outptr_ PVOID *OutGuidObject)
Definition: guidobj.c:217
const GUID MSSmBios_RawSMBiosTables_GUID
Definition: hwhacks.c:20
#define KernelMode
Definition: asm.h:34
#define _Inout_
Definition: no_sal2.h:162
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define FASTCALL
Definition: nt_native.h:50
NTSTATUS NTAPI IoCreateDriver(_In_opt_ PUNICODE_STRING DriverName, _In_ PDRIVER_INITIALIZE InitializationFunction)
Definition: driver.c:1576
NTSTATUS NTAPI WmipQueryRawSMBiosTables(_Inout_ ULONG *InOutBufferSize, _Out_opt_ PVOID OutBuffer)
Definition: smbios.c:220
NTSTATUS NTAPI WmiFlushTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:380
NTSTATUS NTAPI IoWMISetNotificationCallback(IN PVOID Object, IN WMI_NOTIFICATION_CALLBACK Callback, IN PVOID Context)
Definition: wmi.c:299
NTSTATUS NTAPI IoWMIOpenBlock(_In_ LPCGUID DataBlockGuid, _In_ ULONG DesiredAccess, _Out_ PVOID *DataBlockObject)
Definition: wmi.c:140
NTSTATUS NTAPI IoWMIAllocateInstanceIds(IN GUID *Guid, IN ULONG InstanceCount, OUT ULONG *FirstInstanceId)
Definition: wmi.c:82
LONG64 FASTCALL WmiGetClock(IN WMI_CLOCK_TYPE ClockType, IN PVOID Context)
Definition: wmi.c:388
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
NTSTATUS NTAPI IoWMIQuerySingleInstanceMultiple(IN PVOID *DataBlockObjectList, IN PUNICODE_STRING InstanceNames, IN ULONG ObjectCount, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:237
NTSTATUS FASTCALL WmiTraceFastEvent(IN PWNODE_HEADER Wnode)
Definition: wmi.c:421
NTSTATUS NTAPI IoWMIWriteEvent(_Inout_ PVOID WnodeEventItem)
Definition: wmi.c:109
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 IoWMIQueryAllDataMultiple(IN PVOID *DataBlockObjectList, IN ULONG ObjectCount, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:209
BOOLEAN NTAPI WmiInitialize(VOID)
Definition: wmi.c:38
NTSTATUS NTAPI IoWMIDeviceObjectToInstanceName(IN PVOID DataBlockObject, IN PDEVICE_OBJECT DeviceObject, OUT PUNICODE_STRING InstanceName)
Definition: wmi.c:325
NTSTATUS NTAPI WmiTraceMessageVa(IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPGUID MessageGuid, IN USHORT MessageNumber, IN va_list MessageArgList)
Definition: wmi.c:368
NTSTATUS __cdecl WmiTraceMessage(IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPGUID MessageGuid, IN USHORT MessageNumber, IN ...)
Definition: wmi.c:353
enum _WMI_CLOCK_TYPE WMI_CLOCK_TYPE
_WMI_CLOCK_TYPE
Definition: wmi.c:25
@ WMICT_CPUCYCLE
Definition: wmi.c:31
@ WMICT_SYSTEMTIME
Definition: wmi.c:27
@ WMICT_PERFCOUNTER
Definition: wmi.c:28
@ WMICT_THREAD
Definition: wmi.c:30
@ WMICT_DEFAULT
Definition: wmi.c:26
@ WMICT_PROCESS
Definition: wmi.c:29
NTSTATUS NTAPI WmiStopTrace(IN PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:413
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
NTSTATUS NTAPI WmiStartTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:405
PVOID PWMI_LOGGER_INFORMATION
Definition: wmi.c:22
NTSTATUS NTAPI WmiQueryTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:397
NTSTATUS NTAPI IoWMISetSingleInstance(IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN ULONG Version, IN ULONG ValueBufferSize, IN PVOID ValueBuffer)
Definition: wmi.c:252
NTSTATUS NTAPI NtTraceEvent(IN ULONG TraceHandle, IN ULONG Flags, IN ULONG TraceHeaderLength, IN struct _EVENT_TRACE_HEADER *TraceHeader)
Definition: wmi.c:440
NTSTATUS NTAPI WmiUpdateTrace(IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
Definition: wmi.c:429
NTSTATUS NTAPI IoWMIHandleToInstanceName(IN PVOID DataBlockObject, IN HANDLE FileHandle, OUT PUNICODE_STRING InstanceName)
Definition: wmi.c:312
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
NTSTATUS NTAPI IoWMIQuerySingleInstance(IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:223
NTSTATUS NTAPI IoWMIQueryAllData(IN PVOID DataBlockObject, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:169
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:381
unsigned short USHORT
Definition: pedump.c:61
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t * PULONG
Definition: typedefs.h:59
int64_t LONG64
Definition: typedefs.h:68
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3739
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
_In_ ULONG MethodId
Definition: wdfwmi.h:142
_In_ ULONG DataItemId
Definition: wdfwmi.h:123
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:30
_In_ ULONG TraceInformationLength
Definition: wmifuncs.h:29
#define WNODE_FLAG_TRACED_GUID
Definition: wmistr.h:43
#define WMIGUID_QUERY
Definition: wmistr.h:159
enum _TRACE_INFORMATION_CLASS TRACE_INFORMATION_CLASS
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG InstanceCount
Definition: iofuncs.h:1323
_In_ ULONG _Out_ ULONG * FirstInstanceId
Definition: iofuncs.h:1324
_Must_inspect_result_ typedef _In_ ULONG _In_ ULONG MessageNumber
Definition: iotypes.h:4304
FWMI_NOTIFICATION_CALLBACK * WMI_NOTIFICATION_CALLBACK
Definition: iotypes.h:3484
#define ObDereferenceObject
Definition: obfuncs.h:203