ReactOS  0.4.15-dev-3187-ge372f2b
FxIrpQueue Class Reference

#include <fxirpqueue.hpp>

Collaboration diagram for FxIrpQueue:

Public Member Functions

 FxIrpQueue (VOID)
 
 ~FxIrpQueue (VOID)
 
VOID Initialize (__in FxNonPagedObject *LockObject, __in PFN_IRP_QUEUE_CANCEL Callback)
 
_Must_inspect_result_ NTSTATUS InsertTailRequest (__inout MdIrp Irp, __in_opt PMdIoCsqIrpContext CsqContext, __out_opt ULONG *pRequestCount)
 
_Must_inspect_result_ NTSTATUS InsertHeadRequest (__inout MdIrp Irp, __in_opt PMdIoCsqIrpContext CsqContext, __out_opt ULONG *pRequestCount)
 
MdIrp GetNextRequest (__out PMdIoCsqIrpContext *pCsqContext)
 
_Must_inspect_result_ NTSTATUS GetNextRequest (__in_opt PMdIoCsqIrpContext TagContext, __in_opt MdFileObject FileObject, __out FxRequest **ppOutRequest)
 
_Must_inspect_result_ NTSTATUS PeekRequest (__in_opt PMdIoCsqIrpContext TagContext, __in_opt MdFileObject FileObject, __out FxRequest **ppOutRequest)
 
MdIrp RemoveRequest (__in PMdIoCsqIrpContext Context)
 
BOOLEAN IsQueueEmpty ()
 
LONG GetRequestCount ()
 
BOOLEAN IsIrpInQueue (__in PMdIoCsqIrpContext Context)
 

Private Member Functions

_Must_inspect_result_ NTSTATUS InsertIrpInQueue (__inout MdIrp Irp, __in_opt PMdIoCsqIrpContext Context, __in BOOLEAN InsertInHead, __out_opt ULONG *pRequestCount)
 
 FX_DECLARE_VF_FUNCTION_P1 (VOID, VerifyRemoveIrpFromQueueByContext, __in PMdIoCsqIrpContext)
 
MdIrp RemoveIrpFromQueueByContext (__in PMdIoCsqIrpContext Context)
 
MdIrp RemoveNextIrpFromQueue (__in_opt PVOID PeekContext, __out_opt PMdIoCsqIrpContext *pCsqContext)
 
MdIrp PeekNextIrpFromQueue (__in_opt MdIrp Irp, __in_opt PVOID PeekContext)
 
VOID RemoveIrpFromListEntry (__inout FxIrp *Irp)
 
__inline void LockFromCancel (__out PKIRQL PreviousIrql)
 
__inline void UnlockFromCancel (__in KIRQL PreviousIrql)
 

Private Attributes

LIST_ENTRY m_Queue
 
FxNonPagedObjectm_LockObject
 
PFN_IRP_QUEUE_CANCEL m_CancelCallback
 
LONG m_RequestCount
 

Static Private Attributes

static MdCancelRoutineType _WdmCancelRoutineInternal
 

Friends

VOID GetTriageInfo (VOID)
 

Detailed Description

Definition at line 82 of file fxirpqueue.hpp.

Constructor & Destructor Documentation

◆ FxIrpQueue()

FxIrpQueue::FxIrpQueue ( VOID  )

Definition at line 42 of file fxirpqueue.cpp.

45 {
47 
49 
51 
52  m_RequestCount = 0;
53 }
FxNonPagedObject * m_LockObject
Definition: fxirpqueue.hpp:97
LONG m_RequestCount
Definition: fxirpqueue.hpp:107
PFN_IRP_QUEUE_CANCEL m_CancelCallback
Definition: fxirpqueue.hpp:102
LIST_ENTRY m_Queue
Definition: fxirpqueue.hpp:91
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112

◆ ~FxIrpQueue()

FxIrpQueue::~FxIrpQueue ( VOID  )

Definition at line 55 of file fxirpqueue.cpp.

56 {
58 }
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
LIST_ENTRY m_Queue
Definition: fxirpqueue.hpp:91
#define ASSERT(a)
Definition: mode.c:44

Member Function Documentation

◆ FX_DECLARE_VF_FUNCTION_P1()

FxIrpQueue::FX_DECLARE_VF_FUNCTION_P1 ( VOID  ,
VerifyRemoveIrpFromQueueByContext  ,
__in  PMdIoCsqIrpContext 
)
private

◆ GetNextRequest() [1/2]

