ReactOS  0.4.15-dev-1150-g593bcce
classwmi.c File Reference
#include "stddef.h"
#include "ntddk.h"
#include "scsi.h"
#include "classpnp.h"
#include "mountdev.h"
#include <stdarg.h>
#include "classp.h"
#include <wmistr.h>
#include <wmidata.h>
Include dependency graph for classwmi.c:

Go to the source code of this file.

Macros

#define TIME_STRING_LENGTH   25
 
#define MOFRESOURCENAME   L"MofResourceName"
 
#define MSStorageDriver_ClassErrorLogGuid_Index   0
 
#define NUM_CLASS_WMI_GUIDS   (sizeof(wmiClassGuids) / sizeof(GUIDREGINFO))
 

Functions

BOOLEAN ClassFindGuid (PGUIDREGINFO GuidList, ULONG GuidCount, LPGUID Guid, PULONG GuidIndex)
 
NTSTATUS ClassQueryInternalDataBlock (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG BufferAvail, OUT PUCHAR Buffer)
 
PWCHAR ConvertTickToDateTime (IN LARGE_INTEGER Tick, _Out_writes_(TIME_STRING_LENGTH) PWCHAR String)
 
BOOLEAN ClassFindInternalGuid (LPGUID Guid, PULONG GuidIndex)
 
NTSTATUS NTAPI ClassSystemControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ NTSTATUS Status, _In_ ULONG BufferUsed, _In_ CCHAR PriorityBoost)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL)
 

Variables

GUIDREGINFO wmiClassGuids []
 

Macro Definition Documentation

◆ MOFRESOURCENAME

#define MOFRESOURCENAME   L"MofResourceName"

Definition at line 80 of file classwmi.c.

◆ MSStorageDriver_ClassErrorLogGuid_Index

#define MSStorageDriver_ClassErrorLogGuid_Index   0

Definition at line 104 of file classwmi.c.

◆ NUM_CLASS_WMI_GUIDS

#define NUM_CLASS_WMI_GUIDS   (sizeof(wmiClassGuids) / sizeof(GUIDREGINFO))

Definition at line 105 of file classwmi.c.

◆ TIME_STRING_LENGTH

#define TIME_STRING_LENGTH   25

Definition at line 45 of file classwmi.c.

Function Documentation

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 1168 of file classwmi.c.

1178 {
1179 
1180  ULONG sizeNeeded;
1182  NTSTATUS status;
1183 
1184  if (EventData == NULL)
1185  {
1186  EventDataSize = 0;
1187  }
1188 
1189  sizeNeeded = sizeof(WNODE_SINGLE_INSTANCE) + EventDataSize;
1190 
1191  event = ExAllocatePoolWithTag(NonPagedPoolNx, sizeNeeded, CLASS_TAG_WMI);
1192  if (event != NULL)
1193  {
1194  RtlZeroMemory(event, sizeNeeded);
1195  event->WnodeHeader.Guid = *Guid;
1196  event->WnodeHeader.ProviderId = IoWMIDeviceObjectToProviderId(DeviceObject);
1197  event->WnodeHeader.BufferSize = sizeNeeded;
1198  event->WnodeHeader.Flags = WNODE_FLAG_SINGLE_INSTANCE |
1201  KeQuerySystemTime(&event->WnodeHeader.TimeStamp);
1202 
1203  event->InstanceIndex = InstanceIndex;
1204  event->SizeDataBlock = EventDataSize;
1205  event->DataBlockOffset = sizeof(WNODE_SINGLE_INSTANCE);
1206  if (EventData != NULL)
1207  {
1208  RtlCopyMemory( &event->VariableData, EventData, EventDataSize);
1209  }
1210 
1212  if (! NT_SUCCESS(status))
1213  {
1214  FREE_POOL(event);
1215  }
1216  } else {
1218  }
1219 
1220  return(status);
1221 } // 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:1250
NTSTATUS NTAPI IoWMIWriteEvent(IN PVOID WnodeEventItem)
Definition: wmi.c:109
#define WNODE_FLAG_EVENT_ITEM
Definition: wmistr.h:31
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
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:1250
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _cl_event * event
Definition: glext.h:7739
#define CLASS_TAG_WMI
Definition: classpnp.h:83
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IoWMIDeviceObjectToProviderId(DeviceObject)
static SERVICE_STATUS status
Definition: service.c:31
#define WNODE_FLAG_SINGLE_INSTANCE
Definition: wmistr.h:29
Definition: ps.c:97

◆ ClassFindGuid()

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

Definition at line 133 of file classwmi.c.

139 {
140  ULONG i;
141 
142  PAGED_CODE();
143 
144  for (i = 0; i < GuidCount; i++)
145  {
146  if (IsEqualGUID(Guid, &GuidList[i].Guid))
147  {
148  *GuidIndex = i;
149  return(TRUE);
150  }
151  }
152  return(FALSE);
153 } // end ClassFindGuid()
#define TRUE
Definition: types.h:120
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
#define FALSE
Definition: types.h:117
static GUID * Guid
Definition: apphelp.c:93
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
unsigned int ULONG
Definition: retypes.h:1
#define PAGED_CODE()

Referenced by ClassSystemControl().

◆ ClassFindInternalGuid()

BOOLEAN ClassFindInternalGuid ( LPGUID  Guid,
PULONG  GuidIndex 
)

Definition at line 176 of file classwmi.c.

