ReactOS  0.4.15-dev-2144-g2282205
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)
 
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)
 
_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 {
48  m_IoQueue = NULL;
49 
51 
55 
57  m_Reserved = FALSE;
61 }
BOOLEAN m_ForwardRequestToParent
Definition: fxrequest.hpp:461
LIST_ENTRY m_OwnerListEntry
Definition: fxrequest.hpp:420
FxIoQueue * m_ForwardProgressQueue
Definition: fxrequest.hpp:434
#define TRUE
Definition: types.h:120
LIST_ENTRY m_OwnerListEntry2
Definition: fxrequest.hpp:422
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
WDFOBJECT_OFFSET_ALIGNED m_OutputBufferOffset
FxIoQueue * m_IoQueue
Definition: fxrequest.hpp:411
BYTE m_PowerStopState
Definition: fxrequest.hpp:450
WDFOBJECT_OFFSET_ALIGNED m_SystemBufferOffset
BOOLEAN m_Reserved
Definition: fxrequest.hpp:455
FxRequestBase(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize, __in_opt MdIrp Irp, __in FxRequestIrpOwnership Ownership, __in FxRequestConstructorCaller Caller, __in FxObjectType ObjectType=FxObjectTypeExternal)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
LIST_ENTRY m_ForwardProgressList
Definition: fxrequest.hpp:427
PVOID m_InternalContext
Definition: fxrequest.hpp:439
BOOLEAN m_Presented
Definition: fxrequest.hpp:445

Referenced by _Create().

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)) {
195  status = pRequest->Commit(RequestAttributes, &hRequest, NULL, TRUE);
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 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
FxRequest * pRequest
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
status
Definition: fxrequest.cpp:1850
FxRequest(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in MdIrp Irp, __in FxRequestIrpOwnership Ownership, __in FxRequestConstructorCaller Caller, __in USHORT ObjectSize)
Definition: fxrequest.cpp:33
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3428
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
MdIrp SetSubmitIrp(__in_opt MdIrp NewIrp, __in BOOLEAN FreeIrp=TRUE)
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
_Must_inspect_result_ NTSTATUS ValidateTarget(__in FxIoTarget *Target)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
Definition: ps.c:97

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 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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
LONG NTSTATUS
Definition: precomp.h:26
FxRequest * pRequest
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
status
Definition: fxrequest.cpp:1850
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3428
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
VOID AssignMemoryBuffers(__in WDF_DEVICE_IO_TYPE IoType)
Definition: fxrequest.hpp:1372
Definition: ps.c:97

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  }
LIST_ENTRY m_OwnerListEntry
Definition: fxrequest.hpp:420
LIST_ENTRY m_OwnerListEntry2
Definition: fxrequest.hpp:422
#define FALSE
Definition: types.h:117
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define ASSERT(a)
Definition: mode.c:45
_In_ WDFCOLLECTION _In_ ULONG Index
#define NULL
Definition: types.h:112
LIST_ENTRY m_ForwardProgressList
Definition: fxrequest.hpp:427

