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")]
9 use crate::os::raw::{c_char, c_int, c_long, c_longlong, c_uint, c_ulong, c_ushort};
10 use crate::os::windows::io::{BorrowedHandle, HandleOrInvalid, HandleOrNull};
12 use core::ffi::NonZero_c_ulong;
14 use libc::{c_void, size_t, wchar_t};
16 #[path = "c/errors.rs"] // c.rs is included from two places so we need to specify this
20 pub use self::EXCEPTION_DISPOSITION::*;
21 pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
23 pub type DWORD_PTR = ULONG_PTR;
24 pub type DWORD = c_ulong;
25 pub type NonZeroDWORD = NonZero_c_ulong;
26 pub type HANDLE = LPVOID;
27 pub type HINSTANCE = HANDLE;
28 pub type HMODULE = HINSTANCE;
29 pub type HRESULT = LONG;
30 pub type BOOL = c_int;
32 pub type BOOLEAN = BYTE;
33 pub type GROUP = c_uint;
34 pub type LARGE_INTEGER = c_longlong;
35 pub type LONG = c_long;
36 pub type UINT = c_uint;
38 pub type USHORT = c_ushort;
39 pub type SIZE_T = usize;
41 pub type CHAR = c_char;
42 pub type CCHAR = c_char;
43 pub type ULONG_PTR = usize;
44 pub type ULONG = c_ulong;
45 pub type NTSTATUS = LONG;
46 pub type ACCESS_MASK = DWORD;
48 pub type LPBOOL = *mut BOOL;
49 pub type LPBYTE = *mut BYTE;
50 pub type LPCSTR = *const CHAR;
51 pub type LPCWSTR = *const WCHAR;
52 pub type LPDWORD = *mut DWORD;
53 pub type LPHANDLE = *mut HANDLE;
54 pub type LPOVERLAPPED = *mut OVERLAPPED;
55 pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
56 pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
57 pub type LPSTARTUPINFO = *mut STARTUPINFO;
58 pub type LPVOID = *mut c_void;
59 pub type LPWCH = *mut WCHAR;
60 pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
61 pub type LPWSADATA = *mut WSADATA;
62 pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
63 pub type LPWSTR = *mut WCHAR;
64 pub type LPFILETIME = *mut FILETIME;
65 pub type LPSYSTEM_INFO = *mut SYSTEM_INFO;
66 pub type LPWSABUF = *mut WSABUF;
67 pub type LPWSAOVERLAPPED = *mut c_void;
68 pub type LPWSAOVERLAPPED_COMPLETION_ROUTINE = *mut c_void;
69 pub type BCRYPT_ALG_HANDLE = LPVOID;
71 pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE;
72 pub type PLARGE_INTEGER = *mut c_longlong;
73 pub type PSRWLOCK = *mut SRWLOCK;
74 pub type LPINIT_ONCE = *mut INIT_ONCE;
76 pub type SOCKET = crate::os::windows::raw::SOCKET;
77 pub type socklen_t = c_int;
78 pub type ADDRESS_FAMILY = USHORT;
80 pub const TRUE: BOOL = 1;
81 pub const FALSE: BOOL = 0;
83 pub const CSTR_LESS_THAN: c_int = 1;
84 pub const CSTR_EQUAL: c_int = 2;
85 pub const CSTR_GREATER_THAN: c_int = 3;
87 pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1;
88 pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10;
89 pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400;
90 pub const INVALID_FILE_ATTRIBUTES: DWORD = DWORD::MAX;
92 pub const FILE_SHARE_DELETE: DWORD = 0x4;
93 pub const FILE_SHARE_READ: DWORD = 0x1;
94 pub const FILE_SHARE_WRITE: DWORD = 0x2;
96 pub const FILE_OPEN: ULONG = 0x00000001;
97 pub const FILE_OPEN_REPARSE_POINT: ULONG = 0x200000;
98 pub const OBJ_DONT_REPARSE: ULONG = 0x1000;
100 pub const CREATE_ALWAYS: DWORD = 2;
101 pub const CREATE_NEW: DWORD = 1;
102 pub const OPEN_ALWAYS: DWORD = 4;
103 pub const OPEN_EXISTING: DWORD = 3;
104 pub const TRUNCATE_EXISTING: DWORD = 5;
106 pub const FILE_LIST_DIRECTORY: DWORD = 0x1;
107 pub const FILE_WRITE_DATA: DWORD = 0x00000002;
108 pub const FILE_APPEND_DATA: DWORD = 0x00000004;
109 pub const FILE_WRITE_EA: DWORD = 0x00000010;
110 pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100;
111 pub const DELETE: DWORD = 0x10000;
112 pub const READ_CONTROL: DWORD = 0x00020000;
113 pub const SYNCHRONIZE: DWORD = 0x00100000;
114 pub const GENERIC_READ: DWORD = 0x80000000;
115 pub const GENERIC_WRITE: DWORD = 0x40000000;
116 pub const STANDARD_RIGHTS_WRITE: DWORD = READ_CONTROL;
117 pub const FILE_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE
119 | FILE_WRITE_ATTRIBUTES
124 pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
125 pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
126 pub const SECURITY_SQOS_PRESENT: DWORD = 0x00100000;
128 pub const FIONBIO: c_ulong = 0x8004667e;
132 pub struct WIN32_FIND_DATAW {
133 pub dwFileAttributes: DWORD,
134 pub ftCreationTime: FILETIME,
135 pub ftLastAccessTime: FILETIME,
136 pub ftLastWriteTime: FILETIME,
137 pub nFileSizeHigh: DWORD,
138 pub nFileSizeLow: DWORD,
139 pub dwReserved0: DWORD,
140 pub dwReserved1: DWORD,
141 pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
142 pub cAlternateFileName: [wchar_t; 14],
144 impl Clone for WIN32_FIND_DATAW {
145 fn clone(&self) -> Self {
150 pub const WSA_FLAG_OVERLAPPED: DWORD = 0x01;
151 pub const WSA_FLAG_NO_HANDLE_INHERIT: DWORD = 0x80;
153 pub const WSADESCRIPTION_LEN: usize = 256;
154 pub const WSASYS_STATUS_LEN: usize = 128;
155 pub const WSAPROTOCOL_LEN: DWORD = 255;
156 pub const INVALID_SOCKET: SOCKET = !0;
158 pub const MAX_PROTOCOL_CHAIN: DWORD = 7;
160 pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: usize = 16 * 1024;
161 pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
162 pub const IO_REPARSE_TAG_SYMLINK: DWORD = 0xa000000c;
163 pub const IO_REPARSE_TAG_MOUNT_POINT: DWORD = 0xa0000003;
164 pub const SYMLINK_FLAG_RELATIVE: DWORD = 0x00000001;
165 pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
167 pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 0x1;
168 pub const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE: DWORD = 0x2;
170 // Note that these are not actually HANDLEs, just values to pass to GetStdHandle
171 pub const STD_INPUT_HANDLE: DWORD = -10i32 as DWORD;
172 pub const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
173 pub const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD;
175 pub const PROGRESS_CONTINUE: DWORD = 0;
177 pub const E_NOTIMPL: HRESULT = 0x80004001u32 as HRESULT;
179 pub const INVALID_HANDLE_VALUE: HANDLE = ptr::invalid_mut(!0);
181 pub const FACILITY_NT_BIT: DWORD = 0x1000_0000;
183 pub const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000;
184 pub const FORMAT_MESSAGE_FROM_HMODULE: DWORD = 0x00000800;
185 pub const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200;
187 pub const TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF;
189 pub const DLL_THREAD_DETACH: DWORD = 3;
190 pub const DLL_PROCESS_DETACH: DWORD = 0;
192 pub const INFINITE: DWORD = !0;
194 pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002;
196 pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE { ptr: ptr::null_mut() };
197 pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { ptr: ptr::null_mut() };
198 pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = INIT_ONCE { ptr: ptr::null_mut() };
200 pub const INIT_ONCE_INIT_FAILED: DWORD = 0x00000004;
202 pub const DETACHED_PROCESS: DWORD = 0x00000008;
203 pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200;
204 pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400;
205 pub const STARTF_USESTDHANDLES: DWORD = 0x00000100;
207 pub const AF_INET: c_int = 2;
208 pub const AF_INET6: c_int = 23;
209 pub const SD_BOTH: c_int = 2;
210 pub const SD_RECEIVE: c_int = 0;
211 pub const SD_SEND: c_int = 1;
212 pub const SOCK_DGRAM: c_int = 2;
213 pub const SOCK_STREAM: c_int = 1;
214 pub const SOCKET_ERROR: c_int = -1;
215 pub const SOL_SOCKET: c_int = 0xffff;
216 pub const SO_LINGER: c_int = 0x0080;
217 pub const SO_RCVTIMEO: c_int = 0x1006;
218 pub const SO_SNDTIMEO: c_int = 0x1005;
219 pub const IPPROTO_IP: c_int = 0;
220 pub const IPPROTO_TCP: c_int = 6;
221 pub const IPPROTO_IPV6: c_int = 41;
222 pub const TCP_NODELAY: c_int = 0x0001;
223 pub const IP_TTL: c_int = 4;
224 pub const IPV6_V6ONLY: c_int = 27;
225 pub const SO_ERROR: c_int = 0x1007;
226 pub const SO_BROADCAST: c_int = 0x0020;
227 pub const IP_MULTICAST_LOOP: c_int = 11;
228 pub const IPV6_MULTICAST_LOOP: c_int = 11;
229 pub const IP_MULTICAST_TTL: c_int = 10;
230 pub const IP_ADD_MEMBERSHIP: c_int = 12;
231 pub const IP_DROP_MEMBERSHIP: c_int = 13;
232 pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
233 pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
234 pub const MSG_PEEK: c_int = 0x2;
237 #[derive(Copy, Clone)]
239 pub l_onoff: c_ushort,
240 pub l_linger: c_ushort,
245 pub imr_multiaddr: in_addr,
246 pub imr_interface: in_addr,
250 pub struct ipv6_mreq {
251 pub ipv6mr_multiaddr: in6_addr,
252 pub ipv6mr_interface: c_uint,
255 pub const VOLUME_NAME_DOS: DWORD = 0x0;
256 pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1;
258 pub const FILE_BEGIN: DWORD = 0;
259 pub const FILE_CURRENT: DWORD = 1;
260 pub const FILE_END: DWORD = 2;
262 pub const WAIT_OBJECT_0: DWORD = 0x00000000;
263 pub const WAIT_TIMEOUT: DWORD = 258;
264 pub const WAIT_FAILED: DWORD = 0xFFFFFFFF;
266 pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
267 pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
268 pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
269 pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000;
270 pub const PIPE_WAIT: DWORD = 0x00000000;
271 pub const PIPE_TYPE_BYTE: DWORD = 0x00000000;
272 pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008;
273 pub const PIPE_READMODE_BYTE: DWORD = 0x00000000;
275 pub const FD_SETSIZE: usize = 64;
277 pub const STACK_SIZE_PARAM_IS_A_RESERVATION: DWORD = 0x00010000;
279 pub const STATUS_SUCCESS: NTSTATUS = 0x00000000;
280 pub const STATUS_DELETE_PENDING: NTSTATUS = 0xc0000056_u32 as _;
281 pub const STATUS_INVALID_PARAMETER: NTSTATUS = 0xc000000d_u32 as _;
283 pub const STATUS_PENDING: NTSTATUS = 0x103 as _;
284 pub const STATUS_END_OF_FILE: NTSTATUS = 0xC0000011_u32 as _;
285 pub const STATUS_NOT_IMPLEMENTED: NTSTATUS = 0xC0000002_u32 as _;
287 // Equivalent to the `NT_SUCCESS` C preprocessor macro.
288 // See: https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values
289 pub fn nt_success(status: NTSTATUS) -> bool {
294 pub const BCRYPT_RNG_ALGORITHM: &[u16] = &[b'R' as u16, b'N' as u16, b'G' as u16, 0];
295 pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD = 0x00000002;
298 pub struct UNICODE_STRING {
300 pub MaximumLength: u16,
301 pub Buffer: *mut u16,
303 impl UNICODE_STRING {
304 pub fn from_ref(slice: &[u16]) -> Self {
305 let len = slice.len() * mem::size_of::<u16>();
306 Self { Length: len as _, MaximumLength: len as _, Buffer: slice.as_ptr() as _ }
310 pub struct OBJECT_ATTRIBUTES {
312 pub RootDirectory: HANDLE,
313 pub ObjectName: *const UNICODE_STRING,
314 pub Attributes: ULONG,
315 pub SecurityDescriptor: *mut c_void,
316 pub SecurityQualityOfService: *mut c_void,
318 impl Default for OBJECT_ATTRIBUTES {
319 fn default() -> Self {
321 Length: mem::size_of::<Self>() as _,
322 RootDirectory: ptr::null_mut(),
323 ObjectName: ptr::null_mut(),
325 SecurityDescriptor: ptr::null_mut(),
326 SecurityQualityOfService: ptr::null_mut(),
331 union IO_STATUS_BLOCK_union {
333 Pointer: *mut c_void,
335 impl Default for IO_STATUS_BLOCK_union {
336 fn default() -> Self {
337 let mut this = Self { Pointer: ptr::null_mut() };
338 this.Status = STATUS_PENDING;
344 pub struct IO_STATUS_BLOCK {
345 u: IO_STATUS_BLOCK_union,
346 pub Information: usize,
348 impl IO_STATUS_BLOCK {
349 pub fn status(&self) -> NTSTATUS {
350 // SAFETY: If `self.u.Status` was set then this is obviously safe.
351 // If `self.u.Pointer` was set then this is the equivalent to converting
352 // the pointer to an integer, which is also safe.
353 // Currently the only safe way to construct `IO_STATUS_BLOCK` outside of
354 // this module is to call the `default` method, which sets the `Status`.
355 unsafe { self.u.Status }
359 pub type LPOVERLAPPED_COMPLETION_ROUTINE = unsafe extern "system" fn(
361 dwNumberOfBytesTransfered: DWORD,
362 lpOverlapped: *mut OVERLAPPED,
365 type IO_APC_ROUTINE = unsafe extern "system" fn(
366 ApcContext: *mut c_void,
367 IoStatusBlock: *mut IO_STATUS_BLOCK,
372 #[cfg(not(target_pointer_width = "64"))]
375 pub wHighVersion: WORD,
376 pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
377 pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
378 pub iMaxSockets: u16,
380 pub lpVendorInfo: *mut u8,
383 #[cfg(target_pointer_width = "64")]
386 pub wHighVersion: WORD,
387 pub iMaxSockets: u16,
389 pub lpVendorInfo: *mut u8,
390 pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
391 pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
394 #[derive(Copy, Clone)]
402 pub struct WSAPROTOCOL_INFO {
403 pub dwServiceFlags1: DWORD,
404 pub dwServiceFlags2: DWORD,
405 pub dwServiceFlags3: DWORD,
406 pub dwServiceFlags4: DWORD,
407 pub dwProviderFlags: DWORD,
408 pub ProviderId: GUID,
409 pub dwCatalogEntryId: DWORD,
410 pub ProtocolChain: WSAPROTOCOLCHAIN,
412 pub iAddressFamily: c_int,
413 pub iMaxSockAddr: c_int,
414 pub iMinSockAddr: c_int,
415 pub iSocketType: c_int,
416 pub iProtocol: c_int,
417 pub iProtocolMaxOffset: c_int,
418 pub iNetworkByteOrder: c_int,
419 pub iSecurityScheme: c_int,
420 pub dwMessageSize: DWORD,
421 pub dwProviderReserved: DWORD,
422 pub szProtocol: [u16; (WSAPROTOCOL_LEN as usize) + 1],
426 #[derive(Copy, Clone)]
427 pub struct WIN32_FILE_ATTRIBUTE_DATA {
428 pub dwFileAttributes: DWORD,
429 pub ftCreationTime: FILETIME,
430 pub ftLastAccessTime: FILETIME,
431 pub ftLastWriteTime: FILETIME,
432 pub nFileSizeHigh: DWORD,
433 pub nFileSizeLow: DWORD,
437 #[allow(dead_code)] // we only use some variants
438 pub enum FILE_INFO_BY_HANDLE_CLASS {
440 FileStandardInfo = 1,
443 FileDispositionInfo = 4,
444 FileAllocationInfo = 5,
445 FileEndOfFileInfo = 6,
447 FileCompressionInfo = 8,
448 FileAttributeTagInfo = 9,
449 FileIdBothDirectoryInfo = 10, // 0xA
450 FileIdBothDirectoryRestartInfo = 11, // 0xB
451 FileIoPriorityHintInfo = 12, // 0xC
452 FileRemoteProtocolInfo = 13, // 0xD
453 FileFullDirectoryInfo = 14, // 0xE
454 FileFullDirectoryRestartInfo = 15, // 0xF
455 FileStorageInfo = 16, // 0x10
456 FileAlignmentInfo = 17, // 0x11
457 FileIdInfo = 18, // 0x12
458 FileIdExtdDirectoryInfo = 19, // 0x13
459 FileIdExtdDirectoryRestartInfo = 20, // 0x14
460 FileDispositionInfoEx = 21, // 0x15, Windows 10 version 1607
461 MaximumFileInfoByHandlesClass,
465 pub struct FILE_ATTRIBUTE_TAG_INFO {
466 pub FileAttributes: DWORD,
467 pub ReparseTag: DWORD,
471 pub struct FILE_DISPOSITION_INFO {
472 pub DeleteFile: BOOLEAN,
475 pub const FILE_DISPOSITION_DELETE: DWORD = 0x1;
476 pub const FILE_DISPOSITION_POSIX_SEMANTICS: DWORD = 0x2;
477 pub const FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE: DWORD = 0x10;
480 pub struct FILE_DISPOSITION_INFO_EX {
486 pub struct FILE_ID_BOTH_DIR_INFO {
487 pub NextEntryOffset: DWORD,
488 pub FileIndex: DWORD,
489 pub CreationTime: LARGE_INTEGER,
490 pub LastAccessTime: LARGE_INTEGER,
491 pub LastWriteTime: LARGE_INTEGER,
492 pub ChangeTime: LARGE_INTEGER,
493 pub EndOfFile: LARGE_INTEGER,
494 pub AllocationSize: LARGE_INTEGER,
495 pub FileAttributes: DWORD,
496 pub FileNameLength: DWORD,
498 pub ShortNameLength: CCHAR,
499 pub ShortName: [WCHAR; 12],
500 pub FileId: LARGE_INTEGER,
501 pub FileName: [WCHAR; 1],
504 pub struct FILE_BASIC_INFO {
505 pub CreationTime: LARGE_INTEGER,
506 pub LastAccessTime: LARGE_INTEGER,
507 pub LastWriteTime: LARGE_INTEGER,
508 pub ChangeTime: LARGE_INTEGER,
509 pub FileAttributes: DWORD,
513 pub struct FILE_END_OF_FILE_INFO {
514 pub EndOfFile: LARGE_INTEGER,
517 /// NB: Use carefully! In general using this as a reference is likely to get the
518 /// provenance wrong for the `rest` field!
520 pub struct REPARSE_DATA_BUFFER {
521 pub ReparseTag: c_uint,
522 pub ReparseDataLength: c_ushort,
523 pub Reserved: c_ushort,
527 /// NB: Use carefully! In general using this as a reference is likely to get the
528 /// provenance wrong for the `PathBuffer` field!
530 pub struct SYMBOLIC_LINK_REPARSE_BUFFER {
531 pub SubstituteNameOffset: c_ushort,
532 pub SubstituteNameLength: c_ushort,
533 pub PrintNameOffset: c_ushort,
534 pub PrintNameLength: c_ushort,
536 pub PathBuffer: WCHAR,
539 /// NB: Use carefully! In general using this as a reference is likely to get the
540 /// provenance wrong for the `PathBuffer` field!
542 pub struct MOUNT_POINT_REPARSE_BUFFER {
543 pub SubstituteNameOffset: c_ushort,
544 pub SubstituteNameLength: c_ushort,
545 pub PrintNameOffset: c_ushort,
546 pub PrintNameLength: c_ushort,
547 pub PathBuffer: WCHAR,
550 pub type LPPROGRESS_ROUTINE = crate::option::Option<
551 unsafe extern "system" fn(
552 TotalFileSize: LARGE_INTEGER,
553 TotalBytesTransferred: LARGE_INTEGER,
554 StreamSize: LARGE_INTEGER,
555 StreamBytesTransferred: LARGE_INTEGER,
556 dwStreamNumber: DWORD,
557 dwCallbackReason: DWORD,
559 hDestinationFile: HANDLE,
565 pub struct CONDITION_VARIABLE {
573 pub struct INIT_ONCE {
578 pub struct REPARSE_MOUNTPOINT_DATA_BUFFER {
579 pub ReparseTag: DWORD,
580 pub ReparseDataLength: DWORD,
582 pub ReparseTargetLength: WORD,
583 pub ReparseTargetMaximumLength: WORD,
585 pub ReparseTarget: WCHAR,
593 pub Data4: [BYTE; 8],
597 pub struct WSAPROTOCOLCHAIN {
599 pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize],
603 pub struct SECURITY_ATTRIBUTES {
605 pub lpSecurityDescriptor: LPVOID,
606 pub bInheritHandle: BOOL,
610 pub struct PROCESS_INFORMATION {
611 pub hProcess: HANDLE,
613 pub dwProcessId: DWORD,
614 pub dwThreadId: DWORD,
618 pub struct STARTUPINFO {
620 pub lpReserved: LPWSTR,
621 pub lpDesktop: LPWSTR,
627 pub dwXCountChars: DWORD,
628 pub dwYCountCharts: DWORD,
629 pub dwFillAttribute: DWORD,
631 pub wShowWindow: WORD,
632 pub cbReserved2: WORD,
633 pub lpReserved2: LPBYTE,
634 pub hStdInput: HANDLE,
635 pub hStdOutput: HANDLE,
636 pub hStdError: HANDLE,
640 pub struct SOCKADDR {
641 pub sa_family: ADDRESS_FAMILY,
642 pub sa_data: [CHAR; 14],
646 #[derive(Copy, Clone, Debug, Default)]
647 pub struct FILETIME {
648 pub dwLowDateTime: DWORD,
649 pub dwHighDateTime: DWORD,
653 pub struct SYSTEM_INFO {
654 pub wProcessorArchitecture: WORD,
656 pub dwPageSize: DWORD,
657 pub lpMinimumApplicationAddress: LPVOID,
658 pub lpMaximumApplicationAddress: LPVOID,
659 pub dwActiveProcessorMask: DWORD_PTR,
660 pub dwNumberOfProcessors: DWORD,
661 pub dwProcessorType: DWORD,
662 pub dwAllocationGranularity: DWORD,
663 pub wProcessorLevel: WORD,
664 pub wProcessorRevision: WORD,
668 pub struct OVERLAPPED {
669 pub Internal: *mut c_ulong,
670 pub InternalHigh: *mut c_ulong,
672 pub OffsetHigh: DWORD,
677 #[allow(dead_code)] // we only use some variants
678 pub enum ADDRESS_MODE {
686 pub struct SOCKADDR_STORAGE_LH {
687 pub ss_family: ADDRESS_FAMILY,
688 pub __ss_pad1: [CHAR; 6],
690 pub __ss_pad2: [CHAR; 112],
694 pub struct ADDRINFOA {
696 pub ai_family: c_int,
697 pub ai_socktype: c_int,
698 pub ai_protocol: c_int,
699 pub ai_addrlen: size_t,
700 pub ai_canonname: *mut c_char,
701 pub ai_addr: *mut SOCKADDR,
702 pub ai_next: *mut ADDRINFOA,
706 #[derive(Copy, Clone)]
707 pub struct sockaddr_in {
708 pub sin_family: ADDRESS_FAMILY,
709 pub sin_port: USHORT,
710 pub sin_addr: in_addr,
711 pub sin_zero: [CHAR; 8],
715 #[derive(Copy, Clone)]
716 pub struct sockaddr_in6 {
717 pub sin6_family: ADDRESS_FAMILY,
718 pub sin6_port: USHORT,
719 pub sin6_flowinfo: c_ulong,
720 pub sin6_addr: in6_addr,
721 pub sin6_scope_id: c_ulong,
725 #[derive(Copy, Clone)]
731 #[derive(Copy, Clone)]
732 pub struct in6_addr {
733 pub s6_addr: [u8; 16],
737 #[derive(Copy, Clone)]
738 #[allow(dead_code)] // we only use some variants
739 pub enum EXCEPTION_DISPOSITION {
740 ExceptionContinueExecution,
741 ExceptionContinueSearch,
742 ExceptionNestedException,
743 ExceptionCollidedUnwind,
749 pub fd_count: c_uint,
750 pub fd_array: [SOCKET; FD_SETSIZE],
753 impl Clone for fd_set {
754 fn clone(&self) -> fd_set {
760 #[derive(Copy, Clone)]
766 // Desktop specific functions & types
768 if #[cfg(not(target_vendor = "uwp"))] {
769 pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
770 pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
771 pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
774 pub struct EXCEPTION_RECORD {
775 pub ExceptionCode: DWORD,
776 pub ExceptionFlags: DWORD,
777 pub ExceptionRecord: *mut EXCEPTION_RECORD,
778 pub ExceptionAddress: LPVOID,
779 pub NumberParameters: DWORD,
780 pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS],
786 pub struct EXCEPTION_POINTERS {
787 pub ExceptionRecord: *mut EXCEPTION_RECORD,
788 pub ContextRecord: *mut CONTEXT,
791 pub type PVECTORED_EXCEPTION_HANDLER =
792 extern "system" fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
795 #[derive(Copy, Clone)]
796 pub struct CONSOLE_READCONSOLE_CONTROL {
798 pub nInitialChars: ULONG,
799 pub dwCtrlWakeupMask: ULONG,
800 pub dwControlKeyState: ULONG,
803 pub type PCONSOLE_READCONSOLE_CONTROL = *mut CONSOLE_READCONSOLE_CONTROL;
806 pub struct BY_HANDLE_FILE_INFORMATION {
807 pub dwFileAttributes: DWORD,
808 pub ftCreationTime: FILETIME,
809 pub ftLastAccessTime: FILETIME,
810 pub ftLastWriteTime: FILETIME,
811 pub dwVolumeSerialNumber: DWORD,
812 pub nFileSizeHigh: DWORD,
813 pub nFileSizeLow: DWORD,
814 pub nNumberOfLinks: DWORD,
815 pub nFileIndexHigh: DWORD,
816 pub nFileIndexLow: DWORD,
819 pub type LPBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION;
820 pub type LPCVOID = *const c_void;
822 pub const HANDLE_FLAG_INHERIT: DWORD = 0x00000001;
824 pub const TOKEN_READ: DWORD = 0x20008;
826 #[link(name = "advapi32")]
828 // Allowed but unused by UWP
829 pub fn OpenProcessToken(
830 ProcessHandle: HANDLE,
831 DesiredAccess: DWORD,
832 TokenHandle: *mut HANDLE,
836 #[link(name = "userenv")]
838 // Allowed but unused by UWP
839 pub fn GetUserProfileDirectoryW(
841 lpProfileDir: LPWSTR,
842 lpcchSize: *mut DWORD,
846 #[link(name = "kernel32")]
848 // Functions forbidden when targeting UWP
850 hConsoleInput: HANDLE,
852 nNumberOfCharsToRead: DWORD,
853 lpNumberOfCharsRead: LPDWORD,
854 pInputControl: PCONSOLE_READCONSOLE_CONTROL,
857 pub fn WriteConsoleW(
858 hConsoleOutput: HANDLE,
860 nNumberOfCharsToWrite: DWORD,
861 lpNumberOfCharsWritten: LPDWORD,
865 pub fn GetConsoleMode(hConsoleHandle: HANDLE, lpMode: LPDWORD) -> BOOL;
866 // Allowed but unused by UWP
867 pub fn GetFileInformationByHandle(
869 lpFileInformation: LPBY_HANDLE_FILE_INFORMATION,
871 pub fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) -> BOOL;
872 pub fn AddVectoredExceptionHandler(
874 VectoredHandler: PVECTORED_EXCEPTION_HANDLER,
876 pub fn CreateHardLinkW(
877 lpSymlinkFileName: LPCWSTR,
878 lpTargetFileName: LPCWSTR,
879 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
881 pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL;
882 pub fn GetWindowsDirectoryW(lpBuffer: LPWSTR, uSize: UINT) -> UINT;
887 // UWP specific functions & types
889 if #[cfg(target_vendor = "uwp")] {
891 pub struct FILE_STANDARD_INFO {
892 pub AllocationSize: LARGE_INTEGER,
893 pub EndOfFile: LARGE_INTEGER,
894 pub NumberOfLinks: DWORD,
895 pub DeletePending: BOOLEAN,
896 pub Directory: BOOLEAN,
901 // Shared between Desktop & UWP
903 #[link(name = "kernel32")]
905 pub fn GetCurrentProcessId() -> DWORD;
907 pub fn GetSystemDirectoryW(lpBuffer: LPWSTR, uSize: UINT) -> UINT;
908 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
909 pub fn SetFileAttributesW(lpFileName: LPCWSTR, dwFileAttributes: DWORD) -> BOOL;
911 hFile: BorrowedHandle<'_>,
912 lpCreationTime: Option<&FILETIME>,
913 lpLastAccessTime: Option<&FILETIME>,
914 lpLastWriteTime: Option<&FILETIME>,
916 pub fn SetLastError(dwErrCode: DWORD);
917 pub fn GetCommandLineW() -> LPWSTR;
918 pub fn GetTempPathW(nBufferLength: DWORD, lpBuffer: LPCWSTR) -> DWORD;
919 pub fn GetCurrentProcess() -> HANDLE;
920 pub fn GetCurrentThread() -> HANDLE;
921 pub fn GetStdHandle(which: DWORD) -> HANDLE;
922 pub fn ExitProcess(uExitCode: c_uint) -> !;
923 pub fn DeviceIoControl(
925 dwIoControlCode: DWORD,
927 nInBufferSize: DWORD,
929 nOutBufferSize: DWORD,
930 lpBytesReturned: LPDWORD,
931 lpOverlapped: LPOVERLAPPED,
934 lpThreadAttributes: LPSECURITY_ATTRIBUTES,
936 lpStartAddress: extern "system" fn(*mut c_void) -> DWORD,
938 dwCreationFlags: DWORD,
941 pub fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD;
942 pub fn SwitchToThread() -> BOOL;
943 pub fn Sleep(dwMilliseconds: DWORD);
944 pub fn SleepEx(dwMilliseconds: DWORD, bAlertable: BOOL) -> DWORD;
945 pub fn GetProcessId(handle: HANDLE) -> DWORD;
947 lpExistingFileName: LPCWSTR,
948 lpNewFileName: LPCWSTR,
949 lpProgressRoutine: LPPROGRESS_ROUTINE,
954 pub fn FormatMessageW(
963 pub fn TlsAlloc() -> DWORD;
964 pub fn TlsGetValue(dwTlsIndex: DWORD) -> LPVOID;
965 pub fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;
966 pub fn TlsFree(dwTlsIndex: DWORD) -> BOOL;
967 pub fn GetLastError() -> DWORD;
968 pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL;
969 pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL;
970 pub fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL;
971 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL;
972 pub fn CreateProcessW(
973 lpApplicationName: LPCWSTR,
974 lpCommandLine: LPWSTR,
975 lpProcessAttributes: LPSECURITY_ATTRIBUTES,
976 lpThreadAttributes: LPSECURITY_ATTRIBUTES,
977 bInheritHandles: BOOL,
978 dwCreationFlags: DWORD,
979 lpEnvironment: LPVOID,
980 lpCurrentDirectory: LPCWSTR,
981 lpStartupInfo: LPSTARTUPINFO,
982 lpProcessInformation: LPPROCESS_INFORMATION,
984 pub fn GetEnvironmentVariableW(n: LPCWSTR, v: LPWSTR, nsize: DWORD) -> DWORD;
985 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) -> BOOL;
986 pub fn GetEnvironmentStringsW() -> LPWCH;
987 pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
988 pub fn GetModuleFileNameW(hModule: HMODULE, lpFilename: LPWSTR, nSize: DWORD) -> DWORD;
989 pub fn CreateDirectoryW(
991 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
993 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
994 pub fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD;
995 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
996 pub fn DuplicateHandle(
997 hSourceProcessHandle: HANDLE,
998 hSourceHandle: HANDLE,
999 hTargetProcessHandle: HANDLE,
1000 lpTargetHandle: LPHANDLE,
1001 dwDesiredAccess: DWORD,
1002 bInheritHandle: BOOL,
1006 hFile: BorrowedHandle<'_>,
1008 nNumberOfBytesToRead: DWORD,
1009 lpNumberOfBytesRead: LPDWORD,
1010 lpOverlapped: LPOVERLAPPED,
1013 hFile: BorrowedHandle<'_>,
1015 nNumberOfBytesToRead: DWORD,
1016 lpOverlapped: LPOVERLAPPED,
1017 lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE,
1020 hFile: BorrowedHandle<'_>,
1022 nNumberOfBytesToWrite: DWORD,
1023 lpOverlapped: LPOVERLAPPED,
1024 lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE,
1026 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
1027 pub fn MoveFileExW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, dwFlags: DWORD)
1029 pub fn SetFilePointerEx(
1031 liDistanceToMove: LARGE_INTEGER,
1032 lpNewFilePointer: PLARGE_INTEGER,
1033 dwMoveMethod: DWORD,
1035 pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
1037 lpFileName: LPCWSTR,
1038 dwDesiredAccess: DWORD,
1040 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
1041 dwCreationDisposition: DWORD,
1042 dwFlagsAndAttributes: DWORD,
1043 hTemplateFile: HANDLE,
1044 ) -> HandleOrInvalid;
1046 pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) -> HANDLE;
1047 pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) -> BOOL;
1048 pub fn FindClose(findFile: HANDLE) -> BOOL;
1050 pub fn GetProcAddress(handle: HMODULE, name: LPCSTR) -> *mut c_void;
1051 pub fn GetModuleHandleA(lpModuleName: LPCSTR) -> HMODULE;
1052 pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
1054 pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME);
1055 pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO);
1057 pub fn CreateEventW(
1058 lpEventAttributes: LPSECURITY_ATTRIBUTES,
1060 bInitialState: BOOL,
1063 pub fn WaitForMultipleObjects(
1065 lpHandles: *const HANDLE,
1067 dwMilliseconds: DWORD,
1069 pub fn CreateNamedPipeW(
1073 nMaxInstances: DWORD,
1074 nOutBufferSize: DWORD,
1075 nInBufferSize: DWORD,
1076 nDefaultTimeOut: DWORD,
1077 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
1079 pub fn CancelIo(handle: HANDLE) -> BOOL;
1080 pub fn GetOverlappedResult(
1082 lpOverlapped: LPOVERLAPPED,
1083 lpNumberOfBytesTransferred: LPDWORD,
1086 pub fn CreateSymbolicLinkW(
1087 lpSymlinkFileName: LPCWSTR,
1088 lpTargetFileName: LPCWSTR,
1091 pub fn GetFinalPathNameByHandleW(
1093 lpszFilePath: LPCWSTR,
1097 pub fn GetFileInformationByHandleEx(
1099 fileInfoClass: FILE_INFO_BY_HANDLE_CLASS,
1100 lpFileInformation: LPVOID,
1101 dwBufferSize: DWORD,
1103 pub fn SetFileInformationByHandle(
1105 FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
1106 lpFileInformation: LPVOID,
1107 dwBufferSize: DWORD,
1109 pub fn SleepConditionVariableSRW(
1110 ConditionVariable: PCONDITION_VARIABLE,
1112 dwMilliseconds: DWORD,
1116 pub fn WakeConditionVariable(ConditionVariable: PCONDITION_VARIABLE);
1117 pub fn WakeAllConditionVariable(ConditionVariable: PCONDITION_VARIABLE);
1119 pub fn AcquireSRWLockExclusive(SRWLock: PSRWLOCK);
1120 pub fn AcquireSRWLockShared(SRWLock: PSRWLOCK);
1121 pub fn ReleaseSRWLockExclusive(SRWLock: PSRWLOCK);
1122 pub fn ReleaseSRWLockShared(SRWLock: PSRWLOCK);
1123 pub fn TryAcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> BOOLEAN;
1124 pub fn TryAcquireSRWLockShared(SRWLock: PSRWLOCK) -> BOOLEAN;
1126 pub fn InitOnceBeginInitialize(
1127 lpInitOnce: LPINIT_ONCE,
1130 lpContext: *mut LPVOID,
1132 pub fn InitOnceComplete(lpInitOnce: LPINIT_ONCE, dwFlags: DWORD, lpContext: LPVOID) -> BOOL;
1134 pub fn CompareStringOrdinal(
1141 pub fn GetFullPathNameW(
1142 lpFileName: LPCWSTR,
1143 nBufferLength: DWORD,
1145 lpFilePart: *mut LPWSTR,
1147 pub fn GetFileAttributesW(lpFileName: LPCWSTR) -> DWORD;
1150 #[link(name = "ws2_32")]
1152 pub fn WSAStartup(wVersionRequested: WORD, lpWSAData: LPWSADATA) -> c_int;
1153 pub fn WSACleanup() -> c_int;
1154 pub fn WSAGetLastError() -> c_int;
1155 pub fn WSADuplicateSocketW(
1158 lpProtocolInfo: LPWSAPROTOCOL_INFO,
1162 lpBuffers: LPWSABUF,
1163 dwBufferCount: DWORD,
1164 lpNumberOfBytesSent: LPDWORD,
1166 lpOverlapped: LPWSAOVERLAPPED,
1167 lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
1171 lpBuffers: LPWSABUF,
1172 dwBufferCount: DWORD,
1173 lpNumberOfBytesRecvd: LPDWORD,
1175 lpOverlapped: LPWSAOVERLAPPED,
1176 lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
1182 lpProtocolInfo: LPWSAPROTOCOL_INFO,
1186 pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int;
1187 pub fn closesocket(socket: SOCKET) -> c_int;
1188 pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, flags: c_int) -> c_int;
1189 pub fn send(socket: SOCKET, buf: *const c_void, len: c_int, flags: c_int) -> c_int;
1195 addr: *mut SOCKADDR,
1196 addrlen: *mut c_int,
1203 addr: *const SOCKADDR,
1206 pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
1207 pub fn accept(socket: SOCKET, address: *mut SOCKADDR, address_len: *mut c_int) -> SOCKET;
1212 optval: *mut c_char,
1219 optval: *const c_void,
1222 pub fn getsockname(socket: SOCKET, address: *mut SOCKADDR, address_len: *mut c_int) -> c_int;
1223 pub fn getpeername(socket: SOCKET, address: *mut SOCKADDR, address_len: *mut c_int) -> c_int;
1224 pub fn bind(socket: SOCKET, address: *const SOCKADDR, address_len: socklen_t) -> c_int;
1225 pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
1226 pub fn connect(socket: SOCKET, address: *const SOCKADDR, len: c_int) -> c_int;
1228 node: *const c_char,
1229 service: *const c_char,
1230 hints: *const ADDRINFOA,
1231 res: *mut *mut ADDRINFOA,
1233 pub fn freeaddrinfo(res: *mut ADDRINFOA);
1236 readfds: *mut fd_set,
1237 writefds: *mut fd_set,
1238 exceptfds: *mut fd_set,
1239 timeout: *const timeval,
1243 #[link(name = "bcrypt")]
1245 // >= Vista / Server 2008
1246 // https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
1247 pub fn BCryptGenRandom(
1248 hAlgorithm: BCRYPT_ALG_HANDLE,
1253 pub fn BCryptOpenAlgorithmProvider(
1254 phalgorithm: *mut BCRYPT_ALG_HANDLE,
1256 pszimplementation: LPCWSTR,
1259 pub fn BCryptCloseAlgorithmProvider(hAlgorithm: BCRYPT_ALG_HANDLE, dwFlags: ULONG) -> NTSTATUS;
1262 // Functions that aren't available on every version of Windows that we support,
1263 // but we still use them and just provide some form of a fallback implementation.
1264 compat_fn_with_fallback! {
1265 pub static KERNEL32: &CStr = ansi_str!("kernel32");
1268 // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
1269 pub fn SetThreadDescription(hThread: HANDLE,
1270 lpThreadDescription: LPCWSTR) -> HRESULT {
1271 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); E_NOTIMPL
1274 // >= Win8 / Server 2012
1275 // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
1276 pub fn GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime: LPFILETIME)
1278 GetSystemTimeAsFileTime(lpSystemTimeAsFileTime)
1281 // >= Win11 / Server 2022
1282 // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a
1283 pub fn GetTempPath2W(nBufferLength: DWORD, lpBuffer: LPCWSTR) -> DWORD {
1284 GetTempPathW(nBufferLength, lpBuffer)
1288 compat_fn_optional! {
1289 crate::sys::compat::load_synch_functions();
1290 pub fn WaitOnAddress(
1292 CompareAddress: LPVOID,
1293 AddressSize: SIZE_T,
1294 dwMilliseconds: DWORD
1296 pub fn WakeByAddressSingle(Address: LPVOID);
1299 compat_fn_with_fallback! {
1300 pub static NTDLL: &CStr = ansi_str!("ntdll");
1302 pub fn NtCreateFile(
1303 FileHandle: *mut HANDLE,
1304 DesiredAccess: ACCESS_MASK,
1305 ObjectAttributes: *const OBJECT_ATTRIBUTES,
1306 IoStatusBlock: *mut IO_STATUS_BLOCK,
1307 AllocationSize: *mut i64,
1308 FileAttributes: ULONG,
1310 CreateDisposition: ULONG,
1311 CreateOptions: ULONG,
1312 EaBuffer: *mut c_void,
1315 STATUS_NOT_IMPLEMENTED
1318 FileHandle: BorrowedHandle<'_>,
1320 ApcRoutine: Option<IO_APC_ROUTINE>,
1321 ApcContext: *mut c_void,
1322 IoStatusBlock: &mut IO_STATUS_BLOCK,
1323 Buffer: *mut crate::mem::MaybeUninit<u8>,
1325 ByteOffset: Option<&LARGE_INTEGER>,
1328 STATUS_NOT_IMPLEMENTED
1331 FileHandle: BorrowedHandle<'_>,
1333 ApcRoutine: Option<IO_APC_ROUTINE>,
1334 ApcContext: *mut c_void,
1335 IoStatusBlock: &mut IO_STATUS_BLOCK,
1338 ByteOffset: Option<&LARGE_INTEGER>,
1341 STATUS_NOT_IMPLEMENTED
1343 pub fn RtlNtStatusToDosError(
1348 pub fn NtCreateKeyedEvent(
1349 KeyedEventHandle: LPHANDLE,
1350 DesiredAccess: ACCESS_MASK,
1351 ObjectAttributes: LPVOID,
1354 panic!("keyed events not available")
1356 pub fn NtReleaseKeyedEvent(
1357 EventHandle: HANDLE,
1360 Timeout: PLARGE_INTEGER
1362 panic!("keyed events not available")
1364 pub fn NtWaitForKeyedEvent(
1365 EventHandle: HANDLE,
1368 Timeout: PLARGE_INTEGER
1370 panic!("keyed events not available")