ReactOS  0.4.14-dev-376-gaedba84
classwmi.c File Reference
#include "classp.h"
#include <wmistr.h>
Include dependency graph for classwmi.c:

Go to the source code of this file.

Macros

#define MOFRESOURCENAME   L"MofResourceName"
 

Functions

NTSTATUS NTAPI ClassSystemControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
BOOLEAN ClassFindGuid (PGUIDREGINFO GuidList, ULONG GuidCount, LPGUID Guid, PULONG GuidIndex)
 
SCSIPORTAPI NTSTATUS NTAPI ClassWmiCompleteRequest (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN NTSTATUS Status, IN ULONG BufferUsed, IN CCHAR PriorityBoost)
 
NTSTATUS NTAPI ClassWmiFireEvent (IN PDEVICE_OBJECT DeviceObject, IN LPGUID Guid, IN ULONG InstanceIndex, IN ULONG EventDataSize, IN PVOID EventData)
 

Macro Definition Documentation

◆ MOFRESOURCENAME

#define MOFRESOURCENAME   L"MofResourceName"

Definition at line 46 of file classwmi.c.

Function Documentation

◆ ClassFindGuid()

BOOLEAN ClassFindGuid ( PGUIDREGINFO  GuidList,
ULONG  GuidCount,
LPGUID  Guid,
PULONG  GuidIndex 
)

Definition at line 81 of file classwmi.c.

87 {
88  ULONG i;
89 
90  PAGED_CODE();
91 
92  for (i = 0; i < GuidCount; i++)
93  {
94  if (IsEqualGUID(Guid, &GuidList[i].Guid))
95  {
96  *GuidIndex = i;
97  return(TRUE);
98  }
99  }
100 
101  return(FALSE);
102 } // end ClassFindGuid()
#define TRUE
Definition: types.h:120
#define PAGED_CODE()
Definition: video.h:57
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static GUID * Guid
Definition: apphelp.c:93
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:401
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
unsigned int ULONG
Definition: retypes.h:1

Referenced by ClassSystemControl().

◆ ClassSystemControl()

NTSTATUS NTAPI ClassSystemControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 128 of file classwmi.c.