◆ 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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
KIRQL irql
Definition: fxrequest.cpp:379
UCHAR KIRQL
Definition: env_spec_w32.h:591
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define VOID
Definition: acefi.h:82
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define InterlockedIncrement
Definition: armddk.h:53
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124

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) {
2685  AddIrpReference();
2686  return 2;
2687  }
2688  else {
2689  return FxObject::AddRef(Tag, Line, File);
2690  }
2691 }
VOID AddIrpReference(VOID)
Definition: fxrequest.cpp:2470
GLint x0
Definition: linetemp.h:95
WDFOBJECT_OFFSET_ALIGNED m_OutputBufferOffset
#define ASSERT(a)
Definition: mode.c:45
Definition: ncftp.h:79
WDFOBJECT_OFFSET_ALIGNED m_SystemBufferOffset
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG __inline AddRef(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:826
Definition: File.h:15

◆ 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()) {
1378  case IRP_MJ_DEVICE_CONTROL:
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) {
1447  case WdfDeviceIoBuffered:
1449  break;
1450 
1451  case WdfDeviceIoNeither:
1453  if (m_Irp.GetRequestorMode() == KernelMode) {
1455  }
1456  else {
1457  return;
1458  }
1459  break;
1460 
1461  default:
1462  return;
1463  }
1464  break;
1465 
1466  default:
1467  return;
1468  }
1469 
1470  if (m_SystemBuffer.IsBufferSet()) {
1472  }
1473  if (m_OutputBuffer.IsBufferSet()) {
1475  }
1476 }
__inline BOOLEAN IsBufferSet(VOID)
Definition: fxrequest.hpp:168
UCHAR m_RequestBaseStaticFlags
#define METHOD_IN_DIRECT
Definition: nt_native.h:595
__inline VOID SetBuffer(__in PVOID Buffer)
Definition: fxrequest.hpp:334
#define METHOD_NEITHER
Definition: nt_native.h:597
PVOID GetOutputBuffer()
Definition: fxirpum.cpp:594
FxRequestOutputBuffer m_OutputBuffer
Definition: fxrequest.hpp:415
__inline BOOLEAN IsBufferSet(VOID)
Definition: fxrequest.hpp:314
#define METHOD_OUT_DIRECT
Definition: nt_native.h:596
__inline VOID SetBuffer(PVOID Buffer)
Definition: fxrequest.hpp:188
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
PVOID GetParameterIoctlType3InputBuffer(VOID)
Definition: fxirpum.cpp:1542
PVOID GetUserBuffer()
Definition: fxirpum.cpp:633
#define KMDF_ONLY_CODE_PATH_ASSERT()
Definition: fx.hpp:55
PVOID GetSystemBuffer()
Definition: fxirpum.cpp:543
KPROCESSOR_MODE GetRequestorMode(VOID)
Definition: fxirpum.cpp:329
#define METHOD_BUFFERED
Definition: nt_native.h:594
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
_In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_IO_TYPE IoType
Definition: wdfdevice.h:3138
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
FxRequestSystemBuffer m_SystemBuffer
Definition: fxrequest.hpp:413

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 }
struct _IO_STACK_LOCATION::@3760::@3765 Write
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:863
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
WDFCASSERT(sizeof(WDF_DRIVER_CONFIG_V1_0)==sizeof(WDF_DRIVER_CONFIG_V1_1))
WDFOBJECT_OFFSET_ALIGNED m_OutputBufferOffset
struct _IO_STACK_LOCATION::@3760::@3764 Read
union _WDF_REQUEST_PARAMETERS::@3665 Parameters
WDFOBJECT_OFFSET_ALIGNED m_SystemBufferOffset
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3124

◆ ClearFieldsForReuse()

__inline VOID FxRequest::ClearFieldsForReuse ( VOID  )
inline

Definition at line 1294 of file fxrequest.hpp.

1297  {
1300 
1302 
1303  FxRequestBase::ClearFieldsForReuse(); // __super call
1304  }
BOOLEAN m_ForwardRequestToParent
Definition: fxrequest.hpp:461
VOID ClearFieldsForReuse(VOID)
#define FALSE
Definition: types.h:117
__inline VOID ClearBufferMdl(VOID)
Definition: fxrequest.hpp:177
FxRequestOutputBuffer m_OutputBuffer
Definition: fxrequest.hpp:415
#define ASSERT(a)
Definition: mode.c:45
__inline VOID ClearBufferMdl(VOID)
Definition: fxrequest.hpp:323
FxRequestSystemBuffer m_SystemBuffer
Definition: fxrequest.hpp:413

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 {
802  SetPriorityBoost(0);
803  }
804 
805  return CompleteInternal(Status);
806  }
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
VOID __inline SetPriorityBoost(CCHAR PriorityBoost)
Status
Definition: gdiplustypes.h:24
ULONG_PTR GetInformation()
Definition: fxirpum.cpp:513
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
__inline CHAR GetDefaultPriorityBoost(VOID)
Definition: fxdevice.hpp:1111
MdIrp GetIrp(VOID)
Definition: fxirpum.cpp:15
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
NTSTATUS CompleteInternal(__in NTSTATUS Status)
Definition: fxrequest.cpp:515
__inline WDFREQUEST GetHandle(VOID)

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

◆ CompleteInternal()

NTSTATUS FxRequest::CompleteInternal ( __in NTSTATUS  Status)
private

Definition at line 515 of file fxrequest.cpp.