MdIrp FxIrpQueue::GetNextRequest ( __out PMdIoCsqIrpContext pCsqContext)

Definition at line 219 of file fxirpqueue.cpp.

233 {
235 }
__in MdIrp __in PMdIoCsqIrpContext pCsqContext
Definition: fxirpqueue.hpp:74
MdIrp RemoveNextIrpFromQueue(__in_opt PVOID PeekContext, __out_opt PMdIoCsqIrpContext *pCsqContext)
Definition: fxirpqueue.cpp:787
#define NULL
Definition: types.h:112

Referenced by FxIoTarget::DrainPendedRequestsLocked(), and FxRequest::GetNextRequest().

◆ GetNextRequest() [2/2]

_Must_inspect_result_ NTSTATUS FxIrpQueue::GetNextRequest ( __in_opt PMdIoCsqIrpContext  TagContext,
__in_opt MdFileObject  FileObject,
__out FxRequest **  ppOutRequest 
)

Definition at line 240 of file fxirpqueue.cpp.

255 {
256  MdIrp Irp;
259 
260  if( TagContext == NULL ) {
261 
262  //
263  // Returns an IRP from the queue, and if successful
264  // the IRP is no longer on the CSQ (m_Queue) and
265  // is not non-cancellable.
266  //
268  FileObject, // PeekContext
269  &pCsqContext
270  );
271 
272  if( Irp != NULL ) {
273 
275 
276  *ppOutRequest = pRequest;
277 
278  return STATUS_SUCCESS;
279  }
280  else {
281  return STATUS_NO_MORE_ENTRIES;
282  }
283  }
284  else {
285 
286  // Handle TagRequest Case
288  TagContext
289  );
290 
291  if( Irp != NULL ) {
293 
294  *ppOutRequest = pRequest;
295 
296  return STATUS_SUCCESS;
297  }
298  else {
299  return STATUS_NOT_FOUND;
300  }
301  }
302 }
__in MdIrp __in PMdIoCsqIrpContext pCsqContext
Definition: fxirpqueue.hpp:74
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
FxRequest * pRequest
MdIrp RemoveNextIrpFromQueue(__in_opt PVOID PeekContext, __out_opt PMdIoCsqIrpContext *pCsqContext)
Definition: fxirpqueue.cpp:787
_In_ PIRP Irp
Definition: csq.h:116
IWudfIrp * MdIrp
Definition: mxum.h:103
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define STATUS_NOT_FOUND
Definition: shellext.h:72
static __inline FxRequest * RetrieveFromCsqContext(__in PMdIoCsqIrpContext pCsqContext)
Definition: fxrequest.hpp:1163
MdIrp RemoveIrpFromQueueByContext(__in PMdIoCsqIrpContext Context)
Definition: fxirpqueue.cpp:671
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ GetRequestCount()

◆ Initialize()

VOID FxIrpQueue::Initialize ( __in FxNonPagedObject LockObject,
__in PFN_IRP_QUEUE_CANCEL  Callback 
)

Definition at line 61 of file fxirpqueue.cpp.

105 {
106  ASSERT(LockObject != NULL);
107 
110 }
FxNonPagedObject * m_LockObject
Definition: fxirpqueue.hpp:97
PFN_IRP_QUEUE_CANCEL m_CancelCallback
Definition: fxirpqueue.hpp:102
#define ASSERT(a)
Definition: mode.c:44
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
#define NULL
Definition: types.h:112
#define LockObject(Object)
Definition: titypes.h:34

Referenced by FxIoTarget::Construct(), and FxIoQueue::FxIoQueue().

◆ InsertHeadRequest()

_Must_inspect_result_ NTSTATUS FxIrpQueue::InsertHeadRequest ( __inout MdIrp  Irp,
__in_opt PMdIoCsqIrpContext  CsqContext,
__out_opt ULONG pRequestCount 
)

Definition at line 168 of file fxirpqueue.cpp.

203 {
205 
206  // Note: This marks the IRP Pending
208  Irp, // Irp to insert
209  Context, // PIO_CSQ_IRP_CONTEXT
210  TRUE, // InsertInHead
211  pRequestCount
212  );
213 
214  return Status;
215 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ NTSTATUS InsertIrpInQueue(__inout MdIrp Irp, __in_opt PMdIoCsqIrpContext Context, __in BOOLEAN InsertInHead, __out_opt ULONG *pRequestCount)
Definition: fxirpqueue.cpp:505

