@@ -19,6 +19,7 @@ pub use windows_sys::*;
19
19
pub type DWORD = c_ulong ;
20
20
pub type NonZeroDWORD = NonZero_c_ulong ;
21
21
pub type LARGE_INTEGER = c_longlong ;
22
+ #[ cfg_attr( target_vendor = "uwp" , allow( unused) ) ]
22
23
pub type LONG = c_long ;
23
24
pub type UINT = c_uint ;
24
25
pub type WCHAR = u16 ;
@@ -50,6 +51,9 @@ pub type CONDITION_VARIABLE = RTL_CONDITION_VARIABLE;
50
51
pub type SRWLOCK = RTL_SRWLOCK ;
51
52
pub type INIT_ONCE = RTL_RUN_ONCE ;
52
53
54
+ #[ cfg( target_vendor = "uwp" ) ]
55
+ pub const STATUS_NOT_IMPLEMENTED : NTSTATUS = 0xC0000002_u32 as _ ;
56
+
53
57
pub const CONDITION_VARIABLE_INIT : CONDITION_VARIABLE = CONDITION_VARIABLE { Ptr : ptr:: null_mut ( ) } ;
54
58
pub const SRWLOCK_INIT : SRWLOCK = SRWLOCK { Ptr : ptr:: null_mut ( ) } ;
55
59
pub const INIT_ONCE_STATIC_INIT : INIT_ONCE = INIT_ONCE { Ptr : ptr:: null_mut ( ) } ;
@@ -267,6 +271,8 @@ pub unsafe fn getaddrinfo(
267
271
windows_sys:: getaddrinfo ( node. cast :: < u8 > ( ) , service. cast :: < u8 > ( ) , hints, res)
268
272
}
269
273
274
+ cfg_if:: cfg_if! {
275
+ if #[ cfg( not( target_vendor = "uwp" ) ) ] {
270
276
pub unsafe fn NtReadFile (
271
277
filehandle: BorrowedHandle <' _>,
272
278
event: HANDLE ,
@@ -313,6 +319,8 @@ pub unsafe fn NtWriteFile(
313
319
key. map( |k| k as * const u32 ) . unwrap_or( ptr:: null( ) ) ,
314
320
)
315
321
}
322
+ }
323
+ }
316
324
317
325
// Functions that aren't available on every version of Windows that we support,
318
326
// but we still use them and just provide some form of a fallback implementation.
@@ -376,4 +384,54 @@ compat_fn_with_fallback! {
376
384
) -> NTSTATUS {
377
385
panic!( "keyed events not available" )
378
386
}
387
+
388
+ // These functions are available on UWP when lazily loaded. They will fail WACK if loaded statically.
389
+ #[ cfg( target_vendor = "uwp" ) ]
390
+ pub fn NtCreateFile (
391
+ filehandle: * mut HANDLE ,
392
+ desiredaccess: FILE_ACCESS_RIGHTS ,
393
+ objectattributes: * const OBJECT_ATTRIBUTES ,
394
+ iostatusblock: * mut IO_STATUS_BLOCK ,
395
+ allocationsize: * const i64 ,
396
+ fileattributes: FILE_FLAGS_AND_ATTRIBUTES ,
397
+ shareaccess: FILE_SHARE_MODE ,
398
+ createdisposition: NTCREATEFILE_CREATE_DISPOSITION ,
399
+ createoptions: NTCREATEFILE_CREATE_OPTIONS ,
400
+ eabuffer: * const :: core:: ffi:: c_void,
401
+ ealength: u32
402
+ ) -> NTSTATUS {
403
+ STATUS_NOT_IMPLEMENTED
404
+ }
405
+ #[ cfg( target_vendor = "uwp" ) ]
406
+ pub fn NtReadFile (
407
+ filehandle: BorrowedHandle <' _>,
408
+ event: HANDLE ,
409
+ apcroutine: PIO_APC_ROUTINE ,
410
+ apccontext: * mut c_void,
411
+ iostatusblock: & mut IO_STATUS_BLOCK ,
412
+ buffer: * mut crate :: mem:: MaybeUninit <u8 >,
413
+ length: ULONG ,
414
+ byteoffset: Option <& LARGE_INTEGER >,
415
+ key: Option <& ULONG >
416
+ ) -> NTSTATUS {
417
+ STATUS_NOT_IMPLEMENTED
418
+ }
419
+ #[ cfg( target_vendor = "uwp" ) ]
420
+ pub fn NtWriteFile (
421
+ filehandle: BorrowedHandle <' _>,
422
+ event: HANDLE ,
423
+ apcroutine: PIO_APC_ROUTINE ,
424
+ apccontext: * mut c_void,
425
+ iostatusblock: & mut IO_STATUS_BLOCK ,
426
+ buffer: * const u8 ,
427
+ length: ULONG ,
428
+ byteoffset: Option <& LARGE_INTEGER >,
429
+ key: Option <& ULONG >
430
+ ) -> NTSTATUS {
431
+ STATUS_NOT_IMPLEMENTED
432
+ }
433
+ #[ cfg( target_vendor = "uwp" ) ]
434
+ pub fn RtlNtStatusToDosError ( Status : NTSTATUS ) -> ULONG {
435
+ Status as ULONG
436
+ }
379
437
}
0 commit comments