1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! C definitions used by libnative that don't belong in liblibc
13 #![allow(bad_style, overflowing_literals, dead_code, deprecated, unused_imports)]
15 use os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort};
16 use os::raw::{c_char, c_short, c_ulonglong};
17 use libc::{wchar_t, size_t, c_void};
22 struct u64x2(u64, u64);
24 pub use self::GET_FILEEX_INFO_LEVELS::*;
25 pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
26 pub use self::EXCEPTION_DISPOSITION::*;
28 pub type DWORD = c_ulong;
29 pub type HANDLE = LPVOID;
30 pub type HINSTANCE = HANDLE;
31 pub type HMODULE = HINSTANCE;
32 pub type BOOL = c_int;
34 pub type BOOLEAN = BYTE;
35 pub type GROUP = c_uint;
36 pub type LONG_PTR = isize;
37 pub type LARGE_INTEGER = c_longlong;
38 pub type LONG = c_long;
39 pub type UINT = c_uint;
41 pub type USHORT = c_ushort;
42 pub type SIZE_T = usize;
44 pub type CHAR = c_char;
45 pub type HCRYPTPROV = LONG_PTR;
46 pub type ULONG_PTR = c_ulonglong;
47 pub type ULONG = c_ulong;
48 pub type ULONGLONG = u64;
49 pub type DWORDLONG = ULONGLONG;
51 pub type LPBOOL = *mut BOOL;
52 pub type LPBYTE = *mut BYTE;
53 pub type LPBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION;
54 pub type LPCSTR = *const CHAR;
55 pub type LPCVOID = *const c_void;
56 pub type LPCWSTR = *const WCHAR;
57 pub type LPDWORD = *mut DWORD;
58 pub type LPHANDLE = *mut HANDLE;
59 pub type LPOVERLAPPED = *mut OVERLAPPED;
60 pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
61 pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
62 pub type LPSTARTUPINFO = *mut STARTUPINFO;
63 pub type LPVOID = *mut c_void;
64 pub type LPWCH = *mut WCHAR;
65 pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
66 pub type LPWSADATA = *mut WSADATA;
67 pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS;
68 pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
69 pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
70 pub type LPWSTR = *mut WCHAR;
71 pub type LPFILETIME = *mut FILETIME;
73 pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE;
74 pub type PLARGE_INTEGER = *mut c_longlong;
75 pub type PSRWLOCK = *mut SRWLOCK;
77 pub type SOCKET = ::os::windows::raw::SOCKET;
78 pub type socklen_t = c_int;
79 pub type ADDRESS_FAMILY = USHORT;
81 pub const TRUE: BOOL = 1;
82 pub const FALSE: BOOL = 0;
84 pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1;
85 pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10;
86 pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80;
87 pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400;
88 pub const FILE_SHARE_DELETE: DWORD = 0x4;
89 pub const FILE_SHARE_READ: DWORD = 0x1;
90 pub const FILE_SHARE_WRITE: DWORD = 0x2;
91 pub const CREATE_ALWAYS: DWORD = 2;
92 pub const CREATE_NEW: DWORD = 1;
93 pub const OPEN_ALWAYS: DWORD = 4;
94 pub const OPEN_EXISTING: DWORD = 3;
95 pub const TRUNCATE_EXISTING: DWORD = 5;
97 pub const FILE_READ_DATA: DWORD = 0x00000001;
98 pub const FILE_WRITE_DATA: DWORD = 0x00000002;
99 pub const FILE_APPEND_DATA: DWORD = 0x00000004;
100 pub const FILE_READ_EA: DWORD = 0x00000008;
101 pub const FILE_WRITE_EA: DWORD = 0x00000010;
102 pub const FILE_EXECUTE: DWORD = 0x00000020;
103 pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080;
104 pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100;
106 pub const DELETE: DWORD = 0x00008000;
107 pub const READ_CONTROL: DWORD = 0x00020000;
108 pub const WRITE_DAC: DWORD = 0x00040000;
109 pub const WRITE_OWNER: DWORD = 0x00080000;
110 pub const SYNCHRONIZE: DWORD = 0x00100000;
112 pub const GENERIC_READ: DWORD = 0x80000000;
113 pub const GENERIC_WRITE: DWORD = 0x40000000;
114 pub const GENERIC_EXECUTE: DWORD = 0x20000000;
115 pub const GENERIC_ALL: DWORD = 0x10000000;
117 pub const STANDARD_RIGHTS_READ: DWORD = READ_CONTROL;
118 pub const STANDARD_RIGHTS_WRITE: DWORD = READ_CONTROL;
119 pub const STANDARD_RIGHTS_EXECUTE: DWORD = READ_CONTROL;
120 pub const FILE_GENERIC_READ: DWORD = STANDARD_RIGHTS_READ | FILE_READ_DATA |
121 FILE_READ_ATTRIBUTES |
124 pub const FILE_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |
125 FILE_WRITE_ATTRIBUTES |
130 pub const SECURITY_ANONYMOUS: DWORD = 0 << 16;
131 pub const SECURITY_IDENTIFICATION: DWORD = 1 << 16;
132 pub const SECURITY_IMPERSONATION: DWORD = 2 << 16;
133 pub const SECURITY_DELEGATION: DWORD = 3 << 16;
134 pub const SECURITY_CONTEXT_TRACKING: DWORD = 0x00040000;
135 pub const SECURITY_EFFECTIVE_ONLY: DWORD = 0x00080000;
136 pub const SECURITY_SQOS_PRESENT: DWORD = 0x00100000;
140 pub struct WIN32_FIND_DATAW {
141 pub dwFileAttributes: DWORD,
142 pub ftCreationTime: FILETIME,
143 pub ftLastAccessTime: FILETIME,
144 pub ftLastWriteTime: FILETIME,
145 pub nFileSizeHigh: DWORD,
146 pub nFileSizeLow: DWORD,
147 pub dwReserved0: DWORD,
148 pub dwReserved1: DWORD,
149 pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
150 pub cAlternateFileName: [wchar_t; 14],
152 impl Clone for WIN32_FIND_DATAW {
153 fn clone(&self) -> Self { *self }
156 pub const FIONBIO: c_long = 0x8004667e;
157 pub const FD_SETSIZE: usize = 64;
158 pub const MSG_DONTWAIT: c_int = 0;
159 pub const ENABLE_ECHO_INPUT: DWORD = 0x4;
160 pub const ENABLE_EXTENDED_FLAGS: DWORD = 0x80;
161 pub const ENABLE_INSERT_MODE: DWORD = 0x20;
162 pub const ENABLE_LINE_INPUT: DWORD = 0x2;
163 pub const ENABLE_PROCESSED_INPUT: DWORD = 0x1;
164 pub const ENABLE_QUICK_EDIT_MODE: DWORD = 0x40;
166 pub const FD_ACCEPT: c_long = 0x08;
167 pub const FD_MAX_EVENTS: usize = 10;
169 pub const WSA_INVALID_EVENT: WSAEVENT = 0 as WSAEVENT;
170 pub const WSA_INFINITE: DWORD = INFINITE;
171 pub const WSA_WAIT_TIMEOUT: DWORD = WAIT_TIMEOUT;
172 pub const WSA_WAIT_EVENT_0: DWORD = WAIT_OBJECT_0;
173 pub const WSA_WAIT_FAILED: DWORD = WAIT_FAILED;
174 pub const WSA_FLAG_OVERLAPPED: DWORD = 0x01;
175 pub const WSA_FLAG_NO_HANDLE_INHERIT: DWORD = 0x80;
177 pub const WSADESCRIPTION_LEN: usize = 256;
178 pub const WSASYS_STATUS_LEN: usize = 128;
179 pub const WSAPROTOCOL_LEN: DWORD = 255;
180 pub const INVALID_SOCKET: SOCKET = !0;
182 pub const WSAEINTR: c_int = 10004;
183 pub const WSAEBADF: c_int = 10009;
184 pub const WSAEACCES: c_int = 10013;
185 pub const WSAEFAULT: c_int = 10014;
186 pub const WSAEINVAL: c_int = 10022;
187 pub const WSAEMFILE: c_int = 10024;
188 pub const WSAEWOULDBLOCK: c_int = 10035;
189 pub const WSAEINPROGRESS: c_int = 10036;
190 pub const WSAEALREADY: c_int = 10037;
191 pub const WSAENOTSOCK: c_int = 10038;
192 pub const WSAEDESTADDRREQ: c_int = 10039;
193 pub const WSAEMSGSIZE: c_int = 10040;
194 pub const WSAEPROTOTYPE: c_int = 10041;
195 pub const WSAENOPROTOOPT: c_int = 10042;
196 pub const WSAEPROTONOSUPPORT: c_int = 10043;
197 pub const WSAESOCKTNOSUPPORT: c_int = 10044;
198 pub const WSAEOPNOTSUPP: c_int = 10045;
199 pub const WSAEPFNOSUPPORT: c_int = 10046;
200 pub const WSAEAFNOSUPPORT: c_int = 10047;
201 pub const WSAEADDRINUSE: c_int = 10048;
202 pub const WSAEADDRNOTAVAIL: c_int = 10049;
203 pub const WSAENETDOWN: c_int = 10050;
204 pub const WSAENETUNREACH: c_int = 10051;
205 pub const WSAENETRESET: c_int = 10052;
206 pub const WSAECONNABORTED: c_int = 10053;
207 pub const WSAECONNRESET: c_int = 10054;
208 pub const WSAENOBUFS: c_int = 10055;
209 pub const WSAEISCONN: c_int = 10056;
210 pub const WSAENOTCONN: c_int = 10057;
211 pub const WSAESHUTDOWN: c_int = 10058;
212 pub const WSAETOOMANYREFS: c_int = 10059;
213 pub const WSAETIMEDOUT: c_int = 10060;
214 pub const WSAECONNREFUSED: c_int = 10061;
215 pub const WSAELOOP: c_int = 10062;
216 pub const WSAENAMETOOLONG: c_int = 10063;
217 pub const WSAEHOSTDOWN: c_int = 10064;
218 pub const WSAEHOSTUNREACH: c_int = 10065;
219 pub const WSAENOTEMPTY: c_int = 10066;
220 pub const WSAEPROCLIM: c_int = 10067;
221 pub const WSAEUSERS: c_int = 10068;
222 pub const WSAEDQUOT: c_int = 10069;
223 pub const WSAESTALE: c_int = 10070;
224 pub const WSAEREMOTE: c_int = 10071;
225 pub const WSASYSNOTREADY: c_int = 10091;
226 pub const WSAVERNOTSUPPORTED: c_int = 10092;
227 pub const WSANOTINITIALISED: c_int = 10093;
228 pub const WSAEDISCON: c_int = 10101;
229 pub const WSAENOMORE: c_int = 10102;
230 pub const WSAECANCELLED: c_int = 10103;
231 pub const WSAEINVALIDPROCTABLE: c_int = 10104;
232 pub const NI_MAXHOST: DWORD = 1025;
234 pub const MAX_PROTOCOL_CHAIN: DWORD = 7;
236 pub const TOKEN_READ: DWORD = 0x20008;
237 pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
238 pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
239 pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: usize = 16 * 1024;
240 pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
241 pub const IO_REPARSE_TAG_SYMLINK: DWORD = 0xa000000c;
242 pub const IO_REPARSE_TAG_MOUNT_POINT: DWORD = 0xa0000003;
243 pub const SYMLINK_FLAG_RELATIVE: DWORD = 0x00000001;
244 pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
245 pub const FSCTL_DELETE_REPARSE_POINT: DWORD = 0x900ac;
247 pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 0x1;
249 // Note that these are not actually HANDLEs, just values to pass to GetStdHandle
250 pub const STD_INPUT_HANDLE: DWORD = -10i32 as DWORD;
251 pub const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
252 pub const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD;
254 pub const HANDLE_FLAG_INHERIT: DWORD = 0x00000001;
256 pub const PROGRESS_CONTINUE: DWORD = 0;
257 pub const PROGRESS_CANCEL: DWORD = 1;
258 pub const PROGRESS_STOP: DWORD = 2;
259 pub const PROGRESS_QUIET: DWORD = 3;
261 pub const TOKEN_ADJUST_PRIVILEGES: DWORD = 0x0020;
262 pub const SE_PRIVILEGE_ENABLED: DWORD = 2;
265 pub const ERROR_SUCCESS: DWORD = 0;
266 pub const ERROR_INVALID_FUNCTION: DWORD = 1;
267 pub const ERROR_FILE_NOT_FOUND: DWORD = 2;
268 pub const ERROR_PATH_NOT_FOUND: DWORD = 3;
269 pub const ERROR_ACCESS_DENIED: DWORD = 5;
270 pub const ERROR_INVALID_HANDLE: DWORD = 6;
271 pub const ERROR_NO_MORE_FILES: DWORD = 18;
272 pub const ERROR_BROKEN_PIPE: DWORD = 109;
273 pub const ERROR_DISK_FULL: DWORD = 112;
274 pub const ERROR_CALL_NOT_IMPLEMENTED: DWORD = 120;
275 pub const ERROR_INSUFFICIENT_BUFFER: DWORD = 122;
276 pub const ERROR_INVALID_NAME: DWORD = 123;
277 pub const ERROR_ALREADY_EXISTS: DWORD = 183;
278 pub const ERROR_PIPE_BUSY: DWORD = 231;
279 pub const ERROR_NO_DATA: DWORD = 232;
280 pub const ERROR_INVALID_ADDRESS: DWORD = 487;
281 pub const ERROR_PIPE_CONNECTED: DWORD = 535;
282 pub const ERROR_ILLEGAL_CHARACTER: DWORD = 582;
283 pub const ERROR_ENVVAR_NOT_FOUND: DWORD = 203;
284 pub const ERROR_NOTHING_TO_TERMINATE: DWORD = 758;
285 pub const ERROR_OPERATION_ABORTED: DWORD = 995;
286 pub const ERROR_IO_PENDING: DWORD = 997;
287 pub const ERROR_FILE_INVALID: DWORD = 1006;
288 pub const ERROR_NOT_FOUND: DWORD = 1168;
289 pub const ERROR_TIMEOUT: DWORD = 0x5B4;
291 pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
293 pub const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000;
294 pub const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200;
296 pub const TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF;
298 pub const DLL_THREAD_DETACH: DWORD = 3;
299 pub const DLL_PROCESS_DETACH: DWORD = 0;
301 pub const INFINITE: DWORD = !0;
303 pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002;
305 pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE {
306 ptr: ptr::null_mut(),
308 pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { ptr: ptr::null_mut() };
310 pub const STILL_ACTIVE: DWORD = 259;
312 pub const DETACHED_PROCESS: DWORD = 0x00000008;
313 pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200;
314 pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400;
315 pub const STARTF_USESTDHANDLES: DWORD = 0x00000100;
317 pub const AF_INET: c_int = 2;
318 pub const AF_INET6: c_int = 23;
319 pub const SD_BOTH: c_int = 2;
320 pub const SD_RECEIVE: c_int = 0;
321 pub const SD_SEND: c_int = 1;
322 pub const SOCK_DGRAM: c_int = 2;
323 pub const SOCK_STREAM: c_int = 1;
324 pub const SOL_SOCKET: c_int = 0xffff;
325 pub const SO_RCVTIMEO: c_int = 0x1006;
326 pub const SO_SNDTIMEO: c_int = 0x1005;
327 pub const SO_REUSEADDR: c_int = 0x0004;
329 pub const VOLUME_NAME_DOS: DWORD = 0x0;
330 pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1;
332 pub const FILE_BEGIN: DWORD = 0;
333 pub const FILE_CURRENT: DWORD = 1;
334 pub const FILE_END: DWORD = 2;
336 pub const WAIT_ABANDONED: DWORD = 0x00000080;
337 pub const WAIT_OBJECT_0: DWORD = 0x00000000;
338 pub const WAIT_TIMEOUT: DWORD = 0x00000102;
339 pub const WAIT_FAILED: DWORD = !0;
341 pub const MAX_SYM_NAME: usize = 2000;
342 pub const IMAGE_FILE_MACHINE_I386: DWORD = 0x014c;
343 pub const IMAGE_FILE_MACHINE_IA64: DWORD = 0x0200;
344 pub const IMAGE_FILE_MACHINE_AMD64: DWORD = 0x8664;
346 pub const PROV_RSA_FULL: DWORD = 1;
347 pub const CRYPT_SILENT: DWORD = 64;
348 pub const CRYPT_VERIFYCONTEXT: DWORD = 0xF0000000;
350 pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
351 pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
352 pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
353 pub const EXCEPTION_NONCONTINUABLE: DWORD = 0x1; // Noncontinuable exception
354 pub const EXCEPTION_UNWINDING: DWORD = 0x2; // Unwind is in progress
355 pub const EXCEPTION_EXIT_UNWIND: DWORD = 0x4; // Exit unwind is in progress
356 pub const EXCEPTION_STACK_INVALID: DWORD = 0x8; // Stack out of limits or unaligned
357 pub const EXCEPTION_NESTED_CALL: DWORD = 0x10; // Nested exception handler call
358 pub const EXCEPTION_TARGET_UNWIND: DWORD = 0x20; // Target unwind in progress
359 pub const EXCEPTION_COLLIDED_UNWIND: DWORD = 0x40; // Collided exception handler call
360 pub const EXCEPTION_UNWIND: DWORD = EXCEPTION_UNWINDING |
361 EXCEPTION_EXIT_UNWIND |
362 EXCEPTION_TARGET_UNWIND |
363 EXCEPTION_COLLIDED_UNWIND;
366 #[cfg(target_arch = "x86")]
369 pub wHighVersion: WORD,
370 pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
371 pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
372 pub iMaxSockets: u16,
374 pub lpVendorInfo: *mut u8,
377 #[cfg(target_arch = "x86_64")]
380 pub wHighVersion: WORD,
381 pub iMaxSockets: u16,
383 pub lpVendorInfo: *mut u8,
384 pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
385 pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
389 pub struct WSANETWORKEVENTS {
390 pub lNetworkEvents: c_long,
391 pub iErrorCode: [c_int; FD_MAX_EVENTS],
394 pub type WSAEVENT = HANDLE;
397 pub struct WSAPROTOCOL_INFO {
398 pub dwServiceFlags1: DWORD,
399 pub dwServiceFlags2: DWORD,
400 pub dwServiceFlags3: DWORD,
401 pub dwServiceFlags4: DWORD,
402 pub dwProviderFlags: DWORD,
403 pub ProviderId: GUID,
404 pub dwCatalogEntryId: DWORD,
405 pub ProtocolChain: WSAPROTOCOLCHAIN,
407 pub iAddressFamily: c_int,
408 pub iMaxSockAddr: c_int,
409 pub iMinSockAddr: c_int,
410 pub iSocketType: c_int,
411 pub iProtocol: c_int,
412 pub iProtocolMaxOffset: c_int,
413 pub iNetworkByteOrder: c_int,
414 pub iSecurityScheme: c_int,
415 pub dwMessageSize: DWORD,
416 pub dwProviderReserved: DWORD,
417 pub szProtocol: [u16; (WSAPROTOCOL_LEN as usize) + 1],
423 fd_array: [SOCKET; FD_SETSIZE],
426 pub fn fd_set(set: &mut fd_set, s: SOCKET) {
427 set.fd_array[set.fd_count as usize] = s;
431 pub type SHORT = c_short;
440 pub struct SMALL_RECT {
448 pub struct CONSOLE_SCREEN_BUFFER_INFO {
450 pub dwCursorPosition: COORD,
451 pub wAttributes: WORD,
452 pub srWindow: SMALL_RECT,
453 pub dwMaximumWindowSize: COORD,
455 pub type PCONSOLE_SCREEN_BUFFER_INFO = *mut CONSOLE_SCREEN_BUFFER_INFO;
458 #[derive(Copy, Clone)]
459 pub struct WIN32_FILE_ATTRIBUTE_DATA {
460 pub dwFileAttributes: DWORD,
461 pub ftCreationTime: FILETIME,
462 pub ftLastAccessTime: FILETIME,
463 pub ftLastWriteTime: FILETIME,
464 pub nFileSizeHigh: DWORD,
465 pub nFileSizeLow: DWORD,
469 pub struct BY_HANDLE_FILE_INFORMATION {
470 pub dwFileAttributes: DWORD,
471 pub ftCreationTime: FILETIME,
472 pub ftLastAccessTime: FILETIME,
473 pub ftLastWriteTime: FILETIME,
474 pub dwVolumeSerialNumber: DWORD,
475 pub nFileSizeHigh: DWORD,
476 pub nFileSizeLow: DWORD,
477 pub nNumberOfLinks: DWORD,
478 pub nFileIndexHigh: DWORD,
479 pub nFileIndexLow: DWORD,
483 pub enum GET_FILEEX_INFO_LEVELS {
484 GetFileExInfoStandard,
485 GetFileExMaxInfoLevel
489 pub enum FILE_INFO_BY_HANDLE_CLASS {
491 FileStandardInfo = 1,
494 FileDispositionInfo = 4,
495 FileAllocationInfo = 5,
496 FileEndOfFileInfo = 6,
498 FileCompressionInfo = 8,
499 FileAttributeTagInfo = 9,
500 FileIdBothDirectoryInfo = 10, // 0xA
501 FileIdBothDirectoryRestartInfo = 11, // 0xB
502 FileIoPriorityHintInfo = 12, // 0xC
503 FileRemoteProtocolInfo = 13, // 0xD
504 FileFullDirectoryInfo = 14, // 0xE
505 FileFullDirectoryRestartInfo = 15, // 0xF
506 FileStorageInfo = 16, // 0x10
507 FileAlignmentInfo = 17, // 0x11
508 FileIdInfo = 18, // 0x12
509 FileIdExtdDirectoryInfo = 19, // 0x13
510 FileIdExtdDirectoryRestartInfo = 20, // 0x14
511 MaximumFileInfoByHandlesClass
515 pub struct FILE_END_OF_FILE_INFO {
516 pub EndOfFile: LARGE_INTEGER,
520 pub struct REPARSE_DATA_BUFFER {
521 pub ReparseTag: c_uint,
522 pub ReparseDataLength: c_ushort,
523 pub Reserved: c_ushort,
528 pub struct SYMBOLIC_LINK_REPARSE_BUFFER {
529 pub SubstituteNameOffset: c_ushort,
530 pub SubstituteNameLength: c_ushort,
531 pub PrintNameOffset: c_ushort,
532 pub PrintNameLength: c_ushort,
534 pub PathBuffer: WCHAR,
538 pub struct MOUNT_POINT_REPARSE_BUFFER {
539 pub SubstituteNameOffset: c_ushort,
540 pub SubstituteNameLength: c_ushort,
541 pub PrintNameOffset: c_ushort,
542 pub PrintNameLength: c_ushort,
543 pub PathBuffer: WCHAR,
546 pub type LPPROGRESS_ROUTINE = ::option::Option<unsafe extern "system" fn(
547 TotalFileSize: LARGE_INTEGER,
548 TotalBytesTransferred: LARGE_INTEGER,
549 StreamSize: LARGE_INTEGER,
550 StreamBytesTransferred: LARGE_INTEGER,
551 dwStreamNumber: DWORD,
552 dwCallbackReason: DWORD,
554 hDestinationFile: HANDLE,
559 pub struct CONDITION_VARIABLE { pub ptr: LPVOID }
561 pub struct SRWLOCK { pub ptr: LPVOID }
563 pub struct CRITICAL_SECTION {
564 CriticalSectionDebug: LPVOID,
566 RecursionCount: LONG,
567 OwningThread: HANDLE,
568 LockSemaphore: HANDLE,
575 pub HighPart: c_long,
578 pub type PLUID = *mut LUID;
581 pub struct TOKEN_PRIVILEGES {
582 pub PrivilegeCount: DWORD,
583 pub Privileges: [LUID_AND_ATTRIBUTES; 1],
586 pub type PTOKEN_PRIVILEGES = *mut TOKEN_PRIVILEGES;
589 pub struct LUID_AND_ATTRIBUTES {
591 pub Attributes: DWORD,
595 pub struct REPARSE_MOUNTPOINT_DATA_BUFFER {
596 pub ReparseTag: DWORD,
597 pub ReparseDataLength: DWORD,
599 pub ReparseTargetLength: WORD,
600 pub ReparseTargetMaximumLength: WORD,
602 pub ReparseTarget: WCHAR,
606 pub struct EXCEPTION_RECORD {
607 pub ExceptionCode: DWORD,
608 pub ExceptionFlags: DWORD,
609 pub ExceptionRecord: *mut EXCEPTION_RECORD,
610 pub ExceptionAddress: LPVOID,
611 pub NumberParameters: DWORD,
612 pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
616 pub struct EXCEPTION_POINTERS {
617 pub ExceptionRecord: *mut EXCEPTION_RECORD,
618 pub ContextRecord: *mut CONTEXT,
621 pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
622 fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
629 pub Data4: [BYTE; 8],
633 pub struct WSAPROTOCOLCHAIN {
635 pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize],
639 pub struct SECURITY_ATTRIBUTES {
641 pub lpSecurityDescriptor: LPVOID,
642 pub bInheritHandle: BOOL,
646 pub struct PROCESS_INFORMATION {
647 pub hProcess: HANDLE,
649 pub dwProcessId: DWORD,
650 pub dwThreadId: DWORD,
654 pub struct STARTUPINFO {
656 pub lpReserved: LPWSTR,
657 pub lpDesktop: LPWSTR,
663 pub dwXCountChars: DWORD,
664 pub dwYCountCharts: DWORD,
665 pub dwFillAttribute: DWORD,
667 pub wShowWindow: WORD,
668 pub cbReserved2: WORD,
669 pub lpReserved2: LPBYTE,
670 pub hStdInput: HANDLE,
671 pub hStdOutput: HANDLE,
672 pub hStdError: HANDLE,
676 pub struct SOCKADDR {
677 pub sa_family: ADDRESS_FAMILY,
678 pub sa_data: [CHAR; 14],
682 #[derive(Copy, Clone)]
683 pub struct FILETIME {
684 pub dwLowDateTime: DWORD,
685 pub dwHighDateTime: DWORD,
689 pub struct OVERLAPPED {
690 pub Internal: *mut c_ulong,
691 pub InternalHigh: *mut c_ulong,
693 pub OffsetHigh: DWORD,
698 pub struct SYMBOL_INFO {
699 pub SizeOfStruct: c_ulong,
700 pub TypeIndex: c_ulong,
701 pub Reserved: [u64; 2],
708 pub Register: c_ulong,
711 pub NameLen: c_ulong,
712 pub MaxNameLen: c_ulong,
713 // note that windows has this as 1, but it basically just means that
714 // the name is inline at the end of the struct. For us, we just bump
715 // the struct size up to MAX_SYM_NAME.
716 pub Name: [c_char; MAX_SYM_NAME],
720 pub struct IMAGEHLP_LINE64 {
721 pub SizeOfStruct: u32,
722 pub Key: *const c_void,
724 pub Filename: *const c_char,
729 pub enum ADDRESS_MODE {
737 pub struct ADDRESS64 {
740 pub Mode: ADDRESS_MODE,
744 pub struct STACKFRAME64 {
745 pub AddrPC: ADDRESS64,
746 pub AddrReturn: ADDRESS64,
747 pub AddrFrame: ADDRESS64,
748 pub AddrStack: ADDRESS64,
749 pub AddrBStore: ADDRESS64,
750 pub FuncTableEntry: *mut c_void,
751 pub Params: [u64; 4],
754 pub Reserved: [u64; 3],
755 pub KdHelp: KDHELP64,
759 pub struct KDHELP64 {
761 pub ThCallbackStack: DWORD,
762 pub ThCallbackBStore: DWORD,
763 pub NextCallback: DWORD,
764 pub FramePointer: DWORD,
765 pub KiCallUserMode: u64,
766 pub KeUserCallbackDispatcher: u64,
767 pub SystemRangeStart: u64,
768 pub KiUserExceptionDispatcher: u64,
771 pub Reserved: [u64; 5],
774 #[cfg(target_arch = "x86")]
777 pub ContextFlags: DWORD,
784 pub FloatSave: FLOATING_SAVE_AREA,
801 pub ExtendedRegisters: [u8; 512],
804 #[cfg(target_arch = "x86")]
806 pub struct FLOATING_SAVE_AREA {
807 pub ControlWord: DWORD,
808 pub StatusWord: DWORD,
810 pub ErrorOffset: DWORD,
811 pub ErrorSelector: DWORD,
812 pub DataOffset: DWORD,
813 pub DataSelector: DWORD,
814 pub RegisterArea: [u8; 80],
815 pub Cr0NpxState: DWORD,
818 #[cfg(target_arch = "x86_64")]
821 _align_hack: [u64x2; 0], // FIXME align on 16-byte
822 pub P1Home: DWORDLONG,
823 pub P2Home: DWORDLONG,
824 pub P3Home: DWORDLONG,
825 pub P4Home: DWORDLONG,
826 pub P5Home: DWORDLONG,
827 pub P6Home: DWORDLONG,
829 pub ContextFlags: DWORD,
866 pub FltSave: FLOATING_SAVE_AREA,
868 pub VectorRegister: [M128A; 26],
869 pub VectorControl: DWORDLONG,
871 pub DebugControl: DWORDLONG,
872 pub LastBranchToRip: DWORDLONG,
873 pub LastBranchFromRip: DWORDLONG,
874 pub LastExceptionToRip: DWORDLONG,
875 pub LastExceptionFromRip: DWORDLONG,
878 #[cfg(target_arch = "x86_64")]
881 _align_hack: [u64x2; 0], // FIXME align on 16-byte
882 pub Low: c_ulonglong,
886 #[cfg(target_arch = "x86_64")]
888 pub struct FLOATING_SAVE_AREA {
889 _align_hack: [u64x2; 0], // FIXME align on 16-byte
890 _Dummy: [u8; 512] // FIXME: Fill this out
894 pub struct SOCKADDR_STORAGE_LH {
895 pub ss_family: ADDRESS_FAMILY,
896 pub __ss_pad1: [CHAR; 6],
898 pub __ss_pad2: [CHAR; 112],
902 pub struct ADDRINFOA {
904 pub ai_family: c_int,
905 pub ai_socktype: c_int,
906 pub ai_protocol: c_int,
907 pub ai_addrlen: size_t,
908 pub ai_canonname: *mut c_char,
909 pub ai_addr: *mut SOCKADDR,
910 pub ai_next: *mut ADDRINFOA,
914 #[derive(Copy, Clone)]
915 pub struct sockaddr_in {
916 pub sin_family: ADDRESS_FAMILY,
917 pub sin_port: USHORT,
918 pub sin_addr: in_addr,
919 pub sin_zero: [CHAR; 8],
923 #[derive(Copy, Clone)]
924 pub struct sockaddr_in6 {
925 pub sin6_family: ADDRESS_FAMILY,
926 pub sin6_port: USHORT,
927 pub sin6_flowinfo: c_ulong,
928 pub sin6_addr: in6_addr,
929 pub sin6_scope_id: c_ulong,
933 #[derive(Copy, Clone)]
939 #[derive(Copy, Clone)]
940 pub struct in6_addr {
941 pub s6_addr: [u8; 16],
944 pub enum UNWIND_HISTORY_TABLE {}
947 pub struct RUNTIME_FUNCTION {
948 pub BeginAddress: DWORD,
949 pub EndAddress: DWORD,
950 pub UnwindData: DWORD,
954 pub struct DISPATCHER_CONTEXT {
955 pub ControlPc: LPVOID,
956 pub ImageBase: LPVOID,
957 pub FunctionEntry: *const RUNTIME_FUNCTION,
958 pub EstablisherFrame: LPVOID,
959 pub TargetIp: LPVOID,
960 pub ContextRecord: *const CONTEXT,
961 pub LanguageHandler: LPVOID,
962 pub HandlerData: *const u8,
963 pub HistoryTable: *const UNWIND_HISTORY_TABLE,
967 #[derive(Copy, Clone)]
968 pub enum EXCEPTION_DISPOSITION {
969 ExceptionContinueExecution,
970 ExceptionContinueSearch,
971 ExceptionNestedException,
972 ExceptionCollidedUnwind
975 #[link(name = "ws2_32")]
976 #[link(name = "userenv")]
977 #[link(name = "shell32")]
978 #[link(name = "advapi32")]
979 #[cfg(not(cargobuild))]
983 pub fn WSAStartup(wVersionRequested: WORD,
984 lpWSAData: LPWSADATA) -> c_int;
985 pub fn WSACleanup() -> c_int;
986 pub fn WSAGetLastError() -> c_int;
987 pub fn WSADuplicateSocketW(s: SOCKET,
989 lpProtocolInfo: LPWSAPROTOCOL_INFO)
991 pub fn GetCurrentProcessId() -> DWORD;
992 pub fn WSASocketW(af: c_int,
995 lpProtocolInfo: LPWSAPROTOCOL_INFO,
997 dwFlags: DWORD) -> SOCKET;
998 pub fn InitializeCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
999 pub fn EnterCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
1000 pub fn TryEnterCriticalSection(CriticalSection: *mut CRITICAL_SECTION) -> BOOLEAN;
1001 pub fn LeaveCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
1002 pub fn DeleteCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
1004 // FIXME - pInputControl should be PCONSOLE_READCONSOLE_CONTROL
1005 pub fn ReadConsoleW(hConsoleInput: HANDLE,
1007 nNumberOfCharsToRead: DWORD,
1008 lpNumberOfCharsRead: LPDWORD,
1009 pInputControl: LPVOID) -> BOOL;
1011 pub fn WriteConsoleW(hConsoleOutput: HANDLE,
1013 nNumberOfCharsToWrite: DWORD,
1014 lpNumberOfCharsWritten: LPDWORD,
1015 lpReserved: LPVOID) -> BOOL;
1017 pub fn GetConsoleMode(hConsoleHandle: HANDLE,
1018 lpMode: LPDWORD) -> BOOL;
1019 pub fn GetFileAttributesExW(lpFileName: LPCWSTR,
1020 fInfoLevelId: GET_FILEEX_INFO_LEVELS,
1021 lpFileInformation: LPVOID) -> BOOL;
1022 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
1023 pub fn SetFileAttributesW(lpFileName: LPCWSTR,
1024 dwFileAttributes: DWORD) -> BOOL;
1025 pub fn GetFileInformationByHandle(hFile: HANDLE,
1026 lpFileInformation: LPBY_HANDLE_FILE_INFORMATION)
1029 pub fn SetLastError(dwErrCode: DWORD);
1030 pub fn GetCommandLineW() -> *mut LPCWSTR;
1031 pub fn LocalFree(ptr: *mut c_void);
1032 pub fn CommandLineToArgvW(lpCmdLine: *mut LPCWSTR,
1033 pNumArgs: *mut c_int) -> *mut *mut u16;
1034 pub fn GetTempPathW(nBufferLength: DWORD,
1035 lpBuffer: LPCWSTR) -> DWORD;
1036 pub fn OpenProcessToken(ProcessHandle: HANDLE,
1037 DesiredAccess: DWORD,
1038 TokenHandle: *mut HANDLE) -> BOOL;
1039 pub fn GetCurrentProcess() -> HANDLE;
1040 pub fn GetCurrentThread() -> HANDLE;
1041 pub fn GetStdHandle(which: DWORD) -> HANDLE;
1042 pub fn ExitProcess(uExitCode: c_uint) -> !;
1043 pub fn DeviceIoControl(hDevice: HANDLE,
1044 dwIoControlCode: DWORD,
1046 nInBufferSize: DWORD,
1047 lpOutBuffer: LPVOID,
1048 nOutBufferSize: DWORD,
1049 lpBytesReturned: LPDWORD,
1050 lpOverlapped: LPOVERLAPPED) -> BOOL;
1051 pub fn CreatePipe(hReadPipe: LPHANDLE,
1052 hWritePipe: LPHANDLE,
1053 lpPipeAttributes: LPSECURITY_ATTRIBUTES,
1054 nSize: DWORD) -> BOOL;
1055 pub fn CreateThread(lpThreadAttributes: LPSECURITY_ATTRIBUTES,
1056 dwStackSize: SIZE_T,
1057 lpStartAddress: extern "system" fn(*mut c_void)
1059 lpParameter: LPVOID,
1060 dwCreationFlags: DWORD,
1061 lpThreadId: LPDWORD) -> HANDLE;
1062 pub fn WaitForSingleObject(hHandle: HANDLE,
1063 dwMilliseconds: DWORD) -> DWORD;
1064 pub fn SwitchToThread() -> BOOL;
1065 pub fn Sleep(dwMilliseconds: DWORD);
1066 pub fn GetProcessId(handle: HANDLE) -> DWORD;
1067 pub fn GetUserProfileDirectoryW(hToken: HANDLE,
1068 lpProfileDir: LPCWSTR,
1069 lpcchSize: *mut DWORD) -> BOOL;
1070 pub fn SetHandleInformation(hObject: HANDLE,
1072 dwFlags: DWORD) -> BOOL;
1073 pub fn CopyFileExW(lpExistingFileName: LPCWSTR,
1074 lpNewFileName: LPCWSTR,
1075 lpProgressRoutine: LPPROGRESS_ROUTINE,
1078 dwCopyFlags: DWORD) -> BOOL;
1079 pub fn LookupPrivilegeValueW(lpSystemName: LPCWSTR,
1081 lpLuid: PLUID) -> BOOL;
1082 pub fn AdjustTokenPrivileges(TokenHandle: HANDLE,
1083 DisableAllPrivileges: BOOL,
1084 NewState: PTOKEN_PRIVILEGES,
1085 BufferLength: DWORD,
1086 PreviousState: PTOKEN_PRIVILEGES,
1087 ReturnLength: *mut DWORD) -> BOOL;
1088 pub fn AddVectoredExceptionHandler(FirstHandler: ULONG,
1089 VectoredHandler: PVECTORED_EXCEPTION_HANDLER)
1091 pub fn FormatMessageW(flags: DWORD,
1097 args: *const c_void)
1099 pub fn TlsAlloc() -> DWORD;
1100 pub fn TlsFree(dwTlsIndex: DWORD) -> BOOL;
1101 pub fn TlsGetValue(dwTlsIndex: DWORD) -> LPVOID;
1102 pub fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;
1103 pub fn GetLastError() -> DWORD;
1104 pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL;
1105 pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER)
1107 pub fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL;
1108 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL;
1109 pub fn CreateProcessW(lpApplicationName: LPCWSTR,
1110 lpCommandLine: LPWSTR,
1111 lpProcessAttributes: LPSECURITY_ATTRIBUTES,
1112 lpThreadAttributes: LPSECURITY_ATTRIBUTES,
1113 bInheritHandles: BOOL,
1114 dwCreationFlags: DWORD,
1115 lpEnvironment: LPVOID,
1116 lpCurrentDirectory: LPCWSTR,
1117 lpStartupInfo: LPSTARTUPINFO,
1118 lpProcessInformation: LPPROCESS_INFORMATION)
1120 pub fn GetEnvironmentVariableW(n: LPCWSTR, v: LPWSTR, nsize: DWORD) -> DWORD;
1121 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) -> BOOL;
1122 pub fn GetEnvironmentStringsW() -> LPWCH;
1123 pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
1124 pub fn GetModuleFileNameW(hModule: HMODULE,
1128 pub fn CreateDirectoryW(lpPathName: LPCWSTR,
1129 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
1131 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
1132 pub fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD;
1133 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
1135 pub fn closesocket(socket: SOCKET) -> c_int;
1136 pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int,
1137 flags: c_int) -> c_int;
1138 pub fn send(socket: SOCKET, buf: *const c_void, len: c_int,
1139 flags: c_int) -> c_int;
1140 pub fn recvfrom(socket: SOCKET,
1144 addr: *mut SOCKADDR,
1145 addrlen: *mut c_int)
1147 pub fn sendto(socket: SOCKET,
1151 addr: *const SOCKADDR,
1154 pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
1155 pub fn accept(socket: SOCKET,
1156 address: *mut SOCKADDR,
1157 address_len: *mut c_int)
1159 pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
1160 hSourceHandle: HANDLE,
1161 hTargetProcessHandle: HANDLE,
1162 lpTargetHandle: LPHANDLE,
1163 dwDesiredAccess: DWORD,
1164 bInheritHandle: BOOL,
1167 pub fn ReadFile(hFile: HANDLE,
1169 nNumberOfBytesToRead: DWORD,
1170 lpNumberOfBytesRead: LPDWORD,
1171 lpOverlapped: LPOVERLAPPED)
1173 pub fn WriteFile(hFile: HANDLE,
1175 nNumberOfBytesToWrite: DWORD,
1176 lpNumberOfBytesWritten: LPDWORD,
1177 lpOverlapped: LPOVERLAPPED)
1179 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
1180 pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
1181 lpTargetFileName: LPCWSTR,
1182 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
1184 pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
1185 lpNewFileName: LPCWSTR,
1188 pub fn SetFilePointerEx(hFile: HANDLE,
1189 liDistanceToMove: LARGE_INTEGER,
1190 lpNewFilePointer: PLARGE_INTEGER,
1191 dwMoveMethod: DWORD)
1193 pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
1194 pub fn CreateFileW(lpFileName: LPCWSTR,
1195 dwDesiredAccess: DWORD,
1197 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
1198 dwCreationDisposition: DWORD,
1199 dwFlagsAndAttributes: DWORD,
1200 hTemplateFile: HANDLE)
1203 pub fn FindFirstFileW(fileName: LPCWSTR,
1204 findFileData: LPWIN32_FIND_DATAW)
1206 pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
1208 pub fn FindClose(findFile: HANDLE) -> BOOL;
1209 pub fn RtlCaptureContext(ctx: *mut CONTEXT);
1210 pub fn getsockopt(s: SOCKET,
1213 optval: *mut c_char,
1216 pub fn setsockopt(s: SOCKET,
1219 optval: *const c_void,
1222 pub fn getsockname(socket: SOCKET,
1223 address: *mut SOCKADDR,
1224 address_len: *mut c_int)
1226 pub fn getpeername(socket: SOCKET,
1227 address: *mut SOCKADDR,
1228 address_len: *mut c_int)
1230 pub fn bind(socket: SOCKET, address: *const SOCKADDR,
1231 address_len: socklen_t) -> c_int;
1232 pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
1233 pub fn connect(socket: SOCKET, address: *const SOCKADDR, len: c_int)
1235 pub fn getaddrinfo(node: *const c_char, service: *const c_char,
1236 hints: *const ADDRINFOA,
1237 res: *mut *mut ADDRINFOA) -> c_int;
1238 pub fn freeaddrinfo(res: *mut ADDRINFOA);
1239 pub fn getnameinfo(sa: *const SOCKADDR, salen: c_int,
1240 host: *mut c_char, hostlen: DWORD,
1241 serv: *mut c_char, servlen: DWORD,
1242 flags: c_int) -> c_int;
1244 pub fn LoadLibraryW(name: LPCWSTR) -> HMODULE;
1245 pub fn GetModuleHandleExW(dwFlags: DWORD, name: LPCWSTR,
1246 handle: *mut HMODULE) -> BOOL;
1247 pub fn GetProcAddress(handle: HMODULE,
1248 name: LPCSTR) -> *mut c_void;
1249 pub fn FreeLibrary(handle: HMODULE) -> BOOL;
1250 pub fn SetErrorMode(uMode: c_uint) -> c_uint;
1251 pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
1252 pub fn CryptAcquireContextA(phProv: *mut HCRYPTPROV,
1253 pszContainer: LPCSTR,
1254 pszProvider: LPCSTR,
1256 dwFlags: DWORD) -> BOOL;
1257 pub fn CryptGenRandom(hProv: HCRYPTPROV,
1259 pbBuffer: *mut BYTE) -> BOOL;
1260 pub fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL;
1263 pub fn RaiseException(dwExceptionCode: DWORD,
1264 dwExceptionFlags: DWORD,
1265 nNumberOfArguments: DWORD,
1266 lpArguments: *const ULONG_PTR);
1267 pub fn RtlUnwindEx(TargetFrame: LPVOID,
1269 ExceptionRecord: *const EXCEPTION_RECORD,
1270 ReturnValue: LPVOID,
1271 OriginalContext: *const CONTEXT,
1272 HistoryTable: *const UNWIND_HISTORY_TABLE);
1273 pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME);
1276 // Functions that aren't available on Windows XP, but we still use them and just
1277 // provide some form of a fallback implementation.
1281 pub fn CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR,
1282 _lpTargetFileName: LPCWSTR,
1283 _dwFlags: DWORD) -> BOOLEAN {
1284 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1286 pub fn GetFinalPathNameByHandleW(_hFile: HANDLE,
1287 _lpszFilePath: LPCWSTR,
1288 _cchFilePath: DWORD,
1289 _dwFlags: DWORD) -> DWORD {
1290 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1292 pub fn SetThreadErrorMode(_dwNewMode: DWORD,
1293 _lpOldMode: *mut DWORD) -> c_uint {
1294 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1296 pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL {
1297 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1299 pub fn SetFileInformationByHandle(_hFile: HANDLE,
1300 _FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
1301 _lpFileInformation: LPVOID,
1302 _dwBufferSize: DWORD) -> BOOL {
1303 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1305 pub fn SleepConditionVariableSRW(ConditionVariable: PCONDITION_VARIABLE,
1307 dwMilliseconds: DWORD,
1308 Flags: ULONG) -> BOOL {
1309 panic!("condition variables not available")
1311 pub fn WakeConditionVariable(ConditionVariable: PCONDITION_VARIABLE)
1313 panic!("condition variables not available")
1315 pub fn WakeAllConditionVariable(ConditionVariable: PCONDITION_VARIABLE)
1317 panic!("condition variables not available")
1319 pub fn AcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> () {
1320 panic!("rwlocks not available")
1322 pub fn AcquireSRWLockShared(SRWLock: PSRWLOCK) -> () {
1323 panic!("rwlocks not available")
1325 pub fn ReleaseSRWLockExclusive(SRWLock: PSRWLOCK) -> () {
1326 panic!("rwlocks not available")
1328 pub fn ReleaseSRWLockShared(SRWLock: PSRWLOCK) -> () {
1329 panic!("rwlocks not available")
1331 pub fn TryAcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> BOOLEAN {
1332 panic!("rwlocks not available")
1334 pub fn TryAcquireSRWLockShared(SRWLock: PSRWLOCK) -> BOOLEAN {
1335 panic!("rwlocks not available")