Referenced by FxRequest::InsertHeadIrpQueue().

◆ InsertIrpInQueue()

_Must_inspect_result_ NTSTATUS FxIrpQueue::InsertIrpInQueue ( __inout MdIrp  Irp,
__in_opt PMdIoCsqIrpContext  Context,
__in BOOLEAN  InsertInHead,
__out_opt ULONG pRequestCount 
)
private

Definition at line 505 of file fxirpqueue.cpp.

539 {
540  FxIrp irp(Irp);
541  MdCancelRoutine cancelRoutine;
543 
544  //
545  // Set the association between the context and the IRP.
546  //
547 
548  if (Context) {
550  Context->Irp = Irp;
551  Context->Csq = (PIO_CSQ)this;
552 
553 
554 
555 
556 
557 
558 
559 
560 
561 
563  } else {
564 
565  //
566  // Currently always require context, but this will change when we
567  // allow queuing or low level IRP's without FxRequest headers allocated
568  //
569  ASSERT(FALSE);
570 
572  }
573 
574  // See if it's a head insertion
575  if( InsertInHead ) {
577  &m_Queue,
578  irp.ListEntry()
579  );
580  }
581  else {
583  &m_Queue,
584  irp.ListEntry()
585  );
586  }
587 
588  m_RequestCount++;
589 
590  if( pRequestCount != NULL ) {
591  *pRequestCount = m_RequestCount;
592  }
593 
595 
597 
598  ASSERT(!cancelRoutine);
599  UNREFERENCED_PARAMETER(cancelRoutine);
600 
601  if (irp.IsCanceled()) {
602 
603  cancelRoutine = irp.SetCancelRoutine(NULL);
604 
605  if (cancelRoutine) {
606 
607  // Remove the IRP from the list
609 
610  if (Context) {
611  Context->Irp = NULL;
612  }
613 
615 
616  //
617  // Caller does not want us to recurse on their lock by invoking
618  // the m_CancelCallback on the insert path. So they will complete
619  // the IRP themselves.
620  //
621  return STATUS_CANCELLED;
622  } else {
623 
624  //
625  // The cancel routine beat us to it.
626  //
627  DO_NOTHING();
628  }
629 
630  }
631 
632  return status;
633 }
PLIST_ENTRY ListEntry()
Definition: fxirpum.cpp:535
LONG m_RequestCount
Definition: fxirpqueue.hpp:107
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
VOID SetContext(__in ULONG Index, __in PVOID Value)
Definition: fxirpum.cpp:351
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
#define InsertTailList(ListHead, Entry)
#define FX_IRP_QUEUE_CSQ_CONTEXT_ENTRY
Definition: fxirpqueue.hpp:47
LIST_ENTRY m_Queue
Definition: fxirpqueue.hpp:91
VOID RemoveIrpFromListEntry(__inout FxIrp *Irp)
Definition: fxirpqueue.hpp:257
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
struct _IO_CSQ * PIO_CSQ
Definition: csq.h:69
WUDF_DRIVER_CANCEL * MdCancelRoutine
Definition: mxum.h:143
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
BOOLEAN IsCanceled()
Definition: fxirpum.cpp:484
VOID MarkIrpPending()
Definition: fxirpum.cpp:415
static MdCancelRoutineType _WdmCancelRoutineInternal
Definition: fxirpqueue.hpp:273
#define FX_IRP_QUEUE_ENTRY_IDENTIFIER
Definition: fxirpqueue.hpp:52
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
MdCancelRoutine SetCancelRoutine(__in_opt MdCancelRoutine CancelRoutine)
Definition: fxirpum.cpp:124
FxIrp * irp
#define DO_NOTHING()
Definition: mxgeneral.h:32
Definition: ps.c:97

Referenced by InsertHeadRequest(), and InsertTailRequest().

◆ InsertTailRequest()

_Must_inspect_result_ NTSTATUS FxIrpQueue::InsertTailRequest ( __inout MdIrp  Irp,
__in_opt PMdIoCsqIrpContext  CsqContext,
__out_opt ULONG pRequestCount 
)

Definition at line 115 of file fxirpqueue.cpp.

151 {
153 
154  // Note: This marks the IRP Pending
156  Irp, // Irp to insert
157  Context, // PIO_CSQ_IRP_CONTEXT
158  FALSE, // InsertInHead
159  pRequestCount
160  );
161 
162  return Status;
163 }
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ NTSTATUS InsertIrpInQueue(__inout MdIrp Irp, __in_opt PMdIoCsqIrpContext Context, __in BOOLEAN InsertInHead, __out_opt ULONG *pRequestCount)
Definition: fxirpqueue.cpp:505

