github.com/Andyfoo/golang/x/sys@v0.0.0-20190901054642-57c1bf301704/windows/types_windows.go (about)

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package windows
     6  
     7  import (
     8  	"net"
     9  	"syscall"
    10  	"unsafe"
    11  )
    12  
    13  const (
    14  	// Invented values to support what package os expects.
    15  	O_RDONLY   = 0x00000
    16  	O_WRONLY   = 0x00001
    17  	O_RDWR     = 0x00002
    18  	O_CREAT    = 0x00040
    19  	O_EXCL     = 0x00080
    20  	O_NOCTTY   = 0x00100
    21  	O_TRUNC    = 0x00200
    22  	O_NONBLOCK = 0x00800
    23  	O_APPEND   = 0x00400
    24  	O_SYNC     = 0x01000
    25  	O_ASYNC    = 0x02000
    26  	O_CLOEXEC  = 0x80000
    27  )
    28  
    29  const (
    30  	// More invented values for signals
    31  	SIGHUP  = Signal(0x1)
    32  	SIGINT  = Signal(0x2)
    33  	SIGQUIT = Signal(0x3)
    34  	SIGILL  = Signal(0x4)
    35  	SIGTRAP = Signal(0x5)
    36  	SIGABRT = Signal(0x6)
    37  	SIGBUS  = Signal(0x7)
    38  	SIGFPE  = Signal(0x8)
    39  	SIGKILL = Signal(0x9)
    40  	SIGSEGV = Signal(0xb)
    41  	SIGPIPE = Signal(0xd)
    42  	SIGALRM = Signal(0xe)
    43  	SIGTERM = Signal(0xf)
    44  )
    45  
    46  var signals = [...]string{
    47  	1:  "hangup",
    48  	2:  "interrupt",
    49  	3:  "quit",
    50  	4:  "illegal instruction",
    51  	5:  "trace/breakpoint trap",
    52  	6:  "aborted",
    53  	7:  "bus error",
    54  	8:  "floating point exception",
    55  	9:  "killed",
    56  	10: "user defined signal 1",
    57  	11: "segmentation fault",
    58  	12: "user defined signal 2",
    59  	13: "broken pipe",
    60  	14: "alarm clock",
    61  	15: "terminated",
    62  }
    63  
    64  const (
    65  	GENERIC_READ    = 0x80000000
    66  	GENERIC_WRITE   = 0x40000000
    67  	GENERIC_EXECUTE = 0x20000000
    68  	GENERIC_ALL     = 0x10000000
    69  
    70  	FILE_LIST_DIRECTORY   = 0x00000001
    71  	FILE_APPEND_DATA      = 0x00000004
    72  	FILE_WRITE_ATTRIBUTES = 0x00000100
    73  
    74  	FILE_SHARE_READ   = 0x00000001
    75  	FILE_SHARE_WRITE  = 0x00000002
    76  	FILE_SHARE_DELETE = 0x00000004
    77  
    78  	FILE_ATTRIBUTE_READONLY              = 0x00000001
    79  	FILE_ATTRIBUTE_HIDDEN                = 0x00000002
    80  	FILE_ATTRIBUTE_SYSTEM                = 0x00000004
    81  	FILE_ATTRIBUTE_DIRECTORY             = 0x00000010
    82  	FILE_ATTRIBUTE_ARCHIVE               = 0x00000020
    83  	FILE_ATTRIBUTE_DEVICE                = 0x00000040
    84  	FILE_ATTRIBUTE_NORMAL                = 0x00000080
    85  	FILE_ATTRIBUTE_TEMPORARY             = 0x00000100
    86  	FILE_ATTRIBUTE_SPARSE_FILE           = 0x00000200
    87  	FILE_ATTRIBUTE_REPARSE_POINT         = 0x00000400
    88  	FILE_ATTRIBUTE_COMPRESSED            = 0x00000800
    89  	FILE_ATTRIBUTE_OFFLINE               = 0x00001000
    90  	FILE_ATTRIBUTE_NOT_CONTENT_INDEXED   = 0x00002000
    91  	FILE_ATTRIBUTE_ENCRYPTED             = 0x00004000
    92  	FILE_ATTRIBUTE_INTEGRITY_STREAM      = 0x00008000
    93  	FILE_ATTRIBUTE_VIRTUAL               = 0x00010000
    94  	FILE_ATTRIBUTE_NO_SCRUB_DATA         = 0x00020000
    95  	FILE_ATTRIBUTE_RECALL_ON_OPEN        = 0x00040000
    96  	FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000
    97  
    98  	INVALID_FILE_ATTRIBUTES = 0xffffffff
    99  
   100  	CREATE_NEW        = 1
   101  	CREATE_ALWAYS     = 2
   102  	OPEN_EXISTING     = 3
   103  	OPEN_ALWAYS       = 4
   104  	TRUNCATE_EXISTING = 5
   105  
   106  	FILE_FLAG_OPEN_REQUIRING_OPLOCK = 0x00040000
   107  	FILE_FLAG_FIRST_PIPE_INSTANCE   = 0x00080000
   108  	FILE_FLAG_OPEN_NO_RECALL        = 0x00100000
   109  	FILE_FLAG_OPEN_REPARSE_POINT    = 0x00200000
   110  	FILE_FLAG_SESSION_AWARE         = 0x00800000
   111  	FILE_FLAG_POSIX_SEMANTICS       = 0x01000000
   112  	FILE_FLAG_BACKUP_SEMANTICS      = 0x02000000
   113  	FILE_FLAG_DELETE_ON_CLOSE       = 0x04000000
   114  	FILE_FLAG_SEQUENTIAL_SCAN       = 0x08000000
   115  	FILE_FLAG_RANDOM_ACCESS         = 0x10000000
   116  	FILE_FLAG_NO_BUFFERING          = 0x20000000
   117  	FILE_FLAG_OVERLAPPED            = 0x40000000
   118  	FILE_FLAG_WRITE_THROUGH         = 0x80000000
   119  
   120  	HANDLE_FLAG_INHERIT    = 0x00000001
   121  	STARTF_USESTDHANDLES   = 0x00000100
   122  	STARTF_USESHOWWINDOW   = 0x00000001
   123  	DUPLICATE_CLOSE_SOURCE = 0x00000001
   124  	DUPLICATE_SAME_ACCESS  = 0x00000002
   125  
   126  	STD_INPUT_HANDLE  = -10 & (1<<32 - 1)
   127  	STD_OUTPUT_HANDLE = -11 & (1<<32 - 1)
   128  	STD_ERROR_HANDLE  = -12 & (1<<32 - 1)
   129  
   130  	FILE_BEGIN   = 0
   131  	FILE_CURRENT = 1
   132  	FILE_END     = 2
   133  
   134  	LANG_ENGLISH       = 0x09
   135  	SUBLANG_ENGLISH_US = 0x01
   136  
   137  	FORMAT_MESSAGE_ALLOCATE_BUFFER = 256
   138  	FORMAT_MESSAGE_IGNORE_INSERTS  = 512
   139  	FORMAT_MESSAGE_FROM_STRING     = 1024
   140  	FORMAT_MESSAGE_FROM_HMODULE    = 2048
   141  	FORMAT_MESSAGE_FROM_SYSTEM     = 4096
   142  	FORMAT_MESSAGE_ARGUMENT_ARRAY  = 8192
   143  	FORMAT_MESSAGE_MAX_WIDTH_MASK  = 255
   144  
   145  	MAX_PATH      = 260
   146  	MAX_LONG_PATH = 32768
   147  
   148  	MAX_COMPUTERNAME_LENGTH = 15
   149  
   150  	TIME_ZONE_ID_UNKNOWN  = 0
   151  	TIME_ZONE_ID_STANDARD = 1
   152  
   153  	TIME_ZONE_ID_DAYLIGHT = 2
   154  	IGNORE                = 0
   155  	INFINITE              = 0xffffffff
   156  
   157  	WAIT_ABANDONED = 0x00000080
   158  	WAIT_OBJECT_0  = 0x00000000
   159  	WAIT_FAILED    = 0xFFFFFFFF
   160  
   161  	// Standard access rights.
   162  	DELETE       = 0x00010000
   163  	READ_CONTROL = 0x00020000
   164  	SYNCHRONIZE  = 0x00100000
   165  	WRITE_DAC    = 0x00040000
   166  	WRITE_OWNER  = 0x00080000
   167  
   168  	// Access rights for process.
   169  	PROCESS_CREATE_PROCESS            = 0x0080
   170  	PROCESS_CREATE_THREAD             = 0x0002
   171  	PROCESS_DUP_HANDLE                = 0x0040
   172  	PROCESS_QUERY_INFORMATION         = 0x0400
   173  	PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
   174  	PROCESS_SET_INFORMATION           = 0x0200
   175  	PROCESS_SET_QUOTA                 = 0x0100
   176  	PROCESS_SUSPEND_RESUME            = 0x0800
   177  	PROCESS_TERMINATE                 = 0x0001
   178  	PROCESS_VM_OPERATION              = 0x0008
   179  	PROCESS_VM_READ                   = 0x0010
   180  	PROCESS_VM_WRITE                  = 0x0020
   181  
   182  	// Access rights for thread.
   183  	THREAD_DIRECT_IMPERSONATION      = 0x0200
   184  	THREAD_GET_CONTEXT               = 0x0008
   185  	THREAD_IMPERSONATE               = 0x0100
   186  	THREAD_QUERY_INFORMATION         = 0x0040
   187  	THREAD_QUERY_LIMITED_INFORMATION = 0x0800
   188  	THREAD_SET_CONTEXT               = 0x0010
   189  	THREAD_SET_INFORMATION           = 0x0020
   190  	THREAD_SET_LIMITED_INFORMATION   = 0x0400
   191  	THREAD_SET_THREAD_TOKEN          = 0x0080
   192  	THREAD_SUSPEND_RESUME            = 0x0002
   193  	THREAD_TERMINATE                 = 0x0001
   194  
   195  	FILE_MAP_COPY    = 0x01
   196  	FILE_MAP_WRITE   = 0x02
   197  	FILE_MAP_READ    = 0x04
   198  	FILE_MAP_EXECUTE = 0x20
   199  
   200  	CTRL_C_EVENT        = 0
   201  	CTRL_BREAK_EVENT    = 1
   202  	CTRL_CLOSE_EVENT    = 2
   203  	CTRL_LOGOFF_EVENT   = 5
   204  	CTRL_SHUTDOWN_EVENT = 6
   205  
   206  	// Windows reserves errors >= 1<<29 for application use.
   207  	APPLICATION_ERROR = 1 << 29
   208  )
   209  
   210  const (
   211  	// Process creation flags.
   212  	CREATE_BREAKAWAY_FROM_JOB        = 0x01000000
   213  	CREATE_DEFAULT_ERROR_MODE        = 0x04000000
   214  	CREATE_NEW_CONSOLE               = 0x00000010
   215  	CREATE_NEW_PROCESS_GROUP         = 0x00000200
   216  	CREATE_NO_WINDOW                 = 0x08000000
   217  	CREATE_PROTECTED_PROCESS         = 0x00040000
   218  	CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
   219  	CREATE_SEPARATE_WOW_VDM          = 0x00000800
   220  	CREATE_SHARED_WOW_VDM            = 0x00001000
   221  	CREATE_SUSPENDED                 = 0x00000004
   222  	CREATE_UNICODE_ENVIRONMENT       = 0x00000400
   223  	DEBUG_ONLY_THIS_PROCESS          = 0x00000002
   224  	DEBUG_PROCESS                    = 0x00000001
   225  	DETACHED_PROCESS                 = 0x00000008
   226  	EXTENDED_STARTUPINFO_PRESENT     = 0x00080000
   227  	INHERIT_PARENT_AFFINITY          = 0x00010000
   228  )
   229  
   230  const (
   231  	// flags for CreateToolhelp32Snapshot
   232  	TH32CS_SNAPHEAPLIST = 0x01
   233  	TH32CS_SNAPPROCESS  = 0x02
   234  	TH32CS_SNAPTHREAD   = 0x04
   235  	TH32CS_SNAPMODULE   = 0x08
   236  	TH32CS_SNAPMODULE32 = 0x10
   237  	TH32CS_SNAPALL      = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
   238  	TH32CS_INHERIT      = 0x80000000
   239  )
   240  
   241  const (
   242  	// filters for ReadDirectoryChangesW
   243  	FILE_NOTIFY_CHANGE_FILE_NAME   = 0x001
   244  	FILE_NOTIFY_CHANGE_DIR_NAME    = 0x002
   245  	FILE_NOTIFY_CHANGE_ATTRIBUTES  = 0x004
   246  	FILE_NOTIFY_CHANGE_SIZE        = 0x008
   247  	FILE_NOTIFY_CHANGE_LAST_WRITE  = 0x010
   248  	FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x020
   249  	FILE_NOTIFY_CHANGE_CREATION    = 0x040
   250  	FILE_NOTIFY_CHANGE_SECURITY    = 0x100
   251  )
   252  
   253  const (
   254  	// do not reorder
   255  	FILE_ACTION_ADDED = iota + 1
   256  	FILE_ACTION_REMOVED
   257  	FILE_ACTION_MODIFIED
   258  	FILE_ACTION_RENAMED_OLD_NAME
   259  	FILE_ACTION_RENAMED_NEW_NAME
   260  )
   261  
   262  const (
   263  	// wincrypt.h
   264  	PROV_RSA_FULL                    = 1
   265  	PROV_RSA_SIG                     = 2
   266  	PROV_DSS                         = 3
   267  	PROV_FORTEZZA                    = 4
   268  	PROV_MS_EXCHANGE                 = 5
   269  	PROV_SSL                         = 6
   270  	PROV_RSA_SCHANNEL                = 12
   271  	PROV_DSS_DH                      = 13
   272  	PROV_EC_ECDSA_SIG                = 14
   273  	PROV_EC_ECNRA_SIG                = 15
   274  	PROV_EC_ECDSA_FULL               = 16
   275  	PROV_EC_ECNRA_FULL               = 17
   276  	PROV_DH_SCHANNEL                 = 18
   277  	PROV_SPYRUS_LYNKS                = 20
   278  	PROV_RNG                         = 21
   279  	PROV_INTEL_SEC                   = 22
   280  	PROV_REPLACE_OWF                 = 23
   281  	PROV_RSA_AES                     = 24
   282  	CRYPT_VERIFYCONTEXT              = 0xF0000000
   283  	CRYPT_NEWKEYSET                  = 0x00000008
   284  	CRYPT_DELETEKEYSET               = 0x00000010
   285  	CRYPT_MACHINE_KEYSET             = 0x00000020
   286  	CRYPT_SILENT                     = 0x00000040
   287  	CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080
   288  
   289  	USAGE_MATCH_TYPE_AND = 0
   290  	USAGE_MATCH_TYPE_OR  = 1
   291  
   292  	/* msgAndCertEncodingType values for CertOpenStore function */
   293  	X509_ASN_ENCODING   = 0x00000001
   294  	PKCS_7_ASN_ENCODING = 0x00010000
   295  
   296  	/* storeProvider values for CertOpenStore function */
   297  	CERT_STORE_PROV_MSG               = 1
   298  	CERT_STORE_PROV_MEMORY            = 2
   299  	CERT_STORE_PROV_FILE              = 3
   300  	CERT_STORE_PROV_REG               = 4
   301  	CERT_STORE_PROV_PKCS7             = 5
   302  	CERT_STORE_PROV_SERIALIZED        = 6
   303  	CERT_STORE_PROV_FILENAME_A        = 7
   304  	CERT_STORE_PROV_FILENAME_W        = 8
   305  	CERT_STORE_PROV_FILENAME          = CERT_STORE_PROV_FILENAME_W
   306  	CERT_STORE_PROV_SYSTEM_A          = 9
   307  	CERT_STORE_PROV_SYSTEM_W          = 10
   308  	CERT_STORE_PROV_SYSTEM            = CERT_STORE_PROV_SYSTEM_W
   309  	CERT_STORE_PROV_COLLECTION        = 11
   310  	CERT_STORE_PROV_SYSTEM_REGISTRY_A = 12
   311  	CERT_STORE_PROV_SYSTEM_REGISTRY_W = 13
   312  	CERT_STORE_PROV_SYSTEM_REGISTRY   = CERT_STORE_PROV_SYSTEM_REGISTRY_W
   313  	CERT_STORE_PROV_PHYSICAL_W        = 14
   314  	CERT_STORE_PROV_PHYSICAL          = CERT_STORE_PROV_PHYSICAL_W
   315  	CERT_STORE_PROV_SMART_CARD_W      = 15
   316  	CERT_STORE_PROV_SMART_CARD        = CERT_STORE_PROV_SMART_CARD_W
   317  	CERT_STORE_PROV_LDAP_W            = 16
   318  	CERT_STORE_PROV_LDAP              = CERT_STORE_PROV_LDAP_W
   319  	CERT_STORE_PROV_PKCS12            = 17
   320  
   321  	/* store characteristics (low WORD of flag) for CertOpenStore function */
   322  	CERT_STORE_NO_CRYPT_RELEASE_FLAG            = 0x00000001
   323  	CERT_STORE_SET_LOCALIZED_NAME_FLAG          = 0x00000002
   324  	CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004
   325  	CERT_STORE_DELETE_FLAG                      = 0x00000010
   326  	CERT_STORE_UNSAFE_PHYSICAL_FLAG             = 0x00000020
   327  	CERT_STORE_SHARE_STORE_FLAG                 = 0x00000040
   328  	CERT_STORE_SHARE_CONTEXT_FLAG               = 0x00000080
   329  	CERT_STORE_MANIFOLD_FLAG                    = 0x00000100
   330  	CERT_STORE_ENUM_ARCHIVED_FLAG               = 0x00000200
   331  	CERT_STORE_UPDATE_KEYID_FLAG                = 0x00000400
   332  	CERT_STORE_BACKUP_RESTORE_FLAG              = 0x00000800
   333  	CERT_STORE_MAXIMUM_ALLOWED_FLAG             = 0x00001000
   334  	CERT_STORE_CREATE_NEW_FLAG                  = 0x00002000
   335  	CERT_STORE_OPEN_EXISTING_FLAG               = 0x00004000
   336  	CERT_STORE_READONLY_FLAG                    = 0x00008000
   337  
   338  	/* store locations (high WORD of flag) for CertOpenStore function */
   339  	CERT_SYSTEM_STORE_CURRENT_USER               = 0x00010000
   340  	CERT_SYSTEM_STORE_LOCAL_MACHINE              = 0x00020000
   341  	CERT_SYSTEM_STORE_CURRENT_SERVICE            = 0x00040000
   342  	CERT_SYSTEM_STORE_SERVICES                   = 0x00050000
   343  	CERT_SYSTEM_STORE_USERS                      = 0x00060000
   344  	CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY  = 0x00070000
   345  	CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = 0x00080000
   346  	CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE   = 0x00090000
   347  	CERT_SYSTEM_STORE_UNPROTECTED_FLAG           = 0x40000000
   348  	CERT_SYSTEM_STORE_RELOCATE_FLAG              = 0x80000000
   349  
   350  	/* Miscellaneous high-WORD flags for CertOpenStore function */
   351  	CERT_REGISTRY_STORE_REMOTE_FLAG      = 0x00010000
   352  	CERT_REGISTRY_STORE_SERIALIZED_FLAG  = 0x00020000
   353  	CERT_REGISTRY_STORE_ROAMING_FLAG     = 0x00040000
   354  	CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG = 0x00080000
   355  	CERT_REGISTRY_STORE_LM_GPT_FLAG      = 0x01000000
   356  	CERT_REGISTRY_STORE_CLIENT_GPT_FLAG  = 0x80000000
   357  	CERT_FILE_STORE_COMMIT_ENABLE_FLAG   = 0x00010000
   358  	CERT_LDAP_STORE_SIGN_FLAG            = 0x00010000
   359  	CERT_LDAP_STORE_AREC_EXCLUSIVE_FLAG  = 0x00020000
   360  	CERT_LDAP_STORE_OPENED_FLAG          = 0x00040000
   361  	CERT_LDAP_STORE_UNBIND_FLAG          = 0x00080000
   362  
   363  	/* addDisposition values for CertAddCertificateContextToStore function */
   364  	CERT_STORE_ADD_NEW                                 = 1
   365  	CERT_STORE_ADD_USE_EXISTING                        = 2
   366  	CERT_STORE_ADD_REPLACE_EXISTING                    = 3
   367  	CERT_STORE_ADD_ALWAYS                              = 4
   368  	CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5
   369  	CERT_STORE_ADD_NEWER                               = 6
   370  	CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES            = 7
   371  
   372  	/* ErrorStatus values for CertTrustStatus struct */
   373  	CERT_TRUST_NO_ERROR                          = 0x00000000
   374  	CERT_TRUST_IS_NOT_TIME_VALID                 = 0x00000001
   375  	CERT_TRUST_IS_REVOKED                        = 0x00000004
   376  	CERT_TRUST_IS_NOT_SIGNATURE_VALID            = 0x00000008
   377  	CERT_TRUST_IS_NOT_VALID_FOR_USAGE            = 0x00000010
   378  	CERT_TRUST_IS_UNTRUSTED_ROOT                 = 0x00000020
   379  	CERT_TRUST_REVOCATION_STATUS_UNKNOWN         = 0x00000040
   380  	CERT_TRUST_IS_CYCLIC                         = 0x00000080
   381  	CERT_TRUST_INVALID_EXTENSION                 = 0x00000100
   382  	CERT_TRUST_INVALID_POLICY_CONSTRAINTS        = 0x00000200
   383  	CERT_TRUST_INVALID_BASIC_CONSTRAINTS         = 0x00000400
   384  	CERT_TRUST_INVALID_NAME_CONSTRAINTS          = 0x00000800
   385  	CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000
   386  	CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT   = 0x00002000
   387  	CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000
   388  	CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT      = 0x00008000
   389  	CERT_TRUST_IS_PARTIAL_CHAIN                  = 0x00010000
   390  	CERT_TRUST_CTL_IS_NOT_TIME_VALID             = 0x00020000
   391  	CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID        = 0x00040000
   392  	CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE        = 0x00080000
   393  	CERT_TRUST_HAS_WEAK_SIGNATURE                = 0x00100000
   394  	CERT_TRUST_IS_OFFLINE_REVOCATION             = 0x01000000
   395  	CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY          = 0x02000000
   396  	CERT_TRUST_IS_EXPLICIT_DISTRUST              = 0x04000000
   397  	CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT    = 0x08000000
   398  
   399  	/* InfoStatus values for CertTrustStatus struct */
   400  	CERT_TRUST_HAS_EXACT_MATCH_ISSUER        = 0x00000001
   401  	CERT_TRUST_HAS_KEY_MATCH_ISSUER          = 0x00000002
   402  	CERT_TRUST_HAS_NAME_MATCH_ISSUER         = 0x00000004
   403  	CERT_TRUST_IS_SELF_SIGNED                = 0x00000008
   404  	CERT_TRUST_HAS_PREFERRED_ISSUER          = 0x00000100
   405  	CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY     = 0x00000400
   406  	CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS    = 0x00000400
   407  	CERT_TRUST_IS_PEER_TRUSTED               = 0x00000800
   408  	CERT_TRUST_HAS_CRL_VALIDITY_EXTENDED     = 0x00001000
   409  	CERT_TRUST_IS_FROM_EXCLUSIVE_TRUST_STORE = 0x00002000
   410  	CERT_TRUST_IS_CA_TRUSTED                 = 0x00004000
   411  	CERT_TRUST_IS_COMPLEX_CHAIN              = 0x00010000
   412  
   413  	/* policyOID values for CertVerifyCertificateChainPolicy function */
   414  	CERT_CHAIN_POLICY_BASE              = 1
   415  	CERT_CHAIN_POLICY_AUTHENTICODE      = 2
   416  	CERT_CHAIN_POLICY_AUTHENTICODE_TS   = 3
   417  	CERT_CHAIN_POLICY_SSL               = 4
   418  	CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5
   419  	CERT_CHAIN_POLICY_NT_AUTH           = 6
   420  	CERT_CHAIN_POLICY_MICROSOFT_ROOT    = 7
   421  	CERT_CHAIN_POLICY_EV                = 8
   422  	CERT_CHAIN_POLICY_SSL_F12           = 9
   423  
   424  	/* AuthType values for SSLExtraCertChainPolicyPara struct */
   425  	AUTHTYPE_CLIENT = 1
   426  	AUTHTYPE_SERVER = 2
   427  
   428  	/* Checks values for SSLExtraCertChainPolicyPara struct */
   429  	SECURITY_FLAG_IGNORE_REVOCATION        = 0x00000080
   430  	SECURITY_FLAG_IGNORE_UNKNOWN_CA        = 0x00000100
   431  	SECURITY_FLAG_IGNORE_WRONG_USAGE       = 0x00000200
   432  	SECURITY_FLAG_IGNORE_CERT_CN_INVALID   = 0x00001000
   433  	SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000
   434  )
   435  
   436  const (
   437  	// flags for SetErrorMode
   438  	SEM_FAILCRITICALERRORS     = 0x0001
   439  	SEM_NOALIGNMENTFAULTEXCEPT = 0x0004
   440  	SEM_NOGPFAULTERRORBOX      = 0x0002
   441  	SEM_NOOPENFILEERRORBOX     = 0x8000
   442  )
   443  
   444  const (
   445  	// Priority class.
   446  	ABOVE_NORMAL_PRIORITY_CLASS   = 0x00008000
   447  	BELOW_NORMAL_PRIORITY_CLASS   = 0x00004000
   448  	HIGH_PRIORITY_CLASS           = 0x00000080
   449  	IDLE_PRIORITY_CLASS           = 0x00000040
   450  	NORMAL_PRIORITY_CLASS         = 0x00000020
   451  	PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000
   452  	PROCESS_MODE_BACKGROUND_END   = 0x00200000
   453  	REALTIME_PRIORITY_CLASS       = 0x00000100
   454  )
   455  
   456  var (
   457  	OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00")
   458  	OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00")
   459  	OID_SGC_NETSCAPE        = []byte("2.16.840.1.113730.4.1\x00")
   460  )
   461  
   462  // Pointer represents a pointer to an arbitrary Windows type.
   463  //
   464  // Pointer-typed fields may point to one of many different types. It's
   465  // up to the caller to provide a pointer to the appropriate type, cast
   466  // to Pointer. The caller must obey the unsafe.Pointer rules while
   467  // doing so.
   468  type Pointer *struct{}
   469  
   470  // Invented values to support what package os expects.
   471  type Timeval struct {
   472  	Sec  int32
   473  	Usec int32
   474  }
   475  
   476  func (tv *Timeval) Nanoseconds() int64 {
   477  	return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3
   478  }
   479  
   480  func NsecToTimeval(nsec int64) (tv Timeval) {
   481  	tv.Sec = int32(nsec / 1e9)
   482  	tv.Usec = int32(nsec % 1e9 / 1e3)
   483  	return
   484  }
   485  
   486  type SecurityAttributes struct {
   487  	Length             uint32
   488  	SecurityDescriptor uintptr
   489  	InheritHandle      uint32
   490  }
   491  
   492  type Overlapped struct {
   493  	Internal     uintptr
   494  	InternalHigh uintptr
   495  	Offset       uint32
   496  	OffsetHigh   uint32
   497  	HEvent       Handle
   498  }
   499  
   500  type FileNotifyInformation struct {
   501  	NextEntryOffset uint32
   502  	Action          uint32
   503  	FileNameLength  uint32
   504  	FileName        uint16
   505  }
   506  
   507  type Filetime struct {
   508  	LowDateTime  uint32
   509  	HighDateTime uint32
   510  }
   511  
   512  // Nanoseconds returns Filetime ft in nanoseconds
   513  // since Epoch (00:00:00 UTC, January 1, 1970).
   514  func (ft *Filetime) Nanoseconds() int64 {
   515  	// 100-nanosecond intervals since January 1, 1601
   516  	nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)
   517  	// change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
   518  	nsec -= 116444736000000000
   519  	// convert into nanoseconds
   520  	nsec *= 100
   521  	return nsec
   522  }
   523  
   524  func NsecToFiletime(nsec int64) (ft Filetime) {
   525  	// convert into 100-nanosecond
   526  	nsec /= 100
   527  	// change starting time to January 1, 1601
   528  	nsec += 116444736000000000
   529  	// split into high / low
   530  	ft.LowDateTime = uint32(nsec & 0xffffffff)
   531  	ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff)
   532  	return ft
   533  }
   534  
   535  type Win32finddata struct {
   536  	FileAttributes    uint32
   537  	CreationTime      Filetime
   538  	LastAccessTime    Filetime
   539  	LastWriteTime     Filetime
   540  	FileSizeHigh      uint32
   541  	FileSizeLow       uint32
   542  	Reserved0         uint32
   543  	Reserved1         uint32
   544  	FileName          [MAX_PATH - 1]uint16
   545  	AlternateFileName [13]uint16
   546  }
   547  
   548  // This is the actual system call structure.
   549  // Win32finddata is what we committed to in Go 1.
   550  type win32finddata1 struct {
   551  	FileAttributes    uint32
   552  	CreationTime      Filetime
   553  	LastAccessTime    Filetime
   554  	LastWriteTime     Filetime
   555  	FileSizeHigh      uint32
   556  	FileSizeLow       uint32
   557  	Reserved0         uint32
   558  	Reserved1         uint32
   559  	FileName          [MAX_PATH]uint16
   560  	AlternateFileName [14]uint16
   561  }
   562  
   563  func copyFindData(dst *Win32finddata, src *win32finddata1) {
   564  	dst.FileAttributes = src.FileAttributes
   565  	dst.CreationTime = src.CreationTime
   566  	dst.LastAccessTime = src.LastAccessTime
   567  	dst.LastWriteTime = src.LastWriteTime
   568  	dst.FileSizeHigh = src.FileSizeHigh
   569  	dst.FileSizeLow = src.FileSizeLow
   570  	dst.Reserved0 = src.Reserved0
   571  	dst.Reserved1 = src.Reserved1
   572  
   573  	// The src is 1 element bigger than dst, but it must be NUL.
   574  	copy(dst.FileName[:], src.FileName[:])
   575  	copy(dst.AlternateFileName[:], src.AlternateFileName[:])
   576  }
   577  
   578  type ByHandleFileInformation struct {
   579  	FileAttributes     uint32
   580  	CreationTime       Filetime
   581  	LastAccessTime     Filetime
   582  	LastWriteTime      Filetime
   583  	VolumeSerialNumber uint32
   584  	FileSizeHigh       uint32
   585  	FileSizeLow        uint32
   586  	NumberOfLinks      uint32
   587  	FileIndexHigh      uint32
   588  	FileIndexLow       uint32
   589  }
   590  
   591  const (
   592  	GetFileExInfoStandard = 0
   593  	GetFileExMaxInfoLevel = 1
   594  )
   595  
   596  type Win32FileAttributeData struct {
   597  	FileAttributes uint32
   598  	CreationTime   Filetime
   599  	LastAccessTime Filetime
   600  	LastWriteTime  Filetime
   601  	FileSizeHigh   uint32
   602  	FileSizeLow    uint32
   603  }
   604  
   605  // ShowWindow constants
   606  const (
   607  	// winuser.h
   608  	SW_HIDE            = 0
   609  	SW_NORMAL          = 1
   610  	SW_SHOWNORMAL      = 1
   611  	SW_SHOWMINIMIZED   = 2
   612  	SW_SHOWMAXIMIZED   = 3
   613  	SW_MAXIMIZE        = 3
   614  	SW_SHOWNOACTIVATE  = 4
   615  	SW_SHOW            = 5
   616  	SW_MINIMIZE        = 6
   617  	SW_SHOWMINNOACTIVE = 7
   618  	SW_SHOWNA          = 8
   619  	SW_RESTORE         = 9
   620  	SW_SHOWDEFAULT     = 10
   621  	SW_FORCEMINIMIZE   = 11
   622  )
   623  
   624  type StartupInfo struct {
   625  	Cb            uint32
   626  	_             *uint16
   627  	Desktop       *uint16
   628  	Title         *uint16
   629  	X             uint32
   630  	Y             uint32
   631  	XSize         uint32
   632  	YSize         uint32
   633  	XCountChars   uint32
   634  	YCountChars   uint32
   635  	FillAttribute uint32
   636  	Flags         uint32
   637  	ShowWindow    uint16
   638  	_             uint16
   639  	_             *byte
   640  	StdInput      Handle
   641  	StdOutput     Handle
   642  	StdErr        Handle
   643  }
   644  
   645  type ProcessInformation struct {
   646  	Process   Handle
   647  	Thread    Handle
   648  	ProcessId uint32
   649  	ThreadId  uint32
   650  }
   651  
   652  type ProcessEntry32 struct {
   653  	Size            uint32
   654  	Usage           uint32
   655  	ProcessID       uint32
   656  	DefaultHeapID   uintptr
   657  	ModuleID        uint32
   658  	Threads         uint32
   659  	ParentProcessID uint32
   660  	PriClassBase    int32
   661  	Flags           uint32
   662  	ExeFile         [MAX_PATH]uint16
   663  }
   664  
   665  type ThreadEntry32 struct {
   666  	Size           uint32
   667  	Usage          uint32
   668  	ThreadID       uint32
   669  	OwnerProcessID uint32
   670  	BasePri        int32
   671  	DeltaPri       int32
   672  	Flags          uint32
   673  }
   674  
   675  type Systemtime struct {
   676  	Year         uint16
   677  	Month        uint16
   678  	DayOfWeek    uint16
   679  	Day          uint16
   680  	Hour         uint16
   681  	Minute       uint16
   682  	Second       uint16
   683  	Milliseconds uint16
   684  }
   685  
   686  type Timezoneinformation struct {
   687  	Bias         int32
   688  	StandardName [32]uint16
   689  	StandardDate Systemtime
   690  	StandardBias int32
   691  	DaylightName [32]uint16
   692  	DaylightDate Systemtime
   693  	DaylightBias int32
   694  }
   695  
   696  // Socket related.
   697  
   698  const (
   699  	AF_UNSPEC  = 0
   700  	AF_UNIX    = 1
   701  	AF_INET    = 2
   702  	AF_INET6   = 23
   703  	AF_NETBIOS = 17
   704  
   705  	SOCK_STREAM    = 1
   706  	SOCK_DGRAM     = 2
   707  	SOCK_RAW       = 3
   708  	SOCK_SEQPACKET = 5
   709  
   710  	IPPROTO_IP   = 0
   711  	IPPROTO_IPV6 = 0x29
   712  	IPPROTO_TCP  = 6
   713  	IPPROTO_UDP  = 17
   714  
   715  	SOL_SOCKET                = 0xffff
   716  	SO_REUSEADDR              = 4
   717  	SO_KEEPALIVE              = 8
   718  	SO_DONTROUTE              = 16
   719  	SO_BROADCAST              = 32
   720  	SO_LINGER                 = 128
   721  	SO_RCVBUF                 = 0x1002
   722  	SO_SNDBUF                 = 0x1001
   723  	SO_UPDATE_ACCEPT_CONTEXT  = 0x700b
   724  	SO_UPDATE_CONNECT_CONTEXT = 0x7010
   725  
   726  	IOC_OUT                            = 0x40000000
   727  	IOC_IN                             = 0x80000000
   728  	IOC_VENDOR                         = 0x18000000
   729  	IOC_INOUT                          = IOC_IN | IOC_OUT
   730  	IOC_WS2                            = 0x08000000
   731  	SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6
   732  	SIO_KEEPALIVE_VALS                 = IOC_IN | IOC_VENDOR | 4
   733  	SIO_UDP_CONNRESET                  = IOC_IN | IOC_VENDOR | 12
   734  
   735  	// cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460
   736  
   737  	IP_TOS             = 0x3
   738  	IP_TTL             = 0x4
   739  	IP_MULTICAST_IF    = 0x9
   740  	IP_MULTICAST_TTL   = 0xa
   741  	IP_MULTICAST_LOOP  = 0xb
   742  	IP_ADD_MEMBERSHIP  = 0xc
   743  	IP_DROP_MEMBERSHIP = 0xd
   744  
   745  	IPV6_V6ONLY         = 0x1b
   746  	IPV6_UNICAST_HOPS   = 0x4
   747  	IPV6_MULTICAST_IF   = 0x9
   748  	IPV6_MULTICAST_HOPS = 0xa
   749  	IPV6_MULTICAST_LOOP = 0xb
   750  	IPV6_JOIN_GROUP     = 0xc
   751  	IPV6_LEAVE_GROUP    = 0xd
   752  
   753  	MSG_OOB       = 0x1
   754  	MSG_PEEK      = 0x2
   755  	MSG_DONTROUTE = 0x4
   756  	MSG_WAITALL   = 0x8
   757  
   758  	MSG_TRUNC  = 0x0100
   759  	MSG_CTRUNC = 0x0200
   760  	MSG_BCAST  = 0x0400
   761  	MSG_MCAST  = 0x0800
   762  
   763  	SOMAXCONN = 0x7fffffff
   764  
   765  	TCP_NODELAY = 1
   766  
   767  	SHUT_RD   = 0
   768  	SHUT_WR   = 1
   769  	SHUT_RDWR = 2
   770  
   771  	WSADESCRIPTION_LEN = 256
   772  	WSASYS_STATUS_LEN  = 128
   773  )
   774  
   775  type WSABuf struct {
   776  	Len uint32
   777  	Buf *byte
   778  }
   779  
   780  type WSAMsg struct {
   781  	Name        *syscall.RawSockaddrAny
   782  	Namelen     int32
   783  	Buffers     *WSABuf
   784  	BufferCount uint32
   785  	Control     WSABuf
   786  	Flags       uint32
   787  }
   788  
   789  // Invented values to support what package os expects.
   790  const (
   791  	S_IFMT   = 0x1f000
   792  	S_IFIFO  = 0x1000
   793  	S_IFCHR  = 0x2000
   794  	S_IFDIR  = 0x4000
   795  	S_IFBLK  = 0x6000
   796  	S_IFREG  = 0x8000
   797  	S_IFLNK  = 0xa000
   798  	S_IFSOCK = 0xc000
   799  	S_ISUID  = 0x800
   800  	S_ISGID  = 0x400
   801  	S_ISVTX  = 0x200
   802  	S_IRUSR  = 0x100
   803  	S_IWRITE = 0x80
   804  	S_IWUSR  = 0x80
   805  	S_IXUSR  = 0x40
   806  )
   807  
   808  const (
   809  	FILE_TYPE_CHAR    = 0x0002
   810  	FILE_TYPE_DISK    = 0x0001
   811  	FILE_TYPE_PIPE    = 0x0003
   812  	FILE_TYPE_REMOTE  = 0x8000
   813  	FILE_TYPE_UNKNOWN = 0x0000
   814  )
   815  
   816  type Hostent struct {
   817  	Name     *byte
   818  	Aliases  **byte
   819  	AddrType uint16
   820  	Length   uint16
   821  	AddrList **byte
   822  }
   823  
   824  type Protoent struct {
   825  	Name    *byte
   826  	Aliases **byte
   827  	Proto   uint16
   828  }
   829  
   830  const (
   831  	DNS_TYPE_A       = 0x0001
   832  	DNS_TYPE_NS      = 0x0002
   833  	DNS_TYPE_MD      = 0x0003
   834  	DNS_TYPE_MF      = 0x0004
   835  	DNS_TYPE_CNAME   = 0x0005
   836  	DNS_TYPE_SOA     = 0x0006
   837  	DNS_TYPE_MB      = 0x0007
   838  	DNS_TYPE_MG      = 0x0008
   839  	DNS_TYPE_MR      = 0x0009
   840  	DNS_TYPE_NULL    = 0x000a
   841  	DNS_TYPE_WKS     = 0x000b
   842  	DNS_TYPE_PTR     = 0x000c
   843  	DNS_TYPE_HINFO   = 0x000d
   844  	DNS_TYPE_MINFO   = 0x000e
   845  	DNS_TYPE_MX      = 0x000f
   846  	DNS_TYPE_TEXT    = 0x0010
   847  	DNS_TYPE_RP      = 0x0011
   848  	DNS_TYPE_AFSDB   = 0x0012
   849  	DNS_TYPE_X25     = 0x0013
   850  	DNS_TYPE_ISDN    = 0x0014
   851  	DNS_TYPE_RT      = 0x0015
   852  	DNS_TYPE_NSAP    = 0x0016
   853  	DNS_TYPE_NSAPPTR = 0x0017
   854  	DNS_TYPE_SIG     = 0x0018
   855  	DNS_TYPE_KEY     = 0x0019
   856  	DNS_TYPE_PX      = 0x001a
   857  	DNS_TYPE_GPOS    = 0x001b
   858  	DNS_TYPE_AAAA    = 0x001c
   859  	DNS_TYPE_LOC     = 0x001d
   860  	DNS_TYPE_NXT     = 0x001e
   861  	DNS_TYPE_EID     = 0x001f
   862  	DNS_TYPE_NIMLOC  = 0x0020
   863  	DNS_TYPE_SRV     = 0x0021
   864  	DNS_TYPE_ATMA    = 0x0022
   865  	DNS_TYPE_NAPTR   = 0x0023
   866  	DNS_TYPE_KX      = 0x0024
   867  	DNS_TYPE_CERT    = 0x0025
   868  	DNS_TYPE_A6      = 0x0026
   869  	DNS_TYPE_DNAME   = 0x0027
   870  	DNS_TYPE_SINK    = 0x0028
   871  	DNS_TYPE_OPT     = 0x0029
   872  	DNS_TYPE_DS      = 0x002B
   873  	DNS_TYPE_RRSIG   = 0x002E
   874  	DNS_TYPE_NSEC    = 0x002F
   875  	DNS_TYPE_DNSKEY  = 0x0030
   876  	DNS_TYPE_DHCID   = 0x0031
   877  	DNS_TYPE_UINFO   = 0x0064
   878  	DNS_TYPE_UID     = 0x0065
   879  	DNS_TYPE_GID     = 0x0066
   880  	DNS_TYPE_UNSPEC  = 0x0067
   881  	DNS_TYPE_ADDRS   = 0x00f8
   882  	DNS_TYPE_TKEY    = 0x00f9
   883  	DNS_TYPE_TSIG    = 0x00fa
   884  	DNS_TYPE_IXFR    = 0x00fb
   885  	DNS_TYPE_AXFR    = 0x00fc
   886  	DNS_TYPE_MAILB   = 0x00fd
   887  	DNS_TYPE_MAILA   = 0x00fe
   888  	DNS_TYPE_ALL     = 0x00ff
   889  	DNS_TYPE_ANY     = 0x00ff
   890  	DNS_TYPE_WINS    = 0xff01
   891  	DNS_TYPE_WINSR   = 0xff02
   892  	DNS_TYPE_NBSTAT  = 0xff01
   893  )
   894  
   895  const (
   896  	// flags inside DNSRecord.Dw
   897  	DnsSectionQuestion   = 0x0000
   898  	DnsSectionAnswer     = 0x0001
   899  	DnsSectionAuthority  = 0x0002
   900  	DnsSectionAdditional = 0x0003
   901  )
   902  
   903  type DNSSRVData struct {
   904  	Target   *uint16
   905  	Priority uint16
   906  	Weight   uint16
   907  	Port     uint16
   908  	Pad      uint16
   909  }
   910  
   911  type DNSPTRData struct {
   912  	Host *uint16
   913  }
   914  
   915  type DNSMXData struct {
   916  	NameExchange *uint16
   917  	Preference   uint16
   918  	Pad          uint16
   919  }
   920  
   921  type DNSTXTData struct {
   922  	StringCount uint16
   923  	StringArray [1]*uint16
   924  }
   925  
   926  type DNSRecord struct {
   927  	Next     *DNSRecord
   928  	Name     *uint16
   929  	Type     uint16
   930  	Length   uint16
   931  	Dw       uint32
   932  	Ttl      uint32
   933  	Reserved uint32
   934  	Data     [40]byte
   935  }
   936  
   937  const (
   938  	TF_DISCONNECT         = 1
   939  	TF_REUSE_SOCKET       = 2
   940  	TF_WRITE_BEHIND       = 4
   941  	TF_USE_DEFAULT_WORKER = 0
   942  	TF_USE_SYSTEM_THREAD  = 16
   943  	TF_USE_KERNEL_APC     = 32
   944  )
   945  
   946  type TransmitFileBuffers struct {
   947  	Head       uintptr
   948  	HeadLength uint32
   949  	Tail       uintptr
   950  	TailLength uint32
   951  }
   952  
   953  const (
   954  	IFF_UP           = 1
   955  	IFF_BROADCAST    = 2
   956  	IFF_LOOPBACK     = 4
   957  	IFF_POINTTOPOINT = 8
   958  	IFF_MULTICAST    = 16
   959  )
   960  
   961  const SIO_GET_INTERFACE_LIST = 0x4004747F
   962  
   963  // TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old.
   964  // will be fixed to change variable type as suitable.
   965  
   966  type SockaddrGen [24]byte
   967  
   968  type InterfaceInfo struct {
   969  	Flags            uint32
   970  	Address          SockaddrGen
   971  	BroadcastAddress SockaddrGen
   972  	Netmask          SockaddrGen
   973  }
   974  
   975  type IpAddressString struct {
   976  	String [16]byte
   977  }
   978  
   979  type IpMaskString IpAddressString
   980  
   981  type IpAddrString struct {
   982  	Next      *IpAddrString
   983  	IpAddress IpAddressString
   984  	IpMask    IpMaskString
   985  	Context   uint32
   986  }
   987  
   988  const MAX_ADAPTER_NAME_LENGTH = 256
   989  const MAX_ADAPTER_DESCRIPTION_LENGTH = 128
   990  const MAX_ADAPTER_ADDRESS_LENGTH = 8
   991  
   992  type IpAdapterInfo struct {
   993  	Next                *IpAdapterInfo
   994  	ComboIndex          uint32
   995  	AdapterName         [MAX_ADAPTER_NAME_LENGTH + 4]byte
   996  	Description         [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte
   997  	AddressLength       uint32
   998  	Address             [MAX_ADAPTER_ADDRESS_LENGTH]byte
   999  	Index               uint32
  1000  	Type                uint32
  1001  	DhcpEnabled         uint32
  1002  	CurrentIpAddress    *IpAddrString
  1003  	IpAddressList       IpAddrString
  1004  	GatewayList         IpAddrString
  1005  	DhcpServer          IpAddrString
  1006  	HaveWins            bool
  1007  	PrimaryWinsServer   IpAddrString
  1008  	SecondaryWinsServer IpAddrString
  1009  	LeaseObtained       int64
  1010  	LeaseExpires        int64
  1011  }
  1012  
  1013  const MAXLEN_PHYSADDR = 8
  1014  const MAX_INTERFACE_NAME_LEN = 256
  1015  const MAXLEN_IFDESCR = 256
  1016  
  1017  type MibIfRow struct {
  1018  	Name            [MAX_INTERFACE_NAME_LEN]uint16
  1019  	Index           uint32
  1020  	Type            uint32
  1021  	Mtu             uint32
  1022  	Speed           uint32
  1023  	PhysAddrLen     uint32
  1024  	PhysAddr        [MAXLEN_PHYSADDR]byte
  1025  	AdminStatus     uint32
  1026  	OperStatus      uint32
  1027  	LastChange      uint32
  1028  	InOctets        uint32
  1029  	InUcastPkts     uint32
  1030  	InNUcastPkts    uint32
  1031  	InDiscards      uint32
  1032  	InErrors        uint32
  1033  	InUnknownProtos uint32
  1034  	OutOctets       uint32
  1035  	OutUcastPkts    uint32
  1036  	OutNUcastPkts   uint32
  1037  	OutDiscards     uint32
  1038  	OutErrors       uint32
  1039  	OutQLen         uint32
  1040  	DescrLen        uint32
  1041  	Descr           [MAXLEN_IFDESCR]byte
  1042  }
  1043  
  1044  type CertInfo struct {
  1045  	// Not implemented
  1046  }
  1047  
  1048  type CertContext struct {
  1049  	EncodingType uint32
  1050  	EncodedCert  *byte
  1051  	Length       uint32
  1052  	CertInfo     *CertInfo
  1053  	Store        Handle
  1054  }
  1055  
  1056  type CertChainContext struct {
  1057  	Size                       uint32
  1058  	TrustStatus                CertTrustStatus
  1059  	ChainCount                 uint32
  1060  	Chains                     **CertSimpleChain
  1061  	LowerQualityChainCount     uint32
  1062  	LowerQualityChains         **CertChainContext
  1063  	HasRevocationFreshnessTime uint32
  1064  	RevocationFreshnessTime    uint32
  1065  }
  1066  
  1067  type CertTrustListInfo struct {
  1068  	// Not implemented
  1069  }
  1070  
  1071  type CertSimpleChain struct {
  1072  	Size                       uint32
  1073  	TrustStatus                CertTrustStatus
  1074  	NumElements                uint32
  1075  	Elements                   **CertChainElement
  1076  	TrustListInfo              *CertTrustListInfo
  1077  	HasRevocationFreshnessTime uint32
  1078  	RevocationFreshnessTime    uint32
  1079  }
  1080  
  1081  type CertChainElement struct {
  1082  	Size              uint32
  1083  	CertContext       *CertContext
  1084  	TrustStatus       CertTrustStatus
  1085  	RevocationInfo    *CertRevocationInfo
  1086  	IssuanceUsage     *CertEnhKeyUsage
  1087  	ApplicationUsage  *CertEnhKeyUsage
  1088  	ExtendedErrorInfo *uint16
  1089  }
  1090  
  1091  type CertRevocationCrlInfo struct {
  1092  	// Not implemented
  1093  }
  1094  
  1095  type CertRevocationInfo struct {
  1096  	Size             uint32
  1097  	RevocationResult uint32
  1098  	RevocationOid    *byte
  1099  	OidSpecificInfo  Pointer
  1100  	HasFreshnessTime uint32
  1101  	FreshnessTime    uint32
  1102  	CrlInfo          *CertRevocationCrlInfo
  1103  }
  1104  
  1105  type CertTrustStatus struct {
  1106  	ErrorStatus uint32
  1107  	InfoStatus  uint32
  1108  }
  1109  
  1110  type CertUsageMatch struct {
  1111  	Type  uint32
  1112  	Usage CertEnhKeyUsage
  1113  }
  1114  
  1115  type CertEnhKeyUsage struct {
  1116  	Length           uint32
  1117  	UsageIdentifiers **byte
  1118  }
  1119  
  1120  type CertChainPara struct {
  1121  	Size                         uint32
  1122  	RequestedUsage               CertUsageMatch
  1123  	RequstedIssuancePolicy       CertUsageMatch
  1124  	URLRetrievalTimeout          uint32
  1125  	CheckRevocationFreshnessTime uint32
  1126  	RevocationFreshnessTime      uint32
  1127  	CacheResync                  *Filetime
  1128  }
  1129  
  1130  type CertChainPolicyPara struct {
  1131  	Size            uint32
  1132  	Flags           uint32
  1133  	ExtraPolicyPara Pointer
  1134  }
  1135  
  1136  type SSLExtraCertChainPolicyPara struct {
  1137  	Size       uint32
  1138  	AuthType   uint32
  1139  	Checks     uint32
  1140  	ServerName *uint16
  1141  }
  1142  
  1143  type CertChainPolicyStatus struct {
  1144  	Size              uint32
  1145  	Error             uint32
  1146  	ChainIndex        uint32
  1147  	ElementIndex      uint32
  1148  	ExtraPolicyStatus Pointer
  1149  }
  1150  
  1151  const (
  1152  	// do not reorder
  1153  	HKEY_CLASSES_ROOT = 0x80000000 + iota
  1154  	HKEY_CURRENT_USER
  1155  	HKEY_LOCAL_MACHINE
  1156  	HKEY_USERS
  1157  	HKEY_PERFORMANCE_DATA
  1158  	HKEY_CURRENT_CONFIG
  1159  	HKEY_DYN_DATA
  1160  
  1161  	KEY_QUERY_VALUE        = 1
  1162  	KEY_SET_VALUE          = 2
  1163  	KEY_CREATE_SUB_KEY     = 4
  1164  	KEY_ENUMERATE_SUB_KEYS = 8
  1165  	KEY_NOTIFY             = 16
  1166  	KEY_CREATE_LINK        = 32
  1167  	KEY_WRITE              = 0x20006
  1168  	KEY_EXECUTE            = 0x20019
  1169  	KEY_READ               = 0x20019
  1170  	KEY_WOW64_64KEY        = 0x0100
  1171  	KEY_WOW64_32KEY        = 0x0200
  1172  	KEY_ALL_ACCESS         = 0xf003f
  1173  )
  1174  
  1175  const (
  1176  	// do not reorder
  1177  	REG_NONE = iota
  1178  	REG_SZ
  1179  	REG_EXPAND_SZ
  1180  	REG_BINARY
  1181  	REG_DWORD_LITTLE_ENDIAN
  1182  	REG_DWORD_BIG_ENDIAN
  1183  	REG_LINK
  1184  	REG_MULTI_SZ
  1185  	REG_RESOURCE_LIST
  1186  	REG_FULL_RESOURCE_DESCRIPTOR
  1187  	REG_RESOURCE_REQUIREMENTS_LIST
  1188  	REG_QWORD_LITTLE_ENDIAN
  1189  	REG_DWORD = REG_DWORD_LITTLE_ENDIAN
  1190  	REG_QWORD = REG_QWORD_LITTLE_ENDIAN
  1191  )
  1192  
  1193  const (
  1194  	EVENT_MODIFY_STATE = 0x0002
  1195  	EVENT_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1196  
  1197  	MUTANT_QUERY_STATE = 0x0001
  1198  	MUTANT_ALL_ACCESS  = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE
  1199  
  1200  	SEMAPHORE_MODIFY_STATE = 0x0002
  1201  	SEMAPHORE_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1202  
  1203  	TIMER_QUERY_STATE  = 0x0001
  1204  	TIMER_MODIFY_STATE = 0x0002
  1205  	TIMER_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE | TIMER_MODIFY_STATE
  1206  
  1207  	MUTEX_MODIFY_STATE = MUTANT_QUERY_STATE
  1208  	MUTEX_ALL_ACCESS   = MUTANT_ALL_ACCESS
  1209  
  1210  	CREATE_EVENT_MANUAL_RESET  = 0x1
  1211  	CREATE_EVENT_INITIAL_SET   = 0x2
  1212  	CREATE_MUTEX_INITIAL_OWNER = 0x1
  1213  )
  1214  
  1215  type AddrinfoW struct {
  1216  	Flags     int32
  1217  	Family    int32
  1218  	Socktype  int32
  1219  	Protocol  int32
  1220  	Addrlen   uintptr
  1221  	Canonname *uint16
  1222  	Addr      uintptr
  1223  	Next      *AddrinfoW
  1224  }
  1225  
  1226  const (
  1227  	AI_PASSIVE     = 1
  1228  	AI_CANONNAME   = 2
  1229  	AI_NUMERICHOST = 4
  1230  )
  1231  
  1232  type GUID struct {
  1233  	Data1 uint32
  1234  	Data2 uint16
  1235  	Data3 uint16
  1236  	Data4 [8]byte
  1237  }
  1238  
  1239  var WSAID_CONNECTEX = GUID{
  1240  	0x25a207b9,
  1241  	0xddf3,
  1242  	0x4660,
  1243  	[8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e},
  1244  }
  1245  
  1246  var WSAID_WSASENDMSG = GUID{
  1247  	0xa441e712,
  1248  	0x754f,
  1249  	0x43ca,
  1250  	[8]byte{0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d},
  1251  }
  1252  
  1253  var WSAID_WSARECVMSG = GUID{
  1254  	0xf689d7c8,
  1255  	0x6f1f,
  1256  	0x436b,
  1257  	[8]byte{0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22},
  1258  }
  1259  
  1260  const (
  1261  	FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
  1262  	FILE_SKIP_SET_EVENT_ON_HANDLE        = 2
  1263  )
  1264  
  1265  const (
  1266  	WSAPROTOCOL_LEN    = 255
  1267  	MAX_PROTOCOL_CHAIN = 7
  1268  	BASE_PROTOCOL      = 1
  1269  	LAYERED_PROTOCOL   = 0
  1270  
  1271  	XP1_CONNECTIONLESS           = 0x00000001
  1272  	XP1_GUARANTEED_DELIVERY      = 0x00000002
  1273  	XP1_GUARANTEED_ORDER         = 0x00000004
  1274  	XP1_MESSAGE_ORIENTED         = 0x00000008
  1275  	XP1_PSEUDO_STREAM            = 0x00000010
  1276  	XP1_GRACEFUL_CLOSE           = 0x00000020
  1277  	XP1_EXPEDITED_DATA           = 0x00000040
  1278  	XP1_CONNECT_DATA             = 0x00000080
  1279  	XP1_DISCONNECT_DATA          = 0x00000100
  1280  	XP1_SUPPORT_BROADCAST        = 0x00000200
  1281  	XP1_SUPPORT_MULTIPOINT       = 0x00000400
  1282  	XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800
  1283  	XP1_MULTIPOINT_DATA_PLANE    = 0x00001000
  1284  	XP1_QOS_SUPPORTED            = 0x00002000
  1285  	XP1_UNI_SEND                 = 0x00008000
  1286  	XP1_UNI_RECV                 = 0x00010000
  1287  	XP1_IFS_HANDLES              = 0x00020000
  1288  	XP1_PARTIAL_MESSAGE          = 0x00040000
  1289  	XP1_SAN_SUPPORT_SDP          = 0x00080000
  1290  
  1291  	PFL_MULTIPLE_PROTO_ENTRIES  = 0x00000001
  1292  	PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002
  1293  	PFL_HIDDEN                  = 0x00000004
  1294  	PFL_MATCHES_PROTOCOL_ZERO   = 0x00000008
  1295  	PFL_NETWORKDIRECT_PROVIDER  = 0x00000010
  1296  )
  1297  
  1298  type WSAProtocolInfo struct {
  1299  	ServiceFlags1     uint32
  1300  	ServiceFlags2     uint32
  1301  	ServiceFlags3     uint32
  1302  	ServiceFlags4     uint32
  1303  	ProviderFlags     uint32
  1304  	ProviderId        GUID
  1305  	CatalogEntryId    uint32
  1306  	ProtocolChain     WSAProtocolChain
  1307  	Version           int32
  1308  	AddressFamily     int32
  1309  	MaxSockAddr       int32
  1310  	MinSockAddr       int32
  1311  	SocketType        int32
  1312  	Protocol          int32
  1313  	ProtocolMaxOffset int32
  1314  	NetworkByteOrder  int32
  1315  	SecurityScheme    int32
  1316  	MessageSize       uint32
  1317  	ProviderReserved  uint32
  1318  	ProtocolName      [WSAPROTOCOL_LEN + 1]uint16
  1319  }
  1320  
  1321  type WSAProtocolChain struct {
  1322  	ChainLen     int32
  1323  	ChainEntries [MAX_PROTOCOL_CHAIN]uint32
  1324  }
  1325  
  1326  type TCPKeepalive struct {
  1327  	OnOff    uint32
  1328  	Time     uint32
  1329  	Interval uint32
  1330  }
  1331  
  1332  type symbolicLinkReparseBuffer struct {
  1333  	SubstituteNameOffset uint16
  1334  	SubstituteNameLength uint16
  1335  	PrintNameOffset      uint16
  1336  	PrintNameLength      uint16
  1337  	Flags                uint32
  1338  	PathBuffer           [1]uint16
  1339  }
  1340  
  1341  type mountPointReparseBuffer struct {
  1342  	SubstituteNameOffset uint16
  1343  	SubstituteNameLength uint16
  1344  	PrintNameOffset      uint16
  1345  	PrintNameLength      uint16
  1346  	PathBuffer           [1]uint16
  1347  }
  1348  
  1349  type reparseDataBuffer struct {
  1350  	ReparseTag        uint32
  1351  	ReparseDataLength uint16
  1352  	Reserved          uint16
  1353  
  1354  	// GenericReparseBuffer
  1355  	reparseBuffer byte
  1356  }
  1357  
  1358  const (
  1359  	FSCTL_GET_REPARSE_POINT          = 0x900A8
  1360  	MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
  1361  	IO_REPARSE_TAG_MOUNT_POINT       = 0xA0000003
  1362  	IO_REPARSE_TAG_SYMLINK           = 0xA000000C
  1363  	SYMBOLIC_LINK_FLAG_DIRECTORY     = 0x1
  1364  )
  1365  
  1366  const (
  1367  	ComputerNameNetBIOS                   = 0
  1368  	ComputerNameDnsHostname               = 1
  1369  	ComputerNameDnsDomain                 = 2
  1370  	ComputerNameDnsFullyQualified         = 3
  1371  	ComputerNamePhysicalNetBIOS           = 4
  1372  	ComputerNamePhysicalDnsHostname       = 5
  1373  	ComputerNamePhysicalDnsDomain         = 6
  1374  	ComputerNamePhysicalDnsFullyQualified = 7
  1375  	ComputerNameMax                       = 8
  1376  )
  1377  
  1378  // For MessageBox()
  1379  const (
  1380  	MB_OK                   = 0x00000000
  1381  	MB_OKCANCEL             = 0x00000001
  1382  	MB_ABORTRETRYIGNORE     = 0x00000002
  1383  	MB_YESNOCANCEL          = 0x00000003
  1384  	MB_YESNO                = 0x00000004
  1385  	MB_RETRYCANCEL          = 0x00000005
  1386  	MB_CANCELTRYCONTINUE    = 0x00000006
  1387  	MB_ICONHAND             = 0x00000010
  1388  	MB_ICONQUESTION         = 0x00000020
  1389  	MB_ICONEXCLAMATION      = 0x00000030
  1390  	MB_ICONASTERISK         = 0x00000040
  1391  	MB_USERICON             = 0x00000080
  1392  	MB_ICONWARNING          = MB_ICONEXCLAMATION
  1393  	MB_ICONERROR            = MB_ICONHAND
  1394  	MB_ICONINFORMATION      = MB_ICONASTERISK
  1395  	MB_ICONSTOP             = MB_ICONHAND
  1396  	MB_DEFBUTTON1           = 0x00000000
  1397  	MB_DEFBUTTON2           = 0x00000100
  1398  	MB_DEFBUTTON3           = 0x00000200
  1399  	MB_DEFBUTTON4           = 0x00000300
  1400  	MB_APPLMODAL            = 0x00000000
  1401  	MB_SYSTEMMODAL          = 0x00001000
  1402  	MB_TASKMODAL            = 0x00002000
  1403  	MB_HELP                 = 0x00004000
  1404  	MB_NOFOCUS              = 0x00008000
  1405  	MB_SETFOREGROUND        = 0x00010000
  1406  	MB_DEFAULT_DESKTOP_ONLY = 0x00020000
  1407  	MB_TOPMOST              = 0x00040000
  1408  	MB_RIGHT                = 0x00080000
  1409  	MB_RTLREADING           = 0x00100000
  1410  	MB_SERVICE_NOTIFICATION = 0x00200000
  1411  )
  1412  
  1413  const (
  1414  	MOVEFILE_REPLACE_EXISTING      = 0x1
  1415  	MOVEFILE_COPY_ALLOWED          = 0x2
  1416  	MOVEFILE_DELAY_UNTIL_REBOOT    = 0x4
  1417  	MOVEFILE_WRITE_THROUGH         = 0x8
  1418  	MOVEFILE_CREATE_HARDLINK       = 0x10
  1419  	MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20
  1420  )
  1421  
  1422  const GAA_FLAG_INCLUDE_PREFIX = 0x00000010
  1423  
  1424  const (
  1425  	IF_TYPE_OTHER              = 1
  1426  	IF_TYPE_ETHERNET_CSMACD    = 6
  1427  	IF_TYPE_ISO88025_TOKENRING = 9
  1428  	IF_TYPE_PPP                = 23
  1429  	IF_TYPE_SOFTWARE_LOOPBACK  = 24
  1430  	IF_TYPE_ATM                = 37
  1431  	IF_TYPE_IEEE80211          = 71
  1432  	IF_TYPE_TUNNEL             = 131
  1433  	IF_TYPE_IEEE1394           = 144
  1434  )
  1435  
  1436  type SocketAddress struct {
  1437  	Sockaddr       *syscall.RawSockaddrAny
  1438  	SockaddrLength int32
  1439  }
  1440  
  1441  // IP returns an IPv4 or IPv6 address, or nil if the underlying SocketAddress is neither.
  1442  func (addr *SocketAddress) IP() net.IP {
  1443  	if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet4{}) && addr.Sockaddr.Addr.Family == AF_INET {
  1444  		return (*RawSockaddrInet4)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  1445  	} else if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet6{}) && addr.Sockaddr.Addr.Family == AF_INET6 {
  1446  		return (*RawSockaddrInet6)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  1447  	}
  1448  	return nil
  1449  }
  1450  
  1451  type IpAdapterUnicastAddress struct {
  1452  	Length             uint32
  1453  	Flags              uint32
  1454  	Next               *IpAdapterUnicastAddress
  1455  	Address            SocketAddress
  1456  	PrefixOrigin       int32
  1457  	SuffixOrigin       int32
  1458  	DadState           int32
  1459  	ValidLifetime      uint32
  1460  	PreferredLifetime  uint32
  1461  	LeaseLifetime      uint32
  1462  	OnLinkPrefixLength uint8
  1463  }
  1464  
  1465  type IpAdapterAnycastAddress struct {
  1466  	Length  uint32
  1467  	Flags   uint32
  1468  	Next    *IpAdapterAnycastAddress
  1469  	Address SocketAddress
  1470  }
  1471  
  1472  type IpAdapterMulticastAddress struct {
  1473  	Length  uint32
  1474  	Flags   uint32
  1475  	Next    *IpAdapterMulticastAddress
  1476  	Address SocketAddress
  1477  }
  1478  
  1479  type IpAdapterDnsServerAdapter struct {
  1480  	Length   uint32
  1481  	Reserved uint32
  1482  	Next     *IpAdapterDnsServerAdapter
  1483  	Address  SocketAddress
  1484  }
  1485  
  1486  type IpAdapterPrefix struct {
  1487  	Length       uint32
  1488  	Flags        uint32
  1489  	Next         *IpAdapterPrefix
  1490  	Address      SocketAddress
  1491  	PrefixLength uint32
  1492  }
  1493  
  1494  type IpAdapterAddresses struct {
  1495  	Length                uint32
  1496  	IfIndex               uint32
  1497  	Next                  *IpAdapterAddresses
  1498  	AdapterName           *byte
  1499  	FirstUnicastAddress   *IpAdapterUnicastAddress
  1500  	FirstAnycastAddress   *IpAdapterAnycastAddress
  1501  	FirstMulticastAddress *IpAdapterMulticastAddress
  1502  	FirstDnsServerAddress *IpAdapterDnsServerAdapter
  1503  	DnsSuffix             *uint16
  1504  	Description           *uint16
  1505  	FriendlyName          *uint16
  1506  	PhysicalAddress       [syscall.MAX_ADAPTER_ADDRESS_LENGTH]byte
  1507  	PhysicalAddressLength uint32
  1508  	Flags                 uint32
  1509  	Mtu                   uint32
  1510  	IfType                uint32
  1511  	OperStatus            uint32
  1512  	Ipv6IfIndex           uint32
  1513  	ZoneIndices           [16]uint32
  1514  	FirstPrefix           *IpAdapterPrefix
  1515  	/* more fields might be present here. */
  1516  }
  1517  
  1518  const (
  1519  	IfOperStatusUp             = 1
  1520  	IfOperStatusDown           = 2
  1521  	IfOperStatusTesting        = 3
  1522  	IfOperStatusUnknown        = 4
  1523  	IfOperStatusDormant        = 5
  1524  	IfOperStatusNotPresent     = 6
  1525  	IfOperStatusLowerLayerDown = 7
  1526  )
  1527  
  1528  // Console related constants used for the mode parameter to SetConsoleMode. See
  1529  // https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
  1530  
  1531  const (
  1532  	ENABLE_PROCESSED_INPUT        = 0x1
  1533  	ENABLE_LINE_INPUT             = 0x2
  1534  	ENABLE_ECHO_INPUT             = 0x4
  1535  	ENABLE_WINDOW_INPUT           = 0x8
  1536  	ENABLE_MOUSE_INPUT            = 0x10
  1537  	ENABLE_INSERT_MODE            = 0x20
  1538  	ENABLE_QUICK_EDIT_MODE        = 0x40
  1539  	ENABLE_EXTENDED_FLAGS         = 0x80
  1540  	ENABLE_AUTO_POSITION          = 0x100
  1541  	ENABLE_VIRTUAL_TERMINAL_INPUT = 0x200
  1542  
  1543  	ENABLE_PROCESSED_OUTPUT            = 0x1
  1544  	ENABLE_WRAP_AT_EOL_OUTPUT          = 0x2
  1545  	ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
  1546  	DISABLE_NEWLINE_AUTO_RETURN        = 0x8
  1547  	ENABLE_LVB_GRID_WORLDWIDE          = 0x10
  1548  )
  1549  
  1550  type Coord struct {
  1551  	X int16
  1552  	Y int16
  1553  }
  1554  
  1555  type SmallRect struct {
  1556  	Left   int16
  1557  	Top    int16
  1558  	Right  int16
  1559  	Bottom int16
  1560  }
  1561  
  1562  // Used with GetConsoleScreenBuffer to retrieve information about a console
  1563  // screen buffer. See
  1564  // https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str
  1565  // for details.
  1566  
  1567  type ConsoleScreenBufferInfo struct {
  1568  	Size              Coord
  1569  	CursorPosition    Coord
  1570  	Attributes        uint16
  1571  	Window            SmallRect
  1572  	MaximumWindowSize Coord
  1573  }
  1574  
  1575  const UNIX_PATH_MAX = 108 // defined in afunix.h
  1576  
  1577  const (
  1578  	// flags for JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags
  1579  	JOB_OBJECT_LIMIT_ACTIVE_PROCESS             = 0x00000008
  1580  	JOB_OBJECT_LIMIT_AFFINITY                   = 0x00000010
  1581  	JOB_OBJECT_LIMIT_BREAKAWAY_OK               = 0x00000800
  1582  	JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x00000400
  1583  	JOB_OBJECT_LIMIT_JOB_MEMORY                 = 0x00000200
  1584  	JOB_OBJECT_LIMIT_JOB_TIME                   = 0x00000004
  1585  	JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE          = 0x00002000
  1586  	JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME          = 0x00000040
  1587  	JOB_OBJECT_LIMIT_PRIORITY_CLASS             = 0x00000020
  1588  	JOB_OBJECT_LIMIT_PROCESS_MEMORY             = 0x00000100
  1589  	JOB_OBJECT_LIMIT_PROCESS_TIME               = 0x00000002
  1590  	JOB_OBJECT_LIMIT_SCHEDULING_CLASS           = 0x00000080
  1591  	JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK        = 0x00001000
  1592  	JOB_OBJECT_LIMIT_SUBSET_AFFINITY            = 0x00004000
  1593  	JOB_OBJECT_LIMIT_WORKINGSET                 = 0x00000001
  1594  )
  1595  
  1596  type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
  1597  	PerProcessUserTimeLimit int64
  1598  	PerJobUserTimeLimit     int64
  1599  	LimitFlags              uint32
  1600  	MinimumWorkingSetSize   uintptr
  1601  	MaximumWorkingSetSize   uintptr
  1602  	ActiveProcessLimit      uint32
  1603  	Affinity                uintptr
  1604  	PriorityClass           uint32
  1605  	SchedulingClass         uint32
  1606  }
  1607  
  1608  type IO_COUNTERS struct {
  1609  	ReadOperationCount  uint64
  1610  	WriteOperationCount uint64
  1611  	OtherOperationCount uint64
  1612  	ReadTransferCount   uint64
  1613  	WriteTransferCount  uint64
  1614  	OtherTransferCount  uint64
  1615  }
  1616  
  1617  type JOBOBJECT_EXTENDED_LIMIT_INFORMATION struct {
  1618  	BasicLimitInformation JOBOBJECT_BASIC_LIMIT_INFORMATION
  1619  	IoInfo                IO_COUNTERS
  1620  	ProcessMemoryLimit    uintptr
  1621  	JobMemoryLimit        uintptr
  1622  	PeakProcessMemoryUsed uintptr
  1623  	PeakJobMemoryUsed     uintptr
  1624  }
  1625  
  1626  const (
  1627  	// UIRestrictionsClass
  1628  	JOB_OBJECT_UILIMIT_DESKTOP          = 0x00000040
  1629  	JOB_OBJECT_UILIMIT_DISPLAYSETTINGS  = 0x00000010
  1630  	JOB_OBJECT_UILIMIT_EXITWINDOWS      = 0x00000080
  1631  	JOB_OBJECT_UILIMIT_GLOBALATOMS      = 0x00000020
  1632  	JOB_OBJECT_UILIMIT_HANDLES          = 0x00000001
  1633  	JOB_OBJECT_UILIMIT_READCLIPBOARD    = 0x00000002
  1634  	JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = 0x00000008
  1635  	JOB_OBJECT_UILIMIT_WRITECLIPBOARD   = 0x00000004
  1636  )
  1637  
  1638  type JOBOBJECT_BASIC_UI_RESTRICTIONS struct {
  1639  	UIRestrictionsClass uint32
  1640  }
  1641  
  1642  const (
  1643  	// JobObjectInformationClass
  1644  	JobObjectAssociateCompletionPortInformation = 7
  1645  	JobObjectBasicLimitInformation              = 2
  1646  	JobObjectBasicUIRestrictions                = 4
  1647  	JobObjectCpuRateControlInformation          = 15
  1648  	JobObjectEndOfJobTimeInformation            = 6
  1649  	JobObjectExtendedLimitInformation           = 9
  1650  	JobObjectGroupInformation                   = 11
  1651  	JobObjectGroupInformationEx                 = 14
  1652  	JobObjectLimitViolationInformation2         = 35
  1653  	JobObjectNetRateControlInformation          = 32
  1654  	JobObjectNotificationLimitInformation       = 12
  1655  	JobObjectNotificationLimitInformation2      = 34
  1656  	JobObjectSecurityLimitInformation           = 5
  1657  )
  1658  
  1659  const (
  1660  	KF_FLAG_DEFAULT                          = 0x00000000
  1661  	KF_FLAG_FORCE_APP_DATA_REDIRECTION       = 0x00080000
  1662  	KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET = 0x00040000
  1663  	KF_FLAG_FORCE_PACKAGE_REDIRECTION        = 0x00020000
  1664  	KF_FLAG_NO_PACKAGE_REDIRECTION           = 0x00010000
  1665  	KF_FLAG_FORCE_APPCONTAINER_REDIRECTION   = 0x00020000
  1666  	KF_FLAG_NO_APPCONTAINER_REDIRECTION      = 0x00010000
  1667  	KF_FLAG_CREATE                           = 0x00008000
  1668  	KF_FLAG_DONT_VERIFY                      = 0x00004000
  1669  	KF_FLAG_DONT_UNEXPAND                    = 0x00002000
  1670  	KF_FLAG_NO_ALIAS                         = 0x00001000
  1671  	KF_FLAG_INIT                             = 0x00000800
  1672  	KF_FLAG_DEFAULT_PATH                     = 0x00000400
  1673  	KF_FLAG_NOT_PARENT_RELATIVE              = 0x00000200
  1674  	KF_FLAG_SIMPLE_IDLIST                    = 0x00000100
  1675  	KF_FLAG_ALIAS_ONLY                       = 0x80000000
  1676  )
  1677  
  1678  type OsVersionInfoEx struct {
  1679  	osVersionInfoSize uint32
  1680  	MajorVersion      uint32
  1681  	MinorVersion      uint32
  1682  	BuildNumber       uint32
  1683  	PlatformId        uint32
  1684  	CsdVersion        [128]uint16
  1685  	ServicePackMajor  uint16
  1686  	ServicePackMinor  uint16
  1687  	SuiteMask         uint16
  1688  	ProductType       byte
  1689  	_                 byte
  1690  }