ReactOS  0.4.15-dev-3303-g1ade494
fxrequestvalidatefunctions.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft. All rights reserved.
4 
5 Module Name:
6 
7  FxValidateFunctions.h
8 
9 Abstract:
10 
11  Split from FxValidateFunctions.hpp
12  (FxValidateFunctions.hpp has moved to shared\inc)
13 
14 Author:
15 
16 
17 
18 Environment:
19 
20  Both kernel and user mode
21 
22 Revision History:
23 
24 
25 --*/
26 #ifndef _FXREQUESTVALIDATEFUNCTIONS_HPP_
27 #define _FXREQUESTVALIDATEFUNCTIONS_HPP_
28 
29 #if defined(EVENT_TRACING)
30 extern "C" {
31 #include "FxRequestValidateFunctions.hpp.tmh"
32 }
33 #endif
34 
35 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
36 #define WDF_REQUEST_SEND_OPTIONS_VALID_FLAGS \
37  (WDF_REQUEST_SEND_OPTION_TIMEOUT | \
38  WDF_REQUEST_SEND_OPTION_SYNCHRONOUS | \
39  WDF_REQUEST_SEND_OPTION_IGNORE_TARGET_STATE | \
40  WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET)
41 
42 #else // (FX_CORE_MODE == FX_CORE_USER_MODE)
43 #define WDF_REQUEST_SEND_OPTIONS_VALID_FLAGS \
44  (WDF_REQUEST_SEND_OPTION_TIMEOUT | \
45  WDF_REQUEST_SEND_OPTION_SYNCHRONOUS | \
46  WDF_REQUEST_SEND_OPTION_IGNORE_TARGET_STATE | \
47  WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET | \
48  WDF_REQUEST_SEND_OPTION_IMPERSONATE_CLIENT | \
49  WDF_REQUEST_SEND_OPTION_IMPERSONATION_IGNORE_FAILURE)
50 #endif
51 
53 __inline
55  _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
58  )
59 {
60  if (Options == NULL) {
61  return STATUS_SUCCESS;
62  }
63 
64  if (Options->Size != sizeof(WDF_REQUEST_SEND_OPTIONS)) {
65  //
66  // Size is wrong, bale out
67  //
69  "Options %p Size incorrect, expected %d, got %d",
71  Options->Size);
72 
74  }
75 
76  if ((Options->Flags & ~WDF_REQUEST_SEND_OPTIONS_VALID_FLAGS) != 0) {
77  //
78  // Invalid flags
79  //
81  "Options %p Flags 0x%x invalid, valid mask is 0x%x",
82  Options, Options->Flags,
84 
86  }
87 
88 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
90 
93  //
94  // If WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET is set, no other bits
95  // can be set.
96  //
98  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
99  "Options %p, if WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET (0x%x) is "
100  "set, no other Flags 0x%x can be set",
102 
104  }
105 
106 #else // FX_CORE_USER_MODE
107 
111  //
112  // If WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET is set, no other bits
113  // can be set except impersonation flags.
114  //
116  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
117  "Options %p, if WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET (0x%x) is "
118  "set, no other Flags 0x%x can be set except impersonation flags "
119  "%!status!",
122 
124  }
125 
126  //
127  // Verify the send option flags.
128  //
130  //
131  // The request must be a create request (which also means it can never
132  // be a driver-created request).
133  //
134  if (Request == NULL ||
135  Request->IsAllocatedFromIo() == FALSE ||
136  Request->GetSubmitFxIrp()->GetMajorFunction() != IRP_MJ_CREATE) {
138  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
139  "WDF_REQUEST_SEND_OPTION impersonation flags may only "
140  "be set on Create requests. %!status!",
142 
144  }
145 
149  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
150  "Driver must set WDF_REQUEST_SEND_OPTION_IMPERSONATION_"
151  "IGNORE_FAILURE with WDF_REQUEST_SEND_OPTION_IMPERSONATE_CLIENT."
152  " %!status!", STATUS_INVALID_PARAMETER);
153 
155  }
156  }
157 
158 #endif // FX_CORE_MODE
159 
160  return STATUS_SUCCESS;
161 }
162 
163 #endif // _FXREQUESTVALIDATEFUNCTIONS_HPP_
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define _In_opt_
Definition: ms_sal.h:309
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define WDF_REQUEST_SEND_OPTIONS_VALID_FLAGS
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define TRACINGAPIERROR
Definition: dbgtrace.h:60
#define WDF_REQUEST_SEND_OPTION_IMPERSONATION_FLAGS
Definition: fxrequest.hpp:78
NTSTATUS __inline FxValidateRequestOptions(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ PWDF_REQUEST_SEND_OPTIONS Options, _In_opt_ FxRequestBase *Request=NULL)
#define FALSE
Definition: types.h:117
#define _In_
Definition: ms_sal.h:308
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3531
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65