132 {
134  PCLASS_DRIVER_EXTENSION driverExtension;
136  ULONG isRemoved;
137  ULONG bufferSize;
138  PUCHAR buffer;
140  UCHAR minorFunction;
141  ULONG guidIndex;
142  PCLASS_WMI_INFO classWmiInfo;
143 
144  PAGED_CODE();
145 
146  //
147  // Make sure device has not been removed
149  if(isRemoved)
150  {
151  Irp->IoStatus.Status = STATUS_DEVICE_DOES_NOT_EXIST;
155  }
156 
157  //
158  // If the irp is not a WMI irp or it is not targeted at this device
159  // or this device has not registered with WMI then just forward it on.
160  minorFunction = irpStack->MinorFunction;
161  if ((minorFunction > IRP_MN_EXECUTE_METHOD) ||
162  (irpStack->Parameters.WMI.ProviderId != (ULONG_PTR)DeviceObject) ||
163  ((minorFunction != IRP_MN_REGINFO) &&
164  (commonExtension->GuidRegInfo == NULL)))
165  {
166  //
167  // CONSIDER: Do I need to hang onto lock until IoCallDriver returns ?
170  return(IoCallDriver(commonExtension->LowerDeviceObject, Irp));
171  }
172 
173  buffer = (PUCHAR)irpStack->Parameters.WMI.Buffer;
174  bufferSize = irpStack->Parameters.WMI.BufferSize;
175 
176  if (minorFunction != IRP_MN_REGINFO)
177  {
178  //
179  // For all requests other than query registration info we are passed
180  // a guid. Determine if the guid is one that is supported by the
181  // device.
182  if (ClassFindGuid(commonExtension->GuidRegInfo,
183  commonExtension->GuidCount,
184  (LPGUID)irpStack->Parameters.WMI.DataPath,
185  &guidIndex))
186  {
188  } else {
190  }
191 
192  if (NT_SUCCESS(status) &&
193  ((minorFunction == IRP_MN_QUERY_SINGLE_INSTANCE) ||
194  (minorFunction == IRP_MN_CHANGE_SINGLE_INSTANCE) ||
195  (minorFunction == IRP_MN_CHANGE_SINGLE_ITEM) ||
196  (minorFunction == IRP_MN_EXECUTE_METHOD)))
197  {
198  if ( (((PWNODE_HEADER)buffer)->Flags) &
200  {
202  {
204  }
205  } else {
207  }
208  }
209 
210  if (! NT_SUCCESS(status))
211  {
212  Irp->IoStatus.Status = status;
215  return(status);
216  }
217  }
218 
219  driverExtension = commonExtension->DriverExtension;
220 
221  classWmiInfo = commonExtension->IsFdo ?
222  &driverExtension->InitData.FdoData.ClassWmiInfo :
223  &driverExtension->InitData.PdoData.ClassWmiInfo;
224  switch(minorFunction)
225  {
226  case IRP_MN_REGINFO:
227  {
228  ULONG guidCount;
229  PGUIDREGINFO guidList;
230  PWMIREGINFOW wmiRegInfo;
231  PWMIREGGUIDW wmiRegGuid;
232  //PDEVICE_OBJECT pdo;
233  PUNICODE_STRING regPath;
234  PWCHAR stringPtr;
235  ULONG retSize;
236  ULONG registryPathOffset;
237  ULONG mofResourceOffset;
238  ULONG bufferNeeded;
239  ULONG i;
240  ULONG_PTR nameInfo;
241  ULONG nameSize, nameOffset, nameFlags;
242  UNICODE_STRING name, mofName;
243  PCLASS_QUERY_WMI_REGINFO_EX ClassQueryWmiRegInfoEx;
244 
245  name.Buffer = NULL;
246  name.Length = 0;
247  name.MaximumLength = 0;
248  nameFlags = 0;
249 
250  ClassQueryWmiRegInfoEx = commonExtension->IsFdo ?
251  driverExtension->ClassFdoQueryWmiRegInfoEx :
252  driverExtension->ClassPdoQueryWmiRegInfoEx;
253 
254  if (ClassQueryWmiRegInfoEx == NULL)
255  {
256  status = classWmiInfo->ClassQueryWmiRegInfo(
257  DeviceObject,
258  &nameFlags,
259  &name);
260 
262  } else {
263  RtlInitUnicodeString(&mofName, L"");
264  status = (*ClassQueryWmiRegInfoEx)(
265  DeviceObject,
266  &nameFlags,
267  &name,
268  &mofName);
269  }
270 
271  if (NT_SUCCESS(status) &&
272  (! (nameFlags & WMIREG_FLAG_INSTANCE_PDO) &&
273  (name.Buffer == NULL)))
274  {
275  //
276  // if PDO flag not specified then an instance name must be
278  }
279 
280  if (NT_SUCCESS(status))
281  {
282  guidList = classWmiInfo->GuidRegInfo;
283  guidCount = classWmiInfo->GuidCount;
284 
285  nameOffset = sizeof(WMIREGINFO) +
286  guidCount * sizeof(WMIREGGUIDW);
287 
288  if (nameFlags & WMIREG_FLAG_INSTANCE_PDO)
289  {
290  nameSize = 0;
291  nameInfo = commonExtension->IsFdo ?
292  (ULONG_PTR)((PFUNCTIONAL_DEVICE_EXTENSION)commonExtension)->LowerPdo :
294  } else {
295  nameFlags |= WMIREG_FLAG_INSTANCE_LIST;
296  nameSize = name.Length + sizeof(USHORT);
297  nameInfo = nameOffset;
298  }
299 
300  mofResourceOffset = nameOffset + nameSize;
301 
302  registryPathOffset = mofResourceOffset +
303  mofName.Length + sizeof(USHORT);
304 
305  regPath = &driverExtension->RegistryPath;
306  bufferNeeded = registryPathOffset +
307  regPath->Length + sizeof(USHORT);
308 
309  if (bufferNeeded <= bufferSize)
310  {
311  retSize = bufferNeeded;
312 
313  commonExtension->GuidCount = guidCount;
314  commonExtension->GuidRegInfo = guidList;
315 
316  wmiRegInfo = (PWMIREGINFO)buffer;
317  wmiRegInfo->BufferSize = bufferNeeded;
318  wmiRegInfo->NextWmiRegInfo = 0;
319  wmiRegInfo->MofResourceName = mofResourceOffset;
320  wmiRegInfo->RegistryPath = registryPathOffset;
321  wmiRegInfo->GuidCount = guidCount;
322 
323  for (i = 0; i < guidCount; i++)
324  {
325  wmiRegGuid = &wmiRegInfo->WmiRegGuid[i];
326  wmiRegGuid->Guid = guidList[i].Guid;
327  wmiRegGuid->Flags = guidList[i].Flags | nameFlags;
328  wmiRegGuid->InstanceInfo = nameInfo;
329  wmiRegGuid->InstanceCount = 1;
330  }
331 
332  if ( nameFlags & WMIREG_FLAG_INSTANCE_LIST)
333  {
334  stringPtr = (PWCHAR)((PUCHAR)buffer + nameOffset);
335  *stringPtr++ = name.Length;
336  RtlCopyMemory(stringPtr,
337  name.Buffer,
338  name.Length);
339  }
340 
341  stringPtr = (PWCHAR)((PUCHAR)buffer + mofResourceOffset);
342  *stringPtr++ = mofName.Length;
343  RtlCopyMemory(stringPtr,
344  mofName.Buffer,
345  mofName.Length);
346 
347  stringPtr = (PWCHAR)((PUCHAR)buffer + registryPathOffset);
348  *stringPtr++ = regPath->Length;
349  RtlCopyMemory(stringPtr,
350  regPath->Buffer,
351  regPath->Length);
352  } else {
353  *((PULONG)buffer) = bufferNeeded;
354  retSize = sizeof(ULONG);
355  }
356  } else {
357  retSize = 0;
358  }
359 
360  if (name.Buffer != NULL)
361  {
362  ExFreePool(name.Buffer);
363  }
364 
365  Irp->IoStatus.Status = status;
366  Irp->IoStatus.Information = retSize;
369  return(status);
370  }
371 
373  {
374  PWNODE_ALL_DATA wnode;
375  ULONG bufferAvail;
376 
377  wnode = (PWNODE_ALL_DATA)buffer;
378 
379  if (bufferSize < sizeof(WNODE_ALL_DATA))
380  {
381  bufferAvail = 0;
382  } else {
383  bufferAvail = bufferSize - sizeof(WNODE_ALL_DATA);
384  }
385 
386  wnode->DataBlockOffset = sizeof(WNODE_ALL_DATA);
387 
388  status = classWmiInfo->ClassQueryWmiDataBlock(
389  DeviceObject,
390  Irp,
391  guidIndex,
392  bufferAvail,
393  buffer + sizeof(WNODE_ALL_DATA));
394 
395  break;
396  }
397 
399  {
401  ULONG dataBlockOffset;
402 
404 
405  dataBlockOffset = wnode->DataBlockOffset;
406 
407  status = classWmiInfo->ClassQueryWmiDataBlock(
408  DeviceObject,
409  Irp,
410  guidIndex,
411  bufferSize - dataBlockOffset,
412  (PUCHAR)wnode + dataBlockOffset);
413 
414  break;
415  }
416 
418  {
420 
422 
423  status = classWmiInfo->ClassSetWmiDataBlock(
424  DeviceObject,
425  Irp,
426  guidIndex,
427  wnode->SizeDataBlock,
428  (PUCHAR)wnode + wnode->DataBlockOffset);
429 
430  break;
431  }
432 
434  {
435  PWNODE_SINGLE_ITEM wnode;
436 
437  wnode = (PWNODE_SINGLE_ITEM)buffer;
438 
439  status = classWmiInfo->ClassSetWmiDataItem(
440  DeviceObject,
441  Irp,
442  guidIndex,
443  wnode->ItemId,
444  wnode->SizeDataItem,
445  (PUCHAR)wnode + wnode->DataBlockOffset);
446 
447  break;
448  }
449 
451  {
452  PWNODE_METHOD_ITEM wnode;
453 
454  wnode = (PWNODE_METHOD_ITEM)buffer;
455 
456  status = classWmiInfo->ClassExecuteWmiMethod(
457  DeviceObject,
458  Irp,
459  guidIndex,
460  wnode->MethodId,
461  wnode->SizeDataBlock,
462  bufferSize - wnode->DataBlockOffset,
463  buffer + wnode->DataBlockOffset);
464 
465 
466  break;
467  }
468 
470  {
471  status = classWmiInfo->ClassWmiFunctionControl(
472  DeviceObject,
473  Irp,
474  guidIndex,
476  TRUE);
477  break;
478  }
479 
481  {
482  status = classWmiInfo->ClassWmiFunctionControl(
483  DeviceObject,
484  Irp,
485  guidIndex,
487  FALSE);
488  break;
489  }
490 
492  {
493  status = classWmiInfo->ClassWmiFunctionControl(
494  DeviceObject,
495  Irp,
496  guidIndex,
498  TRUE);
499  break;
500  }
501 
503  {
504  status = classWmiInfo->ClassWmiFunctionControl(
505  DeviceObject,
506  Irp,
507  guidIndex,
509  FALSE);
510  break;
511  }
512 
513  default:
514  {
516  break;
517  }
518 
519  }
520 
521  return(status);
522 } // end ClassSystemControl()
ULONG DataBlockOffset
Definition: wmistr.h:129
struct tagWNODE_SINGLE_ITEM * PWNODE_SINGLE_ITEM
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:414
ULONG RegistryPath
Definition: wmistr.h:95
PGUIDREGINFO GuidRegInfo
Definition: classpnp.h:491
#define IRP_MN_REGINFO
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
GUID Guid
Definition: classpnp.h:484
#define ClassAcquireRemoveLock(devobj, tag)
Definition: classpnp.h:97
struct tagWNODE_ALL_DATA * PWNODE_ALL_DATA
struct tagWNODE_SINGLE_INSTANCE * PWNODE_SINGLE_INSTANCE
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:762
GUID Guid
Definition: wmistr.h:79
BOOLEAN ClassFindGuid(PGUIDREGINFO GuidList, ULONG GuidCount, LPGUID Guid, PULONG GuidIndex)
Definition: classwmi.c:81
CLASS_DEV_INFO FdoData
Definition: classpnp.h:521
_In_ PIRP Irp
Definition: csq.h:116
ULONG DataBlockOffset
Definition: wmistr.h:140
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG Flags
Definition: wmistr.h:80
LONG NTSTATUS
Definition: precomp.h:26
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1057
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
GLuint buffer
Definition: glext.h:5915
uint16_t * PWCHAR
Definition: typedefs.h:54
#define IRP_MN_QUERY_SINGLE_INSTANCE
UNICODE_STRING RegistryPath
Definition: kbdclass.h:25
struct tagWNODE_METHOD_ITEM * PWNODE_METHOD_ITEM
ULONG MofResourceName
Definition: wmistr.h:96
#define PAGED_CODE()
Definition: video.h:57
PCLASS_QUERY_WMI_DATABLOCK ClassQueryWmiDataBlock
Definition: classpnp.h:493
#define IRP_MN_ENABLE_COLLECTION
#define STATUS_WMI_INSTANCE_NOT_FOUND
Definition: ntstatus.h:763
#define MOFRESOURCENAME
Definition: classwmi.c:46
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct tagWNODE_ALL_DATA WNODE_ALL_DATA
ULONG GuidCount
Definition: wmistr.h:97
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
WMIREGGUIDW WmiRegGuid[]
Definition: wmistr.h:98
#define IRP_MN_CHANGE_SINGLE_ITEM
#define IRP_MN_DISABLE_COLLECTION
PCLASS_SET_WMI_DATABLOCK ClassSetWmiDataBlock
Definition: classpnp.h:494
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define WMIREG_FLAG_INSTANCE_PDO
Definition: wmistr.h:69
WMIREGINFOW WMIREGINFO
Definition: wmistr.h:101
PCLASS_QUERY_WMI_REGINFO_EX ClassFdoQueryWmiRegInfoEx
Definition: classpnp.h:559
#define WNODE_FLAG_STATIC_INSTANCE_NAMES
Definition: wmistr.h:35
ULONG DataBlockOffset
Definition: wmistr.h:113
ULONG Flags
Definition: classpnp.h:486
#define IRP_MN_ENABLE_EVENTS
if(!(yy_init))
Definition: macro.lex.yy.c:714
CLASS_WMI_INFO ClassWmiInfo
Definition: classpnp.h:516
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG NextWmiRegInfo
Definition: wmistr.h:94
PCLASS_QUERY_WMI_REGINFO_EX ClassPdoQueryWmiRegInfoEx
Definition: classpnp.h:560
ULONG_PTR InstanceInfo
Definition: wmistr.h:87
PWMIREGINFOW PWMIREGINFO
Definition: wmistr.h:102
unsigned char UCHAR
Definition: xmlstorage.h:181
#define IRP_MN_DISABLE_EVENTS
static const WCHAR L[]
Definition: oid.c:1250
PCLASS_DRIVER_EXTENSION DriverExtension
Definition: classpnp.h:576
#define IRP_MN_EXECUTE_METHOD
#define WMIREG_FLAG_INSTANCE_LIST
Definition: wmistr.h:67
#define IRP_MN_CHANGE_SINGLE_INSTANCE
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PCLASS_SET_WMI_DATAITEM ClassSetWmiDataItem
Definition: classpnp.h:495
VOID NTAPI ClassCompleteRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN CCHAR PriorityBoost)
Definition: lock.c:376
ULONG BufferSize
Definition: wmistr.h:93
PGUIDREGINFO GuidRegInfo
Definition: classpnp.h:606
unsigned short USHORT
Definition: pedump.c:61
ULONG GuidCount
Definition: classpnp.h:490
#define IRP_MN_QUERY_ALL_DATA
unsigned int * PULONG
Definition: retypes.h:1
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:574
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
CLASS_DEV_INFO PdoData
Definition: classpnp.h:522
ULONG InstanceCount
Definition: wmistr.h:81
Definition: name.c:36
CLASS_INIT_DATA InitData
Definition: classpnp.h:556
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ULONG_PTR
Definition: config.h:101
PCLASS_EXECUTE_WMI_METHOD ClassExecuteWmiMethod
Definition: classpnp.h:496
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
PCLASS_WMI_FUNCTION_CONTROL ClassWmiFunctionControl
Definition: classpnp.h:497
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PCLASS_QUERY_WMI_REGINFO ClassQueryWmiRegInfo
Definition: classpnp.h:492
VOID NTAPI ClassReleaseRemoveLock(IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PIRP Tag)
Definition: lock.c:212
Definition: ps.c:97
GLuint const GLchar * name
Definition: glext.h:6031