180 {
181  ULONG i;
182 
183  PAGED_CODE();
184 
185  for (i = 0; i < NUM_CLASS_WMI_GUIDS; i++)
186  {
188  {
189  *GuidIndex = i;
190  return(TRUE);
191  }
192  }
193 
194  return(FALSE);
195 } // end ClassFindGuid()
#define NUM_CLASS_WMI_GUIDS
Definition: classwmi.c:105
#define TRUE
Definition: types.h:120
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
#define FALSE
Definition: types.h:117
static GUID * Guid
Definition: apphelp.c:93
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
GUIDREGINFO wmiClassGuids[]
Definition: classwmi.c:97
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
unsigned int ULONG
Definition: retypes.h:1
#define PAGED_CODE()

Referenced by ClassSystemControl().

◆ ClassQueryInternalDataBlock()

NTSTATUS ClassQueryInternalDataBlock ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN ULONG  GuidIndex,
IN ULONG  BufferAvail,
OUT PUCHAR  Buffer 
)

Definition at line 782 of file classwmi.c.

817 {
819 #ifndef __REACTOS__ // WMI in not a thing on ReactOS yet
820  ULONG sizeNeeded = 0, i;
821  PFUNCTIONAL_DEVICE_EXTENSION fdoExt = DeviceObject->DeviceExtension;
823 
824  //
825  // NOTE - ClassErrorLog is still using SCSI_REQUEST_BLOCK and will not be
826  // updated to support extended SRB until classpnp is updated to send >16
827  // byte CDBs. Extended SRBs will be translated to SCSI_REQUEST_BLOCK.
828  //
829  sizeNeeded = MSStorageDriver_ClassErrorLog_SIZE;
830  if (BufferAvail >= sizeNeeded) {
831  PMSStorageDriver_ClassErrorLog errorLog = (PMSStorageDriver_ClassErrorLog) Buffer;
832  PMSStorageDriver_ClassErrorLogEntry logEntry;
833  PMSStorageDriver_ScsiRequestBlock srbBlock;
834  PMSStorageDriver_SenseData senseData;
835  PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData;
836  PCLASS_ERROR_LOG_DATA fdoLogEntry;
837  PSCSI_REQUEST_BLOCK fdoSRBBlock;
838  PSENSE_DATA fdoSenseData;
839  errorLog->numEntries = NUM_ERROR_LOG_ENTRIES;
840  for (i = 0; i < NUM_ERROR_LOG_ENTRIES; i++) {
841  fdoLogEntry = &fdoData->ErrorLogs[i];
842  fdoSRBBlock = &fdoLogEntry->Srb;
843  fdoSenseData = &fdoLogEntry->SenseData;
844  logEntry = &errorLog->logEntries[i];
845  srbBlock = &logEntry->srb;
846  senseData = &logEntry->senseData;
847  logEntry->tickCount = fdoLogEntry->TickCount.QuadPart;
848  logEntry->portNumber = fdoLogEntry->PortNumber;
849  logEntry->errorPaging = (fdoLogEntry->ErrorPaging == 0 ? FALSE : TRUE);
850  logEntry->errorRetried = (fdoLogEntry->ErrorRetried == 0 ? FALSE : TRUE);
851  logEntry->errorUnhandled = (fdoLogEntry->ErrorUnhandled == 0 ? FALSE : TRUE);
852  logEntry->errorReserved = fdoLogEntry->ErrorReserved;
853  RtlMoveMemory(logEntry->reserved, fdoLogEntry->Reserved, sizeof(logEntry->reserved));
854  ConvertTickToDateTime(fdoLogEntry->TickCount, logEntry->eventTime);
855 
856  srbBlock->length = fdoSRBBlock->Length;
857  srbBlock->function = fdoSRBBlock->Function;
858  srbBlock->srbStatus = fdoSRBBlock->SrbStatus;
859  srbBlock->scsiStatus = fdoSRBBlock->ScsiStatus;
860  srbBlock->pathID = fdoSRBBlock->PathId;
861  srbBlock->targetID = fdoSRBBlock->TargetId;
862  srbBlock->lun = fdoSRBBlock->Lun;
863  srbBlock->queueTag = fdoSRBBlock->QueueTag;
864  srbBlock->queueAction = fdoSRBBlock->QueueAction;
865  srbBlock->cdbLength = fdoSRBBlock->CdbLength;
866  srbBlock->senseInfoBufferLength = fdoSRBBlock->SenseInfoBufferLength;
867  srbBlock->srbFlags = fdoSRBBlock->SrbFlags;
868  srbBlock->dataTransferLength = fdoSRBBlock->DataTransferLength;
869  srbBlock->timeOutValue = fdoSRBBlock->TimeOutValue;
870  srbBlock->dataBuffer = (ULONGLONG) fdoSRBBlock->DataBuffer;
871  srbBlock->senseInfoBuffer = (ULONGLONG) fdoSRBBlock->SenseInfoBuffer;
872  srbBlock->nextSRB = (ULONGLONG) fdoSRBBlock->NextSrb;
873  srbBlock->originalRequest = (ULONGLONG) fdoSRBBlock->OriginalRequest;
874  srbBlock->srbExtension = (ULONGLONG) fdoSRBBlock->SrbExtension;
875  srbBlock->internalStatus = fdoSRBBlock->InternalStatus;
876 #if defined(_WIN64)
877  srbBlock->reserved = fdoSRBBlock->Reserved;
878 #else
879  srbBlock->reserved = 0;
880 #endif
881  RtlMoveMemory(srbBlock->cdb, fdoSRBBlock->Cdb, sizeof(srbBlock->cdb));
882 
883  //
884  // Note: Sense data has been converted into Fixed format before it was
885  // put in the log. Therefore, no conversion is needed here.
886  //
887  senseData->errorCode = fdoSenseData->ErrorCode;
888  senseData->valid = (fdoSenseData->Valid == 0 ? FALSE : TRUE);
889  senseData->segmentNumber = fdoSenseData->SegmentNumber;
890  senseData->senseKey = fdoSenseData->SenseKey;
891  senseData->reserved = (fdoSenseData->Reserved == 0 ? FALSE : TRUE);
892  senseData->incorrectLength = (fdoSenseData->IncorrectLength == 0 ? FALSE : TRUE);
893  senseData->endOfMedia = (fdoSenseData->EndOfMedia == 0 ? FALSE : TRUE);
894  senseData->fileMark = (fdoSenseData->FileMark == 0 ? FALSE : TRUE);
895  RtlMoveMemory(senseData->information, fdoSenseData->Information, sizeof(senseData->information));
896  senseData->additionalSenseLength = fdoSenseData->AdditionalSenseLength;
897  RtlMoveMemory(senseData->commandSpecificInformation, fdoSenseData->CommandSpecificInformation, sizeof(senseData->commandSpecificInformation));
898  senseData->additionalSenseCode = fdoSenseData->AdditionalSenseCode;
899  senseData->additionalSenseCodeQualifier = fdoSenseData->AdditionalSenseCodeQualifier;
900  senseData->fieldReplaceableUnitCode = fdoSenseData->FieldReplaceableUnitCode;
901  RtlMoveMemory(senseData->senseKeySpecific, fdoSenseData->SenseKeySpecific, sizeof(senseData->senseKeySpecific));
902  }
904  } else {
906  }
907  } else if (GuidIndex > 0 && GuidIndex < NUM_CLASS_WMI_GUIDS) {
909  } else {
911  }
912 #else
913  ULONG sizeNeeded = 0;
915 #endif
917  Irp,
918  status,
919  sizeNeeded,
921  return status;
922 }
UCHAR FieldReplaceableUnitCode
Definition: cdrw_hw.h:1177
UCHAR SenseKey
Definition: cdrw_hw.h:1167
#define NUM_CLASS_WMI_GUIDS
Definition: classwmi.c:105
UCHAR CommandSpecificInformation[4]
Definition: cdrw_hw.h:1174
ULONG SrbFlags
Definition: srb.h:252
PVOID SrbExtension
Definition: srb.h:259
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
PVOID OriginalRequest
Definition: srb.h:258
UCHAR Cdb[16]
Definition: srb.h:271
LARGE_INTEGER TickCount
Definition: classp.h:461
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
PVOID DataBuffer
Definition: srb.h:255
ULONG DataTransferLength
Definition: srb.h:253
UCHAR SegmentNumber
Definition: cdrw_hw.h:1166
LONG NTSTATUS
Definition: precomp.h:26
SENSE_DATA SenseData
Definition: classp.h:479
UCHAR CdbLength
Definition: srb.h:250
struct _SCSI_REQUEST_BLOCK * NextSrb
Definition: srb.h:257
UCHAR QueueAction
Definition: srb.h:249
ULONG TimeOutValue
Definition: srb.h:254
UCHAR SrbStatus
Definition: srb.h:243
UCHAR FileMark
Definition: cdrw_hw.h:1171
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_WMI_INSTANCE_NOT_FOUND
Definition: ntstatus.h:777
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
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
#define FALSE
Definition: types.h:117
UCHAR SenseKeySpecific[3]
Definition: cdrw_hw.h:1178
UCHAR ScsiStatus
Definition: srb.h:244
UCHAR EndOfMedia
Definition: cdrw_hw.h:1170
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
#define MSStorageDriver_ClassErrorLogGuid_Index
Definition: classwmi.c:104
Definition: bufpool.h:45
UCHAR QueueTag
Definition: srb.h:248
UCHAR TargetId
Definition: srb.h:246
UCHAR Information[4]
Definition: cdrw_hw.h:1172
SCSI_REQUEST_BLOCK Srb
Definition: classp.h:471
UCHAR AdditionalSenseCodeQualifier
Definition: cdrw_hw.h:1176
#define NUM_ERROR_LOG_ENTRIES
Definition: cdromp.h:323
uint64_t ULONGLONG
Definition: typedefs.h:67
UCHAR Function
Definition: srb.h:242
UCHAR Reserved[3]
Definition: classp.h:469
USHORT Length
Definition: srb.h:241
PWCHAR ConvertTickToDateTime(IN LARGE_INTEGER Tick, _Out_writes_(TIME_STRING_LENGTH) PWCHAR String)
Definition: classwmi.c:925
UCHAR Reserved
Definition: cdrw_hw.h:1168
ULONG InternalStatus
Definition: srb.h:261
_In_ PIRP _In_ ULONG _In_ ULONG BufferAvail
Definition: classpnp.h:418
UCHAR SenseInfoBufferLength
Definition: srb.h:251
UCHAR PathId
Definition: srb.h:245
SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ NTSTATUS Status, _In_ ULONG BufferUsed, _In_ CCHAR PriorityBoost)
Definition: classwmi.c:1009
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
UCHAR IncorrectLength
Definition: cdrw_hw.h:1169
PVOID SenseInfoBuffer
Definition: srb.h:256
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
UCHAR AdditionalSenseLength
Definition: cdrw_hw.h:1173
UCHAR Valid
Definition: cdrw_hw.h:1165
UCHAR AdditionalSenseCode
Definition: cdrw_hw.h:1175
return STATUS_SUCCESS
Definition: btrfs.c:3014
static SERVICE_STATUS status
Definition: service.c:31
CLASS_ERROR_LOG_DATA ErrorLogs[NUM_ERROR_LOG_ENTRIES]
Definition: classp.h:821
UCHAR ErrorCode
Definition: cdrw_hw.h:1164
LONGLONG QuadPart
Definition: typedefs.h:114
Definition: ps.c:97

