ReactOS  0.4.15-dev-3165-gdf6fff7
fxwmiinstance.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxWmiInstance.hpp
8 
9 Abstract:
10 
11  This module implements the WMI instance object
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Both kernel and user mode
20 
21 Revision History:
22 
23 
24 
25 --*/
26 
27 #ifndef _FXWMIINSTANCE_H_
28 #define _FXWMIINSTANCE_H_
29 
30 
32 
33  friend FxWmiProvider;
35 
36 public:
38  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
39  __in USHORT ObjectSize,
41  );
42 
44 
45  CfxDevice*
47  VOID
48  )
49  {
50  return m_Provider->GetDevice();
51  }
52 
55  VOID
56  )
57  {
58  return m_Provider;
59  }
60 
62  NTSTATUS
63  FireEvent(
64  __in_bcount_opt(EventBufferSize) PVOID EventBuffer,
65  __inout ULONG EventBufferSize
66  );
67 
68  BOOLEAN
71  )
72  {
73  return m_Provider->IsEnabled(Control);
74  }
75 
76  WDFWMIINSTANCE
78  VOID
79  )
80  {
81  return (WDFWMIINSTANCE) GetObjectHandle();
82  }
83 
84  virtual
85  BOOLEAN
87  VOID
88  ) =0;
89 
90  virtual
94  NTSTATUS
95  QueryInstance(
99  ) =0;
100 
101  virtual
102  BOOLEAN
104  VOID
105  ) =0;
106 
107  virtual
111  NTSTATUS
112  SetInstance(
114  __in_bcount(InBufferSize) PVOID InBuffer
115  ) =0;
116 
117  virtual
118  BOOLEAN
120  VOID
121  ) =0;
122 
123  virtual
127  NTSTATUS
128  SetItem(
131  __in_bcount(InBufferSize) PVOID InBuffer
132  ) =0;
133 
134  virtual
135  BOOLEAN
137  VOID
138  ) =0;
139 
140  virtual
144  NTSTATUS
145  ExecuteMethod(
151  PVOID Buffer,
153  ) =0;
154 
155  // begin FxObject overrides
156  virtual
157  BOOLEAN
158  Dispose(
159  VOID
160  );
161  // end FxObject overrides
162 
163 protected:
164  //
165  // List entry used by FxWmiProvider to hold the list of WMI instances
166  //
168 
169  //
170  // Pointer to the parent provider
171  //
173 };
174 
176 
178 
180  __in PFX_DRIVER_GLOBALS FxDriverGlobals
181  ) :
182  FxCallback(FxDriverGlobals),
183  m_Method(NULL)
184  {
185  }
186 
188  {
189  }
190 
194  NTSTATUS
195  Invoke(
196  __in WDFDEVICE Device,
197  __in WDFWMIINSTANCE WmiInstance,
201  )
202  {
204 
206 
207  if (m_Method != NULL) {
208  CallbackStart();
211  OutBuffer,
212  BufferUsed);
213  CallbackEnd();
214  }
215  else {
217  }
218 
219  return status;
220  }
221 };
222 
224 
226 
228  PFX_DRIVER_GLOBALS FxDriverGlobals
229  ) :
230  FxCallback(FxDriverGlobals),
231  m_Method(NULL)
232  {
233  }
234 
236  {
237  }
238 
242  NTSTATUS
243  Invoke(
244  __in WDFDEVICE Device,
245  __in WDFWMIINSTANCE WmiInstance,
248  )
249  {
251 
253 
254  if (m_Method != NULL) {
255  CallbackStart();
256  status = m_Method(WmiInstance, InBufferSize, InBuffer);
257  CallbackEnd();
258  }
259  else {
261  }
262 
263  return status;
264  }
265 };
266 
268 
270 
272  PFX_DRIVER_GLOBALS FxDriverGlobals
273  ) :
274  FxCallback(FxDriverGlobals),
275  m_Method(NULL)
276  {
277  }
278 
280  {
281  }
282 
286  NTSTATUS
287  Invoke(
288  __in WDFDEVICE Device,
289  __in WDFWMIINSTANCE WmiInstance,
293  )
294  {
296 
298 
299  if (m_Method != NULL) {
300  CallbackStart();
302  DataItemId,
303  InBufferSize,
304  InBuffer);
305  CallbackEnd();
306 
307  }
308  else {
310  }
311 
312  return status;
313  }
314 };
315 
317 
319 
321  PFX_DRIVER_GLOBALS FxDriverGlobals
322  ) :
323  FxCallback(FxDriverGlobals),
324  m_Method(NULL)
325  {
326  }
327 
329  {
330  }
331 
335  NTSTATUS
336  Invoke(
337  __in WDFDEVICE Device,
338  __in WDFWMIINSTANCE WmiInstance,
344  PVOID Buffer,
346  )
347  {
349 
351 
352  if (m_Method != NULL) {
353  CallbackStart();
355  MethodId,
356  InBufferSize,
358  Buffer,
359  BufferUsed);
360  CallbackEnd();
361  }
362  else {
364  }
365 
366  return status;
367  }
368 };
369 
371 public:
373  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
376  );
377 
378  VOID
381  )
382  {
384  }
385 
386  static
388  NTSTATUS
389  _Create(
390  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
392  __in PWDF_WMI_INSTANCE_CONFIG WmiInstanceConfig,
394  __out WDFWMIINSTANCE* WmiInstance,
396  );
397 
398 protected:
399  virtual
400  BOOLEAN
402  VOID
403  );
404 
405  virtual
409  NTSTATUS
410  QueryInstance(
414  );
415 
416  virtual
417  BOOLEAN
419  VOID
420  );
421 
422  virtual
426  NTSTATUS
427  SetInstance(
429  __in_bcount(InBufferSize) PVOID InBuffer
430  );
431 
432  virtual
433  BOOLEAN
435  VOID
436  );
437 
438  virtual
442  NTSTATUS
443  SetItem(
446  __in_bcount(InBufferSize) PVOID InBuffer
447  );
448 
449  virtual
450  BOOLEAN
452  VOID
453  );
454 
455  virtual
459  NTSTATUS
460  ExecuteMethod(
466  PVOID Buffer,
468  );
469 
470 protected:
471  //
472  // Attributes associated with this instance
473  //
475 
477 
479 
481 
483 
485 };
486 
487 typedef
491 NTSTATUS
492 (*PFN_FX_WMI_INSTANCE_QUERY_INSTANCE)(
498  );
499 
500 typedef
504 NTSTATUS
505 (*PFN_FX_WMI_INSTANCE_SET_INSTANCE)(
510  );
511 
512 typedef
516 NTSTATUS
517 (*PFN_FX_WMI_INSTANCE_SET_ITEM)(
522  __in_bcount(InBufferSize) PVOID InBuffer
523  );
524 
525 typedef
529 NTSTATUS
530 (*PFN_FX_WMI_INSTANCE_EXECUTE_METHOD)(
538  PVOID Buffer,
540  );
541 
544  VOID
545  )
546  {
547  RtlZeroMemory(this, sizeof(*this));
548  }
549 
550  //
551  // Callback when caller wants to query the entire data item's buffer.
552  //
553  PFN_FX_WMI_INSTANCE_QUERY_INSTANCE QueryInstance;
554 
555  //
556  // Callback when caller wants to set the entire data item's buffer.
557  //
558  PFN_FX_WMI_INSTANCE_SET_INSTANCE SetInstance;
559 
560  //
561  // Callback when caller wants to set a single field in the data item's buffer
562  //
563  PFN_FX_WMI_INSTANCE_SET_ITEM SetItem;
564 
565  //
566  // Callback when caller wants to execute a method on the data item.
567  //
568  PFN_FX_WMI_INSTANCE_EXECUTE_METHOD ExecuteMethod;
569 };
570 
572 
573 public:
575  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
578  );
579 
580 protected:
581  virtual
582  BOOLEAN
584  VOID
585  );
586 
587  virtual
591  NTSTATUS
592  QueryInstance(
596  );
597 
598  virtual
599  BOOLEAN
601  VOID
602  );
603 
604  virtual
608  NTSTATUS
609  SetInstance(
611  __in_bcount(InBufferSize) PVOID InBuffer
612  );
613 
614  virtual
615  BOOLEAN
617  VOID
618  );
619 
620  virtual
624  NTSTATUS
625  SetItem(
628  __in_bcount(InBufferSize) PVOID InBuffer
629  );
630 
631  virtual
632  BOOLEAN
634  VOID
635  );
636 
637  virtual
641  NTSTATUS
642  ExecuteMethod(
648  PVOID Buffer,
650  );
651 
652 protected:
653  PFN_FX_WMI_INSTANCE_QUERY_INSTANCE m_QueryInstance;
654  PFN_FX_WMI_INSTANCE_SET_INSTANCE m_SetInstance;
655  PFN_FX_WMI_INSTANCE_SET_ITEM m_SetItem;
656  PFN_FX_WMI_INSTANCE_EXECUTE_METHOD m_ExecuteMethod;
657 };
658 
659 #endif // _FXWMIINSTANCE_H_
_In_ ULONG _Out_ PULONG BufferUsed
Definition: wdfwmi.h:92
FxWmiInstanceInternal(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxWmiInstanceInternalCallbacks *Callbacks, __in FxWmiProvider *m_Provider)
virtual _Must_inspect_result_ __drv_sameIRQL __in ULONG __inout ULONG __drv_when(InBufferSize >=OutBufferSize, __inout_bcount(InBufferSize)) __drv_when(InBufferSize< OutBufferSize
PFN_FX_WMI_INSTANCE_SET_ITEM SetItem
FxWmiInstanceExternal(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_WMI_INSTANCE_CONFIG Config, __in FxWmiProvider *Provider)
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
_Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS(*PFN_FX_WMI_INSTANCE_QUERY_INSTANCE)(__in CfxDevice *Device
virtual _Must_inspect_result_ __drv_sameIRQL __out_bcount_part(OutBufferSize, *BufferUsed) PVOID OutBuffer
PFN_FX_WMI_INSTANCE_EXECUTE_METHOD m_ExecuteMethod
PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD m_Method
#define __in_opt
Definition: dbghelp.h:38
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
WDF_EXTERN_C_START enum _WDF_WMI_PROVIDER_CONTROL WDF_WMI_PROVIDER_CONTROL
virtual _Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS QueryInstance(__in ULONG OutBufferSize
virtual _Must_inspect_result_ __drv_sameIRQL __in ULONG __inout ULONG __inout_bcount(OutBufferSize)) PVOID Buffer
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __in ULONG __in ULONG __inout ULONG __drv_when(InBufferSize >=OutBufferSize, __inout_bcount(InBufferSize)) __drv_when(InBufferSize< OutBufferSize
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES InstanceAttributes
Definition: wdfwmi.h:474
virtual _Must_inspect_result_ __drv_sameIRQL __in_bcount(InBufferSize) PVOID InBuffer)=0
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal * Instance
virtual _Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS QueryInstance(__inout ULONG OutBufferSize
virtual BOOLEAN IsSetItemSupported(VOID)
EVT_WDF_WMI_INSTANCE_SET_INSTANCE * PFN_WDF_WMI_INSTANCE_SET_INSTANCE
Definition: wdfwmi.h:111
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T ContextSize
Definition: fltkernel.h:1443
#define STATUS_WMI_READ_ONLY
Definition: ntstatus.h:818
virtual BOOLEAN Dispose(VOID)
FxWmiInstanceSetInstanceCallback m_SetInstanceCallback
friend FxWmiIrpHandler
friend FxWmiProvider
_Must_inspect_result_ _In_ WDFWMIINSTANCE WmiInstance
Definition: wdfwmi.h:514
_Must_inspect_result_ __drv_sameIRQL __in WDFWMIINSTANCE __in ULONG __in_bcount(InBufferSize) PVOID InBuffer)
_Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS Invoke(__in WDFDEVICE Device
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __in ULONG __in ULONG __inout ULONG __inout_bcount(OutBufferSize)) PVOID Buffer
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __in ULONG __in_bcount(InBufferSize) PVOID InBuffer)
PFN_FX_WMI_INSTANCE_EXECUTE_METHOD ExecuteMethod
virtual BOOLEAN IsExecuteMethodSupported(VOID)
PFN_FX_WMI_INSTANCE_SET_INSTANCE m_SetInstance
_Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS Invoke(__in WDFDEVICE Device
virtual _Must_inspect_result_ __drv_sameIRQL __in ULONG __inout ULONG __inout_bcount(OutBufferSize)) PVOID Buffer
virtual _Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS QueryInstance(__inout ULONG OutBufferSize
CfxDevice * GetDevice(VOID)
PFN_WDF_WMI_INSTANCE_SET_INSTANCE m_Method
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
#define __out
Definition: dbghelp.h:62
unsigned char BOOLEAN
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166
_Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS Invoke(__in WDFDEVICE Device
_Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS Invoke(__in WDFDEVICE Device
_Must_inspect_result_ __drv_sameIRQL __in WDFWMIINSTANCE __inout ULONG __out_bcount(OutBufferSize) PVOID OutBuffer
Definition: bufpool.h:45
PFN_WDF_WMI_INSTANCE_SET_ITEM m_Method
virtual _Must_inspect_result_ __drv_sameIRQL __in ULONG __inout ULONG __drv_when(InBufferSize >=OutBufferSize, __inout_bcount(InBufferSize)) __drv_when(InBufferSize< OutBufferSize
virtual BOOLEAN IsSetInstanceSupported(VOID)=0
PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE m_Method
_In_ ULONG DataItemId
Definition: wdfwmi.h:123
LIST_ENTRY m_ListEntry
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
#define __drv_sameIRQL
Definition: driverspecs.h:324
FxWmiInstanceSetItemCallback(PFX_DRIVER_GLOBALS FxDriverGlobals)
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
FxWmiProvider * m_Provider
_Must_inspect_result_ __drv_sameIRQL __in WDFWMIINSTANCE __in ULONG __in ULONG __inout ULONG __inout_bcount(OutBufferSize)) PVOID Buffer
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
EVT_WDF_WMI_INSTANCE_EXECUTE_METHOD * PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD
Definition: wdfwmi.h:154
FxWmiInstanceQueryInstanceCallback m_QueryInstanceCallback
virtual BOOLEAN IsQueryInstanceSupported(VOID)
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __inout ULONG __out_bcount(OutBufferSize) PVOID OutBuffer
virtual _Must_inspect_result_ __drv_sameIRQL __in ULONG __inout ULONG __inout_bcount(OutBufferSize)) PVOID Buffer
PFN_FX_WMI_INSTANCE_QUERY_INSTANCE QueryInstance
_In_ ULONG MethodId
Definition: wdfwmi.h:142
virtual BOOLEAN IsQueryInstanceSupported(VOID)
virtual BOOLEAN IsSetItemSupported(VOID)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
FxWmiInstanceSetInstanceCallback(PFX_DRIVER_GLOBALS FxDriverGlobals)
virtual BOOLEAN IsExecuteMethodSupported(VOID)=0
#define NTSTATUS
Definition: precomp.h:20
BOOLEAN IsEnabled(__in WDF_WMI_PROVIDER_CONTROL Control)
virtual _Must_inspect_result_ __drv_sameIRQL __in_bcount(InBufferSize) PVOID InBuffer)
#define __inout
Definition: dbghelp.h:50
Definition: typedefs.h:119
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
FxWmiProvider * GetProvider(VOID)
virtual BOOLEAN IsSetInstanceSupported(VOID)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:474
virtual BOOLEAN IsSetInstanceSupported(VOID)
FxWmiInstance(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize, __in FxWmiProvider *Provider)
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __inout ULONG __out PULONG BufferUsed
BOOLEAN IsEnabled(__in WDF_WMI_PROVIDER_CONTROL Control)
unsigned short USHORT
Definition: pedump.c:61
FxWmiInstanceExecuteMethodCallback m_ExecuteMethodCallback
unsigned int * PULONG
Definition: retypes.h:1
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __in ULONG InBufferSize
#define NULL
Definition: types.h:112
virtual _Must_inspect_result_ __drv_sameIRQL __out_xcount(OutBuffer->size) PVOID OutBuffer
VOID SetContextForQueryLength(__in ULONG ContextSize)
PFN_FX_WMI_INSTANCE_QUERY_INSTANCE m_QueryInstance
WDFWMIINSTANCE GetHandle(VOID)
PFN_FX_WMI_INSTANCE_SET_ITEM m_SetItem
PFN_FX_WMI_INSTANCE_SET_INSTANCE SetInstance
virtual _Must_inspect_result_ __drv_sameIRQL __in ULONG __inout ULONG __drv_when(InBufferSize >=OutBufferSize, __inout_bcount(InBufferSize)) __drv_when(InBufferSize< OutBufferSize
unsigned int ULONG
Definition: retypes.h:1
FxWmiInstanceExecuteMethodCallback(PFX_DRIVER_GLOBALS FxDriverGlobals)
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __in ULONG DataItemId
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __in ULONG MethodId
_Must_inspect_result_ __in WDFWMIINSTANCE __in_opt ULONG __in_bcount_opt(EventDataSize) PVOID EventData)
Definition: fxwmiapi.cpp:405
FxWmiInstanceSetItemCallback m_SetItemCallback
_Must_inspect_result_ __drv_sameIRQL __in WDFWMIINSTANCE __in ULONG __in ULONG __inout ULONG __drv_when(InBufferSize >=OutBufferSize, __inout_bcount(InBufferSize)) __drv_when(InBufferSize< OutBufferSize
CfxDevice * GetDevice(VOID)
void __inline CallbackStart(VOID)
Definition: fxcallback.hpp:64
_Must_inspect_result_ __drv_sameIRQL __in FxWmiInstanceInternal __inout ULONG OutBufferSize
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxWmiProvider *Provider, __in PWDF_WMI_INSTANCE_CONFIG WmiInstanceConfig, __in_opt PWDF_OBJECT_ATTRIBUTES InstanceAttributes, __out WDFWMIINSTANCE *WmiInstance, __out FxWmiInstanceExternal **Instance)
_Must_inspect_result_ __drv_sameIRQL __in WDFWMIINSTANCE __in ULONG __in ULONG __in_bcount(InBufferSize) PVOID InBuffer)
virtual BOOLEAN IsQueryInstanceSupported(VOID)=0
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
FxWmiInstanceQueryInstanceCallback(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
void __inline CallbackEnd(VOID)
Definition: fxcallback.hpp:74
IN PVOID Instance
Definition: pci.h:361
EVT_WDF_WMI_INSTANCE_SET_ITEM * PFN_WDF_WMI_INSTANCE_SET_ITEM
Definition: wdfwmi.h:130
virtual _Must_inspect_result_ __drv_sameIRQL __in_bcount(InBufferSize) PVOID InBuffer)
virtual BOOLEAN IsExecuteMethodSupported(VOID)
virtual BOOLEAN IsSetItemSupported(VOID)=0
_Must_inspect_result_ NTSTATUS FireEvent(__in_bcount_opt(EventBufferSize) PVOID EventBuffer, __inout ULONG EventBufferSize)
EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE * PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE
Definition: wdfwmi.h:94
virtual _Must_inspect_result_ __drv_sameIRQL __out_bcount(OutBufferSize) PVOID OutBuffer
Definition: ps.c:97