@@ -54,7 +54,13 @@ use wdk_sys::{
54
54
ULONG ,
55
55
WDFOBJECT ,
56
56
WDFREQUEST ,
57
+ WDF_DRIVER_CONFIG ,
58
+ WDF_DRIVER_VERSION_AVAILABLE_PARAMS ,
59
+ WDF_IO_QUEUE_CONFIG ,
60
+ WDF_OBJECT_ATTRIBUTES ,
57
61
WDF_OBJECT_CONTEXT_TYPE_INFO ,
62
+ WDF_PNPPOWER_EVENT_CALLBACKS ,
63
+ WDF_TIMER_CONFIG ,
58
64
} ;
59
65
mod wdf_object_context;
60
66
use core:: sync:: atomic:: AtomicI32 ;
@@ -100,3 +106,114 @@ pub struct RequestContext {
100
106
cancel_completion_ownership_count : AtomicI32 ,
101
107
}
102
108
wdf_declare_context_type_with_name ! ( RequestContext , request_get_context) ;
109
+
110
+ // None of the below SIZE constants should be needed after an equivalent `WDF_STRUCTURE_SIZE` macro is added to `wdk-sys`: https://github.com/microsoft/windows-drivers-rs/issues/242
111
+
112
+ #[ allow(
113
+ clippy:: cast_possible_truncation,
114
+ reason = "size_of::<WDF_DRIVER_CONFIG>() is known to fit in ULONG due to below const assert"
115
+ ) ]
116
+ const WDF_DRIVER_CONFIG_SIZE : ULONG = {
117
+ const S : usize = core:: mem:: size_of :: < WDF_DRIVER_CONFIG > ( ) ;
118
+ const {
119
+ assert ! (
120
+ S <= ULONG :: MAX as usize ,
121
+ "size_of::<WDF_DRIVER_CONFIG>() should fit in ULONG"
122
+ ) ;
123
+ } ;
124
+ S as ULONG
125
+ } ;
126
+
127
+ #[ allow(
128
+ clippy:: cast_possible_truncation,
129
+ reason = "size_of::<WDF_DRIVER_VERSION_AVAILABLE_PARAMS>() is known to fit in ULONG due to \
130
+ below const assert"
131
+ ) ]
132
+ const WDF_DRIVER_VERSION_AVAILABLE_PARAMS_SIZE : ULONG = {
133
+ const S : usize = core:: mem:: size_of :: < WDF_DRIVER_VERSION_AVAILABLE_PARAMS > ( ) ;
134
+ const {
135
+ assert ! (
136
+ S <= ULONG :: MAX as usize ,
137
+ "size_of::<WDF_DRIVER_VERSION_AVAILABLE_PARAMS>() should fit in ULONG"
138
+ ) ;
139
+ } ;
140
+ S as ULONG
141
+ } ;
142
+
143
+ #[ allow(
144
+ clippy:: cast_possible_truncation,
145
+ reason = "size_of::<WDF_IO_QUEUE_CONFIG>() is known to fit in ULONG due to below const assert"
146
+ ) ]
147
+ const WDF_IO_QUEUE_CONFIG_SIZE : ULONG = {
148
+ const S : usize = core:: mem:: size_of :: < WDF_IO_QUEUE_CONFIG > ( ) ;
149
+ const {
150
+ assert ! (
151
+ S <= ULONG :: MAX as usize ,
152
+ "size_of::<WDF_IO_QUEUE_CONFIG>() should fit in ULONG"
153
+ ) ;
154
+ } ;
155
+ S as ULONG
156
+ } ;
157
+
158
+ #[ allow(
159
+ clippy:: cast_possible_truncation,
160
+ reason = "size_of::<WDF_OBJECT_ATTRIBUTES>() is known to fit in ULONG due to below const \
161
+ assert"
162
+ ) ]
163
+ const WDF_OBJECT_ATTRIBUTES_SIZE : ULONG = {
164
+ const S : usize = core:: mem:: size_of :: < WDF_OBJECT_ATTRIBUTES > ( ) ;
165
+ const {
166
+ assert ! (
167
+ S <= ULONG :: MAX as usize ,
168
+ "size_of::<WDF_OBJECT_ATTRIBUTES>() should fit in ULONG"
169
+ ) ;
170
+ } ;
171
+ S as ULONG
172
+ } ;
173
+
174
+ #[ allow(
175
+ clippy:: cast_possible_truncation,
176
+ reason = "size_of::<WDF_OBJECT_CONTEXT_TYPE_INFO>() is known to fit in ULONG due to below \
177
+ const assert"
178
+ ) ]
179
+ const WDF_OBJECT_CONTEXT_TYPE_INFO_SIZE : ULONG = {
180
+ const S : usize = core:: mem:: size_of :: < WDF_OBJECT_CONTEXT_TYPE_INFO > ( ) ;
181
+ const {
182
+ assert ! (
183
+ S <= ULONG :: MAX as usize ,
184
+ "size_of::<WDF_OBJECT_CONTEXT_TYPE_INFO>() should fit in ULONG"
185
+ ) ;
186
+ } ;
187
+ S as ULONG
188
+ } ;
189
+
190
+ #[ allow(
191
+ clippy:: cast_possible_truncation,
192
+ reason = "size_of::<WDF_PNPPOWER_EVENT_CALLBACKS>() is known to fit in ULONG due to below \
193
+ const assert"
194
+ ) ]
195
+ const WDF_PNPPOWER_EVENT_CALLBACKS_SIZE : ULONG = {
196
+ const S : usize = core:: mem:: size_of :: < WDF_PNPPOWER_EVENT_CALLBACKS > ( ) ;
197
+ const {
198
+ assert ! (
199
+ S <= ULONG :: MAX as usize ,
200
+ "size_of::<WDF_PNPPOWER_EVENT_CALLBACKS>() should fit in ULONG"
201
+ ) ;
202
+ } ;
203
+ S as ULONG
204
+ } ;
205
+
206
+ #[ allow(
207
+ clippy:: cast_possible_truncation,
208
+ reason = "size_of::<WDF_TIMER_CONFIG>() is known to fit in ULONG due to below const assert"
209
+ ) ]
210
+ const WDF_TIMER_CONFIG_SIZE : ULONG = {
211
+ const S : usize = core:: mem:: size_of :: < WDF_TIMER_CONFIG > ( ) ;
212
+ const {
213
+ assert ! (
214
+ S <= ULONG :: MAX as usize ,
215
+ "size_of::<WDF_TIMER_CONFIG>() should fit in ULONG"
216
+ ) ;
217
+ } ;
218
+ S as ULONG
219
+ } ;
0 commit comments