]> git.proxmox.com Git - rustc.git/blob - src/libstd/sys/windows/c.rs
New upstream version 1.21.0+dfsg1
[rustc.git] / src / libstd / sys / windows / c.rs
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.
4 //
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.
10
11 //! C definitions used by libnative that don't belong in liblibc
12
13 #![allow(bad_style)]
14 #![cfg_attr(test, allow(dead_code))]
15 #![unstable(issue = "0", feature = "windows_c")]
16
17 use os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort, c_char};
18 #[cfg(target_arch = "x86_64")]
19 use os::raw::c_ulonglong;
20 use libc::{wchar_t, size_t, c_void};
21 use ptr;
22
23 #[repr(simd)]
24 #[repr(C)]
25 #[cfg(target_arch = "x86_64")]
26 struct u64x2(u64, u64);
27
28 pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
29 pub use self::EXCEPTION_DISPOSITION::*;
30
31 pub type DWORD = c_ulong;
32 pub type HANDLE = LPVOID;
33 pub type HINSTANCE = HANDLE;
34 pub type HMODULE = HINSTANCE;
35 pub type BOOL = c_int;
36 pub type BYTE = u8;
37 pub type BOOLEAN = BYTE;
38 pub type GROUP = c_uint;
39 pub type LONG_PTR = isize;
40 pub type LARGE_INTEGER = c_longlong;
41 pub type LONG = c_long;
42 pub type UINT = c_uint;
43 pub type WCHAR = u16;
44 pub type USHORT = c_ushort;
45 pub type SIZE_T = usize;
46 pub type WORD = u16;
47 pub type CHAR = c_char;
48 pub type HCRYPTPROV = LONG_PTR;
49 pub type ULONG_PTR = usize;
50 pub type ULONG = c_ulong;
51 #[cfg(target_arch = "x86_64")]
52 pub type ULONGLONG = u64;
53 #[cfg(target_arch = "x86_64")]
54 pub type DWORDLONG = ULONGLONG;
55
56 pub type LPBOOL = *mut BOOL;
57 pub type LPBYTE = *mut BYTE;
58 pub type LPBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION;
59 pub type LPCSTR = *const CHAR;
60 pub type LPCVOID = *const c_void;
61 pub type LPCWSTR = *const WCHAR;
62 pub type LPDWORD = *mut DWORD;
63 pub type LPHANDLE = *mut HANDLE;
64 pub type LPOVERLAPPED = *mut OVERLAPPED;
65 pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
66 pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
67 pub type LPSTARTUPINFO = *mut STARTUPINFO;
68 pub type LPVOID = *mut c_void;
69 pub type LPWCH = *mut WCHAR;
70 pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
71 pub type LPWSADATA = *mut WSADATA;
72 pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
73 pub type LPSTR = *mut CHAR;
74 pub type LPWSTR = *mut WCHAR;
75 pub type LPFILETIME = *mut FILETIME;
76
77 pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE;
78 pub type PLARGE_INTEGER = *mut c_longlong;
79 pub type PSRWLOCK = *mut SRWLOCK;
80
81 pub type SOCKET = ::os::windows::raw::SOCKET;
82 pub type socklen_t = c_int;
83 pub type ADDRESS_FAMILY = USHORT;
84
85 pub const TRUE: BOOL = 1;
86 pub const FALSE: BOOL = 0;
87
88 pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1;
89 pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10;
90 pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400;
91
92 pub const FILE_SHARE_DELETE: DWORD = 0x4;
93 pub const FILE_SHARE_READ: DWORD = 0x1;
94 pub const FILE_SHARE_WRITE: DWORD = 0x2;
95
96 pub const CREATE_ALWAYS: DWORD = 2;
97 pub const CREATE_NEW: DWORD = 1;
98 pub const OPEN_ALWAYS: DWORD = 4;
99 pub const OPEN_EXISTING: DWORD = 3;
100 pub const TRUNCATE_EXISTING: DWORD = 5;
101
102 pub const FILE_WRITE_DATA: DWORD = 0x00000002;
103 pub const FILE_APPEND_DATA: DWORD = 0x00000004;
104 pub const FILE_WRITE_EA: DWORD = 0x00000010;
105 pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100;
106 pub const READ_CONTROL: DWORD = 0x00020000;
107 pub const SYNCHRONIZE: DWORD = 0x00100000;
108 pub const GENERIC_READ: DWORD = 0x80000000;
109 pub const GENERIC_WRITE: DWORD = 0x40000000;
110 pub const STANDARD_RIGHTS_WRITE: DWORD = READ_CONTROL;
111 pub const FILE_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |
112 FILE_WRITE_ATTRIBUTES |
113 FILE_WRITE_EA |
114 FILE_APPEND_DATA |
115 SYNCHRONIZE;
116
117 pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
118 pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
119 pub const SECURITY_SQOS_PRESENT: DWORD = 0x00100000;
120
121 pub const FIONBIO: c_ulong = 0x8004667e;
122
123 #[repr(C)]
124 #[derive(Copy)]
125 pub struct WIN32_FIND_DATAW {
126 pub dwFileAttributes: DWORD,
127 pub ftCreationTime: FILETIME,
128 pub ftLastAccessTime: FILETIME,
129 pub ftLastWriteTime: FILETIME,
130 pub nFileSizeHigh: DWORD,
131 pub nFileSizeLow: DWORD,
132 pub dwReserved0: DWORD,
133 pub dwReserved1: DWORD,
134 pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
135 pub cAlternateFileName: [wchar_t; 14],
136 }
137 impl Clone for WIN32_FIND_DATAW {
138 fn clone(&self) -> Self { *self }
139 }
140
141 pub const WSA_FLAG_OVERLAPPED: DWORD = 0x01;
142
143 pub const WSADESCRIPTION_LEN: usize = 256;
144 pub const WSASYS_STATUS_LEN: usize = 128;
145 pub const WSAPROTOCOL_LEN: DWORD = 255;
146 pub const INVALID_SOCKET: SOCKET = !0;
147
148 pub const WSAEACCES: c_int = 10013;
149 pub const WSAEINVAL: c_int = 10022;
150 pub const WSAEWOULDBLOCK: c_int = 10035;
151 pub const WSAEADDRINUSE: c_int = 10048;
152 pub const WSAEADDRNOTAVAIL: c_int = 10049;
153 pub const WSAECONNABORTED: c_int = 10053;
154 pub const WSAECONNRESET: c_int = 10054;
155 pub const WSAENOTCONN: c_int = 10057;
156 pub const WSAESHUTDOWN: c_int = 10058;
157 pub const WSAETIMEDOUT: c_int = 10060;
158 pub const WSAECONNREFUSED: c_int = 10061;
159
160 pub const MAX_PROTOCOL_CHAIN: DWORD = 7;
161
162 pub const TOKEN_READ: DWORD = 0x20008;
163 pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: usize = 16 * 1024;
164 pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
165 pub const IO_REPARSE_TAG_SYMLINK: DWORD = 0xa000000c;
166 pub const IO_REPARSE_TAG_MOUNT_POINT: DWORD = 0xa0000003;
167 pub const SYMLINK_FLAG_RELATIVE: DWORD = 0x00000001;
168 pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
169
170 pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 0x1;
171 pub const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE: DWORD = 0x2;
172
173 // Note that these are not actually HANDLEs, just values to pass to GetStdHandle
174 pub const STD_INPUT_HANDLE: DWORD = -10i32 as DWORD;
175 pub const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
176 pub const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD;
177
178 pub const HANDLE_FLAG_INHERIT: DWORD = 0x00000001;
179
180 pub const PROGRESS_CONTINUE: DWORD = 0;
181
182 pub const ERROR_FILE_NOT_FOUND: DWORD = 2;
183 pub const ERROR_PATH_NOT_FOUND: DWORD = 3;
184 pub const ERROR_ACCESS_DENIED: DWORD = 5;
185 pub const ERROR_INVALID_HANDLE: DWORD = 6;
186 pub const ERROR_NO_MORE_FILES: DWORD = 18;
187 pub const ERROR_HANDLE_EOF: DWORD = 38;
188 pub const ERROR_FILE_EXISTS: DWORD = 80;
189 pub const ERROR_INVALID_PARAMETER: DWORD = 87;
190 pub const ERROR_BROKEN_PIPE: DWORD = 109;
191 pub const ERROR_CALL_NOT_IMPLEMENTED: DWORD = 120;
192 pub const ERROR_INSUFFICIENT_BUFFER: DWORD = 122;
193 pub const ERROR_ALREADY_EXISTS: DWORD = 183;
194 pub const ERROR_NO_DATA: DWORD = 232;
195 pub const ERROR_ENVVAR_NOT_FOUND: DWORD = 203;
196 pub const ERROR_OPERATION_ABORTED: DWORD = 995;
197 pub const ERROR_IO_PENDING: DWORD = 997;
198 pub const ERROR_TIMEOUT: DWORD = 0x5B4;
199
200 pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
201
202 pub const FACILITY_NT_BIT: DWORD = 0x1000_0000;
203
204 pub const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000;
205 pub const FORMAT_MESSAGE_FROM_HMODULE: DWORD = 0x00000800;
206 pub const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200;
207
208 pub const TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF;
209
210 pub const DLL_THREAD_DETACH: DWORD = 3;
211 pub const DLL_PROCESS_DETACH: DWORD = 0;
212
213 pub const INFINITE: DWORD = !0;
214
215 pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002;
216
217 pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE {
218 ptr: ptr::null_mut(),
219 };
220 pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { ptr: ptr::null_mut() };
221
222 pub const DETACHED_PROCESS: DWORD = 0x00000008;
223 pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200;
224 pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400;
225 pub const STARTF_USESTDHANDLES: DWORD = 0x00000100;
226
227 pub const AF_INET: c_int = 2;
228 pub const AF_INET6: c_int = 23;
229 pub const SD_BOTH: c_int = 2;
230 pub const SD_RECEIVE: c_int = 0;
231 pub const SD_SEND: c_int = 1;
232 pub const SOCK_DGRAM: c_int = 2;
233 pub const SOCK_STREAM: c_int = 1;
234 pub const SOL_SOCKET: c_int = 0xffff;
235 pub const SO_RCVTIMEO: c_int = 0x1006;
236 pub const SO_SNDTIMEO: c_int = 0x1005;
237 pub const SO_REUSEADDR: c_int = 0x0004;
238 pub const IPPROTO_IP: c_int = 0;
239 pub const IPPROTO_TCP: c_int = 6;
240 pub const IPPROTO_IPV6: c_int = 41;
241 pub const TCP_NODELAY: c_int = 0x0001;
242 pub const IP_TTL: c_int = 4;
243 pub const IPV6_V6ONLY: c_int = 27;
244 pub const SO_ERROR: c_int = 0x1007;
245 pub const SO_BROADCAST: c_int = 0x0020;
246 pub const IP_MULTICAST_LOOP: c_int = 11;
247 pub const IPV6_MULTICAST_LOOP: c_int = 11;
248 pub const IP_MULTICAST_TTL: c_int = 10;
249 pub const IP_ADD_MEMBERSHIP: c_int = 12;
250 pub const IP_DROP_MEMBERSHIP: c_int = 13;
251 pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
252 pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
253 pub const MSG_PEEK: c_int = 0x2;
254
255 #[repr(C)]
256 pub struct ip_mreq {
257 pub imr_multiaddr: in_addr,
258 pub imr_interface: in_addr,
259 }
260
261 #[repr(C)]
262 pub struct ipv6_mreq {
263 pub ipv6mr_multiaddr: in6_addr,
264 pub ipv6mr_interface: c_uint,
265 }
266
267 pub const VOLUME_NAME_DOS: DWORD = 0x0;
268 pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1;
269
270 pub const FILE_BEGIN: DWORD = 0;
271 pub const FILE_CURRENT: DWORD = 1;
272 pub const FILE_END: DWORD = 2;
273
274 pub const WAIT_OBJECT_0: DWORD = 0x00000000;
275 pub const WAIT_TIMEOUT: DWORD = 258;
276 pub const WAIT_FAILED: DWORD = 0xFFFFFFFF;
277
278 #[cfg(target_env = "msvc")]
279 pub const MAX_SYM_NAME: usize = 2000;
280 #[cfg(target_arch = "x86")]
281 pub const IMAGE_FILE_MACHINE_I386: DWORD = 0x014c;
282 #[cfg(target_arch = "x86_64")]
283 pub const IMAGE_FILE_MACHINE_AMD64: DWORD = 0x8664;
284
285 pub const PROV_RSA_FULL: DWORD = 1;
286 pub const CRYPT_SILENT: DWORD = 64;
287 pub const CRYPT_VERIFYCONTEXT: DWORD = 0xF0000000;
288
289 pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
290 pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
291 pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
292
293 pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
294 pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
295 pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
296 pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000;
297 pub const PIPE_WAIT: DWORD = 0x00000000;
298 pub const PIPE_TYPE_BYTE: DWORD = 0x00000000;
299 pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008;
300 pub const PIPE_READMODE_BYTE: DWORD = 0x00000000;
301
302 pub const FD_SETSIZE: usize = 64;
303
304 #[repr(C)]
305 #[cfg(not(target_pointer_width = "64"))]
306 pub struct WSADATA {
307 pub wVersion: WORD,
308 pub wHighVersion: WORD,
309 pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
310 pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
311 pub iMaxSockets: u16,
312 pub iMaxUdpDg: u16,
313 pub lpVendorInfo: *mut u8,
314 }
315 #[repr(C)]
316 #[cfg(target_pointer_width = "64")]
317 pub struct WSADATA {
318 pub wVersion: WORD,
319 pub wHighVersion: WORD,
320 pub iMaxSockets: u16,
321 pub iMaxUdpDg: u16,
322 pub lpVendorInfo: *mut u8,
323 pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
324 pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
325 }
326
327 #[repr(C)]
328 pub struct WSAPROTOCOL_INFO {
329 pub dwServiceFlags1: DWORD,
330 pub dwServiceFlags2: DWORD,
331 pub dwServiceFlags3: DWORD,
332 pub dwServiceFlags4: DWORD,
333 pub dwProviderFlags: DWORD,
334 pub ProviderId: GUID,
335 pub dwCatalogEntryId: DWORD,
336 pub ProtocolChain: WSAPROTOCOLCHAIN,
337 pub iVersion: c_int,
338 pub iAddressFamily: c_int,
339 pub iMaxSockAddr: c_int,
340 pub iMinSockAddr: c_int,
341 pub iSocketType: c_int,
342 pub iProtocol: c_int,
343 pub iProtocolMaxOffset: c_int,
344 pub iNetworkByteOrder: c_int,
345 pub iSecurityScheme: c_int,
346 pub dwMessageSize: DWORD,
347 pub dwProviderReserved: DWORD,
348 pub szProtocol: [u16; (WSAPROTOCOL_LEN as usize) + 1],
349 }
350
351 #[repr(C)]
352 #[derive(Copy, Clone)]
353 pub struct WIN32_FILE_ATTRIBUTE_DATA {
354 pub dwFileAttributes: DWORD,
355 pub ftCreationTime: FILETIME,
356 pub ftLastAccessTime: FILETIME,
357 pub ftLastWriteTime: FILETIME,
358 pub nFileSizeHigh: DWORD,
359 pub nFileSizeLow: DWORD,
360 }
361
362 #[repr(C)]
363 pub struct BY_HANDLE_FILE_INFORMATION {
364 pub dwFileAttributes: DWORD,
365 pub ftCreationTime: FILETIME,
366 pub ftLastAccessTime: FILETIME,
367 pub ftLastWriteTime: FILETIME,
368 pub dwVolumeSerialNumber: DWORD,
369 pub nFileSizeHigh: DWORD,
370 pub nFileSizeLow: DWORD,
371 pub nNumberOfLinks: DWORD,
372 pub nFileIndexHigh: DWORD,
373 pub nFileIndexLow: DWORD,
374 }
375
376 #[repr(C)]
377 #[allow(dead_code)] // we only use some variants
378 pub enum FILE_INFO_BY_HANDLE_CLASS {
379 FileBasicInfo = 0,
380 FileStandardInfo = 1,
381 FileNameInfo = 2,
382 FileRenameInfo = 3,
383 FileDispositionInfo = 4,
384 FileAllocationInfo = 5,
385 FileEndOfFileInfo = 6,
386 FileStreamInfo = 7,
387 FileCompressionInfo = 8,
388 FileAttributeTagInfo = 9,
389 FileIdBothDirectoryInfo = 10, // 0xA
390 FileIdBothDirectoryRestartInfo = 11, // 0xB
391 FileIoPriorityHintInfo = 12, // 0xC
392 FileRemoteProtocolInfo = 13, // 0xD
393 FileFullDirectoryInfo = 14, // 0xE
394 FileFullDirectoryRestartInfo = 15, // 0xF
395 FileStorageInfo = 16, // 0x10
396 FileAlignmentInfo = 17, // 0x11
397 FileIdInfo = 18, // 0x12
398 FileIdExtdDirectoryInfo = 19, // 0x13
399 FileIdExtdDirectoryRestartInfo = 20, // 0x14
400 MaximumFileInfoByHandlesClass
401 }
402
403 #[repr(C)]
404 pub struct FILE_BASIC_INFO {
405 pub CreationTime: LARGE_INTEGER,
406 pub LastAccessTime: LARGE_INTEGER,
407 pub LastWriteTime: LARGE_INTEGER,
408 pub ChangeTime: LARGE_INTEGER,
409 pub FileAttributes: DWORD,
410 }
411
412 #[repr(C)]
413 pub struct FILE_END_OF_FILE_INFO {
414 pub EndOfFile: LARGE_INTEGER,
415 }
416
417 #[repr(C)]
418 pub struct REPARSE_DATA_BUFFER {
419 pub ReparseTag: c_uint,
420 pub ReparseDataLength: c_ushort,
421 pub Reserved: c_ushort,
422 pub rest: (),
423 }
424
425 #[repr(C)]
426 pub struct SYMBOLIC_LINK_REPARSE_BUFFER {
427 pub SubstituteNameOffset: c_ushort,
428 pub SubstituteNameLength: c_ushort,
429 pub PrintNameOffset: c_ushort,
430 pub PrintNameLength: c_ushort,
431 pub Flags: c_ulong,
432 pub PathBuffer: WCHAR,
433 }
434
435 #[repr(C)]
436 pub struct MOUNT_POINT_REPARSE_BUFFER {
437 pub SubstituteNameOffset: c_ushort,
438 pub SubstituteNameLength: c_ushort,
439 pub PrintNameOffset: c_ushort,
440 pub PrintNameLength: c_ushort,
441 pub PathBuffer: WCHAR,
442 }
443
444 pub type LPPROGRESS_ROUTINE = ::option::Option<unsafe extern "system" fn(
445 TotalFileSize: LARGE_INTEGER,
446 TotalBytesTransferred: LARGE_INTEGER,
447 StreamSize: LARGE_INTEGER,
448 StreamBytesTransferred: LARGE_INTEGER,
449 dwStreamNumber: DWORD,
450 dwCallbackReason: DWORD,
451 hSourceFile: HANDLE,
452 hDestinationFile: HANDLE,
453 lpData: LPVOID,
454 ) -> DWORD>;
455
456 #[repr(C)]
457 pub struct CONDITION_VARIABLE { pub ptr: LPVOID }
458 #[repr(C)]
459 pub struct SRWLOCK { pub ptr: LPVOID }
460 #[repr(C)]
461 pub struct CRITICAL_SECTION {
462 CriticalSectionDebug: LPVOID,
463 LockCount: LONG,
464 RecursionCount: LONG,
465 OwningThread: HANDLE,
466 LockSemaphore: HANDLE,
467 SpinCount: ULONG_PTR
468 }
469
470 #[repr(C)]
471 pub struct REPARSE_MOUNTPOINT_DATA_BUFFER {
472 pub ReparseTag: DWORD,
473 pub ReparseDataLength: DWORD,
474 pub Reserved: WORD,
475 pub ReparseTargetLength: WORD,
476 pub ReparseTargetMaximumLength: WORD,
477 pub Reserved1: WORD,
478 pub ReparseTarget: WCHAR,
479 }
480
481 #[repr(C)]
482 pub struct EXCEPTION_RECORD {
483 pub ExceptionCode: DWORD,
484 pub ExceptionFlags: DWORD,
485 pub ExceptionRecord: *mut EXCEPTION_RECORD,
486 pub ExceptionAddress: LPVOID,
487 pub NumberParameters: DWORD,
488 pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
489 }
490
491 #[repr(C)]
492 pub struct EXCEPTION_POINTERS {
493 pub ExceptionRecord: *mut EXCEPTION_RECORD,
494 pub ContextRecord: *mut CONTEXT,
495 }
496
497 pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
498 fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
499
500 #[repr(C)]
501 pub struct GUID {
502 pub Data1: DWORD,
503 pub Data2: WORD,
504 pub Data3: WORD,
505 pub Data4: [BYTE; 8],
506 }
507
508 #[repr(C)]
509 pub struct WSAPROTOCOLCHAIN {
510 pub ChainLen: c_int,
511 pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize],
512 }
513
514 #[repr(C)]
515 pub struct SECURITY_ATTRIBUTES {
516 pub nLength: DWORD,
517 pub lpSecurityDescriptor: LPVOID,
518 pub bInheritHandle: BOOL,
519 }
520
521 #[repr(C)]
522 pub struct PROCESS_INFORMATION {
523 pub hProcess: HANDLE,
524 pub hThread: HANDLE,
525 pub dwProcessId: DWORD,
526 pub dwThreadId: DWORD,
527 }
528
529 #[repr(C)]
530 pub struct STARTUPINFO {
531 pub cb: DWORD,
532 pub lpReserved: LPWSTR,
533 pub lpDesktop: LPWSTR,
534 pub lpTitle: LPWSTR,
535 pub dwX: DWORD,
536 pub dwY: DWORD,
537 pub dwXSize: DWORD,
538 pub dwYSize: DWORD,
539 pub dwXCountChars: DWORD,
540 pub dwYCountCharts: DWORD,
541 pub dwFillAttribute: DWORD,
542 pub dwFlags: DWORD,
543 pub wShowWindow: WORD,
544 pub cbReserved2: WORD,
545 pub lpReserved2: LPBYTE,
546 pub hStdInput: HANDLE,
547 pub hStdOutput: HANDLE,
548 pub hStdError: HANDLE,
549 }
550
551 #[repr(C)]
552 pub struct SOCKADDR {
553 pub sa_family: ADDRESS_FAMILY,
554 pub sa_data: [CHAR; 14],
555 }
556
557 #[repr(C)]
558 #[derive(Copy, Clone)]
559 pub struct FILETIME {
560 pub dwLowDateTime: DWORD,
561 pub dwHighDateTime: DWORD,
562 }
563
564 #[repr(C)]
565 pub struct OVERLAPPED {
566 pub Internal: *mut c_ulong,
567 pub InternalHigh: *mut c_ulong,
568 pub Offset: DWORD,
569 pub OffsetHigh: DWORD,
570 pub hEvent: HANDLE,
571 }
572
573 #[repr(C)]
574 #[cfg(target_env = "msvc")]
575 pub struct SYMBOL_INFO {
576 pub SizeOfStruct: c_ulong,
577 pub TypeIndex: c_ulong,
578 pub Reserved: [u64; 2],
579 pub Index: c_ulong,
580 pub Size: c_ulong,
581 pub ModBase: u64,
582 pub Flags: c_ulong,
583 pub Value: u64,
584 pub Address: u64,
585 pub Register: c_ulong,
586 pub Scope: c_ulong,
587 pub Tag: c_ulong,
588 pub NameLen: c_ulong,
589 pub MaxNameLen: c_ulong,
590 // note that windows has this as 1, but it basically just means that
591 // the name is inline at the end of the struct. For us, we just bump
592 // the struct size up to MAX_SYM_NAME.
593 pub Name: [c_char; MAX_SYM_NAME],
594 }
595
596 #[repr(C)]
597 #[cfg(target_env = "msvc")]
598 pub struct IMAGEHLP_LINE64 {
599 pub SizeOfStruct: u32,
600 pub Key: *const c_void,
601 pub LineNumber: u32,
602 pub Filename: *const c_char,
603 pub Address: u64,
604 }
605
606 #[repr(C)]
607 #[allow(dead_code)] // we only use some variants
608 pub enum ADDRESS_MODE {
609 AddrMode1616,
610 AddrMode1632,
611 AddrModeReal,
612 AddrModeFlat,
613 }
614
615 #[repr(C)]
616 pub struct ADDRESS64 {
617 pub Offset: u64,
618 pub Segment: u16,
619 pub Mode: ADDRESS_MODE,
620 }
621
622 #[repr(C)]
623 pub struct STACKFRAME64 {
624 pub AddrPC: ADDRESS64,
625 pub AddrReturn: ADDRESS64,
626 pub AddrFrame: ADDRESS64,
627 pub AddrStack: ADDRESS64,
628 pub AddrBStore: ADDRESS64,
629 pub FuncTableEntry: *mut c_void,
630 pub Params: [u64; 4],
631 pub Far: BOOL,
632 pub Virtual: BOOL,
633 pub Reserved: [u64; 3],
634 pub KdHelp: KDHELP64,
635 }
636
637 #[repr(C)]
638 pub struct KDHELP64 {
639 pub Thread: u64,
640 pub ThCallbackStack: DWORD,
641 pub ThCallbackBStore: DWORD,
642 pub NextCallback: DWORD,
643 pub FramePointer: DWORD,
644 pub KiCallUserMode: u64,
645 pub KeUserCallbackDispatcher: u64,
646 pub SystemRangeStart: u64,
647 pub KiUserExceptionDispatcher: u64,
648 pub StackBase: u64,
649 pub StackLimit: u64,
650 pub Reserved: [u64; 5],
651 }
652
653 #[cfg(target_arch = "x86")]
654 #[repr(C)]
655 pub struct CONTEXT {
656 pub ContextFlags: DWORD,
657 pub Dr0: DWORD,
658 pub Dr1: DWORD,
659 pub Dr2: DWORD,
660 pub Dr3: DWORD,
661 pub Dr6: DWORD,
662 pub Dr7: DWORD,
663 pub FloatSave: FLOATING_SAVE_AREA,
664 pub SegGs: DWORD,
665 pub SegFs: DWORD,
666 pub SegEs: DWORD,
667 pub SegDs: DWORD,
668 pub Edi: DWORD,
669 pub Esi: DWORD,
670 pub Ebx: DWORD,
671 pub Edx: DWORD,
672 pub Ecx: DWORD,
673 pub Eax: DWORD,
674 pub Ebp: DWORD,
675 pub Eip: DWORD,
676 pub SegCs: DWORD,
677 pub EFlags: DWORD,
678 pub Esp: DWORD,
679 pub SegSs: DWORD,
680 pub ExtendedRegisters: [u8; 512],
681 }
682
683 #[cfg(target_arch = "x86")]
684 #[repr(C)]
685 pub struct FLOATING_SAVE_AREA {
686 pub ControlWord: DWORD,
687 pub StatusWord: DWORD,
688 pub TagWord: DWORD,
689 pub ErrorOffset: DWORD,
690 pub ErrorSelector: DWORD,
691 pub DataOffset: DWORD,
692 pub DataSelector: DWORD,
693 pub RegisterArea: [u8; 80],
694 pub Cr0NpxState: DWORD,
695 }
696
697 #[cfg(target_arch = "x86_64")]
698 #[repr(C)]
699 pub struct CONTEXT {
700 _align_hack: [u64x2; 0], // FIXME align on 16-byte
701 pub P1Home: DWORDLONG,
702 pub P2Home: DWORDLONG,
703 pub P3Home: DWORDLONG,
704 pub P4Home: DWORDLONG,
705 pub P5Home: DWORDLONG,
706 pub P6Home: DWORDLONG,
707
708 pub ContextFlags: DWORD,
709 pub MxCsr: DWORD,
710
711 pub SegCs: WORD,
712 pub SegDs: WORD,
713 pub SegEs: WORD,
714 pub SegFs: WORD,
715 pub SegGs: WORD,
716 pub SegSs: WORD,
717 pub EFlags: DWORD,
718
719 pub Dr0: DWORDLONG,
720 pub Dr1: DWORDLONG,
721 pub Dr2: DWORDLONG,
722 pub Dr3: DWORDLONG,
723 pub Dr6: DWORDLONG,
724 pub Dr7: DWORDLONG,
725
726 pub Rax: DWORDLONG,
727 pub Rcx: DWORDLONG,
728 pub Rdx: DWORDLONG,
729 pub Rbx: DWORDLONG,
730 pub Rsp: DWORDLONG,
731 pub Rbp: DWORDLONG,
732 pub Rsi: DWORDLONG,
733 pub Rdi: DWORDLONG,
734 pub R8: DWORDLONG,
735 pub R9: DWORDLONG,
736 pub R10: DWORDLONG,
737 pub R11: DWORDLONG,
738 pub R12: DWORDLONG,
739 pub R13: DWORDLONG,
740 pub R14: DWORDLONG,
741 pub R15: DWORDLONG,
742
743 pub Rip: DWORDLONG,
744
745 pub FltSave: FLOATING_SAVE_AREA,
746
747 pub VectorRegister: [M128A; 26],
748 pub VectorControl: DWORDLONG,
749
750 pub DebugControl: DWORDLONG,
751 pub LastBranchToRip: DWORDLONG,
752 pub LastBranchFromRip: DWORDLONG,
753 pub LastExceptionToRip: DWORDLONG,
754 pub LastExceptionFromRip: DWORDLONG,
755 }
756
757 #[cfg(target_arch = "x86_64")]
758 #[repr(C)]
759 pub struct M128A {
760 _align_hack: [u64x2; 0], // FIXME align on 16-byte
761 pub Low: c_ulonglong,
762 pub High: c_longlong
763 }
764
765 #[cfg(target_arch = "x86_64")]
766 #[repr(C)]
767 pub struct FLOATING_SAVE_AREA {
768 _align_hack: [u64x2; 0], // FIXME align on 16-byte
769 _Dummy: [u8; 512] // FIXME: Fill this out
770 }
771
772 // FIXME(#43348): This structure is used for backtrace only, and a fake
773 // definition is provided here only to allow rustdoc to pass type-check. This
774 // will not appear in the final documentation. This should be also defined for
775 // other architectures supported by Windows such as ARM, and for historical
776 // interest, maybe MIPS and PowerPC as well.
777 #[cfg(all(dox, not(any(target_arch = "x86_64", target_arch = "x86"))))]
778 pub enum CONTEXT {}
779
780 #[repr(C)]
781 pub struct SOCKADDR_STORAGE_LH {
782 pub ss_family: ADDRESS_FAMILY,
783 pub __ss_pad1: [CHAR; 6],
784 pub __ss_align: i64,
785 pub __ss_pad2: [CHAR; 112],
786 }
787
788 #[repr(C)]
789 pub struct ADDRINFOA {
790 pub ai_flags: c_int,
791 pub ai_family: c_int,
792 pub ai_socktype: c_int,
793 pub ai_protocol: c_int,
794 pub ai_addrlen: size_t,
795 pub ai_canonname: *mut c_char,
796 pub ai_addr: *mut SOCKADDR,
797 pub ai_next: *mut ADDRINFOA,
798 }
799
800 #[repr(C)]
801 #[derive(Copy, Clone)]
802 pub struct sockaddr_in {
803 pub sin_family: ADDRESS_FAMILY,
804 pub sin_port: USHORT,
805 pub sin_addr: in_addr,
806 pub sin_zero: [CHAR; 8],
807 }
808
809 #[repr(C)]
810 #[derive(Copy, Clone)]
811 pub struct sockaddr_in6 {
812 pub sin6_family: ADDRESS_FAMILY,
813 pub sin6_port: USHORT,
814 pub sin6_flowinfo: c_ulong,
815 pub sin6_addr: in6_addr,
816 pub sin6_scope_id: c_ulong,
817 }
818
819 #[repr(C)]
820 #[derive(Copy, Clone)]
821 pub struct in_addr {
822 pub s_addr: u32,
823 }
824
825 #[repr(C)]
826 #[derive(Copy, Clone)]
827 pub struct in6_addr {
828 pub s6_addr: [u8; 16],
829 }
830
831 #[repr(C)]
832 #[derive(Copy, Clone)]
833 #[allow(dead_code)] // we only use some variants
834 pub enum EXCEPTION_DISPOSITION {
835 ExceptionContinueExecution,
836 ExceptionContinueSearch,
837 ExceptionNestedException,
838 ExceptionCollidedUnwind
839 }
840
841 #[repr(C)]
842 #[derive(Copy, Clone)]
843 pub struct CONSOLE_READCONSOLE_CONTROL {
844 pub nLength: ULONG,
845 pub nInitialChars: ULONG,
846 pub dwCtrlWakeupMask: ULONG,
847 pub dwControlKeyState: ULONG,
848 }
849 pub type PCONSOLE_READCONSOLE_CONTROL = *mut CONSOLE_READCONSOLE_CONTROL;
850
851 #[repr(C)]
852 #[derive(Copy)]
853 pub struct fd_set {
854 pub fd_count: c_uint,
855 pub fd_array: [SOCKET; FD_SETSIZE],
856 }
857
858 impl Clone for fd_set {
859 fn clone(&self) -> fd_set {
860 *self
861 }
862 }
863
864 #[repr(C)]
865 #[derive(Copy, Clone)]
866 pub struct timeval {
867 pub tv_sec: c_long,
868 pub tv_usec: c_long,
869 }
870
871 extern "system" {
872 pub fn WSAStartup(wVersionRequested: WORD,
873 lpWSAData: LPWSADATA) -> c_int;
874 pub fn WSACleanup() -> c_int;
875 pub fn WSAGetLastError() -> c_int;
876 pub fn WSADuplicateSocketW(s: SOCKET,
877 dwProcessId: DWORD,
878 lpProtocolInfo: LPWSAPROTOCOL_INFO)
879 -> c_int;
880 pub fn GetCurrentProcessId() -> DWORD;
881 pub fn WSASocketW(af: c_int,
882 kind: c_int,
883 protocol: c_int,
884 lpProtocolInfo: LPWSAPROTOCOL_INFO,
885 g: GROUP,
886 dwFlags: DWORD) -> SOCKET;
887 pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int;
888 pub fn InitializeCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
889 pub fn EnterCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
890 pub fn TryEnterCriticalSection(CriticalSection: *mut CRITICAL_SECTION) -> BOOLEAN;
891 pub fn LeaveCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
892 pub fn DeleteCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
893
894 pub fn ReadConsoleW(hConsoleInput: HANDLE,
895 lpBuffer: LPVOID,
896 nNumberOfCharsToRead: DWORD,
897 lpNumberOfCharsRead: LPDWORD,
898 pInputControl: PCONSOLE_READCONSOLE_CONTROL) -> BOOL;
899
900 pub fn WriteConsoleW(hConsoleOutput: HANDLE,
901 lpBuffer: LPCVOID,
902 nNumberOfCharsToWrite: DWORD,
903 lpNumberOfCharsWritten: LPDWORD,
904 lpReserved: LPVOID) -> BOOL;
905
906 pub fn GetConsoleMode(hConsoleHandle: HANDLE,
907 lpMode: LPDWORD) -> BOOL;
908 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
909 pub fn SetFileAttributesW(lpFileName: LPCWSTR,
910 dwFileAttributes: DWORD) -> BOOL;
911 pub fn GetFileInformationByHandle(hFile: HANDLE,
912 lpFileInformation: LPBY_HANDLE_FILE_INFORMATION)
913 -> BOOL;
914
915 pub fn SetLastError(dwErrCode: DWORD);
916 pub fn GetCommandLineW() -> *mut LPCWSTR;
917 pub fn LocalFree(ptr: *mut c_void);
918 pub fn CommandLineToArgvW(lpCmdLine: *mut LPCWSTR,
919 pNumArgs: *mut c_int) -> *mut *mut u16;
920 pub fn GetTempPathW(nBufferLength: DWORD,
921 lpBuffer: LPCWSTR) -> DWORD;
922 pub fn OpenProcessToken(ProcessHandle: HANDLE,
923 DesiredAccess: DWORD,
924 TokenHandle: *mut HANDLE) -> BOOL;
925 pub fn GetCurrentProcess() -> HANDLE;
926 pub fn GetCurrentThread() -> HANDLE;
927 pub fn GetStdHandle(which: DWORD) -> HANDLE;
928 pub fn ExitProcess(uExitCode: c_uint) -> !;
929 pub fn DeviceIoControl(hDevice: HANDLE,
930 dwIoControlCode: DWORD,
931 lpInBuffer: LPVOID,
932 nInBufferSize: DWORD,
933 lpOutBuffer: LPVOID,
934 nOutBufferSize: DWORD,
935 lpBytesReturned: LPDWORD,
936 lpOverlapped: LPOVERLAPPED) -> BOOL;
937 pub fn CreateThread(lpThreadAttributes: LPSECURITY_ATTRIBUTES,
938 dwStackSize: SIZE_T,
939 lpStartAddress: extern "system" fn(*mut c_void)
940 -> DWORD,
941 lpParameter: LPVOID,
942 dwCreationFlags: DWORD,
943 lpThreadId: LPDWORD) -> HANDLE;
944 pub fn WaitForSingleObject(hHandle: HANDLE,
945 dwMilliseconds: DWORD) -> DWORD;
946 pub fn SwitchToThread() -> BOOL;
947 pub fn Sleep(dwMilliseconds: DWORD);
948 pub fn GetProcessId(handle: HANDLE) -> DWORD;
949 pub fn GetUserProfileDirectoryW(hToken: HANDLE,
950 lpProfileDir: LPWSTR,
951 lpcchSize: *mut DWORD) -> BOOL;
952 pub fn SetHandleInformation(hObject: HANDLE,
953 dwMask: DWORD,
954 dwFlags: DWORD) -> BOOL;
955 pub fn CopyFileExW(lpExistingFileName: LPCWSTR,
956 lpNewFileName: LPCWSTR,
957 lpProgressRoutine: LPPROGRESS_ROUTINE,
958 lpData: LPVOID,
959 pbCancel: LPBOOL,
960 dwCopyFlags: DWORD) -> BOOL;
961 pub fn AddVectoredExceptionHandler(FirstHandler: ULONG,
962 VectoredHandler: PVECTORED_EXCEPTION_HANDLER)
963 -> LPVOID;
964 pub fn FormatMessageW(flags: DWORD,
965 lpSrc: LPVOID,
966 msgId: DWORD,
967 langId: DWORD,
968 buf: LPWSTR,
969 nsize: DWORD,
970 args: *const c_void)
971 -> DWORD;
972 pub fn TlsAlloc() -> DWORD;
973 pub fn TlsGetValue(dwTlsIndex: DWORD) -> LPVOID;
974 pub fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;
975 pub fn GetLastError() -> DWORD;
976 pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL;
977 pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER)
978 -> BOOL;
979 pub fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL;
980 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL;
981 pub fn CreateProcessW(lpApplicationName: LPCWSTR,
982 lpCommandLine: LPWSTR,
983 lpProcessAttributes: LPSECURITY_ATTRIBUTES,
984 lpThreadAttributes: LPSECURITY_ATTRIBUTES,
985 bInheritHandles: BOOL,
986 dwCreationFlags: DWORD,
987 lpEnvironment: LPVOID,
988 lpCurrentDirectory: LPCWSTR,
989 lpStartupInfo: LPSTARTUPINFO,
990 lpProcessInformation: LPPROCESS_INFORMATION)
991 -> BOOL;
992 pub fn GetEnvironmentVariableW(n: LPCWSTR, v: LPWSTR, nsize: DWORD) -> DWORD;
993 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) -> BOOL;
994 pub fn GetEnvironmentStringsW() -> LPWCH;
995 pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
996 pub fn GetModuleFileNameW(hModule: HMODULE,
997 lpFilename: LPWSTR,
998 nSize: DWORD)
999 -> DWORD;
1000 pub fn CreateDirectoryW(lpPathName: LPCWSTR,
1001 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
1002 -> BOOL;
1003 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
1004 pub fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD;
1005 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
1006 pub fn WideCharToMultiByte(CodePage: UINT,
1007 dwFlags: DWORD,
1008 lpWideCharStr: LPCWSTR,
1009 cchWideChar: c_int,
1010 lpMultiByteStr: LPSTR,
1011 cbMultiByte: c_int,
1012 lpDefaultChar: LPCSTR,
1013 lpUsedDefaultChar: LPBOOL) -> c_int;
1014
1015 pub fn closesocket(socket: SOCKET) -> c_int;
1016 pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int,
1017 flags: c_int) -> c_int;
1018 pub fn send(socket: SOCKET, buf: *const c_void, len: c_int,
1019 flags: c_int) -> c_int;
1020 pub fn recvfrom(socket: SOCKET,
1021 buf: *mut c_void,
1022 len: c_int,
1023 flags: c_int,
1024 addr: *mut SOCKADDR,
1025 addrlen: *mut c_int)
1026 -> c_int;
1027 pub fn sendto(socket: SOCKET,
1028 buf: *const c_void,
1029 len: c_int,
1030 flags: c_int,
1031 addr: *const SOCKADDR,
1032 addrlen: c_int)
1033 -> c_int;
1034 pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
1035 pub fn accept(socket: SOCKET,
1036 address: *mut SOCKADDR,
1037 address_len: *mut c_int)
1038 -> SOCKET;
1039 pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
1040 hSourceHandle: HANDLE,
1041 hTargetProcessHandle: HANDLE,
1042 lpTargetHandle: LPHANDLE,
1043 dwDesiredAccess: DWORD,
1044 bInheritHandle: BOOL,
1045 dwOptions: DWORD)
1046 -> BOOL;
1047 pub fn ReadFile(hFile: HANDLE,
1048 lpBuffer: LPVOID,
1049 nNumberOfBytesToRead: DWORD,
1050 lpNumberOfBytesRead: LPDWORD,
1051 lpOverlapped: LPOVERLAPPED)
1052 -> BOOL;
1053 pub fn WriteFile(hFile: HANDLE,
1054 lpBuffer: LPVOID,
1055 nNumberOfBytesToWrite: DWORD,
1056 lpNumberOfBytesWritten: LPDWORD,
1057 lpOverlapped: LPOVERLAPPED)
1058 -> BOOL;
1059 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
1060 pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
1061 lpTargetFileName: LPCWSTR,
1062 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
1063 -> BOOL;
1064 pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
1065 lpNewFileName: LPCWSTR,
1066 dwFlags: DWORD)
1067 -> BOOL;
1068 pub fn SetFilePointerEx(hFile: HANDLE,
1069 liDistanceToMove: LARGE_INTEGER,
1070 lpNewFilePointer: PLARGE_INTEGER,
1071 dwMoveMethod: DWORD)
1072 -> BOOL;
1073 pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
1074 pub fn CreateFileW(lpFileName: LPCWSTR,
1075 dwDesiredAccess: DWORD,
1076 dwShareMode: DWORD,
1077 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
1078 dwCreationDisposition: DWORD,
1079 dwFlagsAndAttributes: DWORD,
1080 hTemplateFile: HANDLE)
1081 -> HANDLE;
1082
1083 pub fn FindFirstFileW(fileName: LPCWSTR,
1084 findFileData: LPWIN32_FIND_DATAW)
1085 -> HANDLE;
1086 pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
1087 -> BOOL;
1088 pub fn FindClose(findFile: HANDLE) -> BOOL;
1089 pub fn RtlCaptureContext(ctx: *mut CONTEXT);
1090 pub fn getsockopt(s: SOCKET,
1091 level: c_int,
1092 optname: c_int,
1093 optval: *mut c_char,
1094 optlen: *mut c_int)
1095 -> c_int;
1096 pub fn setsockopt(s: SOCKET,
1097 level: c_int,
1098 optname: c_int,
1099 optval: *const c_void,
1100 optlen: c_int)
1101 -> c_int;
1102 pub fn getsockname(socket: SOCKET,
1103 address: *mut SOCKADDR,
1104 address_len: *mut c_int)
1105 -> c_int;
1106 pub fn getpeername(socket: SOCKET,
1107 address: *mut SOCKADDR,
1108 address_len: *mut c_int)
1109 -> c_int;
1110 pub fn bind(socket: SOCKET, address: *const SOCKADDR,
1111 address_len: socklen_t) -> c_int;
1112 pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
1113 pub fn connect(socket: SOCKET, address: *const SOCKADDR, len: c_int)
1114 -> c_int;
1115 pub fn getaddrinfo(node: *const c_char, service: *const c_char,
1116 hints: *const ADDRINFOA,
1117 res: *mut *mut ADDRINFOA) -> c_int;
1118 pub fn freeaddrinfo(res: *mut ADDRINFOA);
1119
1120 pub fn LoadLibraryW(name: LPCWSTR) -> HMODULE;
1121 pub fn FreeLibrary(handle: HMODULE) -> BOOL;
1122 pub fn GetProcAddress(handle: HMODULE,
1123 name: LPCSTR) -> *mut c_void;
1124 pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
1125 pub fn CryptAcquireContextA(phProv: *mut HCRYPTPROV,
1126 pszContainer: LPCSTR,
1127 pszProvider: LPCSTR,
1128 dwProvType: DWORD,
1129 dwFlags: DWORD) -> BOOL;
1130 pub fn CryptGenRandom(hProv: HCRYPTPROV,
1131 dwLen: DWORD,
1132 pbBuffer: *mut BYTE) -> BOOL;
1133 pub fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL;
1134
1135 pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME);
1136
1137 pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES,
1138 bManualReset: BOOL,
1139 bInitialState: BOOL,
1140 lpName: LPCWSTR) -> HANDLE;
1141 pub fn WaitForMultipleObjects(nCount: DWORD,
1142 lpHandles: *const HANDLE,
1143 bWaitAll: BOOL,
1144 dwMilliseconds: DWORD) -> DWORD;
1145 pub fn CreateNamedPipeW(lpName: LPCWSTR,
1146 dwOpenMode: DWORD,
1147 dwPipeMode: DWORD,
1148 nMaxInstances: DWORD,
1149 nOutBufferSize: DWORD,
1150 nInBufferSize: DWORD,
1151 nDefaultTimeOut: DWORD,
1152 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
1153 -> HANDLE;
1154 pub fn CancelIo(handle: HANDLE) -> BOOL;
1155 pub fn GetOverlappedResult(hFile: HANDLE,
1156 lpOverlapped: LPOVERLAPPED,
1157 lpNumberOfBytesTransferred: LPDWORD,
1158 bWait: BOOL) -> BOOL;
1159 pub fn select(nfds: c_int,
1160 readfds: *mut fd_set,
1161 writefds: *mut fd_set,
1162 exceptfds: *mut fd_set,
1163 timeout: *const timeval) -> c_int;
1164 }
1165
1166 // Functions that aren't available on Windows XP, but we still use them and just
1167 // provide some form of a fallback implementation.
1168 compat_fn! {
1169 kernel32:
1170
1171 pub fn CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR,
1172 _lpTargetFileName: LPCWSTR,
1173 _dwFlags: DWORD) -> BOOLEAN {
1174 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1175 }
1176 pub fn GetFinalPathNameByHandleW(_hFile: HANDLE,
1177 _lpszFilePath: LPCWSTR,
1178 _cchFilePath: DWORD,
1179 _dwFlags: DWORD) -> DWORD {
1180 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1181 }
1182 pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL {
1183 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1184 }
1185 pub fn SetFileInformationByHandle(_hFile: HANDLE,
1186 _FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
1187 _lpFileInformation: LPVOID,
1188 _dwBufferSize: DWORD) -> BOOL {
1189 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1190 }
1191 pub fn SleepConditionVariableSRW(ConditionVariable: PCONDITION_VARIABLE,
1192 SRWLock: PSRWLOCK,
1193 dwMilliseconds: DWORD,
1194 Flags: ULONG) -> BOOL {
1195 panic!("condition variables not available")
1196 }
1197 pub fn WakeConditionVariable(ConditionVariable: PCONDITION_VARIABLE)
1198 -> () {
1199 panic!("condition variables not available")
1200 }
1201 pub fn WakeAllConditionVariable(ConditionVariable: PCONDITION_VARIABLE)
1202 -> () {
1203 panic!("condition variables not available")
1204 }
1205 pub fn AcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> () {
1206 panic!("rwlocks not available")
1207 }
1208 pub fn AcquireSRWLockShared(SRWLock: PSRWLOCK) -> () {
1209 panic!("rwlocks not available")
1210 }
1211 pub fn ReleaseSRWLockExclusive(SRWLock: PSRWLOCK) -> () {
1212 panic!("rwlocks not available")
1213 }
1214 pub fn ReleaseSRWLockShared(SRWLock: PSRWLOCK) -> () {
1215 panic!("rwlocks not available")
1216 }
1217 pub fn TryAcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> BOOLEAN {
1218 panic!("rwlocks not available")
1219 }
1220 pub fn TryAcquireSRWLockShared(SRWLock: PSRWLOCK) -> BOOLEAN {
1221 panic!("rwlocks not available")
1222 }
1223 }
1224
1225 #[cfg(target_env = "gnu")]
1226 mod gnu {
1227 use super::*;
1228
1229 pub const PROCESS_QUERY_INFORMATION: DWORD = 0x0400;
1230
1231 pub const CP_ACP: UINT = 0;
1232
1233 pub const WC_NO_BEST_FIT_CHARS: DWORD = 0x00000400;
1234
1235 extern "system" {
1236 pub fn OpenProcess(dwDesiredAccess: DWORD,
1237 bInheritHandle: BOOL,
1238 dwProcessId: DWORD) -> HANDLE;
1239 }
1240
1241 compat_fn! {
1242 kernel32:
1243
1244 pub fn QueryFullProcessImageNameW(_hProcess: HANDLE,
1245 _dwFlags: DWORD,
1246 _lpExeName: LPWSTR,
1247 _lpdwSize: LPDWORD) -> BOOL {
1248 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1249 }
1250 }
1251 }
1252
1253 #[cfg(target_env = "gnu")]
1254 pub use self::gnu::*;