Referenced by FxRequest::InsertTailIrpQueue(), and FxIoTarget::PendRequestLocked().

◆ IsIrpInQueue()

BOOLEAN FxIrpQueue::IsIrpInQueue ( __in PMdIoCsqIrpContext  Context)

Definition at line 931 of file fxirpqueue.cpp.

941 {
942  PLIST_ENTRY nextEntry;
943  FxIrp nextIrp(NULL);
945 
946  nextEntry = m_Queue.Flink;
947 
948  while( nextEntry != &m_Queue ) {
949  nextIrp.SetIrp(FxIrp::GetIrpFromListEntry(nextEntry));
950 
952 
953  if( pCsqContext == Context ) {
954  ASSERT(Context->Irp == nextIrp.GetIrp());
955  return TRUE;
956  }
957 
958  nextEntry = nextEntry->Flink;
959  }
960 
961  return FALSE;
962 }
__in MdIrp __in PMdIoCsqIrpContext pCsqContext
Definition: fxirpqueue.hpp:74
static MdIrp GetIrpFromListEntry(__in PLIST_ENTRY Ple)
Definition: fxirpum.cpp:1190
#define TRUE
Definition: types.h:120
Definition: fxirp.hpp:28
#define FX_IRP_QUEUE_CSQ_CONTEXT_ENTRY
Definition: fxirpqueue.hpp:47
IO_CSQ_IRP_CONTEXT * PMdIoCsqIrpContext
LIST_ENTRY m_Queue
Definition: fxirpqueue.hpp:91
#define FALSE
Definition: types.h:117
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:44
Definition: typedefs.h:119
#define NULL
Definition: types.h:112

◆ IsQueueEmpty()

BOOLEAN FxIrpQueue::IsQueueEmpty ( )
inline

Definition at line 173 of file fxirpqueue.hpp.

173  {
174 
175  if( IsListEmpty(&m_Queue) ) {
176 
177  ASSERT(m_RequestCount == 0);
178 
179  return TRUE;
180  }
181  else {
182  ASSERT(m_RequestCount != 0);
183 
184  return FALSE;
185  }
186  }
LONG m_RequestCount
Definition: fxirpqueue.hpp:107
#define TRUE
Definition: types.h:120
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
LIST_ENTRY m_Queue
Definition: fxirpqueue.hpp:91
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44

◆ LockFromCancel()

__inline void FxIrpQueue::LockFromCancel ( __out PKIRQL  PreviousIrql)
inlineprivate

Definition at line 280 of file fxirpqueue.hpp.

283  {
284  m_LockObject->Lock(PreviousIrql);
285  }
FxNonPagedObject * m_LockObject
Definition: fxirpqueue.hpp:97

◆ PeekNextIrpFromQueue()

MdIrp FxIrpQueue::PeekNextIrpFromQueue ( __in_opt MdIrp  Irp,
__in_opt PVOID  PeekContext 
)
private

Definition at line 724 of file fxirpqueue.cpp.

741 {
742  PLIST_ENTRY nextEntry;
743  PLIST_ENTRY listHead;
744  FxIrp irp(Irp);
745  FxIrp nextIrp(NULL);
746 
747  listHead = &m_Queue;
748 
749  //
750  // If the IRP is NULL, we will start peeking from the listhead, else
751  // we will start from that IRP onwards. This is done under the
752  // assumption that new IRPs are always inserted at the tail.
753  //
754 
755  if(Irp == NULL) {
756  nextEntry = listHead->Flink;
757  } else {
758  nextEntry = irp.ListEntry()->Flink;
759  }
760 
761  while(nextEntry != listHead) {
762 
763  nextIrp.SetIrp(FxIrp::GetIrpFromListEntry(nextEntry));
764 
765  //
766  // If PeekContext is supplied, it's a search for an IRP associated
767  // with a particular file object.
768  //
769  if(PeekContext) {
770 
771  if(nextIrp.GetFileObject() == (MdFileObject) PeekContext) {
772  break;
773  }
774  } else {
775  break;
776  }
777 
778  nextIrp.SetIrp(NULL);
779 
780  nextEntry = nextEntry->Flink;
781  }
782 
783  return nextIrp.GetIrp();
784 }
PLIST_ENTRY ListEntry()
Definition: fxirpum.cpp:535
static MdIrp GetIrpFromListEntry(__in PLIST_ENTRY Ple)
Definition: fxirpum.cpp:1190
Definition: fxirp.hpp:28
PFILE_OBJECT MdFileObject
Definition: mxgeneralkm.h:32
LIST_ENTRY m_Queue
Definition: fxirpqueue.hpp:91
_In_ PIRP Irp
Definition: csq.h:116
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:159
FxIrp * irp