◆ ClassWmiCompleteRequest()

SCSIPORTAPI NTSTATUS NTAPI ClassWmiCompleteRequest ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN NTSTATUS  Status,
IN ULONG  BufferUsed,
IN CCHAR  PriorityBoost 
)

Definition at line 559 of file classwmi.c.

566 {
568  //UCHAR MinorFunction;
569  PUCHAR buffer;
570  ULONG retSize;
571  UCHAR minorFunction;
572 
573  minorFunction = irpStack->MinorFunction;
574  buffer = (PUCHAR)irpStack->Parameters.WMI.Buffer;
575 
576  switch(minorFunction)
577  {
579  {
580  PWNODE_ALL_DATA wnode;
581  PWNODE_TOO_SMALL wnodeTooSmall;
582  ULONG bufferNeeded;
583 
584  wnode = (PWNODE_ALL_DATA)buffer;
585 
586  bufferNeeded = sizeof(WNODE_ALL_DATA) + BufferUsed;
587 
588  if (NT_SUCCESS(Status))
589  {
590  retSize = bufferNeeded;
591  wnode->WnodeHeader.BufferSize = bufferNeeded;
592  KeQuerySystemTime(&wnode->WnodeHeader.TimeStamp);
594  wnode->FixedInstanceSize = BufferUsed;
595  wnode->InstanceCount = 1;
596 
597  } else if (Status == STATUS_BUFFER_TOO_SMALL) {
598  wnodeTooSmall = (PWNODE_TOO_SMALL)wnode;
599 
600  wnodeTooSmall->WnodeHeader.BufferSize = sizeof(WNODE_TOO_SMALL);
601  wnodeTooSmall->WnodeHeader.Flags = WNODE_FLAG_TOO_SMALL;
602  wnodeTooSmall->SizeNeeded = sizeof(WNODE_ALL_DATA) + BufferUsed;
603  retSize = sizeof(WNODE_TOO_SMALL);
605  } else {
606  retSize = 0;
607  }
608  break;
609  }
610 
612  {
614  PWNODE_TOO_SMALL wnodeTooSmall;
615  ULONG bufferNeeded;
616 
618 
619  bufferNeeded = wnode->DataBlockOffset + BufferUsed;
620 
621  if (NT_SUCCESS(Status))
622  {
623  retSize = bufferNeeded;
624  wnode->WnodeHeader.BufferSize = bufferNeeded;
625  KeQuerySystemTime(&wnode->WnodeHeader.TimeStamp);
626  wnode->SizeDataBlock = BufferUsed;
627 
628  } else if (Status == STATUS_BUFFER_TOO_SMALL) {
629  wnodeTooSmall = (PWNODE_TOO_SMALL)wnode;
630 
631  wnodeTooSmall->WnodeHeader.BufferSize = sizeof(WNODE_TOO_SMALL);
632  wnodeTooSmall->WnodeHeader.Flags = WNODE_FLAG_TOO_SMALL;
633  wnodeTooSmall->SizeNeeded = bufferNeeded;
634  retSize = sizeof(WNODE_TOO_SMALL);
636  } else {
637  retSize = 0;
638  }
639  break;
640  }
641 
643  {
644  PWNODE_METHOD_ITEM wnode;
645  PWNODE_TOO_SMALL wnodeTooSmall;
646  ULONG bufferNeeded;
647 
648  wnode = (PWNODE_METHOD_ITEM)buffer;
649 
650  bufferNeeded = wnode->DataBlockOffset + BufferUsed;
651 
652  if (NT_SUCCESS(Status))
653  {
654  retSize = bufferNeeded;
655  wnode->WnodeHeader.BufferSize = bufferNeeded;
656  KeQuerySystemTime(&wnode->WnodeHeader.TimeStamp);
657  wnode->SizeDataBlock = BufferUsed;
658 
659  } else if (Status == STATUS_BUFFER_TOO_SMALL) {
660  wnodeTooSmall = (PWNODE_TOO_SMALL)wnode;
661 
662  wnodeTooSmall->WnodeHeader.BufferSize = sizeof(WNODE_TOO_SMALL);
663  wnodeTooSmall->WnodeHeader.Flags = WNODE_FLAG_TOO_SMALL;
664  wnodeTooSmall->SizeNeeded = bufferNeeded;
665  retSize = sizeof(WNODE_TOO_SMALL);
667  } else {
668  retSize = 0;
669  }
670  break;
671  }
672 
673  default:
674  {
675  //
676  // All other requests don't return any data
677  retSize = 0;
678  break;
679  }
680 
681  }
682 
683  Irp->IoStatus.Status = Status;
684  Irp->IoStatus.Information = retSize;
687  return(Status);
688 } // end ClassWmiCompleteRequest()
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct _WNODE_HEADER WnodeHeader
Definition: wmistr.h:52
struct tagWNODE_ALL_DATA * PWNODE_ALL_DATA
struct tagWNODE_SINGLE_INSTANCE * PWNODE_SINGLE_INSTANCE
struct tagWNODE_TOO_SMALL * PWNODE_TOO_SMALL
_In_ PIRP Irp
Definition: csq.h:116
ULONG DataBlockOffset
Definition: wmistr.h:140
unsigned char * PUCHAR
Definition: retypes.h:3
GLuint buffer
Definition: glext.h:5915
#define IRP_MN_QUERY_SINGLE_INSTANCE
struct tagWNODE_METHOD_ITEM * PWNODE_METHOD_ITEM
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct tagWNODE_ALL_DATA WNODE_ALL_DATA
struct tagWNODE_TOO_SMALL WNODE_TOO_SMALL
_In_ CCHAR PriorityBoost
Definition: iofuncs.h:763
#define WNODE_FLAG_FIXED_INSTANCE_SIZE
Definition: wmistr.h:32
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned char UCHAR
Definition: xmlstorage.h:181
#define IRP_MN_EXECUTE_METHOD
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI ClassCompleteRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN CCHAR PriorityBoost)
Definition: lock.c:376
ULONG FixedInstanceSize
Definition: wmistr.h:118
struct _WNODE_HEADER WnodeHeader
Definition: wmistr.h:136
#define IRP_MN_QUERY_ALL_DATA
ULONG SizeNeeded
Definition: wmistr.h:53
unsigned int ULONG
Definition: retypes.h:1
struct _WNODE_HEADER WnodeHeader
Definition: wmistr.h:112
struct _WNODE_HEADER WnodeHeader
Definition: wmistr.h:58
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
ULONG InstanceCount
Definition: wmistr.h:114
#define WNODE_FLAG_TOO_SMALL
Definition: wmistr.h:33
VOID NTAPI ClassReleaseRemoveLock(IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PIRP Tag)
Definition: lock.c:212

