ReactOS 0.4.16-dev-306-g647d351
fxvalidatefunctions.hpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  FX_VALIDATE_FUNCTIONS_FLAGS {
  FX_VALIDATE_OPTION_NONE_SPECIFIED = 0x00000000 , FX_VALIDATE_OPTION_PARENT_NOT_ALLOWED = 0x00000001 , FX_VALIDATE_OPTION_EXECUTION_LEVEL_ALLOWED = 0x00000002 , FX_VALIDATE_OPTION_SYNCHRONIZATION_SCOPE_ALLOWED = 0x00000004 ,
  FX_VALIDATE_OPTION_ATTRIBUTES_REQUIRED = 0x00000008 , FX_VALIDATE_OPTION_PARENT_REQUIRED_FLAG = 0x00000010 , FX_VALIDATE_OPTION_PARENT_REQUIRED
}
 

Functions

_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
 
_Must_inspect_result_ NTSTATUS __inline FxValidateObjectAttributesForParentHandle (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
 
_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING String)
 

Enumeration Type Documentation

◆ FX_VALIDATE_FUNCTIONS_FLAGS

Enumerator
FX_VALIDATE_OPTION_NONE_SPECIFIED 
FX_VALIDATE_OPTION_PARENT_NOT_ALLOWED 
FX_VALIDATE_OPTION_EXECUTION_LEVEL_ALLOWED 
FX_VALIDATE_OPTION_SYNCHRONIZATION_SCOPE_ALLOWED 
FX_VALIDATE_OPTION_ATTRIBUTES_REQUIRED 
FX_VALIDATE_OPTION_PARENT_REQUIRED_FLAG 
FX_VALIDATE_OPTION_PARENT_REQUIRED 

Definition at line 44 of file fxvalidatefunctions.hpp.

44 {
50
51 // not used directly, use FX_VALIDATE_OPTION_PARENT_REQUIRED instead
53
54 // if a parent is required, the attributes themselves are requried
57};
@ FX_VALIDATE_OPTION_PARENT_REQUIRED
@ FX_VALIDATE_OPTION_NONE_SPECIFIED
@ FX_VALIDATE_OPTION_PARENT_REQUIRED_FLAG
@ FX_VALIDATE_OPTION_SYNCHRONIZATION_SCOPE_ALLOWED
@ FX_VALIDATE_OPTION_EXECUTION_LEVEL_ALLOWED
@ FX_VALIDATE_OPTION_ATTRIBUTES_REQUIRED
@ FX_VALIDATE_OPTION_PARENT_NOT_ALLOWED

Function Documentation

◆ FxValidateObjectAttributes()

_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PWDF_OBJECT_ATTRIBUTES  Attributes,
__in ULONG  Flags = FX_VALIDATE_OPTION_NONE_SPECIFIED 
)

Definition at line 45 of file fxvalidatefunctions.cpp.

