ReactOS 0.4.15-dev-8235-gcd88a97
fxrequestapium.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxRequestApiUm.cpp
8
9Abstract:
10
11 This module implements FxRequest object
12
13Author:
14
15Environment:
16
17 User mode only
18
19Revision History:
20
21
22--*/
23#include "coreprivshared.hpp"
24
25// Tracing support
26extern "C" {
27#include "FxRequestApiUm.tmh"
28
33WDFEXPORT(WdfRequestImpersonate)(
34 _In_
36 _In_
37 WDFREQUEST Request,
38 _In_
40 _In_
41 PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate,
44 )
45
46/*++
47
48Routine Description:
49
50 The WdfRequestImpersonate method registers the event that the framework
51 should call for impersonation.
52
53Arguments:
54
55 Request : Request object
56
57 ImpersonationLevel : A SECURITY_IMPERSONATION_LEVEL-typed value that identifies
58 the level of impersonation.
59
60 EvtRequestImpersonate : A pointer to the IImpersonateCallback interface whose
61 method the framework calls for impersonation.
62
63Returns:
64
65 Impersonate returns STATUS_SUCCESS if the operation succeeds. Otherwise,
66 this method returns one of the error codes that are defined in ntstatus.h.
67
68--*/
69
70{
74
75 //
76 // Validate the request handle, and get the FxRequest*
77 //
79 Request,
81 (PVOID*)&pRequest,
83
87 "ImpersonationLevel is not a valid level, %!STATUS!",
88 status);
90 return status;
91 }
92
96 "EvtRequestImpersonate must not be NULL, %!STATUS!",
97 status);
99 return status;
100 }
101
102
103#if FX_VERBOSE_TRACE
105 "Enter: WDFREQUEST 0x%p", Request);
106#endif // FX_VERBOSE_TRACE
107
110 Context);
111
112 return status;
113}
114
116WDFAPI
117ULONG
118WDFEXPORT(WdfRequestGetRequestorProcessId)(
119 _In_
121 _In_
122 WDFREQUEST Request
123 )
124/*++
125
126Routine Description:
127
128 This routine returns the identifier of the process that sent the I/O request.
129
130 The WDM IRP is invalid once WdfRequestComplete is called, regardless
131 of any reference counts on the WDFREQUEST object.
132
133Arguments:
134
135 Request - Handle to the Request object
136
137Returns:
138
139 Process ID
140
141--*/
142{
147
148 //
149 // Validate the request handle, and get the FxRequest*
150 //
152 Request,
154 (PVOID*)&pRequest,
156
157#if FX_VERBOSE_TRACE
159 "Enter: WDFREQUEST 0x%p", Request);
160#endif // FX_VERBOSE_TRACE
161
163
166 "WDFREQUEST is already completed 0x%p, %!STATUS!",
167 Request, status);
169 return 0;
170 }
171
172 return irp->GetRequestorProcessId();
173}
174
176WDFAPI
178WDFEXPORT(WdfRequestIsFromUserModeDriver)(
179 _In_
181 _In_
182 WDFREQUEST Request
183 )
184{
188 MdIrp irp;
189
190 //
191 // Validate the request handle, and get the FxRequest*
192 //
194 Request,
196 (PVOID*)&pRequest,
198
199#if FX_VERBOSE_TRACE
201 "Enter: WDFREQUEST 0x%p", Request);
202#endif // FX_VERBOSE_TRACE
203
205
206 if (!NT_SUCCESS(status)) {
208 "WDFREQUEST is already completed 0x%p, %!STATUS!",
209 Request, status);
211 return FALSE;
212 }
213
214 return (pRequest->GetFxIrp()->GetIoIrp()->IsDriverCreated() ? TRUE : FALSE);
215}
216
218WDFAPI
219VOID
220WDFEXPORT(WdfRequestSetUserModeDriverInitiatedIo)(
221 _In_
223 _In_
224 WDFREQUEST Request,
225 _In_
227 )
228{
232 MdIrp irp;
233
234 //
235 // Validate the request handle, and get the FxRequest*
236 //
238 Request,
240 (PVOID*)&pRequest,
242
243#if FX_VERBOSE_TRACE
245 "Enter: WDFREQUEST 0x%p", Request);
246#endif // FX_VERBOSE_TRACE
247
249
250 if (!NT_SUCCESS(status)) {
252 "WDFREQUEST is already completed 0x%p, %!STATUS!",
253 Request, status);
255 return;
256 }
257
258 pRequest->GetFxIrp()->GetIoIrp()->SetUserModeDriverInitiatedIo(
260 );
261}
262
264WDFAPI
266WDFEXPORT(WdfRequestGetUserModeDriverInitiatedIo)(
267 _In_
269 _In_
270 WDFREQUEST Request
271 )
272{
276 MdIrp irp;
277
278 //
279 // Validate the request handle, and get the FxRequest*
280 //
282 Request,
284 (PVOID*)&pRequest,
286
287#if FX_VERBOSE_TRACE
289 "Enter: WDFREQUEST 0x%p", Request);
290#endif // FX_VERBOSE_TRACE
291
293
294 if (!NT_SUCCESS(status)) {
296 "WDFREQUEST is already completed 0x%p, %!STATUS!",
297 Request, status);
299 return FALSE;
300 }
301
302 return (pRequest->GetFxIrp()->GetIoIrp()->GetUserModeDriverInitiatedIo()
303 ? TRUE : FALSE);
304}
305
307WDFAPI
308VOID
309WDFEXPORT(WdfRequestSetActivityId)(
310 _In_
312 _In_
313 WDFREQUEST Request,
314 _In_
316 )
317{
321 MdIrp irp;
322
323 //
324 // Validate the request handle, and get the FxRequest*
325 //
327 Request,
329 (PVOID*)&pRequest,
331
332#if FX_VERBOSE_TRACE
334 "Enter: WDFREQUEST 0x%p", Request);
335#endif // FX_VERBOSE_TRACE
336
338
339 if (!NT_SUCCESS(status)) {
341 "WDFREQUEST is already completed 0x%p, %!STATUS!",
342 Request, status);
344 return;
345 }
346
347 pRequest->GetFxIrp()->GetIoIrp()->SetActivityId(ActivityId);
348}
349
351WDFAPI
353WDFEXPORT(WdfRequestRetrieveActivityId)(
354 _In_
356 _In_
357 WDFREQUEST Request,
358 _Out_
360 )
361{
365 MdIrp irp;
366
367 //
368 // Validate the request handle, and get the FxRequest*
369 //
371 Request,
373 (PVOID*)&pRequest,
375
377
378#if FX_VERBOSE_TRACE
380 "Enter: WDFREQUEST 0x%p", Request);
381#endif // FX_VERBOSE_TRACE
382
384
385 if (!NT_SUCCESS(status)) {
387 "WDFREQUEST is already completed 0x%p, %!STATUS!",
388 Request, status);
390 return status;
391 }
392
393 if (pRequest->GetFxIrp()->GetIoIrp()->IsActivityIdSet() == FALSE) {
396 "WDFREQUEST 0x%p Activity ID is not set for the "
397 "request, %!STATUS!", Request, status);
398 return status;
399 }
400
401 *ActivityId = *(pRequest->GetFxIrp()->GetIoIrp()->GetActivityId());
403
404 return status;
405}
406
408WDFAPI
410WDFEXPORT(WdfRequestGetEffectiveIoType)(
411 _In_
413 _In_
414 WDFREQUEST Request
415 )
416{
420 MdIrp irp;
421
422 //
423 // Validate the request handle, and get the FxRequest*
424 //
426 Request,
428 (PVOID*)&pRequest,
430
431#if FX_VERBOSE_TRACE
433 "Enter: WDFREQUEST 0x%p", Request);
434#endif // FX_VERBOSE_TRACE
435
437
438 if (!NT_SUCCESS(status)) {
440 "WDFREQUEST is already completed 0x%p, %!STATUS!",
441 Request, status);
444 }
445
446 return (WDF_DEVICE_IO_TYPE)(pRequest->GetFxIrp()->GetIoIrp()->GetTransferMode());
447}
448
449} // extern "C" the whole file
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
IWudfIoIrp * GetIoIrp(VOID)
Definition: fxirpum.cpp:1777
FxIrp * GetFxIrp(VOID)
Definition: fxrequest.hpp:957
_Must_inspect_result_ NTSTATUS GetIrp(__deref_out MdIrp *ppIrp)
Definition: fxrequest.hpp:975
_Must_inspect_result_ NTSTATUS Impersonate(_In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, _In_ PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate, _In_opt_ PVOID Context)
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxVerifierDbgBreakPoint(pFxDriverGlobals)
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
NTSTATUS status
_Must_inspect_result_ _In_ WDFREQUEST Request
_In_ WDFREQUEST _In_ LPGUID ActivityId
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Request, FX_TYPE_REQUEST,(PVOID *)&pRequest, &pFxDriverGlobals)
_Must_inspect_result_ _In_ WDFREQUEST _In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
_Must_inspect_result_ _In_ WDFREQUEST _In_ SECURITY_IMPERSONATION_LEVEL _In_ PFN_WDF_REQUEST_IMPERSONATE _In_opt_ PVOID Context
FxRequest * pRequest
_Must_inspect_result_ _In_ WDFREQUEST _In_ SECURITY_IMPERSONATION_LEVEL _In_ PFN_WDF_REQUEST_IMPERSONATE EvtRequestImpersonate
_In_ WDFREQUEST _In_ BOOLEAN IsUserModeDriverInitiated
MdIrp irp
@ FX_TYPE_REQUEST
Definition: fxtypes.h:53
enum _SECURITY_IMPERSONATION_LEVEL SECURITY_IMPERSONATION_LEVEL
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
IWudfIrp * MdIrp
Definition: mxum.h:103
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
enum _WDF_DEVICE_IO_TYPE WDF_DEVICE_IO_TYPE
@ WdfDeviceIoUndefined
Definition: wdfdevice.h:450
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define WDFAPI
Definition: wdftypes.h:53
#define VALID_IMPERSONATION_LEVEL(Level)
Definition: setypes.h:101