ReactOS  0.4.15-dev-2965-g9a42267
fxiotargetself.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxIoTargetSelf.cpp
8 
9 Abstract:
10 
11  This module implements the IO Target APIs
12 
13 Author:
14 
15 
16 
17 
18 Environment:
19 
20  Both kernel and user mode
21 
22 Revision History:
23 
24 --*/
25 
26 
27 #include "../fxtargetsshared.hpp"
28 
29 extern "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 
48 FxIoQueue*
51  )
52 /*++
53 Routine Description:
54  Returns a pointer to the queue to which an IO sent to the Self
55  io target must be sent to
56 
57 Arguments:
58 
59  MajorFunction - IRP_MJ_READ, IRP_MJ_WRITE, or IRP_MJ_DEVICE_CONTROL
60 
61 Returns:
62 
63  FxIoQueue*
64 
65 --*/
66 {
67  if (m_DispatchQueue != NULL) {
68  return m_DispatchQueue;
69  }
70 
72 }
73 
74 VOID
76  _In_ MdIrp Irp
77  )
78 /*++
79 Routine Description:
80  send an MdIrp to the Self IO Target.
81 
82 Arguments:
83 
84  MdIrp for IRP_MJ_READ, IRP_MJ_WRITE, or IRP_MJ_DEVICE_CONTROL
85 
86 Returns:
87 
88  VOID
89 
90 Implementation 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 
168 Fail:
169 
171  irp.SetInformation(0);
173 
174  return;
175 }
176 
CfxDevice * m_Device
Definition: fxobject.hpp:329
FxIoQueue * queue
VOID SetCurrentDeviceObject(__in MdDeviceObject DeviceObject)
Definition: fxirpum.cpp:1362
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
FxIoQueue * GetDispatchQueue(_In_ UCHAR MajorFunction)
FxIoQueue * m_DispatchQueue
int Fail
Definition: ehthrow.cxx:24
_Must_inspect_result_ NTSTATUS __fastcall DispatchStep2(__inout MdIrp Irp, __in_opt FxIoInCallerContext *IoInCallerCtx, __in_opt FxIoQueue *Queue)
Definition: fxpkgio.cpp:342
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
WDFIOTARGET GetHandle(VOID)
Definition: fxiotarget.hpp:307
virtual VOID Send(_In_ MdIrp Irp)
VOID SetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:1235
_In_ PIRP Irp
Definition: csq.h:116
__inline FxPackage * GetDispatchPackage(__in UCHAR MajorFunction)
Definition: fxdevice.hpp:890
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
Definition: _queue.h:59
FxIoInCallerContext * ioInCallerCtx
#define _In_
Definition: ms_sal.h:308
IWudfIrp * MdIrp
Definition: mxum.h:103
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
unsigned char UCHAR
Definition: xmlstorage.h:181
FxIoQueue * GetDispatchQueue(_In_ UCHAR MajorFunction)
Definition: fxpkgio.hpp:128
FxPkgIo * m_PkgIo
Definition: fxdevice.hpp:669
#define VOID
Definition: acefi.h:82
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
unsigned short USHORT
Definition: pedump.c:61
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
UCHAR majorFunction
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
#define IO_NO_INCREMENT
Definition: iotypes.h:598
FxIoTargetSelf(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ USHORT ObjectSize)
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
static SERVICE_STATUS status
Definition: service.c:31
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
__inline FxIoInCallerContext * GetIoInCallerContextCallback(__in_opt FxCxDeviceInfo *CxDeviceInfo)
Definition: fxpkgio.hpp:396
FxIrp * irp
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97