ReactOS  0.4.15-dev-2776-g4130f0b
fxrequestum.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxRequestUm.cpp
8 
9 Abstract:
10 
11  This module implements KM specific FxRequest object routines
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  User mode only
20 
21 Revision History:
22 
23 
24 --*/
25 
26 #include "coreprivshared.hpp"
27 
28 // Tracing support
29 extern "C" {
30 #include "FxRequestUm.tmh"
31 }
32 
33 VOID
35  VOID
36  )
37 /*++
38 
39 Routine Description:
40  This routine is never actually called by running code, it just has
41  WDFCASSERTs who upon failure, would not allow this file to be compiled.
42 
43  DO NOT REMOVE THIS FUNCTION just because it is not called by any running
44  code.
45 
46 Arguments:
47  None
48 
49 Return Value:
50  None
51 
52  --*/
53 {
54  ASSERTMSG("Not implemented for UMDF\n", FALSE);
55 }
56 
57 
61  __out PMDL *pMdl
62  )
63 {
65 
66  ASSERTMSG("Not implemented for UMDF\n", FALSE);
67 
69 }
70 
71 
75  __out PMDL *pMdl
76  )
77 /*++
78 
79 Routine Description:
80 
81  Return the IRP_MJ_DEVICE_CONTROL OutputBuffer as an MDL
82 
83  The MDL is automatically released when the request is completed.
84 
85  The MDL is not valid for a METHOD_NEITHER IRP_MJ_DEVICE_CONTROL,
86  or for any request other than IRP_MJ_DEVICE_CONTROL.
87 
88  The MDL is as follows for each buffering mode:
89 
90  METHOD_BUFFERED:
91 
92  MmBuildMdlForNonPagedPool(IoAllocateMdl(Irp->UserBuffer, ... ))
93 
94  METHOD_IN_DIRECT:
95 
96  Irp->MdlAddress
97 
98  METHOD_OUT_DIRECT:
99 
100  Irp->MdlAddress
101 
102  METHOD_NEITHER:
103 
104  NULL. Must use WdfDeviceInitSetIoInCallerContextCallback in order
105  to access the request in the calling threads address space before
106  it is placed into any I/O Queues.
107 
108  The MDL is only valid until the request is completed.
109 
110 Arguments:
111 
112  pMdl- Pointer location to return MDL ptr
113 
114 Returns:
115 
116  NTSTATUS
117 
118 --*/
119 {
121 
122  ASSERTMSG("Not implemented for UMDF\n", FALSE);
123 
124  return STATUS_NOT_IMPLEMENTED;
125 }
126 
128 NTSTATUS
130  __in PVOID Buffer,
131  __in ULONG Length,
133  )
134 
135 /*++
136 
137 Routine Description:
138 
139  Probe and lock a memory buffer for reading.
140 
141  This is to be called in the proper process context, and
142  will generate an FxRequestMemory object if successful.
143 
144  The FxRequestMemory object will be associated with the FxRequest
145  object, and is automatically released when the FxRequest is completed.
146 
147  This function performs validation to ensure that the current
148  thread is in the same process as the thread that originated
149  the I/O request.
150 
151 Arguments:
152 
153 
154  Buffer - Buffer to lock down
155 
156  Length - Length of buffer
157 
158  MemoryObject - FxRequestMemory object to return
159 
160 Returns:
161 
162  NTSTATUS
163 
164 --*/
165 
166 {
170 
171  ASSERTMSG("Not implemented for UMDF\n", FALSE);
172 
173  return STATUS_NOT_IMPLEMENTED;
174 }
175 
177 NTSTATUS
179  __in PVOID Buffer,
180  __in ULONG Length,
182  )
183 
184 /*++
185 
186 Routine Description:
187 
188  Probe and lock a memory buffer for writing.
189 
190  This is to be called in the proper process context, and
191  will generate an FxRequestMemory object if successful.
192 
193  The FxRequestMemory object will be associated with the FxRequest
194  object, and is automatically released when the FxRequest is completed.
195 
196  This function performs validation to ensure that the current
197  thread is in the same process as the thread that originated
198  the I/O request.
199 
200 Arguments:
201 
202 
203  Buffer - Buffer to lock down
204 
205  Length - Length of buffer
206 
207  MemoryObject - FxRequestMemory object to return
208 
209 Returns:
210 
211  NTSTATUS
212 
213 --*/
214 
215 {
219 
220  ASSERTMSG("Not implemented for UMDF\n", FALSE);
221 
222  return STATUS_NOT_IMPLEMENTED;
223 }
224 
225 NTSTATUS
228  _In_ PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate,
230  )
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 }
263 
264 
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define _Must_inspect_result_
Definition: no_sal2.h:62
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
HRESULT hr
Definition: shlfolder.c:183
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ WDFREQUEST _In_ SECURITY_IMPERSONATION_LEVEL _In_ PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS GetDeviceControlOutputMdl(__out PMDL *pMdl)
_Must_inspect_result_ NTSTATUS GetMdl(__out PMDL *pMdl)
Definition: fxrequestkm.cpp:80
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define _In_opt_
Definition: no_sal2.h:212
_Must_inspect_result_ NTSTATUS ProbeAndLockForWrite(__in PVOID Buffer, __in ULONG Length, __deref_out FxRequestMemory **pMemoryObject)
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
enum _SECURITY_IMPERSONATION_LEVEL SECURITY_IMPERSONATION_LEVEL
if SUCCEEDED(hr)
#define __out
Definition: dbghelp.h:62
_Must_inspect_result_ NTSTATUS ProbeAndLockForRead(__in PVOID Buffer, __in ULONG Length, __deref_out FxRequestMemory **pMemoryObject)
static NTSTATUS NtStatusFromHr(_In_ IWudfDeviceStack *DevStack, _In_ HRESULT Hr)
Definition: fxdeviceum.cpp:826
IWudfIrp * MdIrp
Definition: mxum.h:103
Definition: bufpool.h:45
#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
_Must_inspect_result_ _In_ WDFREQUEST _In_ size_t _Out_ WDFMEMORY * MemoryObject
Definition: wdfrequest.h:1470
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define _In_
Definition: no_sal2.h:158
_Must_inspect_result_ NTSTATUS Impersonate(_In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, _In_ PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate, _In_opt_ PVOID Context)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define __deref_out
Definition: dbghelp.h:26
unsigned int ULONG
Definition: retypes.h:1
__inline CfxDevice * GetDevice(VOID)
Definition: fxrequest.hpp:600
static VOID CheckAssumptions(VOID)
Definition: fxrequestkm.cpp:34
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ NTSTATUS GetIrp(__deref_out MdIrp *ppIrp)
Definition: fxrequest.hpp:975
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
__inline WDFREQUEST GetHandle(VOID)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97