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 _
;
279 pub const STATUS_NOT_IMPLEMENTED
: NTSTATUS
= 0xC0000002_u32 as _
;
281 // Equivalent to the `NT_SUCCESS` C preprocessor macro.
282 // See: https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values
283 pub fn nt_success(status
: NTSTATUS
) -> bool
{
287 pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG
: DWORD
= 0x00000002;
290 pub struct UNICODE_STRING
{
292 pub MaximumLength
: u16,
293 pub Buffer
: *mut u16,
295 impl UNICODE_STRING
{
296 pub fn from_ref(slice
: &[u16]) -> Self {
297 let len
= slice
.len() * mem
::size_of
::<u16>();
298 Self { Length: len as _, MaximumLength: len as _, Buffer: slice.as_ptr() as _ }
302 pub struct OBJECT_ATTRIBUTES
{
304 pub RootDirectory
: HANDLE
,
305 pub ObjectName
: *const UNICODE_STRING
,
306 pub Attributes
: ULONG
,
307 pub SecurityDescriptor
: *mut c_void
,
308 pub SecurityQualityOfService
: *mut c_void
,
310 impl Default
for OBJECT_ATTRIBUTES
{
311 fn default() -> Self {
313 Length
: mem
::size_of
::<Self>() as _
,
314 RootDirectory
: ptr
::null_mut(),
315 ObjectName
: ptr
::null_mut(),
317 SecurityDescriptor
: ptr
::null_mut(),
318 SecurityQualityOfService
: ptr
::null_mut(),
323 union IO_STATUS_BLOCK_union
{
325 Pointer
: *mut c_void
,
327 impl Default
for IO_STATUS_BLOCK_union
{
328 fn default() -> Self {
329 let mut this
= Self { Pointer: ptr::null_mut() }
;
330 this
.Status
= STATUS_PENDING
;
336 pub struct IO_STATUS_BLOCK
{
337 u
: IO_STATUS_BLOCK_union
,
338 pub Information
: usize,
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 }
351 pub type LPOVERLAPPED_COMPLETION_ROUTINE
= unsafe extern "system" fn(
353 dwNumberOfBytesTransfered
: DWORD
,
354 lpOverlapped
: *mut OVERLAPPED
,
357 type IO_APC_ROUTINE
= unsafe extern "system" fn(
358 ApcContext
: *mut c_void
,
359 IoStatusBlock
: *mut IO_STATUS_BLOCK
,
364 #[cfg(not(target_pointer_width = "64"))]
367 pub wHighVersion
: WORD
,
368 pub szDescription
: [u8; WSADESCRIPTION_LEN
+ 1],
369 pub szSystemStatus
: [u8; WSASYS_STATUS_LEN
+ 1],
370 pub iMaxSockets
: u16,
372 pub lpVendorInfo
: *mut u8,
375 #[cfg(target_pointer_width = "64")]
378 pub wHighVersion
: WORD
,
379 pub iMaxSockets
: u16,
381 pub lpVendorInfo
: *mut u8,
382 pub szDescription
: [u8; WSADESCRIPTION_LEN
+ 1],
383 pub szSystemStatus
: [u8; WSASYS_STATUS_LEN
+ 1],
386 #[derive(Copy, Clone)]
394 pub struct WSAPROTOCOL_INFO
{
395 pub dwServiceFlags1
: DWORD
,
396 pub dwServiceFlags2
: DWORD
,
397 pub dwServiceFlags3
: DWORD
,
398 pub dwServiceFlags4
: DWORD
,
399 pub dwProviderFlags
: DWORD
,
400 pub ProviderId
: GUID
,
401 pub dwCatalogEntryId
: DWORD
,
402 pub ProtocolChain
: WSAPROTOCOLCHAIN
,
404 pub iAddressFamily
: c_int
,
405 pub iMaxSockAddr
: c_int
,
406 pub iMinSockAddr
: c_int
,
407 pub iSocketType
: c_int
,
408 pub iProtocol
: c_int
,
409 pub iProtocolMaxOffset
: c_int
,
410 pub iNetworkByteOrder
: c_int
,
411 pub iSecurityScheme
: c_int
,
412 pub dwMessageSize
: DWORD
,
413 pub dwProviderReserved
: DWORD
,
414 pub szProtocol
: [u16; (WSAPROTOCOL_LEN
as usize) + 1],
418 #[derive(Copy, Clone)]
419 pub struct WIN32_FILE_ATTRIBUTE_DATA
{
420 pub dwFileAttributes
: DWORD
,
421 pub ftCreationTime
: FILETIME
,
422 pub ftLastAccessTime
: FILETIME
,
423 pub ftLastWriteTime
: FILETIME
,
424 pub nFileSizeHigh
: DWORD
,
425 pub nFileSizeLow
: DWORD
,
429 #[allow(dead_code)] // we only use some variants
430 pub enum FILE_INFO_BY_HANDLE_CLASS
{
432 FileStandardInfo
= 1,
435 FileDispositionInfo
= 4,
436 FileAllocationInfo
= 5,
437 FileEndOfFileInfo
= 6,
439 FileCompressionInfo
= 8,
440 FileAttributeTagInfo
= 9,
441 FileIdBothDirectoryInfo
= 10, // 0xA
442 FileIdBothDirectoryRestartInfo
= 11, // 0xB
443 FileIoPriorityHintInfo
= 12, // 0xC
444 FileRemoteProtocolInfo
= 13, // 0xD
445 FileFullDirectoryInfo
= 14, // 0xE
446 FileFullDirectoryRestartInfo
= 15, // 0xF
447 FileStorageInfo
= 16, // 0x10
448 FileAlignmentInfo
= 17, // 0x11
449 FileIdInfo
= 18, // 0x12
450 FileIdExtdDirectoryInfo
= 19, // 0x13
451 FileIdExtdDirectoryRestartInfo
= 20, // 0x14
452 FileDispositionInfoEx
= 21, // 0x15, Windows 10 version 1607
453 MaximumFileInfoByHandlesClass
,
457 pub struct FILE_DISPOSITION_INFO
{
458 pub DeleteFile
: BOOLEAN
,
461 pub const FILE_DISPOSITION_DELETE
: DWORD
= 0x1;
462 pub const FILE_DISPOSITION_POSIX_SEMANTICS
: DWORD
= 0x2;
463 pub const FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE
: DWORD
= 0x10;
466 pub struct FILE_DISPOSITION_INFO_EX
{
472 pub struct FILE_ID_BOTH_DIR_INFO
{
473 pub NextEntryOffset
: DWORD
,
474 pub FileIndex
: DWORD
,
475 pub CreationTime
: LARGE_INTEGER
,
476 pub LastAccessTime
: LARGE_INTEGER
,
477 pub LastWriteTime
: LARGE_INTEGER
,
478 pub ChangeTime
: LARGE_INTEGER
,
479 pub EndOfFile
: LARGE_INTEGER
,
480 pub AllocationSize
: LARGE_INTEGER
,
481 pub FileAttributes
: DWORD
,
482 pub FileNameLength
: DWORD
,
484 pub ShortNameLength
: CCHAR
,
485 pub ShortName
: [WCHAR
; 12],
486 pub FileId
: LARGE_INTEGER
,
487 pub FileName
: [WCHAR
; 1],
490 pub struct FILE_BASIC_INFO
{
491 pub CreationTime
: LARGE_INTEGER
,
492 pub LastAccessTime
: LARGE_INTEGER
,
493 pub LastWriteTime
: LARGE_INTEGER
,
494 pub ChangeTime
: LARGE_INTEGER
,
495 pub FileAttributes
: DWORD
,
499 pub struct FILE_END_OF_FILE_INFO
{
500 pub EndOfFile
: LARGE_INTEGER
,
504 pub struct REPARSE_DATA_BUFFER
{
505 pub ReparseTag
: c_uint
,
506 pub ReparseDataLength
: c_ushort
,
507 pub Reserved
: c_ushort
,
512 pub struct SYMBOLIC_LINK_REPARSE_BUFFER
{
513 pub SubstituteNameOffset
: c_ushort
,
514 pub SubstituteNameLength
: c_ushort
,
515 pub PrintNameOffset
: c_ushort
,
516 pub PrintNameLength
: c_ushort
,
518 pub PathBuffer
: WCHAR
,
522 pub struct MOUNT_POINT_REPARSE_BUFFER
{
523 pub SubstituteNameOffset
: c_ushort
,
524 pub SubstituteNameLength
: c_ushort
,
525 pub PrintNameOffset
: c_ushort
,
526 pub PrintNameLength
: c_ushort
,
527 pub PathBuffer
: WCHAR
,
530 pub type LPPROGRESS_ROUTINE
= crate::option
::Option
<
531 unsafe extern "system" fn(
532 TotalFileSize
: LARGE_INTEGER
,
533 TotalBytesTransferred
: LARGE_INTEGER
,
534 StreamSize
: LARGE_INTEGER
,
535 StreamBytesTransferred
: LARGE_INTEGER
,
536 dwStreamNumber
: DWORD
,
537 dwCallbackReason
: DWORD
,
539 hDestinationFile
: HANDLE
,
545 pub struct CONDITION_VARIABLE
{
554 pub struct REPARSE_MOUNTPOINT_DATA_BUFFER
{
555 pub ReparseTag
: DWORD
,
556 pub ReparseDataLength
: DWORD
,
558 pub ReparseTargetLength
: WORD
,
559 pub ReparseTargetMaximumLength
: WORD
,
561 pub ReparseTarget
: WCHAR
,
569 pub Data4
: [BYTE
; 8],
573 pub struct WSAPROTOCOLCHAIN
{
575 pub ChainEntries
: [DWORD
; MAX_PROTOCOL_CHAIN
as usize],
579 pub struct SECURITY_ATTRIBUTES
{
581 pub lpSecurityDescriptor
: LPVOID
,
582 pub bInheritHandle
: BOOL
,
586 pub struct PROCESS_INFORMATION
{
587 pub hProcess
: HANDLE
,
589 pub dwProcessId
: DWORD
,
590 pub dwThreadId
: DWORD
,
594 pub struct STARTUPINFO
{
596 pub lpReserved
: LPWSTR
,
597 pub lpDesktop
: LPWSTR
,
603 pub dwXCountChars
: DWORD
,
604 pub dwYCountCharts
: DWORD
,
605 pub dwFillAttribute
: DWORD
,
607 pub wShowWindow
: WORD
,
608 pub cbReserved2
: WORD
,
609 pub lpReserved2
: LPBYTE
,
610 pub hStdInput
: HANDLE
,
611 pub hStdOutput
: HANDLE
,
612 pub hStdError
: HANDLE
,
616 pub struct SOCKADDR
{
617 pub sa_family
: ADDRESS_FAMILY
,
618 pub sa_data
: [CHAR
; 14],
622 #[derive(Copy, Clone)]
623 pub struct FILETIME
{
624 pub dwLowDateTime
: DWORD
,
625 pub dwHighDateTime
: DWORD
,
629 pub struct SYSTEM_INFO
{
630 pub wProcessorArchitecture
: WORD
,
632 pub dwPageSize
: DWORD
,
633 pub lpMinimumApplicationAddress
: LPVOID
,
634 pub lpMaximumApplicationAddress
: LPVOID
,
635 pub dwActiveProcessorMask
: DWORD_PTR
,
636 pub dwNumberOfProcessors
: DWORD
,
637 pub dwProcessorType
: DWORD
,
638 pub dwAllocationGranularity
: DWORD
,
639 pub wProcessorLevel
: WORD
,
640 pub wProcessorRevision
: WORD
,
644 pub struct OVERLAPPED
{
645 pub Internal
: *mut c_ulong
,
646 pub InternalHigh
: *mut c_ulong
,
648 pub OffsetHigh
: DWORD
,
653 #[allow(dead_code)] // we only use some variants
654 pub enum ADDRESS_MODE
{
662 pub struct SOCKADDR_STORAGE_LH
{
663 pub ss_family
: ADDRESS_FAMILY
,
664 pub __ss_pad1
: [CHAR
; 6],
666 pub __ss_pad2
: [CHAR
; 112],
670 pub struct ADDRINFOA
{
672 pub ai_family
: c_int
,
673 pub ai_socktype
: c_int
,
674 pub ai_protocol
: c_int
,
675 pub ai_addrlen
: size_t
,
676 pub ai_canonname
: *mut c_char
,
677 pub ai_addr
: *mut SOCKADDR
,
678 pub ai_next
: *mut ADDRINFOA
,
682 #[derive(Copy, Clone)]
683 pub struct sockaddr_in
{
684 pub sin_family
: ADDRESS_FAMILY
,
685 pub sin_port
: USHORT
,
686 pub sin_addr
: in_addr
,
687 pub sin_zero
: [CHAR
; 8],
691 #[derive(Copy, Clone)]
692 pub struct sockaddr_in6
{
693 pub sin6_family
: ADDRESS_FAMILY
,
694 pub sin6_port
: USHORT
,
695 pub sin6_flowinfo
: c_ulong
,
696 pub sin6_addr
: in6_addr
,
697 pub sin6_scope_id
: c_ulong
,
701 #[derive(Copy, Clone)]
707 #[derive(Copy, Clone)]
708 pub struct in6_addr
{
709 pub s6_addr
: [u8; 16],
713 #[derive(Copy, Clone)]
714 #[allow(dead_code)] // we only use some variants
715 pub enum EXCEPTION_DISPOSITION
{
716 ExceptionContinueExecution
,
717 ExceptionContinueSearch
,
718 ExceptionNestedException
,
719 ExceptionCollidedUnwind
,
725 pub fd_count
: c_uint
,
726 pub fd_array
: [SOCKET
; FD_SETSIZE
],
729 impl Clone
for fd_set
{
730 fn clone(&self) -> fd_set
{
736 #[derive(Copy, Clone)]
742 // Desktop specific functions & types
744 if #[cfg(not(target_vendor = "uwp"))] {
745 pub const EXCEPTION_CONTINUE_SEARCH
: LONG
= 0;
746 pub const EXCEPTION_STACK_OVERFLOW
: DWORD
= 0xc00000fd;
747 pub const EXCEPTION_MAXIMUM_PARAMETERS
: usize = 15;
750 pub struct EXCEPTION_RECORD
{
751 pub ExceptionCode
: DWORD
,
752 pub ExceptionFlags
: DWORD
,
753 pub ExceptionRecord
: *mut EXCEPTION_RECORD
,
754 pub ExceptionAddress
: LPVOID
,
755 pub NumberParameters
: DWORD
,
756 pub ExceptionInformation
: [LPVOID
; EXCEPTION_MAXIMUM_PARAMETERS
],
762 pub struct EXCEPTION_POINTERS
{
763 pub ExceptionRecord
: *mut EXCEPTION_RECORD
,
764 pub ContextRecord
: *mut CONTEXT
,
767 pub type PVECTORED_EXCEPTION_HANDLER
=
768 extern "system" fn(ExceptionInfo
: *mut EXCEPTION_POINTERS
) -> LONG
;
771 #[derive(Copy, Clone)]
772 pub struct CONSOLE_READCONSOLE_CONTROL
{
774 pub nInitialChars
: ULONG
,
775 pub dwCtrlWakeupMask
: ULONG
,
776 pub dwControlKeyState
: ULONG
,
779 pub type PCONSOLE_READCONSOLE_CONTROL
= *mut CONSOLE_READCONSOLE_CONTROL
;
782 pub struct BY_HANDLE_FILE_INFORMATION
{
783 pub dwFileAttributes
: DWORD
,
784 pub ftCreationTime
: FILETIME
,
785 pub ftLastAccessTime
: FILETIME
,
786 pub ftLastWriteTime
: FILETIME
,
787 pub dwVolumeSerialNumber
: DWORD
,
788 pub nFileSizeHigh
: DWORD
,
789 pub nFileSizeLow
: DWORD
,
790 pub nNumberOfLinks
: DWORD
,
791 pub nFileIndexHigh
: DWORD
,
792 pub nFileIndexLow
: DWORD
,
795 pub type LPBY_HANDLE_FILE_INFORMATION
= *mut BY_HANDLE_FILE_INFORMATION
;
796 pub type LPCVOID
= *const c_void
;
798 pub const HANDLE_FLAG_INHERIT
: DWORD
= 0x00000001;
800 pub const TOKEN_READ
: DWORD
= 0x20008;
802 #[link(name = "advapi32")]
804 // Forbidden when targeting UWP
805 #[link_name = "SystemFunction036"]
806 pub fn RtlGenRandom(RandomBuffer
: *mut u8, RandomBufferLength
: ULONG
) -> BOOLEAN
;
808 // Allowed but unused by UWP
809 pub fn OpenProcessToken(
810 ProcessHandle
: HANDLE
,
811 DesiredAccess
: DWORD
,
812 TokenHandle
: *mut HANDLE
,
816 #[link(name = "userenv")]
818 // Allowed but unused by UWP
819 pub fn GetUserProfileDirectoryW(
821 lpProfileDir
: LPWSTR
,
822 lpcchSize
: *mut DWORD
,
826 #[link(name = "kernel32")]
828 // Functions forbidden when targeting UWP
830 hConsoleInput
: HANDLE
,
832 nNumberOfCharsToRead
: DWORD
,
833 lpNumberOfCharsRead
: LPDWORD
,
834 pInputControl
: PCONSOLE_READCONSOLE_CONTROL
,
837 pub fn WriteConsoleW(
838 hConsoleOutput
: HANDLE
,
840 nNumberOfCharsToWrite
: DWORD
,
841 lpNumberOfCharsWritten
: LPDWORD
,
845 pub fn GetConsoleMode(hConsoleHandle
: HANDLE
, lpMode
: LPDWORD
) -> BOOL
;
846 // Allowed but unused by UWP
847 pub fn GetFileInformationByHandle(
849 lpFileInformation
: LPBY_HANDLE_FILE_INFORMATION
,
851 pub fn SetHandleInformation(hObject
: HANDLE
, dwMask
: DWORD
, dwFlags
: DWORD
) -> BOOL
;
852 pub fn AddVectoredExceptionHandler(
854 VectoredHandler
: PVECTORED_EXCEPTION_HANDLER
,
856 pub fn CreateHardLinkW(
857 lpSymlinkFileName
: LPCWSTR
,
858 lpTargetFileName
: LPCWSTR
,
859 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
861 pub fn SetThreadStackGuarantee(_size
: *mut c_ulong
) -> BOOL
;
862 pub fn GetWindowsDirectoryW(lpBuffer
: LPWSTR
, uSize
: UINT
) -> UINT
;
867 // UWP specific functions & types
869 if #[cfg(target_vendor = "uwp")] {
871 pub struct FILE_STANDARD_INFO
{
872 pub AllocationSize
: LARGE_INTEGER
,
873 pub EndOfFile
: LARGE_INTEGER
,
874 pub NumberOfLinks
: DWORD
,
875 pub DeletePending
: BOOLEAN
,
876 pub Directory
: BOOLEAN
,
881 // Shared between Desktop & UWP
883 #[link(name = "kernel32")]
885 pub fn GetCurrentProcessId() -> DWORD
;
887 pub fn GetSystemDirectoryW(lpBuffer
: LPWSTR
, uSize
: UINT
) -> UINT
;
888 pub fn RemoveDirectoryW(lpPathName
: LPCWSTR
) -> BOOL
;
889 pub fn SetFileAttributesW(lpFileName
: LPCWSTR
, dwFileAttributes
: DWORD
) -> BOOL
;
890 pub fn SetLastError(dwErrCode
: DWORD
);
891 pub fn GetCommandLineW() -> LPWSTR
;
892 pub fn GetTempPathW(nBufferLength
: DWORD
, lpBuffer
: LPCWSTR
) -> DWORD
;
893 pub fn GetCurrentProcess() -> HANDLE
;
894 pub fn GetCurrentThread() -> HANDLE
;
895 pub fn GetStdHandle(which
: DWORD
) -> HANDLE
;
896 pub fn ExitProcess(uExitCode
: c_uint
) -> !;
897 pub fn DeviceIoControl(
899 dwIoControlCode
: DWORD
,
901 nInBufferSize
: DWORD
,
903 nOutBufferSize
: DWORD
,
904 lpBytesReturned
: LPDWORD
,
905 lpOverlapped
: LPOVERLAPPED
,
908 lpThreadAttributes
: LPSECURITY_ATTRIBUTES
,
910 lpStartAddress
: extern "system" fn(*mut c_void
) -> DWORD
,
912 dwCreationFlags
: DWORD
,
915 pub fn WaitForSingleObject(hHandle
: HANDLE
, dwMilliseconds
: DWORD
) -> DWORD
;
916 pub fn SwitchToThread() -> BOOL
;
917 pub fn Sleep(dwMilliseconds
: DWORD
);
918 pub fn SleepEx(dwMilliseconds
: DWORD
, bAlertable
: BOOL
) -> DWORD
;
919 pub fn GetProcessId(handle
: HANDLE
) -> DWORD
;
921 lpExistingFileName
: LPCWSTR
,
922 lpNewFileName
: LPCWSTR
,
923 lpProgressRoutine
: LPPROGRESS_ROUTINE
,
928 pub fn FormatMessageW(
937 pub fn TlsAlloc() -> DWORD
;
938 pub fn TlsGetValue(dwTlsIndex
: DWORD
) -> LPVOID
;
939 pub fn TlsSetValue(dwTlsIndex
: DWORD
, lpTlsvalue
: LPVOID
) -> BOOL
;
940 pub fn GetLastError() -> DWORD
;
941 pub fn QueryPerformanceFrequency(lpFrequency
: *mut LARGE_INTEGER
) -> BOOL
;
942 pub fn QueryPerformanceCounter(lpPerformanceCount
: *mut LARGE_INTEGER
) -> BOOL
;
943 pub fn GetExitCodeProcess(hProcess
: HANDLE
, lpExitCode
: LPDWORD
) -> BOOL
;
944 pub fn TerminateProcess(hProcess
: HANDLE
, uExitCode
: UINT
) -> BOOL
;
945 pub fn CreateProcessW(
946 lpApplicationName
: LPCWSTR
,
947 lpCommandLine
: LPWSTR
,
948 lpProcessAttributes
: LPSECURITY_ATTRIBUTES
,
949 lpThreadAttributes
: LPSECURITY_ATTRIBUTES
,
950 bInheritHandles
: BOOL
,
951 dwCreationFlags
: DWORD
,
952 lpEnvironment
: LPVOID
,
953 lpCurrentDirectory
: LPCWSTR
,
954 lpStartupInfo
: LPSTARTUPINFO
,
955 lpProcessInformation
: LPPROCESS_INFORMATION
,
957 pub fn GetEnvironmentVariableW(n
: LPCWSTR
, v
: LPWSTR
, nsize
: DWORD
) -> DWORD
;
958 pub fn SetEnvironmentVariableW(n
: LPCWSTR
, v
: LPCWSTR
) -> BOOL
;
959 pub fn GetEnvironmentStringsW() -> LPWCH
;
960 pub fn FreeEnvironmentStringsW(env_ptr
: LPWCH
) -> BOOL
;
961 pub fn GetModuleFileNameW(hModule
: HMODULE
, lpFilename
: LPWSTR
, nSize
: DWORD
) -> DWORD
;
962 pub fn CreateDirectoryW(
964 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
966 pub fn DeleteFileW(lpPathName
: LPCWSTR
) -> BOOL
;
967 pub fn GetCurrentDirectoryW(nBufferLength
: DWORD
, lpBuffer
: LPWSTR
) -> DWORD
;
968 pub fn SetCurrentDirectoryW(lpPathName
: LPCWSTR
) -> BOOL
;
969 pub fn DuplicateHandle(
970 hSourceProcessHandle
: HANDLE
,
971 hSourceHandle
: HANDLE
,
972 hTargetProcessHandle
: HANDLE
,
973 lpTargetHandle
: LPHANDLE
,
974 dwDesiredAccess
: DWORD
,
975 bInheritHandle
: BOOL
,
979 hFile
: BorrowedHandle
<'_
>,
981 nNumberOfBytesToRead
: DWORD
,
982 lpNumberOfBytesRead
: LPDWORD
,
983 lpOverlapped
: LPOVERLAPPED
,
986 hFile
: BorrowedHandle
<'_
>,
988 nNumberOfBytesToRead
: DWORD
,
989 lpOverlapped
: LPOVERLAPPED
,
990 lpCompletionRoutine
: LPOVERLAPPED_COMPLETION_ROUTINE
,
993 hFile
: BorrowedHandle
<'_
>,
995 nNumberOfBytesToWrite
: DWORD
,
996 lpOverlapped
: LPOVERLAPPED
,
997 lpCompletionRoutine
: LPOVERLAPPED_COMPLETION_ROUTINE
,
999 pub fn CloseHandle(hObject
: HANDLE
) -> BOOL
;
1000 pub fn MoveFileExW(lpExistingFileName
: LPCWSTR
, lpNewFileName
: LPCWSTR
, dwFlags
: DWORD
)
1002 pub fn SetFilePointerEx(
1004 liDistanceToMove
: LARGE_INTEGER
,
1005 lpNewFilePointer
: PLARGE_INTEGER
,
1006 dwMoveMethod
: DWORD
,
1008 pub fn FlushFileBuffers(hFile
: HANDLE
) -> BOOL
;
1010 lpFileName
: LPCWSTR
,
1011 dwDesiredAccess
: DWORD
,
1013 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
1014 dwCreationDisposition
: DWORD
,
1015 dwFlagsAndAttributes
: DWORD
,
1016 hTemplateFile
: HANDLE
,
1017 ) -> HandleOrInvalid
;
1019 pub fn FindFirstFileW(fileName
: LPCWSTR
, findFileData
: LPWIN32_FIND_DATAW
) -> HANDLE
;
1020 pub fn FindNextFileW(findFile
: HANDLE
, findFileData
: LPWIN32_FIND_DATAW
) -> BOOL
;
1021 pub fn FindClose(findFile
: HANDLE
) -> BOOL
;
1023 pub fn GetProcAddress(handle
: HMODULE
, name
: LPCSTR
) -> *mut c_void
;
1024 pub fn GetModuleHandleA(lpModuleName
: LPCSTR
) -> HMODULE
;
1025 pub fn GetModuleHandleW(lpModuleName
: LPCWSTR
) -> HMODULE
;
1027 pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime
: LPFILETIME
);
1028 pub fn GetSystemInfo(lpSystemInfo
: LPSYSTEM_INFO
);
1030 pub fn CreateEventW(
1031 lpEventAttributes
: LPSECURITY_ATTRIBUTES
,
1033 bInitialState
: BOOL
,
1036 pub fn WaitForMultipleObjects(
1038 lpHandles
: *const HANDLE
,
1040 dwMilliseconds
: DWORD
,
1042 pub fn CreateNamedPipeW(
1046 nMaxInstances
: DWORD
,
1047 nOutBufferSize
: DWORD
,
1048 nInBufferSize
: DWORD
,
1049 nDefaultTimeOut
: DWORD
,
1050 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
1052 pub fn CancelIo(handle
: HANDLE
) -> BOOL
;
1053 pub fn GetOverlappedResult(
1055 lpOverlapped
: LPOVERLAPPED
,
1056 lpNumberOfBytesTransferred
: LPDWORD
,
1059 pub fn CreateSymbolicLinkW(
1060 lpSymlinkFileName
: LPCWSTR
,
1061 lpTargetFileName
: LPCWSTR
,
1064 pub fn GetFinalPathNameByHandleW(
1066 lpszFilePath
: LPCWSTR
,
1070 pub fn GetFileInformationByHandleEx(
1072 fileInfoClass
: FILE_INFO_BY_HANDLE_CLASS
,
1073 lpFileInformation
: LPVOID
,
1074 dwBufferSize
: DWORD
,
1076 pub fn SetFileInformationByHandle(
1078 FileInformationClass
: FILE_INFO_BY_HANDLE_CLASS
,
1079 lpFileInformation
: LPVOID
,
1080 dwBufferSize
: DWORD
,
1082 pub fn SleepConditionVariableSRW(
1083 ConditionVariable
: PCONDITION_VARIABLE
,
1085 dwMilliseconds
: DWORD
,
1089 pub fn WakeConditionVariable(ConditionVariable
: PCONDITION_VARIABLE
);
1090 pub fn WakeAllConditionVariable(ConditionVariable
: PCONDITION_VARIABLE
);
1092 pub fn AcquireSRWLockExclusive(SRWLock
: PSRWLOCK
);
1093 pub fn AcquireSRWLockShared(SRWLock
: PSRWLOCK
);
1094 pub fn ReleaseSRWLockExclusive(SRWLock
: PSRWLOCK
);
1095 pub fn ReleaseSRWLockShared(SRWLock
: PSRWLOCK
);
1096 pub fn TryAcquireSRWLockExclusive(SRWLock
: PSRWLOCK
) -> BOOLEAN
;
1097 pub fn TryAcquireSRWLockShared(SRWLock
: PSRWLOCK
) -> BOOLEAN
;
1099 pub fn CompareStringOrdinal(
1106 pub fn GetFullPathNameW(
1107 lpFileName
: LPCWSTR
,
1108 nBufferLength
: DWORD
,
1110 lpFilePart
: *mut LPWSTR
,
1112 pub fn GetFileAttributesW(lpFileName
: LPCWSTR
) -> DWORD
;
1115 #[link(name = "ws2_32")]
1117 pub fn WSAStartup(wVersionRequested
: WORD
, lpWSAData
: LPWSADATA
) -> c_int
;
1118 pub fn WSACleanup() -> c_int
;
1119 pub fn WSAGetLastError() -> c_int
;
1120 pub fn WSADuplicateSocketW(
1123 lpProtocolInfo
: LPWSAPROTOCOL_INFO
,
1127 lpBuffers
: LPWSABUF
,
1128 dwBufferCount
: DWORD
,
1129 lpNumberOfBytesSent
: LPDWORD
,
1131 lpOverlapped
: LPWSAOVERLAPPED
,
1132 lpCompletionRoutine
: LPWSAOVERLAPPED_COMPLETION_ROUTINE
,
1136 lpBuffers
: LPWSABUF
,
1137 dwBufferCount
: DWORD
,
1138 lpNumberOfBytesRecvd
: LPDWORD
,
1140 lpOverlapped
: LPWSAOVERLAPPED
,
1141 lpCompletionRoutine
: LPWSAOVERLAPPED_COMPLETION_ROUTINE
,
1147 lpProtocolInfo
: LPWSAPROTOCOL_INFO
,
1151 pub fn ioctlsocket(s
: SOCKET
, cmd
: c_long
, argp
: *mut c_ulong
) -> c_int
;
1152 pub fn closesocket(socket
: SOCKET
) -> c_int
;
1153 pub fn recv(socket
: SOCKET
, buf
: *mut c_void
, len
: c_int
, flags
: c_int
) -> c_int
;
1154 pub fn send(socket
: SOCKET
, buf
: *const c_void
, len
: c_int
, flags
: c_int
) -> c_int
;
1160 addr
: *mut SOCKADDR
,
1161 addrlen
: *mut c_int
,
1168 addr
: *const SOCKADDR
,
1171 pub fn shutdown(socket
: SOCKET
, how
: c_int
) -> c_int
;
1172 pub fn accept(socket
: SOCKET
, address
: *mut SOCKADDR
, address_len
: *mut c_int
) -> SOCKET
;
1177 optval
: *mut c_char
,
1184 optval
: *const c_void
,
1187 pub fn getsockname(socket
: SOCKET
, address
: *mut SOCKADDR
, address_len
: *mut c_int
) -> c_int
;
1188 pub fn getpeername(socket
: SOCKET
, address
: *mut SOCKADDR
, address_len
: *mut c_int
) -> c_int
;
1189 pub fn bind(socket
: SOCKET
, address
: *const SOCKADDR
, address_len
: socklen_t
) -> c_int
;
1190 pub fn listen(socket
: SOCKET
, backlog
: c_int
) -> c_int
;
1191 pub fn connect(socket
: SOCKET
, address
: *const SOCKADDR
, len
: c_int
) -> c_int
;
1193 node
: *const c_char
,
1194 service
: *const c_char
,
1195 hints
: *const ADDRINFOA
,
1196 res
: *mut *mut ADDRINFOA
,
1198 pub fn freeaddrinfo(res
: *mut ADDRINFOA
);
1201 readfds
: *mut fd_set
,
1202 writefds
: *mut fd_set
,
1203 exceptfds
: *mut fd_set
,
1204 timeout
: *const timeval
,
1208 #[link(name = "bcrypt")]
1210 // >= Vista / Server 2008
1211 // https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
1212 pub fn BCryptGenRandom(
1220 // Functions that aren't available on every version of Windows that we support,
1221 // but we still use them and just provide some form of a fallback implementation.
1226 // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
1227 pub fn SetThreadDescription(hThread
: HANDLE
,
1228 lpThreadDescription
: LPCWSTR
) -> HRESULT
{
1229 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
as DWORD
); E_NOTIMPL
1232 // >= Win8 / Server 2012
1233 // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
1234 pub fn GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime
: LPFILETIME
)
1236 GetSystemTimeAsFileTime(lpSystemTimeAsFileTime
)
1239 // >= Win11 / Server 2022
1240 // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a
1241 pub fn GetTempPath2W(nBufferLength
: DWORD
, lpBuffer
: LPCWSTR
) -> DWORD
{
1242 GetTempPathW(nBufferLength
, lpBuffer
)
1247 "api-ms-win-core-synch-l1-2-0":
1249 // >= Windows 8 / Server 2012
1250 // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress
1251 pub fn WaitOnAddress(
1253 CompareAddress
: LPVOID
,
1254 AddressSize
: SIZE_T
,
1255 dwMilliseconds
: DWORD
1257 panic
!("WaitOnAddress not available")
1259 pub fn WakeByAddressSingle(Address
: LPVOID
) -> () {
1260 // If this api is unavailable, there cannot be anything waiting, because
1261 // WaitOnAddress would've panicked. So it's fine to do nothing here.
1267 pub fn NtCreateFile(
1268 FileHandle
: *mut HANDLE
,
1269 DesiredAccess
: ACCESS_MASK
,
1270 ObjectAttributes
: *const OBJECT_ATTRIBUTES
,
1271 IoStatusBlock
: *mut IO_STATUS_BLOCK
,
1272 AllocationSize
: *mut i64,
1273 FileAttributes
: ULONG
,
1275 CreateDisposition
: ULONG
,
1276 CreateOptions
: ULONG
,
1277 EaBuffer
: *mut c_void
,
1280 STATUS_NOT_IMPLEMENTED
1283 FileHandle
: BorrowedHandle
<'_
>,
1285 ApcRoutine
: Option
<IO_APC_ROUTINE
>,
1286 ApcContext
: *mut c_void
,
1287 IoStatusBlock
: &mut IO_STATUS_BLOCK
,
1288 Buffer
: *mut crate::mem
::MaybeUninit
<u8>,
1290 ByteOffset
: Option
<&LARGE_INTEGER
>,
1293 STATUS_NOT_IMPLEMENTED
1296 FileHandle
: BorrowedHandle
<'_
>,
1298 ApcRoutine
: Option
<IO_APC_ROUTINE
>,
1299 ApcContext
: *mut c_void
,
1300 IoStatusBlock
: &mut IO_STATUS_BLOCK
,
1303 ByteOffset
: Option
<&LARGE_INTEGER
>,
1306 STATUS_NOT_IMPLEMENTED
1308 pub fn RtlNtStatusToDosError(
1313 pub fn NtCreateKeyedEvent(
1314 KeyedEventHandle
: LPHANDLE
,
1315 DesiredAccess
: ACCESS_MASK
,
1316 ObjectAttributes
: LPVOID
,
1319 panic
!("keyed events not available")
1321 pub fn NtReleaseKeyedEvent(
1322 EventHandle
: HANDLE
,
1325 Timeout
: PLARGE_INTEGER
1327 panic
!("keyed events not available")
1329 pub fn NtWaitForKeyedEvent(
1330 EventHandle
: HANDLE
,
1333 Timeout
: PLARGE_INTEGER
1335 panic
!("keyed events not available")