Referenced by RemoveNextIrpFromQueue().

◆ PeekRequest()

_Must_inspect_result_ NTSTATUS FxIrpQueue::PeekRequest ( __in_opt PMdIoCsqIrpContext  TagContext,
__in_opt MdFileObject  FileObject,
__out FxRequest **  ppOutRequest 
)

Definition at line 306 of file fxirpqueue.cpp.

399 {
400  PLIST_ENTRY nextEntry;
401  FxIrp nextIrp(NULL);
403  BOOLEAN FoundTag = (TagContext == NULL) ? TRUE : FALSE;
405 
406  for( nextEntry = m_Queue.Flink; nextEntry != &this->m_Queue; nextEntry = nextEntry->Flink) {
407 
408  nextIrp.SetIrp(FxIrp::GetIrpFromListEntry(nextEntry));
409 
410  if(nextIrp.IsCanceled()) {
411  //
412  // This IRP is cancelled and the WdmCancelRoutine is about to run or waiting
413  // for us to drop the lock. So skip this one.
414  //
415  continue;
416  }
417 
419 
420  if( FoundTag ) {
421 
422  if( FileObject != NULL ) {
423 
424  if(nextIrp.GetFileObject() == FileObject ) {
425 
427 
428  //
429  // Must add the reference here under the protection
430  // of the cancel safe queues spinlock
431  //
432  pRequest->ADDREF(NULL);
433 
434  *ppOutRequest = pRequest;
435 
436  return STATUS_SUCCESS;
437  }
438  }
439  else {
440 
442 
443  //
444  // Must add the reference here under the protection
445  // of the cancel safe queues spinlock
446  //
447  pRequest->ADDREF(NULL);
448 
449  *ppOutRequest = pRequest;
450 
451  return STATUS_SUCCESS;
452  }
453  }
454  else {
455 
456  // If we found the tag, we want the *next* entry
457  if( pCsqContext == TagContext ) {
458  FoundTag = TRUE;
459  }
460  }
461 
462  }
463 
464  //
465  // If the caller supplied a tag, and it was
466  // not found, return a different code since
467  // the caller needs to re-scan the queue.
468  //
469  if( (TagContext != NULL) && !FoundTag ) {
470  return STATUS_NOT_FOUND;
471  }
472  else {
473  return STATUS_NO_MORE_ENTRIES;
474  }
475 }
__in MdIrp __in PMdIoCsqIrpContext pCsqContext
Definition: fxirpqueue.hpp:74
static MdIrp GetIrpFromListEntry(__in PLIST_ENTRY Ple)
Definition: fxirpum.cpp:1190
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define TRUE
Definition: types.h:120
FxRequest * pRequest
Definition: fxirp.hpp:28
#define FX_IRP_QUEUE_CSQ_CONTEXT_ENTRY
Definition: fxirpqueue.hpp:47
IO_CSQ_IRP_CONTEXT * PMdIoCsqIrpContext
LIST_ENTRY m_Queue
Definition: fxirpqueue.hpp:91
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define STATUS_NOT_FOUND
Definition: shellext.h:72
static __inline FxRequest * RetrieveFromCsqContext(__in PMdIoCsqIrpContext pCsqContext)
Definition: fxrequest.hpp:1163
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by FxRequest::PeekRequest().

◆ RemoveIrpFromListEntry()

VOID FxIrpQueue::RemoveIrpFromListEntry ( __inout FxIrp Irp)
inlineprivate

Definition at line 257 of file fxirpqueue.hpp.

260  {
261  PLIST_ENTRY entry = Irp->ListEntry();
264  m_RequestCount--;
265  ASSERT(m_RequestCount >= 0);
266  }
LONG m_RequestCount
Definition: fxirpqueue.hpp:107
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
_In_ PIRP Irp
Definition: csq.h:116
#define ASSERT(a)
Definition: mode.c:44
uint32_t entry
Definition: isohybrid.c:63
Definition: typedefs.h:119
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944