Referenced by ClassSystemControl().

◆ ClassSystemControl()

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

Definition at line 221 of file classwmi.c.

225 {
226  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
227  PCLASS_DRIVER_EXTENSION driverExtension;
229  ULONG isRemoved;
230  ULONG bufferSize;
231  PUCHAR buffer;
233  UCHAR minorFunction;
234  ULONG guidIndex = (ULONG)-1;
235  PCLASS_WMI_INFO classWmiInfo;
236  BOOLEAN isInternalGuid = FALSE;
237 
238  PAGED_CODE();
239 
240  //
241  // Make sure device has not been removed
243  if(isRemoved)
244  {
245  Irp->IoStatus.Status = STATUS_DEVICE_DOES_NOT_EXIST;
249  }
250 
251  //
252  // If the irp is not a WMI irp or it is not targetted at this device
253  // or this device has not regstered with WMI then just forward it on.
254  minorFunction = irpStack->MinorFunction;
255  if ((minorFunction > IRP_MN_EXECUTE_METHOD) ||
256  (irpStack->Parameters.WMI.ProviderId != (ULONG_PTR)DeviceObject) ||
257  ((minorFunction != IRP_MN_REGINFO) &&
258  (commonExtension->GuidCount == 0)))
259  {
260  //
261  // CONSIDER: Do I need to hang onto lock until IoCallDriver returns ?
264  return(IoCallDriver(commonExtension->LowerDeviceObject, Irp));
265  }
266 
267  buffer = (PUCHAR)irpStack->Parameters.WMI.Buffer;
268  bufferSize = irpStack->Parameters.WMI.BufferSize;
269 
270  if (minorFunction != IRP_MN_REGINFO)
271  {
272  //
273  // For all requests other than query registration info we are passed
274  // a guid. Determine if the guid is one that is supported by the
275  // device.
276  if (commonExtension->GuidRegInfo != NULL &&
277  ClassFindGuid(commonExtension->GuidRegInfo,
278  commonExtension->GuidCount,
279  (LPGUID)irpStack->Parameters.WMI.DataPath,
280  &guidIndex))
281  {
282  isInternalGuid = FALSE;
284  } else if (ClassFindInternalGuid((LPGUID)irpStack->Parameters.WMI.DataPath,
285  &guidIndex)) {
286  isInternalGuid = TRUE;
288  } else {
290  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_WMI, "WMI GUID not found!"));
291  }
292 
293  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_WMI, "WMI Find Guid = %x, isInternalGuid = %x", status, isInternalGuid));
294  if (NT_SUCCESS(status) &&
295  ((minorFunction == IRP_MN_QUERY_SINGLE_INSTANCE) ||
296  (minorFunction == IRP_MN_CHANGE_SINGLE_INSTANCE) ||
297  (minorFunction == IRP_MN_CHANGE_SINGLE_ITEM) ||
298  (minorFunction == IRP_MN_EXECUTE_METHOD)))
299  {
300  if ( (((PWNODE_HEADER)buffer)->Flags) &
302  {
304  {
306  }
307  } else {
309  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_WMI, "WMI Instance not found!"));
310  }
311  }
312 
313  if (! NT_SUCCESS(status))
314  {
315  Irp->IoStatus.Status = status;
318  return(status);
319  }
320  }
321 
322  driverExtension = commonExtension->DriverExtension;
323 
324  classWmiInfo = commonExtension->IsFdo ?
325  &driverExtension->InitData.FdoData.ClassWmiInfo :
326  &driverExtension->InitData.PdoData.ClassWmiInfo;
327  switch(minorFunction)
328  {
329  case IRP_MN_REGINFO:
330  {
331  ULONG guidCount;
332  PGUIDREGINFO guidList;
333  PWMIREGINFOW wmiRegInfo;
334  PWMIREGGUIDW wmiRegGuid;
335  PUNICODE_STRING regPath;
336  PWCHAR stringPtr;
337  ULONG retSize;
338  ULONG registryPathOffset;
339  ULONG mofResourceOffset;
340  ULONG bufferNeeded;
341  ULONG i;
342  ULONG_PTR nameInfo;
343  ULONG nameSize, nameOffset, nameFlags;
344  UNICODE_STRING name, mofName;
345  PCLASS_QUERY_WMI_REGINFO_EX ClassQueryWmiRegInfoEx;
346 
347  name.Buffer = NULL;
348  name.Length = 0;
349  name.MaximumLength = 0;
350  nameFlags = 0;
351 
352  ClassQueryWmiRegInfoEx = commonExtension->IsFdo ?
353  driverExtension->ClassFdoQueryWmiRegInfoEx :
354  driverExtension->ClassPdoQueryWmiRegInfoEx;
355 
356  if ((classWmiInfo->GuidRegInfo != NULL) &&
357  (classWmiInfo->ClassQueryWmiRegInfo != NULL) &&
358  (ClassQueryWmiRegInfoEx == NULL))
359  {
360  status = classWmiInfo->ClassQueryWmiRegInfo(
361  DeviceObject,
362  &nameFlags,
363  &name);
364 
366 
367  } else if ((classWmiInfo->GuidRegInfo != NULL) && (ClassQueryWmiRegInfoEx != NULL)) {
368  RtlInitUnicodeString(&mofName, L"");
369 
370  status = (*ClassQueryWmiRegInfoEx)(
371  DeviceObject,
372  &nameFlags,
373  &name,
374  &mofName);
375  } else {
376  RtlInitUnicodeString(&mofName, L"");
377  nameFlags = WMIREG_FLAG_INSTANCE_PDO;
379  }
380 
381  if (NT_SUCCESS(status) &&
382  (! (nameFlags & WMIREG_FLAG_INSTANCE_PDO) &&
383  (name.Buffer == NULL)))
384  {
385  //
386  // if PDO flag not specified then an instance name must be
388  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_WMI, "Invalid Device Request!"));
389  }
390 
391  if (NT_SUCCESS(status))
392  {
393  guidList = classWmiInfo->GuidRegInfo;
394  guidCount = (classWmiInfo->GuidRegInfo == NULL ? 0 : classWmiInfo->GuidCount) + NUM_CLASS_WMI_GUIDS;
395 
396  nameOffset = sizeof(WMIREGINFO) +
397  guidCount * sizeof(WMIREGGUIDW);
398 
399  if (nameFlags & WMIREG_FLAG_INSTANCE_PDO)
400  {
401  nameSize = 0;
402  nameInfo = commonExtension->IsFdo ?
403  (ULONG_PTR)((PFUNCTIONAL_DEVICE_EXTENSION)commonExtension)->LowerPdo :
405  } else {
406  nameFlags |= WMIREG_FLAG_INSTANCE_LIST;
407  nameSize = name.Length + sizeof(USHORT);
408  nameInfo = nameOffset;
409  }
410 
411  mofResourceOffset = nameOffset + nameSize;
412 
413  registryPathOffset = mofResourceOffset +
414  mofName.Length + sizeof(USHORT);
415 
416  regPath = &driverExtension->RegistryPath;
417 
418  bufferNeeded = registryPathOffset + regPath->Length;
419  bufferNeeded += sizeof(USHORT);
420 
421  if (bufferNeeded <= bufferSize)
422  {
423  retSize = bufferNeeded;
424 
425  commonExtension->GuidCount = guidCount;
426  commonExtension->GuidRegInfo = guidList;
427 
428  wmiRegInfo = (PWMIREGINFO)buffer;
429  wmiRegInfo->BufferSize = bufferNeeded;
430  wmiRegInfo->NextWmiRegInfo = 0;
431  wmiRegInfo->MofResourceName = mofResourceOffset;
432  wmiRegInfo->RegistryPath = registryPathOffset;
433  wmiRegInfo->GuidCount = guidCount;
434 
435  for (i = 0; i < classWmiInfo->GuidCount; i++)
436  {
437  wmiRegGuid = &wmiRegInfo->WmiRegGuid[i];
438  wmiRegGuid->Guid = guidList[i].Guid;
439  wmiRegGuid->Flags = guidList[i].Flags | nameFlags;
440  wmiRegGuid->InstanceInfo = nameInfo;
441  wmiRegGuid->InstanceCount = 1;
442  }
443  for (i = 0; i < NUM_CLASS_WMI_GUIDS; i++)
444  {
445  wmiRegGuid = &wmiRegInfo->WmiRegGuid[i + classWmiInfo->GuidCount];
446  wmiRegGuid->Guid = wmiClassGuids[i].Guid;
447  wmiRegGuid->Flags = wmiClassGuids[i].Flags | nameFlags;
448  wmiRegGuid->InstanceInfo = nameInfo;
449  wmiRegGuid->InstanceCount = 1;
450  }
451 
452  if ( nameFlags & WMIREG_FLAG_INSTANCE_LIST)
453  {
454  bufferNeeded = nameOffset + sizeof(WCHAR);
455  bufferNeeded += name.Length;
456 
457  if (bufferSize >= bufferNeeded){
458  stringPtr = (PWCHAR)((PUCHAR)buffer + nameOffset);
459  *stringPtr++ = name.Length;
460  RtlCopyMemory(stringPtr, name.Buffer, name.Length);
461  }
462  else {
463  NT_ASSERT(bufferSize >= bufferNeeded);
465  }
466  }
467 
468  bufferNeeded = mofResourceOffset + sizeof(WCHAR);
469  bufferNeeded += mofName.Length;
470 
471  if (bufferSize >= bufferNeeded){
472  stringPtr = (PWCHAR)((PUCHAR)buffer + mofResourceOffset);
473  *stringPtr++ = mofName.Length;
474  RtlCopyMemory(stringPtr, mofName.Buffer, mofName.Length);
475  }
476  else {
477  NT_ASSERT(bufferSize >= bufferNeeded);
479  }
480 
481  bufferNeeded = registryPathOffset + sizeof(WCHAR);
482  bufferNeeded += regPath->Length;
483 
484  if (bufferSize >= bufferNeeded){
485  stringPtr = (PWCHAR)((PUCHAR)buffer + registryPathOffset);
486  *stringPtr++ = regPath->Length;
487  RtlCopyMemory(stringPtr,
488  regPath->Buffer,
489  regPath->Length);
490  }
491  else {
492 
493  NT_ASSERT(bufferSize >= bufferNeeded);
494  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_WMI, "Invalid Buffer Size!"));
496  }
497 
498  } else {
499  *((PULONG)buffer) = bufferNeeded;
500  retSize = sizeof(ULONG);
501  }
502  } else {
503  retSize = 0;
504  }
505 
506  FREE_POOL(name.Buffer);
507 
508  Irp->IoStatus.Status = status;
509  Irp->IoStatus.Information = retSize;
512  return(status);
513  }
514 
516  {
517  PWNODE_ALL_DATA wnode;
518  ULONG bufferAvail;
519 
520  wnode = (PWNODE_ALL_DATA)buffer;
521 
522  if (bufferSize < sizeof(WNODE_ALL_DATA))
523  {
524  bufferAvail = 0;
525  } else {
526  bufferAvail = bufferSize - sizeof(WNODE_ALL_DATA);
527  }
528 
529  wnode->DataBlockOffset = sizeof(WNODE_ALL_DATA);
530 
531  NT_ASSERT(guidIndex != (ULONG)-1);
532  _Analysis_assume_(isInternalGuid);
533  if (isInternalGuid)
534  {
536  DeviceObject,
537  Irp,
538  guidIndex,
539  bufferAvail,
540  buffer + sizeof(WNODE_ALL_DATA));
541  } else {
542  status = classWmiInfo->ClassQueryWmiDataBlock(
543  DeviceObject,
544  Irp,
545  guidIndex,
546  bufferAvail,
547  buffer + sizeof(WNODE_ALL_DATA));
548  }
549  break;
550  }
551 
553  {
555  ULONG dataBlockOffset;
556 
558 
559  dataBlockOffset = wnode->DataBlockOffset;
560 
561  NT_ASSERT(guidIndex != (ULONG)-1);
562  _Analysis_assume_(isInternalGuid);
563  if (isInternalGuid)
564  {
566  DeviceObject,
567  Irp,
568  guidIndex,
569  bufferSize - dataBlockOffset,
570  (PUCHAR)wnode + dataBlockOffset);
571  } else {
572  status = classWmiInfo->ClassQueryWmiDataBlock(
573  DeviceObject,
574  Irp,
575  guidIndex,
576  bufferSize - dataBlockOffset,
577  (PUCHAR)wnode + dataBlockOffset);
578  }
579  break;
580  }
581 
583  {
585 
587  _Analysis_assume_(isInternalGuid);
588  if (isInternalGuid)
589  {
591  Irp,
593  0,
595  } else {
596 
597  NT_ASSERT(guidIndex != (ULONG)-1);
598 
599  status = classWmiInfo->ClassSetWmiDataBlock(
600  DeviceObject,
601  Irp,
602  guidIndex,
603  wnode->SizeDataBlock,
604  (PUCHAR)wnode + wnode->DataBlockOffset);
605  }
606 
607  break;
608  }
609 
611  {
612  PWNODE_SINGLE_ITEM wnode;
613 
614  wnode = (PWNODE_SINGLE_ITEM)buffer;
615 
616  NT_ASSERT(guidIndex != (ULONG)-1);
617  _Analysis_assume_(isInternalGuid);
618  if (isInternalGuid)
619  {
621  Irp,
623  0,
625  } else {
626 
627  NT_ASSERT(guidIndex != (ULONG)-1);
628 
629  status = classWmiInfo->ClassSetWmiDataItem(
630  DeviceObject,
631  Irp,
632  guidIndex,
633  wnode->ItemId,
634  wnode->SizeDataItem,
635  (PUCHAR)wnode + wnode->DataBlockOffset);
636 
637  }
638 
639  break;
640  }
641 
643  {
644  PWNODE_METHOD_ITEM wnode;
645 
646  wnode = (PWNODE_METHOD_ITEM)buffer;
647  _Analysis_assume_(isInternalGuid);
648  if (isInternalGuid)
649  {
651  Irp,
653  0,
655  } else {
656 
657  NT_ASSERT(guidIndex != (ULONG)-1);
658 
659  status = classWmiInfo->ClassExecuteWmiMethod(
660  DeviceObject,
661  Irp,
662  guidIndex,
663  wnode->MethodId,
664  wnode->SizeDataBlock,
665  bufferSize - wnode->DataBlockOffset,
666  buffer + wnode->DataBlockOffset);
667  }
668 
669  break;
670  }
671 
673  {
674  _Analysis_assume_(isInternalGuid);
675  if (isInternalGuid)
676  {
678  Irp,
680  0,
682  } else {
683 
684  NT_ASSERT(guidIndex != (ULONG)-1);
685 
686  status = classWmiInfo->ClassWmiFunctionControl(
687  DeviceObject,
688  Irp,
689  guidIndex,
691  TRUE);
692  }
693  break;
694  }
695 
697  {
698  _Analysis_assume_(isInternalGuid);
699  if (isInternalGuid)
700  {
702  Irp,
704  0,
706  } else {
707 
708  NT_ASSERT(guidIndex != (ULONG)-1);
709 
710  status = classWmiInfo->ClassWmiFunctionControl(
711  DeviceObject,
712  Irp,
713  guidIndex,
715  FALSE);
716  }
717  break;
718  }
719 
721  {
722  _Analysis_assume_(isInternalGuid);
723  if (isInternalGuid)
724  {
726  Irp,
728  0,
730  } else {
731 
732  NT_ASSERT(guidIndex != (ULONG)-1);
733 
734  status = classWmiInfo->ClassWmiFunctionControl(
735  DeviceObject,
736  Irp,
737  guidIndex,
739  TRUE);
740  }
741  break;
742  }
743 
745  {
746  _Analysis_assume_(isInternalGuid);
747  if (isInternalGuid)
748  {
750  Irp,
752  0,
754  } else {
755 
756  NT_ASSERT(guidIndex != (ULONG)-1);
757 
758  status = classWmiInfo->ClassWmiFunctionControl(
759  DeviceObject,
760  Irp,
761  guidIndex,
763  FALSE);
764  }
765 
766  break;
767  }
768 
769  default:
770  {
772  break;
773  }
774 
775  }
776 
777  return(status);
778 } // end ClassSystemControl()
ULONG DataBlockOffset
Definition: wmistr.h:129
struct tagWNODE_SINGLE_ITEM * PWNODE_SINGLE_ITEM
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define NUM_CLASS_WMI_GUIDS
Definition: classwmi.c:105
ULONG RegistryPath
Definition: wmistr.h:95
PGUIDREGINFO GuidRegInfo
Definition: classpnp.h:508
#define IRP_MN_REGINFO
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
GUID Guid
Definition: classpnp.h:501
#define ClassAcquireRemoveLock(devobj, tag)
Definition: classpnp.h:100
struct tagWNODE_ALL_DATA * PWNODE_ALL_DATA
struct tagWNODE_SINGLE_INSTANCE * PWNODE_SINGLE_INSTANCE
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
GUID Guid
Definition: wmistr.h:79
BOOLEAN ClassFindGuid(PGUIDREGINFO GuidList, ULONG GuidCount, LPGUID Guid, PULONG GuidIndex)
Definition: classwmi.c:133
CLASS_DEV_INFO FdoData
Definition: classpnp.h:538
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
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:1250
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
GLuint buffer
Definition: glext.h:5915
uint16_t * PWCHAR
Definition: typedefs.h:56
#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
PCLASS_QUERY_WMI_DATABLOCK ClassQueryWmiDataBlock
Definition: classpnp.h:510
#define IRP_MN_ENABLE_COLLECTION
#define STATUS_WMI_INSTANCE_NOT_FOUND
Definition: ntstatus.h:777
#define MOFRESOURCENAME
Definition: classwmi.c:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
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
NTSTATUS ClassQueryInternalDataBlock(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG BufferAvail, OUT PUCHAR Buffer)
Definition: classwmi.c:782
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
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:511
unsigned char BOOLEAN
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
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:580
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define WNODE_FLAG_STATIC_INSTANCE_NAMES
Definition: wmistr.h:35
ULONG DataBlockOffset
Definition: wmistr.h:113
GUIDREGINFO wmiClassGuids[]
Definition: classwmi.c:97
ULONG Flags
Definition: classpnp.h:503
#define IRP_MN_ENABLE_EVENTS
if(!(yy_init))
Definition: macro.lex.yy.c:714
CLASS_WMI_INFO ClassWmiInfo
Definition: classpnp.h:533
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG NextWmiRegInfo
Definition: wmistr.h:94
PCLASS_QUERY_WMI_REGINFO_EX ClassPdoQueryWmiRegInfoEx
Definition: classpnp.h:581
ULONG_PTR InstanceInfo
Definition: wmistr.h:87
BOOLEAN ClassFindInternalGuid(LPGUID Guid, PULONG GuidIndex)
Definition: classwmi.c:176
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:600
#define IRP_MN_EXECUTE_METHOD
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define WMIREG_FLAG_INSTANCE_LIST
Definition: wmistr.h:67
#define IRP_MN_CHANGE_SINGLE_INSTANCE
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PCLASS_SET_WMI_DATAITEM ClassSetWmiDataItem
Definition: classpnp.h:512
ULONG BufferSize
Definition: wmistr.h:93
PGUIDREGINFO GuidRegInfo
Definition: classpnp.h:630
SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ NTSTATUS Status, _In_ ULONG BufferUsed, _In_ CCHAR PriorityBoost)
Definition: classwmi.c:1009
unsigned short USHORT
Definition: pedump.c:61
ULONG GuidCount
Definition: classpnp.h:507
#define IRP_MN_QUERY_ALL_DATA
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
unsigned int * PULONG
Definition: retypes.h:1
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:598
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:539
ULONG InstanceCount
Definition: wmistr.h:81
Definition: name.c:38
CLASS_INIT_DATA InitData
Definition: classpnp.h:577
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ULONG_PTR
Definition: config.h:101
PCLASS_EXECUTE_WMI_METHOD ClassExecuteWmiMethod
Definition: classpnp.h:513
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
Definition: lock.c:401
static SERVICE_STATUS status
Definition: service.c:31
PCLASS_WMI_FUNCTION_CONTROL ClassWmiFunctionControl
Definition: classpnp.h:514
PCLASS_QUERY_WMI_REGINFO ClassQueryWmiRegInfo
Definition: classpnp.h:509
#define _Analysis_assume_(expr)
Definition: no_sal2.h:10
#define PAGED_CODE()
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by ClassInitializeDispatchTables().

