ReactOS 0.4.15-dev-8119-g4fb2fdb
FxIoContext Struct Reference

#include <fxiotarget.hpp>

Inheritance diagram for FxIoContext:
Collaboration diagram for FxIoContext:

Public Member Functions

 FxIoContext (VOID)
 
virtual ~FxIoContext (VOID)
 
VOID StoreAndReferenceOtherMemory (__in FxRequestBuffer *Buffer)
 
virtual VOID ReleaseAndRestore (__in FxRequestBase *Request)
 
VOID ClearBuffer (VOID)
 
VOID SetBufferAndLength (__in PVOID Buffer, __in size_t BufferLength, __in BOOLEAN CopyBackToBuffer)
 
VOID CopyParameters (__in FxRequestBase *Request)
 
VOID CaptureState (__in FxIrp *Irp)
 
VOID SwapIrpBuffer (_In_ FxRequestBase *Request, _In_ ULONG NewInputBufferCb, _In_reads_bytes_opt_(NewInputBufferCb) PVOID NewInputBuffer, _In_ ULONG NewOutputBufferCb, _In_reads_bytes_opt_(NewOutputBufferCb) PVOID NewOutputBuffer)
 
- Public Member Functions inherited from FxRequestContext
 FxRequestContext (__in FX_REQUEST_CONTEXT_TYPE Type)
 
virtual ~FxRequestContext (VOID)
 
virtual VOID Dispose (VOID)
 
virtual VOID StoreAndReferenceMemory (__in FxRequestBuffer *Buffer)
 
virtual VOID ReleaseAndRestore (__in FxRequestBase *Request)
 
__inline BOOLEAN IsType (__in FX_REQUEST_CONTEXT_TYPE Type)
 
virtual VOID CopyParameters (__in FxRequestBase *Request)
 
VOID FormatWriteParams (__in_opt IFxMemory *WriteMemory, __in_opt PWDFMEMORY_OFFSET WriteOffsets)
 
VOID FormatReadParams (__in_opt IFxMemory *ReadMemory, __in_opt PWDFMEMORY_OFFSET ReadOffsets)
 
VOID FormatOtherParams (__in FxInternalIoctlParams *InternalIoctlParams)
 
- Public Member Functions inherited from FxStump
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in POOL_TYPE PoolType)
 
VOID operator delete (__in PVOID pointer)
 