50{
51 if (Attributes == NULL) {
54 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
55 "WDF_OBJECT_ATTRIBUTES required, %!STATUS!",
57
59 }
60 else {
61 return STATUS_SUCCESS;
62 }
63 }
64
65 if (Attributes->Size != sizeof(WDF_OBJECT_ATTRIBUTES)) {
66 //
67 // Size is wrong, bail out
68 //
70 "Attributes %p Size incorrect, expected %d, got %d, %!STATUS!",
73
75 }
76
77 if (Attributes->ContextTypeInfo != NULL) {
78#pragma prefast(suppress:__WARNING_REDUNDANTTEST, "different structs of the same size")
79 if (Attributes->ContextTypeInfo->Size !=
81 Attributes->ContextTypeInfo->Size !=
84 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
85 "Attributes %p ContextTypeInfo %p Size %d incorrect, expected %d, %!STATUS!",
86 Attributes, Attributes->ContextTypeInfo,
87 Attributes->ContextTypeInfo->Size,
89
91 }
92
93 //
94 // A ContextName != NULL and a ContextSize of 0 is allowed
95 //
96 if (Attributes->ContextTypeInfo->ContextSize > 0 &&
97 Attributes->ContextTypeInfo->ContextName == NULL) {
98
100 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
101 "Attributes %p ContextTypeInfo %p ContextSize %I64d is not zero, "
102 "but ContextName is NULL, %!STATUS!",
103 Attributes, Attributes->ContextTypeInfo,
104 Attributes->ContextTypeInfo->ContextSize,
106
108 }
109 }
110
111 if (Attributes->ContextSizeOverride > 0) {
112 if (Attributes->ContextTypeInfo == NULL) {
113 //
114 // Can't specify additional size without a type
115 //
117 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
118 "Attributes %p ContextSizeOverride of %I64d specified, but no type "
119 "information, %!STATUS!",
120 Attributes, Attributes->ContextSizeOverride,
122
124 }
125 else if (Attributes->ContextSizeOverride <
126 Attributes->ContextTypeInfo->ContextSize) {
128 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
129 "Attributes %p ContextSizeOverride %I64d < "
130 "ContextTypeInfo->ContextSize %I64d, %!STATUS!",
131 Attributes, Attributes->ContextSizeOverride,
132 Attributes->ContextTypeInfo->ContextSize,
134
136 }
137 }
138
140 if (Attributes->ParentObject != NULL) {
142 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
143 "Attributes %p does not allow a parent object to be set, set to "
144 "%p, %!STATUS!", Attributes, Attributes->ParentObject,
146
148 }
149 }
151 Attributes->ParentObject == NULL) {
153 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
154 "ParentObject required in WDF_OBJECT_ATTRIBUTES %p, %!STATUS!",
156
158 }
159
160 // Enum range checks
161 if ((Attributes->ExecutionLevel == WdfExecutionLevelInvalid) ||
162 (Attributes->ExecutionLevel > WdfExecutionLevelDispatch)) {
164 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
165 "Attributes %p execution level set to %d, out of range, %!STATUS!",
166 Attributes, Attributes->ExecutionLevel,
169 }
170
171 if ((Attributes->SynchronizationScope == WdfSynchronizationScopeInvalid) ||
172 (Attributes->SynchronizationScope > WdfSynchronizationScopeNone)) {
174 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
175 "Attributes %p synchronization scope set to %d, out of range, %!STATUS!",
176 Attributes, Attributes->SynchronizationScope,
179 }
180
182
183 //
184 // If synchronization is not allowed for this object,
185 // check the requested level to ensure none was specified.
186 //
187 if ((Attributes->SynchronizationScope != WdfSynchronizationScopeInheritFromParent) &&
188 (Attributes->SynchronizationScope != WdfSynchronizationScopeNone)) {
189
191 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
192 "Attributes %p does not allow synchronization scope too be set, "
193 "but was set to %!WDF_SYNCHRONIZATION_SCOPE!, %!STATUS!",
194 Attributes, Attributes->SynchronizationScope,
196
198 }
199 }
200
202
203 //
204 // If execution level restrictions are not allowed for this object,
205 // check the requested level to ensure none was specified.
206 //
207 if (Attributes->ExecutionLevel != WdfExecutionLevelInheritFromParent) {
209 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
210 "Attributes %p does not allow execution level to be set, but was"
211 " set to %!WDF_EXECUTION_LEVEL!, %!STATUS!",
212 Attributes, Attributes->ExecutionLevel,
214
216 }
217 }
218
219 return STATUS_SUCCESS;
220}
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define TRACINGAPIERROR
Definition: dbgtrace.h:60
#define NULL
Definition: types.h:112
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
@ WdfSynchronizationScopeInheritFromParent
Definition: wdfobject.h:63
@ WdfSynchronizationScopeNone
Definition: wdfobject.h:66
@ WdfSynchronizationScopeInvalid
Definition: wdfobject.h:62
@ WdfExecutionLevelDispatch
Definition: wdfobject.h:55
@ WdfExecutionLevelInheritFromParent
Definition: wdfobject.h:53
@ WdfExecutionLevelInvalid
Definition: wdfobject.h:52
#define STATUS_WDF_PARENT_ASSIGNMENT_NOT_ALLOWED
Definition: wdfstatus.h:225
#define STATUS_WDF_OBJECT_ATTRIBUTES_INVALID
Definition: wdfstatus.h:171
#define STATUS_WDF_SYNCHRONIZATION_SCOPE_INVALID
Definition: wdfstatus.h:234
#define STATUS_WDF_EXECUTION_LEVEL_INVALID
Definition: wdfstatus.h:243
#define STATUS_WDF_PARENT_NOT_SPECIFIED
Definition: wdfstatus.h:252
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by FxWmiProvider::_Create(), FxWmiInstanceExternal::_Create(), FxRequest::_Create(), FxDevice::_OpenKey(), FxUsbDevice::CreateIsochUrb(), FxUsbDevice::CreateUrb(), FxObjectAllocateContext(), if(), and VfAllocateContext().

◆ FxValidateObjectAttributesForParentHandle()

_Must_inspect_result_ NTSTATUS __inline FxValidateObjectAttributesForParentHandle ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PWDF_OBJECT_ATTRIBUTES  Attributes,
__in ULONG  Flags = FX_VALIDATE_OPTION_NONE_SPECIFIED 
)

Definition at line 70 of file fxvalidatefunctions.hpp.

75{
76 if (Attributes == NULL) {
79 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
80 "WDF_OBJECT_ATTRIBUTES required, %!STATUS!",
82 }
84 }
85
86 if (Attributes->Size != sizeof(WDF_OBJECT_ATTRIBUTES)) {
87 //
88 // Size is wrong, bail out
89 //
91 "Attributes %p Size incorrect, expected %d, got %d, %!STATUS!",
94
96 }
97
98 if (Attributes->ParentObject == NULL) {
101 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
102 "ParentObject required in WDF_OBJECT_ATTRIBUTES %p, %!STATUS!",
104 }
106 }
107
108 return STATUS_SUCCESS;
109}

Referenced by FxUsbDevice::CreateIsochUrb(), and FxUsbDevice::CreateUrb().

◆ FxValidateUnicodeString()

_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PCUNICODE_STRING  String 
)

Definition at line 114 of file fxvalidatefunctions.hpp.

118{
120
122
123 if (String->Length & 1) {
125 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
126 "UNICODE_STRING %p, Length %d is odd, %!STATUS!",
127 String, String->Length, status);
128
129 return status;
130 }
131
132 if (String->MaximumLength & 1) {
134 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
135 "UNICODE_STRING %p, MaximumLength %d is odd, %!STATUS!",
136 String, String->MaximumLength, status);
137
138 return status;
139 }
140
141 if (String->MaximumLength > 0 && String->Buffer == NULL) {
143 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
144 "UNICODE_STRING %p, MaximumLength %d > 0, Buffer is NULL, %!STATUS!",
145 String, String->MaximumLength, status);
146
147 return status;
148 }
149
150 if (String->Length > String->MaximumLength) {
152 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGAPIERROR,
153 "UNICODE_STRING %p, Length %d > MaximumLength %d, %!STATUS!",
154 String, String->Length, String->MaximumLength, status);
155
156 return status;
157 }
158
159 return STATUS_SUCCESS;
160}
LONG NTSTATUS
Definition: precomp.h:26
Definition: ps.c:97
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by __in_ecount(), FxIoTargetValidateOpenParams(), FxDevice::FxValidateInterfacePropertyData(), and if().