Referenced by InsertIrpInQueue(), RemoveIrpFromQueueByContext(), and RemoveNextIrpFromQueue().

◆ RemoveIrpFromQueueByContext()

MdIrp FxIrpQueue::RemoveIrpFromQueueByContext ( __in PMdIoCsqIrpContext  Context)
private

Definition at line 671 of file fxirpqueue.cpp.

681 {
682  MdIrp irp;
683  MdCancelRoutine cancelRoutine;
684 
685  if (Context->Irp ) {
686  //
687  // Make sure the Irp belongs to this queue.
688  //
689  ASSERT(Context->Csq == (PIO_CSQ)this);
690  VerifyRemoveIrpFromQueueByContext(m_LockObject->GetDriverGlobals(),
691  Context);
692 
693  irp = Context->Irp;
694 
695  FxIrp fxIrp(irp);
696 
697  cancelRoutine = fxIrp.SetCancelRoutine(NULL);
698  if (!cancelRoutine) {
699  return NULL;
700  }
701 
703 
705 
706  //
707  // Break the association.
708  //
709 
710  Context->Irp = NULL;
712 
713  ASSERT(Context->Csq == (PIO_CSQ)this);
714 
715  return irp;
716 
717  } else {
718  return NULL;
719  }
720 }
FxNonPagedObject * m_LockObject
Definition: fxirpqueue.hpp:97
PVOID GetContext(__in ULONG Index)
Definition: fxirpum.cpp:361
VOID SetContext(__in ULONG Index, __in PVOID Value)
Definition: fxirpum.cpp:351
Definition: fxirp.hpp:28
#define FX_IRP_QUEUE_CSQ_CONTEXT_ENTRY
Definition: fxirpqueue.hpp:47
VOID RemoveIrpFromListEntry(__inout FxIrp *Irp)
Definition: fxirpqueue.hpp:257
IWudfIrp * MdIrp
Definition: mxum.h:103
WUDF_DRIVER_CANCEL * MdCancelRoutine
Definition: mxum.h:143
#define ASSERT(a)
Definition: mode.c:44
Definition: csq.h:222
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
FxIrp fxIrp(Irp)
#define NULL
Definition: types.h:112
VOID __in PMdIoCsqIrpContext Context
Definition: fxirpqueue.cpp:647
MdCancelRoutine SetCancelRoutine(__in_opt MdCancelRoutine CancelRoutine)
Definition: fxirpum.cpp:124
FxIrp * irp

Referenced by GetNextRequest(), and RemoveRequest().

◆ RemoveNextIrpFromQueue()

MdIrp FxIrpQueue::RemoveNextIrpFromQueue ( __in_opt PVOID  PeekContext,
__out_opt PMdIoCsqIrpContext pCsqContext 
)
private

Definition at line 787 of file fxirpqueue.cpp.

800 {
802  MdCancelRoutine cancelRoutine;
803  FxIrp fxIrp(NULL);
804 
806 
807  for (;;) {
808 
809  if (!fxIrp.GetIrp()) {
810  return NULL;
811  }
812 
813  cancelRoutine = fxIrp.SetCancelRoutine(NULL);
814  if (!cancelRoutine) {
816  continue;
817  }
818 
819  RemoveIrpFromListEntry(&fxIrp); // Remove this IRP from the queue
820 
821  break;
822  }
823 
825  if (context->Type == FX_IRP_QUEUE_ENTRY_IDENTIFIER) {
826  context->Irp = NULL;
827  ASSERT(context->Csq == (PIO_CSQ)this);
828  }
829 
830  if(pCsqContext != NULL) {
831  *pCsqContext = context;
832  }
833 
835 
836  return fxIrp.GetIrp();
837 }
PVOID GetContext(__in ULONG Index)
Definition: fxirpum.cpp:361
__in MdIrp __in PMdIoCsqIrpContext pCsqContext
Definition: fxirpqueue.hpp:74
Definition: http.c:7251
VOID SetContext(__in ULONG Index, __in PVOID Value)
Definition: fxirpum.cpp:351
Definition: fxirp.hpp:28
#define FX_IRP_QUEUE_CSQ_CONTEXT_ENTRY
Definition: fxirpqueue.hpp:47
IO_CSQ_IRP_CONTEXT * PMdIoCsqIrpContext
VOID RemoveIrpFromListEntry(__inout FxIrp *Irp)
Definition: fxirpqueue.hpp:257
WUDF_DRIVER_CANCEL * MdCancelRoutine
Definition: mxum.h:143
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ PVOID _In_ ULONG _In_ PVOID context
Definition: wdfdriver.h:113
MdIrp PeekNextIrpFromQueue(__in_opt MdIrp Irp, __in_opt PVOID PeekContext)
Definition: fxirpqueue.cpp:724
#define FX_IRP_QUEUE_ENTRY_IDENTIFIER
Definition: fxirpqueue.hpp:52
Definition: csq.h:222
MdIrp GetIrp(VOID)
Definition: fxirpum.cpp:15
FxIrp fxIrp(Irp)
#define NULL
Definition: types.h:112
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:159
MdIrp SetIrp(MdIrp irp)
Definition: fxirpkm.hpp:71
MdCancelRoutine SetCancelRoutine(__in_opt MdCancelRoutine CancelRoutine)
Definition: fxirpum.cpp:124