542 {
544  MdIrp pIrp;
546  FxIoQueue* queue;
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  //
571  m_Completed = TRUE;
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) {
631  case STATUS_WDF_PAUSED:
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 
667  queue = m_IoQueue;
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  //
740  DestroyChildren();
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  //
833  m_Irp.SetIrp(NULL);
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 }
#define STATUS_WDF_BUSY
Definition: wdfstatus.h:126
virtual size_t GetBufferSize(VOID)
FxIoQueue * queue
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
#define TRUE
Definition: types.h:120
ULONG GetFlags(VOID)
Definition: fxirpum.cpp:1281
CCHAR __inline GetPriorityBoost(VOID)
Definition: fxirp.hpp:28
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
UCHAR m_RequestBaseStaticFlags
BOOLEAN __inline IsAllocatedFromIo(VOID)
virtual _Must_inspect_result_ PMDL GetMdl(VOID)
#define STATUS_WDF_TOO_FRAGMENTED
Definition: wdfstatus.h:180
FxIrp * pIrp
#define TRACINGREQUEST
Definition: dbgtrace.h:65
VOID CreateCompleted(__in FxIrp *Irp)
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
BOOLEAN EarlyDispose(VOID)
VOID PreProcessCompletionForDriverRequest(__in FxRequestCompletionState State, __in FxIoQueue *Queue)
Definition: fxrequest.cpp:955
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
#define FACILITY_DRIVER_FRAMEWORK
Definition: wdfstatus.h:32
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
virtual VOID ReleaseAndRestore(__in FxRequestBase *Request)
Definition: _queue.h:59
IWudfIrp * MdIrp
Definition: mxum.h:103
virtual WDFMEMORY GetHandle(VOID)
#define STATUS_WDF_PAUSED
Definition: wdfstatus.h:117
FxRequestOutputBuffer m_OutputBuffer
Definition: fxrequest.hpp:415
FxIoQueue * m_IoQueue
Definition: fxrequest.hpp:411
VOID SetFlags(__in ULONG Flags)
Definition: fxirpum.cpp:1266
Status
Definition: gdiplustypes.h:24
virtual _Must_inspect_result_ PVOID GetBuffer(VOID)
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define ASSERT(a)
Definition: mode.c:45
__inline BOOLEAN IsReserved()
Definition: fxrequest.hpp:609
#define STATUS_WDF_INTERNAL_ERROR
Definition: wdfstatus.h:108
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
VOID PostProcessCompletionForReserved(__in FxRequestCompletionState State, __in FxIoQueue *Queue)
Definition: fxrequest.cpp:916
FxRequestCompletionState
FxIrpQueue * m_IrpQueue
static const WCHAR L[]
Definition: oid.c:1250
static int state
Definition: maze.c:121
virtual WDFMEMORY GetHandle(VOID)
VOID ClearEvtCallbacks(VOID)
Definition: fxobject.cpp:360
__inline BOOLEAN IsCancelRoutineSet(VOID)
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
virtual _Must_inspect_result_ PMDL GetMdl(VOID)
UCHAR m_RequestBaseFlags
VOID __inline DestroyChildren(VOID)
Definition: fxobject.hpp:464
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
ULONG_PTR GetInformation()
Definition: fxirpum.cpp:513
#define IRP_INPUT_OPERATION
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
MdIrp GetIrp(VOID)
Definition: fxirpum.cpp:15
KPROCESSOR_MODE GetRequestorMode(VOID)
Definition: fxirpum.cpp:329
ULONG GetParameterIoctlOutputBufferLength(VOID)
Definition: fxirpum.cpp:1504
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
#define METHOD_BUFFERED
Definition: nt_native.h:594
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
BOOLEAN __inline IsCanComplete(VOID)
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
#define NULL
Definition: types.h:112
FxRequestContext * m_RequestContext
unsigned int ULONG
Definition: retypes.h:1
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
BOOLEAN m_Presented
Definition: fxrequest.hpp:445
virtual size_t GetBufferSize(VOID)
MdIrp SetIrp(MdIrp irp)
Definition: fxirpkm.hpp:71
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
VOID _In_ NTSTATUS Status
Definition: fxrequest.cpp:376
FxIrp * irp
FxVerifierDbgBreakPoint(pFxDriverGlobals)
VOID PostProcessCompletion(__in FxRequestCompletionState State, __in FxIoQueue *Queue)
Definition: fxrequest.cpp:874
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
virtual PVOID GetBuffer(VOID)
FxRequestSystemBuffer m_SystemBuffer
Definition: fxrequest.hpp:413
#define DO_NOTHING()
Definition: mxgeneral.h:32

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  }
__inline NTSTATUS Complete(__in NTSTATUS Status)
Definition: fxrequest.hpp:770
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1044
Status
Definition: gdiplustypes.h:24
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504

