ReactOS 0.4.15-dev-6057-gd708c79
FxRequest Class Reference

#include <fxrequest.hpp>

Inheritance diagram for FxRequest:
Collaboration diagram for FxRequest:

Public Member Functions

__inline PLIST_ENTRY GetListEntry (__in FxListEntryNames Index)
 
__inline VOID CopyCurrentIrpStackLocationToNext (VOID)
 
_Must_inspect_result_ NTSTATUS Reuse (__in PWDF_REQUEST_REUSE_PARAMS ReuseParams)
 
__inline BOOLEAN IsCancelled (VOID)
 
__inline VOID CopyCompletionParams (__in PWDF_REQUEST_COMPLETION_PARAMS Params)
 
VOID __inline SetPresented (VOID)
 
VOID AddIrpReference (VOID)
 
VOID ReleaseIrpReference (VOID)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
__inline CfxDeviceGetDevice (VOID)
 
__inline BOOLEAN IsReserved ()
 
__inline VOID SetReserved ()
 
__inline VOID SetForwardProgressQueue (__in FxIoQueue *Queue)
 
_Must_inspect_result_ FxIoQueueGetCurrentQueue (VOID)
 
FxRequestCompletionState SetCompletionState (__in FxRequestCompletionState NewState)
 
VOID __inline SetStatus (__in NTSTATUS Status)
 
NTSTATUS SetInformation (__in ULONG_PTR Information)
 
ULONG_PTR GetInformation (VOID)
 
KPROCESSOR_MODE GetRequestorMode (VOID)
 
__inline NTSTATUS Complete (__in NTSTATUS Status)
 
__inline NTSTATUS CompleteWithInformation (__in NTSTATUS Status, __in ULONG_PTR Information)
 
__inline NTSTATUS CompleteWithPriority (__in NTSTATUS Status, __in CCHAR PriorityBoost)
 
 FX_DECLARE_VF_FUNCTION (VOID, VerifyPreProcessSendAndForget)
 
VOID PreProcessSendAndForget (VOID)
 
VOID PostProcessSendAndForget (VOID)
 
NTSTATUS GetStatus (VOID)
 
_Must_inspect_result_ NTSTATUS GetParameters (__out PWDF_REQUEST_PARAMETERS Parameters)
 
_Must_inspect_result_ NTSTATUS GetMemoryObject (__deref_out IFxMemory **Memory, __out PVOID *Buffer, __out size_t *Length)
 
_Must_inspect_result_ NTSTATUS GetMdl (__out PMDL *pMdl)
 
_Must_inspect_result_ NTSTATUS GetDeviceControlOutputMemoryObject (__deref_out IFxMemory **MemoryObject, __out PVOID *Buffer, __out size_t *Length)
 
_Must_inspect_result_ NTSTATUS GetDeviceControlOutputMdl (__out PMDL *pMdl)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyProbeAndLock)
 
_Must_inspect_result_ NTSTATUS ProbeAndLockForRead (__in PVOID Buffer, __in ULONG Length, __deref_out FxRequestMemory **pMemoryObject)
 
_Must_inspect_result_ NTSTATUS ProbeAndLockForWrite (__in PVOID Buffer, __in ULONG Length, __deref_out FxRequestMemory **pMemoryObject)
 
_Must_inspect_result_ NTSTATUS Impersonate (_In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, _In_ PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate, _In_opt_ PVOID Context)
 
VOID SetImpersonationFlags (_In_ ULONG Flags)
 
FxIrpGetFxIrp (VOID)
 
__inline FxIoQueueGetIoQueue (VOID)
 
_Must_inspect_result_ NTSTATUS GetIrp (__deref_out MdIrp *ppIrp)
 
_Must_inspect_result_ NTSTATUS GetFileObject (__deref_out_opt FxFileObject **pFileObject)
 
PIO_STACK_LOCATION GetCurrentIrpStackLocation (VOID)
 
 FX_DECLARE_VF_FUNCTION_P1 (NTSTATUS, VerifyInsertIrpQueue, _In_ FxIrpQueue *)
 
_Must_inspect_result_ NTSTATUS InsertTailIrpQueue (__in FxIrpQueue *IrpQueue, __out_opt ULONG *pRequestCount)
 
_Must_inspect_result_ NTSTATUS InsertHeadIrpQueue (__in FxIrpQueue *IrpQueue, __out_opt ULONG *pRequestCount)
 
_Must_inspect_result_ NTSTATUS RemoveFromIrpQueue (__in FxIrpQueue *IrpQueue)
 
__inline VOID MarkRemovedFromIrpQueue (VOID)
 
__inline PMdIoCsqIrpContext GetCsqContext (VOID)
 
__inline BOOLEAN IsInIrpQueue (__in FxIrpQueue *pIrpQueue)
 
 FX_DECLARE_VF_FUNCTION_P1 (NTSTATUS, VerifyStopAcknowledge, _In_ BOOLEAN)
 
VOID StopAcknowledge (__in BOOLEAN Requeue)
 
__inline BOOLEAN IsPowerStopAcknowledged (VOID)
 
__inline BOOLEAN IsPowerStopAcknowledgedWithRequeue (VOID)
 
VOID ClearPowerStopState (VOID)
 
 FX_DECLARE_VF_FUNCTION (VOID, VerifierBreakpoint_RequestEarlyDisposeDeferred)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsDriverOwned)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsCancelable)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsNotCancelable)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsInCallerContext)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsInEvtIoStopContext)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsNotCompleted)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsTagRequest)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsAllocatedFromIo)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestIsCurrentStackValid)
 
 FX_DECLARE_VF_FUNCTION (NTSTATUS, VerifyRequestCanBeCompleted)
 
VOID FreeRequest (VOID)
 
__inline VOID ClearFieldsForReuse (VOID)
 
virtual ULONG Release (__in PVOID Tag, __in LONG Line, __in_opt PSTR File)
 
__inline BOOLEAN IsRequestForwardedToParent (VOID)
 
__inline VOID SetInternalContext (PVOID Context)
 
__inline PVOID GetInternalContext (VOID)
 
- Public Member Functions inherited from FxRequestBase
__inline VOID SetCompletionRoutine (__in_opt PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine=NULL, __in_opt WDFCONTEXT CompletionContext=NULL)
 
PFN_WDF_REQUEST_COMPLETION_ROUTINE ClearCompletionRoutine (VOID)
 
WDFCONTEXT ClearCompletionContext (VOID)
 
__inline BOOLEAN IsCompletionRoutineSet (VOID)
 
__inline BOOLEAN IsCancelRoutineSet (VOID)
 
__inline FxRequestContextGetContext (VOID)
 
__inline VOID SetContext (__in FxRequestContext *RequestContext=NULL)
 
VOID ContextReleaseAndRestore (VOID)
 
__inline VOID EnableContextDisposeNotification (VOID)
 
__inline BOOLEAN HasContextType (__in FX_REQUEST_CONTEXT_TYPE Type)
 
__inline BOOLEAN HasContext (VOID)
 
__inline MdIrp GetSubmitIrp (VOID)
 
__inline FxIrpGetSubmitFxIrp (VOID)
 
MdIrp SetSubmitIrp (__in_opt MdIrp NewIrp, __in BOOLEAN FreeIrp=TRUE)
 
__inline BOOLEAN CanComplete (VOID)
 
VOID CompleteSubmitted (VOID)
 
_Must_inspect_result_ NTSTATUS ValidateTarget (__in FxIoTarget *Target)
 
__inline FxIoTargetGetTarget (VOID)
 
VOID __inline SetTarget (__in FxIoTarget *Target)
 
__inline UCHAR GetTargetFlags (VOID)
 
__inline VOID SetTargetFlags (__in UCHAR Flags)
 
__inline ULONG ClearTargetFlags (__in UCHAR Flags)
 
__inline VOID SetRequestBaseFlags (__in UCHAR Flags)
 
SHORT GetVerifierFlagsLocked (VOID)
 
__inline SHORT GetVerifierFlags (VOID)
 
__inline VOID SetVerifierFlagsLocked (__in SHORT Flags)
 
__inline VOID SetVerifierFlags (__in SHORT Flags)
 
__inline VOID ClearVerifierFlagsLocked (__in SHORT Flags)
 
__inline VOID ClearVerifierFlags (__in SHORT Flags)
 
__inline VOID VerifierSetFormatted (VOID)
 
__inline VOID VerifierClearFormatted (VOID)
 
__inline BOOLEAN VerifierIsFormatted (VOID)
 
__inline BOOLEAN ShouldClearContext (VOID)
 
_Must_inspect_result_ NTSTATUS CreateTimer (VOID)
 
VOID StartTimer (__in LONGLONG Timeout)
 
_Must_inspect_result_ BOOLEAN CancelTimer (VOID)
 
BOOLEAN Cancel (VOID)
 
BOOLEAN __inline IsAllocatedFromIo (VOID)
 
BOOLEAN __inline IsAllocatedDriver (VOID)
 
BOOLEAN __inline IsCanComplete (VOID)
 
__inline VOID SetCompleted (__in BOOLEAN Value)
 
VOID __inline SetPriorityBoost (CCHAR PriorityBoost)
 
CCHAR __inline GetPriorityBoost (VOID)
 
__inline WDFREQUEST GetHandle (VOID)
 
__inline PVOID GetTraceObjectHandle (VOID)
 
VOID FreeMdls (VOID)
 
DECLSPEC_NORETURN VOID FatalError (__in NTSTATUS Status)
 
VOID ClearFieldsForReuse (VOID)
 
- Public Member Functions inherited from FxNonPagedObject
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
virtual ~FxNonPagedObject (VOID)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
 
 _Releases_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID Unlock(__in __drv_restoresIRQL KIRQL PreviousIrql)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
 
 _Requires_lock_held_ (this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
 
- Public Member Functions inherited from FxObject
PVOID GetCOMWrapper ()
 
void SetCOMWrapper (__drv_aliasesMem PVOID Wrapper)
 
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual ~FxObject (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType Type)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize=0)
 
VOID operator delete (__in PVOID Memory)
 
VOID SetNoContextHeader (VOID)
 
PVOID __inline GetObjectHandle (VOID)
 
__inline FxContextHeaderGetContextHeader (VOID)
 
__inline PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
WDFTYPE GetType (VOID)
 
USHORT GetObjectSize (VOID)
 
LONG GetRefCnt (VOID)
 
FxTagTrackerGetTagTracker (VOID)
 
CfxDeviceGetDevice (VOID)
 
CfxDeviceBaseGetDeviceBase (VOID)
 
VOID SetDeviceBase (__in CfxDeviceBase *DeviceBase)
 
__inline VOID CallCleanup (VOID)
 
