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