Source file
src/syscall/types_windows.go
1
2
3
4
5 package syscall
6
7 import "unsafe"
8
9 const (
10
11 ERROR_FILE_NOT_FOUND Errno = 2
12 ERROR_PATH_NOT_FOUND Errno = 3
13 ERROR_ACCESS_DENIED Errno = 5
14 ERROR_NO_MORE_FILES Errno = 18
15 ERROR_HANDLE_EOF Errno = 38
16 ERROR_NETNAME_DELETED Errno = 64
17 ERROR_FILE_EXISTS Errno = 80
18 ERROR_BROKEN_PIPE Errno = 109
19 ERROR_BUFFER_OVERFLOW Errno = 111
20 ERROR_INSUFFICIENT_BUFFER Errno = 122
21 ERROR_MOD_NOT_FOUND Errno = 126
22 ERROR_PROC_NOT_FOUND Errno = 127
23 ERROR_DIR_NOT_EMPTY Errno = 145
24 ERROR_ALREADY_EXISTS Errno = 183
25 ERROR_ENVVAR_NOT_FOUND Errno = 203
26 ERROR_MORE_DATA Errno = 234
27 ERROR_OPERATION_ABORTED Errno = 995
28 ERROR_IO_PENDING Errno = 997
29 ERROR_NOT_FOUND Errno = 1168
30 ERROR_PRIVILEGE_NOT_HELD Errno = 1314
31 WSAEACCES Errno = 10013
32 WSAENOPROTOOPT Errno = 10042
33 WSAECONNABORTED Errno = 10053
34 WSAECONNRESET Errno = 10054
35 )
36
37 const (
38
39 O_RDONLY = 0x00000
40 O_WRONLY = 0x00001
41 O_RDWR = 0x00002
42 O_CREAT = 0x00040
43 O_EXCL = 0x00080
44 O_NOCTTY = 0x00100
45 O_TRUNC = 0x00200
46 O_NONBLOCK = 0x00800
47 O_APPEND = 0x00400
48 O_SYNC = 0x01000
49 O_ASYNC = 0x02000
50 o_DIRECTORY = 0x04000
51 O_CLOEXEC = 0x80000
52 o_NOFOLLOW_ANY = 0x200000000
53 o_OPEN_REPARSE = 0x400000000
54 o_WRITE_ATTRS = 0x800000000
55 )
56
57 const (
58
59 SIGHUP = Signal(0x1)
60 SIGINT = Signal(0x2)
61 SIGQUIT = Signal(0x3)
62 SIGILL = Signal(0x4)
63 SIGTRAP = Signal(0x5)
64 SIGABRT = Signal(0x6)
65 SIGBUS = Signal(0x7)
66 SIGFPE = Signal(0x8)
67 SIGKILL = Signal(0x9)
68 SIGSEGV = Signal(0xb)
69 SIGPIPE = Signal(0xd)
70 SIGALRM = Signal(0xe)
71 SIGTERM = Signal(0xf)
72 )
73
74 var signals = [...]string{
75 1: "hangup",
76 2: "interrupt",
77 3: "quit",
78 4: "illegal instruction",
79 5: "trace/breakpoint trap",
80 6: "aborted",
81 7: "bus error",
82 8: "floating point exception",
83 9: "killed",
84 10: "user defined signal 1",
85 11: "segmentation fault",
86 12: "user defined signal 2",
87 13: "broken pipe",
88 14: "alarm clock",
89 15: "terminated",
90 }
91
92 const fileFlagsMask = 0xFFF00000
93
94 const validFileFlagsMask = FILE_FLAG_OPEN_REPARSE_POINT |
95 FILE_FLAG_BACKUP_SEMANTICS |
96 FILE_FLAG_OVERLAPPED |
97 _FILE_FLAG_OPEN_NO_RECALL |
98 _FILE_FLAG_SESSION_AWARE |
99 _FILE_FLAG_POSIX_SEMANTICS |
100 _FILE_FLAG_DELETE_ON_CLOSE |
101 _FILE_FLAG_SEQUENTIAL_SCAN |
102 _FILE_FLAG_NO_BUFFERING |
103 _FILE_FLAG_RANDOM_ACCESS |
104 _FILE_FLAG_WRITE_THROUGH
105
106 const (
107 GENERIC_READ = 0x80000000
108 GENERIC_WRITE = 0x40000000
109 GENERIC_EXECUTE = 0x20000000
110 GENERIC_ALL = 0x10000000
111
112 FILE_LIST_DIRECTORY = 0x00000001
113 FILE_APPEND_DATA = 0x00000004
114 _FILE_WRITE_EA = 0x00000010
115 FILE_WRITE_ATTRIBUTES = 0x00000100
116
117 FILE_SHARE_READ = 0x00000001
118 FILE_SHARE_WRITE = 0x00000002
119 FILE_SHARE_DELETE = 0x00000004
120 FILE_ATTRIBUTE_READONLY = 0x00000001
121 FILE_ATTRIBUTE_HIDDEN = 0x00000002
122 FILE_ATTRIBUTE_SYSTEM = 0x00000004
123 FILE_ATTRIBUTE_DIRECTORY = 0x00000010
124 FILE_ATTRIBUTE_ARCHIVE = 0x00000020
125 FILE_ATTRIBUTE_NORMAL = 0x00000080
126 FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
127
128 INVALID_FILE_ATTRIBUTES = 0xffffffff
129
130 CREATE_NEW = 1
131 CREATE_ALWAYS = 2
132 OPEN_EXISTING = 3
133 OPEN_ALWAYS = 4
134 TRUNCATE_EXISTING = 5
135
136
137
138 _FILE_FLAG_OPEN_NO_RECALL = 0x00100000
139 FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
140 _FILE_FLAG_SESSION_AWARE = 0x00800000
141 _FILE_FLAG_POSIX_SEMANTICS = 0x01000000
142 FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
143 _FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
144 _FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000
145 _FILE_FLAG_RANDOM_ACCESS = 0x10000000
146 _FILE_FLAG_NO_BUFFERING = 0x20000000
147 FILE_FLAG_OVERLAPPED = 0x40000000
148 _FILE_FLAG_WRITE_THROUGH = 0x80000000
149
150 HANDLE_FLAG_INHERIT = 0x00000001
151 STARTF_USESTDHANDLES = 0x00000100
152 STARTF_USESHOWWINDOW = 0x00000001
153 DUPLICATE_CLOSE_SOURCE = 0x00000001
154 DUPLICATE_SAME_ACCESS = 0x00000002
155
156 STD_INPUT_HANDLE = -10
157 STD_OUTPUT_HANDLE = -11
158 STD_ERROR_HANDLE = -12
159
160 FILE_BEGIN = 0
161 FILE_CURRENT = 1
162 FILE_END = 2
163
164 LANG_ENGLISH = 0x09
165 SUBLANG_ENGLISH_US = 0x01
166
167 FORMAT_MESSAGE_ALLOCATE_BUFFER = 256
168 FORMAT_MESSAGE_IGNORE_INSERTS = 512
169 FORMAT_MESSAGE_FROM_STRING = 1024
170 FORMAT_MESSAGE_FROM_HMODULE = 2048
171 FORMAT_MESSAGE_FROM_SYSTEM = 4096
172 FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192
173 FORMAT_MESSAGE_MAX_WIDTH_MASK = 255
174
175 MAX_PATH = 260
176 MAX_LONG_PATH = 32768
177
178 MAX_COMPUTERNAME_LENGTH = 15
179
180 TIME_ZONE_ID_UNKNOWN = 0
181 TIME_ZONE_ID_STANDARD = 1
182
183 TIME_ZONE_ID_DAYLIGHT = 2
184 IGNORE = 0
185 INFINITE = 0xffffffff
186
187 WAIT_TIMEOUT = 258
188 WAIT_ABANDONED = 0x00000080
189 WAIT_OBJECT_0 = 0x00000000
190 WAIT_FAILED = 0xFFFFFFFF
191
192 CREATE_NEW_PROCESS_GROUP = 0x00000200
193 CREATE_UNICODE_ENVIRONMENT = 0x00000400
194
195 PROCESS_TERMINATE = 1
196 PROCESS_QUERY_INFORMATION = 0x00000400
197 SYNCHRONIZE = 0x00100000
198
199 PAGE_READONLY = 0x02
200 PAGE_READWRITE = 0x04
201 PAGE_WRITECOPY = 0x08
202 PAGE_EXECUTE_READ = 0x20
203 PAGE_EXECUTE_READWRITE = 0x40
204 PAGE_EXECUTE_WRITECOPY = 0x80
205
206 FILE_MAP_COPY = 0x01
207 FILE_MAP_WRITE = 0x02
208 FILE_MAP_READ = 0x04
209 FILE_MAP_EXECUTE = 0x20
210
211 CTRL_C_EVENT = 0
212 CTRL_BREAK_EVENT = 1
213 CTRL_CLOSE_EVENT = 2
214 CTRL_LOGOFF_EVENT = 5
215 CTRL_SHUTDOWN_EVENT = 6
216 )
217
218 const (
219
220 TH32CS_SNAPHEAPLIST = 0x01
221 TH32CS_SNAPPROCESS = 0x02
222 TH32CS_SNAPTHREAD = 0x04
223 TH32CS_SNAPMODULE = 0x08
224 TH32CS_SNAPMODULE32 = 0x10
225 TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
226 TH32CS_INHERIT = 0x80000000
227 )
228
229 const (
230
231 FILE_NOTIFY_CHANGE_FILE_NAME = 1 << iota
232 FILE_NOTIFY_CHANGE_DIR_NAME
233 FILE_NOTIFY_CHANGE_ATTRIBUTES
234 FILE_NOTIFY_CHANGE_SIZE
235 FILE_NOTIFY_CHANGE_LAST_WRITE
236 FILE_NOTIFY_CHANGE_LAST_ACCESS
237 FILE_NOTIFY_CHANGE_CREATION
238 )
239
240 const (
241
242 FILE_ACTION_ADDED = iota + 1
243 FILE_ACTION_REMOVED
244 FILE_ACTION_MODIFIED
245 FILE_ACTION_RENAMED_OLD_NAME
246 FILE_ACTION_RENAMED_NEW_NAME
247 )
248
249 const (
250
251 PROV_RSA_FULL = 1
252 PROV_RSA_SIG = 2
253 PROV_DSS = 3
254 PROV_FORTEZZA = 4
255 PROV_MS_EXCHANGE = 5
256 PROV_SSL = 6
257 PROV_RSA_SCHANNEL = 12
258 PROV_DSS_DH = 13
259 PROV_EC_ECDSA_SIG = 14
260 PROV_EC_ECNRA_SIG = 15
261 PROV_EC_ECDSA_FULL = 16
262 PROV_EC_ECNRA_FULL = 17
263 PROV_DH_SCHANNEL = 18
264 PROV_SPYRUS_LYNKS = 20
265 PROV_RNG = 21
266 PROV_INTEL_SEC = 22
267 PROV_REPLACE_OWF = 23
268 PROV_RSA_AES = 24
269 CRYPT_VERIFYCONTEXT = 0xF0000000
270 CRYPT_NEWKEYSET = 0x00000008
271 CRYPT_DELETEKEYSET = 0x00000010
272 CRYPT_MACHINE_KEYSET = 0x00000020
273 CRYPT_SILENT = 0x00000040
274 CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080
275
276 USAGE_MATCH_TYPE_AND = 0
277 USAGE_MATCH_TYPE_OR = 1
278
279 X509_ASN_ENCODING = 0x00000001
280 PKCS_7_ASN_ENCODING = 0x00010000
281
282 CERT_STORE_PROV_MEMORY = 2
283
284 CERT_STORE_ADD_ALWAYS = 4
285
286 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004
287
288 CERT_TRUST_NO_ERROR = 0x00000000
289 CERT_TRUST_IS_NOT_TIME_VALID = 0x00000001
290 CERT_TRUST_IS_REVOKED = 0x00000004
291 CERT_TRUST_IS_NOT_SIGNATURE_VALID = 0x00000008
292 CERT_TRUST_IS_NOT_VALID_FOR_USAGE = 0x00000010
293 CERT_TRUST_IS_UNTRUSTED_ROOT = 0x00000020
294 CERT_TRUST_REVOCATION_STATUS_UNKNOWN = 0x00000040
295 CERT_TRUST_IS_CYCLIC = 0x00000080
296 CERT_TRUST_INVALID_EXTENSION = 0x00000100
297 CERT_TRUST_INVALID_POLICY_CONSTRAINTS = 0x00000200
298 CERT_TRUST_INVALID_BASIC_CONSTRAINTS = 0x00000400
299 CERT_TRUST_INVALID_NAME_CONSTRAINTS = 0x00000800
300 CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000
301 CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT = 0x00002000
302 CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000
303 CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT = 0x00008000
304 CERT_TRUST_IS_OFFLINE_REVOCATION = 0x01000000
305 CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY = 0x02000000
306 CERT_TRUST_IS_EXPLICIT_DISTRUST = 0x04000000
307 CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT = 0x08000000
308
309 CERT_CHAIN_POLICY_BASE = 1
310 CERT_CHAIN_POLICY_AUTHENTICODE = 2
311 CERT_CHAIN_POLICY_AUTHENTICODE_TS = 3
312 CERT_CHAIN_POLICY_SSL = 4
313 CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5
314 CERT_CHAIN_POLICY_NT_AUTH = 6
315 CERT_CHAIN_POLICY_MICROSOFT_ROOT = 7
316 CERT_CHAIN_POLICY_EV = 8
317
318 CERT_E_EXPIRED = 0x800B0101
319 CERT_E_ROLE = 0x800B0103
320 CERT_E_PURPOSE = 0x800B0106
321 CERT_E_UNTRUSTEDROOT = 0x800B0109
322 CERT_E_CN_NO_MATCH = 0x800B010F
323
324 AUTHTYPE_CLIENT = 1
325 AUTHTYPE_SERVER = 2
326 )
327
328 var (
329 OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00")
330 OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00")
331 OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00")
332 )
333
334
335
336
337
338
339
340 type Pointer *struct{}
341
342
343 type Timeval struct {
344 Sec int32
345 Usec int32
346 }
347
348 func (tv *Timeval) Nanoseconds() int64 {
349 return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3
350 }
351
352 func NsecToTimeval(nsec int64) (tv Timeval) {
353 tv.Sec = int32(nsec / 1e9)
354 tv.Usec = int32(nsec % 1e9 / 1e3)
355 return
356 }
357
358 type SecurityAttributes struct {
359 Length uint32
360 SecurityDescriptor uintptr
361 InheritHandle uint32
362 }
363
364 type Overlapped struct {
365 Internal uintptr
366 InternalHigh uintptr
367 Offset uint32
368 OffsetHigh uint32
369 HEvent Handle
370 }
371
372 type FileNotifyInformation struct {
373 NextEntryOffset uint32
374 Action uint32
375 FileNameLength uint32
376 FileName uint16
377 }
378
379 type Filetime struct {
380 LowDateTime uint32
381 HighDateTime uint32
382 }
383
384
385
386 func (ft *Filetime) Nanoseconds() int64 {
387
388 nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)
389
390 nsec -= 116444736000000000
391
392 nsec *= 100
393 return nsec
394 }
395
396 func NsecToFiletime(nsec int64) (ft Filetime) {
397
398 nsec /= 100
399
400 nsec += 116444736000000000
401
402 ft.LowDateTime = uint32(nsec & 0xffffffff)
403 ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff)
404 return ft
405 }
406
407 type Win32finddata struct {
408 FileAttributes uint32
409 CreationTime Filetime
410 LastAccessTime Filetime
411 LastWriteTime Filetime
412 FileSizeHigh uint32
413 FileSizeLow uint32
414 Reserved0 uint32
415 Reserved1 uint32
416 FileName [MAX_PATH - 1]uint16
417 AlternateFileName [13]uint16
418 }
419
420
421
422 type win32finddata1 struct {
423 FileAttributes uint32
424 CreationTime Filetime
425 LastAccessTime Filetime
426 LastWriteTime Filetime
427 FileSizeHigh uint32
428 FileSizeLow uint32
429 Reserved0 uint32
430 Reserved1 uint32
431 FileName [MAX_PATH]uint16
432 AlternateFileName [14]uint16
433
434
435
436
437
438
439
440
441 }
442
443 func copyFindData(dst *Win32finddata, src *win32finddata1) {
444 dst.FileAttributes = src.FileAttributes
445 dst.CreationTime = src.CreationTime
446 dst.LastAccessTime = src.LastAccessTime
447 dst.LastWriteTime = src.LastWriteTime
448 dst.FileSizeHigh = src.FileSizeHigh
449 dst.FileSizeLow = src.FileSizeLow
450 dst.Reserved0 = src.Reserved0
451 dst.Reserved1 = src.Reserved1
452
453
454 copy(dst.FileName[:], src.FileName[:])
455 copy(dst.AlternateFileName[:], src.AlternateFileName[:])
456 }
457
458 type ByHandleFileInformation struct {
459 FileAttributes uint32
460 CreationTime Filetime
461 LastAccessTime Filetime
462 LastWriteTime Filetime
463 VolumeSerialNumber uint32
464 FileSizeHigh uint32
465 FileSizeLow uint32
466 NumberOfLinks uint32
467 FileIndexHigh uint32
468 FileIndexLow uint32
469 }
470
471 const (
472 GetFileExInfoStandard = 0
473 GetFileExMaxInfoLevel = 1
474 )
475
476 type Win32FileAttributeData struct {
477 FileAttributes uint32
478 CreationTime Filetime
479 LastAccessTime Filetime
480 LastWriteTime Filetime
481 FileSizeHigh uint32
482 FileSizeLow uint32
483 }
484
485
486 const (
487
488 SW_HIDE = 0
489 SW_NORMAL = 1
490 SW_SHOWNORMAL = 1
491 SW_SHOWMINIMIZED = 2
492 SW_SHOWMAXIMIZED = 3
493 SW_MAXIMIZE = 3
494 SW_SHOWNOACTIVATE = 4
495 SW_SHOW = 5
496 SW_MINIMIZE = 6
497 SW_SHOWMINNOACTIVE = 7
498 SW_SHOWNA = 8
499 SW_RESTORE = 9
500 SW_SHOWDEFAULT = 10
501 SW_FORCEMINIMIZE = 11
502 )
503
504 type StartupInfo struct {
505 Cb uint32
506 _ *uint16
507 Desktop *uint16
508 Title *uint16
509 X uint32
510 Y uint32
511 XSize uint32
512 YSize uint32
513 XCountChars uint32
514 YCountChars uint32
515 FillAttribute uint32
516 Flags uint32
517 ShowWindow uint16
518 _ uint16
519 _ *byte
520 StdInput Handle
521 StdOutput Handle
522 StdErr Handle
523 }
524
525
526
527
528
529 type _PROC_THREAD_ATTRIBUTE_LIST struct{}
530
531 type procThreadAttributeListContainer struct {
532 data *_PROC_THREAD_ATTRIBUTE_LIST
533 pointers []unsafe.Pointer
534 }
535
536 const (
537 _PROC_THREAD_ATTRIBUTE_PARENT_PROCESS = 0x00020000
538 _PROC_THREAD_ATTRIBUTE_HANDLE_LIST = 0x00020002
539 )
540
541 type _STARTUPINFOEXW struct {
542 StartupInfo
543 ProcThreadAttributeList *_PROC_THREAD_ATTRIBUTE_LIST
544 }
545
546 const _EXTENDED_STARTUPINFO_PRESENT = 0x00080000
547
548 type ProcessInformation struct {
549 Process Handle
550 Thread Handle
551 ProcessId uint32
552 ThreadId uint32
553 }
554
555 type ProcessEntry32 struct {
556 Size uint32
557 Usage uint32
558 ProcessID uint32
559 DefaultHeapID uintptr
560 ModuleID uint32
561 Threads uint32
562 ParentProcessID uint32
563 PriClassBase int32
564 Flags uint32
565 ExeFile [MAX_PATH]uint16
566 }
567
568 type Systemtime struct {
569 Year uint16
570 Month uint16
571 DayOfWeek uint16
572 Day uint16
573 Hour uint16
574 Minute uint16
575 Second uint16
576 Milliseconds uint16
577 }
578
579 type Timezoneinformation struct {
580 Bias int32
581 StandardName [32]uint16
582 StandardDate Systemtime
583 StandardBias int32
584 DaylightName [32]uint16
585 DaylightDate Systemtime
586 DaylightBias int32
587 }
588
589
590
591 const (
592 AF_UNSPEC = 0
593 AF_UNIX = 1
594 AF_INET = 2
595 AF_INET6 = 23
596 AF_NETBIOS = 17
597
598 SOCK_STREAM = 1
599 SOCK_DGRAM = 2
600 SOCK_RAW = 3
601 SOCK_SEQPACKET = 5
602
603 IPPROTO_IP = 0
604 IPPROTO_IPV6 = 0x29
605 IPPROTO_TCP = 6
606 IPPROTO_UDP = 17
607
608 SOL_SOCKET = 0xffff
609 SO_REUSEADDR = 4
610 SO_KEEPALIVE = 8
611 SO_DONTROUTE = 16
612 SO_BROADCAST = 32
613 SO_LINGER = 128
614 SO_RCVBUF = 0x1002
615 SO_SNDBUF = 0x1001
616 SO_UPDATE_ACCEPT_CONTEXT = 0x700b
617 SO_UPDATE_CONNECT_CONTEXT = 0x7010
618
619 IOC_OUT = 0x40000000
620 IOC_IN = 0x80000000
621 IOC_VENDOR = 0x18000000
622 IOC_INOUT = IOC_IN | IOC_OUT
623 IOC_WS2 = 0x08000000
624 SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6
625 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4
626 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12
627
628
629
630 IP_TOS = 0x3
631 IP_TTL = 0x4
632 IP_MULTICAST_IF = 0x9
633 IP_MULTICAST_TTL = 0xa
634 IP_MULTICAST_LOOP = 0xb
635 IP_ADD_MEMBERSHIP = 0xc
636 IP_DROP_MEMBERSHIP = 0xd
637
638 IPV6_V6ONLY = 0x1b
639 IPV6_UNICAST_HOPS = 0x4
640 IPV6_MULTICAST_IF = 0x9
641 IPV6_MULTICAST_HOPS = 0xa
642 IPV6_MULTICAST_LOOP = 0xb
643 IPV6_JOIN_GROUP = 0xc
644 IPV6_LEAVE_GROUP = 0xd
645
646 SOMAXCONN = 0x7fffffff
647
648 TCP_NODELAY = 1
649
650 SHUT_RD = 0
651 SHUT_WR = 1
652 SHUT_RDWR = 2
653
654 WSADESCRIPTION_LEN = 256
655 WSASYS_STATUS_LEN = 128
656 )
657
658 type WSABuf struct {
659 Len uint32
660 Buf *byte
661 }
662
663
664 const (
665 S_IFMT = 0x1f000
666 S_IFIFO = 0x1000
667 S_IFCHR = 0x2000
668 S_IFDIR = 0x4000
669 S_IFBLK = 0x6000
670 S_IFREG = 0x8000
671 S_IFLNK = 0xa000
672 S_IFSOCK = 0xc000
673 S_ISUID = 0x800
674 S_ISGID = 0x400
675 S_ISVTX = 0x200
676 S_IRUSR = 0x100
677 S_IWRITE = 0x80
678 S_IWUSR = 0x80
679 S_IXUSR = 0x40
680 )
681
682 const (
683 FILE_TYPE_CHAR = 0x0002
684 FILE_TYPE_DISK = 0x0001
685 FILE_TYPE_PIPE = 0x0003
686 FILE_TYPE_REMOTE = 0x8000
687 FILE_TYPE_UNKNOWN = 0x0000
688 )
689
690 type Hostent struct {
691 Name *byte
692 Aliases **byte
693 AddrType uint16
694 Length uint16
695 AddrList **byte
696 }
697
698 type Protoent struct {
699 Name *byte
700 Aliases **byte
701 Proto uint16
702 }
703
704 const (
705 DNS_TYPE_A = 0x0001
706 DNS_TYPE_NS = 0x0002
707 DNS_TYPE_MD = 0x0003
708 DNS_TYPE_MF = 0x0004
709 DNS_TYPE_CNAME = 0x0005
710 DNS_TYPE_SOA = 0x0006
711 DNS_TYPE_MB = 0x0007
712 DNS_TYPE_MG = 0x0008
713 DNS_TYPE_MR = 0x0009
714 DNS_TYPE_NULL = 0x000a
715 DNS_TYPE_WKS = 0x000b
716 DNS_TYPE_PTR = 0x000c
717 DNS_TYPE_HINFO = 0x000d
718 DNS_TYPE_MINFO = 0x000e
719 DNS_TYPE_MX = 0x000f
720 DNS_TYPE_TEXT = 0x0010
721 DNS_TYPE_RP = 0x0011
722 DNS_TYPE_AFSDB = 0x0012
723 DNS_TYPE_X25 = 0x0013
724 DNS_TYPE_ISDN = 0x0014
725 DNS_TYPE_RT = 0x0015
726 DNS_TYPE_NSAP = 0x0016
727 DNS_TYPE_NSAPPTR = 0x0017
728 DNS_TYPE_SIG = 0x0018
729 DNS_TYPE_KEY = 0x0019
730 DNS_TYPE_PX = 0x001a
731 DNS_TYPE_GPOS = 0x001b
732 DNS_TYPE_AAAA = 0x001c
733 DNS_TYPE_LOC = 0x001d
734 DNS_TYPE_NXT = 0x001e
735 DNS_TYPE_EID = 0x001f
736 DNS_TYPE_NIMLOC = 0x0020
737 DNS_TYPE_SRV = 0x0021
738 DNS_TYPE_ATMA = 0x0022
739 DNS_TYPE_NAPTR = 0x0023
740 DNS_TYPE_KX = 0x0024
741 DNS_TYPE_CERT = 0x0025
742 DNS_TYPE_A6 = 0x0026
743 DNS_TYPE_DNAME = 0x0027
744 DNS_TYPE_SINK = 0x0028
745 DNS_TYPE_OPT = 0x0029
746 DNS_TYPE_DS = 0x002B
747 DNS_TYPE_RRSIG = 0x002E
748 DNS_TYPE_NSEC = 0x002F
749 DNS_TYPE_DNSKEY = 0x0030
750 DNS_TYPE_DHCID = 0x0031
751 DNS_TYPE_UINFO = 0x0064
752 DNS_TYPE_UID = 0x0065
753 DNS_TYPE_GID = 0x0066
754 DNS_TYPE_UNSPEC = 0x0067
755 DNS_TYPE_ADDRS = 0x00f8
756 DNS_TYPE_TKEY = 0x00f9
757 DNS_TYPE_TSIG = 0x00fa
758 DNS_TYPE_IXFR = 0x00fb
759 DNS_TYPE_AXFR = 0x00fc
760 DNS_TYPE_MAILB = 0x00fd
761 DNS_TYPE_MAILA = 0x00fe
762 DNS_TYPE_ALL = 0x00ff
763 DNS_TYPE_ANY = 0x00ff
764 DNS_TYPE_WINS = 0xff01
765 DNS_TYPE_WINSR = 0xff02
766 DNS_TYPE_NBSTAT = 0xff01
767 )
768
769 const (
770 DNS_INFO_NO_RECORDS = 0x251D
771 )
772
773 const (
774
775 DnsSectionQuestion = 0x0000
776 DnsSectionAnswer = 0x0001
777 DnsSectionAuthority = 0x0002
778 DnsSectionAdditional = 0x0003
779 )
780
781 type DNSSRVData struct {
782 Target *uint16
783 Priority uint16
784 Weight uint16
785 Port uint16
786 Pad uint16
787 }
788
789 type DNSPTRData struct {
790 Host *uint16
791 }
792
793 type DNSMXData struct {
794 NameExchange *uint16
795 Preference uint16
796 Pad uint16
797 }
798
799 type DNSTXTData struct {
800 StringCount uint16
801 StringArray [1]*uint16
802 }
803
804 type DNSRecord struct {
805 Next *DNSRecord
806 Name *uint16
807 Type uint16
808 Length uint16
809 Dw uint32
810 Ttl uint32
811 Reserved uint32
812 Data [40]byte
813 }
814
815 const (
816 TF_DISCONNECT = 1
817 TF_REUSE_SOCKET = 2
818 TF_WRITE_BEHIND = 4
819 TF_USE_DEFAULT_WORKER = 0
820 TF_USE_SYSTEM_THREAD = 16
821 TF_USE_KERNEL_APC = 32
822 )
823
824 type TransmitFileBuffers struct {
825 Head uintptr
826 HeadLength uint32
827 Tail uintptr
828 TailLength uint32
829 }
830
831 const (
832 IFF_UP = 1
833 IFF_BROADCAST = 2
834 IFF_LOOPBACK = 4
835 IFF_POINTTOPOINT = 8
836 IFF_MULTICAST = 16
837 )
838
839 const SIO_GET_INTERFACE_LIST = 0x4004747F
840
841
842
843
844 type SockaddrGen [24]byte
845
846 type InterfaceInfo struct {
847 Flags uint32
848 Address SockaddrGen
849 BroadcastAddress SockaddrGen
850 Netmask SockaddrGen
851 }
852
853 type IpAddressString struct {
854 String [16]byte
855 }
856
857 type IpMaskString IpAddressString
858
859 type IpAddrString struct {
860 Next *IpAddrString
861 IpAddress IpAddressString
862 IpMask IpMaskString
863 Context uint32
864 }
865
866 const MAX_ADAPTER_NAME_LENGTH = 256
867 const MAX_ADAPTER_DESCRIPTION_LENGTH = 128
868 const MAX_ADAPTER_ADDRESS_LENGTH = 8
869
870 type IpAdapterInfo struct {
871 Next *IpAdapterInfo
872 ComboIndex uint32
873 AdapterName [MAX_ADAPTER_NAME_LENGTH + 4]byte
874 Description [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte
875 AddressLength uint32
876 Address [MAX_ADAPTER_ADDRESS_LENGTH]byte
877 Index uint32
878 Type uint32
879 DhcpEnabled uint32
880 CurrentIpAddress *IpAddrString
881 IpAddressList IpAddrString
882 GatewayList IpAddrString
883 DhcpServer IpAddrString
884 HaveWins bool
885 PrimaryWinsServer IpAddrString
886 SecondaryWinsServer IpAddrString
887 LeaseObtained int64
888 LeaseExpires int64
889 }
890
891 const MAXLEN_PHYSADDR = 8
892 const MAX_INTERFACE_NAME_LEN = 256
893 const MAXLEN_IFDESCR = 256
894
895 type MibIfRow struct {
896 Name [MAX_INTERFACE_NAME_LEN]uint16
897 Index uint32
898 Type uint32
899 Mtu uint32
900 Speed uint32
901 PhysAddrLen uint32
902 PhysAddr [MAXLEN_PHYSADDR]byte
903 AdminStatus uint32
904 OperStatus uint32
905 LastChange uint32
906 InOctets uint32
907 InUcastPkts uint32
908 InNUcastPkts uint32
909 InDiscards uint32
910 InErrors uint32
911 InUnknownProtos uint32
912 OutOctets uint32
913 OutUcastPkts uint32
914 OutNUcastPkts uint32
915 OutDiscards uint32
916 OutErrors uint32
917 OutQLen uint32
918 DescrLen uint32
919 Descr [MAXLEN_IFDESCR]byte
920 }
921
922 type CertInfo struct {
923
924 }
925
926 type CertContext struct {
927 EncodingType uint32
928 EncodedCert *byte
929 Length uint32
930 CertInfo *CertInfo
931 Store Handle
932 }
933
934 type CertChainContext struct {
935 Size uint32
936 TrustStatus CertTrustStatus
937 ChainCount uint32
938 Chains **CertSimpleChain
939 LowerQualityChainCount uint32
940 LowerQualityChains **CertChainContext
941 HasRevocationFreshnessTime uint32
942 RevocationFreshnessTime uint32
943 }
944
945 type CertTrustListInfo struct {
946
947 }
948
949 type CertSimpleChain struct {
950 Size uint32
951 TrustStatus CertTrustStatus
952 NumElements uint32
953 Elements **CertChainElement
954 TrustListInfo *CertTrustListInfo
955 HasRevocationFreshnessTime uint32
956 RevocationFreshnessTime uint32
957 }
958
959 type CertChainElement struct {
960 Size uint32
961 CertContext *CertContext
962 TrustStatus CertTrustStatus
963 RevocationInfo *CertRevocationInfo
964 IssuanceUsage *CertEnhKeyUsage
965 ApplicationUsage *CertEnhKeyUsage
966 ExtendedErrorInfo *uint16
967 }
968
969 type CertRevocationCrlInfo struct {
970
971 }
972
973 type CertRevocationInfo struct {
974 Size uint32
975 RevocationResult uint32
976 RevocationOid *byte
977 OidSpecificInfo Pointer
978 HasFreshnessTime uint32
979 FreshnessTime uint32
980 CrlInfo *CertRevocationCrlInfo
981 }
982
983 type CertTrustStatus struct {
984 ErrorStatus uint32
985 InfoStatus uint32
986 }
987
988 type CertUsageMatch struct {
989 Type uint32
990 Usage CertEnhKeyUsage
991 }
992
993 type CertEnhKeyUsage struct {
994 Length uint32
995 UsageIdentifiers **byte
996 }
997
998 type CertChainPara struct {
999 Size uint32
1000 RequestedUsage CertUsageMatch
1001 RequstedIssuancePolicy CertUsageMatch
1002 URLRetrievalTimeout uint32
1003 CheckRevocationFreshnessTime uint32
1004 RevocationFreshnessTime uint32
1005 CacheResync *Filetime
1006 }
1007
1008 type CertChainPolicyPara struct {
1009 Size uint32
1010 Flags uint32
1011 ExtraPolicyPara Pointer
1012 }
1013
1014 type SSLExtraCertChainPolicyPara struct {
1015 Size uint32
1016 AuthType uint32
1017 Checks uint32
1018 ServerName *uint16
1019 }
1020
1021 type CertChainPolicyStatus struct {
1022 Size uint32
1023 Error uint32
1024 ChainIndex uint32
1025 ElementIndex uint32
1026 ExtraPolicyStatus Pointer
1027 }
1028
1029 const (
1030
1031 HKEY_CLASSES_ROOT = 0x80000000 + iota
1032 HKEY_CURRENT_USER
1033 HKEY_LOCAL_MACHINE
1034 HKEY_USERS
1035 HKEY_PERFORMANCE_DATA
1036 HKEY_CURRENT_CONFIG
1037 HKEY_DYN_DATA
1038
1039 KEY_QUERY_VALUE = 1
1040 KEY_SET_VALUE = 2
1041 KEY_CREATE_SUB_KEY = 4
1042 KEY_ENUMERATE_SUB_KEYS = 8
1043 KEY_NOTIFY = 16
1044 KEY_CREATE_LINK = 32
1045 KEY_WRITE = 0x20006
1046 KEY_EXECUTE = 0x20019
1047 KEY_READ = 0x20019
1048 KEY_WOW64_64KEY = 0x0100
1049 KEY_WOW64_32KEY = 0x0200
1050 KEY_ALL_ACCESS = 0xf003f
1051 )
1052
1053 const (
1054
1055 REG_NONE = iota
1056 REG_SZ
1057 REG_EXPAND_SZ
1058 REG_BINARY
1059 REG_DWORD_LITTLE_ENDIAN
1060 REG_DWORD_BIG_ENDIAN
1061 REG_LINK
1062 REG_MULTI_SZ
1063 REG_RESOURCE_LIST
1064 REG_FULL_RESOURCE_DESCRIPTOR
1065 REG_RESOURCE_REQUIREMENTS_LIST
1066 REG_QWORD_LITTLE_ENDIAN
1067 REG_DWORD = REG_DWORD_LITTLE_ENDIAN
1068 REG_QWORD = REG_QWORD_LITTLE_ENDIAN
1069 )
1070
1071 type AddrinfoW struct {
1072 Flags int32
1073 Family int32
1074 Socktype int32
1075 Protocol int32
1076 Addrlen uintptr
1077 Canonname *uint16
1078 Addr Pointer
1079 Next *AddrinfoW
1080 }
1081
1082 const (
1083 AI_PASSIVE = 1
1084 AI_CANONNAME = 2
1085 AI_NUMERICHOST = 4
1086 )
1087
1088 type GUID struct {
1089 Data1 uint32
1090 Data2 uint16
1091 Data3 uint16
1092 Data4 [8]byte
1093 }
1094
1095 var WSAID_CONNECTEX = GUID{
1096 0x25a207b9,
1097 0xddf3,
1098 0x4660,
1099 [8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e},
1100 }
1101
1102 const (
1103 FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
1104 FILE_SKIP_SET_EVENT_ON_HANDLE = 2
1105 )
1106
1107 const (
1108 WSAPROTOCOL_LEN = 255
1109 MAX_PROTOCOL_CHAIN = 7
1110 BASE_PROTOCOL = 1
1111 LAYERED_PROTOCOL = 0
1112
1113 XP1_CONNECTIONLESS = 0x00000001
1114 XP1_GUARANTEED_DELIVERY = 0x00000002
1115 XP1_GUARANTEED_ORDER = 0x00000004
1116 XP1_MESSAGE_ORIENTED = 0x00000008
1117 XP1_PSEUDO_STREAM = 0x00000010
1118 XP1_GRACEFUL_CLOSE = 0x00000020
1119 XP1_EXPEDITED_DATA = 0x00000040
1120 XP1_CONNECT_DATA = 0x00000080
1121 XP1_DISCONNECT_DATA = 0x00000100
1122 XP1_SUPPORT_BROADCAST = 0x00000200
1123 XP1_SUPPORT_MULTIPOINT = 0x00000400
1124 XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800
1125 XP1_MULTIPOINT_DATA_PLANE = 0x00001000
1126 XP1_QOS_SUPPORTED = 0x00002000
1127 XP1_UNI_SEND = 0x00008000
1128 XP1_UNI_RECV = 0x00010000
1129 XP1_IFS_HANDLES = 0x00020000
1130 XP1_PARTIAL_MESSAGE = 0x00040000
1131 XP1_SAN_SUPPORT_SDP = 0x00080000
1132
1133 PFL_MULTIPLE_PROTO_ENTRIES = 0x00000001
1134 PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002
1135 PFL_HIDDEN = 0x00000004
1136 PFL_MATCHES_PROTOCOL_ZERO = 0x00000008
1137 PFL_NETWORKDIRECT_PROVIDER = 0x00000010
1138 )
1139
1140 type WSAProtocolInfo struct {
1141 ServiceFlags1 uint32
1142 ServiceFlags2 uint32
1143 ServiceFlags3 uint32
1144 ServiceFlags4 uint32
1145 ProviderFlags uint32
1146 ProviderId GUID
1147 CatalogEntryId uint32
1148 ProtocolChain WSAProtocolChain
1149 Version int32
1150 AddressFamily int32
1151 MaxSockAddr int32
1152 MinSockAddr int32
1153 SocketType int32
1154 Protocol int32
1155 ProtocolMaxOffset int32
1156 NetworkByteOrder int32
1157 SecurityScheme int32
1158 MessageSize uint32
1159 ProviderReserved uint32
1160 ProtocolName [WSAPROTOCOL_LEN + 1]uint16
1161 }
1162
1163 type WSAProtocolChain struct {
1164 ChainLen int32
1165 ChainEntries [MAX_PROTOCOL_CHAIN]uint32
1166 }
1167
1168 type TCPKeepalive struct {
1169 OnOff uint32
1170 Time uint32
1171 Interval uint32
1172 }
1173
1174 type symbolicLinkReparseBuffer struct {
1175 SubstituteNameOffset uint16
1176 SubstituteNameLength uint16
1177 PrintNameOffset uint16
1178 PrintNameLength uint16
1179 Flags uint32
1180 PathBuffer [1]uint16
1181 }
1182
1183 type mountPointReparseBuffer struct {
1184 SubstituteNameOffset uint16
1185 SubstituteNameLength uint16
1186 PrintNameOffset uint16
1187 PrintNameLength uint16
1188 PathBuffer [1]uint16
1189 }
1190
1191 type reparseDataBuffer struct {
1192 ReparseTag uint32
1193 ReparseDataLength uint16
1194 Reserved uint16
1195
1196
1197 reparseBuffer byte
1198 }
1199
1200 const (
1201 FSCTL_GET_REPARSE_POINT = 0x900A8
1202 MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
1203 _IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
1204 IO_REPARSE_TAG_SYMLINK = 0xA000000C
1205 SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
1206 _SYMLINK_FLAG_RELATIVE = 1
1207 )
1208
1209 const UNIX_PATH_MAX = 108
1210
View as plain text