ULONG __inline AddRef (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG Release (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
VOID MarkTraceState (VOID)
 
BOOLEAN __inline IsTraceState (VOID)
 
VOID __inline TraceDroppedEvent (__in FxObjectDroppedEvent Event)
 
VOID MarkPassiveDispose (__in FxObjectLockState State=ObjectLock)
 
VOID MarkPassiveCallbacks (__in FxObjectLockState State=ObjectLock)
 
VOID MarkForceDisposeThread (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsPassiveCallbacks (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsPassiveDispose (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsForceDisposeThread (__in BOOLEAN AcquireLock=TRUE)
 
VOID MarkCommitted (VOID)
 
BOOLEAN IsCommitted (VOID)
 
VOID MarkDisposeOverride (__in FxObjectLockState State=ObjectLock)
 
VOID MarkNoDeleteDDI (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsNoDeleteDDI (VOID)
 
_Must_inspect_result_ NTSTATUS Commit (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
 
VOID DeleteFromFailedCreate (VOID)
 
VOID ClearEvtCallbacks (VOID)
 
BOOLEAN EarlyDispose (VOID)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 

Static Public Member Functions

static FxRequest_FromOwnerListEntry (__in FxListEntryNames Index, __in PLIST_ENTRY OwnerListEntry)
 
static _Must_inspect_result_ NTSTATUS _CreateForPackage (__in CfxDevice *Device, __in PWDF_OBJECT_ATTRIBUTES RequestAttributes, __in MdIrp Irp, __deref_out FxRequest **Request)
 
static _Must_inspect_result_ NTSTATUS _Create (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES RequestAttributes, __in_opt MdIrp Irp, __in_opt FxIoTarget *Target, __in FxRequestIrpOwnership Ownership, __in FxRequestConstructorCaller Caller, __deref_out FxRequest **Request)
 
static _Must_inspect_result_ FxRequestGetNextRequest (__in FxIrpQueue *IrpQueue)
 
static _Must_inspect_result_ NTSTATUS GetNextRequest (__in FxIrpQueue *IrpQueue, __in_opt MdFileObject FileObject, __in_opt FxRequest *TagRequest, __deref_out FxRequest **ppOutRequest)
 
static _Must_inspect_result_ NTSTATUS PeekRequest (__in FxIrpQueue *IrpQueue, __in_opt FxRequest *TagRequest, __in_opt MdFileObject FileObject, __out_opt PWDF_REQUEST_PARAMETERS Parameters, __deref_out FxRequest **ppOutRequest)
 
static __inline FxRequestRetrieveFromCsqContext (__in PMdIoCsqIrpContext pCsqContext)
 
- Static Public Member Functions inherited from FxRequestBase
static __inline FxRequestBase_FromListEntry (__in PLIST_ENTRY Entry)
 
static __inline FxRequestBase_FromDrainEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static __inline FxRequestBase_FromCsqContext (__in PMdIoCsqIrpContext Context)
 
- Static Public Member Functions inherited from FxObject
static FxObject_FromDisposeEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static FxObject_GetObjectFromHandle (__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
 
static PVOID __inline _ToHandle (__in FxObject *Object)
 
static VOID __inline _ReferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static VOID __inline _DereferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static PVOID _GetDebugBase (__in FxObject *Object)
 
static PFX_POOL_HEADER _CleanupPointer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
 
static _Must_inspect_result_ NTSTATUS _GetEffectiveLock (__in FxObject *Object, __in_opt IFxHasCallbacks *Callbacks, __in BOOLEAN AutomaticLocking, __in BOOLEAN PassiveCallbacks, __out FxCallbackLock **CallbackLock, __out_opt FxObject **CallbackLockObject)
 
static _Must_inspect_result_ NTSTATUS _ObjectQuery (_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
 

Protected Member Functions

 FxRequest (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in MdIrp Irp, __in FxRequestIrpOwnership Ownership, __in FxRequestConstructorCaller Caller, __in USHORT ObjectSize)
 
__inline VOID SetCurrentQueue (__in FxIoQueue *Queue)
 
WDFMEMORY GetMemoryHandle (__in USHORT Offset)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
- Protected Member Functions inherited from FxRequestBase
 FxRequestBase (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize, __in_opt MdIrp Irp, __in FxRequestIrpOwnership Ownership, __in FxRequestConstructorCaller Caller, __in FxObjectType ObjectType=FxObjectTypeExternal)
 
virtual ~FxRequestBase (VOID)
 
 FX_DECLARE_VF_FUNCTION (VOID, VerifyDispose)
 
virtual BOOLEAN Dispose (VOID)
 
VOID CompleteSubmittedNoContext (VOID)
 
VOID ZeroOutDriverContext (VOID)
 
- Protected Member Functions inherited from FxObject
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
FxObjectDebugExtensionGetDebugExtension (VOID)
 
BOOLEAN IsDebug (VOID)
 
VOID AllocateTagTracker (__in WDFTYPE Type)
 
virtual VOID SelfDestruct (VOID)
 
PVOID __inline GetObjectHandleUnchecked (VOID)
 
VOID __inline DestroyChildren (VOID)
 
VOID DeleteEarlyDisposedObject (VOID)
 

Protected Attributes

FxIoQueuem_IoQueue
 
FxRequestSystemBuffer m_SystemBuffer
 
FxRequestOutputBuffer m_OutputBuffer
 
LIST_ENTRY m_OwnerListEntry
 
LIST_ENTRY m_OwnerListEntry2
 
LIST_ENTRY m_ForwardProgressList
 
FxIoQueuem_ForwardProgressQueue
 
PVOID m_InternalContext
 
BOOLEAN m_Presented
 
BYTE m_PowerStopState
 
BOOLEAN m_Reserved
 
BOOLEAN m_ForwardRequestToParent
 
- Protected Attributes inherited from FxRequestBase
FxIrp m_Irp
 
FxIoTargetm_Target
 
FxRequestContextm_RequestContext
 
FxRequestTimerm_Timer
 
FxRequestCancelCallback m_CancelRoutine
 
FxRequestCompletionCallback m_CompletionRoutine
 
WDFCONTEXT m_TargetCompletionContext
 
LONG m_IrpCompletionReferenceCount
 
union {
   UCHAR   m_TargetFlags
 
   struct {
      UCHAR   Completed: 1
 
      UCHAR   FlagsPended: 1
 
      UCHAR   TimerSet: 1
 
      UCHAR   CancelledFromTimer: 1
 
      UCHAR   IgnoreState: 1
 
   }   m_TargetFlagsByName
 
}; 
 
UCHAR m_IrpAllocation
 
BOOLEAN m_Completed
 
BOOLEAN m_Canceled
 
WDFOBJECT_OFFSET_ALIGNED m_SystemBufferOffset
 
union {
   SHORT   m_VerifierFlags
 
   struct {
      SHORT   DriverOwned: 1
 
      SHORT   TagRequest: 1
 
      SHORT   Forwarded: 1
 
      SHORT   DriverDispatch: 1
 
      SHORT   DriverCancelable: 1
 
      SHORT   DriverInprocessContext: 1
 
      SHORT   Cancelled: 1
 
      SHORT   Formatted: 1
 
      SHORT   SentToTarget: 1
 
      SHORT   DriverInEvtIoStopContext: 1
 
   }   m_VeriferFlagsByName
 
}; 
 
LONG m_IrpReferenceCount
 
FxIrpQueuem_IrpQueue
 
WDFOBJECT_OFFSET_ALIGNED m_OutputBufferOffset
 
union {
   UCHAR   m_RequestBaseFlags
 
   struct {
      UCHAR   SystemMdlMapped: 1
 
      UCHAR   OutputMdlMapped: 1
 
      UCHAR   SyncCleanupContext: 1
 
   }   m_RequestBaseFlagsByName
 
}; 
 
union {
   UCHAR   m_RequestBaseStaticFlags
 
   struct {
      UCHAR   SystemBufferValid: 1
 
      UCHAR   OutputBufferValid: 1
 
   }   m_RequestBaseStaticFlagsByName
 
}; 
 
CCHAR m_PriorityBoost
 
BYTE m_CompletionState
 
BOOLEAN m_CanComplete
 
PMDL m_AllocatedMdl
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Private Member Functions

 FX_DECLARE_VF_FUNCTION_P1 (VOID, VerifyCompleteInternal, _In_ NTSTATUS)
 
NTSTATUS CompleteInternalReserved (__in NTSTATUS Status, __in CCHAR PriorityBoost)
 
NTSTATUS CompleteInternal (__in NTSTATUS Status)
 
VOID PostProcessCompletion (__in FxRequestCompletionState State, __in FxIoQueue *Queue)
 
VOID PostProcessCompletionForReserved (__in FxRequestCompletionState State, __in FxIoQueue *Queue)
 
VOID PreProcessCompletionForDriverRequest (__in FxRequestCompletionState State, __in FxIoQueue *Queue)
 
VOID PostProcessCompletionForDriverRequest (__in FxRequestCompletionState State, __in FxIoQueue *Queue)
 
VOID AssignMemoryBuffers (__in WDF_DEVICE_IO_TYPE IoType)
 

Static Private Member Functions

static VOID CheckAssumptions (VOID)
 

Private Attributes

friend FxIoTarget
 
friend FxIoQueue
 
friend FxRequestMemory
 
friend FxRequestOutputBuffer
 
friend FxRequestSystemBuffer
 

Friends

VOID GetTriageInfo (VOID)
 

Additional Inherited Members

- Public Attributes inherited from FxRequestBase
union {
   MdIoCsqIrpContext   m_CsqContext
 
   LIST_ENTRY   m_ListEntry
 
}; 
 
union {
   SINGLE_LIST_ENTRY   m_DrainSingleEntry
 
   BOOLEAN   m_NextStackLocationFormatted
 
}; 
 
- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 
- Static Protected Attributes inherited from FxRequestBase
static MdDeferredRoutineType _TimerDPC
 

Detailed Description

Definition at line 396 of file fxrequest.hpp.

Constructor & Destructor Documentation

◆ FxRequest()

FxRequest::FxRequest ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in MdIrp  Irp,
__in FxRequestIrpOwnership  Ownership,
__in FxRequestConstructorCaller  Caller,
__in USHORT  ObjectSize 
)
protected

Definition at line 33 of file fxrequest.cpp.

39 :
40 FxRequestBase(FxDriverGlobals,
41 ObjectSize,
42 Irp,
43 Ownership,
44 Caller)
45{
49
51
55
61}
WDFOBJECT_OFFSET_ALIGNED m_OutputBufferOffset
WDFOBJECT_OFFSET_ALIGNED m_SystemBufferOffset
FxIoQueue * m_IoQueue
Definition: fxrequest.hpp:411
FxIoQueue * m_ForwardProgressQueue
Definition: fxrequest.hpp:434
BOOLEAN m_ForwardRequestToParent
Definition: fxrequest.hpp:461
LIST_ENTRY m_ForwardProgressList
Definition: fxrequest.hpp:427
BOOLEAN m_Presented
Definition: fxrequest.hpp:445
LIST_ENTRY m_OwnerListEntry
Definition: fxrequest.hpp:420
LIST_ENTRY m_OwnerListEntry2
Definition: fxrequest.hpp:422
BOOLEAN m_Reserved
Definition: fxrequest.hpp:455
BYTE m_PowerStopState
Definition: fxrequest.hpp:450
PVOID m_InternalContext
Definition: fxrequest.hpp:439
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
@ FxRequestPowerStopUnknown
Definition: fxrequest.hpp:385
@ FxRequestConstructorCallerIsDriver
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Member Function Documentation

◆ _Create()

_Must_inspect_result_ NTSTATUS FxRequest::_Create ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in_opt PWDF_OBJECT_ATTRIBUTES  RequestAttributes,
__in_opt MdIrp  Irp,
__in_opt FxIoTarget Target,
__in FxRequestIrpOwnership  Ownership,
__in FxRequestConstructorCaller  Caller,
__deref_out FxRequest **  Request 
)
static

Definition at line 161 of file fxrequest.cpp.

170{
171 WDFOBJECT hRequest;
174
175 *Request = NULL;
176
178 if (!NT_SUCCESS(status)) {
179 return status;
180 }
181
182 pRequest = new (FxDriverGlobals, RequestAttributes)
183 FxRequest(FxDriverGlobals,
184 Irp,
185 Ownership,
186 Caller,
187 sizeof(FxRequest));
188
189 if (pRequest != NULL) {
190 if (Target != NULL) {
192 }
193
194 if (NT_SUCCESS(status)) {
196 }
197
198 if (NT_SUCCESS(status)) {
199 *Request = pRequest;
200 }
201 else {
203 "Handle create failed %!STATUS!", status);
204
205 if (Irp != NULL) {
206 //
207 // Clear the irp out of the request so that the destructor does
208 // not free it. Since we are returning failure, the caller does
209 // not expect the PIRP passed in to be freed.
210 //
212 }
213
215 }
216 }
217 else {
219 }
220
222 "Irp %p Ownership %!FxRequestIrpOwnership! FxRequest %p, status %!STATUS!",
223 Irp, Ownership, *Request, status);
224
225 return status;
226}
LONG NTSTATUS
Definition: precomp.h:26
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
MdIrp SetSubmitIrp(__in_opt MdIrp NewIrp, __in BOOLEAN FreeIrp=TRUE)
_Must_inspect_result_ NTSTATUS ValidateTarget(__in FxIoTarget *Target)
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxRequest * pRequest
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3431
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306

Referenced by FxUsbPipeContinuousReader::Config().

◆ _CreateForPackage()

_Must_inspect_result_ NTSTATUS FxRequest::_CreateForPackage ( __in CfxDevice Device,
__in PWDF_OBJECT_ATTRIBUTES  RequestAttributes,
__in MdIrp  Irp,
__deref_out FxRequest **  Request 
)
static

Definition at line 75 of file fxrequest.cpp.

102{
105
106 *Request = NULL;
107
108 //
109 // Allocate the new FxRequest object in the per driver tracking pool
110 //
112
113 if (pRequest == NULL) {
115 Device->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGREQUEST,
116 "Memory allocation failed %!STATUS!",
119 }
120
121 //
122 // For forward progress the IRP can be NULL.
123 //
124 if (Irp != NULL) {
125 pRequest->AssignMemoryBuffers(Device->GetIoTypeForReadWriteBufferAccess());
126 }
127
128 //
129 // Improve I/O perf by not parenting it to device. However, if verifier is
130 // turned on, the request is parented to the device to help track reference
131 // leaks.
132 //
133 if (Device->GetDriverGlobals()->FxRequestParentOptimizationOn) {
135 NULL,
136 NULL,
137 FALSE);
138 }
139 else {
141 NULL,
142 Device,
143 FALSE);
144 }
145
146 if (NT_SUCCESS(status)) {
147 *Request = pRequest;
148 }
149 else {
151 Device->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGREQUEST,
152 "Could not commit FxRequest %!STATUS!", status);
154 }
155
156 return status;
157}
VOID AssignMemoryBuffers(__in WDF_DEVICE_IO_TYPE IoType)
Definition: fxrequest.hpp:1372
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474

Referenced by FxIoQueue::AllocateReservedRequest(), FxPkgIo::DispatchStep2(), and FxPkgGeneral::OnCreate().

◆ _FromOwnerListEntry()

static FxRequest * FxRequest::_FromOwnerListEntry ( __in FxListEntryNames  Index,
__in PLIST_ENTRY  OwnerListEntry 
)
inlinestatic

Definition at line 489 of file fxrequest.hpp.

493 {
494 switch (Index) {
496 return CONTAINING_RECORD(OwnerListEntry, FxRequest, m_OwnerListEntry);
498 return CONTAINING_RECORD(OwnerListEntry, FxRequest, m_OwnerListEntry2);
500 return CONTAINING_RECORD(OwnerListEntry, FxRequest, m_ForwardProgressList);
501 default:
502 ASSERT(FALSE);
503 return NULL;
504 }
505 }
@ FxListEntryDriverOwned
Definition: fxrequest.hpp:378
@ FxListEntryForwardProgress
Definition: fxrequest.hpp:381
@ FxListEntryQueueOwned
Definition: fxrequest.hpp:375
#define ASSERT(a)
Definition: mode.c:44
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ WDFCOLLECTION _In_ ULONG Index

◆ AddIrpReference()

VOID FxRequest::AddIrpReference ( VOID  )

Definition at line 2470 of file fxrequest.cpp.

2492{
2495
2497 KIRQL irql;
2498
2499 Lock(&irql);
2500
2501 (VOID)VerifyRequestIsNotCompleted(pFxDriverGlobals);
2502
2503 Unlock(irql);
2504 }
2505
2507
2508 return;
2509}
#define VOID
Definition: acefi.h:82
#define InterlockedIncrement
Definition: armddk.h:53
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
PFX_DRIVER_GLOBALS pFxDriverGlobals
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127

Referenced by FxRequestSystemBuffer::AddRef(), FxRequestOutputBuffer::AddRef(), AddRefOverride(), FxDmaTransactionBase::ReferenceRequest(), FxRequestMemory::SetBuffer(), and FxRequestMemory::SetMdl().

◆ AddRefOverride()

ULONG FxRequest::AddRefOverride ( __in WDFOBJECT_OFFSET  Offset,
__in PVOID  Tag = NULL,
__in LONG  Line = 0,
__in_opt PSTR  File = NULL 
)
virtual

Definition at line 2675 of file fxrequest.cpp.

2681{
2682 if (Offset != 0x0) {
2686 return 2;
2687 }
2688 else {
2689 return FxObject::AddRef(Tag, Line, File);
2690 }
2691}
Definition: File.h:16
ULONG __inline AddRef(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:826
VOID AddIrpReference(VOID)
Definition: fxrequest.cpp:2470
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: ncftp.h:79
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065

◆ AssignMemoryBuffers()

VOID FxRequest::AssignMemoryBuffers ( __in WDF_DEVICE_IO_TYPE  IoType)
inlineprivate

Definition at line 1372 of file fxrequest.hpp.

1375{
1376
1377 switch (m_Irp.GetMajorFunction()) {
1380
1381
1382
1383
1384
1385
1386
1387
1388
1390 case METHOD_BUFFERED:
1391 //
1392 // Set the buffer in the memory interface. For kernel mode,
1393 // GetOutputBuffer is same as GetSystemBuffer, but for user-mode,
1394 // host provides separate buffers, so that input buffer can only be
1395 // read, and output buffer can only be written to.
1396 //
1399 break;
1400
1401 case METHOD_IN_DIRECT:
1402 //
1403 // InputBuffer is in SystemBuffer
1404 // OutputBuffer is in MdlAddress with read access
1405 //
1408 break;
1409
1410 case METHOD_OUT_DIRECT:
1411 //
1412 // InputBuffer is in SystemBuffer
1413 // OutputBuffer is in MdlAddress with write access
1414 //
1417 break;
1418
1419 case METHOD_NEITHER:
1420 //
1421 // Internal device controls are kernel mode to kernel mode, and deal
1422 // with direct unmapped pointers.
1423 //
1424 // In addition, a normal device control with
1425 // RequestorMode == KernelMode is also treated as kernel mode
1426 // to kernel mode since the I/O Manager will not generate requests
1427 // with this setting from a user mode request.
1428 //
1434 );
1436 }
1437 else {
1438 return;
1439 }
1440 break;
1441 }
1442 break;
1443
1444 case IRP_MJ_READ:
1445 case IRP_MJ_WRITE:
1446 switch (IoType) {
1449 break;
1450
1451 case WdfDeviceIoNeither:
1455 }
1456 else {
1457 return;
1458 }
1459 break;
1460
1461 default:
1462 return;
1463 }
1464 break;
1465
1466 default:
1467 return;
1468 }
1469
1472 }
1475 }
1476}
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
KPROCESSOR_MODE GetRequestorMode(VOID)
Definition: fxirpum.cpp:329
PVOID GetSystemBuffer()
Definition: fxirpum.cpp:543
PVOID GetOutputBuffer()
Definition: fxirpum.cpp:594
PVOID GetParameterIoctlType3InputBuffer(VOID)
Definition: fxirpum.cpp:1542
PVOID GetUserBuffer()
Definition: fxirpum.cpp:633
UCHAR m_RequestBaseStaticFlags
FxRequestOutputBuffer m_OutputBuffer
Definition: fxrequest.hpp:415
FxRequestSystemBuffer m_SystemBuffer
Definition: fxrequest.hpp:413
#define KMDF_ONLY_CODE_PATH_ASSERT()
Definition: fx.hpp:55
@ FxRequestBaseStaticSystemBufferValid
@ FxRequestBaseStaticOutputBufferValid
#define KernelMode
Definition: asm.h:34
#define METHOD_NEITHER
Definition: nt_native.h:597
#define METHOD_OUT_DIRECT
Definition: nt_native.h:596
#define METHOD_BUFFERED
Definition: nt_native.h:594
#define METHOD_IN_DIRECT
Definition: nt_native.h:595
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
__inline VOID SetBuffer(__in PVOID Buffer)
Definition: fxrequest.hpp:334
__inline BOOLEAN IsBufferSet(VOID)
Definition: fxrequest.hpp:314
__inline VOID SetBuffer(PVOID Buffer)
Definition: fxrequest.hpp:188
__inline BOOLEAN IsBufferSet(VOID)
Definition: fxrequest.hpp:168
_In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_IO_TYPE IoType
Definition: wdfdevice.h:3141
@ WdfDeviceIoNeither
Definition: wdfdevice.h:451
@ WdfDeviceIoBuffered
Definition: wdfdevice.h:452
#define IRP_MJ_INTERNAL_DEVICE_CONTROL

