ReactOS 0.4.16-dev-319-g6cf4263
fxiotargetself.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxIoTargetSelf.cpp
8
9Abstract:
10
11 This module implements the IO Target APIs
12
13Author:
14
15
16
17
18Environment:
19
20 Both kernel and user mode
21
22Revision History:
23
24--*/
25
26
27#include "../fxtargetsshared.hpp"
28
29extern "C" {
30#if defined(EVENT_TRACING)
31#include "FxIoTargetSelf.tmh"
32#endif
33}
34
36 _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
37 _In_ USHORT ObjectSize
38 ) :
39 FxIoTarget(FxDriverGlobals, ObjectSize, FX_TYPE_IO_TARGET_SELF),
40 m_DispatchQueue(NULL)
41{
42}
43
45{
46}
47
51 )
52/*++
53Routine Description:
54 Returns a pointer to the queue to which an IO sent to the Self
55 io target must be sent to
56
57Arguments:
58
59 MajorFunction - IRP_MJ_READ, IRP_MJ_WRITE, or IRP_MJ_DEVICE_CONTROL
60
61Returns:
62
63 FxIoQueue*
64
65--*/
66{
67 if (m_DispatchQueue != NULL) {
68 return m_DispatchQueue;
69 }
70
72}
73
74VOID
77 )
78/*++
79Routine Description:
80 send an MdIrp to the Self IO Target.
81
82Arguments:
83
84 MdIrp for IRP_MJ_READ, IRP_MJ_WRITE, or IRP_MJ_DEVICE_CONTROL
85
86Returns:
87
88 VOID
89
90Implementation Note:
91
92 Function body inspired by WdfDeviceWdmDispatchIrpToIoQueue API.
93
94--*/
95{
96 FxIrp irp(Irp);
101
102#if (FX_CORE_MODE == FX_CORE_USER_MODE)
103
104 //
105 // Prepare the request to forward to the inteternal target.
106 //
107 (static_cast<IWudfIoIrp2*>(Irp))->PrepareToForwardToSelf();
108
109#else
110 //
111 // Set Next Stack Location
112 //
114
115 //
116 // Set Device Object.
117 //
119#endif
120
122
123 //
124 // Retrieve Queue
125 //
127
128 if (queue == NULL) {
131 "Send WDFIOTARGET %p, No Dispatch Queue Found for Major Function %d",
134 goto Fail;
135 }
136
137 //
138 // Only read/writes/ctrls/internal_ctrls IRPs are allowed to be sent to
139 // Self IO Target
140 //
145 "Only Read/Write/Control/Internal-Control IRPs can be "
146 "forwarded to Self IO Target 0x%p, %!IRPMJ!, "
147 "IRP_MN %x, Device 0x%p, %!STATUS!",
151 goto Fail;
152 }
153
154 //
155 // Retrieve the InContextCallback function
156 //
158 queue->GetCxDeviceInfo());
159
160 //
161 // DispatchStep2 will convert the IRP into a WDFREQUEST, queue it and if
162 // possible dispatch the request to the driver.
163 // If a failure occurs, DispatchStep2 completes teh Irp
164 //
166 return;
167
168Fail:
169
173
174 return;
175}
176
#define VOID
Definition: acefi.h:82
LONG NTSTATUS
Definition: precomp.h:26
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
__inline FxPackage * GetDispatchPackage(__in UCHAR MajorFunction)
Definition: fxdevice.hpp:890
FxPkgIo * m_PkgIo
Definition: fxdevice.hpp:669
FxIoTargetSelf(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ USHORT ObjectSize)
FxIoQueue * GetDispatchQueue(_In_ UCHAR MajorFunction)
virtual VOID Send(_In_ MdIrp Irp)
FxIoQueue * m_DispatchQueue
Definition: fxirp.hpp:28
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
VOID SetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:1235
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
VOID SetCurrentDeviceObject(__in MdDeviceObject DeviceObject)
Definition: fxirpum.cpp:1362
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
CfxDevice * m_Device
Definition: fxobject.hpp:329
FxIoQueue * GetDispatchQueue(_In_ UCHAR MajorFunction)
Definition: fxpkgio.hpp:128
__inline FxIoInCallerContext * GetIoInCallerContextCallback(__in_opt FxCxDeviceInfo *CxDeviceInfo)
Definition: fxpkgio.hpp:396
_Must_inspect_result_ NTSTATUS __fastcall DispatchStep2(__inout MdIrp Irp, __in_opt FxIoInCallerContext *IoInCallerCtx, __in_opt FxIoQueue *Queue)
Definition: fxpkgio.cpp:342
Definition: _queue.h:67
_In_ PIRP Irp
Definition: csq.h:116
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
#define NULL
Definition: types.h:112
int Fail
Definition: ehthrow.cxx:24
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
return pObject GetObjectHandle()
FxIoInCallerContext * ioInCallerCtx
FxVerifierDbgBreakPoint(pFxDriverGlobals)
UCHAR majorFunction
FxIrp * irp
@ FX_TYPE_IO_TARGET_SELF
Definition: fxtypes.h:105
IWudfIrp * MdIrp
Definition: mxum.h:103
#define _In_
Definition: no_sal2.h:158
unsigned short USHORT
Definition: pedump.c:61
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
#define GetHandle(h)
Definition: treelist.c:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
#define IO_NO_INCREMENT
Definition: iotypes.h:598
unsigned char UCHAR
Definition: xmlstorage.h:181