ReactOS 0.4.15-dev-7846-g8ba6c66
fxvalidatefunctions.cpp File Reference
#include "fxobjectpch.hpp"
Include dependency graph for fxvalidatefunctions.cpp:

Go to the source code of this file.

Functions

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

Function Documentation

◆ FxValidateObjectAttributes()

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

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)
@ 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
#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().