Referenced by _CreateForPackage().

◆ CheckAssumptions()

VOID FxRequest::CheckAssumptions ( VOID  )
staticprivate

Definition at line 34 of file fxrequestkm.cpp.

53{
54 PWDF_REQUEST_PARAMETERS pWdfRequestParameters = NULL;
55 PIO_STACK_LOCATION pIoStackLocation = NULL;
56
57 UNREFERENCED_PARAMETER(pWdfRequestParameters);
58 UNREFERENCED_PARAMETER(pIoStackLocation);
59
60 //
61 // FxRequest::GetParameters relies on these being exactly the same size
62 //
63 WDFCASSERT(sizeof(pWdfRequestParameters->Parameters) ==
64 sizeof(pIoStackLocation->Parameters));
65
66 //
67 // The address of the offset in the structure needs to be 8 bit aligned
68 // so that we can store flags in the bottom 3 bits
69 //
72
75}
@ FxHandleFlagMask
Definition: fxobject.hpp:62
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
struct _IO_STACK_LOCATION::@3776::@3781 Write
struct _IO_STACK_LOCATION::@3776::@3780 Read
union _WDF_REQUEST_PARAMETERS::@3679 Parameters
#define WDFCASSERT(c)
Definition: wdfassert.h:93
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869

◆ ClearFieldsForReuse()

__inline VOID FxRequest::ClearFieldsForReuse ( VOID  )
inline

Definition at line 1294 of file fxrequest.hpp.

1297 {
1300
1302
1303 FxRequestBase::ClearFieldsForReuse(); // __super call
1304 }
VOID ClearFieldsForReuse(VOID)
__inline VOID ClearBufferMdl(VOID)
Definition: fxrequest.hpp:323
__inline VOID ClearBufferMdl(VOID)
Definition: fxrequest.hpp:177

Referenced by Reuse().

◆ ClearPowerStopState()

VOID FxRequest::ClearPowerStopState ( VOID  )
inline

Definition at line 1214 of file fxrequest.hpp.

◆ Complete()

__inline NTSTATUS FxRequest::Complete ( __in NTSTATUS  Status)
inline

Definition at line 770 of file fxrequest.hpp.

773 {
774 CfxDevice* const fxDevice = GetDevice();
775
776 //
777 // Complete the current request object. Can be called directly
778 // by the FxIoQueue to complete a request.
779 //
780 // When an FxRequest is completed, it is marked as completed,
781 // removed from any CSQ it may be a member of, and any registered
782 // callback functions are called. Then the NT IRP is completed,
783 // and the reference count on the object due to the callback routine
784 // is released if a callback routine was specified.
785 //
786 // Completing a request object can cause its reference
787 // count to go to zero, thus deleting it. So the caller
788 // must either reference it explicitly, or not touch it
789 // any more after calling complete.
790 //
791
794 "Completing WDFREQUEST 0x%p for IRP 0x%p with "
795 "Information 0x%I64x, %!STATUS!",
797
798 if (fxDevice != NULL) {
800 }
801 else {
803 }
804
805 return CompleteInternal(Status);
806 }
__inline CHAR GetDefaultPriorityBoost(VOID)
Definition: fxdevice.hpp:1111
MdIrp GetIrp(VOID)
Definition: fxirpum.cpp:15
ULONG_PTR GetInformation()
Definition: fxirpum.cpp:513
VOID __inline SetPriorityBoost(CCHAR PriorityBoost)
NTSTATUS CompleteInternal(__in NTSTATUS Status)
Definition: fxrequest.cpp:515
return pList GetDevice()
Status
Definition: gdiplustypes.h:25
#define GetHandle(h)
Definition: treelist.c:116

Referenced by CompleteWithInformation(), FxIoQueue::DispatchRequestToDriver(), and FxPkgGeneral::OnCreate().

◆ CompleteInternal()

NTSTATUS FxRequest::CompleteInternal ( __in NTSTATUS  Status)
private

Definition at line 515 of file fxrequest.cpp.

542{
544 MdIrp pIrp;
547 CfxDevice* pRefedDevice;
548
550 queue = NULL;
551 //
552 // Store off the irp into a local variable
553 //
554 pIrp = m_Irp.GetIrp();
555
556 //
557 // Lock is no longer required, since it's only used
558 // by verifier for already completed requests. This is a
559 // serious driver error anyway
560 //
561
562
563 VerifyCompleteInternal(pFxDriverGlobals, Status);
564
566 //
567 // No lock needed in non-verifier case since this is only
568 // used to detect double completions with verifier on
569 //
572 }
573
574
575
576
577
578
579#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
580
581
582
583
584
585
586
587 ULONG flagsMasked = m_Irp.GetFlags() & IRP_INPUT_OPERATION;
592 (flagsMasked != 0)) {
593
596 "Driver that handled WDFREQUEST 0x%p is requesting data to "
597 " be written back to the UserBuffer by returing a non zero value "
598 " in the Irp 0x%p Information field even though the OutputBufferLength "
599 " is zero", GetObjectHandle(), pIrp);
600
601 //
602 // We will assert only if the Information field is not zero to warn
603 // the developer that it's a bad thing to do. However, we do avoid
604 // corruption of UserBuffer on completion by clearing the flag
605 // erroneously set by the I/O manager.
606 //
607 if (m_Irp.GetInformation() != 0L) {
609 }
610
611 //
612 // Clear the flag to prevent the I/O manager from coping the
613 // data back from the SystemBuffer to Irp->UserBuffer
614 //
616 }
617#endif
618
619 //
620 // If the status code is one of the framework facility codes,
621 // map it to a standard NTSTATUS
622 //
623
624
625 if ((Status & 0x0FFF0000) == (FACILITY_DRIVER_FRAMEWORK << 16)) {
628 "Converting WDF NTSTATUS value 0x%x...", Status);
629
630 switch (Status) {
632 case STATUS_WDF_BUSY:
634 break;
635
638 break;
639
642 break;
643
644 default:
647 "Unknown WDF NTSTATUS 0x%x", Status);
649 break;
650 }
651
653 "... to %!STATUS!", Status);
654 }
655
656 if (IsAllocatedFromIo() == FALSE && IsCanComplete() == FALSE) {
658 }
659
660 //
661 // It is invalid to complete any requests on an IRPQUEUE
662 //
663 ASSERTMSG("WDFREQUEST is part of a WDFQUEUE, it could be Cancellable\n",
664 (m_IrpQueue == NULL));
665
668
669 //
670 // Some I/O request cleanup. Do not do this for driver created requests.
671 //
672 if (IsAllocatedFromIo()) {
673 //
674 // Set the completion state to none
675 //
677
678 if (IsReserved() == FALSE) {
679 //
680 // Don't set the Queue to NULL for reserved requests.
681 //
682 m_IoQueue = NULL;
683 }
684 }
685
686 //
687 // IMPORTANT: the context must free its references before the request is
688 // completed. Any of these references could be on a memory interface that is
689 // an embedded interface in this object. If this reference
690 // is left outstanding when we check m_IrpReferenceCount below, we would
691 // bugcheck (and the driver writer would be unaware of why things are going
692 // wrong).
693 //
694 // Also, if the driver is freeing the referenced mmemory interface in its
695 // cleanup routine, we don't want an oustanding reference against it.
696 //
697 if (m_RequestContext != NULL) {
698 //
699 // m_RequestContext will be freed when the FxRequest's desctructor runs
700 //
702 }
703
704 //
705 // If the request is not presented to the driver then clear the
706 // cleanup & destroy callbacks before calling PerformEarlyDispose.
707 //
708 if (m_Presented == FALSE) {
710 }
711
712 if (IsReserved() == FALSE && IsAllocatedFromIo()) {
713 //
714 // Fire the driver supplied Cleanup callback if set
715 //
716 // This will allow the driver to release any IRP specific resources such
717 // as MDLs before we complete the IRP back to the OS, and release the
718 // process/thread reference.
719 //
720 // This is also the callback used to tell the driver the WDM IRP is going
721 // away if it has used the WDM "escape" API's to either get the IRP, or
722 // any resources it references.
723 //
724
725 //
726 // If a cleanup callback has been registered, we call it
727 // just before completing the IRP to WDM, which can cause any
728 // associated buffers, MDLs, or memory interfaces to be invalidated.
729 //
730 if (EarlyDispose() == FALSE) {
731 VerifierBreakpoint_RequestEarlyDisposeDeferred(GetDriverGlobals());
732 }
733
734 //
735 // Now that the entire tree is disposed, we want to destroy all of the
736 // children. This will not put this object in the destroyed state. For
737 // m_IrpReferenceCount to go to zero, we need to destroy the child WDFMEMORYs
738 // that were created when we probed and locked the buffers.
739 //
741 }
742 else {
743 //
744 // We don't call cleanup callback for Reserved Requests.
745 // The driver can perform any cleanp it wants before completing the Request
746 // or before reusing the Reserved Request in its Dispatch callback.
747
748
749
750
751
752
753 DO_NOTHING();
754 }
755
756 //
757 // If this is non-zero, indicates a reference count problem on any
758 // WDFMEMORY objects returned to the device driver from this WDFREQUEST.
759 //
760 if (m_IrpReferenceCount != 0) {
761 //
762 // NOTE: you cannot call GetBuffer or GetMdl
765 "WDFREQUEST 0x%p, PIRP 0x%p, Major Function 0x%x, completed with "
766 "outstanding references on WDFMEMORY 0x%p or 0x%p retrieved from "
767 "this request",
775 );
776
781 "WDFMEMORY 0x%p, buffer %p, PMDL %p, length %I64d bytes",
784 }
785
790 "IOCTL output WDFMEMORY 0x%p, buffer %p, PMDL %p, length %I64d bytes",
793 }
794
799 }
800
801 FxIrp irp(pIrp);
802
803 //
804 // Complete the NT IRP through the frameworks FxIrp
805 //
807
809
810 //
811 // For driver created requests we need to use two phase
812 // completion (pre and post) to detach the request from the queue before the
813 // IRP is completed, and then allow a new request to be dispatched.
814 // Note that the IRP is actually completed when the reference on this object
815 // goes to 1 (See FxRequest::Release() for more info).
816 //
817 if (IsAllocatedFromIo() == FALSE) {
818 //
819 // Do not touch the request after this call.
820 // Do not clear the request's IRP field before making this call.
821 //
823 }
824 else {
825 //
826 // We only clear the irp from this object after PerformEarlyDispose has been
827 // called. m_SystemBuffer and m_OutputBuffer use m_Irp to return their
828 // buffers and their WDFMEMORY handles should be valid in the cleanup routine
829 // for the WDFREQUEST. We also keep m_Irp valid until after the
830 // m_IrpReferenceCount check, so we can trace out the buffers in case of
831 // error.
832 //
834
836 //
837 // If this is the last handle to be closed on the device, then the call
838 // to CreateCompleted can cause the device to be deleted if the create
839 // has failed. We add a reference so that we make sure we have a device
840 // to free the request memory back to.
841 //
842 pRefedDevice = GetDevice();
843 pRefedDevice->ADDREF(&irp);
844
845 pRefedDevice->m_PkgGeneral->CreateCompleted(&irp);
846 }
847 else {
848 pRefedDevice = NULL;
849 }
850
851 //
852 // WDM IRP is completed.
853 //
855
856 if (IsReserved() == FALSE) {
858 }
859 else {
861 }
862
863 if (pRefedDevice != NULL) {
864 pRefedDevice->RELEASE(&irp);
865 pRefedDevice = NULL;
866 }
867 }
868
869 return Status;
870}
static int state
Definition: maze.c:121
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
Definition: fxirp.hpp:28
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
ULONG GetParameterIoctlOutputBufferLength(VOID)
Definition: fxirpum.cpp:1504
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
MdIrp SetIrp(MdIrp irp)
Definition: fxirpkm.hpp:71
ULONG GetFlags(VOID)
Definition: fxirpum.cpp:1281
VOID SetFlags(__in ULONG Flags)
Definition: fxirpum.cpp:1266
VOID __inline DestroyChildren(VOID)
Definition: fxobject.hpp:464
VOID ClearEvtCallbacks(VOID)
Definition: fxobject.cpp:360
BOOLEAN EarlyDispose(VOID)
VOID CreateCompleted(__in FxIrp *Irp)
BOOLEAN __inline IsCanComplete(VOID)
FxIrpQueue * m_IrpQueue
FxRequestContext * m_RequestContext
UCHAR m_RequestBaseFlags
__inline BOOLEAN IsCancelRoutineSet(VOID)
BOOLEAN __inline IsAllocatedFromIo(VOID)
CCHAR __inline GetPriorityBoost(VOID)
VOID PostProcessCompletionForReserved(__in FxRequestCompletionState State, __in FxIoQueue *Queue)
Definition: fxrequest.cpp:916
VOID PostProcessCompletion(__in FxRequestCompletionState State, __in FxIoQueue *Queue)
Definition: fxrequest.cpp:874
__inline BOOLEAN IsReserved()
Definition: fxrequest.hpp:609
VOID PreProcessCompletionForDriverRequest(__in FxRequestCompletionState State, __in FxIoQueue *Queue)
Definition: fxrequest.cpp:955
Definition: _queue.h:67
return pObject GetObjectHandle()
FxVerifierDbgBreakPoint(pFxDriverGlobals)
FxIrp * pIrp
FxIrp * irp
@ FxRequestBaseOutputMdlMapped
@ FxRequestBaseSystemMdlMapped
FxRequestCompletionState
@ FxRequestCompletionStateNone
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
#define DO_NOTHING()
Definition: mxgeneral.h:32
IWudfIrp * MdIrp
Definition: mxum.h:103
#define UserMode
Definition: asm.h:35
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define L(x)
Definition: ntvdm.h:50
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
virtual VOID ReleaseAndRestore(__in FxRequestBase *Request)
virtual _Must_inspect_result_ PMDL GetMdl(VOID)
virtual PVOID GetBuffer(VOID)
virtual size_t GetBufferSize(VOID)
virtual WDFMEMORY GetHandle(VOID)
virtual size_t GetBufferSize(VOID)
virtual _Must_inspect_result_ PVOID GetBuffer(VOID)
virtual WDFMEMORY GetHandle(VOID)
virtual _Must_inspect_result_ PMDL GetMdl(VOID)
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
@ WDF_VERIFIER_FATAL_ERROR
Definition: wdfbugcodes.h:60
#define STATUS_WDF_TOO_FRAGMENTED
Definition: wdfstatus.h:180
#define FACILITY_DRIVER_FRAMEWORK
Definition: wdfstatus.h:32
#define STATUS_WDF_PAUSED
Definition: wdfstatus.h:117
#define STATUS_WDF_INTERNAL_ERROR
Definition: wdfstatus.h:108
#define STATUS_WDF_BUSY
Definition: wdfstatus.h:126
#define IRP_INPUT_OPERATION

