ReactOS 0.4.15-dev-5874-gc762234
wmi.c File Reference
#include <ntoskrnl.h>
#include <wmiguid.h>
#include <wmidata.h>
#include <wmistr.h>
#include "wmip.h"
#include <debug.h>
Include dependency graph for wmi.c:

Go to the source code of this file.

Macros

#define INITGUID
 
#define NDEBUG
 

Typedefs

typedef PVOID PWMI_LOGGER_INFORMATION
 
typedef enum _WMI_CLOCK_TYPE WMI_CLOCK_TYPE
 

Enumerations

enum  _WMI_CLOCK_TYPE {
  WMICT_DEFAULT , WMICT_SYSTEMTIME , WMICT_PERFCOUNTER , WMICT_PROCESS ,
  WMICT_THREAD , WMICT_CPUCYCLE
}
 

Functions

BOOLEAN NTAPI WmiInitialize (VOID)
 
NTSTATUS NTAPI IoWMIRegistrationControl (IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
 
NTSTATUS NTAPI IoWMIAllocateInstanceIds (IN GUID *Guid, IN ULONG InstanceCount, OUT ULONG *FirstInstanceId)
 
NTSTATUS NTAPI IoWMISuggestInstanceName (IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN PUNICODE_STRING SymbolicLinkName OPTIONAL, IN BOOLEAN CombineNames, OUT PUNICODE_STRING SuggestedInstanceName)
 
NTSTATUS NTAPI IoWMIWriteEvent (_Inout_ PVOID WnodeEventItem)
 
NTSTATUS NTAPI IoWMIOpenBlock (_In_ LPCGUID DataBlockGuid, _In_ ULONG DesiredAccess, _Out_ PVOID *DataBlockObject)
 
NTSTATUS NTAPI IoWMIQueryAllData (IN PVOID DataBlockObject, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
 
NTSTATUS NTAPI IoWMIQueryAllDataMultiple (IN PVOID *DataBlockObjectList, IN ULONG ObjectCount, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
 
NTSTATUS NTAPI IoWMIQuerySingleInstance (IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
 
NTSTATUS NTAPI IoWMIQuerySingleInstanceMultiple (IN PVOID *DataBlockObjectList, IN PUNICODE_STRING InstanceNames, IN ULONG ObjectCount, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
 
NTSTATUS NTAPI IoWMISetSingleInstance (IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN ULONG Version, IN ULONG ValueBufferSize, IN PVOID ValueBuffer)
 
NTSTATUS NTAPI IoWMISetSingleItem (IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN ULONG DataItemId, IN ULONG Version, IN ULONG ValueBufferSize, IN PVOID ValueBuffer)
 
NTSTATUS NTAPI IoWMIExecuteMethod (IN PVOID DataBlockObject, IN PUNICODE_STRING InstanceName, IN ULONG MethodId, IN ULONG InBufferSize, IN OUT PULONG OutBufferSize, IN OUT PUCHAR InOutBuffer)
 
NTSTATUS NTAPI IoWMISetNotificationCallback (IN PVOID Object, IN WMI_NOTIFICATION_CALLBACK Callback, IN PVOID Context)
 
NTSTATUS NTAPI IoWMIHandleToInstanceName (IN PVOID DataBlockObject, IN HANDLE FileHandle, OUT PUNICODE_STRING InstanceName)
 
NTSTATUS NTAPI IoWMIDeviceObjectToInstanceName (IN PVOID DataBlockObject, IN PDEVICE_OBJECT DeviceObject, OUT PUNICODE_STRING InstanceName)
 
NTSTATUS NTAPI WmiQueryTraceInformation (IN TRACE_INFORMATION_CLASS TraceInformationClass, OUT PVOID TraceInformation, IN ULONG TraceInformationLength, OUT PULONG RequiredLength OPTIONAL, IN PVOID Buffer OPTIONAL)
 
NTSTATUS __cdecl WmiTraceMessage (IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPGUID MessageGuid, IN USHORT MessageNumber, IN ...)
 
NTSTATUS NTAPI WmiTraceMessageVa (IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPGUID MessageGuid, IN USHORT MessageNumber, IN va_list MessageArgList)
 
NTSTATUS NTAPI WmiFlushTrace (IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
 
LONG64 FASTCALL WmiGetClock (IN WMI_CLOCK_TYPE ClockType, IN PVOID Context)
 
NTSTATUS NTAPI WmiQueryTrace (IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
 
NTSTATUS NTAPI WmiStartTrace (IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
 
NTSTATUS NTAPI WmiStopTrace (IN PWMI_LOGGER_INFORMATION LoggerInfo)
 
NTSTATUS FASTCALL WmiTraceFastEvent (IN PWNODE_HEADER Wnode)
 
NTSTATUS NTAPI WmiUpdateTrace (IN OUT PWMI_LOGGER_INFORMATION LoggerInfo)
 
NTSTATUS NTAPI NtTraceEvent (IN ULONG TraceHandle, IN ULONG Flags, IN ULONG TraceHeaderLength, IN struct _EVENT_TRACE_HEADER *TraceHeader)
 

Macro Definition Documentation

◆ INITGUID

#define INITGUID

Definition at line 12 of file wmi.c.

◆ NDEBUG

#define NDEBUG

Definition at line 19 of file wmi.c.

Typedef Documentation

◆ PWMI_LOGGER_INFORMATION

Definition at line 22 of file wmi.c.

◆ WMI_CLOCK_TYPE

Enumeration Type Documentation

◆ _WMI_CLOCK_TYPE

Enumerator
WMICT_DEFAULT 
WMICT_SYSTEMTIME 
WMICT_PERFCOUNTER 
WMICT_PROCESS 
WMICT_THREAD 
WMICT_CPUCYCLE 

Definition at line 24 of file wmi.c.

25{
enum _WMI_CLOCK_TYPE WMI_CLOCK_TYPE
@ 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

Function Documentation

◆ IoWMIAllocateInstanceIds()

NTSTATUS NTAPI IoWMIAllocateInstanceIds ( IN GUID Guid,
IN ULONG  InstanceCount,
OUT ULONG FirstInstanceId 
)

Definition at line 82 of file wmi.c.

85{
88}
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

◆ IoWMIDeviceObjectToInstanceName()

NTSTATUS NTAPI IoWMIDeviceObjectToInstanceName ( IN PVOID  DataBlockObject,
IN PDEVICE_OBJECT  DeviceObject,
OUT PUNICODE_STRING  InstanceName 
)

Definition at line 325 of file wmi.c.

328{
331}

◆ IoWMIExecuteMethod()

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 at line 283 of file wmi.c.

289{
292}

◆ IoWMIHandleToInstanceName()

NTSTATUS NTAPI IoWMIHandleToInstanceName ( IN PVOID  DataBlockObject,
IN HANDLE  FileHandle,
OUT PUNICODE_STRING  InstanceName 
)

Definition at line 312 of file wmi.c.

315{
318}

◆ IoWMIOpenBlock()

NTSTATUS NTAPI IoWMIOpenBlock ( _In_ LPCGUID  DataBlockGuid,
_In_ ULONG  DesiredAccess,
_Out_ PVOID DataBlockObject 
)

Definition at line 140 of file wmi.c.

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}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI WmipOpenGuidObject(_In_ LPCGUID Guid, _In_ ACCESS_MASK DesiredAccess, _In_ KPROCESSOR_MODE AccessMode, _Out_ PHANDLE OutGuidObjectHandle, _Outptr_ PVOID *OutGuidObject)
Definition: guidobj.c:217
#define KernelMode
Definition: asm.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658

Referenced by ExpGetRawSMBiosTable(), and i8042InitializeHwHacks().

◆ IoWMIQueryAllData()

NTSTATUS NTAPI IoWMIQueryAllData ( IN PVOID  DataBlockObject,
IN OUT ULONG InOutBufferSize,
OUT PVOID  OutBuffer 
)

Definition at line 169 of file wmi.c.

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}
#define WmipGuidObjectType
Definition: ObTypes.c:131
const GUID MSSmBios_RawSMBiosTables_GUID
Definition: hwhacks.c:20
NTSTATUS NTAPI WmipQueryRawSMBiosTables(_Inout_ ULONG *InOutBufferSize, _Out_opt_ PVOID OutBuffer)
Definition: smbios.c:220
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:381
#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 WMIGUID_QUERY
Definition: wmistr.h:159
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by ExpGetRawSMBiosTable(), and i8042InitializeHwHacks().

◆ IoWMIQueryAllDataMultiple()

NTSTATUS NTAPI IoWMIQueryAllDataMultiple ( IN PVOID DataBlockObjectList,
IN ULONG  ObjectCount,
IN OUT ULONG InOutBufferSize,
OUT PVOID  OutBuffer 
)

Definition at line 209 of file wmi.c.

213{
216}

◆ IoWMIQuerySingleInstance()

NTSTATUS NTAPI IoWMIQuerySingleInstance ( IN PVOID  DataBlockObject,
IN PUNICODE_STRING  InstanceName,
IN OUT ULONG InOutBufferSize,
OUT PVOID  OutBuffer 
)

Definition at line 223 of file wmi.c.

227{
230}

◆ IoWMIQuerySingleInstanceMultiple()

NTSTATUS NTAPI IoWMIQuerySingleInstanceMultiple ( IN PVOID DataBlockObjectList,
IN PUNICODE_STRING  InstanceNames,
IN ULONG  ObjectCount,
IN OUT ULONG InOutBufferSize,
OUT PVOID  OutBuffer 
)

Definition at line 237 of file wmi.c.

242{
245}

◆ IoWMIRegistrationControl()

NTSTATUS NTAPI IoWMIRegistrationControl ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  Action 
)

Definition at line 68 of file wmi.c.

70{
71 DPRINT("IoWMIRegistrationControl() called for DO %p, requesting %lu action, returning success\n",
73
74 return STATUS_SUCCESS;
75}
#define DPRINT
Definition: sndvol32.h:71
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

Referenced by _Function_class_(), CmBattWmiDeRegistration(), CmBattWmiRegistration(), FxWmiIrpHandler::Deregister(), DiskReregWorker(), FreeBT_WmiDeRegistration(), FreeBT_WmiRegistration(), InPortWmiDeRegistration(), InPortWmiRegistration(), FxWmiIrpHandler::Register(), and FxWmiIrpHandler::UpdateGuids().

◆ IoWMISetNotificationCallback()

NTSTATUS NTAPI IoWMISetNotificationCallback ( IN PVOID  Object,
IN WMI_NOTIFICATION_CALLBACK  Callback,
IN PVOID  Context 
)

Definition at line 299 of file wmi.c.

302{
305}

◆ IoWMISetSingleInstance()

NTSTATUS NTAPI IoWMISetSingleInstance ( IN PVOID  DataBlockObject,
IN PUNICODE_STRING  InstanceName,
IN ULONG  Version,
IN ULONG  ValueBufferSize,
IN PVOID  ValueBuffer 
)

Definition at line 252 of file wmi.c.

257{
260}

◆ IoWMISetSingleItem()

NTSTATUS NTAPI IoWMISetSingleItem ( IN PVOID  DataBlockObject,
IN PUNICODE_STRING  InstanceName,
IN ULONG  DataItemId,
IN ULONG  Version,
IN ULONG  ValueBufferSize,
IN PVOID  ValueBuffer 
)

Definition at line 267 of file wmi.c.

273{
276}

◆ IoWMISuggestInstanceName()

NTSTATUS NTAPI IoWMISuggestInstanceName ( IN PDEVICE_OBJECT PhysicalDeviceObject  OPTIONAL,
IN PUNICODE_STRING SymbolicLinkName  OPTIONAL,
IN BOOLEAN  CombineNames,
OUT PUNICODE_STRING  SuggestedInstanceName 
)

Definition at line 95 of file wmi.c.

99{
102}

◆ IoWMIWriteEvent()

NTSTATUS NTAPI IoWMIWriteEvent ( _Inout_ PVOID  WnodeEventItem)

Definition at line 109 of file wmi.c.

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}
Definition: Header.h:9
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WNODE_FLAG_TRACED_GUID
Definition: wmistr.h:43

Referenced by _IRQL_requires_max_(), and FxWmiInstance::FireEvent().

◆ NtTraceEvent()

NTSTATUS NTAPI NtTraceEvent ( IN ULONG  TraceHandle,
IN ULONG  Flags,
IN ULONG  TraceHeaderLength,
IN struct _EVENT_TRACE_HEADER TraceHeader 
)

Definition at line 440 of file wmi.c.

444{
447}

◆ WmiFlushTrace()

NTSTATUS NTAPI WmiFlushTrace ( IN OUT PWMI_LOGGER_INFORMATION  LoggerInfo)

Definition at line 380 of file wmi.c.

381{
384}

◆ WmiGetClock()

LONG64 FASTCALL WmiGetClock ( IN WMI_CLOCK_TYPE  ClockType,
IN PVOID  Context 
)

Definition at line 388 of file wmi.c.

390{
393}

◆ WmiInitialize()

BOOLEAN NTAPI WmiInitialize ( VOID  )

Definition at line 38 of file wmi.c.

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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI WmipInitializeGuidObjectType(VOID)
Definition: guidobj.c:113
NTSTATUS NTAPI IoCreateDriver(_In_opt_ PUNICODE_STRING DriverName, _In_ PDRIVER_INITIALIZE InitializationFunction)
Definition: driver.c:1561
#define L(x)
Definition: ntvdm.h:50
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by IoInitSystem().

◆ WmiQueryTrace()

NTSTATUS NTAPI WmiQueryTrace ( IN OUT PWMI_LOGGER_INFORMATION  LoggerInfo)

Definition at line 397 of file wmi.c.

398{
401}

◆ WmiQueryTraceInformation()

NTSTATUS NTAPI WmiQueryTraceInformation ( IN TRACE_INFORMATION_CLASS  TraceInformationClass,
OUT PVOID  TraceInformation,
IN ULONG  TraceInformationLength,
OUT PULONG RequiredLength  OPTIONAL,
IN PVOID Buffer  OPTIONAL 
)

Definition at line 338 of file wmi.c.

343{
346}

◆ WmiStartTrace()

NTSTATUS NTAPI WmiStartTrace ( IN OUT PWMI_LOGGER_INFORMATION  LoggerInfo)

Definition at line 405 of file wmi.c.

406{
409}

◆ WmiStopTrace()

NTSTATUS NTAPI WmiStopTrace ( IN PWMI_LOGGER_INFORMATION  LoggerInfo)

Definition at line 413 of file wmi.c.

414{
417}

◆ WmiTraceFastEvent()

NTSTATUS FASTCALL WmiTraceFastEvent ( IN PWNODE_HEADER  Wnode)

Definition at line 421 of file wmi.c.

422{
425}

◆ WmiTraceMessage()

NTSTATUS __cdecl WmiTraceMessage ( IN TRACEHANDLE  LoggerHandle,
IN ULONG  MessageFlags,
IN LPGUID  MessageGuid,
IN USHORT  MessageNumber,
IN ...   
)

Definition at line 353 of file wmi.c.

358{
361}

◆ WmiTraceMessageVa()

NTSTATUS NTAPI WmiTraceMessageVa ( IN TRACEHANDLE  LoggerHandle,
IN ULONG  MessageFlags,
IN LPGUID  MessageGuid,
IN USHORT  MessageNumber,
IN va_list  MessageArgList 
)

Definition at line 368 of file wmi.c.

373{
376}

Referenced by FxWmiTraceMessage().

◆ WmiUpdateTrace()

NTSTATUS NTAPI WmiUpdateTrace ( IN OUT PWMI_LOGGER_INFORMATION  LoggerInfo)

Definition at line 429 of file wmi.c.

430{
433}