Referenced by DiskFdoExecuteWmiMethod(), DiskFdoQueryWmiDataBlock(), DiskFdoSetWmiDataBlock(), DiskFdoSetWmiDataItem(), and DiskWmiFunctionControl().

◆ ClassWmiFireEvent()

NTSTATUS NTAPI ClassWmiFireEvent ( IN PDEVICE_OBJECT  DeviceObject,
IN LPGUID  Guid,
IN ULONG  InstanceIndex,
IN ULONG  EventDataSize,
IN PVOID  EventData 
)

Definition at line 721 of file classwmi.c.

728 {
729 
730  ULONG sizeNeeded;
733 
734  if (EventData == NULL)
735  {
736  EventDataSize = 0;
737  }
738 
739  sizeNeeded = sizeof(WNODE_SINGLE_INSTANCE) + EventDataSize;
740 
741  event = ExAllocatePoolWithTag(NonPagedPool, sizeNeeded, CLASS_TAG_WMI);
742  if (event != NULL)
743  {
744  event->WnodeHeader.Guid = *Guid;
745  event->WnodeHeader.ProviderId = IoWMIDeviceObjectToProviderId(DeviceObject);
746  event->WnodeHeader.BufferSize = sizeNeeded;
747  event->WnodeHeader.Flags = WNODE_FLAG_SINGLE_INSTANCE |
750  KeQuerySystemTime(&event->WnodeHeader.TimeStamp);
751 
752  event->InstanceIndex = InstanceIndex;
753  event->SizeDataBlock = EventDataSize;
754  event->DataBlockOffset = sizeof(WNODE_SINGLE_INSTANCE);
755  if (EventData != NULL)
756  {
757  RtlCopyMemory( &event->VariableData, EventData, EventDataSize);
758  }
759 
761  if (! NT_SUCCESS(status))
762  {
763  ExFreePool(event);
764  }
765  } else {
767  }
768 
769  return(status);
770 } // end ClassWmiFireEvent()
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct tagWNODE_SINGLE_INSTANCE WNODE_SINGLE_INSTANCE
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1057
NTSTATUS NTAPI IoWMIWriteEvent(IN PVOID WnodeEventItem)
Definition: wmi.c:109
#define WNODE_FLAG_EVENT_ITEM
Definition: wmistr.h:31
static GUID * Guid
Definition: apphelp.c:93
smooth NULL
Definition: ftsmooth.c:416
#define WNODE_FLAG_STATIC_INSTANCE_NAMES
Definition: wmistr.h:35
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ LPGUID _In_ ULONG _In_ ULONG EventDataSize
Definition: classpnp.h:1057
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _cl_event * event
Definition: glext.h:7739
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define CLASS_TAG_WMI
Definition: classpnp.h:83
unsigned int ULONG
Definition: retypes.h:1
#define IoWMIDeviceObjectToProviderId(DeviceObject)
static SERVICE_STATUS status
Definition: service.c:31
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define WNODE_FLAG_SINGLE_INSTANCE
Definition: wmistr.h:29
Definition: ps.c:97

Referenced by ClassNotifyFailurePredicted().