Referenced by GetNextRequest().

◆ RemoveRequest()

MdIrp FxIrpQueue::RemoveRequest ( __in PMdIoCsqIrpContext  Context)

Definition at line 478 of file fxirpqueue.cpp.

488 {
489  MdIrp Irp;
490 
491  ASSERT(Context != NULL);
492 
493  //
494  // Returns an IRP from the queue, and if success
495  // the IRP is no longer on the CSQ (m_Queue) and
496  // is not non-cancellable.
497  //
499 
500  return Irp;
501 }
_In_ PIRP Irp
Definition: csq.h:116
IWudfIrp * MdIrp
Definition: mxum.h:103
#define ASSERT(a)
Definition: mode.c:44
MdIrp RemoveIrpFromQueueByContext(__in PMdIoCsqIrpContext Context)
Definition: fxirpqueue.cpp:671
#define NULL
Definition: types.h:112

Referenced by FxRequest::RemoveFromIrpQueue().

◆ UnlockFromCancel()

__inline void FxIrpQueue::UnlockFromCancel ( __in KIRQL  PreviousIrql)
inlineprivate

Definition at line 289 of file fxirpqueue.hpp.

292  {
293  m_LockObject->Unlock(PreviousIrql);
294  }
FxNonPagedObject * m_LockObject
Definition: fxirpqueue.hpp:97

Friends And Related Function Documentation

◆ GetTriageInfo

VOID GetTriageInfo ( VOID  )
friend

Definition at line 75 of file fxlibrarycommon.cpp.

