...

Source file src/golang.org/x/sys/windows/types_windows.go

Documentation: golang.org/x/sys/windows

     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_READ_DATA        = 0x00000001
    70  	FILE_READ_ATTRIBUTES  = 0x00000080
    71  	FILE_READ_EA          = 0x00000008
    72  	FILE_WRITE_DATA       = 0x00000002
    73  	FILE_WRITE_ATTRIBUTES = 0x00000100
    74  	FILE_WRITE_EA         = 0x00000010
    75  	FILE_APPEND_DATA      = 0x00000004
    76  	FILE_EXECUTE          = 0x00000020
    77  
    78  	FILE_GENERIC_READ    = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE
    79  	FILE_GENERIC_WRITE   = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE
    80  	FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE
    81  
    82  	FILE_LIST_DIRECTORY = 0x00000001
    83  	FILE_TRAVERSE       = 0x00000020
    84  
    85  	FILE_SHARE_READ   = 0x00000001
    86  	FILE_SHARE_WRITE  = 0x00000002
    87  	FILE_SHARE_DELETE = 0x00000004
    88  
    89  	FILE_ATTRIBUTE_READONLY              = 0x00000001
    90  	FILE_ATTRIBUTE_HIDDEN                = 0x00000002
    91  	FILE_ATTRIBUTE_SYSTEM                = 0x00000004
    92  	FILE_ATTRIBUTE_DIRECTORY             = 0x00000010
    93  	FILE_ATTRIBUTE_ARCHIVE               = 0x00000020
    94  	FILE_ATTRIBUTE_DEVICE                = 0x00000040
    95  	FILE_ATTRIBUTE_NORMAL                = 0x00000080
    96  	FILE_ATTRIBUTE_TEMPORARY             = 0x00000100
    97  	FILE_ATTRIBUTE_SPARSE_FILE           = 0x00000200
    98  	FILE_ATTRIBUTE_REPARSE_POINT         = 0x00000400
    99  	FILE_ATTRIBUTE_COMPRESSED            = 0x00000800
   100  	FILE_ATTRIBUTE_OFFLINE               = 0x00001000
   101  	FILE_ATTRIBUTE_NOT_CONTENT_INDEXED   = 0x00002000
   102  	FILE_ATTRIBUTE_ENCRYPTED             = 0x00004000
   103  	FILE_ATTRIBUTE_INTEGRITY_STREAM      = 0x00008000
   104  	FILE_ATTRIBUTE_VIRTUAL               = 0x00010000
   105  	FILE_ATTRIBUTE_NO_SCRUB_DATA         = 0x00020000
   106  	FILE_ATTRIBUTE_RECALL_ON_OPEN        = 0x00040000
   107  	FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000
   108  
   109  	INVALID_FILE_ATTRIBUTES = 0xffffffff
   110  
   111  	CREATE_NEW        = 1
   112  	CREATE_ALWAYS     = 2
   113  	OPEN_EXISTING     = 3
   114  	OPEN_ALWAYS       = 4
   115  	TRUNCATE_EXISTING = 5
   116  
   117  	FILE_FLAG_OPEN_REQUIRING_OPLOCK = 0x00040000
   118  	FILE_FLAG_FIRST_PIPE_INSTANCE   = 0x00080000
   119  	FILE_FLAG_OPEN_NO_RECALL        = 0x00100000
   120  	FILE_FLAG_OPEN_REPARSE_POINT    = 0x00200000
   121  	FILE_FLAG_SESSION_AWARE         = 0x00800000
   122  	FILE_FLAG_POSIX_SEMANTICS       = 0x01000000
   123  	FILE_FLAG_BACKUP_SEMANTICS      = 0x02000000
   124  	FILE_FLAG_DELETE_ON_CLOSE       = 0x04000000
   125  	FILE_FLAG_SEQUENTIAL_SCAN       = 0x08000000
   126  	FILE_FLAG_RANDOM_ACCESS         = 0x10000000
   127  	FILE_FLAG_NO_BUFFERING          = 0x20000000
   128  	FILE_FLAG_OVERLAPPED            = 0x40000000
   129  	FILE_FLAG_WRITE_THROUGH         = 0x80000000
   130  
   131  	HANDLE_FLAG_INHERIT    = 0x00000001
   132  	STARTF_USESTDHANDLES   = 0x00000100
   133  	STARTF_USESHOWWINDOW   = 0x00000001
   134  	DUPLICATE_CLOSE_SOURCE = 0x00000001
   135  	DUPLICATE_SAME_ACCESS  = 0x00000002
   136  
   137  	STD_INPUT_HANDLE  = -10 & (1<<32 - 1)
   138  	STD_OUTPUT_HANDLE = -11 & (1<<32 - 1)
   139  	STD_ERROR_HANDLE  = -12 & (1<<32 - 1)
   140  
   141  	FILE_BEGIN   = 0
   142  	FILE_CURRENT = 1
   143  	FILE_END     = 2
   144  
   145  	LANG_ENGLISH       = 0x09
   146  	SUBLANG_ENGLISH_US = 0x01
   147  
   148  	FORMAT_MESSAGE_ALLOCATE_BUFFER = 256
   149  	FORMAT_MESSAGE_IGNORE_INSERTS  = 512
   150  	FORMAT_MESSAGE_FROM_STRING     = 1024
   151  	FORMAT_MESSAGE_FROM_HMODULE    = 2048
   152  	FORMAT_MESSAGE_FROM_SYSTEM     = 4096
   153  	FORMAT_MESSAGE_ARGUMENT_ARRAY  = 8192
   154  	FORMAT_MESSAGE_MAX_WIDTH_MASK  = 255
   155  
   156  	MAX_PATH      = 260
   157  	MAX_LONG_PATH = 32768
   158  
   159  	MAX_MODULE_NAME32 = 255
   160  
   161  	MAX_COMPUTERNAME_LENGTH = 15
   162  
   163  	MAX_DHCPV6_DUID_LENGTH = 130
   164  
   165  	MAX_DNS_SUFFIX_STRING_LENGTH = 256
   166  
   167  	TIME_ZONE_ID_UNKNOWN  = 0
   168  	TIME_ZONE_ID_STANDARD = 1
   169  
   170  	TIME_ZONE_ID_DAYLIGHT = 2
   171  	IGNORE                = 0
   172  	INFINITE              = 0xffffffff
   173  
   174  	WAIT_ABANDONED = 0x00000080
   175  	WAIT_OBJECT_0  = 0x00000000
   176  	WAIT_FAILED    = 0xFFFFFFFF
   177  
   178  	// Access rights for process.
   179  	PROCESS_ALL_ACCESS                = 0xFFFF
   180  	PROCESS_CREATE_PROCESS            = 0x0080
   181  	PROCESS_CREATE_THREAD             = 0x0002
   182  	PROCESS_DUP_HANDLE                = 0x0040
   183  	PROCESS_QUERY_INFORMATION         = 0x0400
   184  	PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
   185  	PROCESS_SET_INFORMATION           = 0x0200
   186  	PROCESS_SET_QUOTA                 = 0x0100
   187  	PROCESS_SUSPEND_RESUME            = 0x0800
   188  	PROCESS_TERMINATE                 = 0x0001
   189  	PROCESS_VM_OPERATION              = 0x0008
   190  	PROCESS_VM_READ                   = 0x0010
   191  	PROCESS_VM_WRITE                  = 0x0020
   192  
   193  	// Access rights for thread.
   194  	THREAD_DIRECT_IMPERSONATION      = 0x0200
   195  	THREAD_GET_CONTEXT               = 0x0008
   196  	THREAD_IMPERSONATE               = 0x0100
   197  	THREAD_QUERY_INFORMATION         = 0x0040
   198  	THREAD_QUERY_LIMITED_INFORMATION = 0x0800
   199  	THREAD_SET_CONTEXT               = 0x0010
   200  	THREAD_SET_INFORMATION           = 0x0020
   201  	THREAD_SET_LIMITED_INFORMATION   = 0x0400
   202  	THREAD_SET_THREAD_TOKEN          = 0x0080
   203  	THREAD_SUSPEND_RESUME            = 0x0002
   204  	THREAD_TERMINATE                 = 0x0001
   205  
   206  	FILE_MAP_COPY    = 0x01
   207  	FILE_MAP_WRITE   = 0x02
   208  	FILE_MAP_READ    = 0x04
   209  	FILE_MAP_EXECUTE = 0x20
   210  
   211  	CTRL_C_EVENT        = 0
   212  	CTRL_BREAK_EVENT    = 1
   213  	CTRL_CLOSE_EVENT    = 2
   214  	CTRL_LOGOFF_EVENT   = 5
   215  	CTRL_SHUTDOWN_EVENT = 6
   216  
   217  	// Windows reserves errors >= 1<<29 for application use.
   218  	APPLICATION_ERROR = 1 << 29
   219  )
   220  
   221  const (
   222  	// Process creation flags.
   223  	CREATE_BREAKAWAY_FROM_JOB        = 0x01000000
   224  	CREATE_DEFAULT_ERROR_MODE        = 0x04000000
   225  	CREATE_NEW_CONSOLE               = 0x00000010
   226  	CREATE_NEW_PROCESS_GROUP         = 0x00000200
   227  	CREATE_NO_WINDOW                 = 0x08000000
   228  	CREATE_PROTECTED_PROCESS         = 0x00040000
   229  	CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
   230  	CREATE_SEPARATE_WOW_VDM          = 0x00000800
   231  	CREATE_SHARED_WOW_VDM            = 0x00001000
   232  	CREATE_SUSPENDED                 = 0x00000004
   233  	CREATE_UNICODE_ENVIRONMENT       = 0x00000400
   234  	DEBUG_ONLY_THIS_PROCESS          = 0x00000002
   235  	DEBUG_PROCESS                    = 0x00000001
   236  	DETACHED_PROCESS                 = 0x00000008
   237  	EXTENDED_STARTUPINFO_PRESENT     = 0x00080000
   238  	INHERIT_PARENT_AFFINITY          = 0x00010000
   239  )
   240  
   241  const (
   242  	// attributes for ProcThreadAttributeList
   243  	PROC_THREAD_ATTRIBUTE_PARENT_PROCESS    = 0x00020000
   244  	PROC_THREAD_ATTRIBUTE_HANDLE_LIST       = 0x00020002
   245  	PROC_THREAD_ATTRIBUTE_GROUP_AFFINITY    = 0x00030003
   246  	PROC_THREAD_ATTRIBUTE_PREFERRED_NODE    = 0x00020004
   247  	PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR   = 0x00030005
   248  	PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY = 0x00020007
   249  	PROC_THREAD_ATTRIBUTE_UMS_THREAD        = 0x00030006
   250  	PROC_THREAD_ATTRIBUTE_PROTECTION_LEVEL  = 0x0002000b
   251  	PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE     = 0x00020016
   252  )
   253  
   254  const (
   255  	// flags for CreateToolhelp32Snapshot
   256  	TH32CS_SNAPHEAPLIST = 0x01
   257  	TH32CS_SNAPPROCESS  = 0x02
   258  	TH32CS_SNAPTHREAD   = 0x04
   259  	TH32CS_SNAPMODULE   = 0x08
   260  	TH32CS_SNAPMODULE32 = 0x10
   261  	TH32CS_SNAPALL      = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
   262  	TH32CS_INHERIT      = 0x80000000
   263  )
   264  
   265  const (
   266  	// flags for EnumProcessModulesEx
   267  	LIST_MODULES_32BIT   = 0x01
   268  	LIST_MODULES_64BIT   = 0x02
   269  	LIST_MODULES_ALL     = 0x03
   270  	LIST_MODULES_DEFAULT = 0x00
   271  )
   272  
   273  const (
   274  	// filters for ReadDirectoryChangesW and FindFirstChangeNotificationW
   275  	FILE_NOTIFY_CHANGE_FILE_NAME   = 0x001
   276  	FILE_NOTIFY_CHANGE_DIR_NAME    = 0x002
   277  	FILE_NOTIFY_CHANGE_ATTRIBUTES  = 0x004
   278  	FILE_NOTIFY_CHANGE_SIZE        = 0x008
   279  	FILE_NOTIFY_CHANGE_LAST_WRITE  = 0x010
   280  	FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x020
   281  	FILE_NOTIFY_CHANGE_CREATION    = 0x040
   282  	FILE_NOTIFY_CHANGE_SECURITY    = 0x100
   283  )
   284  
   285  const (
   286  	// do not reorder
   287  	FILE_ACTION_ADDED = iota + 1
   288  	FILE_ACTION_REMOVED
   289  	FILE_ACTION_MODIFIED
   290  	FILE_ACTION_RENAMED_OLD_NAME
   291  	FILE_ACTION_RENAMED_NEW_NAME
   292  )
   293  
   294  const (
   295  	// wincrypt.h
   296  	/* certenrolld_begin -- PROV_RSA_*/
   297  	PROV_RSA_FULL      = 1
   298  	PROV_RSA_SIG       = 2
   299  	PROV_DSS           = 3
   300  	PROV_FORTEZZA      = 4
   301  	PROV_MS_EXCHANGE   = 5
   302  	PROV_SSL           = 6
   303  	PROV_RSA_SCHANNEL  = 12
   304  	PROV_DSS_DH        = 13
   305  	PROV_EC_ECDSA_SIG  = 14
   306  	PROV_EC_ECNRA_SIG  = 15
   307  	PROV_EC_ECDSA_FULL = 16
   308  	PROV_EC_ECNRA_FULL = 17
   309  	PROV_DH_SCHANNEL   = 18
   310  	PROV_SPYRUS_LYNKS  = 20
   311  	PROV_RNG           = 21
   312  	PROV_INTEL_SEC     = 22
   313  	PROV_REPLACE_OWF   = 23
   314  	PROV_RSA_AES       = 24
   315  
   316  	/* dwFlags definitions for CryptAcquireContext */
   317  	CRYPT_VERIFYCONTEXT              = 0xF0000000
   318  	CRYPT_NEWKEYSET                  = 0x00000008
   319  	CRYPT_DELETEKEYSET               = 0x00000010
   320  	CRYPT_MACHINE_KEYSET             = 0x00000020
   321  	CRYPT_SILENT                     = 0x00000040
   322  	CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080
   323  
   324  	/* Flags for PFXImportCertStore */
   325  	CRYPT_EXPORTABLE                   = 0x00000001
   326  	CRYPT_USER_PROTECTED               = 0x00000002
   327  	CRYPT_USER_KEYSET                  = 0x00001000
   328  	PKCS12_PREFER_CNG_KSP              = 0x00000100
   329  	PKCS12_ALWAYS_CNG_KSP              = 0x00000200
   330  	PKCS12_ALLOW_OVERWRITE_KEY         = 0x00004000
   331  	PKCS12_NO_PERSIST_KEY              = 0x00008000
   332  	PKCS12_INCLUDE_EXTENDED_PROPERTIES = 0x00000010
   333  
   334  	/* Flags for CryptAcquireCertificatePrivateKey */
   335  	CRYPT_ACQUIRE_CACHE_FLAG             = 0x00000001
   336  	CRYPT_ACQUIRE_USE_PROV_INFO_FLAG     = 0x00000002
   337  	CRYPT_ACQUIRE_COMPARE_KEY_FLAG       = 0x00000004
   338  	CRYPT_ACQUIRE_NO_HEALING             = 0x00000008
   339  	CRYPT_ACQUIRE_SILENT_FLAG            = 0x00000040
   340  	CRYPT_ACQUIRE_WINDOW_HANDLE_FLAG     = 0x00000080
   341  	CRYPT_ACQUIRE_NCRYPT_KEY_FLAGS_MASK  = 0x00070000
   342  	CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG  = 0x00010000
   343  	CRYPT_ACQUIRE_PREFER_NCRYPT_KEY_FLAG = 0x00020000
   344  	CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG   = 0x00040000
   345  
   346  	/* pdwKeySpec for CryptAcquireCertificatePrivateKey */
   347  	AT_KEYEXCHANGE       = 1
   348  	AT_SIGNATURE         = 2
   349  	CERT_NCRYPT_KEY_SPEC = 0xFFFFFFFF
   350  
   351  	/* Default usage match type is AND with value zero */
   352  	USAGE_MATCH_TYPE_AND = 0
   353  	USAGE_MATCH_TYPE_OR  = 1
   354  
   355  	/* msgAndCertEncodingType values for CertOpenStore function */
   356  	X509_ASN_ENCODING   = 0x00000001
   357  	PKCS_7_ASN_ENCODING = 0x00010000
   358  
   359  	/* storeProvider values for CertOpenStore function */
   360  	CERT_STORE_PROV_MSG               = 1
   361  	CERT_STORE_PROV_MEMORY            = 2
   362  	CERT_STORE_PROV_FILE              = 3
   363  	CERT_STORE_PROV_REG               = 4
   364  	CERT_STORE_PROV_PKCS7             = 5
   365  	CERT_STORE_PROV_SERIALIZED        = 6
   366  	CERT_STORE_PROV_FILENAME_A        = 7
   367  	CERT_STORE_PROV_FILENAME_W        = 8
   368  	CERT_STORE_PROV_FILENAME          = CERT_STORE_PROV_FILENAME_W
   369  	CERT_STORE_PROV_SYSTEM_A          = 9
   370  	CERT_STORE_PROV_SYSTEM_W          = 10
   371  	CERT_STORE_PROV_SYSTEM            = CERT_STORE_PROV_SYSTEM_W
   372  	CERT_STORE_PROV_COLLECTION        = 11
   373  	CERT_STORE_PROV_SYSTEM_REGISTRY_A = 12
   374  	CERT_STORE_PROV_SYSTEM_REGISTRY_W = 13
   375  	CERT_STORE_PROV_SYSTEM_REGISTRY   = CERT_STORE_PROV_SYSTEM_REGISTRY_W
   376  	CERT_STORE_PROV_PHYSICAL_W        = 14
   377  	CERT_STORE_PROV_PHYSICAL          = CERT_STORE_PROV_PHYSICAL_W
   378  	CERT_STORE_PROV_SMART_CARD_W      = 15
   379  	CERT_STORE_PROV_SMART_CARD        = CERT_STORE_PROV_SMART_CARD_W
   380  	CERT_STORE_PROV_LDAP_W            = 16
   381  	CERT_STORE_PROV_LDAP              = CERT_STORE_PROV_LDAP_W
   382  	CERT_STORE_PROV_PKCS12            = 17
   383  
   384  	/* store characteristics (low WORD of flag) for CertOpenStore function */
   385  	CERT_STORE_NO_CRYPT_RELEASE_FLAG            = 0x00000001
   386  	CERT_STORE_SET_LOCALIZED_NAME_FLAG          = 0x00000002
   387  	CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004
   388  	CERT_STORE_DELETE_FLAG                      = 0x00000010
   389  	CERT_STORE_UNSAFE_PHYSICAL_FLAG             = 0x00000020
   390  	CERT_STORE_SHARE_STORE_FLAG                 = 0x00000040
   391  	CERT_STORE_SHARE_CONTEXT_FLAG               = 0x00000080
   392  	CERT_STORE_MANIFOLD_FLAG                    = 0x00000100
   393  	CERT_STORE_ENUM_ARCHIVED_FLAG               = 0x00000200
   394  	CERT_STORE_UPDATE_KEYID_FLAG                = 0x00000400
   395  	CERT_STORE_BACKUP_RESTORE_FLAG              = 0x00000800
   396  	CERT_STORE_MAXIMUM_ALLOWED_FLAG             = 0x00001000
   397  	CERT_STORE_CREATE_NEW_FLAG                  = 0x00002000
   398  	CERT_STORE_OPEN_EXISTING_FLAG               = 0x00004000
   399  	CERT_STORE_READONLY_FLAG                    = 0x00008000
   400  
   401  	/* store locations (high WORD of flag) for CertOpenStore function */
   402  	CERT_SYSTEM_STORE_CURRENT_USER               = 0x00010000
   403  	CERT_SYSTEM_STORE_LOCAL_MACHINE              = 0x00020000
   404  	CERT_SYSTEM_STORE_CURRENT_SERVICE            = 0x00040000
   405  	CERT_SYSTEM_STORE_SERVICES                   = 0x00050000
   406  	CERT_SYSTEM_STORE_USERS                      = 0x00060000
   407  	CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY  = 0x00070000
   408  	CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = 0x00080000
   409  	CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE   = 0x00090000
   410  	CERT_SYSTEM_STORE_UNPROTECTED_FLAG           = 0x40000000
   411  	CERT_SYSTEM_STORE_RELOCATE_FLAG              = 0x80000000
   412  
   413  	/* Miscellaneous high-WORD flags for CertOpenStore function */
   414  	CERT_REGISTRY_STORE_REMOTE_FLAG      = 0x00010000
   415  	CERT_REGISTRY_STORE_SERIALIZED_FLAG  = 0x00020000
   416  	CERT_REGISTRY_STORE_ROAMING_FLAG     = 0x00040000
   417  	CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG = 0x00080000
   418  	CERT_REGISTRY_STORE_LM_GPT_FLAG      = 0x01000000
   419  	CERT_REGISTRY_STORE_CLIENT_GPT_FLAG  = 0x80000000
   420  	CERT_FILE_STORE_COMMIT_ENABLE_FLAG   = 0x00010000
   421  	CERT_LDAP_STORE_SIGN_FLAG            = 0x00010000
   422  	CERT_LDAP_STORE_AREC_EXCLUSIVE_FLAG  = 0x00020000
   423  	CERT_LDAP_STORE_OPENED_FLAG          = 0x00040000
   424  	CERT_LDAP_STORE_UNBIND_FLAG          = 0x00080000
   425  
   426  	/* addDisposition values for CertAddCertificateContextToStore function */
   427  	CERT_STORE_ADD_NEW                                 = 1
   428  	CERT_STORE_ADD_USE_EXISTING                        = 2
   429  	CERT_STORE_ADD_REPLACE_EXISTING                    = 3
   430  	CERT_STORE_ADD_ALWAYS                              = 4
   431  	CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5
   432  	CERT_STORE_ADD_NEWER                               = 6
   433  	CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES            = 7
   434  
   435  	/* ErrorStatus values for CertTrustStatus struct */
   436  	CERT_TRUST_NO_ERROR                          = 0x00000000
   437  	CERT_TRUST_IS_NOT_TIME_VALID                 = 0x00000001
   438  	CERT_TRUST_IS_REVOKED                        = 0x00000004
   439  	CERT_TRUST_IS_NOT_SIGNATURE_VALID            = 0x00000008
   440  	CERT_TRUST_IS_NOT_VALID_FOR_USAGE            = 0x00000010
   441  	CERT_TRUST_IS_UNTRUSTED_ROOT                 = 0x00000020
   442  	CERT_TRUST_REVOCATION_STATUS_UNKNOWN         = 0x00000040
   443  	CERT_TRUST_IS_CYCLIC                         = 0x00000080
   444  	CERT_TRUST_INVALID_EXTENSION                 = 0x00000100
   445  	CERT_TRUST_INVALID_POLICY_CONSTRAINTS        = 0x00000200
   446  	CERT_TRUST_INVALID_BASIC_CONSTRAINTS         = 0x00000400
   447  	CERT_TRUST_INVALID_NAME_CONSTRAINTS          = 0x00000800
   448  	CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000
   449  	CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT   = 0x00002000
   450  	CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000
   451  	CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT      = 0x00008000
   452  	CERT_TRUST_IS_PARTIAL_CHAIN                  = 0x00010000
   453  	CERT_TRUST_CTL_IS_NOT_TIME_VALID             = 0x00020000
   454  	CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID        = 0x00040000
   455  	CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE        = 0x00080000
   456  	CERT_TRUST_HAS_WEAK_SIGNATURE                = 0x00100000
   457  	CERT_TRUST_IS_OFFLINE_REVOCATION             = 0x01000000
   458  	CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY          = 0x02000000
   459  	CERT_TRUST_IS_EXPLICIT_DISTRUST              = 0x04000000
   460  	CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT    = 0x08000000
   461  
   462  	/* InfoStatus values for CertTrustStatus struct */
   463  	CERT_TRUST_HAS_EXACT_MATCH_ISSUER        = 0x00000001
   464  	CERT_TRUST_HAS_KEY_MATCH_ISSUER          = 0x00000002
   465  	CERT_TRUST_HAS_NAME_MATCH_ISSUER         = 0x00000004
   466  	CERT_TRUST_IS_SELF_SIGNED                = 0x00000008
   467  	CERT_TRUST_HAS_PREFERRED_ISSUER          = 0x00000100
   468  	CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY     = 0x00000400
   469  	CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS    = 0x00000400
   470  	CERT_TRUST_IS_PEER_TRUSTED               = 0x00000800
   471  	CERT_TRUST_HAS_CRL_VALIDITY_EXTENDED     = 0x00001000
   472  	CERT_TRUST_IS_FROM_EXCLUSIVE_TRUST_STORE = 0x00002000
   473  	CERT_TRUST_IS_CA_TRUSTED                 = 0x00004000
   474  	CERT_TRUST_IS_COMPLEX_CHAIN              = 0x00010000
   475  
   476  	/* Certificate Information Flags */
   477  	CERT_INFO_VERSION_FLAG                 = 1
   478  	CERT_INFO_SERIAL_NUMBER_FLAG           = 2
   479  	CERT_INFO_SIGNATURE_ALGORITHM_FLAG     = 3
   480  	CERT_INFO_ISSUER_FLAG                  = 4
   481  	CERT_INFO_NOT_BEFORE_FLAG              = 5
   482  	CERT_INFO_NOT_AFTER_FLAG               = 6
   483  	CERT_INFO_SUBJECT_FLAG                 = 7
   484  	CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG = 8
   485  	CERT_INFO_ISSUER_UNIQUE_ID_FLAG        = 9
   486  	CERT_INFO_SUBJECT_UNIQUE_ID_FLAG       = 10
   487  	CERT_INFO_EXTENSION_FLAG               = 11
   488  
   489  	/* dwFindType for CertFindCertificateInStore  */
   490  	CERT_COMPARE_MASK                     = 0xFFFF
   491  	CERT_COMPARE_SHIFT                    = 16
   492  	CERT_COMPARE_ANY                      = 0
   493  	CERT_COMPARE_SHA1_HASH                = 1
   494  	CERT_COMPARE_NAME                     = 2
   495  	CERT_COMPARE_ATTR                     = 3
   496  	CERT_COMPARE_MD5_HASH                 = 4
   497  	CERT_COMPARE_PROPERTY                 = 5
   498  	CERT_COMPARE_PUBLIC_KEY               = 6
   499  	CERT_COMPARE_HASH                     = CERT_COMPARE_SHA1_HASH
   500  	CERT_COMPARE_NAME_STR_A               = 7
   501  	CERT_COMPARE_NAME_STR_W               = 8
   502  	CERT_COMPARE_KEY_SPEC                 = 9
   503  	CERT_COMPARE_ENHKEY_USAGE             = 10
   504  	CERT_COMPARE_CTL_USAGE                = CERT_COMPARE_ENHKEY_USAGE
   505  	CERT_COMPARE_SUBJECT_CERT             = 11
   506  	CERT_COMPARE_ISSUER_OF                = 12
   507  	CERT_COMPARE_EXISTING                 = 13
   508  	CERT_COMPARE_SIGNATURE_HASH           = 14
   509  	CERT_COMPARE_KEY_IDENTIFIER           = 15
   510  	CERT_COMPARE_CERT_ID                  = 16
   511  	CERT_COMPARE_CROSS_CERT_DIST_POINTS   = 17
   512  	CERT_COMPARE_PUBKEY_MD5_HASH          = 18
   513  	CERT_COMPARE_SUBJECT_INFO_ACCESS      = 19
   514  	CERT_COMPARE_HASH_STR                 = 20
   515  	CERT_COMPARE_HAS_PRIVATE_KEY          = 21
   516  	CERT_FIND_ANY                         = (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT)
   517  	CERT_FIND_SHA1_HASH                   = (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT)
   518  	CERT_FIND_MD5_HASH                    = (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT)
   519  	CERT_FIND_SIGNATURE_HASH              = (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT)
   520  	CERT_FIND_KEY_IDENTIFIER              = (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT)
   521  	CERT_FIND_HASH                        = CERT_FIND_SHA1_HASH
   522  	CERT_FIND_PROPERTY                    = (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT)
   523  	CERT_FIND_PUBLIC_KEY                  = (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT)
   524  	CERT_FIND_SUBJECT_NAME                = (CERT_COMPARE_NAME<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
   525  	CERT_FIND_SUBJECT_ATTR                = (CERT_COMPARE_ATTR<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
   526  	CERT_FIND_ISSUER_NAME                 = (CERT_COMPARE_NAME<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
   527  	CERT_FIND_ISSUER_ATTR                 = (CERT_COMPARE_ATTR<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
   528  	CERT_FIND_SUBJECT_STR_A               = (CERT_COMPARE_NAME_STR_A<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
   529  	CERT_FIND_SUBJECT_STR_W               = (CERT_COMPARE_NAME_STR_W<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
   530  	CERT_FIND_SUBJECT_STR                 = CERT_FIND_SUBJECT_STR_W
   531  	CERT_FIND_ISSUER_STR_A                = (CERT_COMPARE_NAME_STR_A<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
   532  	CERT_FIND_ISSUER_STR_W                = (CERT_COMPARE_NAME_STR_W<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
   533  	CERT_FIND_ISSUER_STR                  = CERT_FIND_ISSUER_STR_W
   534  	CERT_FIND_KEY_SPEC                    = (CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT)
   535  	CERT_FIND_ENHKEY_USAGE                = (CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT)
   536  	CERT_FIND_CTL_USAGE                   = CERT_FIND_ENHKEY_USAGE
   537  	CERT_FIND_SUBJECT_CERT                = (CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT)
   538  	CERT_FIND_ISSUER_OF                   = (CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT)
   539  	CERT_FIND_EXISTING                    = (CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT)
   540  	CERT_FIND_CERT_ID                     = (CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT)
   541  	CERT_FIND_CROSS_CERT_DIST_POINTS      = (CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT)
   542  	CERT_FIND_PUBKEY_MD5_HASH             = (CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT)
   543  	CERT_FIND_SUBJECT_INFO_ACCESS         = (CERT_COMPARE_SUBJECT_INFO_ACCESS << CERT_COMPARE_SHIFT)
   544  	CERT_FIND_HASH_STR                    = (CERT_COMPARE_HASH_STR << CERT_COMPARE_SHIFT)
   545  	CERT_FIND_HAS_PRIVATE_KEY             = (CERT_COMPARE_HAS_PRIVATE_KEY << CERT_COMPARE_SHIFT)
   546  	CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG  = 0x1
   547  	CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG  = 0x2
   548  	CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG = 0x4
   549  	CERT_FIND_NO_ENHKEY_USAGE_FLAG        = 0x8
   550  	CERT_FIND_OR_ENHKEY_USAGE_FLAG        = 0x10
   551  	CERT_FIND_VALID_ENHKEY_USAGE_FLAG     = 0x20
   552  	CERT_FIND_OPTIONAL_CTL_USAGE_FLAG     = CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG
   553  	CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG     = CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG
   554  	CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG    = CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
   555  	CERT_FIND_NO_CTL_USAGE_FLAG           = CERT_FIND_NO_ENHKEY_USAGE_FLAG
   556  	CERT_FIND_OR_CTL_USAGE_FLAG           = CERT_FIND_OR_ENHKEY_USAGE_FLAG
   557  	CERT_FIND_VALID_CTL_USAGE_FLAG        = CERT_FIND_VALID_ENHKEY_USAGE_FLAG
   558  
   559  	/* policyOID values for CertVerifyCertificateChainPolicy function */
   560  	CERT_CHAIN_POLICY_BASE              = 1
   561  	CERT_CHAIN_POLICY_AUTHENTICODE      = 2
   562  	CERT_CHAIN_POLICY_AUTHENTICODE_TS   = 3
   563  	CERT_CHAIN_POLICY_SSL               = 4
   564  	CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5
   565  	CERT_CHAIN_POLICY_NT_AUTH           = 6
   566  	CERT_CHAIN_POLICY_MICROSOFT_ROOT    = 7
   567  	CERT_CHAIN_POLICY_EV                = 8
   568  	CERT_CHAIN_POLICY_SSL_F12           = 9
   569  
   570  	/* flag for dwFindType CertFindChainInStore  */
   571  	CERT_CHAIN_FIND_BY_ISSUER = 1
   572  
   573  	/* dwFindFlags for CertFindChainInStore when dwFindType == CERT_CHAIN_FIND_BY_ISSUER */
   574  	CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG    = 0x0001
   575  	CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG  = 0x0002
   576  	CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG = 0x0004
   577  	CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG  = 0x0008
   578  	CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG         = 0x4000
   579  	CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG     = 0x8000
   580  
   581  	/* Certificate Store close flags */
   582  	CERT_CLOSE_STORE_FORCE_FLAG = 0x00000001
   583  	CERT_CLOSE_STORE_CHECK_FLAG = 0x00000002
   584  
   585  	/* CryptQueryObject object type */
   586  	CERT_QUERY_OBJECT_FILE = 1
   587  	CERT_QUERY_OBJECT_BLOB = 2
   588  
   589  	/* CryptQueryObject content type flags */
   590  	CERT_QUERY_CONTENT_CERT                    = 1
   591  	CERT_QUERY_CONTENT_CTL                     = 2
   592  	CERT_QUERY_CONTENT_CRL                     = 3
   593  	CERT_QUERY_CONTENT_SERIALIZED_STORE        = 4
   594  	CERT_QUERY_CONTENT_SERIALIZED_CERT         = 5
   595  	CERT_QUERY_CONTENT_SERIALIZED_CTL          = 6
   596  	CERT_QUERY_CONTENT_SERIALIZED_CRL          = 7
   597  	CERT_QUERY_CONTENT_PKCS7_SIGNED            = 8
   598  	CERT_QUERY_CONTENT_PKCS7_UNSIGNED          = 9
   599  	CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED      = 10
   600  	CERT_QUERY_CONTENT_PKCS10                  = 11
   601  	CERT_QUERY_CONTENT_PFX                     = 12
   602  	CERT_QUERY_CONTENT_CERT_PAIR               = 13
   603  	CERT_QUERY_CONTENT_PFX_AND_LOAD            = 14
   604  	CERT_QUERY_CONTENT_FLAG_CERT               = (1 << CERT_QUERY_CONTENT_CERT)
   605  	CERT_QUERY_CONTENT_FLAG_CTL                = (1 << CERT_QUERY_CONTENT_CTL)
   606  	CERT_QUERY_CONTENT_FLAG_CRL                = (1 << CERT_QUERY_CONTENT_CRL)
   607  	CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE   = (1 << CERT_QUERY_CONTENT_SERIALIZED_STORE)
   608  	CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT    = (1 << CERT_QUERY_CONTENT_SERIALIZED_CERT)
   609  	CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL     = (1 << CERT_QUERY_CONTENT_SERIALIZED_CTL)
   610  	CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL     = (1 << CERT_QUERY_CONTENT_SERIALIZED_CRL)
   611  	CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED       = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED)
   612  	CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED     = (1 << CERT_QUERY_CONTENT_PKCS7_UNSIGNED)
   613  	CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED)
   614  	CERT_QUERY_CONTENT_FLAG_PKCS10             = (1 << CERT_QUERY_CONTENT_PKCS10)
   615  	CERT_QUERY_CONTENT_FLAG_PFX                = (1 << CERT_QUERY_CONTENT_PFX)
   616  	CERT_QUERY_CONTENT_FLAG_CERT_PAIR          = (1 << CERT_QUERY_CONTENT_CERT_PAIR)
   617  	CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD       = (1 << CERT_QUERY_CONTENT_PFX_AND_LOAD)
   618  	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)
   619  	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)
   620  
   621  	/* CryptQueryObject format type flags */
   622  	CERT_QUERY_FORMAT_BINARY                     = 1
   623  	CERT_QUERY_FORMAT_BASE64_ENCODED             = 2
   624  	CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED      = 3
   625  	CERT_QUERY_FORMAT_FLAG_BINARY                = (1 << CERT_QUERY_FORMAT_BINARY)
   626  	CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED        = (1 << CERT_QUERY_FORMAT_BASE64_ENCODED)
   627  	CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED = (1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED)
   628  	CERT_QUERY_FORMAT_FLAG_ALL                   = (CERT_QUERY_FORMAT_FLAG_BINARY | CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED | CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED)
   629  
   630  	/* CertGetNameString name types */
   631  	CERT_NAME_EMAIL_TYPE            = 1
   632  	CERT_NAME_RDN_TYPE              = 2
   633  	CERT_NAME_ATTR_TYPE             = 3
   634  	CERT_NAME_SIMPLE_DISPLAY_TYPE   = 4
   635  	CERT_NAME_FRIENDLY_DISPLAY_TYPE = 5
   636  	CERT_NAME_DNS_TYPE              = 6
   637  	CERT_NAME_URL_TYPE              = 7
   638  	CERT_NAME_UPN_TYPE              = 8
   639  
   640  	/* CertGetNameString flags */
   641  	CERT_NAME_ISSUER_FLAG              = 0x1
   642  	CERT_NAME_DISABLE_IE4_UTF8_FLAG    = 0x10000
   643  	CERT_NAME_SEARCH_ALL_NAMES_FLAG    = 0x2
   644  	CERT_NAME_STR_ENABLE_PUNYCODE_FLAG = 0x00200000
   645  
   646  	/* AuthType values for SSLExtraCertChainPolicyPara struct */
   647  	AUTHTYPE_CLIENT = 1
   648  	AUTHTYPE_SERVER = 2
   649  
   650  	/* Checks values for SSLExtraCertChainPolicyPara struct */
   651  	SECURITY_FLAG_IGNORE_REVOCATION        = 0x00000080
   652  	SECURITY_FLAG_IGNORE_UNKNOWN_CA        = 0x00000100
   653  	SECURITY_FLAG_IGNORE_WRONG_USAGE       = 0x00000200
   654  	SECURITY_FLAG_IGNORE_CERT_CN_INVALID   = 0x00001000
   655  	SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000
   656  
   657  	/* Flags for Crypt[Un]ProtectData */
   658  	CRYPTPROTECT_UI_FORBIDDEN      = 0x1
   659  	CRYPTPROTECT_LOCAL_MACHINE     = 0x4
   660  	CRYPTPROTECT_CRED_SYNC         = 0x8
   661  	CRYPTPROTECT_AUDIT             = 0x10
   662  	CRYPTPROTECT_NO_RECOVERY       = 0x20
   663  	CRYPTPROTECT_VERIFY_PROTECTION = 0x40
   664  	CRYPTPROTECT_CRED_REGENERATE   = 0x80
   665  
   666  	/* Flags for CryptProtectPromptStruct */
   667  	CRYPTPROTECT_PROMPT_ON_UNPROTECT   = 1
   668  	CRYPTPROTECT_PROMPT_ON_PROTECT     = 2
   669  	CRYPTPROTECT_PROMPT_RESERVED       = 4
   670  	CRYPTPROTECT_PROMPT_STRONG         = 8
   671  	CRYPTPROTECT_PROMPT_REQUIRE_STRONG = 16
   672  )
   673  
   674  const (
   675  	// flags for SetErrorMode
   676  	SEM_FAILCRITICALERRORS     = 0x0001
   677  	SEM_NOALIGNMENTFAULTEXCEPT = 0x0004
   678  	SEM_NOGPFAULTERRORBOX      = 0x0002
   679  	SEM_NOOPENFILEERRORBOX     = 0x8000
   680  )
   681  
   682  const (
   683  	// Priority class.
   684  	ABOVE_NORMAL_PRIORITY_CLASS   = 0x00008000
   685  	BELOW_NORMAL_PRIORITY_CLASS   = 0x00004000
   686  	HIGH_PRIORITY_CLASS           = 0x00000080
   687  	IDLE_PRIORITY_CLASS           = 0x00000040
   688  	NORMAL_PRIORITY_CLASS         = 0x00000020
   689  	PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000
   690  	PROCESS_MODE_BACKGROUND_END   = 0x00200000
   691  	REALTIME_PRIORITY_CLASS       = 0x00000100
   692  )
   693  
   694  /* wintrust.h constants for WinVerifyTrustEx */
   695  const (
   696  	WTD_UI_ALL    = 1
   697  	WTD_UI_NONE   = 2
   698  	WTD_UI_NOBAD  = 3
   699  	WTD_UI_NOGOOD = 4
   700  
   701  	WTD_REVOKE_NONE       = 0
   702  	WTD_REVOKE_WHOLECHAIN = 1
   703  
   704  	WTD_CHOICE_FILE    = 1
   705  	WTD_CHOICE_CATALOG = 2
   706  	WTD_CHOICE_BLOB    = 3
   707  	WTD_CHOICE_SIGNER  = 4
   708  	WTD_CHOICE_CERT    = 5
   709  
   710  	WTD_STATEACTION_IGNORE           = 0x00000000
   711  	WTD_STATEACTION_VERIFY           = 0x00000001
   712  	WTD_STATEACTION_CLOSE            = 0x00000002
   713  	WTD_STATEACTION_AUTO_CACHE       = 0x00000003
   714  	WTD_STATEACTION_AUTO_CACHE_FLUSH = 0x00000004
   715  
   716  	WTD_USE_IE4_TRUST_FLAG                  = 0x1
   717  	WTD_NO_IE4_CHAIN_FLAG                   = 0x2
   718  	WTD_NO_POLICY_USAGE_FLAG                = 0x4
   719  	WTD_REVOCATION_CHECK_NONE               = 0x10
   720  	WTD_REVOCATION_CHECK_END_CERT           = 0x20
   721  	WTD_REVOCATION_CHECK_CHAIN              = 0x40
   722  	WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x80
   723  	WTD_SAFER_FLAG                          = 0x100
   724  	WTD_HASH_ONLY_FLAG                      = 0x200
   725  	WTD_USE_DEFAULT_OSVER_CHECK             = 0x400
   726  	WTD_LIFETIME_SIGNING_FLAG               = 0x800
   727  	WTD_CACHE_ONLY_URL_RETRIEVAL            = 0x1000
   728  	WTD_DISABLE_MD2_MD4                     = 0x2000
   729  	WTD_MOTW                                = 0x4000
   730  
   731  	WTD_UICONTEXT_EXECUTE = 0
   732  	WTD_UICONTEXT_INSTALL = 1
   733  )
   734  
   735  var (
   736  	OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00")
   737  	OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00")
   738  	OID_SGC_NETSCAPE        = []byte("2.16.840.1.113730.4.1\x00")
   739  
   740  	WINTRUST_ACTION_GENERIC_VERIFY_V2 = GUID{
   741  		Data1: 0xaac56b,
   742  		Data2: 0xcd44,
   743  		Data3: 0x11d0,
   744  		Data4: [8]byte{0x8c, 0xc2, 0x0, 0xc0, 0x4f, 0xc2, 0x95, 0xee},
   745  	}
   746  )
   747  
   748  // Pointer represents a pointer to an arbitrary Windows type.
   749  //
   750  // Pointer-typed fields may point to one of many different types. It's
   751  // up to the caller to provide a pointer to the appropriate type, cast
   752  // to Pointer. The caller must obey the unsafe.Pointer rules while
   753  // doing so.
   754  type Pointer *struct{}
   755  
   756  // Invented values to support what package os expects.
   757  type Timeval struct {
   758  	Sec  int32
   759  	Usec int32
   760  }
   761  
   762  func (tv *Timeval) Nanoseconds() int64 {
   763  	return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3
   764  }
   765  
   766  func NsecToTimeval(nsec int64) (tv Timeval) {
   767  	tv.Sec = int32(nsec / 1e9)
   768  	tv.Usec = int32(nsec % 1e9 / 1e3)
   769  	return
   770  }
   771  
   772  type Overlapped struct {
   773  	Internal     uintptr
   774  	InternalHigh uintptr
   775  	Offset       uint32
   776  	OffsetHigh   uint32
   777  	HEvent       Handle
   778  }
   779  
   780  type FileNotifyInformation struct {
   781  	NextEntryOffset uint32
   782  	Action          uint32
   783  	FileNameLength  uint32
   784  	FileName        uint16
   785  }
   786  
   787  type Filetime struct {
   788  	LowDateTime  uint32
   789  	HighDateTime uint32
   790  }
   791  
   792  // Nanoseconds returns Filetime ft in nanoseconds
   793  // since Epoch (00:00:00 UTC, January 1, 1970).
   794  func (ft *Filetime) Nanoseconds() int64 {
   795  	// 100-nanosecond intervals since January 1, 1601
   796  	nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)
   797  	// change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
   798  	nsec -= 116444736000000000
   799  	// convert into nanoseconds
   800  	nsec *= 100
   801  	return nsec
   802  }
   803  
   804  func NsecToFiletime(nsec int64) (ft Filetime) {
   805  	// convert into 100-nanosecond
   806  	nsec /= 100
   807  	// change starting time to January 1, 1601
   808  	nsec += 116444736000000000
   809  	// split into high / low
   810  	ft.LowDateTime = uint32(nsec & 0xffffffff)
   811  	ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff)
   812  	return ft
   813  }
   814  
   815  type Win32finddata struct {
   816  	FileAttributes    uint32
   817  	CreationTime      Filetime
   818  	LastAccessTime    Filetime
   819  	LastWriteTime     Filetime
   820  	FileSizeHigh      uint32
   821  	FileSizeLow       uint32
   822  	Reserved0         uint32
   823  	Reserved1         uint32
   824  	FileName          [MAX_PATH - 1]uint16
   825  	AlternateFileName [13]uint16
   826  }
   827  
   828  // This is the actual system call structure.
   829  // Win32finddata is what we committed to in Go 1.
   830  type win32finddata1 struct {
   831  	FileAttributes    uint32
   832  	CreationTime      Filetime
   833  	LastAccessTime    Filetime
   834  	LastWriteTime     Filetime
   835  	FileSizeHigh      uint32
   836  	FileSizeLow       uint32
   837  	Reserved0         uint32
   838  	Reserved1         uint32
   839  	FileName          [MAX_PATH]uint16
   840  	AlternateFileName [14]uint16
   841  
   842  	// The Microsoft documentation for this struct¹ describes three additional
   843  	// fields: dwFileType, dwCreatorType, and wFinderFlags. However, those fields
   844  	// are empirically only present in the macOS port of the Win32 API,² and thus
   845  	// not needed for binaries built for Windows.
   846  	//
   847  	// ¹ https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-win32_find_dataw describe
   848  	// ² https://golang.org/issue/42637#issuecomment-760715755.
   849  }
   850  
   851  func copyFindData(dst *Win32finddata, src *win32finddata1) {
   852  	dst.FileAttributes = src.FileAttributes
   853  	dst.CreationTime = src.CreationTime
   854  	dst.LastAccessTime = src.LastAccessTime
   855  	dst.LastWriteTime = src.LastWriteTime
   856  	dst.FileSizeHigh = src.FileSizeHigh
   857  	dst.FileSizeLow = src.FileSizeLow
   858  	dst.Reserved0 = src.Reserved0
   859  	dst.Reserved1 = src.Reserved1
   860  
   861  	// The src is 1 element bigger than dst, but it must be NUL.
   862  	copy(dst.FileName[:], src.FileName[:])
   863  	copy(dst.AlternateFileName[:], src.AlternateFileName[:])
   864  }
   865  
   866  type ByHandleFileInformation struct {
   867  	FileAttributes     uint32
   868  	CreationTime       Filetime
   869  	LastAccessTime     Filetime
   870  	LastWriteTime      Filetime
   871  	VolumeSerialNumber uint32
   872  	FileSizeHigh       uint32
   873  	FileSizeLow        uint32
   874  	NumberOfLinks      uint32
   875  	FileIndexHigh      uint32
   876  	FileIndexLow       uint32
   877  }
   878  
   879  const (
   880  	GetFileExInfoStandard = 0
   881  	GetFileExMaxInfoLevel = 1
   882  )
   883  
   884  type Win32FileAttributeData struct {
   885  	FileAttributes uint32
   886  	CreationTime   Filetime
   887  	LastAccessTime Filetime
   888  	LastWriteTime  Filetime
   889  	FileSizeHigh   uint32
   890  	FileSizeLow    uint32
   891  }
   892  
   893  // ShowWindow constants
   894  const (
   895  	// winuser.h
   896  	SW_HIDE            = 0
   897  	SW_NORMAL          = 1
   898  	SW_SHOWNORMAL      = 1
   899  	SW_SHOWMINIMIZED   = 2
   900  	SW_SHOWMAXIMIZED   = 3
   901  	SW_MAXIMIZE        = 3
   902  	SW_SHOWNOACTIVATE  = 4
   903  	SW_SHOW            = 5
   904  	SW_MINIMIZE        = 6
   905  	SW_SHOWMINNOACTIVE = 7
   906  	SW_SHOWNA          = 8
   907  	SW_RESTORE         = 9
   908  	SW_SHOWDEFAULT     = 10
   909  	SW_FORCEMINIMIZE   = 11
   910  )
   911  
   912  type StartupInfo struct {
   913  	Cb            uint32
   914  	_             *uint16
   915  	Desktop       *uint16
   916  	Title         *uint16
   917  	X             uint32
   918  	Y             uint32
   919  	XSize         uint32
   920  	YSize         uint32
   921  	XCountChars   uint32
   922  	YCountChars   uint32
   923  	FillAttribute uint32
   924  	Flags         uint32
   925  	ShowWindow    uint16
   926  	_             uint16
   927  	_             *byte
   928  	StdInput      Handle
   929  	StdOutput     Handle
   930  	StdErr        Handle
   931  }
   932  
   933  type StartupInfoEx struct {
   934  	StartupInfo
   935  	ProcThreadAttributeList *ProcThreadAttributeList
   936  }
   937  
   938  // ProcThreadAttributeList is a placeholder type to represent a PROC_THREAD_ATTRIBUTE_LIST.
   939  //
   940  // To create a *ProcThreadAttributeList, use NewProcThreadAttributeList, update
   941  // it with ProcThreadAttributeListContainer.Update, free its memory using
   942  // ProcThreadAttributeListContainer.Delete, and access the list itself using
   943  // ProcThreadAttributeListContainer.List.
   944  type ProcThreadAttributeList struct{}
   945  
   946  type ProcThreadAttributeListContainer struct {
   947  	data     *ProcThreadAttributeList
   948  	pointers []unsafe.Pointer
   949  }
   950  
   951  type ProcessInformation struct {
   952  	Process   Handle
   953  	Thread    Handle
   954  	ProcessId uint32
   955  	ThreadId  uint32
   956  }
   957  
   958  type ProcessEntry32 struct {
   959  	Size            uint32
   960  	Usage           uint32
   961  	ProcessID       uint32
   962  	DefaultHeapID   uintptr
   963  	ModuleID        uint32
   964  	Threads         uint32
   965  	ParentProcessID uint32
   966  	PriClassBase    int32
   967  	Flags           uint32
   968  	ExeFile         [MAX_PATH]uint16
   969  }
   970  
   971  type ThreadEntry32 struct {
   972  	Size           uint32
   973  	Usage          uint32
   974  	ThreadID       uint32
   975  	OwnerProcessID uint32
   976  	BasePri        int32
   977  	DeltaPri       int32
   978  	Flags          uint32
   979  }
   980  
   981  type ModuleEntry32 struct {
   982  	Size         uint32
   983  	ModuleID     uint32
   984  	ProcessID    uint32
   985  	GlblcntUsage uint32
   986  	ProccntUsage uint32
   987  	ModBaseAddr  uintptr
   988  	ModBaseSize  uint32
   989  	ModuleHandle Handle
   990  	Module       [MAX_MODULE_NAME32 + 1]uint16
   991  	ExePath      [MAX_PATH]uint16
   992  }
   993  
   994  const SizeofModuleEntry32 = unsafe.Sizeof(ModuleEntry32{})
   995  
   996  type Systemtime struct {
   997  	Year         uint16
   998  	Month        uint16
   999  	DayOfWeek    uint16
  1000  	Day          uint16
  1001  	Hour         uint16
  1002  	Minute       uint16
  1003  	Second       uint16
  1004  	Milliseconds uint16
  1005  }
  1006  
  1007  type Timezoneinformation struct {
  1008  	Bias         int32
  1009  	StandardName [32]uint16
  1010  	StandardDate Systemtime
  1011  	StandardBias int32
  1012  	DaylightName [32]uint16
  1013  	DaylightDate Systemtime
  1014  	DaylightBias int32
  1015  }
  1016  
  1017  // Socket related.
  1018  
  1019  const (
  1020  	AF_UNSPEC  = 0
  1021  	AF_UNIX    = 1
  1022  	AF_INET    = 2
  1023  	AF_NETBIOS = 17
  1024  	AF_INET6   = 23
  1025  	AF_IRDA    = 26
  1026  	AF_BTH     = 32
  1027  
  1028  	SOCK_STREAM    = 1
  1029  	SOCK_DGRAM     = 2
  1030  	SOCK_RAW       = 3
  1031  	SOCK_RDM       = 4
  1032  	SOCK_SEQPACKET = 5
  1033  
  1034  	IPPROTO_IP      = 0
  1035  	IPPROTO_ICMP    = 1
  1036  	IPPROTO_IGMP    = 2
  1037  	BTHPROTO_RFCOMM = 3
  1038  	IPPROTO_TCP     = 6
  1039  	IPPROTO_UDP     = 17
  1040  	IPPROTO_IPV6    = 41
  1041  	IPPROTO_ICMPV6  = 58
  1042  	IPPROTO_RM      = 113
  1043  
  1044  	SOL_SOCKET                = 0xffff
  1045  	SO_REUSEADDR              = 4
  1046  	SO_KEEPALIVE              = 8
  1047  	SO_DONTROUTE              = 16
  1048  	SO_BROADCAST              = 32
  1049  	SO_LINGER                 = 128
  1050  	SO_RCVBUF                 = 0x1002
  1051  	SO_RCVTIMEO               = 0x1006
  1052  	SO_SNDBUF                 = 0x1001
  1053  	SO_UPDATE_ACCEPT_CONTEXT  = 0x700b
  1054  	SO_UPDATE_CONNECT_CONTEXT = 0x7010
  1055  
  1056  	IOC_OUT                            = 0x40000000
  1057  	IOC_IN                             = 0x80000000
  1058  	IOC_VENDOR                         = 0x18000000
  1059  	IOC_INOUT                          = IOC_IN | IOC_OUT
  1060  	IOC_WS2                            = 0x08000000
  1061  	SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6
  1062  	SIO_KEEPALIVE_VALS                 = IOC_IN | IOC_VENDOR | 4
  1063  	SIO_UDP_CONNRESET                  = IOC_IN | IOC_VENDOR | 12
  1064  	SIO_UDP_NETRESET                   = IOC_IN | IOC_VENDOR | 15
  1065  
  1066  	// cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460
  1067  
  1068  	IP_HDRINCL         = 0x2
  1069  	IP_TOS             = 0x3
  1070  	IP_TTL             = 0x4
  1071  	IP_MULTICAST_IF    = 0x9
  1072  	IP_MULTICAST_TTL   = 0xa
  1073  	IP_MULTICAST_LOOP  = 0xb
  1074  	IP_ADD_MEMBERSHIP  = 0xc
  1075  	IP_DROP_MEMBERSHIP = 0xd
  1076  	IP_PKTINFO         = 0x13
  1077  
  1078  	IPV6_V6ONLY         = 0x1b
  1079  	IPV6_UNICAST_HOPS   = 0x4
  1080  	IPV6_MULTICAST_IF   = 0x9
  1081  	IPV6_MULTICAST_HOPS = 0xa
  1082  	IPV6_MULTICAST_LOOP = 0xb
  1083  	IPV6_JOIN_GROUP     = 0xc
  1084  	IPV6_LEAVE_GROUP    = 0xd
  1085  	IPV6_PKTINFO        = 0x13
  1086  
  1087  	MSG_OOB       = 0x1
  1088  	MSG_PEEK      = 0x2
  1089  	MSG_DONTROUTE = 0x4
  1090  	MSG_WAITALL   = 0x8
  1091  
  1092  	MSG_TRUNC  = 0x0100
  1093  	MSG_CTRUNC = 0x0200
  1094  	MSG_BCAST  = 0x0400
  1095  	MSG_MCAST  = 0x0800
  1096  
  1097  	SOMAXCONN = 0x7fffffff
  1098  
  1099  	TCP_NODELAY                    = 1
  1100  	TCP_EXPEDITED_1122             = 2
  1101  	TCP_KEEPALIVE                  = 3
  1102  	TCP_MAXSEG                     = 4
  1103  	TCP_MAXRT                      = 5
  1104  	TCP_STDURG                     = 6
  1105  	TCP_NOURG                      = 7
  1106  	TCP_ATMARK                     = 8
  1107  	TCP_NOSYNRETRIES               = 9
  1108  	TCP_TIMESTAMPS                 = 10
  1109  	TCP_OFFLOAD_PREFERENCE         = 11
  1110  	TCP_CONGESTION_ALGORITHM       = 12
  1111  	TCP_DELAY_FIN_ACK              = 13
  1112  	TCP_MAXRTMS                    = 14
  1113  	TCP_FASTOPEN                   = 15
  1114  	TCP_KEEPCNT                    = 16
  1115  	TCP_KEEPIDLE                   = TCP_KEEPALIVE
  1116  	TCP_KEEPINTVL                  = 17
  1117  	TCP_FAIL_CONNECT_ON_ICMP_ERROR = 18
  1118  	TCP_ICMP_ERROR_INFO            = 19
  1119  
  1120  	UDP_NOCHECKSUM              = 1
  1121  	UDP_SEND_MSG_SIZE           = 2
  1122  	UDP_RECV_MAX_COALESCED_SIZE = 3
  1123  	UDP_CHECKSUM_COVERAGE       = 20
  1124  
  1125  	UDP_COALESCED_INFO = 3
  1126  
  1127  	SHUT_RD   = 0
  1128  	SHUT_WR   = 1
  1129  	SHUT_RDWR = 2
  1130  
  1131  	WSADESCRIPTION_LEN = 256
  1132  	WSASYS_STATUS_LEN  = 128
  1133  )
  1134  
  1135  type WSABuf struct {
  1136  	Len uint32
  1137  	Buf *byte
  1138  }
  1139  
  1140  type WSAMsg struct {
  1141  	Name        *syscall.RawSockaddrAny
  1142  	Namelen     int32
  1143  	Buffers     *WSABuf
  1144  	BufferCount uint32
  1145  	Control     WSABuf
  1146  	Flags       uint32
  1147  }
  1148  
  1149  // Flags for WSASocket
  1150  const (
  1151  	WSA_FLAG_OVERLAPPED             = 0x01
  1152  	WSA_FLAG_MULTIPOINT_C_ROOT      = 0x02
  1153  	WSA_FLAG_MULTIPOINT_C_LEAF      = 0x04
  1154  	WSA_FLAG_MULTIPOINT_D_ROOT      = 0x08
  1155  	WSA_FLAG_MULTIPOINT_D_LEAF      = 0x10
  1156  	WSA_FLAG_ACCESS_SYSTEM_SECURITY = 0x40
  1157  	WSA_FLAG_NO_HANDLE_INHERIT      = 0x80
  1158  	WSA_FLAG_REGISTERED_IO          = 0x100
  1159  )
  1160  
  1161  // Invented values to support what package os expects.
  1162  const (
  1163  	S_IFMT   = 0x1f000
  1164  	S_IFIFO  = 0x1000
  1165  	S_IFCHR  = 0x2000
  1166  	S_IFDIR  = 0x4000
  1167  	S_IFBLK  = 0x6000
  1168  	S_IFREG  = 0x8000
  1169  	S_IFLNK  = 0xa000
  1170  	S_IFSOCK = 0xc000
  1171  	S_ISUID  = 0x800
  1172  	S_ISGID  = 0x400
  1173  	S_ISVTX  = 0x200
  1174  	S_IRUSR  = 0x100
  1175  	S_IWRITE = 0x80
  1176  	S_IWUSR  = 0x80
  1177  	S_IXUSR  = 0x40
  1178  )
  1179  
  1180  const (
  1181  	FILE_TYPE_CHAR    = 0x0002
  1182  	FILE_TYPE_DISK    = 0x0001
  1183  	FILE_TYPE_PIPE    = 0x0003
  1184  	FILE_TYPE_REMOTE  = 0x8000
  1185  	FILE_TYPE_UNKNOWN = 0x0000
  1186  )
  1187  
  1188  type Hostent struct {
  1189  	Name     *byte
  1190  	Aliases  **byte
  1191  	AddrType uint16
  1192  	Length   uint16
  1193  	AddrList **byte
  1194  }
  1195  
  1196  type Protoent struct {
  1197  	Name    *byte
  1198  	Aliases **byte
  1199  	Proto   uint16
  1200  }
  1201  
  1202  const (
  1203  	DNS_TYPE_A       = 0x0001
  1204  	DNS_TYPE_NS      = 0x0002
  1205  	DNS_TYPE_MD      = 0x0003
  1206  	DNS_TYPE_MF      = 0x0004
  1207  	DNS_TYPE_CNAME   = 0x0005
  1208  	DNS_TYPE_SOA     = 0x0006
  1209  	DNS_TYPE_MB      = 0x0007
  1210  	DNS_TYPE_MG      = 0x0008
  1211  	DNS_TYPE_MR      = 0x0009
  1212  	DNS_TYPE_NULL    = 0x000a
  1213  	DNS_TYPE_WKS     = 0x000b
  1214  	DNS_TYPE_PTR     = 0x000c
  1215  	DNS_TYPE_HINFO   = 0x000d
  1216  	DNS_TYPE_MINFO   = 0x000e
  1217  	DNS_TYPE_MX      = 0x000f
  1218  	DNS_TYPE_TEXT    = 0x0010
  1219  	DNS_TYPE_RP      = 0x0011
  1220  	DNS_TYPE_AFSDB   = 0x0012
  1221  	DNS_TYPE_X25     = 0x0013
  1222  	DNS_TYPE_ISDN    = 0x0014
  1223  	DNS_TYPE_RT      = 0x0015
  1224  	DNS_TYPE_NSAP    = 0x0016
  1225  	DNS_TYPE_NSAPPTR = 0x0017
  1226  	DNS_TYPE_SIG     = 0x0018
  1227  	DNS_TYPE_KEY     = 0x0019
  1228  	DNS_TYPE_PX      = 0x001a
  1229  	DNS_TYPE_GPOS    = 0x001b
  1230  	DNS_TYPE_AAAA    = 0x001c
  1231  	DNS_TYPE_LOC     = 0x001d
  1232  	DNS_TYPE_NXT     = 0x001e
  1233  	DNS_TYPE_EID     = 0x001f
  1234  	DNS_TYPE_NIMLOC  = 0x0020
  1235  	DNS_TYPE_SRV     = 0x0021
  1236  	DNS_TYPE_ATMA    = 0x0022
  1237  	DNS_TYPE_NAPTR   = 0x0023
  1238  	DNS_TYPE_KX      = 0x0024
  1239  	DNS_TYPE_CERT    = 0x0025
  1240  	DNS_TYPE_A6      = 0x0026
  1241  	DNS_TYPE_DNAME   = 0x0027
  1242  	DNS_TYPE_SINK    = 0x0028
  1243  	DNS_TYPE_OPT     = 0x0029
  1244  	DNS_TYPE_DS      = 0x002B
  1245  	DNS_TYPE_RRSIG   = 0x002E
  1246  	DNS_TYPE_NSEC    = 0x002F
  1247  	DNS_TYPE_DNSKEY  = 0x0030
  1248  	DNS_TYPE_DHCID   = 0x0031
  1249  	DNS_TYPE_UINFO   = 0x0064
  1250  	DNS_TYPE_UID     = 0x0065
  1251  	DNS_TYPE_GID     = 0x0066
  1252  	DNS_TYPE_UNSPEC  = 0x0067
  1253  	DNS_TYPE_ADDRS   = 0x00f8
  1254  	DNS_TYPE_TKEY    = 0x00f9
  1255  	DNS_TYPE_TSIG    = 0x00fa
  1256  	DNS_TYPE_IXFR    = 0x00fb
  1257  	DNS_TYPE_AXFR    = 0x00fc
  1258  	DNS_TYPE_MAILB   = 0x00fd
  1259  	DNS_TYPE_MAILA   = 0x00fe
  1260  	DNS_TYPE_ALL     = 0x00ff
  1261  	DNS_TYPE_ANY     = 0x00ff
  1262  	DNS_TYPE_WINS    = 0xff01
  1263  	DNS_TYPE_WINSR   = 0xff02
  1264  	DNS_TYPE_NBSTAT  = 0xff01
  1265  )
  1266  
  1267  const (
  1268  	// flags inside DNSRecord.Dw
  1269  	DnsSectionQuestion   = 0x0000
  1270  	DnsSectionAnswer     = 0x0001
  1271  	DnsSectionAuthority  = 0x0002
  1272  	DnsSectionAdditional = 0x0003
  1273  )
  1274  
  1275  const (
  1276  	// flags of WSALookupService
  1277  	LUP_DEEP                = 0x0001
  1278  	LUP_CONTAINERS          = 0x0002
  1279  	LUP_NOCONTAINERS        = 0x0004
  1280  	LUP_NEAREST             = 0x0008
  1281  	LUP_RETURN_NAME         = 0x0010
  1282  	LUP_RETURN_TYPE         = 0x0020
  1283  	LUP_RETURN_VERSION      = 0x0040
  1284  	LUP_RETURN_COMMENT      = 0x0080
  1285  	LUP_RETURN_ADDR         = 0x0100
  1286  	LUP_RETURN_BLOB         = 0x0200
  1287  	LUP_RETURN_ALIASES      = 0x0400
  1288  	LUP_RETURN_QUERY_STRING = 0x0800
  1289  	LUP_RETURN_ALL          = 0x0FF0
  1290  	LUP_RES_SERVICE         = 0x8000
  1291  
  1292  	LUP_FLUSHCACHE    = 0x1000
  1293  	LUP_FLUSHPREVIOUS = 0x2000
  1294  
  1295  	LUP_NON_AUTHORITATIVE      = 0x4000
  1296  	LUP_SECURE                 = 0x8000
  1297  	LUP_RETURN_PREFERRED_NAMES = 0x10000
  1298  	LUP_DNS_ONLY               = 0x20000
  1299  
  1300  	LUP_ADDRCONFIG           = 0x100000
  1301  	LUP_DUAL_ADDR            = 0x200000
  1302  	LUP_FILESERVER           = 0x400000
  1303  	LUP_DISABLE_IDN_ENCODING = 0x00800000
  1304  	LUP_API_ANSI             = 0x01000000
  1305  
  1306  	LUP_RESOLUTION_HANDLE = 0x80000000
  1307  )
  1308  
  1309  const (
  1310  	// values of WSAQUERYSET's namespace
  1311  	NS_ALL       = 0
  1312  	NS_DNS       = 12
  1313  	NS_NLA       = 15
  1314  	NS_BTH       = 16
  1315  	NS_EMAIL     = 37
  1316  	NS_PNRPNAME  = 38
  1317  	NS_PNRPCLOUD = 39
  1318  )
  1319  
  1320  type DNSSRVData struct {
  1321  	Target   *uint16
  1322  	Priority uint16
  1323  	Weight   uint16
  1324  	Port     uint16
  1325  	Pad      uint16
  1326  }
  1327  
  1328  type DNSPTRData struct {
  1329  	Host *uint16
  1330  }
  1331  
  1332  type DNSMXData struct {
  1333  	NameExchange *uint16
  1334  	Preference   uint16
  1335  	Pad          uint16
  1336  }
  1337  
  1338  type DNSTXTData struct {
  1339  	StringCount uint16
  1340  	StringArray [1]*uint16
  1341  }
  1342  
  1343  type DNSRecord struct {
  1344  	Next     *DNSRecord
  1345  	Name     *uint16
  1346  	Type     uint16
  1347  	Length   uint16
  1348  	Dw       uint32
  1349  	Ttl      uint32
  1350  	Reserved uint32
  1351  	Data     [40]byte
  1352  }
  1353  
  1354  const (
  1355  	TF_DISCONNECT         = 1
  1356  	TF_REUSE_SOCKET       = 2
  1357  	TF_WRITE_BEHIND       = 4
  1358  	TF_USE_DEFAULT_WORKER = 0
  1359  	TF_USE_SYSTEM_THREAD  = 16
  1360  	TF_USE_KERNEL_APC     = 32
  1361  )
  1362  
  1363  type TransmitFileBuffers struct {
  1364  	Head       uintptr
  1365  	HeadLength uint32
  1366  	Tail       uintptr
  1367  	TailLength uint32
  1368  }
  1369  
  1370  const (
  1371  	IFF_UP           = 1
  1372  	IFF_BROADCAST    = 2
  1373  	IFF_LOOPBACK     = 4
  1374  	IFF_POINTTOPOINT = 8
  1375  	IFF_MULTICAST    = 16
  1376  )
  1377  
  1378  const SIO_GET_INTERFACE_LIST = 0x4004747F
  1379  
  1380  // TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old.
  1381  // will be fixed to change variable type as suitable.
  1382  
  1383  type SockaddrGen [24]byte
  1384  
  1385  type InterfaceInfo struct {
  1386  	Flags            uint32
  1387  	Address          SockaddrGen
  1388  	BroadcastAddress SockaddrGen
  1389  	Netmask          SockaddrGen
  1390  }
  1391  
  1392  type IpAddressString struct {
  1393  	String [16]byte
  1394  }
  1395  
  1396  type IpMaskString IpAddressString
  1397  
  1398  type IpAddrString struct {
  1399  	Next      *IpAddrString
  1400  	IpAddress IpAddressString
  1401  	IpMask    IpMaskString
  1402  	Context   uint32
  1403  }
  1404  
  1405  const MAX_ADAPTER_NAME_LENGTH = 256
  1406  const MAX_ADAPTER_DESCRIPTION_LENGTH = 128
  1407  const MAX_ADAPTER_ADDRESS_LENGTH = 8
  1408  
  1409  type IpAdapterInfo struct {
  1410  	Next                *IpAdapterInfo
  1411  	ComboIndex          uint32
  1412  	AdapterName         [MAX_ADAPTER_NAME_LENGTH + 4]byte
  1413  	Description         [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte
  1414  	AddressLength       uint32
  1415  	Address             [MAX_ADAPTER_ADDRESS_LENGTH]byte
  1416  	Index               uint32
  1417  	Type                uint32
  1418  	DhcpEnabled         uint32
  1419  	CurrentIpAddress    *IpAddrString
  1420  	IpAddressList       IpAddrString
  1421  	GatewayList         IpAddrString
  1422  	DhcpServer          IpAddrString
  1423  	HaveWins            bool
  1424  	PrimaryWinsServer   IpAddrString
  1425  	SecondaryWinsServer IpAddrString
  1426  	LeaseObtained       int64
  1427  	LeaseExpires        int64
  1428  }
  1429  
  1430  const MAXLEN_PHYSADDR = 8
  1431  const MAX_INTERFACE_NAME_LEN = 256
  1432  const MAXLEN_IFDESCR = 256
  1433  
  1434  type MibIfRow struct {
  1435  	Name            [MAX_INTERFACE_NAME_LEN]uint16
  1436  	Index           uint32
  1437  	Type            uint32
  1438  	Mtu             uint32
  1439  	Speed           uint32
  1440  	PhysAddrLen     uint32
  1441  	PhysAddr        [MAXLEN_PHYSADDR]byte
  1442  	AdminStatus     uint32
  1443  	OperStatus      uint32
  1444  	LastChange      uint32
  1445  	InOctets        uint32
  1446  	InUcastPkts     uint32
  1447  	InNUcastPkts    uint32
  1448  	InDiscards      uint32
  1449  	InErrors        uint32
  1450  	InUnknownProtos uint32
  1451  	OutOctets       uint32
  1452  	OutUcastPkts    uint32
  1453  	OutNUcastPkts   uint32
  1454  	OutDiscards     uint32
  1455  	OutErrors       uint32
  1456  	OutQLen         uint32
  1457  	DescrLen        uint32
  1458  	Descr           [MAXLEN_IFDESCR]byte
  1459  }
  1460  
  1461  type CertInfo struct {
  1462  	Version              uint32
  1463  	SerialNumber         CryptIntegerBlob
  1464  	SignatureAlgorithm   CryptAlgorithmIdentifier
  1465  	Issuer               CertNameBlob
  1466  	NotBefore            Filetime
  1467  	NotAfter             Filetime
  1468  	Subject              CertNameBlob
  1469  	SubjectPublicKeyInfo CertPublicKeyInfo
  1470  	IssuerUniqueId       CryptBitBlob
  1471  	SubjectUniqueId      CryptBitBlob
  1472  	CountExtensions      uint32
  1473  	Extensions           *CertExtension
  1474  }
  1475  
  1476  type CertExtension struct {
  1477  	ObjId    *byte
  1478  	Critical int32
  1479  	Value    CryptObjidBlob
  1480  }
  1481  
  1482  type CryptAlgorithmIdentifier struct {
  1483  	ObjId      *byte
  1484  	Parameters CryptObjidBlob
  1485  }
  1486  
  1487  type CertPublicKeyInfo struct {
  1488  	Algorithm CryptAlgorithmIdentifier
  1489  	PublicKey CryptBitBlob
  1490  }
  1491  
  1492  type DataBlob struct {
  1493  	Size uint32
  1494  	Data *byte
  1495  }
  1496  type CryptIntegerBlob DataBlob
  1497  type CryptUintBlob DataBlob
  1498  type CryptObjidBlob DataBlob
  1499  type CertNameBlob DataBlob
  1500  type CertRdnValueBlob DataBlob
  1501  type CertBlob DataBlob
  1502  type CrlBlob DataBlob
  1503  type CryptDataBlob DataBlob
  1504  type CryptHashBlob DataBlob
  1505  type CryptDigestBlob DataBlob
  1506  type CryptDerBlob DataBlob
  1507  type CryptAttrBlob DataBlob
  1508  
  1509  type CryptBitBlob struct {
  1510  	Size       uint32
  1511  	Data       *byte
  1512  	UnusedBits uint32
  1513  }
  1514  
  1515  type CertContext struct {
  1516  	EncodingType uint32
  1517  	EncodedCert  *byte
  1518  	Length       uint32
  1519  	CertInfo     *CertInfo
  1520  	Store        Handle
  1521  }
  1522  
  1523  type CertChainContext struct {
  1524  	Size                       uint32
  1525  	TrustStatus                CertTrustStatus
  1526  	ChainCount                 uint32
  1527  	Chains                     **CertSimpleChain
  1528  	LowerQualityChainCount     uint32
  1529  	LowerQualityChains         **CertChainContext
  1530  	HasRevocationFreshnessTime uint32
  1531  	RevocationFreshnessTime    uint32
  1532  }
  1533  
  1534  type CertTrustListInfo struct {
  1535  	// Not implemented
  1536  }
  1537  
  1538  type CertSimpleChain struct {
  1539  	Size                       uint32
  1540  	TrustStatus                CertTrustStatus
  1541  	NumElements                uint32
  1542  	Elements                   **CertChainElement
  1543  	TrustListInfo              *CertTrustListInfo
  1544  	HasRevocationFreshnessTime uint32
  1545  	RevocationFreshnessTime    uint32
  1546  }
  1547  
  1548  type CertChainElement struct {
  1549  	Size              uint32
  1550  	CertContext       *CertContext
  1551  	TrustStatus       CertTrustStatus
  1552  	RevocationInfo    *CertRevocationInfo
  1553  	IssuanceUsage     *CertEnhKeyUsage
  1554  	ApplicationUsage  *CertEnhKeyUsage
  1555  	ExtendedErrorInfo *uint16
  1556  }
  1557  
  1558  type CertRevocationCrlInfo struct {
  1559  	// Not implemented
  1560  }
  1561  
  1562  type CertRevocationInfo struct {
  1563  	Size             uint32
  1564  	RevocationResult uint32
  1565  	RevocationOid    *byte
  1566  	OidSpecificInfo  Pointer
  1567  	HasFreshnessTime uint32
  1568  	FreshnessTime    uint32
  1569  	CrlInfo          *CertRevocationCrlInfo
  1570  }
  1571  
  1572  type CertTrustStatus struct {
  1573  	ErrorStatus uint32
  1574  	InfoStatus  uint32
  1575  }
  1576  
  1577  type CertUsageMatch struct {
  1578  	Type  uint32
  1579  	Usage CertEnhKeyUsage
  1580  }
  1581  
  1582  type CertEnhKeyUsage struct {
  1583  	Length           uint32
  1584  	UsageIdentifiers **byte
  1585  }
  1586  
  1587  type CertChainPara struct {
  1588  	Size                         uint32
  1589  	RequestedUsage               CertUsageMatch
  1590  	RequstedIssuancePolicy       CertUsageMatch
  1591  	URLRetrievalTimeout          uint32
  1592  	CheckRevocationFreshnessTime uint32
  1593  	RevocationFreshnessTime      uint32
  1594  	CacheResync                  *Filetime
  1595  }
  1596  
  1597  type CertChainPolicyPara struct {
  1598  	Size            uint32
  1599  	Flags           uint32
  1600  	ExtraPolicyPara Pointer
  1601  }
  1602  
  1603  type SSLExtraCertChainPolicyPara struct {
  1604  	Size       uint32
  1605  	AuthType   uint32
  1606  	Checks     uint32
  1607  	ServerName *uint16
  1608  }
  1609  
  1610  type CertChainPolicyStatus struct {
  1611  	Size              uint32
  1612  	Error             uint32
  1613  	ChainIndex        uint32
  1614  	ElementIndex      uint32
  1615  	ExtraPolicyStatus Pointer
  1616  }
  1617  
  1618  type CertPolicyInfo struct {
  1619  	Identifier      *byte
  1620  	CountQualifiers uint32
  1621  	Qualifiers      *CertPolicyQualifierInfo
  1622  }
  1623  
  1624  type CertPoliciesInfo struct {
  1625  	Count       uint32
  1626  	PolicyInfos *CertPolicyInfo
  1627  }
  1628  
  1629  type CertPolicyQualifierInfo struct {
  1630  	// Not implemented
  1631  }
  1632  
  1633  type CertStrongSignPara struct {
  1634  	Size                      uint32
  1635  	InfoChoice                uint32
  1636  	InfoOrSerializedInfoOrOID unsafe.Pointer
  1637  }
  1638  
  1639  type CryptProtectPromptStruct struct {
  1640  	Size        uint32
  1641  	PromptFlags uint32
  1642  	App         HWND
  1643  	Prompt      *uint16
  1644  }
  1645  
  1646  type CertChainFindByIssuerPara struct {
  1647  	Size                   uint32
  1648  	UsageIdentifier        *byte
  1649  	KeySpec                uint32
  1650  	AcquirePrivateKeyFlags uint32
  1651  	IssuerCount            uint32
  1652  	Issuer                 Pointer
  1653  	FindCallback           Pointer
  1654  	FindArg                Pointer
  1655  	IssuerChainIndex       *uint32
  1656  	IssuerElementIndex     *uint32
  1657  }
  1658  
  1659  type WinTrustData struct {
  1660  	Size                            uint32
  1661  	PolicyCallbackData              uintptr
  1662  	SIPClientData                   uintptr
  1663  	UIChoice                        uint32
  1664  	RevocationChecks                uint32
  1665  	UnionChoice                     uint32
  1666  	FileOrCatalogOrBlobOrSgnrOrCert unsafe.Pointer
  1667  	StateAction                     uint32
  1668  	StateData                       Handle
  1669  	URLReference                    *uint16
  1670  	ProvFlags                       uint32
  1671  	UIContext                       uint32
  1672  	SignatureSettings               *WinTrustSignatureSettings
  1673  }
  1674  
  1675  type WinTrustFileInfo struct {
  1676  	Size         uint32
  1677  	FilePath     *uint16
  1678  	File         Handle
  1679  	KnownSubject *GUID
  1680  }
  1681  
  1682  type WinTrustSignatureSettings struct {
  1683  	Size             uint32
  1684  	Index            uint32
  1685  	Flags            uint32
  1686  	SecondarySigs    uint32
  1687  	VerifiedSigIndex uint32
  1688  	CryptoPolicy     *CertStrongSignPara
  1689  }
  1690  
  1691  const (
  1692  	// do not reorder
  1693  	HKEY_CLASSES_ROOT = 0x80000000 + iota
  1694  	HKEY_CURRENT_USER
  1695  	HKEY_LOCAL_MACHINE
  1696  	HKEY_USERS
  1697  	HKEY_PERFORMANCE_DATA
  1698  	HKEY_CURRENT_CONFIG
  1699  	HKEY_DYN_DATA
  1700  
  1701  	KEY_QUERY_VALUE        = 1
  1702  	KEY_SET_VALUE          = 2
  1703  	KEY_CREATE_SUB_KEY     = 4
  1704  	KEY_ENUMERATE_SUB_KEYS = 8
  1705  	KEY_NOTIFY             = 16
  1706  	KEY_CREATE_LINK        = 32
  1707  	KEY_WRITE              = 0x20006
  1708  	KEY_EXECUTE            = 0x20019
  1709  	KEY_READ               = 0x20019
  1710  	KEY_WOW64_64KEY        = 0x0100
  1711  	KEY_WOW64_32KEY        = 0x0200
  1712  	KEY_ALL_ACCESS         = 0xf003f
  1713  )
  1714  
  1715  const (
  1716  	// do not reorder
  1717  	REG_NONE = iota
  1718  	REG_SZ
  1719  	REG_EXPAND_SZ
  1720  	REG_BINARY
  1721  	REG_DWORD_LITTLE_ENDIAN
  1722  	REG_DWORD_BIG_ENDIAN
  1723  	REG_LINK
  1724  	REG_MULTI_SZ
  1725  	REG_RESOURCE_LIST
  1726  	REG_FULL_RESOURCE_DESCRIPTOR
  1727  	REG_RESOURCE_REQUIREMENTS_LIST
  1728  	REG_QWORD_LITTLE_ENDIAN
  1729  	REG_DWORD = REG_DWORD_LITTLE_ENDIAN
  1730  	REG_QWORD = REG_QWORD_LITTLE_ENDIAN
  1731  )
  1732  
  1733  const (
  1734  	EVENT_MODIFY_STATE = 0x0002
  1735  	EVENT_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1736  
  1737  	MUTANT_QUERY_STATE = 0x0001
  1738  	MUTANT_ALL_ACCESS  = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE
  1739  
  1740  	SEMAPHORE_MODIFY_STATE = 0x0002
  1741  	SEMAPHORE_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1742  
  1743  	TIMER_QUERY_STATE  = 0x0001
  1744  	TIMER_MODIFY_STATE = 0x0002
  1745  	TIMER_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE | TIMER_MODIFY_STATE
  1746  
  1747  	MUTEX_MODIFY_STATE = MUTANT_QUERY_STATE
  1748  	MUTEX_ALL_ACCESS   = MUTANT_ALL_ACCESS
  1749  
  1750  	CREATE_EVENT_MANUAL_RESET  = 0x1
  1751  	CREATE_EVENT_INITIAL_SET   = 0x2
  1752  	CREATE_MUTEX_INITIAL_OWNER = 0x1
  1753  )
  1754  
  1755  type AddrinfoW struct {
  1756  	Flags     int32
  1757  	Family    int32
  1758  	Socktype  int32
  1759  	Protocol  int32
  1760  	Addrlen   uintptr
  1761  	Canonname *uint16
  1762  	Addr      uintptr
  1763  	Next      *AddrinfoW
  1764  }
  1765  
  1766  const (
  1767  	AI_PASSIVE     = 1
  1768  	AI_CANONNAME   = 2
  1769  	AI_NUMERICHOST = 4
  1770  )
  1771  
  1772  type GUID struct {
  1773  	Data1 uint32
  1774  	Data2 uint16
  1775  	Data3 uint16
  1776  	Data4 [8]byte
  1777  }
  1778  
  1779  var WSAID_CONNECTEX = GUID{
  1780  	0x25a207b9,
  1781  	0xddf3,
  1782  	0x4660,
  1783  	[8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e},
  1784  }
  1785  
  1786  var WSAID_WSASENDMSG = GUID{
  1787  	0xa441e712,
  1788  	0x754f,
  1789  	0x43ca,
  1790  	[8]byte{0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d},
  1791  }
  1792  
  1793  var WSAID_WSARECVMSG = GUID{
  1794  	0xf689d7c8,
  1795  	0x6f1f,
  1796  	0x436b,
  1797  	[8]byte{0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22},
  1798  }
  1799  
  1800  const (
  1801  	FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
  1802  	FILE_SKIP_SET_EVENT_ON_HANDLE        = 2
  1803  )
  1804  
  1805  const (
  1806  	WSAPROTOCOL_LEN    = 255
  1807  	MAX_PROTOCOL_CHAIN = 7
  1808  	BASE_PROTOCOL      = 1
  1809  	LAYERED_PROTOCOL   = 0
  1810  
  1811  	XP1_CONNECTIONLESS           = 0x00000001
  1812  	XP1_GUARANTEED_DELIVERY      = 0x00000002
  1813  	XP1_GUARANTEED_ORDER         = 0x00000004
  1814  	XP1_MESSAGE_ORIENTED         = 0x00000008
  1815  	XP1_PSEUDO_STREAM            = 0x00000010
  1816  	XP1_GRACEFUL_CLOSE           = 0x00000020
  1817  	XP1_EXPEDITED_DATA           = 0x00000040
  1818  	XP1_CONNECT_DATA             = 0x00000080
  1819  	XP1_DISCONNECT_DATA          = 0x00000100
  1820  	XP1_SUPPORT_BROADCAST        = 0x00000200
  1821  	XP1_SUPPORT_MULTIPOINT       = 0x00000400
  1822  	XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800
  1823  	XP1_MULTIPOINT_DATA_PLANE    = 0x00001000
  1824  	XP1_QOS_SUPPORTED            = 0x00002000
  1825  	XP1_UNI_SEND                 = 0x00008000
  1826  	XP1_UNI_RECV                 = 0x00010000
  1827  	XP1_IFS_HANDLES              = 0x00020000
  1828  	XP1_PARTIAL_MESSAGE          = 0x00040000
  1829  	XP1_SAN_SUPPORT_SDP          = 0x00080000
  1830  
  1831  	PFL_MULTIPLE_PROTO_ENTRIES  = 0x00000001
  1832  	PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002
  1833  	PFL_HIDDEN                  = 0x00000004
  1834  	PFL_MATCHES_PROTOCOL_ZERO   = 0x00000008
  1835  	PFL_NETWORKDIRECT_PROVIDER  = 0x00000010
  1836  )
  1837  
  1838  type WSAProtocolInfo struct {
  1839  	ServiceFlags1     uint32
  1840  	ServiceFlags2     uint32
  1841  	ServiceFlags3     uint32
  1842  	ServiceFlags4     uint32
  1843  	ProviderFlags     uint32
  1844  	ProviderId        GUID
  1845  	CatalogEntryId    uint32
  1846  	ProtocolChain     WSAProtocolChain
  1847  	Version           int32
  1848  	AddressFamily     int32
  1849  	MaxSockAddr       int32
  1850  	MinSockAddr       int32
  1851  	SocketType        int32
  1852  	Protocol          int32
  1853  	ProtocolMaxOffset int32
  1854  	NetworkByteOrder  int32
  1855  	SecurityScheme    int32
  1856  	MessageSize       uint32
  1857  	ProviderReserved  uint32
  1858  	ProtocolName      [WSAPROTOCOL_LEN + 1]uint16
  1859  }
  1860  
  1861  type WSAProtocolChain struct {
  1862  	ChainLen     int32
  1863  	ChainEntries [MAX_PROTOCOL_CHAIN]uint32
  1864  }
  1865  
  1866  type TCPKeepalive struct {
  1867  	OnOff    uint32
  1868  	Time     uint32
  1869  	Interval uint32
  1870  }
  1871  
  1872  type symbolicLinkReparseBuffer struct {
  1873  	SubstituteNameOffset uint16
  1874  	SubstituteNameLength uint16
  1875  	PrintNameOffset      uint16
  1876  	PrintNameLength      uint16
  1877  	Flags                uint32
  1878  	PathBuffer           [1]uint16
  1879  }
  1880  
  1881  type mountPointReparseBuffer struct {
  1882  	SubstituteNameOffset uint16
  1883  	SubstituteNameLength uint16
  1884  	PrintNameOffset      uint16
  1885  	PrintNameLength      uint16
  1886  	PathBuffer           [1]uint16
  1887  }
  1888  
  1889  type reparseDataBuffer struct {
  1890  	ReparseTag        uint32
  1891  	ReparseDataLength uint16
  1892  	Reserved          uint16
  1893  
  1894  	// GenericReparseBuffer
  1895  	reparseBuffer byte
  1896  }
  1897  
  1898  const (
  1899  	FSCTL_CREATE_OR_GET_OBJECT_ID             = 0x0900C0
  1900  	FSCTL_DELETE_OBJECT_ID                    = 0x0900A0
  1901  	FSCTL_DELETE_REPARSE_POINT                = 0x0900AC
  1902  	FSCTL_DUPLICATE_EXTENTS_TO_FILE           = 0x098344
  1903  	FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX        = 0x0983E8
  1904  	FSCTL_FILESYSTEM_GET_STATISTICS           = 0x090060
  1905  	FSCTL_FILE_LEVEL_TRIM                     = 0x098208
  1906  	FSCTL_FIND_FILES_BY_SID                   = 0x09008F
  1907  	FSCTL_GET_COMPRESSION                     = 0x09003C
  1908  	FSCTL_GET_INTEGRITY_INFORMATION           = 0x09027C
  1909  	FSCTL_GET_NTFS_VOLUME_DATA                = 0x090064
  1910  	FSCTL_GET_REFS_VOLUME_DATA                = 0x0902D8
  1911  	FSCTL_GET_OBJECT_ID                       = 0x09009C
  1912  	FSCTL_GET_REPARSE_POINT                   = 0x0900A8
  1913  	FSCTL_GET_RETRIEVAL_POINTER_COUNT         = 0x09042B
  1914  	FSCTL_GET_RETRIEVAL_POINTERS              = 0x090073
  1915  	FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT = 0x0903D3
  1916  	FSCTL_IS_PATHNAME_VALID                   = 0x09002C
  1917  	FSCTL_LMR_SET_LINK_TRACKING_INFORMATION   = 0x1400EC
  1918  	FSCTL_MARK_HANDLE                         = 0x0900FC
  1919  	FSCTL_OFFLOAD_READ                        = 0x094264
  1920  	FSCTL_OFFLOAD_WRITE                       = 0x098268
  1921  	FSCTL_PIPE_PEEK                           = 0x11400C
  1922  	FSCTL_PIPE_TRANSCEIVE                     = 0x11C017
  1923  	FSCTL_PIPE_WAIT                           = 0x110018
  1924  	FSCTL_QUERY_ALLOCATED_RANGES              = 0x0940CF
  1925  	FSCTL_QUERY_FAT_BPB                       = 0x090058
  1926  	FSCTL_QUERY_FILE_REGIONS                  = 0x090284
  1927  	FSCTL_QUERY_ON_DISK_VOLUME_INFO           = 0x09013C
  1928  	FSCTL_QUERY_SPARING_INFO                  = 0x090138
  1929  	FSCTL_READ_FILE_USN_DATA                  = 0x0900EB
  1930  	FSCTL_RECALL_FILE                         = 0x090117
  1931  	FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT     = 0x090440
  1932  	FSCTL_SET_COMPRESSION                     = 0x09C040
  1933  	FSCTL_SET_DEFECT_MANAGEMENT               = 0x098134
  1934  	FSCTL_SET_ENCRYPTION                      = 0x0900D7
  1935  	FSCTL_SET_INTEGRITY_INFORMATION           = 0x09C280
  1936  	FSCTL_SET_INTEGRITY_INFORMATION_EX        = 0x090380
  1937  	FSCTL_SET_OBJECT_ID                       = 0x090098
  1938  	FSCTL_SET_OBJECT_ID_EXTENDED              = 0x0900BC
  1939  	FSCTL_SET_REPARSE_POINT                   = 0x0900A4
  1940  	FSCTL_SET_SPARSE                          = 0x0900C4
  1941  	FSCTL_SET_ZERO_DATA                       = 0x0980C8
  1942  	FSCTL_SET_ZERO_ON_DEALLOCATION            = 0x090194
  1943  	FSCTL_SIS_COPYFILE                        = 0x090100
  1944  	FSCTL_WRITE_USN_CLOSE_RECORD              = 0x0900EF
  1945  
  1946  	MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
  1947  	IO_REPARSE_TAG_MOUNT_POINT       = 0xA0000003
  1948  	IO_REPARSE_TAG_SYMLINK           = 0xA000000C
  1949  	SYMBOLIC_LINK_FLAG_DIRECTORY     = 0x1
  1950  )
  1951  
  1952  const (
  1953  	ComputerNameNetBIOS                   = 0
  1954  	ComputerNameDnsHostname               = 1
  1955  	ComputerNameDnsDomain                 = 2
  1956  	ComputerNameDnsFullyQualified         = 3
  1957  	ComputerNamePhysicalNetBIOS           = 4
  1958  	ComputerNamePhysicalDnsHostname       = 5
  1959  	ComputerNamePhysicalDnsDomain         = 6
  1960  	ComputerNamePhysicalDnsFullyQualified = 7
  1961  	ComputerNameMax                       = 8
  1962  )
  1963  
  1964  // For MessageBox()
  1965  const (
  1966  	MB_OK                   = 0x00000000
  1967  	MB_OKCANCEL             = 0x00000001
  1968  	MB_ABORTRETRYIGNORE     = 0x00000002
  1969  	MB_YESNOCANCEL          = 0x00000003
  1970  	MB_YESNO                = 0x00000004
  1971  	MB_RETRYCANCEL          = 0x00000005
  1972  	MB_CANCELTRYCONTINUE    = 0x00000006
  1973  	MB_ICONHAND             = 0x00000010
  1974  	MB_ICONQUESTION         = 0x00000020
  1975  	MB_ICONEXCLAMATION      = 0x00000030
  1976  	MB_ICONASTERISK         = 0x00000040
  1977  	MB_USERICON             = 0x00000080
  1978  	MB_ICONWARNING          = MB_ICONEXCLAMATION
  1979  	MB_ICONERROR            = MB_ICONHAND
  1980  	MB_ICONINFORMATION      = MB_ICONASTERISK
  1981  	MB_ICONSTOP             = MB_ICONHAND
  1982  	MB_DEFBUTTON1           = 0x00000000
  1983  	MB_DEFBUTTON2           = 0x00000100
  1984  	MB_DEFBUTTON3           = 0x00000200
  1985  	MB_DEFBUTTON4           = 0x00000300
  1986  	MB_APPLMODAL            = 0x00000000
  1987  	MB_SYSTEMMODAL          = 0x00001000
  1988  	MB_TASKMODAL            = 0x00002000
  1989  	MB_HELP                 = 0x00004000
  1990  	MB_NOFOCUS              = 0x00008000
  1991  	MB_SETFOREGROUND        = 0x00010000
  1992  	MB_DEFAULT_DESKTOP_ONLY = 0x00020000
  1993  	MB_TOPMOST              = 0x00040000
  1994  	MB_RIGHT                = 0x00080000
  1995  	MB_RTLREADING           = 0x00100000
  1996  	MB_SERVICE_NOTIFICATION = 0x00200000
  1997  )
  1998  
  1999  const (
  2000  	MOVEFILE_REPLACE_EXISTING      = 0x1
  2001  	MOVEFILE_COPY_ALLOWED          = 0x2
  2002  	MOVEFILE_DELAY_UNTIL_REBOOT    = 0x4
  2003  	MOVEFILE_WRITE_THROUGH         = 0x8
  2004  	MOVEFILE_CREATE_HARDLINK       = 0x10
  2005  	MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20
  2006  )
  2007  
  2008  // Flags for GetAdaptersAddresses, see
  2009  // https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses.
  2010  const (
  2011  	GAA_FLAG_SKIP_UNICAST                = 0x1
  2012  	GAA_FLAG_SKIP_ANYCAST                = 0x2
  2013  	GAA_FLAG_SKIP_MULTICAST              = 0x4
  2014  	GAA_FLAG_SKIP_DNS_SERVER             = 0x8
  2015  	GAA_FLAG_INCLUDE_PREFIX              = 0x10
  2016  	GAA_FLAG_SKIP_FRIENDLY_NAME          = 0x20
  2017  	GAA_FLAG_INCLUDE_WINS_INFO           = 0x40
  2018  	GAA_FLAG_INCLUDE_GATEWAYS            = 0x80
  2019  	GAA_FLAG_INCLUDE_ALL_INTERFACES      = 0x100
  2020  	GAA_FLAG_INCLUDE_ALL_COMPARTMENTS    = 0x200
  2021  	GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400
  2022  )
  2023  
  2024  const (
  2025  	IF_TYPE_OTHER              = 1
  2026  	IF_TYPE_ETHERNET_CSMACD    = 6
  2027  	IF_TYPE_ISO88025_TOKENRING = 9
  2028  	IF_TYPE_PPP                = 23
  2029  	IF_TYPE_SOFTWARE_LOOPBACK  = 24
  2030  	IF_TYPE_ATM                = 37
  2031  	IF_TYPE_IEEE80211          = 71
  2032  	IF_TYPE_TUNNEL             = 131
  2033  	IF_TYPE_IEEE1394           = 144
  2034  )
  2035  
  2036  // Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see
  2037  // https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin
  2038  const (
  2039  	IpPrefixOriginOther               = 0
  2040  	IpPrefixOriginManual              = 1
  2041  	IpPrefixOriginWellKnown           = 2
  2042  	IpPrefixOriginDhcp                = 3
  2043  	IpPrefixOriginRouterAdvertisement = 4
  2044  	IpPrefixOriginUnchanged           = 1 << 4
  2045  )
  2046  
  2047  // Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see
  2048  // https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin
  2049  const (
  2050  	NlsoOther                      = 0
  2051  	NlsoManual                     = 1
  2052  	NlsoWellKnown                  = 2
  2053  	NlsoDhcp                       = 3
  2054  	NlsoLinkLayerAddress           = 4
  2055  	NlsoRandom                     = 5
  2056  	IpSuffixOriginOther            = 0
  2057  	IpSuffixOriginManual           = 1
  2058  	IpSuffixOriginWellKnown        = 2
  2059  	IpSuffixOriginDhcp             = 3
  2060  	IpSuffixOriginLinkLayerAddress = 4
  2061  	IpSuffixOriginRandom           = 5
  2062  	IpSuffixOriginUnchanged        = 1 << 4
  2063  )
  2064  
  2065  // Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see
  2066  // https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state
  2067  const (
  2068  	NldsInvalid          = 0
  2069  	NldsTentative        = 1
  2070  	NldsDuplicate        = 2
  2071  	NldsDeprecated       = 3
  2072  	NldsPreferred        = 4
  2073  	IpDadStateInvalid    = 0
  2074  	IpDadStateTentative  = 1
  2075  	IpDadStateDuplicate  = 2
  2076  	IpDadStateDeprecated = 3
  2077  	IpDadStatePreferred  = 4
  2078  )
  2079  
  2080  type SocketAddress struct {
  2081  	Sockaddr       *syscall.RawSockaddrAny
  2082  	SockaddrLength int32
  2083  }
  2084  
  2085  // IP returns an IPv4 or IPv6 address, or nil if the underlying SocketAddress is neither.
  2086  func (addr *SocketAddress) IP() net.IP {
  2087  	if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet4{}) && addr.Sockaddr.Addr.Family == AF_INET {
  2088  		return (*RawSockaddrInet4)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  2089  	} else if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet6{}) && addr.Sockaddr.Addr.Family == AF_INET6 {
  2090  		return (*RawSockaddrInet6)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  2091  	}
  2092  	return nil
  2093  }
  2094  
  2095  type IpAdapterUnicastAddress struct {
  2096  	Length             uint32
  2097  	Flags              uint32
  2098  	Next               *IpAdapterUnicastAddress
  2099  	Address            SocketAddress
  2100  	PrefixOrigin       int32
  2101  	SuffixOrigin       int32
  2102  	DadState           int32
  2103  	ValidLifetime      uint32
  2104  	PreferredLifetime  uint32
  2105  	LeaseLifetime      uint32
  2106  	OnLinkPrefixLength uint8
  2107  }
  2108  
  2109  type IpAdapterAnycastAddress struct {
  2110  	Length  uint32
  2111  	Flags   uint32
  2112  	Next    *IpAdapterAnycastAddress
  2113  	Address SocketAddress
  2114  }
  2115  
  2116  type IpAdapterMulticastAddress struct {
  2117  	Length  uint32
  2118  	Flags   uint32
  2119  	Next    *IpAdapterMulticastAddress
  2120  	Address SocketAddress
  2121  }
  2122  
  2123  type IpAdapterDnsServerAdapter struct {
  2124  	Length   uint32
  2125  	Reserved uint32
  2126  	Next     *IpAdapterDnsServerAdapter
  2127  	Address  SocketAddress
  2128  }
  2129  
  2130  type IpAdapterPrefix struct {
  2131  	Length       uint32
  2132  	Flags        uint32
  2133  	Next         *IpAdapterPrefix
  2134  	Address      SocketAddress
  2135  	PrefixLength uint32
  2136  }
  2137  
  2138  type IpAdapterAddresses struct {
  2139  	Length                 uint32
  2140  	IfIndex                uint32
  2141  	Next                   *IpAdapterAddresses
  2142  	AdapterName            *byte
  2143  	FirstUnicastAddress    *IpAdapterUnicastAddress
  2144  	FirstAnycastAddress    *IpAdapterAnycastAddress
  2145  	FirstMulticastAddress  *IpAdapterMulticastAddress
  2146  	FirstDnsServerAddress  *IpAdapterDnsServerAdapter
  2147  	DnsSuffix              *uint16
  2148  	Description            *uint16
  2149  	FriendlyName           *uint16
  2150  	PhysicalAddress        [syscall.MAX_ADAPTER_ADDRESS_LENGTH]byte
  2151  	PhysicalAddressLength  uint32
  2152  	Flags                  uint32
  2153  	Mtu                    uint32
  2154  	IfType                 uint32
  2155  	OperStatus             uint32
  2156  	Ipv6IfIndex            uint32
  2157  	ZoneIndices            [16]uint32
  2158  	FirstPrefix            *IpAdapterPrefix
  2159  	TransmitLinkSpeed      uint64
  2160  	ReceiveLinkSpeed       uint64
  2161  	FirstWinsServerAddress *IpAdapterWinsServerAddress
  2162  	FirstGatewayAddress    *IpAdapterGatewayAddress
  2163  	Ipv4Metric             uint32
  2164  	Ipv6Metric             uint32
  2165  	Luid                   uint64
  2166  	Dhcpv4Server           SocketAddress
  2167  	CompartmentId          uint32
  2168  	NetworkGuid            GUID
  2169  	ConnectionType         uint32
  2170  	TunnelType             uint32
  2171  	Dhcpv6Server           SocketAddress
  2172  	Dhcpv6ClientDuid       [MAX_DHCPV6_DUID_LENGTH]byte
  2173  	Dhcpv6ClientDuidLength uint32
  2174  	Dhcpv6Iaid             uint32
  2175  	FirstDnsSuffix         *IpAdapterDNSSuffix
  2176  }
  2177  
  2178  type IpAdapterWinsServerAddress struct {
  2179  	Length   uint32
  2180  	Reserved uint32
  2181  	Next     *IpAdapterWinsServerAddress
  2182  	Address  SocketAddress
  2183  }
  2184  
  2185  type IpAdapterGatewayAddress struct {
  2186  	Length   uint32
  2187  	Reserved uint32
  2188  	Next     *IpAdapterGatewayAddress
  2189  	Address  SocketAddress
  2190  }
  2191  
  2192  type IpAdapterDNSSuffix struct {
  2193  	Next   *IpAdapterDNSSuffix
  2194  	String [MAX_DNS_SUFFIX_STRING_LENGTH]uint16
  2195  }
  2196  
  2197  const (
  2198  	IfOperStatusUp             = 1
  2199  	IfOperStatusDown           = 2
  2200  	IfOperStatusTesting        = 3
  2201  	IfOperStatusUnknown        = 4
  2202  	IfOperStatusDormant        = 5
  2203  	IfOperStatusNotPresent     = 6
  2204  	IfOperStatusLowerLayerDown = 7
  2205  )
  2206  
  2207  const (
  2208  	IF_MAX_PHYS_ADDRESS_LENGTH = 32
  2209  	IF_MAX_STRING_SIZE         = 256
  2210  )
  2211  
  2212  // MIB_IF_ENTRY_LEVEL enumeration from netioapi.h or
  2213  // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-getifentry2ex.
  2214  const (
  2215  	MibIfEntryNormal                  = 0
  2216  	MibIfEntryNormalWithoutStatistics = 2
  2217  )
  2218  
  2219  // MIB_NOTIFICATION_TYPE enumeration from netioapi.h or
  2220  // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ne-netioapi-mib_notification_type.
  2221  const (
  2222  	MibParameterNotification = 0
  2223  	MibAddInstance           = 1
  2224  	MibDeleteInstance        = 2
  2225  	MibInitialNotification   = 3
  2226  )
  2227  
  2228  // MibIfRow2 stores information about a particular interface. See
  2229  // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_row2.
  2230  type MibIfRow2 struct {
  2231  	InterfaceLuid               uint64
  2232  	InterfaceIndex              uint32
  2233  	InterfaceGuid               GUID
  2234  	Alias                       [IF_MAX_STRING_SIZE + 1]uint16
  2235  	Description                 [IF_MAX_STRING_SIZE + 1]uint16
  2236  	PhysicalAddressLength       uint32
  2237  	PhysicalAddress             [IF_MAX_PHYS_ADDRESS_LENGTH]uint8
  2238  	PermanentPhysicalAddress    [IF_MAX_PHYS_ADDRESS_LENGTH]uint8
  2239  	Mtu                         uint32
  2240  	Type                        uint32
  2241  	TunnelType                  uint32
  2242  	MediaType                   uint32
  2243  	PhysicalMediumType          uint32
  2244  	AccessType                  uint32
  2245  	DirectionType               uint32
  2246  	InterfaceAndOperStatusFlags uint8
  2247  	OperStatus                  uint32
  2248  	AdminStatus                 uint32
  2249  	MediaConnectState           uint32
  2250  	NetworkGuid                 GUID
  2251  	ConnectionType              uint32
  2252  	TransmitLinkSpeed           uint64
  2253  	ReceiveLinkSpeed            uint64
  2254  	InOctets                    uint64
  2255  	InUcastPkts                 uint64
  2256  	InNUcastPkts                uint64
  2257  	InDiscards                  uint64
  2258  	InErrors                    uint64
  2259  	InUnknownProtos             uint64
  2260  	InUcastOctets               uint64
  2261  	InMulticastOctets           uint64
  2262  	InBroadcastOctets           uint64
  2263  	OutOctets                   uint64
  2264  	OutUcastPkts                uint64
  2265  	OutNUcastPkts               uint64
  2266  	OutDiscards                 uint64
  2267  	OutErrors                   uint64
  2268  	OutUcastOctets              uint64
  2269  	OutMulticastOctets          uint64
  2270  	OutBroadcastOctets          uint64
  2271  	OutQLen                     uint64
  2272  }
  2273  
  2274  // MIB_UNICASTIPADDRESS_ROW stores information about a unicast IP address. See
  2275  // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_row.
  2276  type MibUnicastIpAddressRow struct {
  2277  	Address            RawSockaddrInet6 // SOCKADDR_INET union
  2278  	InterfaceLuid      uint64
  2279  	InterfaceIndex     uint32
  2280  	PrefixOrigin       uint32
  2281  	SuffixOrigin       uint32
  2282  	ValidLifetime      uint32
  2283  	PreferredLifetime  uint32
  2284  	OnLinkPrefixLength uint8
  2285  	SkipAsSource       uint8
  2286  	DadState           uint32
  2287  	ScopeId            uint32
  2288  	CreationTimeStamp  Filetime
  2289  }
  2290  
  2291  const ScopeLevelCount = 16
  2292  
  2293  // MIB_IPINTERFACE_ROW stores interface management information for a particular IP address family on a network interface.
  2294  // See https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipinterface_row.
  2295  type MibIpInterfaceRow struct {
  2296  	Family                               uint16
  2297  	InterfaceLuid                        uint64
  2298  	InterfaceIndex                       uint32
  2299  	MaxReassemblySize                    uint32
  2300  	InterfaceIdentifier                  uint64
  2301  	MinRouterAdvertisementInterval       uint32
  2302  	MaxRouterAdvertisementInterval       uint32
  2303  	AdvertisingEnabled                   uint8
  2304  	ForwardingEnabled                    uint8
  2305  	WeakHostSend                         uint8
  2306  	WeakHostReceive                      uint8
  2307  	UseAutomaticMetric                   uint8
  2308  	UseNeighborUnreachabilityDetection   uint8
  2309  	ManagedAddressConfigurationSupported uint8
  2310  	OtherStatefulConfigurationSupported  uint8
  2311  	AdvertiseDefaultRoute                uint8
  2312  	RouterDiscoveryBehavior              uint32
  2313  	DadTransmits                         uint32
  2314  	BaseReachableTime                    uint32
  2315  	RetransmitTime                       uint32
  2316  	PathMtuDiscoveryTimeout              uint32
  2317  	LinkLocalAddressBehavior             uint32
  2318  	LinkLocalAddressTimeout              uint32
  2319  	ZoneIndices                          [ScopeLevelCount]uint32
  2320  	SitePrefixLength                     uint32
  2321  	Metric                               uint32
  2322  	NlMtu                                uint32
  2323  	Connected                            uint8
  2324  	SupportsWakeUpPatterns               uint8
  2325  	SupportsNeighborDiscovery            uint8
  2326  	SupportsRouterDiscovery              uint8
  2327  	ReachableTime                        uint32
  2328  	TransmitOffload                      uint32
  2329  	ReceiveOffload                       uint32
  2330  	DisableDefaultRoutes                 uint8
  2331  }
  2332  
  2333  // Console related constants used for the mode parameter to SetConsoleMode. See
  2334  // https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
  2335  
  2336  const (
  2337  	ENABLE_PROCESSED_INPUT        = 0x1
  2338  	ENABLE_LINE_INPUT             = 0x2
  2339  	ENABLE_ECHO_INPUT             = 0x4
  2340  	ENABLE_WINDOW_INPUT           = 0x8
  2341  	ENABLE_MOUSE_INPUT            = 0x10
  2342  	ENABLE_INSERT_MODE            = 0x20
  2343  	ENABLE_QUICK_EDIT_MODE        = 0x40
  2344  	ENABLE_EXTENDED_FLAGS         = 0x80
  2345  	ENABLE_AUTO_POSITION          = 0x100
  2346  	ENABLE_VIRTUAL_TERMINAL_INPUT = 0x200
  2347  
  2348  	ENABLE_PROCESSED_OUTPUT            = 0x1
  2349  	ENABLE_WRAP_AT_EOL_OUTPUT          = 0x2
  2350  	ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
  2351  	DISABLE_NEWLINE_AUTO_RETURN        = 0x8
  2352  	ENABLE_LVB_GRID_WORLDWIDE          = 0x10
  2353  )
  2354  
  2355  // Pseudo console related constants used for the flags parameter to
  2356  // CreatePseudoConsole. See: https://learn.microsoft.com/en-us/windows/console/createpseudoconsole
  2357  const (
  2358  	PSEUDOCONSOLE_INHERIT_CURSOR = 0x1
  2359  )
  2360  
  2361  type Coord struct {
  2362  	X int16
  2363  	Y int16
  2364  }
  2365  
  2366  type SmallRect struct {
  2367  	Left   int16
  2368  	Top    int16
  2369  	Right  int16
  2370  	Bottom int16
  2371  }
  2372  
  2373  // Used with GetConsoleScreenBuffer to retrieve information about a console
  2374  // screen buffer. See
  2375  // https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str
  2376  // for details.
  2377  
  2378  type ConsoleScreenBufferInfo struct {
  2379  	Size              Coord
  2380  	CursorPosition    Coord
  2381  	Attributes        uint16
  2382  	Window            SmallRect
  2383  	MaximumWindowSize Coord
  2384  }
  2385  
  2386  const UNIX_PATH_MAX = 108 // defined in afunix.h
  2387  
  2388  const (
  2389  	// flags for JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags
  2390  	JOB_OBJECT_LIMIT_ACTIVE_PROCESS             = 0x00000008
  2391  	JOB_OBJECT_LIMIT_AFFINITY                   = 0x00000010
  2392  	JOB_OBJECT_LIMIT_BREAKAWAY_OK               = 0x00000800
  2393  	JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x00000400
  2394  	JOB_OBJECT_LIMIT_JOB_MEMORY                 = 0x00000200
  2395  	JOB_OBJECT_LIMIT_JOB_TIME                   = 0x00000004
  2396  	JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE          = 0x00002000
  2397  	JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME          = 0x00000040
  2398  	JOB_OBJECT_LIMIT_PRIORITY_CLASS             = 0x00000020
  2399  	JOB_OBJECT_LIMIT_PROCESS_MEMORY             = 0x00000100
  2400  	JOB_OBJECT_LIMIT_PROCESS_TIME               = 0x00000002
  2401  	JOB_OBJECT_LIMIT_SCHEDULING_CLASS           = 0x00000080
  2402  	JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK        = 0x00001000
  2403  	JOB_OBJECT_LIMIT_SUBSET_AFFINITY            = 0x00004000
  2404  	JOB_OBJECT_LIMIT_WORKINGSET                 = 0x00000001
  2405  )
  2406  
  2407  type IO_COUNTERS struct {
  2408  	ReadOperationCount  uint64
  2409  	WriteOperationCount uint64
  2410  	OtherOperationCount uint64
  2411  	ReadTransferCount   uint64
  2412  	WriteTransferCount  uint64
  2413  	OtherTransferCount  uint64
  2414  }
  2415  
  2416  type JOBOBJECT_EXTENDED_LIMIT_INFORMATION struct {
  2417  	BasicLimitInformation JOBOBJECT_BASIC_LIMIT_INFORMATION
  2418  	IoInfo                IO_COUNTERS
  2419  	ProcessMemoryLimit    uintptr
  2420  	JobMemoryLimit        uintptr
  2421  	PeakProcessMemoryUsed uintptr
  2422  	PeakJobMemoryUsed     uintptr
  2423  }
  2424  
  2425  const (
  2426  	// UIRestrictionsClass
  2427  	JOB_OBJECT_UILIMIT_DESKTOP          = 0x00000040
  2428  	JOB_OBJECT_UILIMIT_DISPLAYSETTINGS  = 0x00000010
  2429  	JOB_OBJECT_UILIMIT_EXITWINDOWS      = 0x00000080
  2430  	JOB_OBJECT_UILIMIT_GLOBALATOMS      = 0x00000020
  2431  	JOB_OBJECT_UILIMIT_HANDLES          = 0x00000001
  2432  	JOB_OBJECT_UILIMIT_READCLIPBOARD    = 0x00000002
  2433  	JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = 0x00000008
  2434  	JOB_OBJECT_UILIMIT_WRITECLIPBOARD   = 0x00000004
  2435  )
  2436  
  2437  type JOBOBJECT_BASIC_UI_RESTRICTIONS struct {
  2438  	UIRestrictionsClass uint32
  2439  }
  2440  
  2441  const (
  2442  	// JobObjectInformationClass for QueryInformationJobObject and SetInformationJobObject
  2443  	JobObjectAssociateCompletionPortInformation = 7
  2444  	JobObjectBasicAccountingInformation         = 1
  2445  	JobObjectBasicAndIoAccountingInformation    = 8
  2446  	JobObjectBasicLimitInformation              = 2
  2447  	JobObjectBasicProcessIdList                 = 3
  2448  	JobObjectBasicUIRestrictions                = 4
  2449  	JobObjectCpuRateControlInformation          = 15
  2450  	JobObjectEndOfJobTimeInformation            = 6
  2451  	JobObjectExtendedLimitInformation           = 9
  2452  	JobObjectGroupInformation                   = 11
  2453  	JobObjectGroupInformationEx                 = 14
  2454  	JobObjectLimitViolationInformation          = 13
  2455  	JobObjectLimitViolationInformation2         = 34
  2456  	JobObjectNetRateControlInformation          = 32
  2457  	JobObjectNotificationLimitInformation       = 12
  2458  	JobObjectNotificationLimitInformation2      = 33
  2459  	JobObjectSecurityLimitInformation           = 5
  2460  )
  2461  
  2462  const (
  2463  	KF_FLAG_DEFAULT                          = 0x00000000
  2464  	KF_FLAG_FORCE_APP_DATA_REDIRECTION       = 0x00080000
  2465  	KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET = 0x00040000
  2466  	KF_FLAG_FORCE_PACKAGE_REDIRECTION        = 0x00020000
  2467  	KF_FLAG_NO_PACKAGE_REDIRECTION           = 0x00010000
  2468  	KF_FLAG_FORCE_APPCONTAINER_REDIRECTION   = 0x00020000
  2469  	KF_FLAG_NO_APPCONTAINER_REDIRECTION      = 0x00010000
  2470  	KF_FLAG_CREATE                           = 0x00008000
  2471  	KF_FLAG_DONT_VERIFY                      = 0x00004000
  2472  	KF_FLAG_DONT_UNEXPAND                    = 0x00002000
  2473  	KF_FLAG_NO_ALIAS                         = 0x00001000
  2474  	KF_FLAG_INIT                             = 0x00000800
  2475  	KF_FLAG_DEFAULT_PATH                     = 0x00000400
  2476  	KF_FLAG_NOT_PARENT_RELATIVE              = 0x00000200
  2477  	KF_FLAG_SIMPLE_IDLIST                    = 0x00000100
  2478  	KF_FLAG_ALIAS_ONLY                       = 0x80000000
  2479  )
  2480  
  2481  type OsVersionInfoEx struct {
  2482  	osVersionInfoSize uint32
  2483  	MajorVersion      uint32
  2484  	MinorVersion      uint32
  2485  	BuildNumber       uint32
  2486  	PlatformId        uint32
  2487  	CsdVersion        [128]uint16
  2488  	ServicePackMajor  uint16
  2489  	ServicePackMinor  uint16
  2490  	SuiteMask         uint16
  2491  	ProductType       byte
  2492  	_                 byte
  2493  }
  2494  
  2495  const (
  2496  	EWX_LOGOFF          = 0x00000000
  2497  	EWX_SHUTDOWN        = 0x00000001
  2498  	EWX_REBOOT          = 0x00000002
  2499  	EWX_FORCE           = 0x00000004
  2500  	EWX_POWEROFF        = 0x00000008
  2501  	EWX_FORCEIFHUNG     = 0x00000010
  2502  	EWX_QUICKRESOLVE    = 0x00000020
  2503  	EWX_RESTARTAPPS     = 0x00000040
  2504  	EWX_HYBRID_SHUTDOWN = 0x00400000
  2505  	EWX_BOOTOPTIONS     = 0x01000000
  2506  
  2507  	SHTDN_REASON_FLAG_COMMENT_REQUIRED          = 0x01000000
  2508  	SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED = 0x02000000
  2509  	SHTDN_REASON_FLAG_CLEAN_UI                  = 0x04000000
  2510  	SHTDN_REASON_FLAG_DIRTY_UI                  = 0x08000000
  2511  	SHTDN_REASON_FLAG_USER_DEFINED              = 0x40000000
  2512  	SHTDN_REASON_FLAG_PLANNED                   = 0x80000000
  2513  	SHTDN_REASON_MAJOR_OTHER                    = 0x00000000
  2514  	SHTDN_REASON_MAJOR_NONE                     = 0x00000000
  2515  	SHTDN_REASON_MAJOR_HARDWARE                 = 0x00010000
  2516  	SHTDN_REASON_MAJOR_OPERATINGSYSTEM          = 0x00020000
  2517  	SHTDN_REASON_MAJOR_SOFTWARE                 = 0x00030000
  2518  	SHTDN_REASON_MAJOR_APPLICATION              = 0x00040000
  2519  	SHTDN_REASON_MAJOR_SYSTEM                   = 0x00050000
  2520  	SHTDN_REASON_MAJOR_POWER                    = 0x00060000
  2521  	SHTDN_REASON_MAJOR_LEGACY_API               = 0x00070000
  2522  	SHTDN_REASON_MINOR_OTHER                    = 0x00000000
  2523  	SHTDN_REASON_MINOR_NONE                     = 0x000000ff
  2524  	SHTDN_REASON_MINOR_MAINTENANCE              = 0x00000001
  2525  	SHTDN_REASON_MINOR_INSTALLATION             = 0x00000002
  2526  	SHTDN_REASON_MINOR_UPGRADE                  = 0x00000003
  2527  	SHTDN_REASON_MINOR_RECONFIG                 = 0x00000004
  2528  	SHTDN_REASON_MINOR_HUNG                     = 0x00000005
  2529  	SHTDN_REASON_MINOR_UNSTABLE                 = 0x00000006
  2530  	SHTDN_REASON_MINOR_DISK                     = 0x00000007
  2531  	SHTDN_REASON_MINOR_PROCESSOR                = 0x00000008
  2532  	SHTDN_REASON_MINOR_NETWORKCARD              = 0x00000009
  2533  	SHTDN_REASON_MINOR_POWER_SUPPLY             = 0x0000000a
  2534  	SHTDN_REASON_MINOR_CORDUNPLUGGED            = 0x0000000b
  2535  	SHTDN_REASON_MINOR_ENVIRONMENT              = 0x0000000c
  2536  	SHTDN_REASON_MINOR_HARDWARE_DRIVER          = 0x0000000d
  2537  	SHTDN_REASON_MINOR_OTHERDRIVER              = 0x0000000e
  2538  	SHTDN_REASON_MINOR_BLUESCREEN               = 0x0000000F
  2539  	SHTDN_REASON_MINOR_SERVICEPACK              = 0x00000010
  2540  	SHTDN_REASON_MINOR_HOTFIX                   = 0x00000011
  2541  	SHTDN_REASON_MINOR_SECURITYFIX              = 0x00000012
  2542  	SHTDN_REASON_MINOR_SECURITY                 = 0x00000013
  2543  	SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY     = 0x00000014
  2544  	SHTDN_REASON_MINOR_WMI                      = 0x00000015
  2545  	SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL    = 0x00000016
  2546  	SHTDN_REASON_MINOR_HOTFIX_UNINSTALL         = 0x00000017
  2547  	SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL    = 0x00000018
  2548  	SHTDN_REASON_MINOR_MMC                      = 0x00000019
  2549  	SHTDN_REASON_MINOR_SYSTEMRESTORE            = 0x0000001a
  2550  	SHTDN_REASON_MINOR_TERMSRV                  = 0x00000020
  2551  	SHTDN_REASON_MINOR_DC_PROMOTION             = 0x00000021
  2552  	SHTDN_REASON_MINOR_DC_DEMOTION              = 0x00000022
  2553  	SHTDN_REASON_UNKNOWN                        = SHTDN_REASON_MINOR_NONE
  2554  	SHTDN_REASON_LEGACY_API                     = SHTDN_REASON_MAJOR_LEGACY_API | SHTDN_REASON_FLAG_PLANNED
  2555  	SHTDN_REASON_VALID_BIT_MASK                 = 0xc0ffffff
  2556  
  2557  	SHUTDOWN_NORETRY = 0x1
  2558  )
  2559  
  2560  // Flags used for GetModuleHandleEx
  2561  const (
  2562  	GET_MODULE_HANDLE_EX_FLAG_PIN                = 1
  2563  	GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2
  2564  	GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS       = 4
  2565  )
  2566  
  2567  // MUI function flag values
  2568  const (
  2569  	MUI_LANGUAGE_ID                    = 0x4
  2570  	MUI_LANGUAGE_NAME                  = 0x8
  2571  	MUI_MERGE_SYSTEM_FALLBACK          = 0x10
  2572  	MUI_MERGE_USER_FALLBACK            = 0x20
  2573  	MUI_UI_FALLBACK                    = MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK
  2574  	MUI_THREAD_LANGUAGES               = 0x40
  2575  	MUI_CONSOLE_FILTER                 = 0x100
  2576  	MUI_COMPLEX_SCRIPT_FILTER          = 0x200
  2577  	MUI_RESET_FILTERS                  = 0x001
  2578  	MUI_USER_PREFERRED_UI_LANGUAGES    = 0x10
  2579  	MUI_USE_INSTALLED_LANGUAGES        = 0x20
  2580  	MUI_USE_SEARCH_ALL_LANGUAGES       = 0x40
  2581  	MUI_LANG_NEUTRAL_PE_FILE           = 0x100
  2582  	MUI_NON_LANG_NEUTRAL_FILE          = 0x200
  2583  	MUI_MACHINE_LANGUAGE_SETTINGS      = 0x400
  2584  	MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL  = 0x001
  2585  	MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN = 0x002
  2586  	MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI  = 0x004
  2587  	MUI_QUERY_TYPE                     = 0x001
  2588  	MUI_QUERY_CHECKSUM                 = 0x002
  2589  	MUI_QUERY_LANGUAGE_NAME            = 0x004
  2590  	MUI_QUERY_RESOURCE_TYPES           = 0x008
  2591  	MUI_FILEINFO_VERSION               = 0x001
  2592  
  2593  	MUI_FULL_LANGUAGE      = 0x01
  2594  	MUI_PARTIAL_LANGUAGE   = 0x02
  2595  	MUI_LIP_LANGUAGE       = 0x04
  2596  	MUI_LANGUAGE_INSTALLED = 0x20
  2597  	MUI_LANGUAGE_LICENSED  = 0x40
  2598  )
  2599  
  2600  // FILE_INFO_BY_HANDLE_CLASS constants for SetFileInformationByHandle/GetFileInformationByHandleEx
  2601  const (
  2602  	FileBasicInfo                  = 0
  2603  	FileStandardInfo               = 1
  2604  	FileNameInfo                   = 2
  2605  	FileRenameInfo                 = 3
  2606  	FileDispositionInfo            = 4
  2607  	FileAllocationInfo             = 5
  2608  	FileEndOfFileInfo              = 6
  2609  	FileStreamInfo                 = 7
  2610  	FileCompressionInfo            = 8
  2611  	FileAttributeTagInfo           = 9
  2612  	FileIdBothDirectoryInfo        = 10
  2613  	FileIdBothDirectoryRestartInfo = 11
  2614  	FileIoPriorityHintInfo         = 12
  2615  	FileRemoteProtocolInfo         = 13
  2616  	FileFullDirectoryInfo          = 14
  2617  	FileFullDirectoryRestartInfo   = 15
  2618  	FileStorageInfo                = 16
  2619  	FileAlignmentInfo              = 17
  2620  	FileIdInfo                     = 18
  2621  	FileIdExtdDirectoryInfo        = 19
  2622  	FileIdExtdDirectoryRestartInfo = 20
  2623  	FileDispositionInfoEx          = 21
  2624  	FileRenameInfoEx               = 22
  2625  	FileCaseSensitiveInfo          = 23
  2626  	FileNormalizedNameInfo         = 24
  2627  )
  2628  
  2629  // LoadLibrary flags for determining from where to search for a DLL
  2630  const (
  2631  	DONT_RESOLVE_DLL_REFERENCES               = 0x1
  2632  	LOAD_LIBRARY_AS_DATAFILE                  = 0x2
  2633  	LOAD_WITH_ALTERED_SEARCH_PATH             = 0x8
  2634  	LOAD_IGNORE_CODE_AUTHZ_LEVEL              = 0x10
  2635  	LOAD_LIBRARY_AS_IMAGE_RESOURCE            = 0x20
  2636  	LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE        = 0x40
  2637  	LOAD_LIBRARY_REQUIRE_SIGNED_TARGET        = 0x80
  2638  	LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR          = 0x100
  2639  	LOAD_LIBRARY_SEARCH_APPLICATION_DIR       = 0x200
  2640  	LOAD_LIBRARY_SEARCH_USER_DIRS             = 0x400
  2641  	LOAD_LIBRARY_SEARCH_SYSTEM32              = 0x800
  2642  	LOAD_LIBRARY_SEARCH_DEFAULT_DIRS          = 0x1000
  2643  	LOAD_LIBRARY_SAFE_CURRENT_DIRS            = 0x00002000
  2644  	LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER = 0x00004000
  2645  	LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY      = 0x00008000
  2646  )
  2647  
  2648  // RegNotifyChangeKeyValue notifyFilter flags.
  2649  const (
  2650  	// REG_NOTIFY_CHANGE_NAME notifies the caller if a subkey is added or deleted.
  2651  	REG_NOTIFY_CHANGE_NAME = 0x00000001
  2652  
  2653  	// REG_NOTIFY_CHANGE_ATTRIBUTES notifies the caller of changes to the attributes of the key, such as the security descriptor information.
  2654  	REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002
  2655  
  2656  	// 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.
  2657  	REG_NOTIFY_CHANGE_LAST_SET = 0x00000004
  2658  
  2659  	// REG_NOTIFY_CHANGE_SECURITY notifies the caller of changes to the security descriptor of the key.
  2660  	REG_NOTIFY_CHANGE_SECURITY = 0x00000008
  2661  
  2662  	// 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.
  2663  	REG_NOTIFY_THREAD_AGNOSTIC = 0x10000000
  2664  )
  2665  
  2666  type CommTimeouts struct {
  2667  	ReadIntervalTimeout         uint32
  2668  	ReadTotalTimeoutMultiplier  uint32
  2669  	ReadTotalTimeoutConstant    uint32
  2670  	WriteTotalTimeoutMultiplier uint32
  2671  	WriteTotalTimeoutConstant   uint32
  2672  }
  2673  
  2674  // NTUnicodeString is a UTF-16 string for NT native APIs, corresponding to UNICODE_STRING.
  2675  type NTUnicodeString struct {
  2676  	Length        uint16
  2677  	MaximumLength uint16
  2678  	Buffer        *uint16
  2679  }
  2680  
  2681  // NTString is an ANSI string for NT native APIs, corresponding to STRING.
  2682  type NTString struct {
  2683  	Length        uint16
  2684  	MaximumLength uint16
  2685  	Buffer        *byte
  2686  }
  2687  
  2688  type LIST_ENTRY struct {
  2689  	Flink *LIST_ENTRY
  2690  	Blink *LIST_ENTRY
  2691  }
  2692  
  2693  type RUNTIME_FUNCTION struct {
  2694  	BeginAddress uint32
  2695  	EndAddress   uint32
  2696  	UnwindData   uint32
  2697  }
  2698  
  2699  type LDR_DATA_TABLE_ENTRY struct {
  2700  	reserved1          [2]uintptr
  2701  	InMemoryOrderLinks LIST_ENTRY
  2702  	reserved2          [2]uintptr
  2703  	DllBase            uintptr
  2704  	reserved3          [2]uintptr
  2705  	FullDllName        NTUnicodeString
  2706  	reserved4          [8]byte
  2707  	reserved5          [3]uintptr
  2708  	reserved6          uintptr
  2709  	TimeDateStamp      uint32
  2710  }
  2711  
  2712  type PEB_LDR_DATA struct {
  2713  	reserved1               [8]byte
  2714  	reserved2               [3]uintptr
  2715  	InMemoryOrderModuleList LIST_ENTRY
  2716  }
  2717  
  2718  type CURDIR struct {
  2719  	DosPath NTUnicodeString
  2720  	Handle  Handle
  2721  }
  2722  
  2723  type RTL_DRIVE_LETTER_CURDIR struct {
  2724  	Flags     uint16
  2725  	Length    uint16
  2726  	TimeStamp uint32
  2727  	DosPath   NTString
  2728  }
  2729  
  2730  type RTL_USER_PROCESS_PARAMETERS struct {
  2731  	MaximumLength, Length uint32
  2732  
  2733  	Flags, DebugFlags uint32
  2734  
  2735  	ConsoleHandle                                Handle
  2736  	ConsoleFlags                                 uint32
  2737  	StandardInput, StandardOutput, StandardError Handle
  2738  
  2739  	CurrentDirectory CURDIR
  2740  	DllPath          NTUnicodeString
  2741  	ImagePathName    NTUnicodeString
  2742  	CommandLine      NTUnicodeString
  2743  	Environment      unsafe.Pointer
  2744  
  2745  	StartingX, StartingY, CountX, CountY, CountCharsX, CountCharsY, FillAttribute uint32
  2746  
  2747  	WindowFlags, ShowWindowFlags                     uint32
  2748  	WindowTitle, DesktopInfo, ShellInfo, RuntimeData NTUnicodeString
  2749  	CurrentDirectories                               [32]RTL_DRIVE_LETTER_CURDIR
  2750  
  2751  	EnvironmentSize, EnvironmentVersion uintptr
  2752  
  2753  	PackageDependencyData unsafe.Pointer
  2754  	ProcessGroupId        uint32
  2755  	LoaderThreads         uint32
  2756  
  2757  	RedirectionDllName               NTUnicodeString
  2758  	HeapPartitionName                NTUnicodeString
  2759  	DefaultThreadpoolCpuSetMasks     uintptr
  2760  	DefaultThreadpoolCpuSetMaskCount uint32
  2761  }
  2762  
  2763  type PEB struct {
  2764  	reserved1              [2]byte
  2765  	BeingDebugged          byte
  2766  	BitField               byte
  2767  	reserved3              uintptr
  2768  	ImageBaseAddress       uintptr
  2769  	Ldr                    *PEB_LDR_DATA
  2770  	ProcessParameters      *RTL_USER_PROCESS_PARAMETERS
  2771  	reserved4              [3]uintptr
  2772  	AtlThunkSListPtr       uintptr
  2773  	reserved5              uintptr
  2774  	reserved6              uint32
  2775  	reserved7              uintptr
  2776  	reserved8              uint32
  2777  	AtlThunkSListPtr32     uint32
  2778  	reserved9              [45]uintptr
  2779  	reserved10             [96]byte
  2780  	PostProcessInitRoutine uintptr
  2781  	reserved11             [128]byte
  2782  	reserved12             [1]uintptr
  2783  	SessionId              uint32
  2784  }
  2785  
  2786  type OBJECT_ATTRIBUTES struct {
  2787  	Length             uint32
  2788  	RootDirectory      Handle
  2789  	ObjectName         *NTUnicodeString
  2790  	Attributes         uint32
  2791  	SecurityDescriptor *SECURITY_DESCRIPTOR
  2792  	SecurityQoS        *SECURITY_QUALITY_OF_SERVICE
  2793  }
  2794  
  2795  // Values for the Attributes member of OBJECT_ATTRIBUTES.
  2796  const (
  2797  	OBJ_INHERIT                       = 0x00000002
  2798  	OBJ_PERMANENT                     = 0x00000010
  2799  	OBJ_EXCLUSIVE                     = 0x00000020
  2800  	OBJ_CASE_INSENSITIVE              = 0x00000040
  2801  	OBJ_OPENIF                        = 0x00000080
  2802  	OBJ_OPENLINK                      = 0x00000100
  2803  	OBJ_KERNEL_HANDLE                 = 0x00000200
  2804  	OBJ_FORCE_ACCESS_CHECK            = 0x00000400
  2805  	OBJ_IGNORE_IMPERSONATED_DEVICEMAP = 0x00000800
  2806  	OBJ_DONT_REPARSE                  = 0x00001000
  2807  	OBJ_VALID_ATTRIBUTES              = 0x00001FF2
  2808  )
  2809  
  2810  type IO_STATUS_BLOCK struct {
  2811  	Status      NTStatus
  2812  	Information uintptr
  2813  }
  2814  
  2815  type RTLP_CURDIR_REF struct {
  2816  	RefCount int32
  2817  	Handle   Handle
  2818  }
  2819  
  2820  type RTL_RELATIVE_NAME struct {
  2821  	RelativeName        NTUnicodeString
  2822  	ContainingDirectory Handle
  2823  	CurDirRef           *RTLP_CURDIR_REF
  2824  }
  2825  
  2826  const (
  2827  	// CreateDisposition flags for NtCreateFile and NtCreateNamedPipeFile.
  2828  	FILE_SUPERSEDE           = 0x00000000
  2829  	FILE_OPEN                = 0x00000001
  2830  	FILE_CREATE              = 0x00000002
  2831  	FILE_OPEN_IF             = 0x00000003
  2832  	FILE_OVERWRITE           = 0x00000004
  2833  	FILE_OVERWRITE_IF        = 0x00000005
  2834  	FILE_MAXIMUM_DISPOSITION = 0x00000005
  2835  
  2836  	// CreateOptions flags for NtCreateFile and NtCreateNamedPipeFile.
  2837  	FILE_DIRECTORY_FILE            = 0x00000001
  2838  	FILE_WRITE_THROUGH             = 0x00000002
  2839  	FILE_SEQUENTIAL_ONLY           = 0x00000004
  2840  	FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008
  2841  	FILE_SYNCHRONOUS_IO_ALERT      = 0x00000010
  2842  	FILE_SYNCHRONOUS_IO_NONALERT   = 0x00000020
  2843  	FILE_NON_DIRECTORY_FILE        = 0x00000040
  2844  	FILE_CREATE_TREE_CONNECTION    = 0x00000080
  2845  	FILE_COMPLETE_IF_OPLOCKED      = 0x00000100
  2846  	FILE_NO_EA_KNOWLEDGE           = 0x00000200
  2847  	FILE_OPEN_REMOTE_INSTANCE      = 0x00000400
  2848  	FILE_RANDOM_ACCESS             = 0x00000800
  2849  	FILE_DELETE_ON_CLOSE           = 0x00001000
  2850  	FILE_OPEN_BY_FILE_ID           = 0x00002000
  2851  	FILE_OPEN_FOR_BACKUP_INTENT    = 0x00004000
  2852  	FILE_NO_COMPRESSION            = 0x00008000
  2853  	FILE_OPEN_REQUIRING_OPLOCK     = 0x00010000
  2854  	FILE_DISALLOW_EXCLUSIVE        = 0x00020000
  2855  	FILE_RESERVE_OPFILTER          = 0x00100000
  2856  	FILE_OPEN_REPARSE_POINT        = 0x00200000
  2857  	FILE_OPEN_NO_RECALL            = 0x00400000
  2858  	FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
  2859  
  2860  	// Parameter constants for NtCreateNamedPipeFile.
  2861  
  2862  	FILE_PIPE_BYTE_STREAM_TYPE = 0x00000000
  2863  	FILE_PIPE_MESSAGE_TYPE     = 0x00000001
  2864  
  2865  	FILE_PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000
  2866  	FILE_PIPE_REJECT_REMOTE_CLIENTS = 0x00000002
  2867  
  2868  	FILE_PIPE_TYPE_VALID_MASK = 0x00000003
  2869  
  2870  	FILE_PIPE_BYTE_STREAM_MODE = 0x00000000
  2871  	FILE_PIPE_MESSAGE_MODE     = 0x00000001
  2872  
  2873  	FILE_PIPE_QUEUE_OPERATION    = 0x00000000
  2874  	FILE_PIPE_COMPLETE_OPERATION = 0x00000001
  2875  
  2876  	FILE_PIPE_INBOUND     = 0x00000000
  2877  	FILE_PIPE_OUTBOUND    = 0x00000001
  2878  	FILE_PIPE_FULL_DUPLEX = 0x00000002
  2879  
  2880  	FILE_PIPE_DISCONNECTED_STATE = 0x00000001
  2881  	FILE_PIPE_LISTENING_STATE    = 0x00000002
  2882  	FILE_PIPE_CONNECTED_STATE    = 0x00000003
  2883  	FILE_PIPE_CLOSING_STATE      = 0x00000004
  2884  
  2885  	FILE_PIPE_CLIENT_END = 0x00000000
  2886  	FILE_PIPE_SERVER_END = 0x00000001
  2887  )
  2888  
  2889  const (
  2890  	// FileInformationClass for NtSetInformationFile
  2891  	FileBasicInformation                         = 4
  2892  	FileRenameInformation                        = 10
  2893  	FileDispositionInformation                   = 13
  2894  	FilePositionInformation                      = 14
  2895  	FileEndOfFileInformation                     = 20
  2896  	FileValidDataLengthInformation               = 39
  2897  	FileShortNameInformation                     = 40
  2898  	FileIoPriorityHintInformation                = 43
  2899  	FileReplaceCompletionInformation             = 61
  2900  	FileDispositionInformationEx                 = 64
  2901  	FileCaseSensitiveInformation                 = 71
  2902  	FileLinkInformation                          = 72
  2903  	FileCaseSensitiveInformationForceAccessCheck = 75
  2904  	FileKnownFolderInformation                   = 76
  2905  
  2906  	// Flags for FILE_RENAME_INFORMATION
  2907  	FILE_RENAME_REPLACE_IF_EXISTS                    = 0x00000001
  2908  	FILE_RENAME_POSIX_SEMANTICS                      = 0x00000002
  2909  	FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE       = 0x00000004
  2910  	FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008
  2911  	FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE          = 0x00000010
  2912  	FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE          = 0x00000020
  2913  	FILE_RENAME_PRESERVE_AVAILABLE_SPACE             = 0x00000030
  2914  	FILE_RENAME_IGNORE_READONLY_ATTRIBUTE            = 0x00000040
  2915  	FILE_RENAME_FORCE_RESIZE_TARGET_SR               = 0x00000080
  2916  	FILE_RENAME_FORCE_RESIZE_SOURCE_SR               = 0x00000100
  2917  	FILE_RENAME_FORCE_RESIZE_SR                      = 0x00000180
  2918  
  2919  	// Flags for FILE_DISPOSITION_INFORMATION_EX
  2920  	FILE_DISPOSITION_DO_NOT_DELETE             = 0x00000000
  2921  	FILE_DISPOSITION_DELETE                    = 0x00000001
  2922  	FILE_DISPOSITION_POSIX_SEMANTICS           = 0x00000002
  2923  	FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK = 0x00000004
  2924  	FILE_DISPOSITION_ON_CLOSE                  = 0x00000008
  2925  	FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE = 0x00000010
  2926  
  2927  	// Flags for FILE_CASE_SENSITIVE_INFORMATION
  2928  	FILE_CS_FLAG_CASE_SENSITIVE_DIR = 0x00000001
  2929  
  2930  	// Flags for FILE_LINK_INFORMATION
  2931  	FILE_LINK_REPLACE_IF_EXISTS                    = 0x00000001
  2932  	FILE_LINK_POSIX_SEMANTICS                      = 0x00000002
  2933  	FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008
  2934  	FILE_LINK_NO_INCREASE_AVAILABLE_SPACE          = 0x00000010
  2935  	FILE_LINK_NO_DECREASE_AVAILABLE_SPACE          = 0x00000020
  2936  	FILE_LINK_PRESERVE_AVAILABLE_SPACE             = 0x00000030
  2937  	FILE_LINK_IGNORE_READONLY_ATTRIBUTE            = 0x00000040
  2938  	FILE_LINK_FORCE_RESIZE_TARGET_SR               = 0x00000080
  2939  	FILE_LINK_FORCE_RESIZE_SOURCE_SR               = 0x00000100
  2940  	FILE_LINK_FORCE_RESIZE_SR                      = 0x00000180
  2941  )
  2942  
  2943  // ProcessInformationClasses for NtQueryInformationProcess and NtSetInformationProcess.
  2944  const (
  2945  	ProcessBasicInformation = iota
  2946  	ProcessQuotaLimits
  2947  	ProcessIoCounters
  2948  	ProcessVmCounters
  2949  	ProcessTimes
  2950  	ProcessBasePriority
  2951  	ProcessRaisePriority
  2952  	ProcessDebugPort
  2953  	ProcessExceptionPort
  2954  	ProcessAccessToken
  2955  	ProcessLdtInformation
  2956  	ProcessLdtSize
  2957  	ProcessDefaultHardErrorMode
  2958  	ProcessIoPortHandlers
  2959  	ProcessPooledUsageAndLimits
  2960  	ProcessWorkingSetWatch
  2961  	ProcessUserModeIOPL
  2962  	ProcessEnableAlignmentFaultFixup
  2963  	ProcessPriorityClass
  2964  	ProcessWx86Information
  2965  	ProcessHandleCount
  2966  	ProcessAffinityMask
  2967  	ProcessPriorityBoost
  2968  	ProcessDeviceMap
  2969  	ProcessSessionInformation
  2970  	ProcessForegroundInformation
  2971  	ProcessWow64Information
  2972  	ProcessImageFileName
  2973  	ProcessLUIDDeviceMapsEnabled
  2974  	ProcessBreakOnTermination
  2975  	ProcessDebugObjectHandle
  2976  	ProcessDebugFlags
  2977  	ProcessHandleTracing
  2978  	ProcessIoPriority
  2979  	ProcessExecuteFlags
  2980  	ProcessTlsInformation
  2981  	ProcessCookie
  2982  	ProcessImageInformation
  2983  	ProcessCycleTime
  2984  	ProcessPagePriority
  2985  	ProcessInstrumentationCallback
  2986  	ProcessThreadStackAllocation
  2987  	ProcessWorkingSetWatchEx
  2988  	ProcessImageFileNameWin32
  2989  	ProcessImageFileMapping
  2990  	ProcessAffinityUpdateMode
  2991  	ProcessMemoryAllocationMode
  2992  	ProcessGroupInformation
  2993  	ProcessTokenVirtualizationEnabled
  2994  	ProcessConsoleHostProcess
  2995  	ProcessWindowInformation
  2996  	ProcessHandleInformation
  2997  	ProcessMitigationPolicy
  2998  	ProcessDynamicFunctionTableInformation
  2999  	ProcessHandleCheckingMode
  3000  	ProcessKeepAliveCount
  3001  	ProcessRevokeFileHandles
  3002  	ProcessWorkingSetControl
  3003  	ProcessHandleTable
  3004  	ProcessCheckStackExtentsMode
  3005  	ProcessCommandLineInformation
  3006  	ProcessProtectionInformation
  3007  	ProcessMemoryExhaustion
  3008  	ProcessFaultInformation
  3009  	ProcessTelemetryIdInformation
  3010  	ProcessCommitReleaseInformation
  3011  	ProcessDefaultCpuSetsInformation
  3012  	ProcessAllowedCpuSetsInformation
  3013  	ProcessSubsystemProcess
  3014  	ProcessJobMemoryInformation
  3015  	ProcessInPrivate
  3016  	ProcessRaiseUMExceptionOnInvalidHandleClose
  3017  	ProcessIumChallengeResponse
  3018  	ProcessChildProcessInformation
  3019  	ProcessHighGraphicsPriorityInformation
  3020  	ProcessSubsystemInformation
  3021  	ProcessEnergyValues
  3022  	ProcessActivityThrottleState
  3023  	ProcessActivityThrottlePolicy
  3024  	ProcessWin32kSyscallFilterInformation
  3025  	ProcessDisableSystemAllowedCpuSets
  3026  	ProcessWakeInformation
  3027  	ProcessEnergyTrackingState
  3028  	ProcessManageWritesToExecutableMemory
  3029  	ProcessCaptureTrustletLiveDump
  3030  	ProcessTelemetryCoverage
  3031  	ProcessEnclaveInformation
  3032  	ProcessEnableReadWriteVmLogging
  3033  	ProcessUptimeInformation
  3034  	ProcessImageSection
  3035  	ProcessDebugAuthInformation
  3036  	ProcessSystemResourceManagement
  3037  	ProcessSequenceNumber
  3038  	ProcessLoaderDetour
  3039  	ProcessSecurityDomainInformation
  3040  	ProcessCombineSecurityDomainsInformation
  3041  	ProcessEnableLogging
  3042  	ProcessLeapSecondInformation
  3043  	ProcessFiberShadowStackAllocation
  3044  	ProcessFreeFiberShadowStackAllocation
  3045  	ProcessAltSystemCallInformation
  3046  	ProcessDynamicEHContinuationTargets
  3047  	ProcessDynamicEnforcedCetCompatibleRanges
  3048  )
  3049  
  3050  type PROCESS_BASIC_INFORMATION struct {
  3051  	ExitStatus                   NTStatus
  3052  	PebBaseAddress               *PEB
  3053  	AffinityMask                 uintptr
  3054  	BasePriority                 int32
  3055  	UniqueProcessId              uintptr
  3056  	InheritedFromUniqueProcessId uintptr
  3057  }
  3058  
  3059  type SYSTEM_PROCESS_INFORMATION struct {
  3060  	NextEntryOffset              uint32
  3061  	NumberOfThreads              uint32
  3062  	WorkingSetPrivateSize        int64
  3063  	HardFaultCount               uint32
  3064  	NumberOfThreadsHighWatermark uint32
  3065  	CycleTime                    uint64
  3066  	CreateTime                   int64
  3067  	UserTime                     int64
  3068  	KernelTime                   int64
  3069  	ImageName                    NTUnicodeString
  3070  	BasePriority                 int32
  3071  	UniqueProcessID              uintptr
  3072  	InheritedFromUniqueProcessID uintptr
  3073  	HandleCount                  uint32
  3074  	SessionID                    uint32
  3075  	UniqueProcessKey             *uint32
  3076  	PeakVirtualSize              uintptr
  3077  	VirtualSize                  uintptr
  3078  	PageFaultCount               uint32
  3079  	PeakWorkingSetSize           uintptr
  3080  	WorkingSetSize               uintptr
  3081  	QuotaPeakPagedPoolUsage      uintptr
  3082  	QuotaPagedPoolUsage          uintptr
  3083  	QuotaPeakNonPagedPoolUsage   uintptr
  3084  	QuotaNonPagedPoolUsage       uintptr
  3085  	PagefileUsage                uintptr
  3086  	PeakPagefileUsage            uintptr
  3087  	PrivatePageCount             uintptr
  3088  	ReadOperationCount           int64
  3089  	WriteOperationCount          int64
  3090  	OtherOperationCount          int64
  3091  	ReadTransferCount            int64
  3092  	WriteTransferCount           int64
  3093  	OtherTransferCount           int64
  3094  }
  3095  
  3096  // SystemInformationClasses for NtQuerySystemInformation and NtSetSystemInformation
  3097  const (
  3098  	SystemBasicInformation = iota
  3099  	SystemProcessorInformation
  3100  	SystemPerformanceInformation
  3101  	SystemTimeOfDayInformation
  3102  	SystemPathInformation
  3103  	SystemProcessInformation
  3104  	SystemCallCountInformation
  3105  	SystemDeviceInformation
  3106  	SystemProcessorPerformanceInformation
  3107  	SystemFlagsInformation
  3108  	SystemCallTimeInformation
  3109  	SystemModuleInformation
  3110  	SystemLocksInformation
  3111  	SystemStackTraceInformation
  3112  	SystemPagedPoolInformation
  3113  	SystemNonPagedPoolInformation
  3114  	SystemHandleInformation
  3115  	SystemObjectInformation
  3116  	SystemPageFileInformation
  3117  	SystemVdmInstemulInformation
  3118  	SystemVdmBopInformation
  3119  	SystemFileCacheInformation
  3120  	SystemPoolTagInformation
  3121  	SystemInterruptInformation
  3122  	SystemDpcBehaviorInformation
  3123  	SystemFullMemoryInformation
  3124  	SystemLoadGdiDriverInformation
  3125  	SystemUnloadGdiDriverInformation
  3126  	SystemTimeAdjustmentInformation
  3127  	SystemSummaryMemoryInformation
  3128  	SystemMirrorMemoryInformation
  3129  	SystemPerformanceTraceInformation
  3130  	systemObsolete0
  3131  	SystemExceptionInformation
  3132  	SystemCrashDumpStateInformation
  3133  	SystemKernelDebuggerInformation
  3134  	SystemContextSwitchInformation
  3135  	SystemRegistryQuotaInformation
  3136  	SystemExtendServiceTableInformation
  3137  	SystemPrioritySeperation
  3138  	SystemVerifierAddDriverInformation
  3139  	SystemVerifierRemoveDriverInformation
  3140  	SystemProcessorIdleInformation
  3141  	SystemLegacyDriverInformation
  3142  	SystemCurrentTimeZoneInformation
  3143  	SystemLookasideInformation
  3144  	SystemTimeSlipNotification
  3145  	SystemSessionCreate
  3146  	SystemSessionDetach
  3147  	SystemSessionInformation
  3148  	SystemRangeStartInformation
  3149  	SystemVerifierInformation
  3150  	SystemVerifierThunkExtend
  3151  	SystemSessionProcessInformation
  3152  	SystemLoadGdiDriverInSystemSpace
  3153  	SystemNumaProcessorMap
  3154  	SystemPrefetcherInformation
  3155  	SystemExtendedProcessInformation
  3156  	SystemRecommendedSharedDataAlignment
  3157  	SystemComPlusPackage
  3158  	SystemNumaAvailableMemory
  3159  	SystemProcessorPowerInformation
  3160  	SystemEmulationBasicInformation
  3161  	SystemEmulationProcessorInformation
  3162  	SystemExtendedHandleInformation
  3163  	SystemLostDelayedWriteInformation
  3164  	SystemBigPoolInformation
  3165  	SystemSessionPoolTagInformation
  3166  	SystemSessionMappedViewInformation
  3167  	SystemHotpatchInformation
  3168  	SystemObjectSecurityMode
  3169  	SystemWatchdogTimerHandler
  3170  	SystemWatchdogTimerInformation
  3171  	SystemLogicalProcessorInformation
  3172  	SystemWow64SharedInformationObsolete
  3173  	SystemRegisterFirmwareTableInformationHandler
  3174  	SystemFirmwareTableInformation
  3175  	SystemModuleInformationEx
  3176  	SystemVerifierTriageInformation
  3177  	SystemSuperfetchInformation
  3178  	SystemMemoryListInformation
  3179  	SystemFileCacheInformationEx
  3180  	SystemThreadPriorityClientIdInformation
  3181  	SystemProcessorIdleCycleTimeInformation
  3182  	SystemVerifierCancellationInformation
  3183  	SystemProcessorPowerInformationEx
  3184  	SystemRefTraceInformation
  3185  	SystemSpecialPoolInformation
  3186  	SystemProcessIdInformation
  3187  	SystemErrorPortInformation
  3188  	SystemBootEnvironmentInformation
  3189  	SystemHypervisorInformation
  3190  	SystemVerifierInformationEx
  3191  	SystemTimeZoneInformation
  3192  	SystemImageFileExecutionOptionsInformation
  3193  	SystemCoverageInformation
  3194  	SystemPrefetchPatchInformation
  3195  	SystemVerifierFaultsInformation
  3196  	SystemSystemPartitionInformation
  3197  	SystemSystemDiskInformation
  3198  	SystemProcessorPerformanceDistribution
  3199  	SystemNumaProximityNodeInformation
  3200  	SystemDynamicTimeZoneInformation
  3201  	SystemCodeIntegrityInformation
  3202  	SystemProcessorMicrocodeUpdateInformation
  3203  	SystemProcessorBrandString
  3204  	SystemVirtualAddressInformation
  3205  	SystemLogicalProcessorAndGroupInformation
  3206  	SystemProcessorCycleTimeInformation
  3207  	SystemStoreInformation
  3208  	SystemRegistryAppendString
  3209  	SystemAitSamplingValue
  3210  	SystemVhdBootInformation
  3211  	SystemCpuQuotaInformation
  3212  	SystemNativeBasicInformation
  3213  	systemSpare1
  3214  	SystemLowPriorityIoInformation
  3215  	SystemTpmBootEntropyInformation
  3216  	SystemVerifierCountersInformation
  3217  	SystemPagedPoolInformationEx
  3218  	SystemSystemPtesInformationEx
  3219  	SystemNodeDistanceInformation
  3220  	SystemAcpiAuditInformation
  3221  	SystemBasicPerformanceInformation
  3222  	SystemQueryPerformanceCounterInformation
  3223  	SystemSessionBigPoolInformation
  3224  	SystemBootGraphicsInformation
  3225  	SystemScrubPhysicalMemoryInformation
  3226  	SystemBadPageInformation
  3227  	SystemProcessorProfileControlArea
  3228  	SystemCombinePhysicalMemoryInformation
  3229  	SystemEntropyInterruptTimingCallback
  3230  	SystemConsoleInformation
  3231  	SystemPlatformBinaryInformation
  3232  	SystemThrottleNotificationInformation
  3233  	SystemHypervisorProcessorCountInformation
  3234  	SystemDeviceDataInformation
  3235  	SystemDeviceDataEnumerationInformation
  3236  	SystemMemoryTopologyInformation
  3237  	SystemMemoryChannelInformation
  3238  	SystemBootLogoInformation
  3239  	SystemProcessorPerformanceInformationEx
  3240  	systemSpare0
  3241  	SystemSecureBootPolicyInformation
  3242  	SystemPageFileInformationEx
  3243  	SystemSecureBootInformation
  3244  	SystemEntropyInterruptTimingRawInformation
  3245  	SystemPortableWorkspaceEfiLauncherInformation
  3246  	SystemFullProcessInformation
  3247  	SystemKernelDebuggerInformationEx
  3248  	SystemBootMetadataInformation
  3249  	SystemSoftRebootInformation
  3250  	SystemElamCertificateInformation
  3251  	SystemOfflineDumpConfigInformation
  3252  	SystemProcessorFeaturesInformation
  3253  	SystemRegistryReconciliationInformation
  3254  	SystemEdidInformation
  3255  	SystemManufacturingInformation
  3256  	SystemEnergyEstimationConfigInformation
  3257  	SystemHypervisorDetailInformation
  3258  	SystemProcessorCycleStatsInformation
  3259  	SystemVmGenerationCountInformation
  3260  	SystemTrustedPlatformModuleInformation
  3261  	SystemKernelDebuggerFlags
  3262  	SystemCodeIntegrityPolicyInformation
  3263  	SystemIsolatedUserModeInformation
  3264  	SystemHardwareSecurityTestInterfaceResultsInformation
  3265  	SystemSingleModuleInformation
  3266  	SystemAllowedCpuSetsInformation
  3267  	SystemDmaProtectionInformation
  3268  	SystemInterruptCpuSetsInformation
  3269  	SystemSecureBootPolicyFullInformation
  3270  	SystemCodeIntegrityPolicyFullInformation
  3271  	SystemAffinitizedInterruptProcessorInformation
  3272  	SystemRootSiloInformation
  3273  )
  3274  
  3275  type RTL_PROCESS_MODULE_INFORMATION struct {
  3276  	Section          Handle
  3277  	MappedBase       uintptr
  3278  	ImageBase        uintptr
  3279  	ImageSize        uint32
  3280  	Flags            uint32
  3281  	LoadOrderIndex   uint16
  3282  	InitOrderIndex   uint16
  3283  	LoadCount        uint16
  3284  	OffsetToFileName uint16
  3285  	FullPathName     [256]byte
  3286  }
  3287  
  3288  type RTL_PROCESS_MODULES struct {
  3289  	NumberOfModules uint32
  3290  	Modules         [1]RTL_PROCESS_MODULE_INFORMATION
  3291  }
  3292  
  3293  // Constants for LocalAlloc flags.
  3294  const (
  3295  	LMEM_FIXED          = 0x0
  3296  	LMEM_MOVEABLE       = 0x2
  3297  	LMEM_NOCOMPACT      = 0x10
  3298  	LMEM_NODISCARD      = 0x20
  3299  	LMEM_ZEROINIT       = 0x40
  3300  	LMEM_MODIFY         = 0x80
  3301  	LMEM_DISCARDABLE    = 0xf00
  3302  	LMEM_VALID_FLAGS    = 0xf72
  3303  	LMEM_INVALID_HANDLE = 0x8000
  3304  	LHND                = LMEM_MOVEABLE | LMEM_ZEROINIT
  3305  	LPTR                = LMEM_FIXED | LMEM_ZEROINIT
  3306  	NONZEROLHND         = LMEM_MOVEABLE
  3307  	NONZEROLPTR         = LMEM_FIXED
  3308  )
  3309  
  3310  // Constants for the CreateNamedPipe-family of functions.
  3311  const (
  3312  	PIPE_ACCESS_INBOUND  = 0x1
  3313  	PIPE_ACCESS_OUTBOUND = 0x2
  3314  	PIPE_ACCESS_DUPLEX   = 0x3
  3315  
  3316  	PIPE_CLIENT_END = 0x0
  3317  	PIPE_SERVER_END = 0x1
  3318  
  3319  	PIPE_WAIT                  = 0x0
  3320  	PIPE_NOWAIT                = 0x1
  3321  	PIPE_READMODE_BYTE         = 0x0
  3322  	PIPE_READMODE_MESSAGE      = 0x2
  3323  	PIPE_TYPE_BYTE             = 0x0
  3324  	PIPE_TYPE_MESSAGE          = 0x4
  3325  	PIPE_ACCEPT_REMOTE_CLIENTS = 0x0
  3326  	PIPE_REJECT_REMOTE_CLIENTS = 0x8
  3327  
  3328  	PIPE_UNLIMITED_INSTANCES = 255
  3329  )
  3330  
  3331  // Constants for security attributes when opening named pipes.
  3332  const (
  3333  	SECURITY_ANONYMOUS      = SecurityAnonymous << 16
  3334  	SECURITY_IDENTIFICATION = SecurityIdentification << 16
  3335  	SECURITY_IMPERSONATION  = SecurityImpersonation << 16
  3336  	SECURITY_DELEGATION     = SecurityDelegation << 16
  3337  
  3338  	SECURITY_CONTEXT_TRACKING = 0x40000
  3339  	SECURITY_EFFECTIVE_ONLY   = 0x80000
  3340  
  3341  	SECURITY_SQOS_PRESENT     = 0x100000
  3342  	SECURITY_VALID_SQOS_FLAGS = 0x1f0000
  3343  )
  3344  
  3345  // ResourceID represents a 16-bit resource identifier, traditionally created with the MAKEINTRESOURCE macro.
  3346  type ResourceID uint16
  3347  
  3348  // ResourceIDOrString must be either a ResourceID, to specify a resource or resource type by ID,
  3349  // or a string, to specify a resource or resource type by name.
  3350  type ResourceIDOrString interface{}
  3351  
  3352  // Predefined resource names and types.
  3353  var (
  3354  	// Predefined names.
  3355  	CREATEPROCESS_MANIFEST_RESOURCE_ID                 ResourceID = 1
  3356  	ISOLATIONAWARE_MANIFEST_RESOURCE_ID                ResourceID = 2
  3357  	ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID ResourceID = 3
  3358  	ISOLATIONPOLICY_MANIFEST_RESOURCE_ID               ResourceID = 4
  3359  	ISOLATIONPOLICY_BROWSER_MANIFEST_RESOURCE_ID       ResourceID = 5
  3360  	MINIMUM_RESERVED_MANIFEST_RESOURCE_ID              ResourceID = 1  // inclusive
  3361  	MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID              ResourceID = 16 // inclusive
  3362  
  3363  	// Predefined types.
  3364  	RT_CURSOR       ResourceID = 1
  3365  	RT_BITMAP       ResourceID = 2
  3366  	RT_ICON         ResourceID = 3
  3367  	RT_MENU         ResourceID = 4
  3368  	RT_DIALOG       ResourceID = 5
  3369  	RT_STRING       ResourceID = 6
  3370  	RT_FONTDIR      ResourceID = 7
  3371  	RT_FONT         ResourceID = 8
  3372  	RT_ACCELERATOR  ResourceID = 9
  3373  	RT_RCDATA       ResourceID = 10
  3374  	RT_MESSAGETABLE ResourceID = 11
  3375  	RT_GROUP_CURSOR ResourceID = 12
  3376  	RT_GROUP_ICON   ResourceID = 14
  3377  	RT_VERSION      ResourceID = 16
  3378  	RT_DLGINCLUDE   ResourceID = 17
  3379  	RT_PLUGPLAY     ResourceID = 19
  3380  	RT_VXD          ResourceID = 20
  3381  	RT_ANICURSOR    ResourceID = 21
  3382  	RT_ANIICON      ResourceID = 22
  3383  	RT_HTML         ResourceID = 23
  3384  	RT_MANIFEST     ResourceID = 24
  3385  )
  3386  
  3387  type VS_FIXEDFILEINFO struct {
  3388  	Signature        uint32
  3389  	StrucVersion     uint32
  3390  	FileVersionMS    uint32
  3391  	FileVersionLS    uint32
  3392  	ProductVersionMS uint32
  3393  	ProductVersionLS uint32
  3394  	FileFlagsMask    uint32
  3395  	FileFlags        uint32
  3396  	FileOS           uint32
  3397  	FileType         uint32
  3398  	FileSubtype      uint32
  3399  	FileDateMS       uint32
  3400  	FileDateLS       uint32
  3401  }
  3402  
  3403  type COAUTHIDENTITY struct {
  3404  	User           *uint16
  3405  	UserLength     uint32
  3406  	Domain         *uint16
  3407  	DomainLength   uint32
  3408  	Password       *uint16
  3409  	PasswordLength uint32
  3410  	Flags          uint32
  3411  }
  3412  
  3413  type COAUTHINFO struct {
  3414  	AuthnSvc           uint32
  3415  	AuthzSvc           uint32
  3416  	ServerPrincName    *uint16
  3417  	AuthnLevel         uint32
  3418  	ImpersonationLevel uint32
  3419  	AuthIdentityData   *COAUTHIDENTITY
  3420  	Capabilities       uint32
  3421  }
  3422  
  3423  type COSERVERINFO struct {
  3424  	Reserved1 uint32
  3425  	Aame      *uint16
  3426  	AuthInfo  *COAUTHINFO
  3427  	Reserved2 uint32
  3428  }
  3429  
  3430  type BIND_OPTS3 struct {
  3431  	CbStruct          uint32
  3432  	Flags             uint32
  3433  	Mode              uint32
  3434  	TickCountDeadline uint32
  3435  	TrackFlags        uint32
  3436  	ClassContext      uint32
  3437  	Locale            uint32
  3438  	ServerInfo        *COSERVERINFO
  3439  	Hwnd              HWND
  3440  }
  3441  
  3442  const (
  3443  	CLSCTX_INPROC_SERVER          = 0x1
  3444  	CLSCTX_INPROC_HANDLER         = 0x2
  3445  	CLSCTX_LOCAL_SERVER           = 0x4
  3446  	CLSCTX_INPROC_SERVER16        = 0x8
  3447  	CLSCTX_REMOTE_SERVER          = 0x10
  3448  	CLSCTX_INPROC_HANDLER16       = 0x20
  3449  	CLSCTX_RESERVED1              = 0x40
  3450  	CLSCTX_RESERVED2              = 0x80
  3451  	CLSCTX_RESERVED3              = 0x100
  3452  	CLSCTX_RESERVED4              = 0x200
  3453  	CLSCTX_NO_CODE_DOWNLOAD       = 0x400
  3454  	CLSCTX_RESERVED5              = 0x800
  3455  	CLSCTX_NO_CUSTOM_MARSHAL      = 0x1000
  3456  	CLSCTX_ENABLE_CODE_DOWNLOAD   = 0x2000
  3457  	CLSCTX_NO_FAILURE_LOG         = 0x4000
  3458  	CLSCTX_DISABLE_AAA            = 0x8000
  3459  	CLSCTX_ENABLE_AAA             = 0x10000
  3460  	CLSCTX_FROM_DEFAULT_CONTEXT   = 0x20000
  3461  	CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000
  3462  	CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
  3463  	CLSCTX_ENABLE_CLOAKING        = 0x100000
  3464  	CLSCTX_APPCONTAINER           = 0x400000
  3465  	CLSCTX_ACTIVATE_AAA_AS_IU     = 0x800000
  3466  	CLSCTX_PS_DLL                 = 0x80000000
  3467  
  3468  	COINIT_MULTITHREADED     = 0x0
  3469  	COINIT_APARTMENTTHREADED = 0x2
  3470  	COINIT_DISABLE_OLE1DDE   = 0x4
  3471  	COINIT_SPEED_OVER_MEMORY = 0x8
  3472  )
  3473  
  3474  // Flag for QueryFullProcessImageName.
  3475  const PROCESS_NAME_NATIVE = 1
  3476  
  3477  type ModuleInfo struct {
  3478  	BaseOfDll   uintptr
  3479  	SizeOfImage uint32
  3480  	EntryPoint  uintptr
  3481  }
  3482  
  3483  const ALL_PROCESSOR_GROUPS = 0xFFFF
  3484  
  3485  type Rect struct {
  3486  	Left   int32
  3487  	Top    int32
  3488  	Right  int32
  3489  	Bottom int32
  3490  }
  3491  
  3492  type GUIThreadInfo struct {
  3493  	Size        uint32
  3494  	Flags       uint32
  3495  	Active      HWND
  3496  	Focus       HWND
  3497  	Capture     HWND
  3498  	MenuOwner   HWND
  3499  	MoveSize    HWND
  3500  	CaretHandle HWND
  3501  	CaretRect   Rect
  3502  }
  3503  
  3504  const (
  3505  	DWMWA_NCRENDERING_ENABLED            = 1
  3506  	DWMWA_NCRENDERING_POLICY             = 2
  3507  	DWMWA_TRANSITIONS_FORCEDISABLED      = 3
  3508  	DWMWA_ALLOW_NCPAINT                  = 4
  3509  	DWMWA_CAPTION_BUTTON_BOUNDS          = 5
  3510  	DWMWA_NONCLIENT_RTL_LAYOUT           = 6
  3511  	DWMWA_FORCE_ICONIC_REPRESENTATION    = 7
  3512  	DWMWA_FLIP3D_POLICY                  = 8
  3513  	DWMWA_EXTENDED_FRAME_BOUNDS          = 9
  3514  	DWMWA_HAS_ICONIC_BITMAP              = 10
  3515  	DWMWA_DISALLOW_PEEK                  = 11
  3516  	DWMWA_EXCLUDED_FROM_PEEK             = 12
  3517  	DWMWA_CLOAK                          = 13
  3518  	DWMWA_CLOAKED                        = 14
  3519  	DWMWA_FREEZE_REPRESENTATION          = 15
  3520  	DWMWA_PASSIVE_UPDATE_MODE            = 16
  3521  	DWMWA_USE_HOSTBACKDROPBRUSH          = 17
  3522  	DWMWA_USE_IMMERSIVE_DARK_MODE        = 20
  3523  	DWMWA_WINDOW_CORNER_PREFERENCE       = 33
  3524  	DWMWA_BORDER_COLOR                   = 34
  3525  	DWMWA_CAPTION_COLOR                  = 35
  3526  	DWMWA_TEXT_COLOR                     = 36
  3527  	DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37
  3528  )
  3529  
  3530  type WSAQUERYSET struct {
  3531  	Size                uint32
  3532  	ServiceInstanceName *uint16
  3533  	ServiceClassId      *GUID
  3534  	Version             *WSAVersion
  3535  	Comment             *uint16
  3536  	NameSpace           uint32
  3537  	NSProviderId        *GUID
  3538  	Context             *uint16
  3539  	NumberOfProtocols   uint32
  3540  	AfpProtocols        *AFProtocols
  3541  	QueryString         *uint16
  3542  	NumberOfCsAddrs     uint32
  3543  	SaBuffer            *CSAddrInfo
  3544  	OutputFlags         uint32
  3545  	Blob                *BLOB
  3546  }
  3547  
  3548  type WSAVersion struct {
  3549  	Version                 uint32
  3550  	EnumerationOfComparison int32
  3551  }
  3552  
  3553  type AFProtocols struct {
  3554  	AddressFamily int32
  3555  	Protocol      int32
  3556  }
  3557  
  3558  type CSAddrInfo struct {
  3559  	LocalAddr  SocketAddress
  3560  	RemoteAddr SocketAddress
  3561  	SocketType int32
  3562  	Protocol   int32
  3563  }
  3564  
  3565  type BLOB struct {
  3566  	Size     uint32
  3567  	BlobData *byte
  3568  }
  3569  
  3570  type ComStat struct {
  3571  	Flags    uint32
  3572  	CBInQue  uint32
  3573  	CBOutQue uint32
  3574  }
  3575  
  3576  type DCB struct {
  3577  	DCBlength  uint32
  3578  	BaudRate   uint32
  3579  	Flags      uint32
  3580  	wReserved  uint16
  3581  	XonLim     uint16
  3582  	XoffLim    uint16
  3583  	ByteSize   uint8
  3584  	Parity     uint8
  3585  	StopBits   uint8
  3586  	XonChar    byte
  3587  	XoffChar   byte
  3588  	ErrorChar  byte
  3589  	EofChar    byte
  3590  	EvtChar    byte
  3591  	wReserved1 uint16
  3592  }
  3593  
  3594  // Keyboard Layout Flags.
  3595  // See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw
  3596  const (
  3597  	KLF_ACTIVATE      = 0x00000001
  3598  	KLF_SUBSTITUTE_OK = 0x00000002
  3599  	KLF_REORDER       = 0x00000008
  3600  	KLF_REPLACELANG   = 0x00000010
  3601  	KLF_NOTELLSHELL   = 0x00000080
  3602  	KLF_SETFORPROCESS = 0x00000100
  3603  )
  3604  

View as plain text