Referenced by Complete(), and CompleteWithPriority().

◆ CompleteInternalReserved()

NTSTATUS FxRequest::CompleteInternalReserved ( __in NTSTATUS  Status,
__in CCHAR  PriorityBoost 
)
private

◆ CompleteWithInformation()

__inline NTSTATUS FxRequest::CompleteWithInformation ( __in NTSTATUS  Status,
__in ULONG_PTR  Information 
)
inline

Definition at line 810 of file fxrequest.hpp.

814 {
815 //
816 // Complete the request object. If the status is success, get the
817 // priority boost for the owning device type, and complete the request.
818 //
820 return Complete(Status);
821 }
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
__inline NTSTATUS Complete(__in NTSTATUS Status)
Definition: fxrequest.hpp:770
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

Referenced by FxIoQueue::GetRequest(), and FxIoQueue::QueueRequest().

◆ CompleteWithPriority()

__inline NTSTATUS FxRequest::CompleteWithPriority ( __in NTSTATUS  Status,
__in CCHAR  PriorityBoost 
)
inline

Definition at line 825 of file fxrequest.hpp.

829 {
830 //
831 // Complete the current request object. Can be called directly
832 // by the FxIoQueue to complete a request.
833 //
834 // When an FxRequest is completed, it is marked as completed,
835 // removed from any CSQ it may be a member of, and any registered
836 // callback functions are called. Then the NT IRP is completed,
837 // and the reference count on the object due to the callback routine
838 // is released if a callback routine was specified.
839 //
840 // Completing a request object can cause its reference
841 // count to go to zero, thus deleting it. So the caller
842 // must either reference it explicitly, or not touch it
843 // any more after calling complete.
844 //
845
848 "Completing WDFREQUEST 0x%p for IRP 0x%p with "
849 "Information 0x%I64x, %!STATUS!",
851
853 return CompleteInternal(Status);
854 }
_In_ WDFREQUEST _In_ NTSTATUS _In_ CCHAR PriorityBoost
Definition: wdfrequest.h:1016

◆ CopyCompletionParams()

__inline VOID FxRequest::CopyCompletionParams ( __in PWDF_REQUEST_COMPLETION_PARAMS  Params)
inline

Definition at line 534 of file fxrequest.hpp.

537 {
538 if (m_RequestContext != NULL) {
542 }
543 else {
546 "WdfRequestGetCompletionParams will not return valid information if the"
547 " request is not formatted using WdfIoTargetFormatxxx DDIs"
548 );
549
551
553 }
554 }
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
FORCEINLINE VOID WDF_REQUEST_COMPLETION_PARAMS_INIT(_Out_ PWDF_REQUEST_COMPLETION_PARAMS Params)
Definition: wdfrequest.h:288
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308

◆ CopyCurrentIrpStackLocationToNext()

__inline VOID FxRequest::CopyCurrentIrpStackLocationToNext ( VOID  )
inline

Definition at line 509 of file fxrequest.hpp.

512 {
515 }
VOID CopyCurrentIrpStackLocationToNext(VOID)
Definition: fxirpum.cpp:209
__inline FxIrp * GetSubmitFxIrp(VOID)

◆ FreeRequest()

VOID FxRequest::FreeRequest ( VOID  )

Definition at line 1022 of file fxrequest.cpp.

1033{
1034 //
1035 // Restore any fields if necessary
1036 //
1037 if (m_RequestContext != NULL) {
1038 //
1039 // m_RequestContext will be freed when the FxRequest's destructor runs
1040 //
1042 }
1043
1044 //
1045 // If the request is not presented to the driver then clear the
1046 // cleanup & destroy callbacks before calling PerformEarlyDispose.
1047 //
1048 if (m_Presented == FALSE) {
1050 }
1051
1052 DeleteObject();
1053}
pKey DeleteObject()

Referenced by FxIoQueue::AllocateReservedRequest().

◆ FX_DECLARE_VF_FUNCTION() [1/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyProbeAndLock   
)

◆ FX_DECLARE_VF_FUNCTION() [2/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestCanBeCompleted   
)

◆ FX_DECLARE_VF_FUNCTION() [3/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsAllocatedFromIo   
)

◆ FX_DECLARE_VF_FUNCTION() [4/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsCancelable   
)

◆ FX_DECLARE_VF_FUNCTION() [5/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsCurrentStackValid   
)

◆ FX_DECLARE_VF_FUNCTION() [6/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsDriverOwned   
)

◆ FX_DECLARE_VF_FUNCTION() [7/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsInCallerContext   
)

◆ FX_DECLARE_VF_FUNCTION() [8/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsInEvtIoStopContext   
)

◆ FX_DECLARE_VF_FUNCTION() [9/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsNotCancelable   
)

◆ FX_DECLARE_VF_FUNCTION() [10/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsNotCompleted   
)

◆ FX_DECLARE_VF_FUNCTION() [11/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsTagRequest   
)

◆ FX_DECLARE_VF_FUNCTION() [12/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( VOID  ,
VerifierBreakpoint_RequestEarlyDisposeDeferred   
)

◆ FX_DECLARE_VF_FUNCTION() [13/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( VOID  ,
VerifyPreProcessSendAndForget   
)

◆ FX_DECLARE_VF_FUNCTION_P1() [1/3]

FxRequest::FX_DECLARE_VF_FUNCTION_P1 ( NTSTATUS  ,
VerifyInsertIrpQueue  ,
_In_ FxIrpQueue  
)

◆ FX_DECLARE_VF_FUNCTION_P1() [2/3]

FxRequest::FX_DECLARE_VF_FUNCTION_P1 ( NTSTATUS  ,
VerifyStopAcknowledge  ,
_In_  BOOLEAN 
)

◆ FX_DECLARE_VF_FUNCTION_P1() [3/3]

FxRequest::FX_DECLARE_VF_FUNCTION_P1 ( VOID  ,
VerifyCompleteInternal  ,
_In_  NTSTATUS 
)
private

◆ GetCsqContext()

__inline PMdIoCsqIrpContext FxRequest::GetCsqContext ( VOID  )
inline

Definition at line 1113 of file fxrequest.hpp.

1116 {
1117 return &m_CsqContext;
1118 }
MdIoCsqIrpContext m_CsqContext

Referenced by IsInIrpQueue().

◆ GetCurrentIrpStackLocation()

PIO_STACK_LOCATION FxRequest::GetCurrentIrpStackLocation ( VOID  )
inline

Definition at line 1026 of file fxrequest.hpp.

1029 {
1030 if (GetDriverGlobals()->FxVerifierIO) {
1032 KIRQL irql;
1034
1035 Lock(&irql);
1036 status = VerifyRequestIsNotCompleted(GetDriverGlobals());
1037 if (!NT_SUCCESS(status)) {
1038 ios = NULL;
1039 }
1040 else {
1042 }
1043 Unlock(irql);
1044
1045 return ios;
1046 }
1047 else {
1049 }
1050 }
basic_ios< char, char_traits< char > > ios
Definition: _iosfwd.h:78
PIO_STACK_LOCATION GetCurrentIrpStackLocation(VOID)
Definition: fxirpum.cpp:370

Referenced by FxIoQueue::DispatchRequestToDriver(), and FxIoQueue::GetRequest().

◆ GetCurrentQueue()

_Must_inspect_result_ FxIoQueue * FxRequest::GetCurrentQueue ( VOID  )
inline

Definition at line 728 of file fxrequest.hpp.

731 {
732 if(m_Completed) {
733 return NULL;
734 }
735
736 return m_IoQueue;
737 }

Referenced by PerfIoComplete(), PerfIoStart(), and FxIoQueue::Requeue().

◆ GetDevice()

__inline CfxDevice * FxRequest::GetDevice ( VOID  )
inline

Definition at line 600 of file fxrequest.hpp.

603 {
604 return m_Device;
605 }
CfxDevice * m_Device
Definition: fxobject.hpp:329

◆ GetDeviceControlOutputMdl()

_Must_inspect_result_ NTSTATUS FxRequest::GetDeviceControlOutputMdl ( __out PMDL pMdl)

Definition at line 347 of file fxrequestkm.cpp.

392{
395 KIRQL irql;
398 PMDL pNewMdl;
400
401 length = 0;
402 pBuffer = NULL;
404
405 Lock(&irql);
406
407 // Verifier
409
410 status = VerifyRequestIsNotCompleted(pFxDriverGlobals);
411 if (!NT_SUCCESS(status)) {
412 Unlock(irql);
413 return status;
414 }
415 }
416
417 //
418 // See if we have an IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL
419 //
421
425
426 //
427 // It's a non-Device Control request, which is an error for this call
428 //
431 "WDFREQUEST %p (MajorFunction is 0x%x) this call is only valid for "
432 "IOCTLs, %!STATUS!", GetHandle(), majorFunction, status);
433 *pMdl = NULL;
434
435 Unlock(irql);
436
437 return status;
438 }
439
441 case METHOD_BUFFERED:
442
445
446 // Fall through to common buffer handler
447 break;
448
449 case METHOD_IN_DIRECT:
450 //
451 // InputBuffer is in SystemBuffer
452 // OutputBuffer is in MdlAddress with read access
453 //
454 *pMdl = m_Irp.GetMdl();
455
456 if (*pMdl == NULL) {
458
461 "WDFREQUEST 0x%p, METHOD_IN_DIRECT IOCTL, PMDL is NULL, "
462 "%!STATUS!", GetHandle(), status);
463 }
464 else {
466 }
467 Unlock(irql);
468
469 return status;
470
472 //
473 // InputBuffer is in SystemBuffer
474 // OutputBuffer is in MdlAddress with write access
475 //
476 *pMdl = m_Irp.GetMdl();
477
478 if (*pMdl == NULL) {
480
483 "WDFREQUEST 0x%p, METHOD_OUT_DIRECT IOCTL, PMDL is NULL, "
484 "%!STATUS!", GetHandle(), status);
485 }
486 else {
488 }
489 Unlock(irql);
490
491 return status;
492
493 case METHOD_NEITHER:
495
498 "Attempt to get UserMode Buffer Pointer for METHOD_NEITHER "
499 "DeviceControl 0x%x, WDFDEVICE 0x%p, WDFREQUEST 0x%p, %!STATUS!",
502
505 "Driver must use METHOD_BUFFERED or METHOD_xx_DIRECT I/O for this "
506 "call, or use WdfDeviceInitSetIoInCallerContextCallback to probe "
507 "and lock user mode memory");
508
509 *pMdl = NULL;
510 Unlock(irql);
511
512 return status;
513 }
514
515 //
516 // if pBuffer != NULL, attempt to generate an MDL for it
517 //
518 if( (pBuffer == NULL) || (length == 0) ) {
519 *pMdl = NULL;
520
521 Unlock(irql);
522
524
525 if (pBuffer == NULL) {
528 "WDFREQUEST 0x%p, SystemBuffer is NULL, %!STATUS!",
529 GetHandle(), status);
530 }
531 else if (length == 0) {
534 "WDFREQUEST 0x%p, SystemBuffer length is 0, %!STATUS!",
535 GetHandle(), status);
536 }
537
538 return status;
539 }
540
541 //
542 // See if we have already allocated an MDL for this
543 //
544 if( m_AllocatedMdl != NULL ) {
545 *pMdl = m_AllocatedMdl;
546 Unlock(irql);
547
548 return STATUS_SUCCESS;
549 }
550
552 this,
553 pBuffer,
554 length,
555 FALSE,
556 FALSE);
557
558 if (pNewMdl == NULL) {
560
563 "WDFREQUEST %p could not allocate MDL for buffer 0x%p Length %d, "
564 "%!STATUS!", GetHandle(), pBuffer, length, status);
565 *pMdl = NULL;
566 Unlock(irql);
567
568 return status;
569 }
570
572
573 //
574 // We associated the Mdl with the request object
575 // so it can be freed when completed.
576 //
577 m_AllocatedMdl = pNewMdl;
578
579 *pMdl = pNewMdl;
580
581 Unlock(irql);
582
583 return STATUS_SUCCESS;
584}
ULONG GetParameterIoctlCode(VOID)
Definition: fxirpum.cpp:1474
PMDL GetMdl()
Definition: fxirpum.cpp:625
static __inline VOID MxBuildMdlForNonPagedPool(__inout PMDL Mdl)
Definition: mxgeneralkm.h:376
PMDL FORCEINLINE FxMdlAllocate(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Owner, __in PVOID VirtualAddress, __in ULONG Length, __in BOOLEAN SecondaryBuffer, __in BOOLEAN ChargeQuota)
Definition: fxmdl.h:31
UCHAR majorFunction
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
PVOID pBuffer
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
BOOLEAN FxVerifierIO
Definition: fxglobals.h:446
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by switch().