PVOID operator new[] (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
VOID operator delete[] (__in PVOID pointer)
 

Public Attributes

PVOID m_BufferToFree
 
PVOID m_OriginalSystemBuffer
 
PVOID m_OriginalUserBuffer
 
PMDL m_MdlToFree
 
union {
   PMDL   m_OriginalMdl
 
   PFX_DRIVER_GLOBALS   m_DriverGlobals
 
}; 
 
ULONG m_OriginalFlags
 
size_t m_BufferToFreeLength
 
size_t m_MdlToFreeSize
 
BOOLEAN m_CopyBackToBuffer
 
BOOLEAN m_UnlockPages
 
BOOLEAN m_RestoreState
 
UCHAR m_MajorFunction
 
IFxMemorym_OtherMemory
 
- Public Attributes inherited from FxRequestContext
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
 
IFxMemorym_RequestMemory
 
FX_REQUEST_CONTEXT_TYPE m_RequestType
 

Additional Inherited Members

- Protected Member Functions inherited from FxRequestContext
VOID __inline InitCompletionParams (VOID)
 
- Protected Member Functions inherited from FxStump
 FxStump (VOID)
 
- Static Protected Member Functions inherited from FxRequestContext
static VOID _StoreAndReferenceMemoryWorker (__in PVOID Tag, __deref_out_opt IFxMemory **PPMemory, __in FxRequestBuffer *Buffer)
 

Detailed Description

Definition at line 32 of file fxiotarget.hpp.

Constructor & Destructor Documentation

◆ FxIoContext()

__inline FxIoContext::FxIoContext ( VOID  )

Definition at line 32 of file fxiotargetkm.hpp.

34 :
47{
48}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
PVOID m_OriginalSystemBuffer
Definition: fxiotarget.hpp:92
PVOID m_BufferToFree
Definition: fxiotarget.hpp:91
BOOLEAN m_RestoreState
Definition: fxiotarget.hpp:113
PMDL m_MdlToFree
Definition: fxiotarget.hpp:94
IFxMemory * m_OtherMemory
Definition: fxiotarget.hpp:115
BOOLEAN m_UnlockPages
Definition: fxiotarget.hpp:105
BOOLEAN m_CopyBackToBuffer
Definition: fxiotarget.hpp:104
size_t m_MdlToFreeSize
Definition: fxiotarget.hpp:103
PVOID m_OriginalUserBuffer
Definition: fxiotarget.hpp:93
size_t m_BufferToFreeLength
Definition: fxiotarget.hpp:102
PMDL m_OriginalMdl
Definition: fxiotarget.hpp:96

◆ ~FxIoContext()

__inline FxIoContext::~FxIoContext ( VOID  )
virtual

Definition at line 51 of file fxiotargetkm.hpp.

54{
55 //
56 // Free the buffer allocated for the request, reset m_CopyBackToBuffer
57 // to FALSE.
58 // NOTE: We delay the freeing of the buffer on purpose.
59 //
61
62 //
63 // Free the MDL allocated for the request
64 //
65 if (m_MdlToFree != NULL) {
66 //
67 // Being defensive here, MmUnlockPages should have been done in
68 // ReleaseAndRestore.
69 //
70 if (m_UnlockPages) {
73 }
74
77 }
78}
VOID __inline FxMdlFree(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PMDL Mdl)
Definition: fxmdl.h:60
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435
PFX_DRIVER_GLOBALS m_DriverGlobals
Definition: fxiotarget.hpp:97
VOID ClearBuffer(VOID)

Member Function Documentation

◆ CaptureState()

__inline VOID FxIoContext::CaptureState ( __in FxIrp Irp)

Definition at line 202 of file fxiotargetkm.hpp.

205{
207 m_OriginalSystemBuffer = Irp->GetSystemBuffer();
208 m_OriginalUserBuffer = Irp->GetUserBuffer();
209 m_OriginalMdl = Irp->GetMdl();
210 m_OriginalFlags = Irp->GetFlags();
211}
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
ULONG m_OriginalFlags
Definition: fxiotarget.hpp:100

Referenced by FxIoTarget::FormatIoctlRequest(), and FxIoTarget::FormatIoRequest().

◆ ClearBuffer()

__inline VOID FxIoContext::ClearBuffer ( VOID  )

Definition at line 135 of file fxiotargetkm.hpp.

138{
139 if (m_BufferToFree != NULL) {
142 }
143
146}
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361

Referenced by ~FxIoContext().

◆ CopyParameters()

__inline VOID FxIoContext::CopyParameters ( __in FxRequestBase Request)
virtual

Reimplemented from FxRequestContext.

Definition at line 150 of file fxiotargetkm.hpp.

153{
154 switch (m_MajorFunction) {
155 case IRP_MJ_WRITE:
158 break;
159
160 case IRP_MJ_READ:
163 break;
164
167 m_CompletionParams.Parameters.Ioctl.Output.Length =
169 break;
170
171 default:
172 ASSERT(FALSE);
173 }
174
175 if (m_BufferToFree == NULL) {
176 return;
177 }
178
179 if (m_CopyBackToBuffer) {
180 FxIrp* irp = Request->GetSubmitFxIrp();
181
182 if (irp->GetUserBuffer() != NULL) {
183 //
184 // UserBuffer contains the caller's original output buffer.
185 // Copy the results back into the original buffer.
186 //
190 }
191
196 }
197 }
198}
Definition: fxirp.hpp:28
ULONG_PTR GetInformation()
Definition: fxirpum.cpp:513
PVOID GetUserBuffer()
Definition: fxirpum.cpp:633
FxIrp * irp
#define ASSERT(a)
Definition: mode.c:44
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
UCHAR m_MajorFunction
Definition: fxiotarget.hpp:114
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
struct _WDF_REQUEST_COMPLETION_PARAMS::@3892::@3894 Read
struct _WDF_REQUEST_COMPLETION_PARAMS::@3892::@3893 Write
union _WDF_REQUEST_COMPLETION_PARAMS::@3892 Parameters
struct _WDF_REQUEST_COMPLETION_PARAMS::@3892::@3895 Ioctl
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define IRP_MJ_INTERNAL_DEVICE_CONTROL

◆ ReleaseAndRestore()

__inline VOID FxIoContext::ReleaseAndRestore ( __in FxRequestBase Request)
virtual

Reimplemented from FxRequestContext.

Definition at line 82 of file fxiotargetkm.hpp.

85{
86 FxIrp* irp = NULL;
87
88 irp = Request->GetSubmitFxIrp();
89
90 if (m_RestoreState) {
99
101 }
102
103 //
104 // If there was a buffer present don't free the buffer here so that
105 // it can be reused for any request with the same size.
106 // Similarly if there was an MDL to be freed unlock the pages but dont free
107 // the Mdl so that it can be reused.
108 //
109 if (m_MdlToFree != NULL) {
110 if (m_UnlockPages) {
113 }
114
115
116 m_DriverGlobals = Request->GetDriverGlobals();
117 }
118
119 //
120 // Release the 2ndary buffer if we have an outstanding reference
121 //
122 if (m_OtherMemory != NULL) {
123 m_OtherMemory->RELEASE(this);
125 }
126
127 //
128 // Release the other buffer and all __super related fields
129 //
131}
VOID SetSystemBuffer(__in PVOID Value)
Definition: fxirpum.cpp:1313
VOID SetUserBuffer(__in PVOID Value)
Definition: fxirpum.cpp:1341
VOID SetFlags(__in ULONG Flags)
Definition: fxirpum.cpp:1266
VOID SetMdlAddress(__in PMDL Value)
Definition: fxirpum.cpp:1330
virtual VOID ReleaseAndRestore(__in FxRequestBase *Request)