78 {
79  // Object
80  _WdfObjectTriageInfo.RawObjectSize = sizeof(FxObject);
81  _WdfObjectTriageInfo.ObjectType = FIELD_OFFSET(FxObject, m_Type);
82  _WdfObjectTriageInfo.TotalObjectSize = FIELD_OFFSET(FxObject, m_ObjectSize);
83  _WdfObjectTriageInfo.ChildListHead = FIELD_OFFSET(FxObject, m_ChildListHead);
84  _WdfObjectTriageInfo.ChildEntry = FIELD_OFFSET(FxObject, m_ChildEntry);
85  _WdfObjectTriageInfo.Globals = FIELD_OFFSET(FxObject, m_Globals);
86  _WdfObjectTriageInfo.ParentObject = FIELD_OFFSET(FxObject, m_ParentObject);
87 
88  // Context Triage Info
89  _WdfContextTriageInfo.HeaderSize = sizeof(FxContextHeader);
90  _WdfContextTriageInfo.NextHeader = FIELD_OFFSET(FxContextHeader, NextHeader);
92  _WdfContextTriageInfo.TypeInfoPtr = FIELD_OFFSET(FxContextHeader, ContextTypeInfo);
94 
95  // Context type Triage info
99 
100  // WdfRequest Queue
101  _WdfQueueTriageInfo.QueueSize = sizeof(FxIoQueue);
103  _WdfQueueTriageInfo.IrpQueue2 = FIELD_OFFSET(FxIoQueue, m_DriverCancelable);
104  _WdfQueueTriageInfo.RequestList1 = FIELD_OFFSET(FxIoQueue, m_Cancelled);
105  _WdfQueueTriageInfo.RequestList2 = FIELD_OFFSET(FxIoQueue, m_CanceledOnQueueList);
106  _WdfQueueTriageInfo.FwdProgressContext = FIELD_OFFSET(FxIoQueue, m_FwdProgContext);
107  _WdfQueueTriageInfo.PkgIo = FIELD_OFFSET(FxIoQueue, m_PkgIo);
108 
109  // Forward Progress
110  _WdfFwdProgressTriageInfo.ReservedRequestList =
111  FIELD_OFFSET(FXIO_FORWARD_PROGRESS_CONTEXT, m_ReservedRequestList);
112  _WdfFwdProgressTriageInfo.ReservedRequestInUseList =
113  FIELD_OFFSET(FXIO_FORWARD_PROGRESS_CONTEXT, m_ReservedRequestInUseList);
114  _WdfFwdProgressTriageInfo.PendedIrpList =
116 
117  // Irp Queue
118  _WdfIrpQueueTriageInfo.IrpQueueSize = sizeof(FxIrpQueue);
120  _WdfIrpQueueTriageInfo.IrpListEntry = FIELD_OFFSET(IRP, Tail.Overlay.ListEntry);
122  Tail.Overlay.DriverContext[FX_IRP_QUEUE_CSQ_CONTEXT_ENTRY]);
123 
124  // WdfRequest
125  _WdfRequestTriageInfo.RequestSize = sizeof(FxRequest);
126  _WdfRequestTriageInfo.CsqContext = FIELD_OFFSET(FxRequest, m_CsqContext);
128  _WdfRequestTriageInfo.ListEntryQueueOwned =
129  FIELD_OFFSET(FxRequest, m_OwnerListEntry);
130  _WdfRequestTriageInfo.ListEntryQueueOwned2 =
131  FIELD_OFFSET(FxRequest, m_OwnerListEntry2);
132  _WdfRequestTriageInfo.RequestListEntry =
133  FIELD_OFFSET(FxRequest, m_ListEntry);
134  _WdfRequestTriageInfo.FwdProgressList =
135  FIELD_OFFSET(FxRequest, m_ForwardProgressList);
136 
137  // WdfDevice
138  _WdfDeviceTriageInfo.DeviceInitSize = sizeof(WDFDEVICE_INIT);
139  _WdfDeviceTriageInfo.DeviceDriver = FIELD_OFFSET(FxDevice, m_Driver);
140 
141  // FxIrp
142  _WdfIrpTriageInfo.FxIrpSize = sizeof(FxIrp);
143  _WdfIrpTriageInfo.IrpPtr = FIELD_OFFSET(FxIrp, m_Irp);
144 }
Definition: fxirp.hpp:28
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T ContextSize
Definition: fltkernel.h:1443
#define FX_IRP_QUEUE_CSQ_CONTEXT_ENTRY
Definition: fxirpqueue.hpp:47
static WDFREQUEST_TRIAGE_INFO _WdfRequestTriageInfo
LIST_ENTRY m_Queue
Definition: fxirpqueue.hpp:91
static WDFFWDPROGRESS_TRIAGE_INFO _WdfFwdProgressTriageInfo
struct _WDF_OBJECT_CONTEXT_TYPE_INFO WDF_OBJECT_CONTEXT_TYPE_INFO
static WDFCONTEXT_TRIAGE_INFO _WdfContextTriageInfo
static WDFDEVICE_TRIAGE_INFO _WdfDeviceTriageInfo
static WDFOBJECT_TRIAGE_INFO _WdfObjectTriageInfo
static WDFIRP_TRIAGE_INFO _WdfIrpTriageInfo
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
static WDFIRPQUEUE_TRIAGE_INFO _WdfIrpQueueTriageInfo
FxIrpQueue(VOID)
Definition: fxirpqueue.cpp:42
static WDFCONTEXTTYPE_TRIAGE_INFO _WdfContextTypeTriageInfo
static WDFQUEUE_TRIAGE_INFO _WdfQueueTriageInfo

Member Data Documentation

◆ _WdmCancelRoutineInternal

VOID FxIrpQueue::_WdmCancelRoutineInternal
staticprivate

Definition at line 273 of file fxirpqueue.hpp.

Referenced by InsertIrpInQueue().

◆ m_CancelCallback

PFN_IRP_QUEUE_CANCEL FxIrpQueue::m_CancelCallback
private

Definition at line 102 of file fxirpqueue.hpp.

Referenced by FxIrpQueue(), and Initialize().

◆ m_LockObject

FxNonPagedObject* FxIrpQueue::m_LockObject
private

◆ m_Queue

LIST_ENTRY FxIrpQueue::m_Queue
private

◆ m_RequestCount

LONG FxIrpQueue::m_RequestCount
private

The documentation for this class was generated from the following files: