ReactOS  0.4.15-dev-3299-gbe8e5fc
fxwmiinstance.cpp File Reference
#include "fxwmipch.hpp"
Include dependency graph for fxwmiinstance.cpp:

Go to the source code of this file.

Functions

_Must_inspect_result_ __drv_sameIRQL __drv_maxIRQL (PASSIVE_LEVEL) NTSTATUS FxWmiInstanceExternal
 

Function Documentation

◆ __drv_maxIRQL()

Definition at line 362 of file fxwmiinstance.cpp.

369 {
371 
372  if (m_UseContextForQuery) {
373  //
374  // No matter what, we are reporting the length of the context. If the
375  // buffer is too small, it is used to report the desired buffer length.
376  // Otherwise, it is the amount of data we copied to the query buffer.
377  //
378  *BufferUsed = m_ContextLength;
379 
380  if (OutBufferSize < m_ContextLength) {
382 
384  GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGDEVICE,
385  "WDFWMIINSTANCE %p query instance using context for query, "
386  "query buffer length %d, context length %d, %!STATUS!",
387  GetHandle(), OutBufferSize, m_ContextLength, status);
388  }
389  else {
391 
393  &GetContextHeader()->Context[0],
394  m_ContextLength);
395  }
396  }
397  else if (m_QueryInstanceCallback.m_Method != NULL) {
398  BYTE dummy;
399 
400  if (OutBufferSize == 0) {
401  ASSERT(m_Provider->GetMinInstanceBufferSize() == 0);
402  OutBuffer = (PVOID) &dummy;
403  OutBufferSize = sizeof(dummy);
404  }
405 
406  status = m_QueryInstanceCallback.Invoke(
407  GetDevice()->GetHandle(),
408  GetHandle(),
410  OutBuffer,
411  BufferUsed
412  );
413 
414  if (status == STATUS_PENDING) {
416  GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
417  "WDFWMIINSTANCE %p was queried and returned %!STATUS!, which is "
418  "not an allowed return value", GetHandle(), status);
419 
420  FxVerifierDbgBreakPoint(GetDriverGlobals());
421 
423  *BufferUsed = 0;
424  }
425  else if (NT_SUCCESS(status)) {
426  if (*BufferUsed > OutBufferSize) {
427  //
428  // Caller error, they returned more bytes in *BufferUsed then
429  // was passed in via OutBufferSize, yet returned NT_SUCCESS
430  //
432  GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
433  "WDFWMIINSTANCE %p was queried with buffer size %d, "
434  " but returned %d bytes and %!STATUS!, should return "
435  "!NT_SUCCESS in this case",
437 
438  FxVerifierDbgBreakPoint(GetDriverGlobals());
439 
441  *BufferUsed = 0;
442  }
443  else if (OutBuffer == &dummy && *BufferUsed > 0) {
444  //
445  // Convert success back to an error where we can report the
446  // required size back to the caller.
447  //
449  }
450  }
451  else if (status == STATUS_BUFFER_TOO_SMALL) {
452  if (m_Provider->GetMinInstanceBufferSize()) {
454  GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
455  "WDFWMIINSTANCE %p returned %!STATUS!, but it specified "
456  "a minimum instance size %d in its WDFWMIPROVIDER %p",
457  GetHandle(), status, m_Provider->GetMinInstanceBufferSize(),
458  m_Provider->GetHandle());
460  GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
461  "This is a break in the contract. Minimum instance size "
462  "should only be used for fixed sized instances");
463 
464  FxVerifierDbgBreakPoint(GetDriverGlobals());
465  }
466  }
467  }
468  else {
469  ASSERT(m_ExecuteMethodCallback.m_Method != NULL);
470 
472  GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
473  "WDFWMIINSTANCE %p was queried with no query callback and supports "
474  "execute method (%p), zero bytes returned", GetHandle(),
475  m_ExecuteMethodCallback.m_Method);
476 
478  *BufferUsed = 0;
479  }
480 
481  return status;
482 }
_In_ ULONG _Out_ PULONG BufferUsed
Definition: wdfwmi.h:92
#define GetHandle(h)
Definition: treelist.c:116
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
void * PVOID
Definition: retypes.h:9
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
return pList GetDevice()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char BYTE
Definition: xxhash.c:193
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACINGPNP
Definition: dbgtrace.h:67
unsigned char dummy
Definition: maze.c:118
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97