◆ ClassWmiCompleteRequest()

SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp,
_In_ NTSTATUS  Status,
_In_ ULONG  BufferUsed,
_In_ CCHAR  PriorityBoost 
)

Definition at line 1009 of file classwmi.c.

1016 {
1018  PUCHAR buffer;
1019  ULONG retSize;
1020  UCHAR minorFunction;
1021 
1022  minorFunction = irpStack->MinorFunction;
1023  buffer = (PUCHAR)irpStack->Parameters.WMI.Buffer;
1024 
1025  switch(minorFunction)
1026  {
1027  case IRP_MN_QUERY_ALL_DATA:
1028  {
1029  PWNODE_ALL_DATA wnode;
1030  PWNODE_TOO_SMALL wnodeTooSmall;
1031  ULONG bufferNeeded;
1032 
1033  wnode = (PWNODE_ALL_DATA)buffer;
1034 
1035  bufferNeeded = sizeof(WNODE_ALL_DATA) + BufferUsed;
1036 
1037  if (NT_SUCCESS(Status))
1038  {
1039  retSize = bufferNeeded;
1040  wnode->WnodeHeader.BufferSize = bufferNeeded;
1041  KeQuerySystemTime(&wnode->WnodeHeader.TimeStamp);
1043  wnode->FixedInstanceSize = BufferUsed;
1044  wnode->InstanceCount = 1;
1045 
1046  } else if (Status == STATUS_BUFFER_TOO_SMALL) {
1047  wnodeTooSmall = (PWNODE_TOO_SMALL)wnode;
1048 
1049  wnodeTooSmall->WnodeHeader.BufferSize = sizeof(WNODE_TOO_SMALL);
1050  wnodeTooSmall->WnodeHeader.Flags = WNODE_FLAG_TOO_SMALL;
1051  wnodeTooSmall->SizeNeeded = sizeof(WNODE_ALL_DATA) + BufferUsed;
1052  retSize = sizeof(WNODE_TOO_SMALL);
1054  } else {
1055  retSize = 0;
1056  }
1057  break;
1058  }
1059 
1061  {
1062  PWNODE_SINGLE_INSTANCE wnode;
1063  PWNODE_TOO_SMALL wnodeTooSmall;
1064  ULONG bufferNeeded;
1065 
1066  wnode = (PWNODE_SINGLE_INSTANCE)buffer;
1067 
1068  bufferNeeded = wnode->DataBlockOffset + BufferUsed;
1069 
1070  if (NT_SUCCESS(Status))
1071  {
1072  retSize = bufferNeeded;
1073  wnode->WnodeHeader.BufferSize = bufferNeeded;
1074  KeQuerySystemTime(&wnode->WnodeHeader.TimeStamp);
1075  wnode->SizeDataBlock = BufferUsed;
1076 
1077  } else if (Status == STATUS_BUFFER_TOO_SMALL) {
1078  wnodeTooSmall = (PWNODE_TOO_SMALL)wnode;
1079 
1080  wnodeTooSmall->WnodeHeader.BufferSize = sizeof(WNODE_TOO_SMALL);
1081  wnodeTooSmall->WnodeHeader.Flags = WNODE_FLAG_TOO_SMALL;
1082  wnodeTooSmall->SizeNeeded = bufferNeeded;
1083  retSize = sizeof(WNODE_TOO_SMALL);
1085  } else {
1086  retSize = 0;
1087  }
1088  break;
1089  }
1090 
1091  case IRP_MN_EXECUTE_METHOD:
1092  {
1093  PWNODE_METHOD_ITEM wnode;
1094  PWNODE_TOO_SMALL wnodeTooSmall;
1095  ULONG bufferNeeded;
1096 
1097  wnode = (PWNODE_METHOD_ITEM)buffer;
1098 
1099  bufferNeeded = wnode->DataBlockOffset + BufferUsed;
1100 
1101  if (NT_SUCCESS(Status))
1102  {
1103  retSize = bufferNeeded;
1104  wnode->WnodeHeader.BufferSize = bufferNeeded;
1105  KeQuerySystemTime(&wnode->WnodeHeader.TimeStamp);
1106  wnode->SizeDataBlock = BufferUsed;
1107 
1108  } else if (Status == STATUS_BUFFER_TOO_SMALL) {
1109  wnodeTooSmall = (PWNODE_TOO_SMALL)wnode;
1110 
1111  wnodeTooSmall->WnodeHeader.BufferSize = sizeof(WNODE_TOO_SMALL);
1112  wnodeTooSmall->WnodeHeader.Flags = WNODE_FLAG_TOO_SMALL;
1113  wnodeTooSmall->SizeNeeded = bufferNeeded;
1114  retSize = sizeof(WNODE_TOO_SMALL);
1116  } else {
1117  retSize = 0;
1118  }
1119  break;
1120  }
1121 
1122  default:
1123  {
1124  //
1125  // All other requests don't return any data
1126  retSize = 0;
1127  break;
1128  }
1129 
1130  }
1131 
1132  Irp->IoStatus.Status = Status;
1133  Irp->IoStatus.Information = retSize;
1136  return(Status);
1137 } // 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
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
#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
Status
Definition: gdiplustypes.h:24
#define IRP_MN_EXECUTE_METHOD
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
ULONG FixedInstanceSize
Definition: wmistr.h:118
struct _WNODE_HEADER WnodeHeader
Definition: wmistr.h:136
#define IRP_MN_QUERY_ALL_DATA
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
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:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
Definition: lock.c:401
ULONG InstanceCount
Definition: wmistr.h:114
#define WNODE_FLAG_TOO_SMALL
Definition: wmistr.h:33

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