◆ 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  }
#define TRACINGREQUEST
Definition: dbgtrace.h:65
_In_ WDFREQUEST _In_ NTSTATUS _In_ CCHAR PriorityBoost
Definition: wdfrequest.h:1011
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
VOID __inline SetPriorityBoost(CCHAR PriorityBoost)
Status
Definition: gdiplustypes.h:24
ULONG_PTR GetInformation()
Definition: fxirpum.cpp:513
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
MdIrp GetIrp(VOID)
Definition: fxirpum.cpp:15
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
NTSTATUS CompleteInternal(__in NTSTATUS Status)
Definition: fxrequest.cpp:515
__inline WDFREQUEST GetHandle(VOID)

◆ 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  }
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
#define TRACINGREQUEST
Definition: dbgtrace.h:65
FORCEINLINE VOID WDF_REQUEST_COMPLETION_PARAMS_INIT(_Out_ PWDF_REQUEST_COMPLETION_PARAMS Params)
Definition: wdfrequest.h:288
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
FxRequestContext * m_RequestContext
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
FxVerifierDbgBreakPoint(pFxDriverGlobals)

◆ CopyCurrentIrpStackLocationToNext()

__inline VOID FxRequest::CopyCurrentIrpStackLocationToNext ( VOID  )
inline

Definition at line 509 of file fxrequest.hpp.

512  {
513  FxIrp* irp = GetSubmitFxIrp();
515  }
__inline FxIrp * GetSubmitFxIrp(VOID)
Definition: fxirp.hpp:28
VOID CopyCurrentIrpStackLocationToNext(VOID)
Definition: fxirpum.cpp:209
FxIrp * irp

◆ 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 }
virtual VOID DeleteObject(VOID)
#define FALSE
Definition: types.h:117
virtual VOID ReleaseAndRestore(__in FxRequestBase *Request)
VOID ClearEvtCallbacks(VOID)
Definition: fxobject.cpp:360
#define NULL
Definition: types.h:112
FxRequestContext * m_RequestContext
BOOLEAN m_Presented
Definition: fxrequest.hpp:445

◆ FX_DECLARE_VF_FUNCTION() [1/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( VOID  ,
VerifyPreProcessSendAndForget   
)

◆ FX_DECLARE_VF_FUNCTION() [2/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyProbeAndLock   
)

◆ FX_DECLARE_VF_FUNCTION() [3/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( VOID  ,
VerifierBreakpoint_RequestEarlyDisposeDeferred   
)

◆ FX_DECLARE_VF_FUNCTION() [4/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsDriverOwned   
)

◆ FX_DECLARE_VF_FUNCTION() [5/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsCancelable   
)

◆ FX_DECLARE_VF_FUNCTION() [6/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsNotCancelable   
)

◆ 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  ,
VerifyRequestIsNotCompleted   
)

◆ FX_DECLARE_VF_FUNCTION() [10/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsTagRequest   
)

◆ FX_DECLARE_VF_FUNCTION() [11/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsAllocatedFromIo   
)

◆ FX_DECLARE_VF_FUNCTION() [12/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestIsCurrentStackValid   
)

◆ FX_DECLARE_VF_FUNCTION() [13/13]

FxRequest::FX_DECLARE_VF_FUNCTION ( NTSTATUS  ,
VerifyRequestCanBeCompleted   
)

◆ 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;
1033  NTSTATUS status;
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  }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
LONG NTSTATUS
Definition: precomp.h:26
PIO_STACK_LOCATION GetCurrentIrpStackLocation(VOID)
Definition: fxirpum.cpp:370
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
basic_ios< char, char_traits< char > > ios
Definition: _iosfwd.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ 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  }
FxIoQueue * m_IoQueue
Definition: fxrequest.hpp:411
#define NULL
Definition: types.h:112

Referenced by PerfIoComplete(), and PerfIoStart().

◆ GetDevice()

◆ GetDeviceControlOutputMdl()

_Must_inspect_result_ NTSTATUS FxRequest::GetDeviceControlOutputMdl ( __out PMDL pMdl)

Definition at line 347 of file fxrequestkm.cpp.

