ReactOS 0.4.16-dev-306-g647d351
fxvalidatefunctions.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft. All rights reserved.
4
5Module Name:
6
7 FxValidateFunctions.h
8
9Abstract:
10
11 Inline functions which validate external WDF data structures
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23 Made it mode agnostic
24
25 Moved request options validation to FxRequestValidateFunctions.hpp
26 in kmdf\inc\private
27
28 When request is merged FxRequestValidateFunctions.hpp can be moved to
29 shared directory
30
31--*/
32
33#ifndef _FXVALIDATEFUNCTIONS_H_
34#define _FXVALIDATEFUNCTIONS_H_
35
36extern "C" {
37
38#if defined(EVENT_TRACING)
39#include "FxValidateFunctions.hpp.tmh"
40#endif
41
42}
43
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};
58
62 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
65 );
66
69__inline
71 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
74 )
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}
110
113__inline
115 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
117 )
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}
161
162#endif // _FXVALIDATEFUNCTIONS_H_
LONG NTSTATUS
Definition: precomp.h:26
#define __in
Definition: dbghelp.h:35
#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_FUNCTIONS_FLAGS
@ 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
_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING String)
_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 FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
#define _Must_inspect_result_
Definition: no_sal2.h:62
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
#define STATUS_WDF_PARENT_NOT_SPECIFIED
Definition: wdfstatus.h:252
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170