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