File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -326,7 +326,9 @@ union IO_STATUS_BLOCK_union {
326
326
}
327
327
impl Default for IO_STATUS_BLOCK_union {
328
328
fn default ( ) -> Self {
329
- Self { Pointer : ptr:: null_mut ( ) }
329
+ let mut this = Self { Pointer : ptr:: null_mut ( ) } ;
330
+ this. Status = STATUS_PENDING ;
331
+ this
330
332
}
331
333
}
332
334
#[ repr( C ) ]
@@ -335,6 +337,16 @@ pub struct IO_STATUS_BLOCK {
335
337
u : IO_STATUS_BLOCK_union ,
336
338
pub Information : usize ,
337
339
}
340
+ impl IO_STATUS_BLOCK {
341
+ pub fn status ( & self ) -> NTSTATUS {
342
+ // SAFETY: If `self.u.Status` was set then this is obviously safe.
343
+ // If `self.u.Pointer` was set then this is the equivalent to converting
344
+ // the pointer to an integer, which is also safe.
345
+ // Currently the only safe way to construct `IO_STATUS_BLOCK` outside of
346
+ // this module is to call the `default` method, which sets the `Status`.
347
+ unsafe { self . u . Status }
348
+ }
349
+ }
338
350
339
351
pub type LPOVERLAPPED_COMPLETION_ROUTINE = unsafe extern "system" fn (
340
352
dwErrorCode : DWORD ,
Original file line number Diff line number Diff line change @@ -248,6 +248,13 @@ impl Handle {
248
248
offset. map ( |n| n as _ ) . as_ref ( ) ,
249
249
None ,
250
250
) ;
251
+
252
+ let status = if status == c:: STATUS_PENDING {
253
+ c:: WaitForSingleObject ( self . as_raw_handle ( ) , c:: INFINITE ) ;
254
+ io_status. status ( )
255
+ } else {
256
+ status
257
+ } ;
251
258
match status {
252
259
// If the operation has not completed then abort the process.
253
260
// Doing otherwise means that the buffer and stack may be written to
@@ -291,6 +298,12 @@ impl Handle {
291
298
None ,
292
299
)
293
300
} ;
301
+ let status = if status == c:: STATUS_PENDING {
302
+ unsafe { c:: WaitForSingleObject ( self . as_raw_handle ( ) , c:: INFINITE ) } ;
303
+ io_status. status ( )
304
+ } else {
305
+ status
306
+ } ;
294
307
match status {
295
308
// If the operation has not completed then abort the process.
296
309
// Doing otherwise means that the buffer may be read and the stack
You can’t perform that action at this time.
0 commit comments