◆ GetDeviceControlOutputMemoryObject()

_Must_inspect_result_ NTSTATUS FxRequest::GetDeviceControlOutputMemoryObject ( __deref_out IFxMemory **  MemoryObject,
__out PVOID Buffer,
__out size_t Length 
)

Definition at line 1524 of file fxrequest.cpp.

1579{
1580 size_t length;
1582 KIRQL irql;
1583 BOOLEAN mapMdl;
1585
1588
1590 length = 0;
1592 mapMdl = FALSE;
1593
1594 //
1595 // Verifier
1596 //
1597 if (GetDriverGlobals()->FxVerifierIO ) {
1598 status = VerifyRequestIsNotCompleted(GetDriverGlobals());
1599 if (!NT_SUCCESS(status)) {
1600 return status;
1601 }
1602 }
1603
1605 Lock(&irql);
1606 }
1607
1608 //
1609 // See if we already have a validated buffer
1610 //
1611 //if (m_RequestBaseFlags & FxRequestBaseOutputBufferValid) {
1612 // status = STATUS_SUCCESS;
1613 //}
1614
1616
1619
1621
1622 if (length == 0) {
1624
1627 "WDFREQUEST 0x%p IOCTL output buffer length is zero, %!STATUS!",
1628 GetHandle(), status);
1629
1630 goto Done;
1631 }
1632
1634 //
1635 // InputBuffer is in SystemBuffer
1636 // OutputBuffer is in MdlAddress with read access
1637 //
1638 case METHOD_IN_DIRECT:
1639 // || || fall || ||
1640 // \/ \/ through \/ \/
1641
1642 //
1643 // InputBuffer is in SystemBuffer
1644 // OutputBuffer is in MdlAddress with read access
1645 //
1646 case METHOD_OUT_DIRECT:
1647 mapMdl = TRUE;
1648 break;
1649
1650 case METHOD_NEITHER:
1651 //
1652 // Internal device controls are kernel mode to kernel mode, and deal
1653 // with direct unmapped pointers.
1654 //
1655 // In addition, a normal device control with
1656 // RequestorMode == KernelMode is also treated as kernel mode
1657 // to kernel mode since the I/O Manager will not generate requests
1658 // with this setting from a user mode request.
1659 //
1660 if ((m_Irp.GetRequestorMode() == KernelMode) ||
1662 DO_NOTHING();
1663 }
1664 else {
1666
1669 "Attempt to get UserMode Buffer Pointer for "
1670 "METHOD_NEITHER DeviceControl 0x%x, WDFDEVICE 0x%p, "
1671 "WDFREQUEST 0x%p, %!STATUS!",
1674
1677 "Driver must use METHOD_BUFFERED or METHOD_xx_DIRECT "
1678 "I/O for this call, or use "
1679 "WdfDeviceInitSetIoInCallerContextCallback to probe and "
1680 "lock user mode memory");
1681 }
1682 break;
1683 }
1684
1685 if (mapMdl && (m_RequestBaseFlags & FxRequestBaseOutputMdlMapped) == 0x0) {
1686 PMDL pMdl;
1687 PVOID pVA;
1688
1689
1690 pMdl = m_Irp.GetMdl();
1691
1692 if (pMdl == NULL) {
1693 //
1694 // Zero length transfer
1695 //
1697
1700 "WDFREQUEST 0x%p, METHOD_IN_DIRECT IOCTL PMDL is NULL, "
1701 "%!STATUS!", GetHandle(), status);
1702
1703 ASSERT(
1705 );
1706 }
1707 else {
1708 //
1709 // PagePriority may need to be a property, and/or parameter to
1710 // this call
1711 //
1712 //
1713 // Upon success, MmGetSystemAddressForMdlSafe stores the mapped
1714 // VA pointer in the pMdl and upon subsequent calls to
1715 // MmGetSystemAddressForMdlSafe, no mapping is done, just
1716 // the stored VA is returned. FxRequestOutputBuffer relies
1717 // on this behavior and, more importantly, relies on this function
1718 // to do the initial mapping so that FxRequestOutputBuffer::GetBuffer()
1719 // will not return a NULL pointer.
1720 //
1722
1723 if (pVA == NULL) {
1725
1728 "WDFREQUEST 0x%p could not get a system address for PMDL"
1729 "0x%p, %!STATUS!", GetHandle(), pMdl, status);
1730 }
1731 else {
1732 m_OutputBuffer.SetMdl(pMdl);
1735 }
1736 }
1737 }
1738
1739Done:
1741 Unlock(irql);
1742 }
1743
1744 if (NT_SUCCESS(status)) {
1746 if (mapMdl) {
1749 }
1750 else {
1752 }
1753 *Length = length;
1754 }
1755
1756 return status;
1757}
unsigned char BOOLEAN
Definition: bufpool.h:45
static __inline PVOID MxGetSystemAddressForMdlSafe(__inout PMDL Mdl, __in ULONG Priority)
Definition: mxgeneralkm.h:366
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
@ NormalPagePriority
Definition: imports.h:56
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
__inline VOID SetMdl(__in PMDL Mdl)
Definition: fxrequest.hpp:344
_Must_inspect_result_ _In_ WDFREQUEST _In_ size_t _Out_ WDFMEMORY * MemoryObject
Definition: wdfrequest.h:1473

Referenced by if().

◆ GetFileObject()

_Must_inspect_result_ NTSTATUS FxRequest::GetFileObject ( __deref_out_opt FxFileObject **  pFileObject)

Definition at line 2408 of file fxrequest.cpp.

2411{
2413 FxFileObject* pFileObject;
2416
2417 pFileObject = NULL;
2419
2420 pDevice = GetDevice();
2421
2423 KIRQL irql;
2424 *FileObject = NULL;
2425
2426 Lock(&irql);
2427 status = VerifyRequestIsNotCompleted(pFxDriverGlobals);
2428
2429 Unlock(irql);
2430 if (!NT_SUCCESS(status)) {
2431 return status;
2432 }
2433
2434 }
2435
2436 if (NULL == m_Irp.GetFileObject() && IsAllocatedDriver()) {
2438 //
2439 // This is a 'must_complete' driver created request.
2440 //
2441 *FileObject = NULL;
2442 return STATUS_SUCCESS;
2443 }
2444
2446 pDevice,
2449 &pFileObject
2450 );
2451
2452 if (NT_SUCCESS(status) && pFileObject != NULL) {
2453 *FileObject = pFileObject;
2454 return STATUS_SUCCESS;
2455 }
2456 else if (NT_SUCCESS(status) &&
2458 //
2459 // Driver told us that it is ok for the file object to be NULL.
2460 //
2461 *FileObject = NULL;
2462 return STATUS_SUCCESS;
2463 }
2464 else {
2466 }
2467}
__inline WDF_FILEOBJECT_CLASS GetFileObjectClass(VOID)
Definition: fxdevice.hpp:1123
static _Must_inspect_result_ NTSTATUS _GetFileObjectFromWdm(__in FxDevice *pDevice, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt MdFileObject pWdmFileObject, __deref_out_opt FxFileObject **ppFxFileObject)
MdFileObject GetFileObject(VOID)
Definition: fxirpum.cpp:1460
BOOLEAN m_CanComplete
BOOLEAN __inline IsAllocatedDriver(VOID)
FxDevice * pDevice
BOOLEAN __inline FxIsFileObjectOptional(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:112
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

◆ GetFxIrp()

◆ GetInformation()

ULONG_PTR FxRequest::GetInformation ( VOID  )

Definition at line 277 of file fxrequest.cpp.

296{
298
300
301 // Verifier
304 KIRQL irql;
306
307 Lock(&irql);
308
309 status = VerifyRequestIsNotCompleted(pFxDriverGlobals);
310 if (!NT_SUCCESS(status)) {
311 info = NULL;
312 }
313 else {
315 }
316
317 Unlock(irql);
318
319 return info;
320 }
321 else {
322 return m_Irp.GetInformation();
323 }
324}

◆ GetInternalContext()

__inline PVOID FxRequest::GetInternalContext ( VOID  )
inline

Definition at line 1492 of file fxrequest.hpp.

1495 {
1496 PVOID context;
1497
1500
1501 return context;
1502 }
Definition: http.c:7252

Referenced by FxPkgIo::EnqueueRequest().

◆ GetIoQueue()

__inline FxIoQueue * FxRequest::GetIoQueue ( VOID  )
inline

Definition at line 966 of file fxrequest.hpp.

969 {
970 return m_IoQueue;
971 }

◆ GetIrp()

_Must_inspect_result_ NTSTATUS FxRequest::GetIrp ( __deref_out MdIrp ppIrp)
inline

Definition at line 975 of file fxrequest.hpp.

978 {
979 if (GetDriverGlobals()->FxVerifierIO) {
981 KIRQL irql;
982
983 Lock(&irql);
984
985 status = VerifyRequestIsNotCompleted(GetDriverGlobals());
986 if (!NT_SUCCESS(status)) {
987 *ppIrp = NULL;
989 }
990 else {
991 *ppIrp = m_Irp.GetIrp();
992 }
993
994 Unlock(irql);
995
996 return status;
997 }
998 else {
999 *ppIrp = m_Irp.GetIrp();
1000 return STATUS_SUCCESS;
1001 }
1002 }

Referenced by Impersonate(), and FxIoQueue::QueueRequest().

◆ GetListEntry()

__inline PLIST_ENTRY FxRequest::GetListEntry ( __in FxListEntryNames  Index)
inline

Definition at line 475 of file fxrequest.hpp.

478 {
479 switch (Index) {
483 default: ASSERT(FALSE); return NULL;
484 }
485 }

Referenced by FxIoQueue::CancelForDriver().

◆ GetMdl()

_Must_inspect_result_ NTSTATUS FxRequest::GetMdl ( __out PMDL pMdl)

Definition at line 80 of file fxrequestkm.cpp.

83{
84 WDF_DEVICE_IO_TYPE ioType;
89 KIRQL irql;
90 PMDL pNewMdl;
92
93 pBuffer = NULL;
94 length = 0;
96
97 Lock(&irql);
98
99 // Verifier
101
102 status = VerifyRequestIsNotCompleted(pFxDriverGlobals);
103 if(!NT_SUCCESS(status)) {
104 Unlock(irql);
105 return status;
106 }
107 }
108
109 //
110 // See if we have an IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL
111 //
113
116
118 case METHOD_BUFFERED:
121
122 // Fall through to common buffer handler
123 break;
124
125 case METHOD_IN_DIRECT:
126 //
127 // InputBuffer is in SystemBuffer
128 // OutputBuffer is in MdlAddress with read access
129 //
132
133 // Fall through to common buffer handler
134 break;
135
137 //
138 // InputBuffer is in SystemBuffer
139 // OutputBuffer is in MdlAddress with write access
140 //
143
144 // Fall through to common buffer handler
145
146 break;
147
148 case METHOD_NEITHER:
149 default:
153 "Attempt to get UserMode MDL for METHOD_NEITHER DeviceControl 0x%x, "
154 "WDFDEVICE 0x%p, WDFREQUEST 0x%p, %!STATUS!",
157
160 "Driver must use METHOD_BUFFERED or METHOD_xx_DIRECT "
161 "I/O for this call, or use "
162 "WdfDeviceInitSetIoInCallerContextCallback to probe "
163 "and lock user mode memory");
164
165 *pMdl = NULL;
166 Unlock(irql);
167
168 return status;
169 }
170 }
171 else {
172 //
173 // It's a non-Device Control request, we must know the devices I/O type in
174 // order to safely return the correct buffer
175 //
176 ioType = GetDevice()->GetIoType();
177
178 if (ioType == WdfDeviceIoBuffered) {
179
181
182 //
183 // Must get the length depending on the request type code
184 //
185 if (majorFunction == IRP_MJ_READ) {
187 }
188 else if (majorFunction == IRP_MJ_WRITE) {
190 }
191 else {
192 //
193 // Report the error, we can support other IRP_MJ_xxx codes are required
194 // later
195 //
197
200 "WDFREQUEST %p no Automatic MDL mapping for buffered request"
201 "major function 0x%x available for WDFDEVICE 0x%p, %!STATUS!",
203 status);
204
205 *pMdl = NULL;
206
207 Unlock(irql);
208
209 return status;
210 }
211
212 // Fall through to common buffer handler
213 }
214 else if (ioType == WdfDeviceIoDirect) {
215
216 //
217 // If driver has used the default DO_DIRECT_IO I/O Mgr has done all the work
218 //
219 *pMdl = m_Irp.GetMdl();
220
221 if (*pMdl == NULL) {
223
226 "WDFREQUEST 0x%p for a direct io device, PMDL is NULL, "
227 "%!STATUS!", GetHandle(), status);
228 }
229 else {
231 }
232
233 Unlock(irql);
234
235 return status;
236 }
237 else if (ioType == WdfDeviceIoNeither) {
239
242 "Attempt to get UserMode Buffer Pointer for "
243 "WDFDEVICE 0x%p, WDFREQUEST 0x%p, %!STATUS!",
245
248 "Driver must use buffered or direct I/O for this "
249 "call, or use WdfDeviceInitSetIoInCallerContextCallback "
250 "to probe and lock user mode memory");
252
253 *pMdl = NULL;
254 Unlock(irql);
255
256 return status;
257 }
258 else {
260
263 "Unrecognized I/O Type %d on WDFDEVICE 0x%p, WDFREQUEST 0x%p, "
264 "%!STATUS!",
265 ioType, GetDevice()->GetHandle(), GetHandle(), status);
267
268 *pMdl = NULL;
269 Unlock(irql);
270
271 return status;
272 }
273 }
274
275 //
276 // if pBuffer != NULL, attempt to generate an MDL for it
277 //
278 if( (pBuffer == NULL) || (length == 0) ) {
279 *pMdl = NULL;
280 Unlock(irql);
281
283
284 if (pBuffer == NULL) {
287 "WDFREQUEST 0x%p, SystemBuffer is NULL, %!STATUS!",
288 GetHandle(), status);
289 }
290 else if (length == 0) {
293 "WDFREQUEST 0x%p, SystemBuffer length is 0, %!STATUS!",
294 GetHandle(), status);
295 }
296
297 return status;
298 }
299
300 //
301 // See if we have already allocated an MDL for this
302 //
303 if( m_AllocatedMdl != NULL ) {
304 *pMdl = m_AllocatedMdl;
305 Unlock(irql);
306 return STATUS_SUCCESS;
307 }
308
310 this,
311 pBuffer,
312 length,
313 FALSE,
314 FALSE);
315
316 if (pNewMdl == NULL) {
318
321 "Could not allocate MDL for buffer 0x%p Length %d, %!STATUS!",
323 *pMdl = NULL;
324 Unlock(irql);
325
326 return status;
327 }
328
330
331 //
332 // We associated the Mdl with the request object
333 // so it can be freed when completed.
334 //
335 m_AllocatedMdl = pNewMdl;
336
337 *pMdl = pNewMdl;
338
339 Unlock(irql);
340
341 return STATUS_SUCCESS;
342}
ULONG GetParameterWriteLength(VOID)
Definition: fxirpum.cpp:1601
ULONG GetParameterIoctlInputBufferLength(VOID)
Definition: fxirpum.cpp:1518
ULONG GetParameterReadLength(VOID)
Definition: fxirpum.cpp:1589
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
enum _WDF_DEVICE_IO_TYPE WDF_DEVICE_IO_TYPE
@ WdfDeviceIoDirect
Definition: wdfdevice.h:453

