github.com/nibnait/go-learn@v0.0.0-20220227013611-dfa47ea6d2da/src/pkg/mod/golang.org/x/sys@v0.0.0-20210630005230-0f9fa26af87c/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  // NTStatus corresponds with NTSTATUS, error values returned by ntdll.dll and
    14  // other native functions.
    15  type NTStatus uint32
    16  
    17  const (
    18  	// Invented values to support what package os expects.
    19  	O_RDONLY   = 0x00000
    20  	O_WRONLY   = 0x00001
    21  	O_RDWR     = 0x00002
    22  	O_CREAT    = 0x00040
    23  	O_EXCL     = 0x00080
    24  	O_NOCTTY   = 0x00100
    25  	O_TRUNC    = 0x00200
    26  	O_NONBLOCK = 0x00800
    27  	O_APPEND   = 0x00400
    28  	O_SYNC     = 0x01000
    29  	O_ASYNC    = 0x02000
    30  	O_CLOEXEC  = 0x80000
    31  )
    32  
    33  const (
    34  	// More invented values for signals
    35  	SIGHUP  = Signal(0x1)
    36  	SIGINT  = Signal(0x2)
    37  	SIGQUIT = Signal(0x3)
    38  	SIGILL  = Signal(0x4)
    39  	SIGTRAP = Signal(0x5)
    40  	SIGABRT = Signal(0x6)
    41  	SIGBUS  = Signal(0x7)
    42  	SIGFPE  = Signal(0x8)
    43  	SIGKILL = Signal(0x9)
    44  	SIGSEGV = Signal(0xb)
    45  	SIGPIPE = Signal(0xd)
    46  	SIGALRM = Signal(0xe)
    47  	SIGTERM = Signal(0xf)
    48  )
    49  
    50  var signals = [...]string{
    51  	1:  "hangup",
    52  	2:  "interrupt",
    53  	3:  "quit",
    54  	4:  "illegal instruction",
    55  	5:  "trace/breakpoint trap",
    56  	6:  "aborted",
    57  	7:  "bus error",
    58  	8:  "floating point exception",
    59  	9:  "killed",
    60  	10: "user defined signal 1",
    61  	11: "segmentation fault",
    62  	12: "user defined signal 2",
    63  	13: "broken pipe",
    64  	14: "alarm clock",
    65  	15: "terminated",
    66  }
    67  
    68  const (
    69  	FILE_LIST_DIRECTORY   = 0x00000001
    70  	FILE_APPEND_DATA      = 0x00000004
    71  	FILE_WRITE_ATTRIBUTES = 0x00000100
    72  
    73  	FILE_SHARE_READ   = 0x00000001
    74  	FILE_SHARE_WRITE  = 0x00000002
    75  	FILE_SHARE_DELETE = 0x00000004
    76  
    77  	FILE_ATTRIBUTE_READONLY              = 0x00000001
    78  	FILE_ATTRIBUTE_HIDDEN                = 0x00000002
    79  	FILE_ATTRIBUTE_SYSTEM                = 0x00000004
    80  	FILE_ATTRIBUTE_DIRECTORY             = 0x00000010
    81  	FILE_ATTRIBUTE_ARCHIVE               = 0x00000020
    82  	FILE_ATTRIBUTE_DEVICE                = 0x00000040
    83  	FILE_ATTRIBUTE_NORMAL                = 0x00000080
    84  	FILE_ATTRIBUTE_TEMPORARY             = 0x00000100
    85  	FILE_ATTRIBUTE_SPARSE_FILE           = 0x00000200
    86  	FILE_ATTRIBUTE_REPARSE_POINT         = 0x00000400
    87  	FILE_ATTRIBUTE_COMPRESSED            = 0x00000800
    88  	FILE_ATTRIBUTE_OFFLINE               = 0x00001000
    89  	FILE_ATTRIBUTE_NOT_CONTENT_INDEXED   = 0x00002000
    90  	FILE_ATTRIBUTE_ENCRYPTED             = 0x00004000
    91  	FILE_ATTRIBUTE_INTEGRITY_STREAM      = 0x00008000
    92  	FILE_ATTRIBUTE_VIRTUAL               = 0x00010000
    93  	FILE_ATTRIBUTE_NO_SCRUB_DATA         = 0x00020000
    94  	FILE_ATTRIBUTE_RECALL_ON_OPEN        = 0x00040000
    95  	FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000
    96  
    97  	INVALID_FILE_ATTRIBUTES = 0xffffffff
    98  
    99  	CREATE_NEW        = 1
   100  	CREATE_ALWAYS     = 2
   101  	OPEN_EXISTING     = 3
   102  	OPEN_ALWAYS       = 4
   103  	TRUNCATE_EXISTING = 5
   104  
   105  	FILE_FLAG_OPEN_REQUIRING_OPLOCK = 0x00040000
   106  	FILE_FLAG_FIRST_PIPE_INSTANCE   = 0x00080000
   107  	FILE_FLAG_OPEN_NO_RECALL        = 0x00100000
   108  	FILE_FLAG_OPEN_REPARSE_POINT    = 0x00200000
   109  	FILE_FLAG_SESSION_AWARE         = 0x00800000
   110  	FILE_FLAG_POSIX_SEMANTICS       = 0x01000000
   111  	FILE_FLAG_BACKUP_SEMANTICS      = 0x02000000
   112  	FILE_FLAG_DELETE_ON_CLOSE       = 0x04000000
   113  	FILE_FLAG_SEQUENTIAL_SCAN       = 0x08000000
   114  	FILE_FLAG_RANDOM_ACCESS         = 0x10000000
   115  	FILE_FLAG_NO_BUFFERING          = 0x20000000
   116  	FILE_FLAG_OVERLAPPED            = 0x40000000
   117  	FILE_FLAG_WRITE_THROUGH         = 0x80000000
   118  
   119  	HANDLE_FLAG_INHERIT    = 0x00000001
   120  	STARTF_USESTDHANDLES   = 0x00000100
   121  	STARTF_USESHOWWINDOW   = 0x00000001
   122  	DUPLICATE_CLOSE_SOURCE = 0x00000001
   123  	DUPLICATE_SAME_ACCESS  = 0x00000002
   124  
   125  	STD_INPUT_HANDLE  = -10 & (1<<32 - 1)
   126  	STD_OUTPUT_HANDLE = -11 & (1<<32 - 1)
   127  	STD_ERROR_HANDLE  = -12 & (1<<32 - 1)
   128  
   129  	FILE_BEGIN   = 0
   130  	FILE_CURRENT = 1
   131  	FILE_END     = 2
   132  
   133  	LANG_ENGLISH       = 0x09
   134  	SUBLANG_ENGLISH_US = 0x01
   135  
   136  	FORMAT_MESSAGE_ALLOCATE_BUFFER = 256
   137  	FORMAT_MESSAGE_IGNORE_INSERTS  = 512
   138  	FORMAT_MESSAGE_FROM_STRING     = 1024
   139  	FORMAT_MESSAGE_FROM_HMODULE    = 2048
   140  	FORMAT_MESSAGE_FROM_SYSTEM     = 4096
   141  	FORMAT_MESSAGE_ARGUMENT_ARRAY  = 8192
   142  	FORMAT_MESSAGE_MAX_WIDTH_MASK  = 255
   143  
   144  	MAX_PATH      = 260
   145  	MAX_LONG_PATH = 32768
   146  
   147  	MAX_COMPUTERNAME_LENGTH = 15
   148  
   149  	TIME_ZONE_ID_UNKNOWN  = 0
   150  	TIME_ZONE_ID_STANDARD = 1
   151  
   152  	TIME_ZONE_ID_DAYLIGHT = 2
   153  	IGNORE                = 0
   154  	INFINITE              = 0xffffffff
   155  
   156  	WAIT_ABANDONED = 0x00000080
   157  	WAIT_OBJECT_0  = 0x00000000
   158  	WAIT_FAILED    = 0xFFFFFFFF
   159  
   160  	// Access rights for process.
   161  	PROCESS_CREATE_PROCESS            = 0x0080
   162  	PROCESS_CREATE_THREAD             = 0x0002
   163  	PROCESS_DUP_HANDLE                = 0x0040
   164  	PROCESS_QUERY_INFORMATION         = 0x0400
   165  	PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
   166  	PROCESS_SET_INFORMATION           = 0x0200
   167  	PROCESS_SET_QUOTA                 = 0x0100
   168  	PROCESS_SUSPEND_RESUME            = 0x0800
   169  	PROCESS_TERMINATE                 = 0x0001
   170  	PROCESS_VM_OPERATION              = 0x0008
   171  	PROCESS_VM_READ                   = 0x0010
   172  	PROCESS_VM_WRITE                  = 0x0020
   173  
   174  	// Access rights for thread.
   175  	THREAD_DIRECT_IMPERSONATION      = 0x0200
   176  	THREAD_GET_CONTEXT               = 0x0008
   177  	THREAD_IMPERSONATE               = 0x0100
   178  	THREAD_QUERY_INFORMATION         = 0x0040
   179  	THREAD_QUERY_LIMITED_INFORMATION = 0x0800
   180  	THREAD_SET_CONTEXT               = 0x0010
   181  	THREAD_SET_INFORMATION           = 0x0020
   182  	THREAD_SET_LIMITED_INFORMATION   = 0x0400
   183  	THREAD_SET_THREAD_TOKEN          = 0x0080
   184  	THREAD_SUSPEND_RESUME            = 0x0002
   185  	THREAD_TERMINATE                 = 0x0001
   186  
   187  	FILE_MAP_COPY    = 0x01
   188  	FILE_MAP_WRITE   = 0x02
   189  	FILE_MAP_READ    = 0x04
   190  	FILE_MAP_EXECUTE = 0x20
   191  
   192  	CTRL_C_EVENT        = 0
   193  	CTRL_BREAK_EVENT    = 1
   194  	CTRL_CLOSE_EVENT    = 2
   195  	CTRL_LOGOFF_EVENT   = 5
   196  	CTRL_SHUTDOWN_EVENT = 6
   197  
   198  	// Windows reserves errors >= 1<<29 for application use.
   199  	APPLICATION_ERROR = 1 << 29
   200  )
   201  
   202  const (
   203  	// Process creation flags.
   204  	CREATE_BREAKAWAY_FROM_JOB        = 0x01000000
   205  	CREATE_DEFAULT_ERROR_MODE        = 0x04000000
   206  	CREATE_NEW_CONSOLE               = 0x00000010
   207  	CREATE_NEW_PROCESS_GROUP         = 0x00000200
   208  	CREATE_NO_WINDOW                 = 0x08000000
   209  	CREATE_PROTECTED_PROCESS         = 0x00040000
   210  	CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
   211  	CREATE_SEPARATE_WOW_VDM          = 0x00000800
   212  	CREATE_SHARED_WOW_VDM            = 0x00001000
   213  	CREATE_SUSPENDED                 = 0x00000004
   214  	CREATE_UNICODE_ENVIRONMENT       = 0x00000400
   215  	DEBUG_ONLY_THIS_PROCESS          = 0x00000002
   216  	DEBUG_PROCESS                    = 0x00000001
   217  	DETACHED_PROCESS                 = 0x00000008
   218  	EXTENDED_STARTUPINFO_PRESENT     = 0x00080000
   219  	INHERIT_PARENT_AFFINITY          = 0x00010000
   220  )
   221  
   222  const (
   223  	// attributes for ProcThreadAttributeList
   224  	PROC_THREAD_ATTRIBUTE_PARENT_PROCESS    = 0x00020000
   225  	PROC_THREAD_ATTRIBUTE_HANDLE_LIST       = 0x00020002
   226  	PROC_THREAD_ATTRIBUTE_GROUP_AFFINITY    = 0x00030003
   227  	PROC_THREAD_ATTRIBUTE_PREFERRED_NODE    = 0x00020004
   228  	PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR   = 0x00030005
   229  	PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY = 0x00020007
   230  	PROC_THREAD_ATTRIBUTE_UMS_THREAD        = 0x00030006
   231  	PROC_THREAD_ATTRIBUTE_PROTECTION_LEVEL  = 0x0002000b
   232  )
   233  
   234  const (
   235  	// flags for CreateToolhelp32Snapshot
   236  	TH32CS_SNAPHEAPLIST = 0x01
   237  	TH32CS_SNAPPROCESS  = 0x02
   238  	TH32CS_SNAPTHREAD   = 0x04
   239  	TH32CS_SNAPMODULE   = 0x08
   240  	TH32CS_SNAPMODULE32 = 0x10
   241  	TH32CS_SNAPALL      = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
   242  	TH32CS_INHERIT      = 0x80000000
   243  )
   244  
   245  const (
   246  	// filters for ReadDirectoryChangesW and FindFirstChangeNotificationW
   247  	FILE_NOTIFY_CHANGE_FILE_NAME   = 0x001
   248  	FILE_NOTIFY_CHANGE_DIR_NAME    = 0x002
   249  	FILE_NOTIFY_CHANGE_ATTRIBUTES  = 0x004
   250  	FILE_NOTIFY_CHANGE_SIZE        = 0x008
   251  	FILE_NOTIFY_CHANGE_LAST_WRITE  = 0x010
   252  	FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x020
   253  	FILE_NOTIFY_CHANGE_CREATION    = 0x040
   254  	FILE_NOTIFY_CHANGE_SECURITY    = 0x100
   255  )
   256  
   257  const (
   258  	// do not reorder
   259  	FILE_ACTION_ADDED = iota + 1
   260  	FILE_ACTION_REMOVED
   261  	FILE_ACTION_MODIFIED
   262  	FILE_ACTION_RENAMED_OLD_NAME
   263  	FILE_ACTION_RENAMED_NEW_NAME
   264  )
   265  
   266  const (
   267  	// wincrypt.h
   268  	/* certenrolld_begin -- PROV_RSA_*/
   269  	PROV_RSA_FULL      = 1
   270  	PROV_RSA_SIG       = 2
   271  	PROV_DSS           = 3
   272  	PROV_FORTEZZA      = 4
   273  	PROV_MS_EXCHANGE   = 5
   274  	PROV_SSL           = 6
   275  	PROV_RSA_SCHANNEL  = 12
   276  	PROV_DSS_DH        = 13
   277  	PROV_EC_ECDSA_SIG  = 14
   278  	PROV_EC_ECNRA_SIG  = 15
   279  	PROV_EC_ECDSA_FULL = 16
   280  	PROV_EC_ECNRA_FULL = 17
   281  	PROV_DH_SCHANNEL   = 18
   282  	PROV_SPYRUS_LYNKS  = 20
   283  	PROV_RNG           = 21
   284  	PROV_INTEL_SEC     = 22
   285  	PROV_REPLACE_OWF   = 23
   286  	PROV_RSA_AES       = 24
   287  
   288  	/* dwFlags definitions for CryptAcquireContext */
   289  	CRYPT_VERIFYCONTEXT              = 0xF0000000
   290  	CRYPT_NEWKEYSET                  = 0x00000008
   291  	CRYPT_DELETEKEYSET               = 0x00000010
   292  	CRYPT_MACHINE_KEYSET             = 0x00000020
   293  	CRYPT_SILENT                     = 0x00000040
   294  	CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080
   295  
   296  	/* Flags for PFXImportCertStore */
   297  	CRYPT_EXPORTABLE                   = 0x00000001
   298  	CRYPT_USER_PROTECTED               = 0x00000002
   299  	CRYPT_USER_KEYSET                  = 0x00001000
   300  	PKCS12_PREFER_CNG_KSP              = 0x00000100
   301  	PKCS12_ALWAYS_CNG_KSP              = 0x00000200
   302  	PKCS12_ALLOW_OVERWRITE_KEY         = 0x00004000
   303  	PKCS12_NO_PERSIST_KEY              = 0x00008000
   304  	PKCS12_INCLUDE_EXTENDED_PROPERTIES = 0x00000010
   305  
   306  	/* Flags for CryptAcquireCertificatePrivateKey */
   307  	CRYPT_ACQUIRE_CACHE_FLAG             = 0x00000001
   308  	CRYPT_ACQUIRE_USE_PROV_INFO_FLAG     = 0x00000002
   309  	CRYPT_ACQUIRE_COMPARE_KEY_FLAG       = 0x00000004
   310  	CRYPT_ACQUIRE_NO_HEALING             = 0x00000008
   311  	CRYPT_ACQUIRE_SILENT_FLAG            = 0x00000040
   312  	CRYPT_ACQUIRE_WINDOW_HANDLE_FLAG     = 0x00000080
   313  	CRYPT_ACQUIRE_NCRYPT_KEY_FLAGS_MASK  = 0x00070000
   314  	CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG  = 0x00010000
   315  	CRYPT_ACQUIRE_PREFER_NCRYPT_KEY_FLAG = 0x00020000
   316  	CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG   = 0x00040000
   317  
   318  	/* pdwKeySpec for CryptAcquireCertificatePrivateKey */
   319  	AT_KEYEXCHANGE       = 1
   320  	AT_SIGNATURE         = 2
   321  	CERT_NCRYPT_KEY_SPEC = 0xFFFFFFFF
   322  
   323  	/* Default usage match type is AND with value zero */
   324  	USAGE_MATCH_TYPE_AND = 0
   325  	USAGE_MATCH_TYPE_OR  = 1
   326  
   327  	/* msgAndCertEncodingType values for CertOpenStore function */
   328  	X509_ASN_ENCODING   = 0x00000001
   329  	PKCS_7_ASN_ENCODING = 0x00010000
   330  
   331  	/* storeProvider values for CertOpenStore function */
   332  	CERT_STORE_PROV_MSG               = 1
   333  	CERT_STORE_PROV_MEMORY            = 2
   334  	CERT_STORE_PROV_FILE              = 3
   335  	CERT_STORE_PROV_REG               = 4
   336  	CERT_STORE_PROV_PKCS7             = 5
   337  	CERT_STORE_PROV_SERIALIZED        = 6
   338  	CERT_STORE_PROV_FILENAME_A        = 7
   339  	CERT_STORE_PROV_FILENAME_W        = 8
   340  	CERT_STORE_PROV_FILENAME          = CERT_STORE_PROV_FILENAME_W
   341  	CERT_STORE_PROV_SYSTEM_A          = 9
   342  	CERT_STORE_PROV_SYSTEM_W          = 10
   343  	CERT_STORE_PROV_SYSTEM            = CERT_STORE_PROV_SYSTEM_W
   344  	CERT_STORE_PROV_COLLECTION        = 11
   345  	CERT_STORE_PROV_SYSTEM_REGISTRY_A = 12
   346  	CERT_STORE_PROV_SYSTEM_REGISTRY_W = 13
   347  	CERT_STORE_PROV_SYSTEM_REGISTRY   = CERT_STORE_PROV_SYSTEM_REGISTRY_W
   348  	CERT_STORE_PROV_PHYSICAL_W        = 14
   349  	CERT_STORE_PROV_PHYSICAL          = CERT_STORE_PROV_PHYSICAL_W
   350  	CERT_STORE_PROV_SMART_CARD_W      = 15
   351  	CERT_STORE_PROV_SMART_CARD        = CERT_STORE_PROV_SMART_CARD_W
   352  	CERT_STORE_PROV_LDAP_W            = 16
   353  	CERT_STORE_PROV_LDAP              = CERT_STORE_PROV_LDAP_W
   354  	CERT_STORE_PROV_PKCS12            = 17
   355  
   356  	/* store characteristics (low WORD of flag) for CertOpenStore function */
   357  	CERT_STORE_NO_CRYPT_RELEASE_FLAG            = 0x00000001
   358  	CERT_STORE_SET_LOCALIZED_NAME_FLAG          = 0x00000002
   359  	CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004
   360  	CERT_STORE_DELETE_FLAG                      = 0x00000010
   361  	CERT_STORE_UNSAFE_PHYSICAL_FLAG             = 0x00000020
   362  	CERT_STORE_SHARE_STORE_FLAG                 = 0x00000040
   363  	CERT_STORE_SHARE_CONTEXT_FLAG               = 0x00000080
   364  	CERT_STORE_MANIFOLD_FLAG                    = 0x00000100
   365  	CERT_STORE_ENUM_ARCHIVED_FLAG               = 0x00000200
   366  	CERT_STORE_UPDATE_KEYID_FLAG                = 0x00000400
   367  	CERT_STORE_BACKUP_RESTORE_FLAG              = 0x00000800
   368  	CERT_STORE_MAXIMUM_ALLOWED_FLAG             = 0x00001000
   369  	CERT_STORE_CREATE_NEW_FLAG                  = 0x00002000
   370  	CERT_STORE_OPEN_EXISTING_FLAG               = 0x00004000
   371  	CERT_STORE_READONLY_FLAG                    = 0x00008000
   372  
   373  	/* store locations (high WORD of flag) for CertOpenStore function */
   374  	CERT_SYSTEM_STORE_CURRENT_USER               = 0x00010000
   375  	CERT_SYSTEM_STORE_LOCAL_MACHINE              = 0x00020000
   376  	CERT_SYSTEM_STORE_CURRENT_SERVICE            = 0x00040000
   377  	CERT_SYSTEM_STORE_SERVICES                   = 0x00050000
   378  	CERT_SYSTEM_STORE_USERS                      = 0x00060000
   379  	CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY  = 0x00070000
   380  	CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = 0x00080000
   381  	CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE   = 0x00090000
   382  	CERT_SYSTEM_STORE_UNPROTECTED_FLAG           = 0x40000000
   383  	CERT_SYSTEM_STORE_RELOCATE_FLAG              = 0x80000000
   384  
   385  	/* Miscellaneous high-WORD flags for CertOpenStore function */
   386  	CERT_REGISTRY_STORE_REMOTE_FLAG      = 0x00010000
   387  	CERT_REGISTRY_STORE_SERIALIZED_FLAG  = 0x00020000
   388  	CERT_REGISTRY_STORE_ROAMING_FLAG     = 0x00040000
   389  	CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG = 0x00080000
   390  	CERT_REGISTRY_STORE_LM_GPT_FLAG      = 0x01000000
   391  	CERT_REGISTRY_STORE_CLIENT_GPT_FLAG  = 0x80000000
   392  	CERT_FILE_STORE_COMMIT_ENABLE_FLAG   = 0x00010000
   393  	CERT_LDAP_STORE_SIGN_FLAG            = 0x00010000
   394  	CERT_LDAP_STORE_AREC_EXCLUSIVE_FLAG  = 0x00020000
   395  	CERT_LDAP_STORE_OPENED_FLAG          = 0x00040000
   396  	CERT_LDAP_STORE_UNBIND_FLAG          = 0x00080000
   397  
   398  	/* addDisposition values for CertAddCertificateContextToStore function */
   399  	CERT_STORE_ADD_NEW                                 = 1
   400  	CERT_STORE_ADD_USE_EXISTING                        = 2
   401  	CERT_STORE_ADD_REPLACE_EXISTING                    = 3
   402  	CERT_STORE_ADD_ALWAYS                              = 4
   403  	CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5
   404  	CERT_STORE_ADD_NEWER                               = 6
   405  	CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES            = 7
   406  
   407  	/* ErrorStatus values for CertTrustStatus struct */
   408  	CERT_TRUST_NO_ERROR                          = 0x00000000
   409  	CERT_TRUST_IS_NOT_TIME_VALID                 = 0x00000001
   410  	CERT_TRUST_IS_REVOKED                        = 0x00000004
   411  	CERT_TRUST_IS_NOT_SIGNATURE_VALID            = 0x00000008
   412  	CERT_TRUST_IS_NOT_VALID_FOR_USAGE            = 0x00000010
   413  	CERT_TRUST_IS_UNTRUSTED_ROOT                 = 0x00000020
   414  	CERT_TRUST_REVOCATION_STATUS_UNKNOWN         = 0x00000040
   415  	CERT_TRUST_IS_CYCLIC                         = 0x00000080
   416  	CERT_TRUST_INVALID_EXTENSION                 = 0x00000100
   417  	CERT_TRUST_INVALID_POLICY_CONSTRAINTS        = 0x00000200
   418  	CERT_TRUST_INVALID_BASIC_CONSTRAINTS         = 0x00000400
   419  	CERT_TRUST_INVALID_NAME_CONSTRAINTS          = 0x00000800
   420  	CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000
   421  	CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT   = 0x00002000
   422  	CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000
   423  	CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT      = 0x00008000
   424  	CERT_TRUST_IS_PARTIAL_CHAIN                  = 0x00010000
   425  	CERT_TRUST_CTL_IS_NOT_TIME_VALID             = 0x00020000
   426  	CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID        = 0x00040000
   427  	CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE        = 0x00080000
   428  	CERT_TRUST_HAS_WEAK_SIGNATURE                = 0x00100000
   429  	CERT_TRUST_IS_OFFLINE_REVOCATION             = 0x01000000
   430  	CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY          = 0x02000000
   431  	CERT_TRUST_IS_EXPLICIT_DISTRUST              = 0x04000000
   432  	CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT    = 0x08000000
   433  
   434  	/* InfoStatus values for CertTrustStatus struct */
   435  	CERT_TRUST_HAS_EXACT_MATCH_ISSUER        = 0x00000001
   436  	CERT_TRUST_HAS_KEY_MATCH_ISSUER          = 0x00000002
   437  	CERT_TRUST_HAS_NAME_MATCH_ISSUER         = 0x00000004
   438  	CERT_TRUST_IS_SELF_SIGNED                = 0x00000008
   439  	CERT_TRUST_HAS_PREFERRED_ISSUER          = 0x00000100
   440  	CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY     = 0x00000400
   441  	CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS    = 0x00000400
   442  	CERT_TRUST_IS_PEER_TRUSTED               = 0x00000800
   443  	CERT_TRUST_HAS_CRL_VALIDITY_EXTENDED     = 0x00001000
   444  	CERT_TRUST_IS_FROM_EXCLUSIVE_TRUST_STORE = 0x00002000
   445  	CERT_TRUST_IS_CA_TRUSTED                 = 0x00004000
   446  	CERT_TRUST_IS_COMPLEX_CHAIN              = 0x00010000
   447  
   448  	/* Certificate Information Flags */
   449  	CERT_INFO_VERSION_FLAG                 = 1
   450  	CERT_INFO_SERIAL_NUMBER_FLAG           = 2
   451  	CERT_INFO_SIGNATURE_ALGORITHM_FLAG     = 3
   452  	CERT_INFO_ISSUER_FLAG                  = 4
   453  	CERT_INFO_NOT_BEFORE_FLAG              = 5
   454  	CERT_INFO_NOT_AFTER_FLAG               = 6
   455  	CERT_INFO_SUBJECT_FLAG                 = 7
   456  	CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG = 8
   457  	CERT_INFO_ISSUER_UNIQUE_ID_FLAG        = 9
   458  	CERT_INFO_SUBJECT_UNIQUE_ID_FLAG       = 10
   459  	CERT_INFO_EXTENSION_FLAG               = 11
   460  
   461  	/* dwFindType for CertFindCertificateInStore  */
   462  	CERT_COMPARE_MASK                     = 0xFFFF
   463  	CERT_COMPARE_SHIFT                    = 16
   464  	CERT_COMPARE_ANY                      = 0
   465  	CERT_COMPARE_SHA1_HASH                = 1
   466  	CERT_COMPARE_NAME                     = 2
   467  	CERT_COMPARE_ATTR                     = 3
   468  	CERT_COMPARE_MD5_HASH                 = 4
   469  	CERT_COMPARE_PROPERTY                 = 5
   470  	CERT_COMPARE_PUBLIC_KEY               = 6
   471  	CERT_COMPARE_HASH                     = CERT_COMPARE_SHA1_HASH
   472  	CERT_COMPARE_NAME_STR_A               = 7
   473  	CERT_COMPARE_NAME_STR_W               = 8
   474  	CERT_COMPARE_KEY_SPEC                 = 9
   475  	CERT_COMPARE_ENHKEY_USAGE             = 10
   476  	CERT_COMPARE_CTL_USAGE                = CERT_COMPARE_ENHKEY_USAGE
   477  	CERT_COMPARE_SUBJECT_CERT             = 11
   478  	CERT_COMPARE_ISSUER_OF                = 12
   479  	CERT_COMPARE_EXISTING                 = 13
   480  	CERT_COMPARE_SIGNATURE_HASH           = 14
   481  	CERT_COMPARE_KEY_IDENTIFIER           = 15
   482  	CERT_COMPARE_CERT_ID                  = 16
   483  	CERT_COMPARE_CROSS_CERT_DIST_POINTS   = 17
   484  	CERT_COMPARE_PUBKEY_MD5_HASH          = 18
   485  	CERT_COMPARE_SUBJECT_INFO_ACCESS      = 19
   486  	CERT_COMPARE_HASH_STR                 = 20
   487  	CERT_COMPARE_HAS_PRIVATE_KEY          = 21
   488  	CERT_FIND_ANY                         = (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT)
   489  	CERT_FIND_SHA1_HASH                   = (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT)
   490  	CERT_FIND_MD5_HASH                    = (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT)
   491  	CERT_FIND_SIGNATURE_HASH              = (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT)
   492  	CERT_FIND_KEY_IDENTIFIER              = (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT)
   493  	CERT_FIND_HASH                        = CERT_FIND_SHA1_HASH
   494  	CERT_FIND_PROPERTY                    = (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT)
   495  	CERT_FIND_PUBLIC_KEY                  = (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT)
   496  	CERT_FIND_SUBJECT_NAME                = (CERT_COMPARE_NAME<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
   497  	CERT_FIND_SUBJECT_ATTR                = (CERT_COMPARE_ATTR<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
   498  	CERT_FIND_ISSUER_NAME                 = (CERT_COMPARE_NAME<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
   499  	CERT_FIND_ISSUER_ATTR                 = (CERT_COMPARE_ATTR<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
   500  	CERT_FIND_SUBJECT_STR_A               = (CERT_COMPARE_NAME_STR_A<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
   501  	CERT_FIND_SUBJECT_STR_W               = (CERT_COMPARE_NAME_STR_W<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
   502  	CERT_FIND_SUBJECT_STR                 = CERT_FIND_SUBJECT_STR_W
   503  	CERT_FIND_ISSUER_STR_A                = (CERT_COMPARE_NAME_STR_A<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
   504  	CERT_FIND_ISSUER_STR_W                = (CERT_COMPARE_NAME_STR_W<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
   505  	CERT_FIND_ISSUER_STR                  = CERT_FIND_ISSUER_STR_W
   506  	CERT_FIND_KEY_SPEC                    = (CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT)
   507  	CERT_FIND_ENHKEY_USAGE                = (CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT)
   508  	CERT_FIND_CTL_USAGE                   = CERT_FIND_ENHKEY_USAGE
   509  	CERT_FIND_SUBJECT_CERT                = (CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT)
   510  	CERT_FIND_ISSUER_OF                   = (CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT)
   511  	CERT_FIND_EXISTING                    = (CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT)
   512  	CERT_FIND_CERT_ID                     = (CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT)
   513  	CERT_FIND_CROSS_CERT_DIST_POINTS      = (CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT)
   514  	CERT_FIND_PUBKEY_MD5_HASH             = (CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT)
   515  	CERT_FIND_SUBJECT_INFO_ACCESS         = (CERT_COMPARE_SUBJECT_INFO_ACCESS << CERT_COMPARE_SHIFT)
   516  	CERT_FIND_HASH_STR                    = (CERT_COMPARE_HASH_STR << CERT_COMPARE_SHIFT)
   517  	CERT_FIND_HAS_PRIVATE_KEY             = (CERT_COMPARE_HAS_PRIVATE_KEY << CERT_COMPARE_SHIFT)
   518  	CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG  = 0x1
   519  	CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG  = 0x2
   520  	CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG = 0x4
   521  	CERT_FIND_NO_ENHKEY_USAGE_FLAG        = 0x8
   522  	CERT_FIND_OR_ENHKEY_USAGE_FLAG        = 0x10
   523  	CERT_FIND_VALID_ENHKEY_USAGE_FLAG     = 0x20
   524  	CERT_FIND_OPTIONAL_CTL_USAGE_FLAG     = CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG
   525  	CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG     = CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG
   526  	CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG    = CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
   527  	CERT_FIND_NO_CTL_USAGE_FLAG           = CERT_FIND_NO_ENHKEY_USAGE_FLAG
   528  	CERT_FIND_OR_CTL_USAGE_FLAG           = CERT_FIND_OR_ENHKEY_USAGE_FLAG
   529  	CERT_FIND_VALID_CTL_USAGE_FLAG        = CERT_FIND_VALID_ENHKEY_USAGE_FLAG
   530  
   531  	/* policyOID values for CertVerifyCertificateChainPolicy function */
   532  	CERT_CHAIN_POLICY_BASE              = 1
   533  	CERT_CHAIN_POLICY_AUTHENTICODE      = 2
   534  	CERT_CHAIN_POLICY_AUTHENTICODE_TS   = 3
   535  	CERT_CHAIN_POLICY_SSL               = 4
   536  	CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5
   537  	CERT_CHAIN_POLICY_NT_AUTH           = 6
   538  	CERT_CHAIN_POLICY_MICROSOFT_ROOT    = 7
   539  	CERT_CHAIN_POLICY_EV                = 8
   540  	CERT_CHAIN_POLICY_SSL_F12           = 9
   541  
   542  	/* flag for dwFindType CertFindChainInStore  */
   543  	CERT_CHAIN_FIND_BY_ISSUER = 1
   544  
   545  	/* dwFindFlags for CertFindChainInStore when dwFindType == CERT_CHAIN_FIND_BY_ISSUER */
   546  	CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG    = 0x0001
   547  	CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG  = 0x0002
   548  	CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG = 0x0004
   549  	CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG  = 0x0008
   550  	CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG         = 0x4000
   551  	CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG     = 0x8000
   552  
   553  	/* Certificate Store close flags */
   554  	CERT_CLOSE_STORE_FORCE_FLAG = 0x00000001
   555  	CERT_CLOSE_STORE_CHECK_FLAG = 0x00000002
   556  
   557  	/* CryptQueryObject object type */
   558  	CERT_QUERY_OBJECT_FILE = 1
   559  	CERT_QUERY_OBJECT_BLOB = 2
   560  
   561  	/* CryptQueryObject content type flags */
   562  	CERT_QUERY_CONTENT_CERT                    = 1
   563  	CERT_QUERY_CONTENT_CTL                     = 2
   564  	CERT_QUERY_CONTENT_CRL                     = 3
   565  	CERT_QUERY_CONTENT_SERIALIZED_STORE        = 4
   566  	CERT_QUERY_CONTENT_SERIALIZED_CERT         = 5
   567  	CERT_QUERY_CONTENT_SERIALIZED_CTL          = 6
   568  	CERT_QUERY_CONTENT_SERIALIZED_CRL          = 7
   569  	CERT_QUERY_CONTENT_PKCS7_SIGNED            = 8
   570  	CERT_QUERY_CONTENT_PKCS7_UNSIGNED          = 9
   571  	CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED      = 10
   572  	CERT_QUERY_CONTENT_PKCS10                  = 11
   573  	CERT_QUERY_CONTENT_PFX                     = 12
   574  	CERT_QUERY_CONTENT_CERT_PAIR               = 13
   575  	CERT_QUERY_CONTENT_PFX_AND_LOAD            = 14
   576  	CERT_QUERY_CONTENT_FLAG_CERT               = (1 << CERT_QUERY_CONTENT_CERT)
   577  	CERT_QUERY_CONTENT_FLAG_CTL                = (1 << CERT_QUERY_CONTENT_CTL)
   578  	CERT_QUERY_CONTENT_FLAG_CRL                = (1 << CERT_QUERY_CONTENT_CRL)
   579  	CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE   = (1 << CERT_QUERY_CONTENT_SERIALIZED_STORE)
   580  	CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT    = (1 << CERT_QUERY_CONTENT_SERIALIZED_CERT)
   581  	CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL     = (1 << CERT_QUERY_CONTENT_SERIALIZED_CTL)
   582  	CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL     = (1 << CERT_QUERY_CONTENT_SERIALIZED_CRL)
   583  	CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED       = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED)
   584  	CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED     = (1 << CERT_QUERY_CONTENT_PKCS7_UNSIGNED)
   585  	CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED)
   586  	CERT_QUERY_CONTENT_FLAG_PKCS10             = (1 << CERT_QUERY_CONTENT_PKCS10)
   587  	CERT_QUERY_CONTENT_FLAG_PFX                = (1 << CERT_QUERY_CONTENT_PFX)
   588  	CERT_QUERY_CONTENT_FLAG_CERT_PAIR          = (1 << CERT_QUERY_CONTENT_CERT_PAIR)
   589  	CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD       = (1 << CERT_QUERY_CONTENT_PFX_AND_LOAD)
   590  	CERT_QUERY_CONTENT_FLAG_ALL                = (CERT_QUERY_CONTENT_FLAG_CERT | CERT_QUERY_CONTENT_FLAG_CTL | CERT_QUERY_CONTENT_FLAG_CRL | CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED | CERT_QUERY_CONTENT_FLAG_PKCS10 | CERT_QUERY_CONTENT_FLAG_PFX | CERT_QUERY_CONTENT_FLAG_CERT_PAIR)
   591  	CERT_QUERY_CONTENT_FLAG_ALL_ISSUER_CERT    = (CERT_QUERY_CONTENT_FLAG_CERT | CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED)
   592  
   593  	/* CryptQueryObject format type flags */
   594  	CERT_QUERY_FORMAT_BINARY                     = 1
   595  	CERT_QUERY_FORMAT_BASE64_ENCODED             = 2
   596  	CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED      = 3
   597  	CERT_QUERY_FORMAT_FLAG_BINARY                = (1 << CERT_QUERY_FORMAT_BINARY)
   598  	CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED        = (1 << CERT_QUERY_FORMAT_BASE64_ENCODED)
   599  	CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED = (1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED)
   600  	CERT_QUERY_FORMAT_FLAG_ALL                   = (CERT_QUERY_FORMAT_FLAG_BINARY | CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED | CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED)
   601  
   602  	/* CertGetNameString name types */
   603  	CERT_NAME_EMAIL_TYPE            = 1
   604  	CERT_NAME_RDN_TYPE              = 2
   605  	CERT_NAME_ATTR_TYPE             = 3
   606  	CERT_NAME_SIMPLE_DISPLAY_TYPE   = 4
   607  	CERT_NAME_FRIENDLY_DISPLAY_TYPE = 5
   608  	CERT_NAME_DNS_TYPE              = 6
   609  	CERT_NAME_URL_TYPE              = 7
   610  	CERT_NAME_UPN_TYPE              = 8
   611  
   612  	/* CertGetNameString flags */
   613  	CERT_NAME_ISSUER_FLAG              = 0x1
   614  	CERT_NAME_DISABLE_IE4_UTF8_FLAG    = 0x10000
   615  	CERT_NAME_SEARCH_ALL_NAMES_FLAG    = 0x2
   616  	CERT_NAME_STR_ENABLE_PUNYCODE_FLAG = 0x00200000
   617  
   618  	/* AuthType values for SSLExtraCertChainPolicyPara struct */
   619  	AUTHTYPE_CLIENT = 1
   620  	AUTHTYPE_SERVER = 2
   621  
   622  	/* Checks values for SSLExtraCertChainPolicyPara struct */
   623  	SECURITY_FLAG_IGNORE_REVOCATION        = 0x00000080
   624  	SECURITY_FLAG_IGNORE_UNKNOWN_CA        = 0x00000100
   625  	SECURITY_FLAG_IGNORE_WRONG_USAGE       = 0x00000200
   626  	SECURITY_FLAG_IGNORE_CERT_CN_INVALID   = 0x00001000
   627  	SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000
   628  
   629  	/* Flags for Crypt[Un]ProtectData */
   630  	CRYPTPROTECT_UI_FORBIDDEN      = 0x1
   631  	CRYPTPROTECT_LOCAL_MACHINE     = 0x4
   632  	CRYPTPROTECT_CRED_SYNC         = 0x8
   633  	CRYPTPROTECT_AUDIT             = 0x10
   634  	CRYPTPROTECT_NO_RECOVERY       = 0x20
   635  	CRYPTPROTECT_VERIFY_PROTECTION = 0x40
   636  	CRYPTPROTECT_CRED_REGENERATE   = 0x80
   637  
   638  	/* Flags for CryptProtectPromptStruct */
   639  	CRYPTPROTECT_PROMPT_ON_UNPROTECT   = 1
   640  	CRYPTPROTECT_PROMPT_ON_PROTECT     = 2
   641  	CRYPTPROTECT_PROMPT_RESERVED       = 4
   642  	CRYPTPROTECT_PROMPT_STRONG         = 8
   643  	CRYPTPROTECT_PROMPT_REQUIRE_STRONG = 16
   644  )
   645  
   646  const (
   647  	// flags for SetErrorMode
   648  	SEM_FAILCRITICALERRORS     = 0x0001
   649  	SEM_NOALIGNMENTFAULTEXCEPT = 0x0004
   650  	SEM_NOGPFAULTERRORBOX      = 0x0002
   651  	SEM_NOOPENFILEERRORBOX     = 0x8000
   652  )
   653  
   654  const (
   655  	// Priority class.
   656  	ABOVE_NORMAL_PRIORITY_CLASS   = 0x00008000
   657  	BELOW_NORMAL_PRIORITY_CLASS   = 0x00004000
   658  	HIGH_PRIORITY_CLASS           = 0x00000080
   659  	IDLE_PRIORITY_CLASS           = 0x00000040
   660  	NORMAL_PRIORITY_CLASS         = 0x00000020
   661  	PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000
   662  	PROCESS_MODE_BACKGROUND_END   = 0x00200000
   663  	REALTIME_PRIORITY_CLASS       = 0x00000100
   664  )
   665  
   666  /* wintrust.h constants for WinVerifyTrustEx */
   667  const (
   668  	WTD_UI_ALL    = 1
   669  	WTD_UI_NONE   = 2
   670  	WTD_UI_NOBAD  = 3
   671  	WTD_UI_NOGOOD = 4
   672  
   673  	WTD_REVOKE_NONE       = 0
   674  	WTD_REVOKE_WHOLECHAIN = 1
   675  
   676  	WTD_CHOICE_FILE    = 1
   677  	WTD_CHOICE_CATALOG = 2
   678  	WTD_CHOICE_BLOB    = 3
   679  	WTD_CHOICE_SIGNER  = 4
   680  	WTD_CHOICE_CERT    = 5
   681  
   682  	WTD_STATEACTION_IGNORE           = 0x00000000
   683  	WTD_STATEACTION_VERIFY           = 0x00000001
   684  	WTD_STATEACTION_CLOSE            = 0x00000002
   685  	WTD_STATEACTION_AUTO_CACHE       = 0x00000003
   686  	WTD_STATEACTION_AUTO_CACHE_FLUSH = 0x00000004
   687  
   688  	WTD_USE_IE4_TRUST_FLAG                  = 0x1
   689  	WTD_NO_IE4_CHAIN_FLAG                   = 0x2
   690  	WTD_NO_POLICY_USAGE_FLAG                = 0x4
   691  	WTD_REVOCATION_CHECK_NONE               = 0x10
   692  	WTD_REVOCATION_CHECK_END_CERT           = 0x20
   693  	WTD_REVOCATION_CHECK_CHAIN              = 0x40
   694  	WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x80
   695  	WTD_SAFER_FLAG                          = 0x100
   696  	WTD_HASH_ONLY_FLAG                      = 0x200
   697  	WTD_USE_DEFAULT_OSVER_CHECK             = 0x400
   698  	WTD_LIFETIME_SIGNING_FLAG               = 0x800
   699  	WTD_CACHE_ONLY_URL_RETRIEVAL            = 0x1000
   700  	WTD_DISABLE_MD2_MD4                     = 0x2000
   701  	WTD_MOTW                                = 0x4000
   702  
   703  	WTD_UICONTEXT_EXECUTE = 0
   704  	WTD_UICONTEXT_INSTALL = 1
   705  )
   706  
   707  var (
   708  	OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00")
   709  	OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00")
   710  	OID_SGC_NETSCAPE        = []byte("2.16.840.1.113730.4.1\x00")
   711  
   712  	WINTRUST_ACTION_GENERIC_VERIFY_V2 = GUID{
   713  		Data1: 0xaac56b,
   714  		Data2: 0xcd44,
   715  		Data3: 0x11d0,
   716  		Data4: [8]byte{0x8c, 0xc2, 0x0, 0xc0, 0x4f, 0xc2, 0x95, 0xee},
   717  	}
   718  )
   719  
   720  // Pointer represents a pointer to an arbitrary Windows type.
   721  //
   722  // Pointer-typed fields may point to one of many different types. It's
   723  // up to the caller to provide a pointer to the appropriate type, cast
   724  // to Pointer. The caller must obey the unsafe.Pointer rules while
   725  // doing so.
   726  type Pointer *struct{}
   727  
   728  // Invented values to support what package os expects.
   729  type Timeval struct {
   730  	Sec  int32
   731  	Usec int32
   732  }
   733  
   734  func (tv *Timeval) Nanoseconds() int64 {
   735  	return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3
   736  }
   737  
   738  func NsecToTimeval(nsec int64) (tv Timeval) {
   739  	tv.Sec = int32(nsec / 1e9)
   740  	tv.Usec = int32(nsec % 1e9 / 1e3)
   741  	return
   742  }
   743  
   744  type Overlapped struct {
   745  	Internal     uintptr
   746  	InternalHigh uintptr
   747  	Offset       uint32
   748  	OffsetHigh   uint32
   749  	HEvent       Handle
   750  }
   751  
   752  type FileNotifyInformation struct {
   753  	NextEntryOffset uint32
   754  	Action          uint32
   755  	FileNameLength  uint32
   756  	FileName        uint16
   757  }
   758  
   759  type Filetime struct {
   760  	LowDateTime  uint32
   761  	HighDateTime uint32
   762  }
   763  
   764  // Nanoseconds returns Filetime ft in nanoseconds
   765  // since Epoch (00:00:00 UTC, January 1, 1970).
   766  func (ft *Filetime) Nanoseconds() int64 {
   767  	// 100-nanosecond intervals since January 1, 1601
   768  	nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)
   769  	// change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
   770  	nsec -= 116444736000000000
   771  	// convert into nanoseconds
   772  	nsec *= 100
   773  	return nsec
   774  }
   775  
   776  func NsecToFiletime(nsec int64) (ft Filetime) {
   777  	// convert into 100-nanosecond
   778  	nsec /= 100
   779  	// change starting time to January 1, 1601
   780  	nsec += 116444736000000000
   781  	// split into high / low
   782  	ft.LowDateTime = uint32(nsec & 0xffffffff)
   783  	ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff)
   784  	return ft
   785  }
   786  
   787  type Win32finddata struct {
   788  	FileAttributes    uint32
   789  	CreationTime      Filetime
   790  	LastAccessTime    Filetime
   791  	LastWriteTime     Filetime
   792  	FileSizeHigh      uint32
   793  	FileSizeLow       uint32
   794  	Reserved0         uint32
   795  	Reserved1         uint32
   796  	FileName          [MAX_PATH - 1]uint16
   797  	AlternateFileName [13]uint16
   798  }
   799  
   800  // This is the actual system call structure.
   801  // Win32finddata is what we committed to in Go 1.
   802  type win32finddata1 struct {
   803  	FileAttributes    uint32
   804  	CreationTime      Filetime
   805  	LastAccessTime    Filetime
   806  	LastWriteTime     Filetime
   807  	FileSizeHigh      uint32
   808  	FileSizeLow       uint32
   809  	Reserved0         uint32
   810  	Reserved1         uint32
   811  	FileName          [MAX_PATH]uint16
   812  	AlternateFileName [14]uint16
   813  
   814  	// The Microsoft documentation for this struct¹ describes three additional
   815  	// fields: dwFileType, dwCreatorType, and wFinderFlags. However, those fields
   816  	// are empirically only present in the macOS port of the Win32 API,² and thus
   817  	// not needed for binaries built for Windows.
   818  	//
   819  	// ¹ https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-win32_find_dataw describe
   820  	// ² https://golang.org/issue/42637#issuecomment-760715755.
   821  }
   822  
   823  func copyFindData(dst *Win32finddata, src *win32finddata1) {
   824  	dst.FileAttributes = src.FileAttributes
   825  	dst.CreationTime = src.CreationTime
   826  	dst.LastAccessTime = src.LastAccessTime
   827  	dst.LastWriteTime = src.LastWriteTime
   828  	dst.FileSizeHigh = src.FileSizeHigh
   829  	dst.FileSizeLow = src.FileSizeLow
   830  	dst.Reserved0 = src.Reserved0
   831  	dst.Reserved1 = src.Reserved1
   832  
   833  	// The src is 1 element bigger than dst, but it must be NUL.
   834  	copy(dst.FileName[:], src.FileName[:])
   835  	copy(dst.AlternateFileName[:], src.AlternateFileName[:])
   836  }
   837  
   838  type ByHandleFileInformation struct {
   839  	FileAttributes     uint32
   840  	CreationTime       Filetime
   841  	LastAccessTime     Filetime
   842  	LastWriteTime      Filetime
   843  	VolumeSerialNumber uint32
   844  	FileSizeHigh       uint32
   845  	FileSizeLow        uint32
   846  	NumberOfLinks      uint32
   847  	FileIndexHigh      uint32
   848  	FileIndexLow       uint32
   849  }
   850  
   851  const (
   852  	GetFileExInfoStandard = 0
   853  	GetFileExMaxInfoLevel = 1
   854  )
   855  
   856  type Win32FileAttributeData struct {
   857  	FileAttributes uint32
   858  	CreationTime   Filetime
   859  	LastAccessTime Filetime
   860  	LastWriteTime  Filetime
   861  	FileSizeHigh   uint32
   862  	FileSizeLow    uint32
   863  }
   864  
   865  // ShowWindow constants
   866  const (
   867  	// winuser.h
   868  	SW_HIDE            = 0
   869  	SW_NORMAL          = 1
   870  	SW_SHOWNORMAL      = 1
   871  	SW_SHOWMINIMIZED   = 2
   872  	SW_SHOWMAXIMIZED   = 3
   873  	SW_MAXIMIZE        = 3
   874  	SW_SHOWNOACTIVATE  = 4
   875  	SW_SHOW            = 5
   876  	SW_MINIMIZE        = 6
   877  	SW_SHOWMINNOACTIVE = 7
   878  	SW_SHOWNA          = 8
   879  	SW_RESTORE         = 9
   880  	SW_SHOWDEFAULT     = 10
   881  	SW_FORCEMINIMIZE   = 11
   882  )
   883  
   884  type StartupInfo struct {
   885  	Cb            uint32
   886  	_             *uint16
   887  	Desktop       *uint16
   888  	Title         *uint16
   889  	X             uint32
   890  	Y             uint32
   891  	XSize         uint32
   892  	YSize         uint32
   893  	XCountChars   uint32
   894  	YCountChars   uint32
   895  	FillAttribute uint32
   896  	Flags         uint32
   897  	ShowWindow    uint16
   898  	_             uint16
   899  	_             *byte
   900  	StdInput      Handle
   901  	StdOutput     Handle
   902  	StdErr        Handle
   903  }
   904  
   905  type StartupInfoEx struct {
   906  	StartupInfo
   907  	ProcThreadAttributeList *ProcThreadAttributeList
   908  }
   909  
   910  // ProcThreadAttributeList is a placeholder type to represent a PROC_THREAD_ATTRIBUTE_LIST.
   911  //
   912  // To create a *ProcThreadAttributeList, use NewProcThreadAttributeList, update
   913  // it with ProcThreadAttributeListContainer.Update, free its memory using
   914  // ProcThreadAttributeListContainer.Delete, and access the list itself using
   915  // ProcThreadAttributeListContainer.List.
   916  type ProcThreadAttributeList struct{}
   917  
   918  type ProcThreadAttributeListContainer struct {
   919  	data            *ProcThreadAttributeList
   920  	heapAllocations []uintptr
   921  }
   922  
   923  type ProcessInformation struct {
   924  	Process   Handle
   925  	Thread    Handle
   926  	ProcessId uint32
   927  	ThreadId  uint32
   928  }
   929  
   930  type ProcessEntry32 struct {
   931  	Size            uint32
   932  	Usage           uint32
   933  	ProcessID       uint32
   934  	DefaultHeapID   uintptr
   935  	ModuleID        uint32
   936  	Threads         uint32
   937  	ParentProcessID uint32
   938  	PriClassBase    int32
   939  	Flags           uint32
   940  	ExeFile         [MAX_PATH]uint16
   941  }
   942  
   943  type ThreadEntry32 struct {
   944  	Size           uint32
   945  	Usage          uint32
   946  	ThreadID       uint32
   947  	OwnerProcessID uint32
   948  	BasePri        int32
   949  	DeltaPri       int32
   950  	Flags          uint32
   951  }
   952  
   953  type Systemtime struct {
   954  	Year         uint16
   955  	Month        uint16
   956  	DayOfWeek    uint16
   957  	Day          uint16
   958  	Hour         uint16
   959  	Minute       uint16
   960  	Second       uint16
   961  	Milliseconds uint16
   962  }
   963  
   964  type Timezoneinformation struct {
   965  	Bias         int32
   966  	StandardName [32]uint16
   967  	StandardDate Systemtime
   968  	StandardBias int32
   969  	DaylightName [32]uint16
   970  	DaylightDate Systemtime
   971  	DaylightBias int32
   972  }
   973  
   974  // Socket related.
   975  
   976  const (
   977  	AF_UNSPEC  = 0
   978  	AF_UNIX    = 1
   979  	AF_INET    = 2
   980  	AF_NETBIOS = 17
   981  	AF_INET6   = 23
   982  	AF_IRDA    = 26
   983  	AF_BTH     = 32
   984  
   985  	SOCK_STREAM    = 1
   986  	SOCK_DGRAM     = 2
   987  	SOCK_RAW       = 3
   988  	SOCK_RDM       = 4
   989  	SOCK_SEQPACKET = 5
   990  
   991  	IPPROTO_IP      = 0
   992  	IPPROTO_ICMP    = 1
   993  	IPPROTO_IGMP    = 2
   994  	BTHPROTO_RFCOMM = 3
   995  	IPPROTO_TCP     = 6
   996  	IPPROTO_UDP     = 17
   997  	IPPROTO_IPV6    = 41
   998  	IPPROTO_ICMPV6  = 58
   999  	IPPROTO_RM      = 113
  1000  
  1001  	SOL_SOCKET                = 0xffff
  1002  	SO_REUSEADDR              = 4
  1003  	SO_KEEPALIVE              = 8
  1004  	SO_DONTROUTE              = 16
  1005  	SO_BROADCAST              = 32
  1006  	SO_LINGER                 = 128
  1007  	SO_RCVBUF                 = 0x1002
  1008  	SO_RCVTIMEO               = 0x1006
  1009  	SO_SNDBUF                 = 0x1001
  1010  	SO_UPDATE_ACCEPT_CONTEXT  = 0x700b
  1011  	SO_UPDATE_CONNECT_CONTEXT = 0x7010
  1012  
  1013  	IOC_OUT                            = 0x40000000
  1014  	IOC_IN                             = 0x80000000
  1015  	IOC_VENDOR                         = 0x18000000
  1016  	IOC_INOUT                          = IOC_IN | IOC_OUT
  1017  	IOC_WS2                            = 0x08000000
  1018  	SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6
  1019  	SIO_KEEPALIVE_VALS                 = IOC_IN | IOC_VENDOR | 4
  1020  	SIO_UDP_CONNRESET                  = IOC_IN | IOC_VENDOR | 12
  1021  
  1022  	// cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460
  1023  
  1024  	IP_HDRINCL         = 0x2
  1025  	IP_TOS             = 0x3
  1026  	IP_TTL             = 0x4
  1027  	IP_MULTICAST_IF    = 0x9
  1028  	IP_MULTICAST_TTL   = 0xa
  1029  	IP_MULTICAST_LOOP  = 0xb
  1030  	IP_ADD_MEMBERSHIP  = 0xc
  1031  	IP_DROP_MEMBERSHIP = 0xd
  1032  	IP_PKTINFO         = 0x13
  1033  
  1034  	IPV6_V6ONLY         = 0x1b
  1035  	IPV6_UNICAST_HOPS   = 0x4
  1036  	IPV6_MULTICAST_IF   = 0x9
  1037  	IPV6_MULTICAST_HOPS = 0xa
  1038  	IPV6_MULTICAST_LOOP = 0xb
  1039  	IPV6_JOIN_GROUP     = 0xc
  1040  	IPV6_LEAVE_GROUP    = 0xd
  1041  	IPV6_PKTINFO        = 0x13
  1042  
  1043  	MSG_OOB       = 0x1
  1044  	MSG_PEEK      = 0x2
  1045  	MSG_DONTROUTE = 0x4
  1046  	MSG_WAITALL   = 0x8
  1047  
  1048  	MSG_TRUNC  = 0x0100
  1049  	MSG_CTRUNC = 0x0200
  1050  	MSG_BCAST  = 0x0400
  1051  	MSG_MCAST  = 0x0800
  1052  
  1053  	SOMAXCONN = 0x7fffffff
  1054  
  1055  	TCP_NODELAY = 1
  1056  
  1057  	SHUT_RD   = 0
  1058  	SHUT_WR   = 1
  1059  	SHUT_RDWR = 2
  1060  
  1061  	WSADESCRIPTION_LEN = 256
  1062  	WSASYS_STATUS_LEN  = 128
  1063  )
  1064  
  1065  type WSABuf struct {
  1066  	Len uint32
  1067  	Buf *byte
  1068  }
  1069  
  1070  type WSAMsg struct {
  1071  	Name        *syscall.RawSockaddrAny
  1072  	Namelen     int32
  1073  	Buffers     *WSABuf
  1074  	BufferCount uint32
  1075  	Control     WSABuf
  1076  	Flags       uint32
  1077  }
  1078  
  1079  // Flags for WSASocket
  1080  const (
  1081  	WSA_FLAG_OVERLAPPED             = 0x01
  1082  	WSA_FLAG_MULTIPOINT_C_ROOT      = 0x02
  1083  	WSA_FLAG_MULTIPOINT_C_LEAF      = 0x04
  1084  	WSA_FLAG_MULTIPOINT_D_ROOT      = 0x08
  1085  	WSA_FLAG_MULTIPOINT_D_LEAF      = 0x10
  1086  	WSA_FLAG_ACCESS_SYSTEM_SECURITY = 0x40
  1087  	WSA_FLAG_NO_HANDLE_INHERIT      = 0x80
  1088  	WSA_FLAG_REGISTERED_IO          = 0x100
  1089  )
  1090  
  1091  // Invented values to support what package os expects.
  1092  const (
  1093  	S_IFMT   = 0x1f000
  1094  	S_IFIFO  = 0x1000
  1095  	S_IFCHR  = 0x2000
  1096  	S_IFDIR  = 0x4000
  1097  	S_IFBLK  = 0x6000
  1098  	S_IFREG  = 0x8000
  1099  	S_IFLNK  = 0xa000
  1100  	S_IFSOCK = 0xc000
  1101  	S_ISUID  = 0x800
  1102  	S_ISGID  = 0x400
  1103  	S_ISVTX  = 0x200
  1104  	S_IRUSR  = 0x100
  1105  	S_IWRITE = 0x80
  1106  	S_IWUSR  = 0x80
  1107  	S_IXUSR  = 0x40
  1108  )
  1109  
  1110  const (
  1111  	FILE_TYPE_CHAR    = 0x0002
  1112  	FILE_TYPE_DISK    = 0x0001
  1113  	FILE_TYPE_PIPE    = 0x0003
  1114  	FILE_TYPE_REMOTE  = 0x8000
  1115  	FILE_TYPE_UNKNOWN = 0x0000
  1116  )
  1117  
  1118  type Hostent struct {
  1119  	Name     *byte
  1120  	Aliases  **byte
  1121  	AddrType uint16
  1122  	Length   uint16
  1123  	AddrList **byte
  1124  }
  1125  
  1126  type Protoent struct {
  1127  	Name    *byte
  1128  	Aliases **byte
  1129  	Proto   uint16
  1130  }
  1131  
  1132  const (
  1133  	DNS_TYPE_A       = 0x0001
  1134  	DNS_TYPE_NS      = 0x0002
  1135  	DNS_TYPE_MD      = 0x0003
  1136  	DNS_TYPE_MF      = 0x0004
  1137  	DNS_TYPE_CNAME   = 0x0005
  1138  	DNS_TYPE_SOA     = 0x0006
  1139  	DNS_TYPE_MB      = 0x0007
  1140  	DNS_TYPE_MG      = 0x0008
  1141  	DNS_TYPE_MR      = 0x0009
  1142  	DNS_TYPE_NULL    = 0x000a
  1143  	DNS_TYPE_WKS     = 0x000b
  1144  	DNS_TYPE_PTR     = 0x000c
  1145  	DNS_TYPE_HINFO   = 0x000d
  1146  	DNS_TYPE_MINFO   = 0x000e
  1147  	DNS_TYPE_MX      = 0x000f
  1148  	DNS_TYPE_TEXT    = 0x0010
  1149  	DNS_TYPE_RP      = 0x0011
  1150  	DNS_TYPE_AFSDB   = 0x0012
  1151  	DNS_TYPE_X25     = 0x0013
  1152  	DNS_TYPE_ISDN    = 0x0014
  1153  	DNS_TYPE_RT      = 0x0015
  1154  	DNS_TYPE_NSAP    = 0x0016
  1155  	DNS_TYPE_NSAPPTR = 0x0017
  1156  	DNS_TYPE_SIG     = 0x0018
  1157  	DNS_TYPE_KEY     = 0x0019
  1158  	DNS_TYPE_PX      = 0x001a
  1159  	DNS_TYPE_GPOS    = 0x001b
  1160  	DNS_TYPE_AAAA    = 0x001c
  1161  	DNS_TYPE_LOC     = 0x001d
  1162  	DNS_TYPE_NXT     = 0x001e
  1163  	DNS_TYPE_EID     = 0x001f
  1164  	DNS_TYPE_NIMLOC  = 0x0020
  1165  	DNS_TYPE_SRV     = 0x0021
  1166  	DNS_TYPE_ATMA    = 0x0022
  1167  	DNS_TYPE_NAPTR   = 0x0023
  1168  	DNS_TYPE_KX      = 0x0024
  1169  	DNS_TYPE_CERT    = 0x0025
  1170  	DNS_TYPE_A6      = 0x0026
  1171  	DNS_TYPE_DNAME   = 0x0027
  1172  	DNS_TYPE_SINK    = 0x0028
  1173  	DNS_TYPE_OPT     = 0x0029
  1174  	DNS_TYPE_DS      = 0x002B
  1175  	DNS_TYPE_RRSIG   = 0x002E
  1176  	DNS_TYPE_NSEC    = 0x002F
  1177  	DNS_TYPE_DNSKEY  = 0x0030
  1178  	DNS_TYPE_DHCID   = 0x0031
  1179  	DNS_TYPE_UINFO   = 0x0064
  1180  	DNS_TYPE_UID     = 0x0065
  1181  	DNS_TYPE_GID     = 0x0066
  1182  	DNS_TYPE_UNSPEC  = 0x0067
  1183  	DNS_TYPE_ADDRS   = 0x00f8
  1184  	DNS_TYPE_TKEY    = 0x00f9
  1185  	DNS_TYPE_TSIG    = 0x00fa
  1186  	DNS_TYPE_IXFR    = 0x00fb
  1187  	DNS_TYPE_AXFR    = 0x00fc
  1188  	DNS_TYPE_MAILB   = 0x00fd
  1189  	DNS_TYPE_MAILA   = 0x00fe
  1190  	DNS_TYPE_ALL     = 0x00ff
  1191  	DNS_TYPE_ANY     = 0x00ff
  1192  	DNS_TYPE_WINS    = 0xff01
  1193  	DNS_TYPE_WINSR   = 0xff02
  1194  	DNS_TYPE_NBSTAT  = 0xff01
  1195  )
  1196  
  1197  const (
  1198  	// flags inside DNSRecord.Dw
  1199  	DnsSectionQuestion   = 0x0000
  1200  	DnsSectionAnswer     = 0x0001
  1201  	DnsSectionAuthority  = 0x0002
  1202  	DnsSectionAdditional = 0x0003
  1203  )
  1204  
  1205  type DNSSRVData struct {
  1206  	Target   *uint16
  1207  	Priority uint16
  1208  	Weight   uint16
  1209  	Port     uint16
  1210  	Pad      uint16
  1211  }
  1212  
  1213  type DNSPTRData struct {
  1214  	Host *uint16
  1215  }
  1216  
  1217  type DNSMXData struct {
  1218  	NameExchange *uint16
  1219  	Preference   uint16
  1220  	Pad          uint16
  1221  }
  1222  
  1223  type DNSTXTData struct {
  1224  	StringCount uint16
  1225  	StringArray [1]*uint16
  1226  }
  1227  
  1228  type DNSRecord struct {
  1229  	Next     *DNSRecord
  1230  	Name     *uint16
  1231  	Type     uint16
  1232  	Length   uint16
  1233  	Dw       uint32
  1234  	Ttl      uint32
  1235  	Reserved uint32
  1236  	Data     [40]byte
  1237  }
  1238  
  1239  const (
  1240  	TF_DISCONNECT         = 1
  1241  	TF_REUSE_SOCKET       = 2
  1242  	TF_WRITE_BEHIND       = 4
  1243  	TF_USE_DEFAULT_WORKER = 0
  1244  	TF_USE_SYSTEM_THREAD  = 16
  1245  	TF_USE_KERNEL_APC     = 32
  1246  )
  1247  
  1248  type TransmitFileBuffers struct {
  1249  	Head       uintptr
  1250  	HeadLength uint32
  1251  	Tail       uintptr
  1252  	TailLength uint32
  1253  }
  1254  
  1255  const (
  1256  	IFF_UP           = 1
  1257  	IFF_BROADCAST    = 2
  1258  	IFF_LOOPBACK     = 4
  1259  	IFF_POINTTOPOINT = 8
  1260  	IFF_MULTICAST    = 16
  1261  )
  1262  
  1263  const SIO_GET_INTERFACE_LIST = 0x4004747F
  1264  
  1265  // TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old.
  1266  // will be fixed to change variable type as suitable.
  1267  
  1268  type SockaddrGen [24]byte
  1269  
  1270  type InterfaceInfo struct {
  1271  	Flags            uint32
  1272  	Address          SockaddrGen
  1273  	BroadcastAddress SockaddrGen
  1274  	Netmask          SockaddrGen
  1275  }
  1276  
  1277  type IpAddressString struct {
  1278  	String [16]byte
  1279  }
  1280  
  1281  type IpMaskString IpAddressString
  1282  
  1283  type IpAddrString struct {
  1284  	Next      *IpAddrString
  1285  	IpAddress IpAddressString
  1286  	IpMask    IpMaskString
  1287  	Context   uint32
  1288  }
  1289  
  1290  const MAX_ADAPTER_NAME_LENGTH = 256
  1291  const MAX_ADAPTER_DESCRIPTION_LENGTH = 128
  1292  const MAX_ADAPTER_ADDRESS_LENGTH = 8
  1293  
  1294  type IpAdapterInfo struct {
  1295  	Next                *IpAdapterInfo
  1296  	ComboIndex          uint32
  1297  	AdapterName         [MAX_ADAPTER_NAME_LENGTH + 4]byte
  1298  	Description         [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte
  1299  	AddressLength       uint32
  1300  	Address             [MAX_ADAPTER_ADDRESS_LENGTH]byte
  1301  	Index               uint32
  1302  	Type                uint32
  1303  	DhcpEnabled         uint32
  1304  	CurrentIpAddress    *IpAddrString
  1305  	IpAddressList       IpAddrString
  1306  	GatewayList         IpAddrString
  1307  	DhcpServer          IpAddrString
  1308  	HaveWins            bool
  1309  	PrimaryWinsServer   IpAddrString
  1310  	SecondaryWinsServer IpAddrString
  1311  	LeaseObtained       int64
  1312  	LeaseExpires        int64
  1313  }
  1314  
  1315  const MAXLEN_PHYSADDR = 8
  1316  const MAX_INTERFACE_NAME_LEN = 256
  1317  const MAXLEN_IFDESCR = 256
  1318  
  1319  type MibIfRow struct {
  1320  	Name            [MAX_INTERFACE_NAME_LEN]uint16
  1321  	Index           uint32
  1322  	Type            uint32
  1323  	Mtu             uint32
  1324  	Speed           uint32
  1325  	PhysAddrLen     uint32
  1326  	PhysAddr        [MAXLEN_PHYSADDR]byte
  1327  	AdminStatus     uint32
  1328  	OperStatus      uint32
  1329  	LastChange      uint32
  1330  	InOctets        uint32
  1331  	InUcastPkts     uint32
  1332  	InNUcastPkts    uint32
  1333  	InDiscards      uint32
  1334  	InErrors        uint32
  1335  	InUnknownProtos uint32
  1336  	OutOctets       uint32
  1337  	OutUcastPkts    uint32
  1338  	OutNUcastPkts   uint32
  1339  	OutDiscards     uint32
  1340  	OutErrors       uint32
  1341  	OutQLen         uint32
  1342  	DescrLen        uint32
  1343  	Descr           [MAXLEN_IFDESCR]byte
  1344  }
  1345  
  1346  type CertInfo struct {
  1347  	Version              uint32
  1348  	SerialNumber         CryptIntegerBlob
  1349  	SignatureAlgorithm   CryptAlgorithmIdentifier
  1350  	Issuer               CertNameBlob
  1351  	NotBefore            Filetime
  1352  	NotAfter             Filetime
  1353  	Subject              CertNameBlob
  1354  	SubjectPublicKeyInfo CertPublicKeyInfo
  1355  	IssuerUniqueId       CryptBitBlob
  1356  	SubjectUniqueId      CryptBitBlob
  1357  	CountExtensions      uint32
  1358  	Extensions           *CertExtension
  1359  }
  1360  
  1361  type CertExtension struct {
  1362  	ObjId    *byte
  1363  	Critical int32
  1364  	Value    CryptObjidBlob
  1365  }
  1366  
  1367  type CryptAlgorithmIdentifier struct {
  1368  	ObjId      *byte
  1369  	Parameters CryptObjidBlob
  1370  }
  1371  
  1372  type CertPublicKeyInfo struct {
  1373  	Algorithm CryptAlgorithmIdentifier
  1374  	PublicKey CryptBitBlob
  1375  }
  1376  
  1377  type DataBlob struct {
  1378  	Size uint32
  1379  	Data *byte
  1380  }
  1381  type CryptIntegerBlob DataBlob
  1382  type CryptUintBlob DataBlob
  1383  type CryptObjidBlob DataBlob
  1384  type CertNameBlob DataBlob
  1385  type CertRdnValueBlob DataBlob
  1386  type CertBlob DataBlob
  1387  type CrlBlob DataBlob
  1388  type CryptDataBlob DataBlob
  1389  type CryptHashBlob DataBlob
  1390  type CryptDigestBlob DataBlob
  1391  type CryptDerBlob DataBlob
  1392  type CryptAttrBlob DataBlob
  1393  
  1394  type CryptBitBlob struct {
  1395  	Size       uint32
  1396  	Data       *byte
  1397  	UnusedBits uint32
  1398  }
  1399  
  1400  type CertContext struct {
  1401  	EncodingType uint32
  1402  	EncodedCert  *byte
  1403  	Length       uint32
  1404  	CertInfo     *CertInfo
  1405  	Store        Handle
  1406  }
  1407  
  1408  type CertChainContext struct {
  1409  	Size                       uint32
  1410  	TrustStatus                CertTrustStatus
  1411  	ChainCount                 uint32
  1412  	Chains                     **CertSimpleChain
  1413  	LowerQualityChainCount     uint32
  1414  	LowerQualityChains         **CertChainContext
  1415  	HasRevocationFreshnessTime uint32
  1416  	RevocationFreshnessTime    uint32
  1417  }
  1418  
  1419  type CertTrustListInfo struct {
  1420  	// Not implemented
  1421  }
  1422  
  1423  type CertSimpleChain struct {
  1424  	Size                       uint32
  1425  	TrustStatus                CertTrustStatus
  1426  	NumElements                uint32
  1427  	Elements                   **CertChainElement
  1428  	TrustListInfo              *CertTrustListInfo
  1429  	HasRevocationFreshnessTime uint32
  1430  	RevocationFreshnessTime    uint32
  1431  }
  1432  
  1433  type CertChainElement struct {
  1434  	Size              uint32
  1435  	CertContext       *CertContext
  1436  	TrustStatus       CertTrustStatus
  1437  	RevocationInfo    *CertRevocationInfo
  1438  	IssuanceUsage     *CertEnhKeyUsage
  1439  	ApplicationUsage  *CertEnhKeyUsage
  1440  	ExtendedErrorInfo *uint16
  1441  }
  1442  
  1443  type CertRevocationCrlInfo struct {
  1444  	// Not implemented
  1445  }
  1446  
  1447  type CertRevocationInfo struct {
  1448  	Size             uint32
  1449  	RevocationResult uint32
  1450  	RevocationOid    *byte
  1451  	OidSpecificInfo  Pointer
  1452  	HasFreshnessTime uint32
  1453  	FreshnessTime    uint32
  1454  	CrlInfo          *CertRevocationCrlInfo
  1455  }
  1456  
  1457  type CertTrustStatus struct {
  1458  	ErrorStatus uint32
  1459  	InfoStatus  uint32
  1460  }
  1461  
  1462  type CertUsageMatch struct {
  1463  	Type  uint32
  1464  	Usage CertEnhKeyUsage
  1465  }
  1466  
  1467  type CertEnhKeyUsage struct {
  1468  	Length           uint32
  1469  	UsageIdentifiers **byte
  1470  }
  1471  
  1472  type CertChainPara struct {
  1473  	Size                         uint32
  1474  	RequestedUsage               CertUsageMatch
  1475  	RequstedIssuancePolicy       CertUsageMatch
  1476  	URLRetrievalTimeout          uint32
  1477  	CheckRevocationFreshnessTime uint32
  1478  	RevocationFreshnessTime      uint32
  1479  	CacheResync                  *Filetime
  1480  }
  1481  
  1482  type CertChainPolicyPara struct {
  1483  	Size            uint32
  1484  	Flags           uint32
  1485  	ExtraPolicyPara Pointer
  1486  }
  1487  
  1488  type SSLExtraCertChainPolicyPara struct {
  1489  	Size       uint32
  1490  	AuthType   uint32
  1491  	Checks     uint32
  1492  	ServerName *uint16
  1493  }
  1494  
  1495  type CertChainPolicyStatus struct {
  1496  	Size              uint32
  1497  	Error             uint32
  1498  	ChainIndex        uint32
  1499  	ElementIndex      uint32
  1500  	ExtraPolicyStatus Pointer
  1501  }
  1502  
  1503  type CertPolicyInfo struct {
  1504  	Identifier      *byte
  1505  	CountQualifiers uint32
  1506  	Qualifiers      *CertPolicyQualifierInfo
  1507  }
  1508  
  1509  type CertPoliciesInfo struct {
  1510  	Count       uint32
  1511  	PolicyInfos *CertPolicyInfo
  1512  }
  1513  
  1514  type CertPolicyQualifierInfo struct {
  1515  	// Not implemented
  1516  }
  1517  
  1518  type CertStrongSignPara struct {
  1519  	Size                      uint32
  1520  	InfoChoice                uint32
  1521  	InfoOrSerializedInfoOrOID unsafe.Pointer
  1522  }
  1523  
  1524  type CryptProtectPromptStruct struct {
  1525  	Size        uint32
  1526  	PromptFlags uint32
  1527  	App         HWND
  1528  	Prompt      *uint16
  1529  }
  1530  
  1531  type CertChainFindByIssuerPara struct {
  1532  	Size                   uint32
  1533  	UsageIdentifier        *byte
  1534  	KeySpec                uint32
  1535  	AcquirePrivateKeyFlags uint32
  1536  	IssuerCount            uint32
  1537  	Issuer                 Pointer
  1538  	FindCallback           Pointer
  1539  	FindArg                Pointer
  1540  	IssuerChainIndex       *uint32
  1541  	IssuerElementIndex     *uint32
  1542  }
  1543  
  1544  type WinTrustData struct {
  1545  	Size                            uint32
  1546  	PolicyCallbackData              uintptr
  1547  	SIPClientData                   uintptr
  1548  	UIChoice                        uint32
  1549  	RevocationChecks                uint32
  1550  	UnionChoice                     uint32
  1551  	FileOrCatalogOrBlobOrSgnrOrCert unsafe.Pointer
  1552  	StateAction                     uint32
  1553  	StateData                       Handle
  1554  	URLReference                    *uint16
  1555  	ProvFlags                       uint32
  1556  	UIContext                       uint32
  1557  	SignatureSettings               *WinTrustSignatureSettings
  1558  }
  1559  
  1560  type WinTrustFileInfo struct {
  1561  	Size         uint32
  1562  	FilePath     *uint16
  1563  	File         Handle
  1564  	KnownSubject *GUID
  1565  }
  1566  
  1567  type WinTrustSignatureSettings struct {
  1568  	Size             uint32
  1569  	Index            uint32
  1570  	Flags            uint32
  1571  	SecondarySigs    uint32
  1572  	VerifiedSigIndex uint32
  1573  	CryptoPolicy     *CertStrongSignPara
  1574  }
  1575  
  1576  const (
  1577  	// do not reorder
  1578  	HKEY_CLASSES_ROOT = 0x80000000 + iota
  1579  	HKEY_CURRENT_USER
  1580  	HKEY_LOCAL_MACHINE
  1581  	HKEY_USERS
  1582  	HKEY_PERFORMANCE_DATA
  1583  	HKEY_CURRENT_CONFIG
  1584  	HKEY_DYN_DATA
  1585  
  1586  	KEY_QUERY_VALUE        = 1
  1587  	KEY_SET_VALUE          = 2
  1588  	KEY_CREATE_SUB_KEY     = 4
  1589  	KEY_ENUMERATE_SUB_KEYS = 8
  1590  	KEY_NOTIFY             = 16
  1591  	KEY_CREATE_LINK        = 32
  1592  	KEY_WRITE              = 0x20006
  1593  	KEY_EXECUTE            = 0x20019
  1594  	KEY_READ               = 0x20019
  1595  	KEY_WOW64_64KEY        = 0x0100
  1596  	KEY_WOW64_32KEY        = 0x0200
  1597  	KEY_ALL_ACCESS         = 0xf003f
  1598  )
  1599  
  1600  const (
  1601  	// do not reorder
  1602  	REG_NONE = iota
  1603  	REG_SZ
  1604  	REG_EXPAND_SZ
  1605  	REG_BINARY
  1606  	REG_DWORD_LITTLE_ENDIAN
  1607  	REG_DWORD_BIG_ENDIAN
  1608  	REG_LINK
  1609  	REG_MULTI_SZ
  1610  	REG_RESOURCE_LIST
  1611  	REG_FULL_RESOURCE_DESCRIPTOR
  1612  	REG_RESOURCE_REQUIREMENTS_LIST
  1613  	REG_QWORD_LITTLE_ENDIAN
  1614  	REG_DWORD = REG_DWORD_LITTLE_ENDIAN
  1615  	REG_QWORD = REG_QWORD_LITTLE_ENDIAN
  1616  )
  1617  
  1618  const (
  1619  	EVENT_MODIFY_STATE = 0x0002
  1620  	EVENT_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1621  
  1622  	MUTANT_QUERY_STATE = 0x0001
  1623  	MUTANT_ALL_ACCESS  = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE
  1624  
  1625  	SEMAPHORE_MODIFY_STATE = 0x0002
  1626  	SEMAPHORE_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1627  
  1628  	TIMER_QUERY_STATE  = 0x0001
  1629  	TIMER_MODIFY_STATE = 0x0002
  1630  	TIMER_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE | TIMER_MODIFY_STATE
  1631  
  1632  	MUTEX_MODIFY_STATE = MUTANT_QUERY_STATE
  1633  	MUTEX_ALL_ACCESS   = MUTANT_ALL_ACCESS
  1634  
  1635  	CREATE_EVENT_MANUAL_RESET  = 0x1
  1636  	CREATE_EVENT_INITIAL_SET   = 0x2
  1637  	CREATE_MUTEX_INITIAL_OWNER = 0x1
  1638  )
  1639  
  1640  type AddrinfoW struct {
  1641  	Flags     int32
  1642  	Family    int32
  1643  	Socktype  int32
  1644  	Protocol  int32
  1645  	Addrlen   uintptr
  1646  	Canonname *uint16
  1647  	Addr      uintptr
  1648  	Next      *AddrinfoW
  1649  }
  1650  
  1651  const (
  1652  	AI_PASSIVE     = 1
  1653  	AI_CANONNAME   = 2
  1654  	AI_NUMERICHOST = 4
  1655  )
  1656  
  1657  type GUID struct {
  1658  	Data1 uint32
  1659  	Data2 uint16
  1660  	Data3 uint16
  1661  	Data4 [8]byte
  1662  }
  1663  
  1664  var WSAID_CONNECTEX = GUID{
  1665  	0x25a207b9,
  1666  	0xddf3,
  1667  	0x4660,
  1668  	[8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e},
  1669  }
  1670  
  1671  var WSAID_WSASENDMSG = GUID{
  1672  	0xa441e712,
  1673  	0x754f,
  1674  	0x43ca,
  1675  	[8]byte{0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d},
  1676  }
  1677  
  1678  var WSAID_WSARECVMSG = GUID{
  1679  	0xf689d7c8,
  1680  	0x6f1f,
  1681  	0x436b,
  1682  	[8]byte{0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22},
  1683  }
  1684  
  1685  const (
  1686  	FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
  1687  	FILE_SKIP_SET_EVENT_ON_HANDLE        = 2
  1688  )
  1689  
  1690  const (
  1691  	WSAPROTOCOL_LEN    = 255
  1692  	MAX_PROTOCOL_CHAIN = 7
  1693  	BASE_PROTOCOL      = 1
  1694  	LAYERED_PROTOCOL   = 0
  1695  
  1696  	XP1_CONNECTIONLESS           = 0x00000001
  1697  	XP1_GUARANTEED_DELIVERY      = 0x00000002
  1698  	XP1_GUARANTEED_ORDER         = 0x00000004
  1699  	XP1_MESSAGE_ORIENTED         = 0x00000008
  1700  	XP1_PSEUDO_STREAM            = 0x00000010
  1701  	XP1_GRACEFUL_CLOSE           = 0x00000020
  1702  	XP1_EXPEDITED_DATA           = 0x00000040
  1703  	XP1_CONNECT_DATA             = 0x00000080
  1704  	XP1_DISCONNECT_DATA          = 0x00000100
  1705  	XP1_SUPPORT_BROADCAST        = 0x00000200
  1706  	XP1_SUPPORT_MULTIPOINT       = 0x00000400
  1707  	XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800
  1708  	XP1_MULTIPOINT_DATA_PLANE    = 0x00001000
  1709  	XP1_QOS_SUPPORTED            = 0x00002000
  1710  	XP1_UNI_SEND                 = 0x00008000
  1711  	XP1_UNI_RECV                 = 0x00010000
  1712  	XP1_IFS_HANDLES              = 0x00020000
  1713  	XP1_PARTIAL_MESSAGE          = 0x00040000
  1714  	XP1_SAN_SUPPORT_SDP          = 0x00080000
  1715  
  1716  	PFL_MULTIPLE_PROTO_ENTRIES  = 0x00000001
  1717  	PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002
  1718  	PFL_HIDDEN                  = 0x00000004
  1719  	PFL_MATCHES_PROTOCOL_ZERO   = 0x00000008
  1720  	PFL_NETWORKDIRECT_PROVIDER  = 0x00000010
  1721  )
  1722  
  1723  type WSAProtocolInfo struct {
  1724  	ServiceFlags1     uint32
  1725  	ServiceFlags2     uint32
  1726  	ServiceFlags3     uint32
  1727  	ServiceFlags4     uint32
  1728  	ProviderFlags     uint32
  1729  	ProviderId        GUID
  1730  	CatalogEntryId    uint32
  1731  	ProtocolChain     WSAProtocolChain
  1732  	Version           int32
  1733  	AddressFamily     int32
  1734  	MaxSockAddr       int32
  1735  	MinSockAddr       int32
  1736  	SocketType        int32
  1737  	Protocol          int32
  1738  	ProtocolMaxOffset int32
  1739  	NetworkByteOrder  int32
  1740  	SecurityScheme    int32
  1741  	MessageSize       uint32
  1742  	ProviderReserved  uint32
  1743  	ProtocolName      [WSAPROTOCOL_LEN + 1]uint16
  1744  }
  1745  
  1746  type WSAProtocolChain struct {
  1747  	ChainLen     int32
  1748  	ChainEntries [MAX_PROTOCOL_CHAIN]uint32
  1749  }
  1750  
  1751  type TCPKeepalive struct {
  1752  	OnOff    uint32
  1753  	Time     uint32
  1754  	Interval uint32
  1755  }
  1756  
  1757  type symbolicLinkReparseBuffer struct {
  1758  	SubstituteNameOffset uint16
  1759  	SubstituteNameLength uint16
  1760  	PrintNameOffset      uint16
  1761  	PrintNameLength      uint16
  1762  	Flags                uint32
  1763  	PathBuffer           [1]uint16
  1764  }
  1765  
  1766  type mountPointReparseBuffer struct {
  1767  	SubstituteNameOffset uint16
  1768  	SubstituteNameLength uint16
  1769  	PrintNameOffset      uint16
  1770  	PrintNameLength      uint16
  1771  	PathBuffer           [1]uint16
  1772  }
  1773  
  1774  type reparseDataBuffer struct {
  1775  	ReparseTag        uint32
  1776  	ReparseDataLength uint16
  1777  	Reserved          uint16
  1778  
  1779  	// GenericReparseBuffer
  1780  	reparseBuffer byte
  1781  }
  1782  
  1783  const (
  1784  	FSCTL_GET_REPARSE_POINT          = 0x900A8
  1785  	MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
  1786  	IO_REPARSE_TAG_MOUNT_POINT       = 0xA0000003
  1787  	IO_REPARSE_TAG_SYMLINK           = 0xA000000C
  1788  	SYMBOLIC_LINK_FLAG_DIRECTORY     = 0x1
  1789  )
  1790  
  1791  const (
  1792  	ComputerNameNetBIOS                   = 0
  1793  	ComputerNameDnsHostname               = 1
  1794  	ComputerNameDnsDomain                 = 2
  1795  	ComputerNameDnsFullyQualified         = 3
  1796  	ComputerNamePhysicalNetBIOS           = 4
  1797  	ComputerNamePhysicalDnsHostname       = 5
  1798  	ComputerNamePhysicalDnsDomain         = 6
  1799  	ComputerNamePhysicalDnsFullyQualified = 7
  1800  	ComputerNameMax                       = 8
  1801  )
  1802  
  1803  // For MessageBox()
  1804  const (
  1805  	MB_OK                   = 0x00000000
  1806  	MB_OKCANCEL             = 0x00000001
  1807  	MB_ABORTRETRYIGNORE     = 0x00000002
  1808  	MB_YESNOCANCEL          = 0x00000003
  1809  	MB_YESNO                = 0x00000004
  1810  	MB_RETRYCANCEL          = 0x00000005
  1811  	MB_CANCELTRYCONTINUE    = 0x00000006
  1812  	MB_ICONHAND             = 0x00000010
  1813  	MB_ICONQUESTION         = 0x00000020
  1814  	MB_ICONEXCLAMATION      = 0x00000030
  1815  	MB_ICONASTERISK         = 0x00000040
  1816  	MB_USERICON             = 0x00000080
  1817  	MB_ICONWARNING          = MB_ICONEXCLAMATION
  1818  	MB_ICONERROR            = MB_ICONHAND
  1819  	MB_ICONINFORMATION      = MB_ICONASTERISK
  1820  	MB_ICONSTOP             = MB_ICONHAND
  1821  	MB_DEFBUTTON1           = 0x00000000
  1822  	MB_DEFBUTTON2           = 0x00000100
  1823  	MB_DEFBUTTON3           = 0x00000200
  1824  	MB_DEFBUTTON4           = 0x00000300
  1825  	MB_APPLMODAL            = 0x00000000
  1826  	MB_SYSTEMMODAL          = 0x00001000
  1827  	MB_TASKMODAL            = 0x00002000
  1828  	MB_HELP                 = 0x00004000
  1829  	MB_NOFOCUS              = 0x00008000
  1830  	MB_SETFOREGROUND        = 0x00010000
  1831  	MB_DEFAULT_DESKTOP_ONLY = 0x00020000
  1832  	MB_TOPMOST              = 0x00040000
  1833  	MB_RIGHT                = 0x00080000
  1834  	MB_RTLREADING           = 0x00100000
  1835  	MB_SERVICE_NOTIFICATION = 0x00200000
  1836  )
  1837  
  1838  const (
  1839  	MOVEFILE_REPLACE_EXISTING      = 0x1
  1840  	MOVEFILE_COPY_ALLOWED          = 0x2
  1841  	MOVEFILE_DELAY_UNTIL_REBOOT    = 0x4
  1842  	MOVEFILE_WRITE_THROUGH         = 0x8
  1843  	MOVEFILE_CREATE_HARDLINK       = 0x10
  1844  	MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20
  1845  )
  1846  
  1847  const GAA_FLAG_INCLUDE_PREFIX = 0x00000010
  1848  
  1849  const (
  1850  	IF_TYPE_OTHER              = 1
  1851  	IF_TYPE_ETHERNET_CSMACD    = 6
  1852  	IF_TYPE_ISO88025_TOKENRING = 9
  1853  	IF_TYPE_PPP                = 23
  1854  	IF_TYPE_SOFTWARE_LOOPBACK  = 24
  1855  	IF_TYPE_ATM                = 37
  1856  	IF_TYPE_IEEE80211          = 71
  1857  	IF_TYPE_TUNNEL             = 131
  1858  	IF_TYPE_IEEE1394           = 144
  1859  )
  1860  
  1861  type SocketAddress struct {
  1862  	Sockaddr       *syscall.RawSockaddrAny
  1863  	SockaddrLength int32
  1864  }
  1865  
  1866  // IP returns an IPv4 or IPv6 address, or nil if the underlying SocketAddress is neither.
  1867  func (addr *SocketAddress) IP() net.IP {
  1868  	if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet4{}) && addr.Sockaddr.Addr.Family == AF_INET {
  1869  		return (*RawSockaddrInet4)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  1870  	} else if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet6{}) && addr.Sockaddr.Addr.Family == AF_INET6 {
  1871  		return (*RawSockaddrInet6)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  1872  	}
  1873  	return nil
  1874  }
  1875  
  1876  type IpAdapterUnicastAddress struct {
  1877  	Length             uint32
  1878  	Flags              uint32
  1879  	Next               *IpAdapterUnicastAddress
  1880  	Address            SocketAddress
  1881  	PrefixOrigin       int32
  1882  	SuffixOrigin       int32
  1883  	DadState           int32
  1884  	ValidLifetime      uint32
  1885  	PreferredLifetime  uint32
  1886  	LeaseLifetime      uint32
  1887  	OnLinkPrefixLength uint8
  1888  }
  1889  
  1890  type IpAdapterAnycastAddress struct {
  1891  	Length  uint32
  1892  	Flags   uint32
  1893  	Next    *IpAdapterAnycastAddress
  1894  	Address SocketAddress
  1895  }
  1896  
  1897  type IpAdapterMulticastAddress struct {
  1898  	Length  uint32
  1899  	Flags   uint32
  1900  	Next    *IpAdapterMulticastAddress
  1901  	Address SocketAddress
  1902  }
  1903  
  1904  type IpAdapterDnsServerAdapter struct {
  1905  	Length   uint32
  1906  	Reserved uint32
  1907  	Next     *IpAdapterDnsServerAdapter
  1908  	Address  SocketAddress
  1909  }
  1910  
  1911  type IpAdapterPrefix struct {
  1912  	Length       uint32
  1913  	Flags        uint32
  1914  	Next         *IpAdapterPrefix
  1915  	Address      SocketAddress
  1916  	PrefixLength uint32
  1917  }
  1918  
  1919  type IpAdapterAddresses struct {
  1920  	Length                uint32
  1921  	IfIndex               uint32
  1922  	Next                  *IpAdapterAddresses
  1923  	AdapterName           *byte
  1924  	FirstUnicastAddress   *IpAdapterUnicastAddress
  1925  	FirstAnycastAddress   *IpAdapterAnycastAddress
  1926  	FirstMulticastAddress *IpAdapterMulticastAddress
  1927  	FirstDnsServerAddress *IpAdapterDnsServerAdapter
  1928  	DnsSuffix             *uint16
  1929  	Description           *uint16
  1930  	FriendlyName          *uint16
  1931  	PhysicalAddress       [syscall.MAX_ADAPTER_ADDRESS_LENGTH]byte
  1932  	PhysicalAddressLength uint32
  1933  	Flags                 uint32
  1934  	Mtu                   uint32
  1935  	IfType                uint32
  1936  	OperStatus            uint32
  1937  	Ipv6IfIndex           uint32
  1938  	ZoneIndices           [16]uint32
  1939  	FirstPrefix           *IpAdapterPrefix
  1940  	/* more fields might be present here. */
  1941  }
  1942  
  1943  const (
  1944  	IfOperStatusUp             = 1
  1945  	IfOperStatusDown           = 2
  1946  	IfOperStatusTesting        = 3
  1947  	IfOperStatusUnknown        = 4
  1948  	IfOperStatusDormant        = 5
  1949  	IfOperStatusNotPresent     = 6
  1950  	IfOperStatusLowerLayerDown = 7
  1951  )
  1952  
  1953  // Console related constants used for the mode parameter to SetConsoleMode. See
  1954  // https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
  1955  
  1956  const (
  1957  	ENABLE_PROCESSED_INPUT        = 0x1
  1958  	ENABLE_LINE_INPUT             = 0x2
  1959  	ENABLE_ECHO_INPUT             = 0x4
  1960  	ENABLE_WINDOW_INPUT           = 0x8
  1961  	ENABLE_MOUSE_INPUT            = 0x10
  1962  	ENABLE_INSERT_MODE            = 0x20
  1963  	ENABLE_QUICK_EDIT_MODE        = 0x40
  1964  	ENABLE_EXTENDED_FLAGS         = 0x80
  1965  	ENABLE_AUTO_POSITION          = 0x100
  1966  	ENABLE_VIRTUAL_TERMINAL_INPUT = 0x200
  1967  
  1968  	ENABLE_PROCESSED_OUTPUT            = 0x1
  1969  	ENABLE_WRAP_AT_EOL_OUTPUT          = 0x2
  1970  	ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
  1971  	DISABLE_NEWLINE_AUTO_RETURN        = 0x8
  1972  	ENABLE_LVB_GRID_WORLDWIDE          = 0x10
  1973  )
  1974  
  1975  type Coord struct {
  1976  	X int16
  1977  	Y int16
  1978  }
  1979  
  1980  type SmallRect struct {
  1981  	Left   int16
  1982  	Top    int16
  1983  	Right  int16
  1984  	Bottom int16
  1985  }
  1986  
  1987  // Used with GetConsoleScreenBuffer to retrieve information about a console
  1988  // screen buffer. See
  1989  // https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str
  1990  // for details.
  1991  
  1992  type ConsoleScreenBufferInfo struct {
  1993  	Size              Coord
  1994  	CursorPosition    Coord
  1995  	Attributes        uint16
  1996  	Window            SmallRect
  1997  	MaximumWindowSize Coord
  1998  }
  1999  
  2000  const UNIX_PATH_MAX = 108 // defined in afunix.h
  2001  
  2002  const (
  2003  	// flags for JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags
  2004  	JOB_OBJECT_LIMIT_ACTIVE_PROCESS             = 0x00000008
  2005  	JOB_OBJECT_LIMIT_AFFINITY                   = 0x00000010
  2006  	JOB_OBJECT_LIMIT_BREAKAWAY_OK               = 0x00000800
  2007  	JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x00000400
  2008  	JOB_OBJECT_LIMIT_JOB_MEMORY                 = 0x00000200
  2009  	JOB_OBJECT_LIMIT_JOB_TIME                   = 0x00000004
  2010  	JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE          = 0x00002000
  2011  	JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME          = 0x00000040
  2012  	JOB_OBJECT_LIMIT_PRIORITY_CLASS             = 0x00000020
  2013  	JOB_OBJECT_LIMIT_PROCESS_MEMORY             = 0x00000100
  2014  	JOB_OBJECT_LIMIT_PROCESS_TIME               = 0x00000002
  2015  	JOB_OBJECT_LIMIT_SCHEDULING_CLASS           = 0x00000080
  2016  	JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK        = 0x00001000
  2017  	JOB_OBJECT_LIMIT_SUBSET_AFFINITY            = 0x00004000
  2018  	JOB_OBJECT_LIMIT_WORKINGSET                 = 0x00000001
  2019  )
  2020  
  2021  type IO_COUNTERS struct {
  2022  	ReadOperationCount  uint64
  2023  	WriteOperationCount uint64
  2024  	OtherOperationCount uint64
  2025  	ReadTransferCount   uint64
  2026  	WriteTransferCount  uint64
  2027  	OtherTransferCount  uint64
  2028  }
  2029  
  2030  type JOBOBJECT_EXTENDED_LIMIT_INFORMATION struct {
  2031  	BasicLimitInformation JOBOBJECT_BASIC_LIMIT_INFORMATION
  2032  	IoInfo                IO_COUNTERS
  2033  	ProcessMemoryLimit    uintptr
  2034  	JobMemoryLimit        uintptr
  2035  	PeakProcessMemoryUsed uintptr
  2036  	PeakJobMemoryUsed     uintptr
  2037  }
  2038  
  2039  const (
  2040  	// UIRestrictionsClass
  2041  	JOB_OBJECT_UILIMIT_DESKTOP          = 0x00000040
  2042  	JOB_OBJECT_UILIMIT_DISPLAYSETTINGS  = 0x00000010
  2043  	JOB_OBJECT_UILIMIT_EXITWINDOWS      = 0x00000080
  2044  	JOB_OBJECT_UILIMIT_GLOBALATOMS      = 0x00000020
  2045  	JOB_OBJECT_UILIMIT_HANDLES          = 0x00000001
  2046  	JOB_OBJECT_UILIMIT_READCLIPBOARD    = 0x00000002
  2047  	JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = 0x00000008
  2048  	JOB_OBJECT_UILIMIT_WRITECLIPBOARD   = 0x00000004
  2049  )
  2050  
  2051  type JOBOBJECT_BASIC_UI_RESTRICTIONS struct {
  2052  	UIRestrictionsClass uint32
  2053  }
  2054  
  2055  const (
  2056  	// JobObjectInformationClass
  2057  	JobObjectAssociateCompletionPortInformation = 7
  2058  	JobObjectBasicLimitInformation              = 2
  2059  	JobObjectBasicUIRestrictions                = 4
  2060  	JobObjectCpuRateControlInformation          = 15
  2061  	JobObjectEndOfJobTimeInformation            = 6
  2062  	JobObjectExtendedLimitInformation           = 9
  2063  	JobObjectGroupInformation                   = 11
  2064  	JobObjectGroupInformationEx                 = 14
  2065  	JobObjectLimitViolationInformation2         = 35
  2066  	JobObjectNetRateControlInformation          = 32
  2067  	JobObjectNotificationLimitInformation       = 12
  2068  	JobObjectNotificationLimitInformation2      = 34
  2069  	JobObjectSecurityLimitInformation           = 5
  2070  )
  2071  
  2072  const (
  2073  	KF_FLAG_DEFAULT                          = 0x00000000
  2074  	KF_FLAG_FORCE_APP_DATA_REDIRECTION       = 0x00080000
  2075  	KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET = 0x00040000
  2076  	KF_FLAG_FORCE_PACKAGE_REDIRECTION        = 0x00020000
  2077  	KF_FLAG_NO_PACKAGE_REDIRECTION           = 0x00010000
  2078  	KF_FLAG_FORCE_APPCONTAINER_REDIRECTION   = 0x00020000
  2079  	KF_FLAG_NO_APPCONTAINER_REDIRECTION      = 0x00010000
  2080  	KF_FLAG_CREATE                           = 0x00008000
  2081  	KF_FLAG_DONT_VERIFY                      = 0x00004000
  2082  	KF_FLAG_DONT_UNEXPAND                    = 0x00002000
  2083  	KF_FLAG_NO_ALIAS                         = 0x00001000
  2084  	KF_FLAG_INIT                             = 0x00000800
  2085  	KF_FLAG_DEFAULT_PATH                     = 0x00000400
  2086  	KF_FLAG_NOT_PARENT_RELATIVE              = 0x00000200
  2087  	KF_FLAG_SIMPLE_IDLIST                    = 0x00000100
  2088  	KF_FLAG_ALIAS_ONLY                       = 0x80000000
  2089  )
  2090  
  2091  type OsVersionInfoEx struct {
  2092  	osVersionInfoSize uint32
  2093  	MajorVersion      uint32
  2094  	MinorVersion      uint32
  2095  	BuildNumber       uint32
  2096  	PlatformId        uint32
  2097  	CsdVersion        [128]uint16
  2098  	ServicePackMajor  uint16
  2099  	ServicePackMinor  uint16
  2100  	SuiteMask         uint16
  2101  	ProductType       byte
  2102  	_                 byte
  2103  }
  2104  
  2105  const (
  2106  	EWX_LOGOFF          = 0x00000000
  2107  	EWX_SHUTDOWN        = 0x00000001
  2108  	EWX_REBOOT          = 0x00000002
  2109  	EWX_FORCE           = 0x00000004
  2110  	EWX_POWEROFF        = 0x00000008
  2111  	EWX_FORCEIFHUNG     = 0x00000010
  2112  	EWX_QUICKRESOLVE    = 0x00000020
  2113  	EWX_RESTARTAPPS     = 0x00000040
  2114  	EWX_HYBRID_SHUTDOWN = 0x00400000
  2115  	EWX_BOOTOPTIONS     = 0x01000000
  2116  
  2117  	SHTDN_REASON_FLAG_COMMENT_REQUIRED          = 0x01000000
  2118  	SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED = 0x02000000
  2119  	SHTDN_REASON_FLAG_CLEAN_UI                  = 0x04000000
  2120  	SHTDN_REASON_FLAG_DIRTY_UI                  = 0x08000000
  2121  	SHTDN_REASON_FLAG_USER_DEFINED              = 0x40000000
  2122  	SHTDN_REASON_FLAG_PLANNED                   = 0x80000000
  2123  	SHTDN_REASON_MAJOR_OTHER                    = 0x00000000
  2124  	SHTDN_REASON_MAJOR_NONE                     = 0x00000000
  2125  	SHTDN_REASON_MAJOR_HARDWARE                 = 0x00010000
  2126  	SHTDN_REASON_MAJOR_OPERATINGSYSTEM          = 0x00020000
  2127  	SHTDN_REASON_MAJOR_SOFTWARE                 = 0x00030000
  2128  	SHTDN_REASON_MAJOR_APPLICATION              = 0x00040000
  2129  	SHTDN_REASON_MAJOR_SYSTEM                   = 0x00050000
  2130  	SHTDN_REASON_MAJOR_POWER                    = 0x00060000
  2131  	SHTDN_REASON_MAJOR_LEGACY_API               = 0x00070000
  2132  	SHTDN_REASON_MINOR_OTHER                    = 0x00000000
  2133  	SHTDN_REASON_MINOR_NONE                     = 0x000000ff
  2134  	SHTDN_REASON_MINOR_MAINTENANCE              = 0x00000001
  2135  	SHTDN_REASON_MINOR_INSTALLATION             = 0x00000002
  2136  	SHTDN_REASON_MINOR_UPGRADE                  = 0x00000003
  2137  	SHTDN_REASON_MINOR_RECONFIG                 = 0x00000004
  2138  	SHTDN_REASON_MINOR_HUNG                     = 0x00000005
  2139  	SHTDN_REASON_MINOR_UNSTABLE                 = 0x00000006
  2140  	SHTDN_REASON_MINOR_DISK                     = 0x00000007
  2141  	SHTDN_REASON_MINOR_PROCESSOR                = 0x00000008
  2142  	SHTDN_REASON_MINOR_NETWORKCARD              = 0x00000009
  2143  	SHTDN_REASON_MINOR_POWER_SUPPLY             = 0x0000000a
  2144  	SHTDN_REASON_MINOR_CORDUNPLUGGED            = 0x0000000b
  2145  	SHTDN_REASON_MINOR_ENVIRONMENT              = 0x0000000c
  2146  	SHTDN_REASON_MINOR_HARDWARE_DRIVER          = 0x0000000d
  2147  	SHTDN_REASON_MINOR_OTHERDRIVER              = 0x0000000e
  2148  	SHTDN_REASON_MINOR_BLUESCREEN               = 0x0000000F
  2149  	SHTDN_REASON_MINOR_SERVICEPACK              = 0x00000010
  2150  	SHTDN_REASON_MINOR_HOTFIX                   = 0x00000011
  2151  	SHTDN_REASON_MINOR_SECURITYFIX              = 0x00000012
  2152  	SHTDN_REASON_MINOR_SECURITY                 = 0x00000013
  2153  	SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY     = 0x00000014
  2154  	SHTDN_REASON_MINOR_WMI                      = 0x00000015
  2155  	SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL    = 0x00000016
  2156  	SHTDN_REASON_MINOR_HOTFIX_UNINSTALL         = 0x00000017
  2157  	SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL    = 0x00000018
  2158  	SHTDN_REASON_MINOR_MMC                      = 0x00000019
  2159  	SHTDN_REASON_MINOR_SYSTEMRESTORE            = 0x0000001a
  2160  	SHTDN_REASON_MINOR_TERMSRV                  = 0x00000020
  2161  	SHTDN_REASON_MINOR_DC_PROMOTION             = 0x00000021
  2162  	SHTDN_REASON_MINOR_DC_DEMOTION              = 0x00000022
  2163  	SHTDN_REASON_UNKNOWN                        = SHTDN_REASON_MINOR_NONE
  2164  	SHTDN_REASON_LEGACY_API                     = SHTDN_REASON_MAJOR_LEGACY_API | SHTDN_REASON_FLAG_PLANNED
  2165  	SHTDN_REASON_VALID_BIT_MASK                 = 0xc0ffffff
  2166  
  2167  	SHUTDOWN_NORETRY = 0x1
  2168  )
  2169  
  2170  // Flags used for GetModuleHandleEx
  2171  const (
  2172  	GET_MODULE_HANDLE_EX_FLAG_PIN                = 1
  2173  	GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2
  2174  	GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS       = 4
  2175  )
  2176  
  2177  // MUI function flag values
  2178  const (
  2179  	MUI_LANGUAGE_ID                    = 0x4
  2180  	MUI_LANGUAGE_NAME                  = 0x8
  2181  	MUI_MERGE_SYSTEM_FALLBACK          = 0x10
  2182  	MUI_MERGE_USER_FALLBACK            = 0x20
  2183  	MUI_UI_FALLBACK                    = MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK
  2184  	MUI_THREAD_LANGUAGES               = 0x40
  2185  	MUI_CONSOLE_FILTER                 = 0x100
  2186  	MUI_COMPLEX_SCRIPT_FILTER          = 0x200
  2187  	MUI_RESET_FILTERS                  = 0x001
  2188  	MUI_USER_PREFERRED_UI_LANGUAGES    = 0x10
  2189  	MUI_USE_INSTALLED_LANGUAGES        = 0x20
  2190  	MUI_USE_SEARCH_ALL_LANGUAGES       = 0x40
  2191  	MUI_LANG_NEUTRAL_PE_FILE           = 0x100
  2192  	MUI_NON_LANG_NEUTRAL_FILE          = 0x200
  2193  	MUI_MACHINE_LANGUAGE_SETTINGS      = 0x400
  2194  	MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL  = 0x001
  2195  	MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN = 0x002
  2196  	MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI  = 0x004
  2197  	MUI_QUERY_TYPE                     = 0x001
  2198  	MUI_QUERY_CHECKSUM                 = 0x002
  2199  	MUI_QUERY_LANGUAGE_NAME            = 0x004
  2200  	MUI_QUERY_RESOURCE_TYPES           = 0x008
  2201  	MUI_FILEINFO_VERSION               = 0x001
  2202  
  2203  	MUI_FULL_LANGUAGE      = 0x01
  2204  	MUI_PARTIAL_LANGUAGE   = 0x02
  2205  	MUI_LIP_LANGUAGE       = 0x04
  2206  	MUI_LANGUAGE_INSTALLED = 0x20
  2207  	MUI_LANGUAGE_LICENSED  = 0x40
  2208  )
  2209  
  2210  // FILE_INFO_BY_HANDLE_CLASS constants for SetFileInformationByHandle/GetFileInformationByHandleEx
  2211  const (
  2212  	FileBasicInfo                  = 0
  2213  	FileStandardInfo               = 1
  2214  	FileNameInfo                   = 2
  2215  	FileRenameInfo                 = 3
  2216  	FileDispositionInfo            = 4
  2217  	FileAllocationInfo             = 5
  2218  	FileEndOfFileInfo              = 6
  2219  	FileStreamInfo                 = 7
  2220  	FileCompressionInfo            = 8
  2221  	FileAttributeTagInfo           = 9
  2222  	FileIdBothDirectoryInfo        = 10
  2223  	FileIdBothDirectoryRestartInfo = 11
  2224  	FileIoPriorityHintInfo         = 12
  2225  	FileRemoteProtocolInfo         = 13
  2226  	FileFullDirectoryInfo          = 14
  2227  	FileFullDirectoryRestartInfo   = 15
  2228  	FileStorageInfo                = 16
  2229  	FileAlignmentInfo              = 17
  2230  	FileIdInfo                     = 18
  2231  	FileIdExtdDirectoryInfo        = 19
  2232  	FileIdExtdDirectoryRestartInfo = 20
  2233  	FileDispositionInfoEx          = 21
  2234  	FileRenameInfoEx               = 22
  2235  	FileCaseSensitiveInfo          = 23
  2236  	FileNormalizedNameInfo         = 24
  2237  )
  2238  
  2239  // LoadLibrary flags for determining from where to search for a DLL
  2240  const (
  2241  	DONT_RESOLVE_DLL_REFERENCES               = 0x1
  2242  	LOAD_LIBRARY_AS_DATAFILE                  = 0x2
  2243  	LOAD_WITH_ALTERED_SEARCH_PATH             = 0x8
  2244  	LOAD_IGNORE_CODE_AUTHZ_LEVEL              = 0x10
  2245  	LOAD_LIBRARY_AS_IMAGE_RESOURCE            = 0x20
  2246  	LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE        = 0x40
  2247  	LOAD_LIBRARY_REQUIRE_SIGNED_TARGET        = 0x80
  2248  	LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR          = 0x100
  2249  	LOAD_LIBRARY_SEARCH_APPLICATION_DIR       = 0x200
  2250  	LOAD_LIBRARY_SEARCH_USER_DIRS             = 0x400
  2251  	LOAD_LIBRARY_SEARCH_SYSTEM32              = 0x800
  2252  	LOAD_LIBRARY_SEARCH_DEFAULT_DIRS          = 0x1000
  2253  	LOAD_LIBRARY_SAFE_CURRENT_DIRS            = 0x00002000
  2254  	LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER = 0x00004000
  2255  	LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY      = 0x00008000
  2256  )
  2257  
  2258  // RegNotifyChangeKeyValue notifyFilter flags.
  2259  const (
  2260  	// REG_NOTIFY_CHANGE_NAME notifies the caller if a subkey is added or deleted.
  2261  	REG_NOTIFY_CHANGE_NAME = 0x00000001
  2262  
  2263  	// REG_NOTIFY_CHANGE_ATTRIBUTES notifies the caller of changes to the attributes of the key, such as the security descriptor information.
  2264  	REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002
  2265  
  2266  	// REG_NOTIFY_CHANGE_LAST_SET notifies the caller of changes to a value of the key. This can include adding or deleting a value, or changing an existing value.
  2267  	REG_NOTIFY_CHANGE_LAST_SET = 0x00000004
  2268  
  2269  	// REG_NOTIFY_CHANGE_SECURITY notifies the caller of changes to the security descriptor of the key.
  2270  	REG_NOTIFY_CHANGE_SECURITY = 0x00000008
  2271  
  2272  	// REG_NOTIFY_THREAD_AGNOSTIC indicates that the lifetime of the registration must not be tied to the lifetime of the thread issuing the RegNotifyChangeKeyValue call. Note: This flag value is only supported in Windows 8 and later.
  2273  	REG_NOTIFY_THREAD_AGNOSTIC = 0x10000000
  2274  )
  2275  
  2276  type CommTimeouts struct {
  2277  	ReadIntervalTimeout         uint32
  2278  	ReadTotalTimeoutMultiplier  uint32
  2279  	ReadTotalTimeoutConstant    uint32
  2280  	WriteTotalTimeoutMultiplier uint32
  2281  	WriteTotalTimeoutConstant   uint32
  2282  }
  2283  
  2284  // NTUnicodeString is a UTF-16 string for NT native APIs, corresponding to UNICODE_STRING.
  2285  type NTUnicodeString struct {
  2286  	Length        uint16
  2287  	MaximumLength uint16
  2288  	Buffer        *uint16
  2289  }
  2290  
  2291  // NTString is an ANSI string for NT native APIs, corresponding to STRING.
  2292  type NTString struct {
  2293  	Length        uint16
  2294  	MaximumLength uint16
  2295  	Buffer        *byte
  2296  }
  2297  
  2298  type LIST_ENTRY struct {
  2299  	Flink *LIST_ENTRY
  2300  	Blink *LIST_ENTRY
  2301  }
  2302  
  2303  type LDR_DATA_TABLE_ENTRY struct {
  2304  	reserved1          [2]uintptr
  2305  	InMemoryOrderLinks LIST_ENTRY
  2306  	reserved2          [2]uintptr
  2307  	DllBase            uintptr
  2308  	reserved3          [2]uintptr
  2309  	FullDllName        NTUnicodeString
  2310  	reserved4          [8]byte
  2311  	reserved5          [3]uintptr
  2312  	reserved6          uintptr
  2313  	TimeDateStamp      uint32
  2314  }
  2315  
  2316  type PEB_LDR_DATA struct {
  2317  	reserved1               [8]byte
  2318  	reserved2               [3]uintptr
  2319  	InMemoryOrderModuleList LIST_ENTRY
  2320  }
  2321  
  2322  type CURDIR struct {
  2323  	DosPath NTUnicodeString
  2324  	Handle  Handle
  2325  }
  2326  
  2327  type RTL_DRIVE_LETTER_CURDIR struct {
  2328  	Flags     uint16
  2329  	Length    uint16
  2330  	TimeStamp uint32
  2331  	DosPath   NTString
  2332  }
  2333  
  2334  type RTL_USER_PROCESS_PARAMETERS struct {
  2335  	MaximumLength, Length uint32
  2336  
  2337  	Flags, DebugFlags uint32
  2338  
  2339  	ConsoleHandle                                Handle
  2340  	ConsoleFlags                                 uint32
  2341  	StandardInput, StandardOutput, StandardError Handle
  2342  
  2343  	CurrentDirectory CURDIR
  2344  	DllPath          NTUnicodeString
  2345  	ImagePathName    NTUnicodeString
  2346  	CommandLine      NTUnicodeString
  2347  	Environment      unsafe.Pointer
  2348  
  2349  	StartingX, StartingY, CountX, CountY, CountCharsX, CountCharsY, FillAttribute uint32
  2350  
  2351  	WindowFlags, ShowWindowFlags                     uint32
  2352  	WindowTitle, DesktopInfo, ShellInfo, RuntimeData NTUnicodeString
  2353  	CurrentDirectories                               [32]RTL_DRIVE_LETTER_CURDIR
  2354  
  2355  	EnvironmentSize, EnvironmentVersion uintptr
  2356  
  2357  	PackageDependencyData unsafe.Pointer
  2358  	ProcessGroupId        uint32
  2359  	LoaderThreads         uint32
  2360  
  2361  	RedirectionDllName               NTUnicodeString
  2362  	HeapPartitionName                NTUnicodeString
  2363  	DefaultThreadpoolCpuSetMasks     uintptr
  2364  	DefaultThreadpoolCpuSetMaskCount uint32
  2365  }
  2366  
  2367  type PEB struct {
  2368  	reserved1              [2]byte
  2369  	BeingDebugged          byte
  2370  	BitField               byte
  2371  	reserved3              uintptr
  2372  	ImageBaseAddress       uintptr
  2373  	Ldr                    *PEB_LDR_DATA
  2374  	ProcessParameters      *RTL_USER_PROCESS_PARAMETERS
  2375  	reserved4              [3]uintptr
  2376  	AtlThunkSListPtr       uintptr
  2377  	reserved5              uintptr
  2378  	reserved6              uint32
  2379  	reserved7              uintptr
  2380  	reserved8              uint32
  2381  	AtlThunkSListPtr32     uint32
  2382  	reserved9              [45]uintptr
  2383  	reserved10             [96]byte
  2384  	PostProcessInitRoutine uintptr
  2385  	reserved11             [128]byte
  2386  	reserved12             [1]uintptr
  2387  	SessionId              uint32
  2388  }
  2389  
  2390  type OBJECT_ATTRIBUTES struct {
  2391  	Length             uint32
  2392  	RootDirectory      Handle
  2393  	ObjectName         *NTUnicodeString
  2394  	Attributes         uint32
  2395  	SecurityDescriptor *SECURITY_DESCRIPTOR
  2396  	SecurityQoS        *SECURITY_QUALITY_OF_SERVICE
  2397  }
  2398  
  2399  // Values for the Attributes member of OBJECT_ATTRIBUTES.
  2400  const (
  2401  	OBJ_INHERIT                       = 0x00000002
  2402  	OBJ_PERMANENT                     = 0x00000010
  2403  	OBJ_EXCLUSIVE                     = 0x00000020
  2404  	OBJ_CASE_INSENSITIVE              = 0x00000040
  2405  	OBJ_OPENIF                        = 0x00000080
  2406  	OBJ_OPENLINK                      = 0x00000100
  2407  	OBJ_KERNEL_HANDLE                 = 0x00000200
  2408  	OBJ_FORCE_ACCESS_CHECK            = 0x00000400
  2409  	OBJ_IGNORE_IMPERSONATED_DEVICEMAP = 0x00000800
  2410  	OBJ_DONT_REPARSE                  = 0x00001000
  2411  	OBJ_VALID_ATTRIBUTES              = 0x00001FF2
  2412  )
  2413  
  2414  type IO_STATUS_BLOCK struct {
  2415  	Status      NTStatus
  2416  	Information uintptr
  2417  }
  2418  
  2419  type RTLP_CURDIR_REF struct {
  2420  	RefCount int32
  2421  	Handle   Handle
  2422  }
  2423  
  2424  type RTL_RELATIVE_NAME struct {
  2425  	RelativeName        NTUnicodeString
  2426  	ContainingDirectory Handle
  2427  	CurDirRef           *RTLP_CURDIR_REF
  2428  }
  2429  
  2430  const (
  2431  	// CreateDisposition flags for NtCreateFile and NtCreateNamedPipeFile.
  2432  	FILE_SUPERSEDE           = 0x00000000
  2433  	FILE_OPEN                = 0x00000001
  2434  	FILE_CREATE              = 0x00000002
  2435  	FILE_OPEN_IF             = 0x00000003
  2436  	FILE_OVERWRITE           = 0x00000004
  2437  	FILE_OVERWRITE_IF        = 0x00000005
  2438  	FILE_MAXIMUM_DISPOSITION = 0x00000005
  2439  
  2440  	// CreateOptions flags for NtCreateFile and NtCreateNamedPipeFile.
  2441  	FILE_DIRECTORY_FILE            = 0x00000001
  2442  	FILE_WRITE_THROUGH             = 0x00000002
  2443  	FILE_SEQUENTIAL_ONLY           = 0x00000004
  2444  	FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008
  2445  	FILE_SYNCHRONOUS_IO_ALERT      = 0x00000010
  2446  	FILE_SYNCHRONOUS_IO_NONALERT   = 0x00000020
  2447  	FILE_NON_DIRECTORY_FILE        = 0x00000040
  2448  	FILE_CREATE_TREE_CONNECTION    = 0x00000080
  2449  	FILE_COMPLETE_IF_OPLOCKED      = 0x00000100
  2450  	FILE_NO_EA_KNOWLEDGE           = 0x00000200
  2451  	FILE_OPEN_REMOTE_INSTANCE      = 0x00000400
  2452  	FILE_RANDOM_ACCESS             = 0x00000800
  2453  	FILE_DELETE_ON_CLOSE           = 0x00001000
  2454  	FILE_OPEN_BY_FILE_ID           = 0x00002000
  2455  	FILE_OPEN_FOR_BACKUP_INTENT    = 0x00004000
  2456  	FILE_NO_COMPRESSION            = 0x00008000
  2457  	FILE_OPEN_REQUIRING_OPLOCK     = 0x00010000
  2458  	FILE_DISALLOW_EXCLUSIVE        = 0x00020000
  2459  	FILE_RESERVE_OPFILTER          = 0x00100000
  2460  	FILE_OPEN_REPARSE_POINT        = 0x00200000
  2461  	FILE_OPEN_NO_RECALL            = 0x00400000
  2462  	FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
  2463  
  2464  	// Parameter constants for NtCreateNamedPipeFile.
  2465  
  2466  	FILE_PIPE_BYTE_STREAM_TYPE = 0x00000000
  2467  	FILE_PIPE_MESSAGE_TYPE     = 0x00000001
  2468  
  2469  	FILE_PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000
  2470  	FILE_PIPE_REJECT_REMOTE_CLIENTS = 0x00000002
  2471  
  2472  	FILE_PIPE_TYPE_VALID_MASK = 0x00000003
  2473  
  2474  	FILE_PIPE_BYTE_STREAM_MODE = 0x00000000
  2475  	FILE_PIPE_MESSAGE_MODE     = 0x00000001
  2476  
  2477  	FILE_PIPE_QUEUE_OPERATION    = 0x00000000
  2478  	FILE_PIPE_COMPLETE_OPERATION = 0x00000001
  2479  
  2480  	FILE_PIPE_INBOUND     = 0x00000000
  2481  	FILE_PIPE_OUTBOUND    = 0x00000001
  2482  	FILE_PIPE_FULL_DUPLEX = 0x00000002
  2483  
  2484  	FILE_PIPE_DISCONNECTED_STATE = 0x00000001
  2485  	FILE_PIPE_LISTENING_STATE    = 0x00000002
  2486  	FILE_PIPE_CONNECTED_STATE    = 0x00000003
  2487  	FILE_PIPE_CLOSING_STATE      = 0x00000004
  2488  
  2489  	FILE_PIPE_CLIENT_END = 0x00000000
  2490  	FILE_PIPE_SERVER_END = 0x00000001
  2491  )
  2492  
  2493  // ProcessInformationClasses for NtQueryInformationProcess and NtSetInformationProcess.
  2494  const (
  2495  	ProcessBasicInformation = iota
  2496  	ProcessQuotaLimits
  2497  	ProcessIoCounters
  2498  	ProcessVmCounters
  2499  	ProcessTimes
  2500  	ProcessBasePriority
  2501  	ProcessRaisePriority
  2502  	ProcessDebugPort
  2503  	ProcessExceptionPort
  2504  	ProcessAccessToken
  2505  	ProcessLdtInformation
  2506  	ProcessLdtSize
  2507  	ProcessDefaultHardErrorMode
  2508  	ProcessIoPortHandlers
  2509  	ProcessPooledUsageAndLimits
  2510  	ProcessWorkingSetWatch
  2511  	ProcessUserModeIOPL
  2512  	ProcessEnableAlignmentFaultFixup
  2513  	ProcessPriorityClass
  2514  	ProcessWx86Information
  2515  	ProcessHandleCount
  2516  	ProcessAffinityMask
  2517  	ProcessPriorityBoost
  2518  	ProcessDeviceMap
  2519  	ProcessSessionInformation
  2520  	ProcessForegroundInformation
  2521  	ProcessWow64Information
  2522  	ProcessImageFileName
  2523  	ProcessLUIDDeviceMapsEnabled
  2524  	ProcessBreakOnTermination
  2525  	ProcessDebugObjectHandle
  2526  	ProcessDebugFlags
  2527  	ProcessHandleTracing
  2528  	ProcessIoPriority
  2529  	ProcessExecuteFlags
  2530  	ProcessTlsInformation
  2531  	ProcessCookie
  2532  	ProcessImageInformation
  2533  	ProcessCycleTime
  2534  	ProcessPagePriority
  2535  	ProcessInstrumentationCallback
  2536  	ProcessThreadStackAllocation
  2537  	ProcessWorkingSetWatchEx
  2538  	ProcessImageFileNameWin32
  2539  	ProcessImageFileMapping
  2540  	ProcessAffinityUpdateMode
  2541  	ProcessMemoryAllocationMode
  2542  	ProcessGroupInformation
  2543  	ProcessTokenVirtualizationEnabled
  2544  	ProcessConsoleHostProcess
  2545  	ProcessWindowInformation
  2546  	ProcessHandleInformation
  2547  	ProcessMitigationPolicy
  2548  	ProcessDynamicFunctionTableInformation
  2549  	ProcessHandleCheckingMode
  2550  	ProcessKeepAliveCount
  2551  	ProcessRevokeFileHandles
  2552  	ProcessWorkingSetControl
  2553  	ProcessHandleTable
  2554  	ProcessCheckStackExtentsMode
  2555  	ProcessCommandLineInformation
  2556  	ProcessProtectionInformation
  2557  	ProcessMemoryExhaustion
  2558  	ProcessFaultInformation
  2559  	ProcessTelemetryIdInformation
  2560  	ProcessCommitReleaseInformation
  2561  	ProcessDefaultCpuSetsInformation
  2562  	ProcessAllowedCpuSetsInformation
  2563  	ProcessSubsystemProcess
  2564  	ProcessJobMemoryInformation
  2565  	ProcessInPrivate
  2566  	ProcessRaiseUMExceptionOnInvalidHandleClose
  2567  	ProcessIumChallengeResponse
  2568  	ProcessChildProcessInformation
  2569  	ProcessHighGraphicsPriorityInformation
  2570  	ProcessSubsystemInformation
  2571  	ProcessEnergyValues
  2572  	ProcessActivityThrottleState
  2573  	ProcessActivityThrottlePolicy
  2574  	ProcessWin32kSyscallFilterInformation
  2575  	ProcessDisableSystemAllowedCpuSets
  2576  	ProcessWakeInformation
  2577  	ProcessEnergyTrackingState
  2578  	ProcessManageWritesToExecutableMemory
  2579  	ProcessCaptureTrustletLiveDump
  2580  	ProcessTelemetryCoverage
  2581  	ProcessEnclaveInformation
  2582  	ProcessEnableReadWriteVmLogging
  2583  	ProcessUptimeInformation
  2584  	ProcessImageSection
  2585  	ProcessDebugAuthInformation
  2586  	ProcessSystemResourceManagement
  2587  	ProcessSequenceNumber
  2588  	ProcessLoaderDetour
  2589  	ProcessSecurityDomainInformation
  2590  	ProcessCombineSecurityDomainsInformation
  2591  	ProcessEnableLogging
  2592  	ProcessLeapSecondInformation
  2593  	ProcessFiberShadowStackAllocation
  2594  	ProcessFreeFiberShadowStackAllocation
  2595  	ProcessAltSystemCallInformation
  2596  	ProcessDynamicEHContinuationTargets
  2597  	ProcessDynamicEnforcedCetCompatibleRanges
  2598  )
  2599  
  2600  type PROCESS_BASIC_INFORMATION struct {
  2601  	ExitStatus                   NTStatus
  2602  	PebBaseAddress               *PEB
  2603  	AffinityMask                 uintptr
  2604  	BasePriority                 int32
  2605  	UniqueProcessId              uintptr
  2606  	InheritedFromUniqueProcessId uintptr
  2607  }
  2608  
  2609  // Constants for LocalAlloc flags.
  2610  const (
  2611  	LMEM_FIXED          = 0x0
  2612  	LMEM_MOVEABLE       = 0x2
  2613  	LMEM_NOCOMPACT      = 0x10
  2614  	LMEM_NODISCARD      = 0x20
  2615  	LMEM_ZEROINIT       = 0x40
  2616  	LMEM_MODIFY         = 0x80
  2617  	LMEM_DISCARDABLE    = 0xf00
  2618  	LMEM_VALID_FLAGS    = 0xf72
  2619  	LMEM_INVALID_HANDLE = 0x8000
  2620  	LHND                = LMEM_MOVEABLE | LMEM_ZEROINIT
  2621  	LPTR                = LMEM_FIXED | LMEM_ZEROINIT
  2622  	NONZEROLHND         = LMEM_MOVEABLE
  2623  	NONZEROLPTR         = LMEM_FIXED
  2624  )
  2625  
  2626  // Constants for the CreateNamedPipe-family of functions.
  2627  const (
  2628  	PIPE_ACCESS_INBOUND  = 0x1
  2629  	PIPE_ACCESS_OUTBOUND = 0x2
  2630  	PIPE_ACCESS_DUPLEX   = 0x3
  2631  
  2632  	PIPE_CLIENT_END = 0x0
  2633  	PIPE_SERVER_END = 0x1
  2634  
  2635  	PIPE_WAIT                  = 0x0
  2636  	PIPE_NOWAIT                = 0x1
  2637  	PIPE_READMODE_BYTE         = 0x0
  2638  	PIPE_READMODE_MESSAGE      = 0x2
  2639  	PIPE_TYPE_BYTE             = 0x0
  2640  	PIPE_TYPE_MESSAGE          = 0x4
  2641  	PIPE_ACCEPT_REMOTE_CLIENTS = 0x0
  2642  	PIPE_REJECT_REMOTE_CLIENTS = 0x8
  2643  
  2644  	PIPE_UNLIMITED_INSTANCES = 255
  2645  )
  2646  
  2647  // Constants for security attributes when opening named pipes.
  2648  const (
  2649  	SECURITY_ANONYMOUS      = SecurityAnonymous << 16
  2650  	SECURITY_IDENTIFICATION = SecurityIdentification << 16
  2651  	SECURITY_IMPERSONATION  = SecurityImpersonation << 16
  2652  	SECURITY_DELEGATION     = SecurityDelegation << 16
  2653  
  2654  	SECURITY_CONTEXT_TRACKING = 0x40000
  2655  	SECURITY_EFFECTIVE_ONLY   = 0x80000
  2656  
  2657  	SECURITY_SQOS_PRESENT     = 0x100000
  2658  	SECURITY_VALID_SQOS_FLAGS = 0x1f0000
  2659  )
  2660  
  2661  // ResourceID represents a 16-bit resource identifier, traditionally created with the MAKEINTRESOURCE macro.
  2662  type ResourceID uint16
  2663  
  2664  // ResourceIDOrString must be either a ResourceID, to specify a resource or resource type by ID,
  2665  // or a string, to specify a resource or resource type by name.
  2666  type ResourceIDOrString interface{}
  2667  
  2668  // Predefined resource names and types.
  2669  var (
  2670  	// Predefined names.
  2671  	CREATEPROCESS_MANIFEST_RESOURCE_ID                 ResourceID = 1
  2672  	ISOLATIONAWARE_MANIFEST_RESOURCE_ID                ResourceID = 2
  2673  	ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID ResourceID = 3
  2674  	ISOLATIONPOLICY_MANIFEST_RESOURCE_ID               ResourceID = 4
  2675  	ISOLATIONPOLICY_BROWSER_MANIFEST_RESOURCE_ID       ResourceID = 5
  2676  	MINIMUM_RESERVED_MANIFEST_RESOURCE_ID              ResourceID = 1  // inclusive
  2677  	MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID              ResourceID = 16 // inclusive
  2678  
  2679  	// Predefined types.
  2680  	RT_CURSOR       ResourceID = 1
  2681  	RT_BITMAP       ResourceID = 2
  2682  	RT_ICON         ResourceID = 3
  2683  	RT_MENU         ResourceID = 4
  2684  	RT_DIALOG       ResourceID = 5
  2685  	RT_STRING       ResourceID = 6
  2686  	RT_FONTDIR      ResourceID = 7
  2687  	RT_FONT         ResourceID = 8
  2688  	RT_ACCELERATOR  ResourceID = 9
  2689  	RT_RCDATA       ResourceID = 10
  2690  	RT_MESSAGETABLE ResourceID = 11
  2691  	RT_GROUP_CURSOR ResourceID = 12
  2692  	RT_GROUP_ICON   ResourceID = 14
  2693  	RT_VERSION      ResourceID = 16
  2694  	RT_DLGINCLUDE   ResourceID = 17
  2695  	RT_PLUGPLAY     ResourceID = 19
  2696  	RT_VXD          ResourceID = 20
  2697  	RT_ANICURSOR    ResourceID = 21
  2698  	RT_ANIICON      ResourceID = 22
  2699  	RT_HTML         ResourceID = 23
  2700  	RT_MANIFEST     ResourceID = 24
  2701  )
  2702  
  2703  type COAUTHIDENTITY struct {
  2704  	User           *uint16
  2705  	UserLength     uint32
  2706  	Domain         *uint16
  2707  	DomainLength   uint32
  2708  	Password       *uint16
  2709  	PasswordLength uint32
  2710  	Flags          uint32
  2711  }
  2712  
  2713  type COAUTHINFO struct {
  2714  	AuthnSvc           uint32
  2715  	AuthzSvc           uint32
  2716  	ServerPrincName    *uint16
  2717  	AuthnLevel         uint32
  2718  	ImpersonationLevel uint32
  2719  	AuthIdentityData   *COAUTHIDENTITY
  2720  	Capabilities       uint32
  2721  }
  2722  
  2723  type COSERVERINFO struct {
  2724  	Reserved1 uint32
  2725  	Aame      *uint16
  2726  	AuthInfo  *COAUTHINFO
  2727  	Reserved2 uint32
  2728  }
  2729  
  2730  type BIND_OPTS3 struct {
  2731  	CbStruct          uint32
  2732  	Flags             uint32
  2733  	Mode              uint32
  2734  	TickCountDeadline uint32
  2735  	TrackFlags        uint32
  2736  	ClassContext      uint32
  2737  	Locale            uint32
  2738  	ServerInfo        *COSERVERINFO
  2739  	Hwnd              HWND
  2740  }
  2741  
  2742  const (
  2743  	CLSCTX_INPROC_SERVER          = 0x1
  2744  	CLSCTX_INPROC_HANDLER         = 0x2
  2745  	CLSCTX_LOCAL_SERVER           = 0x4
  2746  	CLSCTX_INPROC_SERVER16        = 0x8
  2747  	CLSCTX_REMOTE_SERVER          = 0x10
  2748  	CLSCTX_INPROC_HANDLER16       = 0x20
  2749  	CLSCTX_RESERVED1              = 0x40
  2750  	CLSCTX_RESERVED2              = 0x80
  2751  	CLSCTX_RESERVED3              = 0x100
  2752  	CLSCTX_RESERVED4              = 0x200
  2753  	CLSCTX_NO_CODE_DOWNLOAD       = 0x400
  2754  	CLSCTX_RESERVED5              = 0x800
  2755  	CLSCTX_NO_CUSTOM_MARSHAL      = 0x1000
  2756  	CLSCTX_ENABLE_CODE_DOWNLOAD   = 0x2000
  2757  	CLSCTX_NO_FAILURE_LOG         = 0x4000
  2758  	CLSCTX_DISABLE_AAA            = 0x8000
  2759  	CLSCTX_ENABLE_AAA             = 0x10000
  2760  	CLSCTX_FROM_DEFAULT_CONTEXT   = 0x20000
  2761  	CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000
  2762  	CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
  2763  	CLSCTX_ENABLE_CLOAKING        = 0x100000
  2764  	CLSCTX_APPCONTAINER           = 0x400000
  2765  	CLSCTX_ACTIVATE_AAA_AS_IU     = 0x800000
  2766  	CLSCTX_PS_DLL                 = 0x80000000
  2767  
  2768  	COINIT_MULTITHREADED     = 0x0
  2769  	COINIT_APARTMENTTHREADED = 0x2
  2770  	COINIT_DISABLE_OLE1DDE   = 0x4
  2771  	COINIT_SPEED_OVER_MEMORY = 0x8
  2772  )
  2773  
  2774  // Flag for QueryFullProcessImageName.
  2775  const PROCESS_NAME_NATIVE = 1