1 //! C definitions used by libnative that don't belong in liblibc
3 #![allow(nonstandard_style)]
4 #![cfg_attr(test, allow(dead_code))]
5 #![unstable(issue = "none", feature = "windows_c")]
8 use crate::os
::raw
::{c_char, c_int, c_long, c_longlong, c_uint, c_ulong, c_ushort}
;
9 use crate::os
::windows
::io
::{BorrowedHandle, HandleOrInvalid, HandleOrNull}
;
11 use core
::ffi
::NonZero_c_ulong
;
13 use libc
::{c_void, size_t, wchar_t}
;
15 #[path = "c/errors.rs"] // c.rs is included from two places so we need to specify this
19 pub use self::EXCEPTION_DISPOSITION
::*;
20 pub use self::FILE_INFO_BY_HANDLE_CLASS
::*;
22 pub type DWORD_PTR
= ULONG_PTR
;
23 pub type DWORD
= c_ulong
;
24 pub type NonZeroDWORD
= NonZero_c_ulong
;
25 pub type HANDLE
= LPVOID
;
26 pub type HINSTANCE
= HANDLE
;
27 pub type HMODULE
= HINSTANCE
;
28 pub type HRESULT
= LONG
;
29 pub type BOOL
= c_int
;
31 pub type BOOLEAN
= BYTE
;
32 pub type GROUP
= c_uint
;
33 pub type LARGE_INTEGER
= c_longlong
;
34 pub type LONG
= c_long
;
35 pub type UINT
= c_uint
;
37 pub type USHORT
= c_ushort
;
38 pub type SIZE_T
= usize;
40 pub type CHAR
= c_char
;
41 pub type CCHAR
= c_char
;
42 pub type ULONG_PTR
= usize;
43 pub type ULONG
= c_ulong
;
44 pub type NTSTATUS
= LONG
;
45 pub type ACCESS_MASK
= DWORD
;
47 pub type LPBOOL
= *mut BOOL
;
48 pub type LPBYTE
= *mut BYTE
;
49 pub type LPCSTR
= *const CHAR
;
50 pub type LPCWSTR
= *const WCHAR
;
51 pub type LPDWORD
= *mut DWORD
;
52 pub type LPHANDLE
= *mut HANDLE
;
53 pub type LPOVERLAPPED
= *mut OVERLAPPED
;
54 pub type LPPROCESS_INFORMATION
= *mut PROCESS_INFORMATION
;
55 pub type LPSECURITY_ATTRIBUTES
= *mut SECURITY_ATTRIBUTES
;
56 pub type LPSTARTUPINFO
= *mut STARTUPINFO
;
57 pub type LPVOID
= *mut c_void
;
58 pub type LPWCH
= *mut WCHAR
;
59 pub type LPWIN32_FIND_DATAW
= *mut WIN32_FIND_DATAW
;
60 pub type LPWSADATA
= *mut WSADATA
;
61 pub type LPWSAPROTOCOL_INFO
= *mut WSAPROTOCOL_INFO
;
62 pub type LPWSTR
= *mut WCHAR
;
63 pub type LPFILETIME
= *mut FILETIME
;
64 pub type LPSYSTEM_INFO
= *mut SYSTEM_INFO
;
65 pub type LPWSABUF
= *mut WSABUF
;
66 pub type LPWSAOVERLAPPED
= *mut c_void
;
67 pub type LPWSAOVERLAPPED_COMPLETION_ROUTINE
= *mut c_void
;
69 pub type PCONDITION_VARIABLE
= *mut CONDITION_VARIABLE
;
70 pub type PLARGE_INTEGER
= *mut c_longlong
;
71 pub type PSRWLOCK
= *mut SRWLOCK
;
73 pub type SOCKET
= crate::os
::windows
::raw
::SOCKET
;
74 pub type socklen_t
= c_int
;
75 pub type ADDRESS_FAMILY
= USHORT
;
77 pub const TRUE
: BOOL
= 1;
78 pub const FALSE
: BOOL
= 0;
80 pub const CSTR_LESS_THAN
: c_int
= 1;
81 pub const CSTR_EQUAL
: c_int
= 2;
82 pub const CSTR_GREATER_THAN
: c_int
= 3;
84 pub const FILE_ATTRIBUTE_READONLY
: DWORD
= 0x1;
85 pub const FILE_ATTRIBUTE_DIRECTORY
: DWORD
= 0x10;
86 pub const FILE_ATTRIBUTE_REPARSE_POINT
: DWORD
= 0x400;
87 pub const INVALID_FILE_ATTRIBUTES
: DWORD
= DWORD
::MAX
;
89 pub const FILE_SHARE_DELETE
: DWORD
= 0x4;
90 pub const FILE_SHARE_READ
: DWORD
= 0x1;
91 pub const FILE_SHARE_WRITE
: DWORD
= 0x2;
93 pub const FILE_OPEN
: ULONG
= 0x00000001;
94 pub const FILE_OPEN_REPARSE_POINT
: ULONG
= 0x200000;
95 pub const OBJ_DONT_REPARSE
: ULONG
= 0x1000;
97 pub const CREATE_ALWAYS
: DWORD
= 2;
98 pub const CREATE_NEW
: DWORD
= 1;
99 pub const OPEN_ALWAYS
: DWORD
= 4;
100 pub const OPEN_EXISTING
: DWORD
= 3;
101 pub const TRUNCATE_EXISTING
: DWORD
= 5;
103 pub const FILE_LIST_DIRECTORY
: DWORD
= 0x1;
104 pub const FILE_WRITE_DATA
: DWORD
= 0x00000002;
105 pub const FILE_APPEND_DATA
: DWORD
= 0x00000004;
106 pub const FILE_WRITE_EA
: DWORD
= 0x00000010;
107 pub const FILE_WRITE_ATTRIBUTES
: DWORD
= 0x00000100;
108 pub const DELETE
: DWORD
= 0x10000;
109 pub const READ_CONTROL
: DWORD
= 0x00020000;
110 pub const SYNCHRONIZE
: DWORD
= 0x00100000;
111 pub const GENERIC_READ
: DWORD
= 0x80000000;
112 pub const GENERIC_WRITE
: DWORD
= 0x40000000;
113 pub const STANDARD_RIGHTS_WRITE
: DWORD
= READ_CONTROL
;
114 pub const FILE_GENERIC_WRITE
: DWORD
= STANDARD_RIGHTS_WRITE
116 | FILE_WRITE_ATTRIBUTES
121 pub const FILE_FLAG_OPEN_REPARSE_POINT
: DWORD
= 0x00200000;
122 pub const FILE_FLAG_BACKUP_SEMANTICS
: DWORD
= 0x02000000;
123 pub const SECURITY_SQOS_PRESENT
: DWORD
= 0x00100000;
125 pub const FIONBIO
: c_ulong
= 0x8004667e;
129 pub struct WIN32_FIND_DATAW
{
130 pub dwFileAttributes
: DWORD
,
131 pub ftCreationTime
: FILETIME
,
132 pub ftLastAccessTime
: FILETIME
,
133 pub ftLastWriteTime
: FILETIME
,
134 pub nFileSizeHigh
: DWORD
,
135 pub nFileSizeLow
: DWORD
,
136 pub dwReserved0
: DWORD
,
137 pub dwReserved1
: DWORD
,
138 pub cFileName
: [wchar_t
; 260], // #define MAX_PATH 260
139 pub cAlternateFileName
: [wchar_t
; 14],
141 impl Clone
for WIN32_FIND_DATAW
{
142 fn clone(&self) -> Self {
147 pub const WSA_FLAG_OVERLAPPED
: DWORD
= 0x01;
148 pub const WSA_FLAG_NO_HANDLE_INHERIT
: DWORD
= 0x80;
150 pub const WSADESCRIPTION_LEN
: usize = 256;
151 pub const WSASYS_STATUS_LEN
: usize = 128;
152 pub const WSAPROTOCOL_LEN
: DWORD
= 255;
153 pub const INVALID_SOCKET
: SOCKET
= !0;
155 pub const MAX_PROTOCOL_CHAIN
: DWORD
= 7;
157 pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE
: usize = 16 * 1024;
158 pub const FSCTL_GET_REPARSE_POINT
: DWORD
= 0x900a8;
159 pub const IO_REPARSE_TAG_SYMLINK
: DWORD
= 0xa000000c;
160 pub const IO_REPARSE_TAG_MOUNT_POINT
: DWORD
= 0xa0000003;
161 pub const SYMLINK_FLAG_RELATIVE
: DWORD
= 0x00000001;
162 pub const FSCTL_SET_REPARSE_POINT
: DWORD
= 0x900a4;
164 pub const SYMBOLIC_LINK_FLAG_DIRECTORY
: DWORD
= 0x1;
165 pub const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
: DWORD
= 0x2;
167 // Note that these are not actually HANDLEs, just values to pass to GetStdHandle
168 pub const STD_INPUT_HANDLE
: DWORD
= -10i32 as DWORD
;
169 pub const STD_OUTPUT_HANDLE
: DWORD
= -11i32 as DWORD
;
170 pub const STD_ERROR_HANDLE
: DWORD
= -12i32 as DWORD
;
172 pub const PROGRESS_CONTINUE
: DWORD
= 0;
174 pub const E_NOTIMPL
: HRESULT
= 0x80004001u32 as HRESULT
;
176 pub const INVALID_HANDLE_VALUE
: HANDLE
= ptr
::invalid_mut(!0);
178 pub const FACILITY_NT_BIT
: DWORD
= 0x1000_0000;
180 pub const FORMAT_MESSAGE_FROM_SYSTEM
: DWORD
= 0x00001000;
181 pub const FORMAT_MESSAGE_FROM_HMODULE
: DWORD
= 0x00000800;
182 pub const FORMAT_MESSAGE_IGNORE_INSERTS
: DWORD
= 0x00000200;
184 pub const TLS_OUT_OF_INDEXES
: DWORD
= 0xFFFFFFFF;
186 pub const DLL_THREAD_DETACH
: DWORD
= 3;
187 pub const DLL_PROCESS_DETACH
: DWORD
= 0;
189 pub const INFINITE
: DWORD
= !0;
191 pub const DUPLICATE_SAME_ACCESS
: DWORD
= 0x00000002;
193 pub const CONDITION_VARIABLE_INIT
: CONDITION_VARIABLE
= CONDITION_VARIABLE { ptr: ptr::null_mut() }
;
194 pub const SRWLOCK_INIT
: SRWLOCK
= SRWLOCK { ptr: ptr::null_mut() }
;
196 pub const DETACHED_PROCESS
: DWORD
= 0x00000008;
197 pub const CREATE_NEW_PROCESS_GROUP
: DWORD
= 0x00000200;
198 pub const CREATE_UNICODE_ENVIRONMENT
: DWORD
= 0x00000400;
199 pub const STARTF_USESTDHANDLES
: DWORD
= 0x00000100;
201 pub const AF_INET
: c_int
= 2;
202 pub const AF_INET6
: c_int
= 23;
203 pub const SD_BOTH
: c_int
= 2;
204 pub const SD_RECEIVE
: c_int
= 0;
205 pub const SD_SEND
: c_int
= 1;
206 pub const SOCK_DGRAM
: c_int
= 2;
207 pub const SOCK_STREAM
: c_int
= 1;
208 pub const SOCKET_ERROR
: c_int
= -1;
209 pub const SOL_SOCKET
: c_int
= 0xffff;
210 pub const SO_LINGER
: c_int
= 0x0080;
211 pub const SO_RCVTIMEO
: c_int
= 0x1006;
212 pub const SO_SNDTIMEO
: c_int
= 0x1005;
213 pub const IPPROTO_IP
: c_int
= 0;
214 pub const IPPROTO_TCP
: c_int
= 6;
215 pub const IPPROTO_IPV6
: c_int
= 41;
216 pub const TCP_NODELAY
: c_int
= 0x0001;
217 pub const IP_TTL
: c_int
= 4;
218 pub const IPV6_V6ONLY
: c_int
= 27;
219 pub const SO_ERROR
: c_int
= 0x1007;
220 pub const SO_BROADCAST
: c_int
= 0x0020;
221 pub const IP_MULTICAST_LOOP
: c_int
= 11;
222 pub const IPV6_MULTICAST_LOOP
: c_int
= 11;
223 pub const IP_MULTICAST_TTL
: c_int
= 10;
224 pub const IP_ADD_MEMBERSHIP
: c_int
= 12;
225 pub const IP_DROP_MEMBERSHIP
: c_int
= 13;
226 pub const IPV6_ADD_MEMBERSHIP
: c_int
= 12;
227 pub const IPV6_DROP_MEMBERSHIP
: c_int
= 13;
228 pub const MSG_PEEK
: c_int
= 0x2;
231 #[derive(Copy, Clone)]
233 pub l_onoff
: c_ushort
,
234 pub l_linger
: c_ushort
,
239 pub imr_multiaddr
: in_addr
,
240 pub imr_interface
: in_addr
,
244 pub struct ipv6_mreq
{
245 pub ipv6mr_multiaddr
: in6_addr
,
246 pub ipv6mr_interface
: c_uint
,
249 pub const VOLUME_NAME_DOS
: DWORD
= 0x0;
250 pub const MOVEFILE_REPLACE_EXISTING
: DWORD
= 1;
252 pub const FILE_BEGIN
: DWORD
= 0;
253 pub const FILE_CURRENT
: DWORD
= 1;
254 pub const FILE_END
: DWORD
= 2;
256 pub const WAIT_OBJECT_0
: DWORD
= 0x00000000;
257 pub const WAIT_TIMEOUT
: DWORD
= 258;
258 pub const WAIT_FAILED
: DWORD
= 0xFFFFFFFF;
260 pub const PIPE_ACCESS_INBOUND
: DWORD
= 0x00000001;
261 pub const PIPE_ACCESS_OUTBOUND
: DWORD
= 0x00000002;
262 pub const FILE_FLAG_FIRST_PIPE_INSTANCE
: DWORD
= 0x00080000;
263 pub const FILE_FLAG_OVERLAPPED
: DWORD
= 0x40000000;
264 pub const PIPE_WAIT
: DWORD
= 0x00000000;
265 pub const PIPE_TYPE_BYTE
: DWORD
= 0x00000000;
266 pub const PIPE_REJECT_REMOTE_CLIENTS
: DWORD
= 0x00000008;
267 pub const PIPE_READMODE_BYTE
: DWORD
= 0x00000000;
269 pub const FD_SETSIZE
: usize = 64;
271 pub const STACK_SIZE_PARAM_IS_A_RESERVATION
: DWORD
= 0x00010000;
273 pub const STATUS_SUCCESS
: NTSTATUS
= 0x00000000;
274 pub const STATUS_DELETE_PENDING
: NTSTATUS
= 0xc0000056_u32 as _
;
275 pub const STATUS_INVALID_PARAMETER
: NTSTATUS
= 0xc000000d_u32 as _
;
277 pub const STATUS_PENDING
: NTSTATUS
= 0x103 as _
;
278 pub const STATUS_END_OF_FILE
: NTSTATUS
= 0xC0000011_u32 as _
;
280 // Equivalent to the `NT_SUCCESS` C preprocessor macro.
281 // See: https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values
282 pub fn nt_success(status
: NTSTATUS
) -> bool
{
286 pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG
: DWORD
= 0x00000002;
289 pub struct UNICODE_STRING
{
291 pub MaximumLength
: u16,
292 pub Buffer
: *mut u16,
294 impl UNICODE_STRING
{
295 pub fn from_ref(slice
: &[u16]) -> Self {
296 let len
= slice
.len() * mem
::size_of
::<u16>();
297 Self { Length: len as _, MaximumLength: len as _, Buffer: slice.as_ptr() as _ }
301 pub struct OBJECT_ATTRIBUTES
{
303 pub RootDirectory
: HANDLE
,
304 pub ObjectName
: *const UNICODE_STRING
,
305 pub Attributes
: ULONG
,
306 pub SecurityDescriptor
: *mut c_void
,
307 pub SecurityQualityOfService
: *mut c_void
,
309 impl Default
for OBJECT_ATTRIBUTES
{
310 fn default() -> Self {
312 Length
: mem
::size_of
::<Self>() as _
,
313 RootDirectory
: ptr
::null_mut(),
314 ObjectName
: ptr
::null_mut(),
316 SecurityDescriptor
: ptr
::null_mut(),
317 SecurityQualityOfService
: ptr
::null_mut(),
322 union IO_STATUS_BLOCK_union
{
324 Pointer
: *mut c_void
,
326 impl Default
for IO_STATUS_BLOCK_union
{
327 fn default() -> Self {
328 let mut this
= Self { Pointer: ptr::null_mut() }
;
329 this
.Status
= STATUS_PENDING
;
335 pub struct IO_STATUS_BLOCK
{
336 u
: IO_STATUS_BLOCK_union
,
337 pub Information
: usize,
339 impl IO_STATUS_BLOCK
{
340 pub fn status(&self) -> NTSTATUS
{
341 // SAFETY: If `self.u.Status` was set then this is obviously safe.
342 // If `self.u.Pointer` was set then this is the equivalent to converting
343 // the pointer to an integer, which is also safe.
344 // Currently the only safe way to construct `IO_STATUS_BLOCK` outside of
345 // this module is to call the `default` method, which sets the `Status`.
346 unsafe { self.u.Status }
350 pub type LPOVERLAPPED_COMPLETION_ROUTINE
= unsafe extern "system" fn(
352 dwNumberOfBytesTransfered
: DWORD
,
353 lpOverlapped
: *mut OVERLAPPED
,
356 type IO_APC_ROUTINE
= unsafe extern "system" fn(
357 ApcContext
: *mut c_void
,
358 IoStatusBlock
: *mut IO_STATUS_BLOCK
,
363 #[cfg(not(target_pointer_width = "64"))]
366 pub wHighVersion
: WORD
,
367 pub szDescription
: [u8; WSADESCRIPTION_LEN
+ 1],
368 pub szSystemStatus
: [u8; WSASYS_STATUS_LEN
+ 1],
369 pub iMaxSockets
: u16,
371 pub lpVendorInfo
: *mut u8,
374 #[cfg(target_pointer_width = "64")]
377 pub wHighVersion
: WORD
,
378 pub iMaxSockets
: u16,
380 pub lpVendorInfo
: *mut u8,
381 pub szDescription
: [u8; WSADESCRIPTION_LEN
+ 1],
382 pub szSystemStatus
: [u8; WSASYS_STATUS_LEN
+ 1],
385 #[derive(Copy, Clone)]
393 pub struct WSAPROTOCOL_INFO
{
394 pub dwServiceFlags1
: DWORD
,
395 pub dwServiceFlags2
: DWORD
,
396 pub dwServiceFlags3
: DWORD
,
397 pub dwServiceFlags4
: DWORD
,
398 pub dwProviderFlags
: DWORD
,
399 pub ProviderId
: GUID
,
400 pub dwCatalogEntryId
: DWORD
,
401 pub ProtocolChain
: WSAPROTOCOLCHAIN
,
403 pub iAddressFamily
: c_int
,
404 pub iMaxSockAddr
: c_int
,
405 pub iMinSockAddr
: c_int
,
406 pub iSocketType
: c_int
,
407 pub iProtocol
: c_int
,
408 pub iProtocolMaxOffset
: c_int
,
409 pub iNetworkByteOrder
: c_int
,
410 pub iSecurityScheme
: c_int
,
411 pub dwMessageSize
: DWORD
,
412 pub dwProviderReserved
: DWORD
,
413 pub szProtocol
: [u16; (WSAPROTOCOL_LEN
as usize) + 1],
417 #[derive(Copy, Clone)]
418 pub struct WIN32_FILE_ATTRIBUTE_DATA
{
419 pub dwFileAttributes
: DWORD
,
420 pub ftCreationTime
: FILETIME
,
421 pub ftLastAccessTime
: FILETIME
,
422 pub ftLastWriteTime
: FILETIME
,
423 pub nFileSizeHigh
: DWORD
,
424 pub nFileSizeLow
: DWORD
,
428 #[allow(dead_code)] // we only use some variants
429 pub enum FILE_INFO_BY_HANDLE_CLASS
{
431 FileStandardInfo
= 1,
434 FileDispositionInfo
= 4,
435 FileAllocationInfo
= 5,
436 FileEndOfFileInfo
= 6,
438 FileCompressionInfo
= 8,
439 FileAttributeTagInfo
= 9,
440 FileIdBothDirectoryInfo
= 10, // 0xA
441 FileIdBothDirectoryRestartInfo
= 11, // 0xB
442 FileIoPriorityHintInfo
= 12, // 0xC
443 FileRemoteProtocolInfo
= 13, // 0xD
444 FileFullDirectoryInfo
= 14, // 0xE
445 FileFullDirectoryRestartInfo
= 15, // 0xF
446 FileStorageInfo
= 16, // 0x10
447 FileAlignmentInfo
= 17, // 0x11
448 FileIdInfo
= 18, // 0x12
449 FileIdExtdDirectoryInfo
= 19, // 0x13
450 FileIdExtdDirectoryRestartInfo
= 20, // 0x14
451 FileDispositionInfoEx
= 21, // 0x15, Windows 10 version 1607
452 MaximumFileInfoByHandlesClass
,
456 pub struct FILE_DISPOSITION_INFO
{
457 pub DeleteFile
: BOOLEAN
,
460 pub const FILE_DISPOSITION_DELETE
: DWORD
= 0x1;
461 pub const FILE_DISPOSITION_POSIX_SEMANTICS
: DWORD
= 0x2;
462 pub const FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE
: DWORD
= 0x10;
465 pub struct FILE_DISPOSITION_INFO_EX
{
471 pub struct FILE_ID_BOTH_DIR_INFO
{
472 pub NextEntryOffset
: DWORD
,
473 pub FileIndex
: DWORD
,
474 pub CreationTime
: LARGE_INTEGER
,
475 pub LastAccessTime
: LARGE_INTEGER
,
476 pub LastWriteTime
: LARGE_INTEGER
,
477 pub ChangeTime
: LARGE_INTEGER
,
478 pub EndOfFile
: LARGE_INTEGER
,
479 pub AllocationSize
: LARGE_INTEGER
,
480 pub FileAttributes
: DWORD
,
481 pub FileNameLength
: DWORD
,
483 pub ShortNameLength
: CCHAR
,
484 pub ShortName
: [WCHAR
; 12],
485 pub FileId
: LARGE_INTEGER
,
486 pub FileName
: [WCHAR
; 1],
489 pub struct FILE_BASIC_INFO
{
490 pub CreationTime
: LARGE_INTEGER
,
491 pub LastAccessTime
: LARGE_INTEGER
,
492 pub LastWriteTime
: LARGE_INTEGER
,
493 pub ChangeTime
: LARGE_INTEGER
,
494 pub FileAttributes
: DWORD
,
498 pub struct FILE_END_OF_FILE_INFO
{
499 pub EndOfFile
: LARGE_INTEGER
,
503 pub struct REPARSE_DATA_BUFFER
{
504 pub ReparseTag
: c_uint
,
505 pub ReparseDataLength
: c_ushort
,
506 pub Reserved
: c_ushort
,
511 pub struct SYMBOLIC_LINK_REPARSE_BUFFER
{
512 pub SubstituteNameOffset
: c_ushort
,
513 pub SubstituteNameLength
: c_ushort
,
514 pub PrintNameOffset
: c_ushort
,
515 pub PrintNameLength
: c_ushort
,
517 pub PathBuffer
: WCHAR
,
521 pub struct MOUNT_POINT_REPARSE_BUFFER
{
522 pub SubstituteNameOffset
: c_ushort
,
523 pub SubstituteNameLength
: c_ushort
,
524 pub PrintNameOffset
: c_ushort
,
525 pub PrintNameLength
: c_ushort
,
526 pub PathBuffer
: WCHAR
,
529 pub type LPPROGRESS_ROUTINE
= crate::option
::Option
<
530 unsafe extern "system" fn(
531 TotalFileSize
: LARGE_INTEGER
,
532 TotalBytesTransferred
: LARGE_INTEGER
,
533 StreamSize
: LARGE_INTEGER
,
534 StreamBytesTransferred
: LARGE_INTEGER
,
535 dwStreamNumber
: DWORD
,
536 dwCallbackReason
: DWORD
,
538 hDestinationFile
: HANDLE
,
544 pub struct CONDITION_VARIABLE
{
553 pub struct REPARSE_MOUNTPOINT_DATA_BUFFER
{
554 pub ReparseTag
: DWORD
,
555 pub ReparseDataLength
: DWORD
,
557 pub ReparseTargetLength
: WORD
,
558 pub ReparseTargetMaximumLength
: WORD
,
560 pub ReparseTarget
: WCHAR
,
568 pub Data4
: [BYTE
; 8],
572 pub struct WSAPROTOCOLCHAIN
{
574 pub ChainEntries
: [DWORD
; MAX_PROTOCOL_CHAIN
as usize],
578 pub struct SECURITY_ATTRIBUTES
{
580 pub lpSecurityDescriptor
: LPVOID
,
581 pub bInheritHandle
: BOOL
,
585 pub struct PROCESS_INFORMATION
{
586 pub hProcess
: HANDLE
,
588 pub dwProcessId
: DWORD
,
589 pub dwThreadId
: DWORD
,
593 pub struct STARTUPINFO
{
595 pub lpReserved
: LPWSTR
,
596 pub lpDesktop
: LPWSTR
,
602 pub dwXCountChars
: DWORD
,
603 pub dwYCountCharts
: DWORD
,
604 pub dwFillAttribute
: DWORD
,
606 pub wShowWindow
: WORD
,
607 pub cbReserved2
: WORD
,
608 pub lpReserved2
: LPBYTE
,
609 pub hStdInput
: HANDLE
,
610 pub hStdOutput
: HANDLE
,
611 pub hStdError
: HANDLE
,
615 pub struct SOCKADDR
{
616 pub sa_family
: ADDRESS_FAMILY
,
617 pub sa_data
: [CHAR
; 14],
621 #[derive(Copy, Clone)]
622 pub struct FILETIME
{
623 pub dwLowDateTime
: DWORD
,
624 pub dwHighDateTime
: DWORD
,
628 pub struct SYSTEM_INFO
{
629 pub wProcessorArchitecture
: WORD
,
631 pub dwPageSize
: DWORD
,
632 pub lpMinimumApplicationAddress
: LPVOID
,
633 pub lpMaximumApplicationAddress
: LPVOID
,
634 pub dwActiveProcessorMask
: DWORD_PTR
,
635 pub dwNumberOfProcessors
: DWORD
,
636 pub dwProcessorType
: DWORD
,
637 pub dwAllocationGranularity
: DWORD
,
638 pub wProcessorLevel
: WORD
,
639 pub wProcessorRevision
: WORD
,
643 pub struct OVERLAPPED
{
644 pub Internal
: *mut c_ulong
,
645 pub InternalHigh
: *mut c_ulong
,
647 pub OffsetHigh
: DWORD
,
652 #[allow(dead_code)] // we only use some variants
653 pub enum ADDRESS_MODE
{
661 pub struct SOCKADDR_STORAGE_LH
{
662 pub ss_family
: ADDRESS_FAMILY
,
663 pub __ss_pad1
: [CHAR
; 6],
665 pub __ss_pad2
: [CHAR
; 112],
669 pub struct ADDRINFOA
{
671 pub ai_family
: c_int
,
672 pub ai_socktype
: c_int
,
673 pub ai_protocol
: c_int
,
674 pub ai_addrlen
: size_t
,
675 pub ai_canonname
: *mut c_char
,
676 pub ai_addr
: *mut SOCKADDR
,
677 pub ai_next
: *mut ADDRINFOA
,
681 #[derive(Copy, Clone)]
682 pub struct sockaddr_in
{
683 pub sin_family
: ADDRESS_FAMILY
,
684 pub sin_port
: USHORT
,
685 pub sin_addr
: in_addr
,
686 pub sin_zero
: [CHAR
; 8],
690 #[derive(Copy, Clone)]
691 pub struct sockaddr_in6
{
692 pub sin6_family
: ADDRESS_FAMILY
,
693 pub sin6_port
: USHORT
,
694 pub sin6_flowinfo
: c_ulong
,
695 pub sin6_addr
: in6_addr
,
696 pub sin6_scope_id
: c_ulong
,
700 #[derive(Copy, Clone)]
706 #[derive(Copy, Clone)]
707 pub struct in6_addr
{
708 pub s6_addr
: [u8; 16],
712 #[derive(Copy, Clone)]
713 #[allow(dead_code)] // we only use some variants
714 pub enum EXCEPTION_DISPOSITION
{
715 ExceptionContinueExecution
,
716 ExceptionContinueSearch
,
717 ExceptionNestedException
,
718 ExceptionCollidedUnwind
,
724 pub fd_count
: c_uint
,
725 pub fd_array
: [SOCKET
; FD_SETSIZE
],
728 impl Clone
for fd_set
{
729 fn clone(&self) -> fd_set
{
735 #[derive(Copy, Clone)]
741 // Desktop specific functions & types
743 if #[cfg(not(target_vendor = "uwp"))] {
744 pub const EXCEPTION_CONTINUE_SEARCH
: LONG
= 0;
745 pub const EXCEPTION_STACK_OVERFLOW
: DWORD
= 0xc00000fd;
746 pub const EXCEPTION_MAXIMUM_PARAMETERS
: usize = 15;
749 pub struct EXCEPTION_RECORD
{
750 pub ExceptionCode
: DWORD
,
751 pub ExceptionFlags
: DWORD
,
752 pub ExceptionRecord
: *mut EXCEPTION_RECORD
,
753 pub ExceptionAddress
: LPVOID
,
754 pub NumberParameters
: DWORD
,
755 pub ExceptionInformation
: [LPVOID
; EXCEPTION_MAXIMUM_PARAMETERS
],
761 pub struct EXCEPTION_POINTERS
{
762 pub ExceptionRecord
: *mut EXCEPTION_RECORD
,
763 pub ContextRecord
: *mut CONTEXT
,
766 pub type PVECTORED_EXCEPTION_HANDLER
=
767 extern "system" fn(ExceptionInfo
: *mut EXCEPTION_POINTERS
) -> LONG
;
770 #[derive(Copy, Clone)]
771 pub struct CONSOLE_READCONSOLE_CONTROL
{
773 pub nInitialChars
: ULONG
,
774 pub dwCtrlWakeupMask
: ULONG
,
775 pub dwControlKeyState
: ULONG
,
778 pub type PCONSOLE_READCONSOLE_CONTROL
= *mut CONSOLE_READCONSOLE_CONTROL
;
781 pub struct BY_HANDLE_FILE_INFORMATION
{
782 pub dwFileAttributes
: DWORD
,
783 pub ftCreationTime
: FILETIME
,
784 pub ftLastAccessTime
: FILETIME
,
785 pub ftLastWriteTime
: FILETIME
,
786 pub dwVolumeSerialNumber
: DWORD
,
787 pub nFileSizeHigh
: DWORD
,
788 pub nFileSizeLow
: DWORD
,
789 pub nNumberOfLinks
: DWORD
,
790 pub nFileIndexHigh
: DWORD
,
791 pub nFileIndexLow
: DWORD
,
794 pub type LPBY_HANDLE_FILE_INFORMATION
= *mut BY_HANDLE_FILE_INFORMATION
;
795 pub type LPCVOID
= *const c_void
;
797 pub const HANDLE_FLAG_INHERIT
: DWORD
= 0x00000001;
799 pub const TOKEN_READ
: DWORD
= 0x20008;
801 #[link(name = "advapi32")]
803 // Allowed but unused by UWP
804 pub fn OpenProcessToken(
805 ProcessHandle
: HANDLE
,
806 DesiredAccess
: DWORD
,
807 TokenHandle
: *mut HANDLE
,
811 #[link(name = "userenv")]
813 // Allowed but unused by UWP
814 pub fn GetUserProfileDirectoryW(
816 lpProfileDir
: LPWSTR
,
817 lpcchSize
: *mut DWORD
,
821 #[link(name = "kernel32")]
823 // Functions forbidden when targeting UWP
825 hConsoleInput
: HANDLE
,
827 nNumberOfCharsToRead
: DWORD
,
828 lpNumberOfCharsRead
: LPDWORD
,
829 pInputControl
: PCONSOLE_READCONSOLE_CONTROL
,
832 pub fn WriteConsoleW(
833 hConsoleOutput
: HANDLE
,
835 nNumberOfCharsToWrite
: DWORD
,
836 lpNumberOfCharsWritten
: LPDWORD
,
840 pub fn GetConsoleMode(hConsoleHandle
: HANDLE
, lpMode
: LPDWORD
) -> BOOL
;
841 // Allowed but unused by UWP
842 pub fn GetFileInformationByHandle(
844 lpFileInformation
: LPBY_HANDLE_FILE_INFORMATION
,
846 pub fn SetHandleInformation(hObject
: HANDLE
, dwMask
: DWORD
, dwFlags
: DWORD
) -> BOOL
;
847 pub fn AddVectoredExceptionHandler(
849 VectoredHandler
: PVECTORED_EXCEPTION_HANDLER
,
851 pub fn CreateHardLinkW(
852 lpSymlinkFileName
: LPCWSTR
,
853 lpTargetFileName
: LPCWSTR
,
854 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
856 pub fn SetThreadStackGuarantee(_size
: *mut c_ulong
) -> BOOL
;
857 pub fn GetWindowsDirectoryW(lpBuffer
: LPWSTR
, uSize
: UINT
) -> UINT
;
862 // UWP specific functions & types
864 if #[cfg(target_vendor = "uwp")] {
866 pub struct FILE_STANDARD_INFO
{
867 pub AllocationSize
: LARGE_INTEGER
,
868 pub EndOfFile
: LARGE_INTEGER
,
869 pub NumberOfLinks
: DWORD
,
870 pub DeletePending
: BOOLEAN
,
871 pub Directory
: BOOLEAN
,
876 // Shared between Desktop & UWP
878 #[link(name = "kernel32")]
880 pub fn GetCurrentProcessId() -> DWORD
;
882 pub fn GetSystemDirectoryW(lpBuffer
: LPWSTR
, uSize
: UINT
) -> UINT
;
883 pub fn RemoveDirectoryW(lpPathName
: LPCWSTR
) -> BOOL
;
884 pub fn SetFileAttributesW(lpFileName
: LPCWSTR
, dwFileAttributes
: DWORD
) -> BOOL
;
885 pub fn SetLastError(dwErrCode
: DWORD
);
886 pub fn GetCommandLineW() -> LPWSTR
;
887 pub fn GetTempPathW(nBufferLength
: DWORD
, lpBuffer
: LPCWSTR
) -> DWORD
;
888 pub fn GetCurrentProcess() -> HANDLE
;
889 pub fn GetCurrentThread() -> HANDLE
;
890 pub fn GetStdHandle(which
: DWORD
) -> HANDLE
;
891 pub fn ExitProcess(uExitCode
: c_uint
) -> !;
892 pub fn DeviceIoControl(
894 dwIoControlCode
: DWORD
,
896 nInBufferSize
: DWORD
,
898 nOutBufferSize
: DWORD
,
899 lpBytesReturned
: LPDWORD
,
900 lpOverlapped
: LPOVERLAPPED
,
903 lpThreadAttributes
: LPSECURITY_ATTRIBUTES
,
905 lpStartAddress
: extern "system" fn(*mut c_void
) -> DWORD
,
907 dwCreationFlags
: DWORD
,
910 pub fn WaitForSingleObject(hHandle
: HANDLE
, dwMilliseconds
: DWORD
) -> DWORD
;
911 pub fn SwitchToThread() -> BOOL
;
912 pub fn Sleep(dwMilliseconds
: DWORD
);
913 pub fn SleepEx(dwMilliseconds
: DWORD
, bAlertable
: BOOL
) -> DWORD
;
914 pub fn GetProcessId(handle
: HANDLE
) -> DWORD
;
916 lpExistingFileName
: LPCWSTR
,
917 lpNewFileName
: LPCWSTR
,
918 lpProgressRoutine
: LPPROGRESS_ROUTINE
,
923 pub fn FormatMessageW(
932 pub fn TlsAlloc() -> DWORD
;
933 pub fn TlsGetValue(dwTlsIndex
: DWORD
) -> LPVOID
;
934 pub fn TlsSetValue(dwTlsIndex
: DWORD
, lpTlsvalue
: LPVOID
) -> BOOL
;
935 pub fn GetLastError() -> DWORD
;
936 pub fn QueryPerformanceFrequency(lpFrequency
: *mut LARGE_INTEGER
) -> BOOL
;
937 pub fn QueryPerformanceCounter(lpPerformanceCount
: *mut LARGE_INTEGER
) -> BOOL
;
938 pub fn GetExitCodeProcess(hProcess
: HANDLE
, lpExitCode
: LPDWORD
) -> BOOL
;
939 pub fn TerminateProcess(hProcess
: HANDLE
, uExitCode
: UINT
) -> BOOL
;
940 pub fn CreateProcessW(
941 lpApplicationName
: LPCWSTR
,
942 lpCommandLine
: LPWSTR
,
943 lpProcessAttributes
: LPSECURITY_ATTRIBUTES
,
944 lpThreadAttributes
: LPSECURITY_ATTRIBUTES
,
945 bInheritHandles
: BOOL
,
946 dwCreationFlags
: DWORD
,
947 lpEnvironment
: LPVOID
,
948 lpCurrentDirectory
: LPCWSTR
,
949 lpStartupInfo
: LPSTARTUPINFO
,
950 lpProcessInformation
: LPPROCESS_INFORMATION
,
952 pub fn GetEnvironmentVariableW(n
: LPCWSTR
, v
: LPWSTR
, nsize
: DWORD
) -> DWORD
;
953 pub fn SetEnvironmentVariableW(n
: LPCWSTR
, v
: LPCWSTR
) -> BOOL
;
954 pub fn GetEnvironmentStringsW() -> LPWCH
;
955 pub fn FreeEnvironmentStringsW(env_ptr
: LPWCH
) -> BOOL
;
956 pub fn GetModuleFileNameW(hModule
: HMODULE
, lpFilename
: LPWSTR
, nSize
: DWORD
) -> DWORD
;
957 pub fn CreateDirectoryW(
959 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
961 pub fn DeleteFileW(lpPathName
: LPCWSTR
) -> BOOL
;
962 pub fn GetCurrentDirectoryW(nBufferLength
: DWORD
, lpBuffer
: LPWSTR
) -> DWORD
;
963 pub fn SetCurrentDirectoryW(lpPathName
: LPCWSTR
) -> BOOL
;
964 pub fn DuplicateHandle(
965 hSourceProcessHandle
: HANDLE
,
966 hSourceHandle
: HANDLE
,
967 hTargetProcessHandle
: HANDLE
,
968 lpTargetHandle
: LPHANDLE
,
969 dwDesiredAccess
: DWORD
,
970 bInheritHandle
: BOOL
,
974 hFile
: BorrowedHandle
<'_
>,
976 nNumberOfBytesToRead
: DWORD
,
977 lpNumberOfBytesRead
: LPDWORD
,
978 lpOverlapped
: LPOVERLAPPED
,
981 hFile
: BorrowedHandle
<'_
>,
983 nNumberOfBytesToRead
: DWORD
,
984 lpOverlapped
: LPOVERLAPPED
,
985 lpCompletionRoutine
: LPOVERLAPPED_COMPLETION_ROUTINE
,
988 hFile
: BorrowedHandle
<'_
>,
990 nNumberOfBytesToWrite
: DWORD
,
991 lpOverlapped
: LPOVERLAPPED
,
992 lpCompletionRoutine
: LPOVERLAPPED_COMPLETION_ROUTINE
,
994 pub fn CloseHandle(hObject
: HANDLE
) -> BOOL
;
995 pub fn MoveFileExW(lpExistingFileName
: LPCWSTR
, lpNewFileName
: LPCWSTR
, dwFlags
: DWORD
)
997 pub fn SetFilePointerEx(
999 liDistanceToMove
: LARGE_INTEGER
,
1000 lpNewFilePointer
: PLARGE_INTEGER
,
1001 dwMoveMethod
: DWORD
,
1003 pub fn FlushFileBuffers(hFile
: HANDLE
) -> BOOL
;
1005 lpFileName
: LPCWSTR
,
1006 dwDesiredAccess
: DWORD
,
1008 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
1009 dwCreationDisposition
: DWORD
,
1010 dwFlagsAndAttributes
: DWORD
,
1011 hTemplateFile
: HANDLE
,
1012 ) -> HandleOrInvalid
;
1014 pub fn FindFirstFileW(fileName
: LPCWSTR
, findFileData
: LPWIN32_FIND_DATAW
) -> HANDLE
;
1015 pub fn FindNextFileW(findFile
: HANDLE
, findFileData
: LPWIN32_FIND_DATAW
) -> BOOL
;
1016 pub fn FindClose(findFile
: HANDLE
) -> BOOL
;
1018 pub fn GetProcAddress(handle
: HMODULE
, name
: LPCSTR
) -> *mut c_void
;
1019 pub fn GetModuleHandleA(lpModuleName
: LPCSTR
) -> HMODULE
;
1020 pub fn GetModuleHandleW(lpModuleName
: LPCWSTR
) -> HMODULE
;
1022 pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime
: LPFILETIME
);
1023 pub fn GetSystemInfo(lpSystemInfo
: LPSYSTEM_INFO
);
1025 pub fn CreateEventW(
1026 lpEventAttributes
: LPSECURITY_ATTRIBUTES
,
1028 bInitialState
: BOOL
,
1031 pub fn WaitForMultipleObjects(
1033 lpHandles
: *const HANDLE
,
1035 dwMilliseconds
: DWORD
,
1037 pub fn CreateNamedPipeW(
1041 nMaxInstances
: DWORD
,
1042 nOutBufferSize
: DWORD
,
1043 nInBufferSize
: DWORD
,
1044 nDefaultTimeOut
: DWORD
,
1045 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
1047 pub fn CancelIo(handle
: HANDLE
) -> BOOL
;
1048 pub fn GetOverlappedResult(
1050 lpOverlapped
: LPOVERLAPPED
,
1051 lpNumberOfBytesTransferred
: LPDWORD
,
1054 pub fn CreateSymbolicLinkW(
1055 lpSymlinkFileName
: LPCWSTR
,
1056 lpTargetFileName
: LPCWSTR
,
1059 pub fn GetFinalPathNameByHandleW(
1061 lpszFilePath
: LPCWSTR
,
1065 pub fn GetFileInformationByHandleEx(
1067 fileInfoClass
: FILE_INFO_BY_HANDLE_CLASS
,
1068 lpFileInformation
: LPVOID
,
1069 dwBufferSize
: DWORD
,
1071 pub fn SetFileInformationByHandle(
1073 FileInformationClass
: FILE_INFO_BY_HANDLE_CLASS
,
1074 lpFileInformation
: LPVOID
,
1075 dwBufferSize
: DWORD
,
1077 pub fn SleepConditionVariableSRW(
1078 ConditionVariable
: PCONDITION_VARIABLE
,
1080 dwMilliseconds
: DWORD
,
1084 pub fn WakeConditionVariable(ConditionVariable
: PCONDITION_VARIABLE
);
1085 pub fn WakeAllConditionVariable(ConditionVariable
: PCONDITION_VARIABLE
);
1087 pub fn AcquireSRWLockExclusive(SRWLock
: PSRWLOCK
);
1088 pub fn AcquireSRWLockShared(SRWLock
: PSRWLOCK
);
1089 pub fn ReleaseSRWLockExclusive(SRWLock
: PSRWLOCK
);
1090 pub fn ReleaseSRWLockShared(SRWLock
: PSRWLOCK
);
1091 pub fn TryAcquireSRWLockExclusive(SRWLock
: PSRWLOCK
) -> BOOLEAN
;
1092 pub fn TryAcquireSRWLockShared(SRWLock
: PSRWLOCK
) -> BOOLEAN
;
1094 pub fn CompareStringOrdinal(
1101 pub fn GetFullPathNameW(
1102 lpFileName
: LPCWSTR
,
1103 nBufferLength
: DWORD
,
1105 lpFilePart
: *mut LPWSTR
,
1107 pub fn GetFileAttributesW(lpFileName
: LPCWSTR
) -> DWORD
;
1110 #[link(name = "ws2_32")]
1112 pub fn WSAStartup(wVersionRequested
: WORD
, lpWSAData
: LPWSADATA
) -> c_int
;
1113 pub fn WSACleanup() -> c_int
;
1114 pub fn WSAGetLastError() -> c_int
;
1115 pub fn WSADuplicateSocketW(
1118 lpProtocolInfo
: LPWSAPROTOCOL_INFO
,
1122 lpBuffers
: LPWSABUF
,
1123 dwBufferCount
: DWORD
,
1124 lpNumberOfBytesSent
: LPDWORD
,
1126 lpOverlapped
: LPWSAOVERLAPPED
,
1127 lpCompletionRoutine
: LPWSAOVERLAPPED_COMPLETION_ROUTINE
,
1131 lpBuffers
: LPWSABUF
,
1132 dwBufferCount
: DWORD
,
1133 lpNumberOfBytesRecvd
: LPDWORD
,
1135 lpOverlapped
: LPWSAOVERLAPPED
,
1136 lpCompletionRoutine
: LPWSAOVERLAPPED_COMPLETION_ROUTINE
,
1142 lpProtocolInfo
: LPWSAPROTOCOL_INFO
,
1146 pub fn ioctlsocket(s
: SOCKET
, cmd
: c_long
, argp
: *mut c_ulong
) -> c_int
;
1147 pub fn closesocket(socket
: SOCKET
) -> c_int
;
1148 pub fn recv(socket
: SOCKET
, buf
: *mut c_void
, len
: c_int
, flags
: c_int
) -> c_int
;
1149 pub fn send(socket
: SOCKET
, buf
: *const c_void
, len
: c_int
, flags
: c_int
) -> c_int
;
1155 addr
: *mut SOCKADDR
,
1156 addrlen
: *mut c_int
,
1163 addr
: *const SOCKADDR
,
1166 pub fn shutdown(socket
: SOCKET
, how
: c_int
) -> c_int
;
1167 pub fn accept(socket
: SOCKET
, address
: *mut SOCKADDR
, address_len
: *mut c_int
) -> SOCKET
;
1172 optval
: *mut c_char
,
1179 optval
: *const c_void
,
1182 pub fn getsockname(socket
: SOCKET
, address
: *mut SOCKADDR
, address_len
: *mut c_int
) -> c_int
;
1183 pub fn getpeername(socket
: SOCKET
, address
: *mut SOCKADDR
, address_len
: *mut c_int
) -> c_int
;
1184 pub fn bind(socket
: SOCKET
, address
: *const SOCKADDR
, address_len
: socklen_t
) -> c_int
;
1185 pub fn listen(socket
: SOCKET
, backlog
: c_int
) -> c_int
;
1186 pub fn connect(socket
: SOCKET
, address
: *const SOCKADDR
, len
: c_int
) -> c_int
;
1188 node
: *const c_char
,
1189 service
: *const c_char
,
1190 hints
: *const ADDRINFOA
,
1191 res
: *mut *mut ADDRINFOA
,
1193 pub fn freeaddrinfo(res
: *mut ADDRINFOA
);
1196 readfds
: *mut fd_set
,
1197 writefds
: *mut fd_set
,
1198 exceptfds
: *mut fd_set
,
1199 timeout
: *const timeval
,
1203 #[link(name = "bcrypt")]
1205 // >= Vista / Server 2008
1206 // https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
1207 pub fn BCryptGenRandom(
1215 // Functions that aren't available on every version of Windows that we support,
1216 // but we still use them and just provide some form of a fallback implementation.
1221 // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
1222 pub fn SetThreadDescription(hThread
: HANDLE
,
1223 lpThreadDescription
: LPCWSTR
) -> HRESULT
{
1224 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
as DWORD
); E_NOTIMPL
1227 // >= Win8 / Server 2012
1228 // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
1229 pub fn GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime
: LPFILETIME
)
1231 GetSystemTimeAsFileTime(lpSystemTimeAsFileTime
)
1234 // >= Win11 / Server 2022
1235 // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a
1236 pub fn GetTempPath2W(nBufferLength
: DWORD
, lpBuffer
: LPCWSTR
) -> DWORD
{
1237 GetTempPathW(nBufferLength
, lpBuffer
)
1242 "api-ms-win-core-synch-l1-2-0":
1244 // >= Windows 8 / Server 2012
1245 // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress
1246 pub fn WaitOnAddress(
1248 CompareAddress
: LPVOID
,
1249 AddressSize
: SIZE_T
,
1250 dwMilliseconds
: DWORD
1252 panic
!("WaitOnAddress not available")
1254 pub fn WakeByAddressSingle(Address
: LPVOID
) -> () {
1255 // If this api is unavailable, there cannot be anything waiting, because
1256 // WaitOnAddress would've panicked. So it's fine to do nothing here.
1262 pub fn NtCreateFile(
1263 FileHandle
: *mut HANDLE
,
1264 DesiredAccess
: ACCESS_MASK
,
1265 ObjectAttributes
: *const OBJECT_ATTRIBUTES
,
1266 IoStatusBlock
: *mut IO_STATUS_BLOCK
,
1267 AllocationSize
: *mut i64,
1268 FileAttributes
: ULONG
,
1270 CreateDisposition
: ULONG
,
1271 CreateOptions
: ULONG
,
1272 EaBuffer
: *mut c_void
,
1275 panic
!("`NtCreateFile` not available");
1278 FileHandle
: BorrowedHandle
<'_
>,
1280 ApcRoutine
: Option
<IO_APC_ROUTINE
>,
1281 ApcContext
: *mut c_void
,
1282 IoStatusBlock
: &mut IO_STATUS_BLOCK
,
1283 Buffer
: *mut crate::mem
::MaybeUninit
<u8>,
1285 ByteOffset
: Option
<&LARGE_INTEGER
>,
1288 panic
!("`NtReadFile` not available");
1291 FileHandle
: BorrowedHandle
<'_
>,
1293 ApcRoutine
: Option
<IO_APC_ROUTINE
>,
1294 ApcContext
: *mut c_void
,
1295 IoStatusBlock
: &mut IO_STATUS_BLOCK
,
1298 ByteOffset
: Option
<&LARGE_INTEGER
>,
1301 panic
!("`NtWriteFile` not available");
1303 pub fn RtlNtStatusToDosError(
1306 panic
!("`RtlNtStatusToDosError` not available");
1308 pub fn NtCreateKeyedEvent(
1309 KeyedEventHandle
: LPHANDLE
,
1310 DesiredAccess
: ACCESS_MASK
,
1311 ObjectAttributes
: LPVOID
,
1314 panic
!("keyed events not available")
1316 pub fn NtReleaseKeyedEvent(
1317 EventHandle
: HANDLE
,
1320 Timeout
: PLARGE_INTEGER
1322 panic
!("keyed events not available")
1324 pub fn NtWaitForKeyedEvent(
1325 EventHandle
: HANDLE
,
1328 Timeout
: PLARGE_INTEGER
1330 panic
!("keyed events not available")