Referenced by switch().

◆ GetMemoryHandle()

WDFMEMORY FxRequest::GetMemoryHandle ( __in USHORT  Offset)
inlineprotected

Definition at line 658 of file fxrequest.hpp.

661 {
663
664 //
665 // The offset into this object must be self relative.
666 //
668
670
671 //
672 // Make sure initial value has the flag bits cleared.
673 //
675
676 //
677 // We always apply the mask.
678 //
680
681 //
682 // Make sure final value (before we set the flag) has the flag bits
683 // cleared.
684 //
686
687 //
688 // This handle is an offset
690
691 return (WDFMEMORY) handle;
692 }
#define ULONG_PTR
Definition: config.h:101
@ FxHandleFlagIsOffset
Definition: fxobject.hpp:61
DECLSPEC_SELECTANY const ULONG_PTR FxHandleValueMask
uint16_t * PUSHORT
Definition: typedefs.h:56
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144

Referenced by FxRequestSystemBuffer::GetHandle(), and FxRequestOutputBuffer::GetHandle().

◆ GetMemoryObject()

_Must_inspect_result_ NTSTATUS FxRequest::GetMemoryObject ( __deref_out IFxMemory **  Memory,
__out PVOID Buffer,
__out size_t Length 
)

Definition at line 1284 of file fxrequest.cpp.

1289{
1290 PMDL pMdl;
1292 ULONG length;
1293 KIRQL irql;
1294 BOOLEAN mapMdl;
1296
1298 length = 0x0;
1299 mapMdl = FALSE;
1302
1303
1304 //
1305 // Verifier
1306 //
1307 if (GetDriverGlobals()->FxVerifierIO) {
1308 status = VerifyRequestIsNotCompleted(GetDriverGlobals());
1309 if (!NT_SUCCESS(status)) {
1310 goto Done;
1311 }
1313 &&
1316 &&
1317 GetDevice()->GetIoType() == WdfDeviceIoNeither) {
1319
1322 "Attempt to get UserMode Buffer Pointer for WDFDEVICE 0x%p, "
1323 "WDFREQUEST 0x%p, %!STATUS!",
1325
1328 "Driver must use buffered or direct I/O for this call, or use "
1329 "WdfDeviceInitSetIoInCallerContextCallback to probe and lock "
1330 "user mode memory");
1331
1333 }
1334 }
1335
1337 Lock(&irql);
1338 }
1339
1340 //
1341 // We must dig into the IRP to get the buffer, length, and readonly status
1342 //
1343
1344 switch (majorFunction) {
1348
1349 if (length == 0) {
1351
1354 "WDFREQUEST %p InputBufferLength length is zero, %!STATUS!",
1356
1357 goto Done;
1358 }
1359
1361 //
1362 // Internal device controls are kernel mode to kernel mode, and deal
1363 // with direct unmapped pointers.
1364 //
1365 // In addition, a normal device control with
1366 // RequestorMode == KernelMode is also treated as kernel mode
1367 // to kernel mode since the I/O Manager will not generate requests
1368 // with this setting from a user mode request.
1369 //
1370 if ((m_Irp.GetRequestorMode() == KernelMode) ||
1372 DO_NOTHING();
1373 }
1374 else {
1376
1379 "Attempt to get UserMode Buffer Pointer for METHOD_NEITHER "
1380 "DeviceControl 0x%x, WDFDEVICE 0x%p, WDFREQUEST 0x%p, "
1381 "%!STATUS!",
1384
1387 "Driver must use METHOD_BUFFERED or METHOD_xx_DIRECT I/O for "
1388 "this call, or use WdfDeviceInitSetIoInCallerContextCallback to "
1389 "probe and lock user mode memory %!STATUS!",
1391
1392 goto Done;
1393 }
1394 }
1395 break;
1396
1397 case IRP_MJ_READ:
1399
1400 if (GetDevice()->GetIoTypeForReadWriteBufferAccess() == WdfDeviceIoDirect) {
1402 mapMdl = TRUE;
1403 }
1404 break;
1405
1406 case IRP_MJ_WRITE:
1408
1409 if (GetDevice()->GetIoTypeForReadWriteBufferAccess() == WdfDeviceIoDirect) {
1411 mapMdl = TRUE;
1412 }
1413 break;
1414
1415 default:
1418 "Unrecognized Major Function 0x%x on WDFDEVICE 0x%p WDFREQUEST 0x%p",
1420
1422
1424 goto Done;
1425 }
1426
1427 if (length == 0) {
1429
1432 "WDFREQUEST 0x%p length is zero, %!STATUS!",
1433 GetHandle(), status);
1434
1435 goto Done;
1436 }
1437
1438 //
1439 // See if we need to map
1440 //
1441 if (mapMdl && (m_RequestBaseFlags & FxRequestBaseSystemMdlMapped) == 0x00) {
1442 pMdl = m_Irp.GetMdl();
1443
1444 if (pMdl == NULL) {
1445 //
1446 // Zero length transfer
1447 //
1449
1452 "WDFREQUEST 0x%p, direct io device, PMDL is NULL, "
1453 "%!STATUS!", GetHandle(), status);
1454
1455 ASSERT(length == 0);
1456 }
1457 else {
1458 PVOID pVA;
1459
1460 //
1461 // PagePriority may need to be a property, and/or parameter to
1462 // this call
1463 //
1464 //
1465 // Upon success, MmGetSystemAddressForMdlSafe stores the mapped
1466 // VA pointer in the pMdl and upon subsequent calls to
1467 // MmGetSystemAddressForMdlSafe, no mapping is done, just
1468 // the stored VA is returned. FxRequestSystemBuffer relies
1469 // on this behavior and, more importantly, relies on this function
1470 // to do the initial mapping so that FxRequestSystemBuffer::GetBuffer()
1471 // will not return a NULL pointer.
1472 //
1474
1475 if (pVA == NULL) {
1477
1480 "WDFREQUEST 0x%p could not get a system address for PMDL "
1481 "0x%p, %!STATUS!", GetHandle(), pMdl, status);
1482 }
1483 else {
1484 //
1485 // System will automatically release the mapping PTE's when
1486 // the MDL is released by the I/O request
1487 //
1488
1489
1490
1491
1492
1494
1496 }
1497 }
1498 }
1499
1500Done:
1502 Unlock(irql);
1503 }
1504
1505 if (NT_SUCCESS(status)) {
1507
1508 if (mapMdl) {
1511 }
1512 else {
1514 }
1515
1516 *Length = length;
1517 }
1518
1519 return status;
1520}
__inline VOID SetMdl(PMDL Mdl)
Definition: fxrequest.hpp:198

◆ GetNextRequest() [1/2]

_Must_inspect_result_ FxRequest * FxRequest::GetNextRequest ( __in FxIrpQueue IrpQueue)
static

Definition at line 2025 of file fxrequest.cpp.

2028{
2029 MdIrp pIrp;
2032
2033 pIrp = IrpQueue->GetNextRequest(&pCsqContext);
2034
2035 if (pIrp == NULL) {
2036 return NULL;
2037 }
2038
2039 // Irp is not cancellable now
2041
2042 // Must tell the request it's off the queue
2044
2045 // Remove reference placed when on IrpQueue
2046 pRequest->RELEASE(FXREQUEST_QUEUE_TAG);
2047
2048 return pRequest;
2049}
static __inline FxRequest * RetrieveFromCsqContext(__in PMdIoCsqIrpContext pCsqContext)
Definition: fxrequest.hpp:1163
__inline VOID MarkRemovedFromIrpQueue(VOID)
Definition: fxrequest.hpp:1100
LIST_ENTRY IrpQueue
Definition: csqrtns.c:49
__in MdIrp __in PMdIoCsqIrpContext pCsqContext
Definition: fxirpqueue.hpp:75
#define FXREQUEST_QUEUE_TAG
Definition: fxrequest.hpp:47

Referenced by _Releases_lock_(), FxIoQueue::FlushByFileObject(), FxIoQueue::GetRequest(), FxIoQueue::QueueIdle(), and FxIoQueue::QueuePurge().

◆ GetNextRequest() [2/2]

_Must_inspect_result_ NTSTATUS FxRequest::GetNextRequest ( __in FxIrpQueue IrpQueue,
__in_opt MdFileObject  FileObject,
__in_opt FxRequest TagRequest,
__deref_out FxRequest **  ppOutRequest 
)
static

Definition at line 2057 of file fxrequest.cpp.

2063{
2066 PMdIoCsqIrpContext TagCsqContext;
2067
2068 if( TagRequest != NULL ) {
2069 TagCsqContext = TagRequest->GetCsqContext();
2070 }
2071 else {
2072 TagCsqContext = NULL;
2073 }
2074
2075 Status = IrpQueue->GetNextRequest( TagCsqContext, FileObject, &pRequest );
2076 if( !NT_SUCCESS(Status) ) {
2077 return Status;
2078 }
2079
2080 // Irp is not cancellable now
2081
2082 // Must tell the request its off the queue
2084
2085 // Remove reference placed when on IrpQueue
2086 pRequest->RELEASE(FXREQUEST_QUEUE_TAG);
2087
2088 *ppOutRequest = pRequest;
2089
2090 return STATUS_SUCCESS;
2091}

◆ GetParameters()

_Must_inspect_result_ NTSTATUS FxRequest::GetParameters ( __out PWDF_REQUEST_PARAMETERS  Parameters)

Definition at line 1221 of file fxrequest.cpp.

1224{
1226
1228
1229 //
1230 // No lock needed. Only reason this may be invalid is due
1231 // to previous completion, which is a serious driver bug
1232 // that will result in a crash anyway.
1233 //
1234
1236 KIRQL irql;
1238
1239 Lock(&irql);
1240
1241 status = VerifyRequestIsCurrentStackValid(pFxDriverGlobals);
1242 if (NT_SUCCESS(status)) {
1243 status = VerifyRequestIsNotCompleted(pFxDriverGlobals);
1244 }
1245
1246 Unlock(irql);
1247
1248 if (!NT_SUCCESS(status)) {
1249 return status;
1250 }
1251 }
1252
1253 ASSERT(Parameters->Size >= sizeof(WDF_REQUEST_PARAMETERS));
1254
1255 // How much we copied
1256 Parameters->Size = sizeof(WDF_REQUEST_PARAMETERS);
1257
1258
1259 // Copy parameters
1261 Parameters->MinorFunction = m_Irp.GetMinorFunction();
1262
1263 // Copy the Parameters structure which we are a subset of
1265
1267 //
1268 // If verifier is on, and the operation is an IRP_MJ_DEVICE_CONTROL
1269 // with METHOD_NEITHER, then set Type3InputBuffer to zero since
1270 // this should not be used to pass parameters in the normal path
1271 //
1274 Parameters->Parameters.DeviceIoControl.Type3InputBuffer = NULL;
1275 }
1276 }
1277
1278 return STATUS_SUCCESS;
1279}
VOID CopyParameters(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: fxirpum.cpp:1691
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
enum _WDF_REQUEST_TYPE WDF_REQUEST_TYPE
struct _WDF_REQUEST_PARAMETERS WDF_REQUEST_PARAMETERS

◆ GetRequestorMode()

KPROCESSOR_MODE FxRequest::GetRequestorMode ( VOID  )

Definition at line 327 of file fxrequest.cpp.

342{
344
346
349 KIRQL irql;
351
352 Lock(&irql);
353
354 status = VerifyRequestIsNotCompleted(pFxDriverGlobals);
355 if (!NT_SUCCESS(status)) {
356 mode = UserMode;
357 } else {
359 }
360
361 Unlock(irql);
362
363 return mode;
364 }
365 else {
366 return m_Irp.GetRequestorMode();
367 }
368}
GLenum mode
Definition: glext.h:6217
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7

◆ GetStatus()

NTSTATUS FxRequest::GetStatus ( VOID  )

Definition at line 1187 of file fxrequest.cpp.

1190{
1193
1195
1197 KIRQL irql;
1198
1199 Lock(&irql);
1200
1201
1202
1203
1204
1205
1206
1207
1209
1210 Unlock(irql);
1211
1212 return status;
1213 }
1214 else {
1215 return m_Irp.GetStatus();
1216 }
1217}
NTSTATUS GetStatus()
Definition: fxirpum.cpp:466

◆ Impersonate()

NTSTATUS FxRequest::Impersonate ( _In_ SECURITY_IMPERSONATION_LEVEL  ImpersonationLevel,
_In_ PFN_WDF_REQUEST_IMPERSONATE  EvtRequestImpersonate,
_In_opt_ PVOID  Context 
)

Definition at line 226 of file fxrequestum.cpp.

231{
232 DDI_ENTRY();
233
235 HRESULT hr;
236 MdIrp irp;
237
238 status = GetIrp(&irp);
239 if (!NT_SUCCESS(status)) {
241 "WDFREQUEST is already completed 0x%p, %!STATUS!",
242 GetHandle(), status);
244 return status;
245 }
246
247 hr = irp->ImpersonateRequestorProcess(ImpersonationLevel);
248
249 if (SUCCEEDED(hr)) {
252 irp->RevertImpersonation();
253 }
254 else {
255 status = GetDevice()->NtStatusFromHr(hr);
257 "WDFREQUEST 0x%p, Could not impersonate, %!STATUS!",
258 GetHandle(), status);
259 }
260
261 return status;
262}
_Must_inspect_result_ NTSTATUS GetIrp(__deref_out MdIrp *ppIrp)
Definition: fxrequest.hpp:975
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
_Must_inspect_result_ _In_ WDFREQUEST _In_ SECURITY_IMPERSONATION_LEVEL _In_ PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT hr
Definition: shlfolder.c:183
_Out_ PBOOLEAN _Out_ PBOOLEAN _Out_ PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: psfuncs.h:156

◆ InsertHeadIrpQueue()

_Must_inspect_result_ NTSTATUS FxRequest::InsertHeadIrpQueue ( __in FxIrpQueue IrpQueue,
__out_opt ULONG pRequestCount 
)

Definition at line 1908 of file fxrequest.cpp.