◆ ConvertTickToDateTime()

PWCHAR ConvertTickToDateTime ( IN LARGE_INTEGER  Tick,
_Out_writes_(TIME_STRING_LENGTH) PWCHAR  String 
)

Definition at line 925 of file classwmi.c.

947 {
948  LARGE_INTEGER nowTick, nowTime, time;
949  ULONG maxInc = 0;
950  TIME_FIELDS timeFields = {0};
951  WCHAR outDateTime[TIME_STRING_LENGTH + 1];
952 
953  nowTick.QuadPart = 0;
954  nowTime.QuadPart = 0;
955  //
956  // Translate the tick count to a system time
957  //
958  KeQueryTickCount(&nowTick);
959  maxInc = KeQueryTimeIncrement();
960  KeQuerySystemTime(&nowTime);
961  time.QuadPart = nowTime.QuadPart - ((nowTick.QuadPart - Tick.QuadPart) * maxInc);
962 
963  RtlTimeToTimeFields(&time, &timeFields);
964 
965  //
966  // The buffer String is of size MAX_PATH. Use that to specify the buffer size.
967  //
968  //yyyymmddhhmmss.mmmmmmsutc
969  RtlStringCbPrintfW(outDateTime, sizeof(outDateTime), L"%04d%02d%02d%02d%02d%02d.%03d***+000", timeFields.Year, timeFields.Month, timeFields.Day, timeFields.Hour, timeFields.Minute, timeFields.Second, timeFields.Milliseconds);
970  RtlMoveMemory(String, outDateTime, sizeof(WCHAR) * TIME_STRING_LENGTH);
971  return String;
972 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
static WCHAR String[]
Definition: stringtable.c:55
__u16 time
Definition: mkdosfs.c:366
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
USHORT Milliseconds
Definition: env_spec_w32.h:717
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
BOOLEAN RtlTimeToTimeFields(IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
static const WCHAR L[]
Definition: oid.c:1250
unsigned int ULONG
Definition: retypes.h:1
#define TIME_STRING_LENGTH
Definition: classwmi.c:45
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by ClassQueryInternalDataBlock().

Variable Documentation

◆ wmiClassGuids

GUIDREGINFO wmiClassGuids[]
Initial value:
=
{
{
MSStorageDriver_ClassErrorLogGuid, 1, 0
}
}

Definition at line 97 of file classwmi.c.

Referenced by ClassFindInternalGuid(), and ClassSystemControl().