◆ SetBufferAndLength()

__inline VOID FxIoContext::SetBufferAndLength ( __in PVOID  Buffer,
__in size_t  BufferLength,
__in BOOLEAN  CopyBackToBuffer 
)

Definition at line 215 of file fxiotargetkm.hpp.

220{
221 PVOID pOldBuffer;
222
223 pOldBuffer = m_BufferToFree;
226 m_CopyBackToBuffer = CopyBackToBuffer;
227
228 if (pOldBuffer != NULL) {
229 FxPoolFree(pOldBuffer);
230 }
231}
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by FxIoTarget::FormatIoctlRequest(), and FxIoTarget::FormatIoRequest().

◆ StoreAndReferenceOtherMemory()

VOID FxIoContext::StoreAndReferenceOtherMemory ( __in FxRequestBuffer Buffer)
inline

Definition at line 44 of file fxiotarget.hpp.

47 {
49 }
static VOID _StoreAndReferenceMemoryWorker(__in PVOID Tag, __deref_out_opt IFxMemory **PPMemory, __in FxRequestBuffer *Buffer)

Referenced by FxIoTarget::FormatIoctlRequest().

◆ SwapIrpBuffer()

__inline VOID FxIoContext::SwapIrpBuffer ( _In_ FxRequestBase Request,
_In_ ULONG  NewInputBufferCb,
_In_reads_bytes_opt_(NewInputBufferCb) PVOID  NewInputBuffer,
_In_ ULONG  NewOutputBufferCb,
_In_reads_bytes_opt_(NewOutputBufferCb) PVOID  NewOutputBuffer 
)

Definition at line 115 of file fxiotargetum.hpp.

122{
123 FxIrp* irp = NULL;
124
125 irp = Request->GetSubmitFxIrp();
126
128 irp->GetIoIrp()->SwapCurrentBuffer(
129 true,
130 NewInputBufferCb,
131 NewInputBuffer,
132 NewOutputBufferCb,
133 NewOutputBuffer,
134 &m_OriginalBufferInfo
135 );
136}
IWudfIoIrp * GetIoIrp(VOID)
Definition: fxirpum.cpp:1777

Member Data Documentation

◆ 

union { ... } FxIoContext::@4771

◆ m_BufferToFree

PVOID FxIoContext::m_BufferToFree

◆ m_BufferToFreeLength

size_t FxIoContext::m_BufferToFreeLength

◆ m_CopyBackToBuffer

BOOLEAN FxIoContext::m_CopyBackToBuffer

◆ m_DriverGlobals

PFX_DRIVER_GLOBALS FxIoContext::m_DriverGlobals

Definition at line 97 of file fxiotarget.hpp.

Referenced by ReleaseAndRestore(), and ~FxIoContext().

◆ m_MajorFunction

UCHAR FxIoContext::m_MajorFunction

◆ m_MdlToFree

PMDL FxIoContext::m_MdlToFree

◆ m_MdlToFreeSize

size_t FxIoContext::m_MdlToFreeSize

Definition at line 103 of file fxiotarget.hpp.

Referenced by FxIoTarget::FormatIoctlRequest(), and FxIoTarget::FormatIoRequest().

◆ m_OriginalFlags

ULONG FxIoContext::m_OriginalFlags

Definition at line 100 of file fxiotarget.hpp.

Referenced by CaptureState(), and ReleaseAndRestore().

◆ m_OriginalMdl

PMDL FxIoContext::m_OriginalMdl

Definition at line 96 of file fxiotarget.hpp.

Referenced by CaptureState(), and ReleaseAndRestore().

◆ m_OriginalSystemBuffer

PVOID FxIoContext::m_OriginalSystemBuffer

Definition at line 92 of file fxiotarget.hpp.

Referenced by CaptureState(), and ReleaseAndRestore().

◆ m_OriginalUserBuffer

PVOID FxIoContext::m_OriginalUserBuffer

Definition at line 93 of file fxiotarget.hpp.

Referenced by CaptureState(), and ReleaseAndRestore().

◆ m_OtherMemory

IFxMemory* FxIoContext::m_OtherMemory

Definition at line 115 of file fxiotarget.hpp.

Referenced by ReleaseAndRestore(), and StoreAndReferenceOtherMemory().

◆ m_RestoreState

BOOLEAN FxIoContext::m_RestoreState

Definition at line 113 of file fxiotarget.hpp.

Referenced by CaptureState(), ReleaseAndRestore(), and SwapIrpBuffer().

◆ m_UnlockPages

BOOLEAN FxIoContext::m_UnlockPages

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