1912{
1915
1917
1918 // No locking required since only one accessor till inserted on queue
1919
1920 status = VerifyInsertIrpQueue(pFxDriverGlobals, IrpQueue);
1921 if (!NT_SUCCESS(status)) {
1922 return status;
1923 }
1924
1925 //
1926 // If a request is on an IrpQueue, it must be referenced
1927 //
1928
1929
1930
1931
1932
1933
1935
1938
1940
1941 status = IrpQueue->InsertHeadRequest(m_Irp.GetIrp(),
1942 &m_CsqContext,
1943 pRequestCount);
1944
1945 //
1946 // If this insert failed, we must release the extra reference we took
1947 //
1948 if (!NT_SUCCESS(status)) {
1951 }
1952
1953 return status;
1954}
#define ADDREF(_tag)
Definition: fxobject.hpp:49
#define RELEASE(_tag)
Definition: fxobject.hpp:50

Referenced by FxIoQueue::Requeue().

◆ InsertTailIrpQueue()

_Must_inspect_result_ NTSTATUS FxRequest::InsertTailIrpQueue ( __in FxIrpQueue IrpQueue,
__out_opt ULONG pRequestCount 
)

Definition at line 1858 of file fxrequest.cpp.

1862{
1865
1867
1868 // No locking required since only one accessor till inserted on queue
1869
1870 status = VerifyInsertIrpQueue(pFxDriverGlobals, IrpQueue);
1871 if (!NT_SUCCESS(status)) {
1872 return status;
1873 }
1874
1875 //
1876 // If a request is on an IrpQueue, it must be referenced
1877 //
1878
1879
1880
1881
1882
1883
1885
1888
1890
1891 status = IrpQueue->InsertTailRequest(m_Irp.GetIrp(),
1892 &m_CsqContext,
1893 pRequestCount);
1894
1895 //
1896 // If this insert failed, we must release the extra reference we took
1897 //
1898 if (!NT_SUCCESS(status)) {
1901 }
1902
1903 return status;
1904}

Referenced by FxIoQueue::QueueRequestFromForward(), and FxIoQueue::RequestCancelable().

◆ IsCancelled()

__inline BOOLEAN FxRequest::IsCancelled ( VOID  )
inline

Definition at line 525 of file fxrequest.hpp.

528 {
529 return m_Irp.IsCanceled() || m_Canceled;
530 }
BOOLEAN IsCanceled()
Definition: fxirpum.cpp:484

◆ IsInIrpQueue()

__inline BOOLEAN FxRequest::IsInIrpQueue ( __in FxIrpQueue pIrpQueue)
inline

Definition at line 1173 of file fxrequest.hpp.

1176 {
1177 return pIrpQueue->IsIrpInQueue(GetCsqContext());
1178 }
__inline PMdIoCsqIrpContext GetCsqContext(VOID)
Definition: fxrequest.hpp:1113

◆ IsPowerStopAcknowledged()

__inline BOOLEAN FxRequest::IsPowerStopAcknowledged ( VOID  )
inline

Definition at line 1195 of file fxrequest.hpp.

1198 {
1200 ||
1202 }
@ FxRequestPowerStopAcknowledged
Definition: fxrequest.hpp:388
@ FxRequestPowerStopAcknowledgedWithRequeue
Definition: fxrequest.hpp:391

◆ IsPowerStopAcknowledgedWithRequeue()

__inline BOOLEAN FxRequest::IsPowerStopAcknowledgedWithRequeue ( VOID  )
inline

Definition at line 1206 of file fxrequest.hpp.

◆ IsRequestForwardedToParent()

__inline BOOLEAN FxRequest::IsRequestForwardedToParent ( VOID  )
inline

Definition at line 1316 of file fxrequest.hpp.

1319 {
1321 }

Referenced by FxRequestFromLookaside::SelfDestruct().

◆ IsReserved()

__inline BOOLEAN FxRequest::IsReserved ( )
inline

◆ MarkRemovedFromIrpQueue()

__inline VOID FxRequest::MarkRemovedFromIrpQueue ( VOID  )
inline

Definition at line 1100 of file fxrequest.hpp.

1103 {
1104 m_IrpQueue = NULL;
1105 return;
1106 }

Referenced by FxIoQueue::CancelForDriver(), GetNextRequest(), InsertHeadIrpQueue(), InsertTailIrpQueue(), and RemoveFromIrpQueue().

◆ PeekRequest()

_Must_inspect_result_ NTSTATUS FxRequest::PeekRequest ( __in FxIrpQueue IrpQueue,
__in_opt FxRequest TagRequest,
__in_opt MdFileObject  FileObject,
__out_opt PWDF_REQUEST_PARAMETERS  Parameters,
__deref_out FxRequest **  ppOutRequest 
)
static

Definition at line 2098 of file fxrequest.cpp.

2105{
2107
2108 PMdIoCsqIrpContext TagContext = NULL;
2109
2110 //
2111 // IrpQueue::PeekRequest works with CSQ_CONTEXT
2112 // structures since this is the only value that
2113 // is valid across cancellation.
2114 //
2115 if( TagRequest != NULL ) {
2116 TagContext = TagRequest->GetCsqContext();
2117 }
2118
2119 Status = IrpQueue->PeekRequest(
2120 TagContext,
2121 FileObject,
2122 ppOutRequest
2123 );
2124 if(NT_SUCCESS(Status)) {
2125
2126 if( Parameters != NULL ) {
2127 Status = (*ppOutRequest)->GetParameters(Parameters);
2128 }
2129 }
2130
2131 return Status;
2132}

Referenced by FxIoQueue::PeekRequest(), and FxIoQueue::QueueIdle().

◆ PostProcessCompletion()

VOID FxRequest::PostProcessCompletion ( __in FxRequestCompletionState  State,
__in FxIoQueue Queue 
)
private

Definition at line 874 of file fxrequest.cpp.

878{
879 //
880 // Fire frameworks internal callback event if one is set
881 // (FxIoQueue or IoTarget's internal use)
882 //
884 //
885 // NOTE: This occurs after the IRP has already been released,
886 // and is only used for notification that the request
887 // has completed.
888 //
890 GetDevice()->m_PkgIo->RequestCompletedCallback(this);
891 }
892 else {
893 ASSERT(Queue != NULL);
894 Queue->RequestCompletedCallback(this);
895 //FxIoQueueToMx::RequestCompletedCallback(Queue, this);
896 }
897
898 //
899 // DeleteObject will dereference the object reference taken when the callback
900 // was registered
901 //
903 }
904 else {
905 //
906 // Caller still wants the FxRequest class to be valid on return,
907 // but must call DeleteObject in order to ensure the object is
908 // no longer assigned any child objects, etc.
909 //
911 DeleteObject();
912 }
913}
VOID DeleteEarlyDisposedObject(VOID)
#define FXREQUEST_COMPLETE_TAG
Definition: fxrequest.hpp:52
@ FxRequestCompletionStateIoPkgFlag
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2225

Referenced by CompleteInternal(), and PostProcessSendAndForget().

◆ PostProcessCompletionForDriverRequest()

VOID FxRequest::PostProcessCompletionForDriverRequest ( __in FxRequestCompletionState  State,
__in FxIoQueue Queue 
)
private

Definition at line 996 of file fxrequest.cpp.

1000{
1001 //
1002 // NOTE: Do not touch the request object here. The request object may already be
1003 // re-used or deleted.
1004 //
1005
1008 //
1009 // Fire frameworks internal callback (post) event if one is set.
1010 //
1012 //
1013 // NOTE: This occurs after the IRP has already been released, and is only used
1014 // to notify the queue to update its internal state and if appropriate, send
1015 // another request.
1016 //
1017 Queue->PostRequestCompletedCallback(this);
1018 }
1019}
@ FxRequestCompletionStateQueue

Referenced by Release().

◆ PostProcessCompletionForReserved()

VOID FxRequest::PostProcessCompletionForReserved ( __in FxRequestCompletionState  State,
__in FxIoQueue Queue 
)
private

Definition at line 916 of file fxrequest.cpp.

920{
921 //
922 // Fire frameworks internal callback event if one is set
923 // (FxIoQueue or IoTarget's internal use)
924 //
926 //
927 // NOTE: This occurs after the IRP has already been released,
928 // and is only used for notification that the request
929 // has completed.
930 //
932 GetDevice()->m_PkgIo->RequestCompletedCallback(this);
933 }
934 else {
936 Queue->RequestCompletedCallback(this);
937 }
938 }
939 else {
940 //
941 // Caller still wants the FxRequest class to be valid on return,
942 // but must call DeleteObject in order to ensure the object is
943 // no longer assigned any child objects, etc.
944 //
946 }
947
949}
#define FXREQUEST_FWDPRG_TAG
Definition: fxrequest.hpp:63

Referenced by CompleteInternal(), and PostProcessSendAndForget().

◆ PostProcessSendAndForget()

VOID FxRequest::PostProcessSendAndForget ( VOID  )

Definition at line 1149 of file fxrequest.cpp.

1152{
1155
1156 m_Irp.SetIrp(NULL);
1157
1158 //
1159 // Capture the m_IoQueue value before making any other calls.
1160 // Note: m_IoQueue could be NULL if the request is freed before it's queued.
1161 //
1162 pQueue = m_IoQueue;
1163
1165
1168
1169 //
1170 // Technically we did not complete the irp, but a send and forget is
1171 // functionally the same. We no longer own the irp.
1172 //
1173 if (IsReserved() == FALSE) {
1175 }
1176 else {
1177 //
1178 // Release checks m_Completed flag to decide whether to return
1179 // the request to reserved pool.
1180 //
1181 m_Completed = TRUE;
1183 }
1184}
FxIoQueue * pQueue

Referenced by FxPkgIo::EnqueueRequest().

◆ PreProcessCompletionForDriverRequest()

VOID FxRequest::PreProcessCompletionForDriverRequest ( __in FxRequestCompletionState  State,
__in FxIoQueue Queue 
)
private

Definition at line 955 of file fxrequest.cpp.

959{
962 //
963 // Fire frameworks internal callback (pre) event if one is set.
964 //
966 //
967 // NOTE: This occurs before the IRP has already been released,
968 // and is only used to notify the queue to remove this request from this queue's
969 // internal lists. A second notification (lPostProcessCompletionForAllocatedDriver)
970 // is made after the IRP is completed.
971 //
972 Queue->PreRequestCompletedCallback(this);
973 }
974 else if (Queue != NULL){
975 //
976 // On return from PostProcessCompletionForDriverRequest, caller (framework)
977 // will try to release the last ref. Increase the ref count so request stays alive until
978 // driver invokes WdfObjectDelete on this request.
979 //
981 }
982
983 //
984 // Let the system know that it is OK to complete this request.
985 //
987}
#define FXREQUEST_DCRC_TAG
Definition: fxrequest.hpp:69

Referenced by CompleteInternal().

◆ PreProcessSendAndForget()

VOID FxRequest::PreProcessSendAndForget ( VOID  )

Definition at line 1101 of file fxrequest.cpp.

1104{
1105 VerifyPreProcessSendAndForget(GetDriverGlobals());
1106
1107 //
1108 // To be sent and forgotten, the irp must have been presented
1109 //
1111
1112 //
1113 // To be sent and forgotten, the irp must not have a formatted IO context.
1114 //
1115 ASSERT(HasContext() == FALSE);
1116
1117 //
1118 // If the driver writer setup the next stack location using the current
1119 // stack location or did a manual IO_STACK_LOCATION copy, we do not want to
1120 // skip the current stack location that their format is used by the target
1121 // driver.
1122 //
1125 }
1126
1127 if (IsReserved() == FALSE) {
1128
1129 //
1130 // If a cleanup callback has been registered, we call it
1131 // just before sending the IRP on its way. The contract is that the cleanup
1132 // routine for a WDFREQUEST is called while the PIRP is still valid.
1133 //
1134 if (EarlyDispose() == FALSE) {
1135 VerifierBreakpoint_RequestEarlyDisposeDeferred(GetDriverGlobals());
1136 }
1137
1138 //
1139 // Now that the entire tree is disposed, we want to destroy all of the
1140 // children. This will not put this object in the destroyed state. For
1141 // m_IrpReferenceCount to go to zero, we need to destroy the child WDFMEMORYs
1142 // that were created when we probed and locked the buffers.
1143 //
1145 }
1146}
VOID SkipCurrentIrpStackLocation(VOID)
Definition: fxirpum.cpp:400
__inline BOOLEAN HasContext(VOID)
BOOLEAN m_NextStackLocationFormatted

Referenced by FxPkgIo::EnqueueRequest().

◆ ProbeAndLockForRead()

_Must_inspect_result_ NTSTATUS FxRequest::ProbeAndLockForRead ( __in PVOID  Buffer,
__in ULONG  Length,
__deref_out FxRequestMemory **  pMemoryObject 
)

Definition at line 588 of file fxrequestkm.cpp.

625{
627 PMDL pMdl;
628 PIRP irp;
629 PVOID pVA;
632
633 pMdl = NULL;
634 pMemory = NULL;
636
637 if (Length == 0) {
639
642 "Length of zero not allowed, %!STATUS!", status);
643
644 return status;
645 }
646
647 irp = m_Irp.GetIrp();
648
649 if (irp == NULL) {
651
652 // Error, completed request
655 "WDFREQUEST %p has already been completed or has no PIRP assignment,"
656 " %!STATUS!", GetObjectHandle(), status);
657
659
660 return status;
661 }
662
663 //
664 // Look at the Irp, and if there is a thread field, validate we are
665 // actually in the correct process!
666 //
667 status = VerifyProbeAndLock(pFxDriverGlobals);
668 if(!NT_SUCCESS(status) ) {
669 return status;
670 }
671
673
674 if (pMdl == NULL) {
677 "Failed to allocate MDL %!STATUS!", status);
678 return status;
679 }
680
681 // Use a C utility function for the probe due to C++ exception handling issues
683
684 if (!NT_SUCCESS(status)) {
686 "Exception is raised for Address 0x%p, Length %d %!STATUS!",
689 return status;
690 }
691
692 //
693 // Get a system address for the MDL
694 //
696 if (pVA == NULL) {
698 goto Done;
699 }
700
701 // Build an FxRequestMemory object now
703 if (!NT_SUCCESS(status)) {
704 goto Done;
705 }
706
707 // Associate the FxRequestMemory object with the FxRequest
708 status = pMemory->Commit(NULL, NULL, this);
709 if (!NT_SUCCESS(status)) {
710 goto Done;
711 }
712
713Done:
714 if (NT_SUCCESS(status)) {
715 //
716 // If we re-define the WDFMEMORY interfaces to allow
717 // failure for get buffer, we could delay the assignment
718 // of SystemAddressForMdl and its PTE's until the driver
719 // actually requests a double buffer mapping.
720 //
721 // Some DMA drivers may just retrieve the MDL from the WDFMEMORY
722 // and not even attempt to access the underlying bytes, other
723 // than through hardware DMA.
724 //
725 pMemory->SetMdl(
726 this,
727 pMdl,
728 pVA,
729 Length,
730 TRUE // Readonly
731 );
732
734 }
735 else {
736 if (pMemory != NULL) {
738 }
739
740 Mx::MxUnlockPages(pMdl);
742 }
743
744 return status;
745}
static NTSTATUS Create(__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out FxRequestMemory **Object)
static __inline VOID MxUnlockPages(__in PMDL Mdl)
Definition: mxgeneralkm.h:357
FxMemoryObject * pMemory
VOID __inline FxMdlFree(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PMDL Mdl)
Definition: fxmdl.h:60
NTSTATUS FxProbeAndLockForRead(__in PMDL Mdl, __in KPROCESSOR_MODE AccessMode)
Definition: probeandlock.c:36
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166