392 {
393  ULONG length;
394  PVOID pBuffer;
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 
471  case METHOD_OUT_DIRECT:
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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static __inline VOID MxBuildMdlForNonPagedPool(__inout PMDL Mdl)
Definition: mxgeneralkm.h:376
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
KIRQL irql
Definition: wave.h:1
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define METHOD_IN_DIRECT
Definition: nt_native.h:595
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define METHOD_NEITHER
Definition: nt_native.h:597
#define FALSE
Definition: types.h:117
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
PVOID pBuffer
PMDL GetMdl()
Definition: fxirpum.cpp:625
#define METHOD_OUT_DIRECT
Definition: nt_native.h:596
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
unsigned char UCHAR
Definition: xmlstorage.h:181
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
BOOLEAN FxVerifierIO
Definition: fxglobals.h:446
PVOID GetSystemBuffer()
Definition: fxirpum.cpp:543
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
ULONG GetParameterIoctlOutputBufferLength(VOID)
Definition: fxirpum.cpp:1504
#define METHOD_BUFFERED
Definition: nt_native.h:594
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
#define NULL
Definition: types.h:112
UCHAR majorFunction
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
unsigned int ULONG
Definition: retypes.h:1
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
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
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG GetParameterIoctlCode(VOID)
Definition: fxirpum.cpp:1474
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
static SERVICE_STATUS status
Definition: service.c:31
__inline WDFREQUEST GetHandle(VOID)
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
Definition: ps.c:97

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;
1581  NTSTATUS status;
1582  KIRQL irql;
1583  BOOLEAN mapMdl;
1585 
1588 
1590  length = 0;
1591  irql = PASSIVE_LEVEL;
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 
1739 Done:
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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
GLint x0
Definition: linetemp.h:95
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
UCHAR m_RequestBaseStaticFlags
status
Definition: fxrequest.cpp:1850
#define TRACINGREQUEST
Definition: dbgtrace.h:65
KIRQL irql
Definition: fxrequest.cpp:379
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define METHOD_IN_DIRECT
Definition: nt_native.h:595
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define METHOD_NEITHER
Definition: nt_native.h:597
#define FALSE
Definition: types.h:117
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
unsigned char BOOLEAN
Definition: bufpool.h:45
FxRequestOutputBuffer m_OutputBuffer
Definition: fxrequest.hpp:415
PMDL GetMdl()
Definition: fxirpum.cpp:625
#define METHOD_OUT_DIRECT
Definition: nt_native.h:596
#define ASSERT(a)
Definition: mode.c:45
static __inline PVOID MxGetSystemAddressForMdlSafe(__inout PMDL Mdl, __in ULONG Priority)
Definition: mxgeneralkm.h:366
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
unsigned char UCHAR
Definition: xmlstorage.h:181
_Must_inspect_result_ _In_ WDFREQUEST _In_ size_t _Out_ WDFMEMORY * MemoryObject
Definition: wdfrequest.h:1470
ULONG length
Definition: fxrequest.cpp:378
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
UCHAR m_RequestBaseFlags
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
KPROCESSOR_MODE GetRequestorMode(VOID)
Definition: fxirpum.cpp:329
ULONG GetParameterIoctlOutputBufferLength(VOID)
Definition: fxirpum.cpp:1504
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
#define NULL
Definition: types.h:112
UCHAR majorFunction
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
__inline VOID SetMdl(__in PMDL Mdl)
Definition: fxrequest.hpp:344
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG GetParameterIoctlCode(VOID)
Definition: fxirpum.cpp:1474
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
__inline WDFREQUEST GetHandle(VOID)
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define DO_NOTHING()
Definition: mxgeneral.h:32
Definition: ps.c:97

Referenced by if().

◆ GetFileObject()

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

Definition at line 2408 of file fxrequest.cpp.

2411 {
2412  NTSTATUS status;
2413  FxFileObject* pFileObject;
2414  CfxDevice* pDevice;
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,
2448  m_Irp.GetFileObject(),
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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
MdFileObject GetFileObject(VOID)
Definition: fxirpum.cpp:1460
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
status
Definition: fxrequest.cpp:1850
KIRQL irql
Definition: fxrequest.cpp:379
UCHAR KIRQL
Definition: env_spec_w32.h:591
__inline WDF_FILEOBJECT_CLASS GetFileObjectClass(VOID)
Definition: fxdevice.hpp:1123
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FxDevice * pDevice
PFX_DRIVER_GLOBALS pFxDriverGlobals
BOOLEAN __inline FxIsFileObjectOptional(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:112
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static _Must_inspect_result_ NTSTATUS _GetFileObjectFromWdm(__in FxDevice *pDevice, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt MdFileObject pWdmFileObject, __deref_out_opt FxFileObject **ppFxFileObject)
BOOLEAN FxVerifierIO
Definition: fxglobals.h:446
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOLEAN m_CanComplete
BOOLEAN __inline IsAllocatedDriver(VOID)
Definition: ps.c:97

◆ GetFxIrp()

◆ GetInformation()

ULONG_PTR FxRequest::GetInformation ( VOID  )

Definition at line 277 of file fxrequest.cpp.

296 {
298 
300 
301  // Verifier
303  ULONG_PTR info;
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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
LONG NTSTATUS
Definition: precomp.h:26
status
Definition: fxrequest.cpp:1850
KIRQL irql
Definition: fxrequest.cpp:379
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR KIRQL
Definition: env_spec_w32.h:591
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _test_info info[]
Definition: SetCursorPos.c:19
ULONG_PTR GetInformation()
Definition: fxirpum.cpp:513
BOOLEAN FxVerifierIO
Definition: fxglobals.h:446
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
Definition: ps.c:97

◆ 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:7251
_In_opt_ PVOID _In_ ULONG _In_ PVOID context
Definition: wdfdriver.h:113
#define NULL
Definition: types.h:112
PVOID m_InternalContext
Definition: fxrequest.hpp:439

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  }
FxIoQueue * m_IoQueue
Definition: fxrequest.hpp:411

◆ 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  }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
MdIrp GetIrp(VOID)
Definition: fxirpum.cpp:15
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by Impersonate().

◆ 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  }
LIST_ENTRY m_OwnerListEntry
Definition: fxrequest.hpp:420
LIST_ENTRY m_OwnerListEntry2
Definition: fxrequest.hpp:422
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45
_In_ WDFCOLLECTION _In_ ULONG Index
#define NULL
Definition: types.h:112
LIST_ENTRY m_ForwardProgressList
Definition: fxrequest.hpp:427

◆ 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;
85  ULONG length;
86  PVOID pBuffer;
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 
136  case METHOD_OUT_DIRECT:
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!",
322  pBuffer, length, 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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
ULONG GetParameterReadLength(VOID)
Definition: fxirpum.cpp:1589
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static __inline VOID MxBuildMdlForNonPagedPool(__inout PMDL Mdl)
Definition: mxgeneralkm.h:376
__inline WDF_DEVICE_IO_TYPE GetIoType(VOID)
Definition: fxdevice.hpp:1084
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
enum _WDF_DEVICE_IO_TYPE WDF_DEVICE_IO_TYPE
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
KIRQL irql
Definition: wave.h:1
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define METHOD_IN_DIRECT
Definition: nt_native.h:595
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define METHOD_NEITHER
Definition: nt_native.h:597
#define FALSE
Definition: types.h:117
ULONG GetParameterIoctlInputBufferLength(VOID)
Definition: fxirpum.cpp:1518
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
PVOID pBuffer
PMDL GetMdl()
Definition: fxirpum.cpp:625
#define METHOD_OUT_DIRECT
Definition: nt_native.h:596
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
unsigned char UCHAR
Definition: xmlstorage.h:181
ULONG GetParameterWriteLength(VOID)
Definition: fxirpum.cpp:1601
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
BOOLEAN FxVerifierIO
Definition: fxglobals.h:446
PVOID GetSystemBuffer()
Definition: fxirpum.cpp:543
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define METHOD_BUFFERED
Definition: nt_native.h:594
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
#define NULL
Definition: types.h:112
UCHAR majorFunction
#define IRP_MJ_READ
Definition: rdpdr.c:46
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
unsigned int ULONG
Definition: retypes.h:1
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
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
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG GetParameterIoctlCode(VOID)
Definition: fxirpum.cpp:1474
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
static SERVICE_STATUS status
Definition: service.c:31
__inline WDFREQUEST GetHandle(VOID)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
Definition: ps.c:97

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  //
674  ASSERT((handle & FxHandleFlagMask) == 0);
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  //
685  ASSERT((handle & FxHandleFlagMask) == 0);
686 
687  //
688  // This handle is an offset
690 
691  return (WDFMEMORY) handle;
692  }
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144
uint32_t ULONG_PTR
Definition: typedefs.h:65
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
DECLSPEC_SELECTANY const ULONG_PTR FxHandleValueMask
#define ASSERT(a)
Definition: mode.c:45
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define ULONG_PTR
Definition: config.h:101
unsigned short * PUSHORT
Definition: retypes.h:2

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;
1291  NTSTATUS status;
1292  ULONG length;
1293  KIRQL irql;
1294  BOOLEAN mapMdl;
1296 
1298  length = 0x0;
1299  mapMdl = FALSE;
1300  irql = PASSIVE_LEVEL;
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  &&
1319 
1322  "Attempt to get UserMode Buffer Pointer for WDFDEVICE 0x%p, "
1323  "WDFREQUEST 0x%p, %!STATUS!",
1324  GetDevice()->GetHandle(), GetHandle(), 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) {
1345  case IRP_MJ_DEVICE_CONTROL:
1348 
1349  if (length == 0) {
1351 
1354  "WDFREQUEST %p InputBufferLength length is zero, %!STATUS!",
1355  GetObjectHandle(), 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!",
1383  GetDevice()->GetHandle(), GetHandle(), 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 
1500 Done:
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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
ULONG GetParameterReadLength(VOID)
Definition: fxirpum.cpp:1589
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
__inline WDF_DEVICE_IO_TYPE GetIoType(VOID)
Definition: fxdevice.hpp:1084
#define TRUE
Definition: types.h:120
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
UCHAR m_RequestBaseStaticFlags
status
Definition: fxrequest.cpp:1850
#define TRACINGREQUEST
Definition: dbgtrace.h:65
KIRQL irql
Definition: fxrequest.cpp:379
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define METHOD_NEITHER
Definition: nt_native.h:597
#define FALSE
Definition: types.h:117
ULONG GetParameterIoctlInputBufferLength(VOID)
Definition: fxirpum.cpp:1518
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
unsigned char BOOLEAN
Definition: bufpool.h:45
PMDL GetMdl()
Definition: fxirpum.cpp:625
#define ASSERT(a)
Definition: mode.c:45
static __inline PVOID MxGetSystemAddressForMdlSafe(__inout PMDL Mdl, __in ULONG Priority)
Definition: mxgeneralkm.h:366
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
unsigned char UCHAR
Definition: xmlstorage.h:181
_Must_inspect_result_ _In_ WDFREQUEST _In_ size_t _Out_ WDFMEMORY * MemoryObject
Definition: wdfrequest.h:1470
__inline VOID SetMdl(PMDL Mdl)
Definition: fxrequest.hpp:198
ULONG length
Definition: fxrequest.cpp:378
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
ULONG GetParameterWriteLength(VOID)
Definition: fxirpum.cpp:1601
UCHAR m_RequestBaseFlags
#define KMDF_ONLY_CODE_PATH_ASSERT()
Definition: fx.hpp:55
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
KPROCESSOR_MODE GetRequestorMode(VOID)
Definition: fxirpum.cpp:329
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
#define NULL
Definition: types.h:112
UCHAR majorFunction
#define IRP_MJ_READ
Definition: rdpdr.c:46
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
unsigned int ULONG
Definition: retypes.h:1
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG GetParameterIoctlCode(VOID)
Definition: fxirpum.cpp:1474
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
__inline WDFREQUEST GetHandle(VOID)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
FxRequestSystemBuffer m_SystemBuffer
Definition: fxrequest.hpp:413
#define DO_NOTHING()
Definition: mxgeneral.h:32
Definition: ps.c:97

◆ 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 
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 }
__in MdIrp __in PMdIoCsqIrpContext pCsqContext
Definition: fxirpqueue.hpp:74
#define FXREQUEST_QUEUE_TAG
Definition: fxrequest.hpp:47
MdIrp GetNextRequest(__out PMdIoCsqIrpContext *pCsqContext)
Definition: fxirpqueue.cpp:219
FxRequest * pRequest
FxIrp * pIrp
IWudfIrp * MdIrp
Definition: mxum.h:103
static __inline FxRequest * RetrieveFromCsqContext(__in PMdIoCsqIrpContext pCsqContext)
Definition: fxrequest.hpp:1163
#define NULL
Definition: types.h:112
_Must_inspect_result_ NTSTATUS _In_ FxIrpQueue * IrpQueue
Definition: fxrequest.cpp:1823
__inline VOID MarkRemovedFromIrpQueue(VOID)
Definition: fxrequest.hpp:1100

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 {
2064  NTSTATUS Status;
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 }
#define FXREQUEST_QUEUE_TAG
Definition: fxrequest.hpp:47
MdIrp GetNextRequest(__out PMdIoCsqIrpContext *pCsqContext)
Definition: fxirpqueue.cpp:219
LONG NTSTATUS
Definition: precomp.h:26
FxRequest * pRequest
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NULL
Definition: types.h:112
_Must_inspect_result_ NTSTATUS _In_ FxIrpQueue * IrpQueue
Definition: fxrequest.cpp:1823
#define STATUS_SUCCESS
Definition: shellext.h:65
__inline VOID MarkRemovedFromIrpQueue(VOID)
Definition: fxrequest.hpp:1100
VOID _In_ NTSTATUS Status
Definition: fxrequest.cpp:376

◆ 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;
1237  NTSTATUS status;
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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:863
LONG NTSTATUS
Definition: precomp.h:26
struct _WDF_REQUEST_PARAMETERS WDF_REQUEST_PARAMETERS
status
Definition: fxrequest.cpp:1850
KIRQL irql
Definition: fxrequest.cpp:379
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define METHOD_NEITHER
Definition: nt_native.h:597
PFX_DRIVER_GLOBALS pFxDriverGlobals
enum _WDF_REQUEST_TYPE WDF_REQUEST_TYPE
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN FxVerifierIO
Definition: fxglobals.h:446
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
VOID CopyParameters(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: fxirpum.cpp:1691
ULONG GetParameterIoctlCodeBufferMethod(VOID)
Definition: fxirpum.cpp:1490
#define NULL
Definition: types.h:112
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define STATUS_SUCCESS
Definition: shellext.h:65
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
Definition: ps.c:97

◆ 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 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
LONG NTSTATUS
Definition: precomp.h:26
status
Definition: fxrequest.cpp:1850
KIRQL irql
Definition: fxrequest.cpp:379
UCHAR KIRQL
Definition: env_spec_w32.h:591
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
GLenum mode
Definition: glext.h:6217
BOOLEAN FxVerifierIO
Definition: fxglobals.h:446
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
KPROCESSOR_MODE GetRequestorMode(VOID)
Definition: fxirpum.cpp:329
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
Definition: ps.c:97

◆ GetStatus()

NTSTATUS FxRequest::GetStatus ( VOID  )

Definition at line 1187 of file fxrequest.cpp.

1190 {
1192  NTSTATUS status;
1193 
1195 
1197  KIRQL irql;
1198 
1199  Lock(&irql);
1200 
1201 
1202 
1203 
1204 
1205 
1206 
1207 
1208  status = m_Irp.GetStatus();
1209 
1210  Unlock(irql);
1211 
1212  return status;
1213  }
1214  else {
1215  return m_Irp.GetStatus();
1216  }
1217 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
LONG NTSTATUS
Definition: precomp.h:26
status
Definition: fxrequest.cpp:1850
KIRQL irql
Definition: fxrequest.cpp:379
UCHAR KIRQL
Definition: env_spec_w32.h:591
PFX_DRIVER_GLOBALS pFxDriverGlobals
BOOLEAN FxVerifierIO
Definition: fxglobals.h:446
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
NTSTATUS GetStatus()
Definition: fxirpum.cpp:466
Definition: ps.c:97

◆ 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 {
257  "WDFREQUEST 0x%p, Could not impersonate, %!STATUS!",
258  GetHandle(), status);
259  }
260 
261  return status;
262 }
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
HRESULT hr
Definition: shlfolder.c:183
_Must_inspect_result_ _In_ WDFREQUEST _In_ SECURITY_IMPERSONATION_LEVEL _In_ PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate
LONG NTSTATUS
Definition: precomp.h:26
#define TRACINGREQUEST
Definition: dbgtrace.h:65
if SUCCEEDED(hr)
static NTSTATUS NtStatusFromHr(_In_ IWudfDeviceStack *DevStack, _In_ HRESULT Hr)
Definition: fxdeviceum.cpp:826
IWudfIrp * MdIrp
Definition: mxum.h:103
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:79
_Out_ PBOOLEAN _Out_ PBOOLEAN _Out_ PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: psfuncs.h:154
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ NTSTATUS GetIrp(__deref_out MdIrp *ppIrp)
Definition: fxrequest.hpp:975
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
__inline WDFREQUEST GetHandle(VOID)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97

◆ InsertHeadIrpQueue()

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

Definition at line 1908 of file fxrequest.cpp.

1912 {
1914  NTSTATUS status;
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 
1936  ASSERT(m_Completed == FALSE);
1937  ASSERT(m_IrpQueue == NULL);
1938 
1939  m_IrpQueue = IrpQueue;
1940 
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 }
_Must_inspect_result_ NTSTATUS InsertHeadRequest(__inout MdIrp Irp, __in_opt PMdIoCsqIrpContext CsqContext, __out_opt ULONG *pRequestCount)
Definition: fxirpqueue.cpp:168
#define FXREQUEST_QUEUE_TAG
Definition: fxrequest.hpp:47
LONG NTSTATUS
Definition: precomp.h:26
status
Definition: fxrequest.cpp:1850
#define RELEASE(_tag)
Definition: fxobject.hpp:50