◆ ProbeAndLockForWrite()

_Must_inspect_result_ NTSTATUS FxRequest::ProbeAndLockForWrite ( __in PVOID  Buffer,
__in ULONG  Length,
__deref_out FxRequestMemory **  pMemoryObject 
)

Definition at line 749 of file fxrequestkm.cpp.

786{
788 PMDL pMdl;
789 PIRP irp;
790 PVOID pVA;
793
794 pMdl = NULL;
795 pMemory = NULL;
797
798 if (Length == 0) {
800
803 "Length of zero not allowed, %!STATUS!", status);
804
805 return status;
806 }
807
808 irp = m_Irp.GetIrp();
809
810 if (irp == NULL) {
812
813 // Error, completed request
816 "WDFREQUEST %p has already been completed or has no PIRP assignment,"
817 " %!STATUS!", GetObjectHandle(), status);
818
820
821 return status;
822 }
823
824 //
825 // Look at the Irp, and if there is a thread field, validate we are
826 // actually in the correct process!
827 //
828 status = VerifyProbeAndLock(pFxDriverGlobals);
829 if(!NT_SUCCESS(status) ) {
830 return status;
831 }
832
834 if (pMdl == NULL) {
837 "Failed to allocate MDL %!STATUS!", status);
838 return status;
839 }
840
841 // Use a C utility function for the probe due to C++ exception handling issues
843
844 if (!NT_SUCCESS(status)) {
846 "Exception is raised for Address 0x%p, Length %d %!STATUS!",
849 return status;
850 }
851
852 //
853 // Get a system address for the MDL
854 //
856 if (pVA == NULL) {
858 goto Done;
859 }
860
861 // Build an FxRequestMemory object now
863 if (!NT_SUCCESS(status)) {
864 goto Done;
865 }
866
867 // Associate the FxRequestMemory object with the FxRequest
868 status = pMemory->Commit(NULL, NULL, this);
869 if (!NT_SUCCESS(status)) {
870 goto Done;
871 }
872
873Done:
874 if (NT_SUCCESS(status)) {
875 //
876 // If we re-define the WDFMEMORY interfaces to allow
877 // failure for get buffer, we could delay the assignment
878 // of SystemAddressForMdl and its PTE's until the driver
879 // actually requests a double buffer mapping.
880 //
881 // Some DMA drivers may just retrieve the MDL from the WDFMEMORY
882 // and not even attempt to access the underlying bytes, other
883 // than through hardware DMA.
884 //
885 pMemory->SetMdl(
886 this,
887 pMdl,
888 pVA,
889 Length,
890 FALSE // FALSE indicates not a readonly buffer
891 );
892
894 }
895 else {
896 if (pMemory != NULL) {
898 }
899
900 Mx::MxUnlockPages(pMdl);
902 }
903
904 return status;
905}
NTSTATUS FxProbeAndLockForWrite(__in PMDL Mdl, __in KPROCESSOR_MODE AccessMode)
Definition: probeandlock.c:55

◆ QueryInterface()

_Must_inspect_result_ NTSTATUS FxRequest::QueryInterface ( __in FxQueryInterfaceParams Params)
protectedvirtual

Reimplemented from FxObject.

Definition at line 2714 of file fxrequest.cpp.

2717{
2718 switch (Params->Type) {
2719 case FX_TYPE_REQUEST:
2720 *Params->Object = (FxRequest*) this;
2721 break;
2722
2723 case IFX_TYPE_MEMORY:
2725 *Params->Object = (IFxMemory*) &m_SystemBuffer;
2726 break;
2727 }
2728 else if (Params->Offset == FIELD_OFFSET(FxRequest, m_OutputBufferOffset)) {
2729 *Params->Object = (IFxMemory*) &m_OutputBuffer;
2730 break;
2731 }
2732
2733 // || || Fall || ||
2734 // \/ \/ through \/ \/
2735 default:
2736 return FxRequestBase::QueryInterface(Params); // __super call
2737 }
2738
2739 return STATUS_SUCCESS;
2740}
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
@ IFX_TYPE_MEMORY
Definition: fxtypes.h:55
@ FX_TYPE_REQUEST
Definition: fxtypes.h:53

◆ Release()

ULONG FxRequest::Release ( __in PVOID  Tag,
__in LONG  Line,
__in_opt PSTR  File 
)
virtual

Definition at line 3089 of file fxrequest.cpp.

3094{
3095 ULONG retValue;
3096 BOOLEAN reservedRequest;
3097 BOOLEAN allocFromIo;
3098 BOOLEAN canComplete;
3099
3100 //
3101 // This may be the last ref, copy flags before calling Release().
3102 //
3103 reservedRequest = IsReserved();
3104 allocFromIo = IsAllocatedFromIo();
3105 canComplete = IsCanComplete();
3106
3107 retValue = FxRequestBase::Release(Tag, Line, File); // __super call
3108
3109 if (reservedRequest && retValue == 1 && m_Completed) {
3110 //
3111 // Reserved requests should have an associated queue all the time.
3112 //
3114 }
3115 else if (allocFromIo == FALSE && canComplete && retValue == 1 && m_Completed) {
3116
3119
3120 //
3121 // Make a local copy before request is gone.
3122 //
3124 queue = m_IoQueue;
3125
3127 m_IoQueue = NULL;
3128
3129 //
3130 // We are now ready to complete this driver created request.
3131 //
3132 FxIrp irp(m_Irp.GetIrp());
3133
3134 m_Irp.SetIrp(NULL);
3135
3137
3139 }
3140
3141 return retValue;
3142}
VOID ReturnReservedRequest(__in FxRequest *ReservedRequest)
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
VOID PostProcessCompletionForDriverRequest(__in FxRequestCompletionState State, __in FxIoQueue *Queue)
Definition: fxrequest.cpp:996

◆ ReleaseIrpReference()

VOID FxRequest::ReleaseIrpReference ( VOID  )

Definition at line 2512 of file fxrequest.cpp.

2530{
2531 LONG count;
2532
2534
2535 if( count < 0 ) {
2537 "Attempt to release an IRP reference without adding "
2538 "one first WDFREQUEST 0x%p",GetHandle());
2540 }
2541
2542 return;
2543}
#define InterlockedDecrement
Definition: armddk.h:52
GLuint GLuint GLsizei count
Definition: gl.h:1545
long LONG
Definition: pedump.c:60

Referenced by FxRequestSystemBuffer::Release(), FxRequestOutputBuffer::Release(), FxDmaTransactionBase::ReleaseButRetainRequest(), ReleaseOverride(), and FxRequestMemory::~FxRequestMemory().

◆ ReleaseOverride()

ULONG FxRequest::ReleaseOverride ( __in WDFOBJECT_OFFSET  Offset,
__in PVOID  Tag = NULL,
__in LONG  Line = 0,
__in_opt PSTR  File = NULL 
)
virtual

Definition at line 2694 of file fxrequest.cpp.

2700{
2701 if (Offset != 0x0) {
2705 return 1;
2706 }
2707 else {
2708 return FxObject::Release(Tag, Line, File);
2709 }
2710}
VOID ReleaseIrpReference(VOID)
Definition: fxrequest.cpp:2512

◆ RemoveFromIrpQueue()

_Must_inspect_result_ NTSTATUS FxRequest::RemoveFromIrpQueue ( __in FxIrpQueue IrpQueue)

Definition at line 1961 of file fxrequest.cpp.

1964{
1966 MdIrp pIrp;
1967
1969
1970 //
1971 // Cancel Safe Queues allow this request
1972 // removal to be race free even if the
1973 // request has been cancelled already.
1974 //
1975 // It signals this by returning NULL for
1976 // the Irp.
1977 //
1978 pIrp = IrpQueue->RemoveRequest(&m_CsqContext);
1979
1980 if (pIrp == NULL) {
1981
1982 //
1983 // Cancel routine removed it from the cancel
1984 // safe queue.
1985 //
1986 // The cancel handler will remove this reference
1987 // in FxIoQueue::_IrpCancelForDriver /
1988 // FxIrpQueue::_WdmCancelRoutineInternal
1989 //
1990
1991 return STATUS_CANCELLED;
1992 }
1993 else {
1994
1995 //
1996 // We retrieved the Irp from the cancel safe queue
1997 // without it having been cancelled first.
1998 //
1999 // It is no longer cancelable
2000 //
2002 if (m_IrpQueue == NULL) {
2005 "WDFREQUEST 0x%p not on IrpQueue",
2006 GetHandle());
2007
2009 }
2010 }
2011
2013
2015
2016 return STATUS_SUCCESS;
2017 }
2018}
#define STATUS_CANCELLED
Definition: udferr_usr.h:170

Referenced by FxIoQueue::RequestCancelable().

◆ RetrieveFromCsqContext()

static __inline FxRequest * FxRequest::RetrieveFromCsqContext ( __in PMdIoCsqIrpContext  pCsqContext)
inlinestatic

◆ Reuse()

_Must_inspect_result_ NTSTATUS FxRequest::Reuse ( __in PWDF_REQUEST_REUSE_PARAMS  ReuseParams)

Definition at line 2136 of file fxrequest.cpp.

2139{
2140 FxIrp currentIrp;
2142
2143 //
2144 // Make sure request is not pended in IoTarget.
2145 //
2147 SHORT flags;
2148 KIRQL irql;
2149
2150 Lock(&irql);
2155 "Driver is trying to reuse WDFREQUEST 0x%p while it is still "
2156 "active on WDFIOTARGET 0x%p. ",
2159 }
2160 Unlock(irql);
2161 }
2162
2163 //
2164 // For drivers 1.9 and above (for maintaining backwards compatibility)
2165 // deregister previously registered completion routine.
2166 //
2169 }
2170
2171 currentIrp.SetIrp(m_Irp.GetIrp());
2172
2173 if (currentIrp.GetIrp() != NULL) {
2174 //
2175 // Release all outstanding references and restore original fields in
2176 // the PIRP
2177 //
2178 if (m_RequestContext != NULL) {
2180 }
2181
2183 //
2184 // An irp presented by io queue can only reset a limited state
2185 //
2187 //
2188 // Not allowed to set a new irp
2189 //
2191 }
2192
2193#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
2194 currentIrp.SetStatus(ReuseParams->Status);
2195 currentIrp.SetCancel(FALSE);
2196#else
2197 //
2198 // For UMDF, host sets cancel flag to false as part of Reuse(), so no
2199 // need to have a separate call for UMDF (that's why host irp doesn't
2200 // expose any interface to set this independently).
2201
2202
2203
2204
2205 //
2206 currentIrp.Reuse(ReuseParams->Status);
2207#endif
2209 m_Canceled = FALSE;
2210
2211 return STATUS_SUCCESS;
2212 }
2214 //
2215 // Release outstanding reference on a must complete driver request.
2216 //
2217 if (m_CanComplete && m_Completed == FALSE) {
2218 ASSERT(GetRefCnt() >= 2);
2219
2222 }
2223
2225 }
2226 }
2227 }
2228 else {
2229 //
2230 // We should not have a m_RequestContext with anything to ReleaseAndRestore
2231 // because there is no IRP to have anything formatted off of.
2232 //
2233 DO_NOTHING();
2234 }
2235
2236 //
2237 // This cannot be a request on a queue
2238 //
2240 m_IoQueue == NULL);
2241
2243 currentIrp.SetIrp((MdIrp)ReuseParams->NewIrp);
2244
2245 //
2246 // If we are replacing an internal irp, we must free it later.
2247 //
2249 MdIrp pOldIrp;
2250
2252 pOldIrp = m_Irp.SetIrp(currentIrp.GetIrp());
2253
2254 if (pOldIrp != NULL) {
2255 FxIrp oldIrp(pOldIrp);
2256 oldIrp.FreeIrp();
2257 }
2258 }
2259 else {
2260 (void) m_Irp.SetIrp(currentIrp.GetIrp());
2261 }
2262
2264 }
2265
2266 //
2267 // Only reinitialize an internal irp. If the irp is external, then its
2268 // still valid.
2269 //
2270 if (m_IrpAllocation == REQUEST_ALLOCATED_INTERNAL && currentIrp.GetIrp() != NULL) {
2273 currentIrp.Reuse(ReuseParams->Status);
2274
2275 //
2276 // For UMDF, host sets cancel flag to false as part of Reuse(), so no
2277 // need to have a separate call for UMDF (that's why host irp doesn't
2278 // expose any interface to set this independently).
2279
2280
2281
2282
2283 //
2284#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
2285 currentIrp.SetCancel(FALSE);
2286#endif
2287 }
2288
2289 //
2290 // If necessary, reinit the request to support WdfRequestComplete.
2291 //
2294
2295 //
2296 // WDF guarantees a successful return code when the driver calls Reuse() from its
2297 // completion routine with valid input.
2298 //
2299
2300 //
2301 // This feature can only be used from WDF v1.11 and above.
2302 //
2307 "WDFREQUEST %p doesn't belong to any queue, %!STATUS!",
2310 return status;
2311 }
2312
2313 //
2314 // 'must_complete' flag requires an IRP.
2315 //
2316 if (currentIrp.GetIrp() == NULL) {
2320 "Driver is trying to reuse WDFREQUEST 0x%p without "
2321 "specifying an IRP with "
2322 "WDF_REQUEST_REUSE_MUST_COMPLETE flag, %!STATUS!",
2325 return status;
2326 }
2327
2328 //
2329 // Do not support internal IRPs.
2330 //
2335 "Driver is trying to reuse WDFREQUEST 0x%p holding an"
2336 "internal allocated IRP with "
2337 "WDF_REQUEST_REUSE_MUST_COMPLETE flag, %!STATUS!",
2340 return status;
2341 }
2342
2343 //
2344 // Ref count must be 1.
2345 //
2346 if (GetRefCnt() != 1) {
2350 "Driver is trying to reuse WDFREQUEST 0x%p with "
2351 "WDF_REQUEST_REUSE_MUST_COMPLETE flag while request is "
2352 "being referenced, reference count:%d, %!STATUS!",
2355 return status;
2356 }
2357
2358 //
2359 // Make sure current IRP stack location is valid.
2360 //
2361 if (currentIrp.IsCurrentIrpStackLocationValid() == FALSE) {