1 /***********************************************************************\ 2 * winnt.d * 3 * * 4 * Windows API header module * 5 * * 6 * Translated from MinGW API for MS-Windows 3.12 * 7 * * 8 * Placed into public domain * 9 \***********************************************************************/ 10 module win32.winnt; 11 12 public import win32.basetsd, win32.windef, win32.winerror; 13 private import win32.w32api; 14 15 /* Translation Notes: 16 The following macros are unneeded for D: 17 FIELD_OFFSET(t,f), CONTAINING_RECORD(address, type, field) 18 */ 19 20 alias void VOID; 21 alias char CHAR, CCHAR; 22 alias wchar WCHAR; 23 alias bool BOOLEAN; 24 alias byte FCHAR; 25 alias ubyte UCHAR; 26 alias short SHORT; 27 alias ushort LANGID, FSHORT; 28 alias uint LCID, FLONG, ACCESS_MASK; 29 alias long LONGLONG, USN; 30 alias ulong DWORDLONG, ULONGLONG; 31 32 alias void* PVOID, LPVOID; 33 alias char* PSZ, PCHAR, PCCHAR, LPCH, PCH, LPSTR, PSTR; 34 alias wchar* PWCHAR, LPWCH, PWCH, LPWSTR, PWSTR; 35 alias bool* PBOOLEAN; 36 alias ubyte* PUCHAR; 37 alias short* PSHORT; 38 alias int* PLONG; 39 alias uint* PLCID, PACCESS_MASK; 40 alias long* PLONGLONG; 41 alias ulong* PDWORDLONG, PULONGLONG; 42 43 // FIXME(MinGW) for __WIN64 44 alias void* PVOID64; 45 46 // const versions 47 alias CPtr!(char) LPCCH, PCSTR, LPCSTR; 48 alias CPtr!(wchar) LPCWCH, PCWCH, LPCWSTR, PCWSTR; 49 50 version (Unicode) { 51 alias WCHAR TCHAR, _TCHAR; 52 } else { 53 alias CHAR TCHAR, _TCHAR; 54 } 55 56 alias TCHAR TBYTE; 57 alias TCHAR* PTCH, PTBYTE, LPTCH, PTSTR, LPTSTR, LP, PTCHAR; 58 alias CPtr!(TCHAR) LPCTSTR; 59 60 const char ANSI_NULL = '\0'; 61 const wchar UNICODE_NULL = '\0'; 62 63 const APPLICATION_ERROR_MASK = 0x20000000; 64 const ERROR_SEVERITY_SUCCESS = 0x00000000; 65 const ERROR_SEVERITY_INFORMATIONAL = 0x40000000; 66 const ERROR_SEVERITY_WARNING = 0x80000000; 67 const ERROR_SEVERITY_ERROR = 0xC0000000; 68 69 // MinGW: also in ddk/ntifs.h 70 enum : USHORT { 71 COMPRESSION_FORMAT_NONE = 0x0000, 72 COMPRESSION_FORMAT_DEFAULT = 0x0001, 73 COMPRESSION_FORMAT_LZNT1 = 0x0002, 74 COMPRESSION_ENGINE_STANDARD = 0x0000, 75 COMPRESSION_ENGINE_MAXIMUM = 0x0100, 76 COMPRESSION_ENGINE_HIBER = 0x0200 77 } 78 79 // ACCESS_DENIED_OBJECT_ACE, etc 80 const DWORD 81 ACE_OBJECT_TYPE_PRESENT = 0x00000001, 82 ACE_INHERITED_OBJECT_TYPE_PRESENT = 0x00000002; 83 84 // ACE_HEADER.AceType 85 // also in ddk/ntifs.h 86 enum : BYTE { 87 ACCESS_ALLOWED_ACE_TYPE, 88 ACCESS_DENIED_ACE_TYPE, 89 SYSTEM_AUDIT_ACE_TYPE, 90 SYSTEM_ALARM_ACE_TYPE 91 } 92 93 // ACE_HEADER.AceFlags 94 const BYTE 95 OBJECT_INHERIT_ACE = 0x01, 96 CONTAINER_INHERIT_ACE = 0x02, 97 NO_PROPAGATE_INHERIT_ACE = 0x04, 98 INHERIT_ONLY_ACE = 0x08, 99 INHERITED_ACE = 0x10, 100 VALID_INHERIT_FLAGS = 0x1F, 101 SUCCESSFUL_ACCESS_ACE_FLAG = 0x40, 102 FAILED_ACCESS_ACE_FLAG = 0x80; 103 104 // Access Mask Format 105 const ACCESS_MASK 106 DELETE = 0x00010000, 107 READ_CONTROL = 0x00020000, 108 WRITE_DAC = 0x00040000, 109 WRITE_OWNER = 0x00080000, 110 SYNCHRONIZE = 0x00100000, 111 ACCESS_SYSTEM_SECURITY = 0x01000000, 112 MAXIMUM_ALLOWED = 0x02000000, 113 GENERIC_READ = 0x80000000, 114 GENERIC_WRITE = 0x40000000, 115 GENERIC_EXECUTE = 0x20000000, 116 GENERIC_ALL = 0x10000000, 117 STANDARD_RIGHTS_REQUIRED = 0x000F0000, 118 STANDARD_RIGHTS_READ = 0x00020000, 119 STANDARD_RIGHTS_WRITE = 0x00020000, 120 STANDARD_RIGHTS_EXECUTE = 0x00020000, 121 STANDARD_RIGHTS_ALL = 0x001F0000, 122 SPECIFIC_RIGHTS_ALL = 0x0000FFFF; 123 124 125 const DWORD INVALID_FILE_ATTRIBUTES = -1; 126 127 // MinGW: Also in ddk/winddk.h 128 const DWORD 129 FILE_LIST_DIRECTORY = 0x00000001, 130 FILE_READ_DATA = 0x00000001, 131 FILE_ADD_FILE = 0x00000002, 132 FILE_WRITE_DATA = 0x00000002, 133 FILE_ADD_SUBDIRECTORY = 0x00000004, 134 FILE_APPEND_DATA = 0x00000004, 135 FILE_CREATE_PIPE_INSTANCE = 0x00000004, 136 FILE_READ_EA = 0x00000008, 137 FILE_READ_PROPERTIES = 0x00000008, 138 FILE_WRITE_EA = 0x00000010, 139 FILE_WRITE_PROPERTIES = 0x00000010, 140 FILE_EXECUTE = 0x00000020, 141 FILE_TRAVERSE = 0x00000020, 142 FILE_DELETE_CHILD = 0x00000040, 143 FILE_READ_ATTRIBUTES = 0x00000080, 144 FILE_WRITE_ATTRIBUTES = 0x00000100; 145 146 const DWORD 147 FILE_SHARE_READ = 0x00000001, 148 FILE_SHARE_WRITE = 0x00000002, 149 FILE_SHARE_DELETE = 0x00000004, 150 FILE_SHARE_VALID_FLAGS = 0x00000007; 151 152 const DWORD 153 FILE_ATTRIBUTE_READONLY = 0x00000001, 154 FILE_ATTRIBUTE_HIDDEN = 0x00000002, 155 FILE_ATTRIBUTE_SYSTEM = 0x00000004, 156 FILE_ATTRIBUTE_DIRECTORY = 0x00000010, 157 FILE_ATTRIBUTE_ARCHIVE = 0x00000020, 158 FILE_ATTRIBUTE_DEVICE = 0x00000040, 159 FILE_ATTRIBUTE_NORMAL = 0x00000080, 160 FILE_ATTRIBUTE_TEMPORARY = 0x00000100, 161 FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200, 162 FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400, 163 FILE_ATTRIBUTE_COMPRESSED = 0x00000800, 164 FILE_ATTRIBUTE_OFFLINE = 0x00001000, 165 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000, 166 FILE_ATTRIBUTE_ENCRYPTED = 0x00004000, 167 FILE_ATTRIBUTE_VALID_FLAGS = 0x00007fb7, 168 FILE_ATTRIBUTE_VALID_SET_FLAGS = 0x000031a7; 169 170 // These are not documented on MSDN 171 const FILE_COPY_STRUCTURED_STORAGE = 0x00000041; 172 const FILE_STRUCTURED_STORAGE = 0x00000441; 173 174 // Nor are these 175 const FILE_VALID_OPTION_FLAGS = 0x00ffffff; 176 const FILE_VALID_PIPE_OPTION_FLAGS = 0x00000032; 177 const FILE_VALID_MAILSLOT_OPTION_FLAGS = 0x00000032; 178 const FILE_VALID_SET_FLAGS = 0x00000036; 179 180 const ULONG 181 FILE_SUPERSEDE = 0x00000000, 182 FILE_OPEN = 0x00000001, 183 FILE_CREATE = 0x00000002, 184 FILE_OPEN_IF = 0x00000003, 185 FILE_OVERWRITE = 0x00000004, 186 FILE_OVERWRITE_IF = 0x00000005, 187 FILE_MAXIMUM_DISPOSITION = 0x00000005; 188 189 const ULONG 190 FILE_DIRECTORY_FILE = 0x00000001, 191 FILE_WRITE_THROUGH = 0x00000002, 192 FILE_SEQUENTIAL_ONLY = 0x00000004, 193 FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008, 194 FILE_SYNCHRONOUS_IO_ALERT = 0x00000010, 195 FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020, 196 FILE_NON_DIRECTORY_FILE = 0x00000040, 197 FILE_CREATE_TREE_CONNECTION = 0x00000080, 198 FILE_COMPLETE_IF_OPLOCKED = 0x00000100, 199 FILE_NO_EA_KNOWLEDGE = 0x00000200, 200 FILE_OPEN_FOR_RECOVERY = 0x00000400, 201 FILE_RANDOM_ACCESS = 0x00000800, 202 FILE_DELETE_ON_CLOSE = 0x00001000, 203 FILE_OPEN_BY_FILE_ID = 0x00002000, 204 FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000, 205 FILE_NO_COMPRESSION = 0x00008000, 206 FILE_RESERVE_OPFILTER = 0x00100000, 207 FILE_OPEN_REPARSE_POINT = 0x00200000, 208 FILE_OPEN_NO_RECALL = 0x00400000, 209 FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000; 210 211 212 const ACCESS_MASK 213 FILE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x01FF, 214 FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES 215 | FILE_EXECUTE | SYNCHRONIZE, 216 FILE_GENERIC_READ = STANDARD_RIGHTS_READ | FILE_READ_DATA 217 | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE, 218 FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA 219 | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA 220 | SYNCHRONIZE; 221 222 // MinGW: end winddk.h 223 // MinGW: also in ddk/ntifs.h 224 const DWORD 225 FILE_NOTIFY_CHANGE_FILE_NAME = 0x00000001, 226 FILE_NOTIFY_CHANGE_DIR_NAME = 0x00000002, 227 FILE_NOTIFY_CHANGE_NAME = 0x00000003, 228 FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x00000004, 229 FILE_NOTIFY_CHANGE_SIZE = 0x00000008, 230 FILE_NOTIFY_CHANGE_LAST_WRITE = 0x00000010, 231 FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x00000020, 232 FILE_NOTIFY_CHANGE_CREATION = 0x00000040, 233 FILE_NOTIFY_CHANGE_EA = 0x00000080, 234 FILE_NOTIFY_CHANGE_SECURITY = 0x00000100, 235 FILE_NOTIFY_CHANGE_STREAM_NAME = 0x00000200, 236 FILE_NOTIFY_CHANGE_STREAM_SIZE = 0x00000400, 237 FILE_NOTIFY_CHANGE_STREAM_WRITE = 0x00000800, 238 FILE_NOTIFY_VALID_MASK = 0x00000fff; 239 240 const DWORD 241 FILE_CASE_SENSITIVE_SEARCH = 0x00000001, 242 FILE_CASE_PRESERVED_NAMES = 0x00000002, 243 FILE_UNICODE_ON_DISK = 0x00000004, 244 FILE_PERSISTENT_ACLS = 0x00000008, 245 FILE_FILE_COMPRESSION = 0x00000010, 246 FILE_VOLUME_QUOTAS = 0x00000020, 247 FILE_SUPPORTS_SPARSE_FILES = 0x00000040, 248 FILE_SUPPORTS_REPARSE_POINTS = 0x00000080, 249 FILE_SUPPORTS_REMOTE_STORAGE = 0x00000100, 250 FS_LFN_APIS = 0x00004000, 251 FILE_VOLUME_IS_COMPRESSED = 0x00008000, 252 FILE_SUPPORTS_OBJECT_IDS = 0x00010000, 253 FILE_SUPPORTS_ENCRYPTION = 0x00020000, 254 FILE_NAMED_STREAMS = 0x00040000, 255 FILE_READ_ONLY_VOLUME = 0x00080000, 256 FILE_SEQUENTIAL_WRITE_ONCE = 0x00100000, 257 FILE_SUPPORTS_TRANSACTIONS = 0x00200000; 258 259 // These are not documented on MSDN 260 const ACCESS_MASK 261 IO_COMPLETION_QUERY_STATE = 1, 262 IO_COMPLETION_MODIFY_STATE = 2, 263 IO_COMPLETION_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 3; 264 // MinGW: end ntifs.h 265 266 // MinGW: also in ddk/winddk.h 267 const DWORD 268 DUPLICATE_CLOSE_SOURCE = 1, 269 DUPLICATE_SAME_ACCESS = 2, 270 DUPLICATE_SAME_ATTRIBUTES = 4; 271 // MinGW: end winddk.k 272 273 const DWORD 274 MAILSLOT_NO_MESSAGE = -1, 275 MAILSLOT_WAIT_FOREVER = -1; 276 277 const ACCESS_MASK 278 PROCESS_TERMINATE = 0x0001, 279 PROCESS_CREATE_THREAD = 0x0002, 280 PROCESS_SET_SESSIONID = 0x0004, 281 PROCESS_VM_OPERATION = 0x0008, 282 PROCESS_VM_READ = 0x0010, 283 PROCESS_VM_WRITE = 0x0020, 284 PROCESS_DUP_HANDLE = 0x0040, 285 PROCESS_CREATE_PROCESS = 0x0080, 286 PROCESS_SET_QUOTA = 0x0100, 287 PROCESS_SET_INFORMATION = 0x0200, 288 PROCESS_QUERY_INFORMATION = 0x0400, 289 PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x0FFF; 290 291 const ACCESS_MASK 292 THREAD_TERMINATE = 0x0001, 293 THREAD_SUSPEND_RESUME = 0x0002, 294 THREAD_GET_CONTEXT = 0x0008, 295 THREAD_SET_CONTEXT = 0x0010, 296 THREAD_SET_INFORMATION = 0x0020, 297 THREAD_QUERY_INFORMATION = 0x0040, 298 THREAD_SET_THREAD_TOKEN = 0x0080, 299 THREAD_IMPERSONATE = 0x0100, 300 THREAD_DIRECT_IMPERSONATION = 0x0200, 301 THREAD_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3FF; 302 303 // These are not documented on MSDN 304 const THREAD_BASE_PRIORITY_LOWRT = 15; 305 const THREAD_BASE_PRIORITY_MAX = 2; 306 const THREAD_BASE_PRIORITY_MIN = -2; 307 const THREAD_BASE_PRIORITY_IDLE = -15; 308 309 const DWORD EXCEPTION_NONCONTINUABLE = 1; 310 const size_t EXCEPTION_MAXIMUM_PARAMETERS = 15; 311 312 // These are not documented on MSDN 313 const ACCESS_MASK 314 MUTANT_QUERY_STATE = 1, 315 MUTANT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE; 316 317 const ACCESS_MASK 318 TIMER_QUERY_STATE = 1, 319 TIMER_MODIFY_STATE = 2, 320 TIMER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE 321 | TIMER_MODIFY_STATE; 322 323 const SID_IDENTIFIER_AUTHORITY 324 SECURITY_NULL_SID_AUTHORITY = {[5: 0]}, 325 SECURITY_WORLD_SID_AUTHORITY = {[5: 1]}, 326 SECURITY_LOCAL_SID_AUTHORITY = {[5: 2]}, 327 SECURITY_CREATOR_SID_AUTHORITY = {[5: 3]}, 328 SECURITY_NON_UNIQUE_AUTHORITY = {[5: 4]}, 329 SECURITY_NT_AUTHORITY = {[5: 5]}, 330 SECURITY_MANDATORY_LABEL_AUTHORITY = {[5: 6]}; 331 332 const DWORD 333 SECURITY_NULL_RID = 0, 334 SECURITY_WORLD_RID = 0, 335 SECURITY_LOCAL_RID = 0, 336 SECURITY_CREATOR_OWNER_RID = 0, 337 SECURITY_CREATOR_GROUP_RID = 1, 338 SECURITY_DIALUP_RID = 1, 339 SECURITY_NETWORK_RID = 2, 340 SECURITY_BATCH_RID = 3, 341 SECURITY_INTERACTIVE_RID = 4, 342 SECURITY_LOGON_IDS_RID = 5, 343 SECURITY_SERVICE_RID = 6, 344 SECURITY_LOCAL_SYSTEM_RID = 18, 345 SECURITY_BUILTIN_DOMAIN_RID = 32, 346 SECURITY_PRINCIPAL_SELF_RID = 10, 347 SECURITY_CREATOR_OWNER_SERVER_RID = 2, 348 SECURITY_CREATOR_GROUP_SERVER_RID = 3, 349 SECURITY_LOGON_IDS_RID_COUNT = 3, 350 SECURITY_ANONYMOUS_LOGON_RID = 7, 351 SECURITY_PROXY_RID = 8, 352 SECURITY_ENTERPRISE_CONTROLLERS_RID = 9, 353 SECURITY_SERVER_LOGON_RID = SECURITY_ENTERPRISE_CONTROLLERS_RID, 354 SECURITY_AUTHENTICATED_USER_RID = 11, 355 SECURITY_RESTRICTED_CODE_RID = 12, 356 SECURITY_NT_NON_UNIQUE_RID = 21, 357 SID_REVISION = 1; 358 359 enum : DWORD { 360 DOMAIN_USER_RID_ADMIN = 0x01F4, 361 DOMAIN_USER_RID_GUEST = 0x01F5, 362 DOMAIN_GROUP_RID_ADMINS = 0x0200, 363 DOMAIN_GROUP_RID_USERS = 0x0201, 364 DOMAIN_ALIAS_RID_ADMINS = 0x0220, 365 DOMAIN_ALIAS_RID_USERS = 0x0221, 366 DOMAIN_ALIAS_RID_GUESTS = 0x0222, 367 DOMAIN_ALIAS_RID_POWER_USERS = 0x0223, 368 DOMAIN_ALIAS_RID_ACCOUNT_OPS = 0x0224, 369 DOMAIN_ALIAS_RID_SYSTEM_OPS = 0x0225, 370 DOMAIN_ALIAS_RID_PRINT_OPS = 0x0226, 371 DOMAIN_ALIAS_RID_BACKUP_OPS = 0x0227, 372 DOMAIN_ALIAS_RID_REPLICATOR = 0x0228 373 } 374 375 enum : WORD { 376 SECURITY_MANDATORY_UNTRUSTED_RID = 0, 377 SECURITY_MANDATORY_LOW_RID = 0x1000, 378 SECURITY_MANDATORY_MEDIUM_RID = 0x2000, 379 SECURITY_MANDATORY_HIGH_RID = 0x3000, 380 SECURITY_MANDATORY_SYSTEM_RID = 0x4000, 381 SECURITY_MANDATORY_PROTECTED_PROCESS_RID = 0x5000, 382 SECURITY_MANDATORY_MAXIMUM_USER_RID = SECURITY_MANDATORY_SYSTEM_RID 383 } 384 385 const TCHAR[] 386 SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege", 387 SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege", 388 SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege", 389 SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege", 390 SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege", 391 SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege", 392 SE_TCB_NAME = "SeTcbPrivilege", 393 SE_SECURITY_NAME = "SeSecurityPrivilege", 394 SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege", 395 SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege", 396 SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege", 397 SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege", 398 SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege", 399 SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege", 400 SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege", 401 SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege", 402 SE_BACKUP_NAME = "SeBackupPrivilege", 403 SE_RESTORE_NAME = "SeRestorePrivilege", 404 SE_SHUTDOWN_NAME = "SeShutdownPrivilege", 405 SE_DEBUG_NAME = "SeDebugPrivilege", 406 SE_AUDIT_NAME = "SeAuditPrivilege", 407 SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege", 408 SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege", 409 SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege", 410 SE_CREATE_GLOBAL_NAME = "SeCreateGlobalPrivilege", 411 SE_UNDOCK_NAME = "SeUndockPrivilege", 412 SE_MANAGE_VOLUME_NAME = "SeManageVolumePrivilege", 413 SE_IMPERSONATE_NAME = "SeImpersonatePrivilege", 414 SE_ENABLE_DELEGATION_NAME = "SeEnableDelegationPrivilege", 415 SE_SYNC_AGENT_NAME = "SeSyncAgentPrivilege", 416 SE_TRUSTED_CREDMAN_ACCESS_NAME = "SeTrustedCredManAccessPrivilege", 417 SE_RELABEL_NAME = "SeRelabelPrivilege", 418 SE_INCREASE_WORKING_SET_NAME = "SeIncreaseWorkingSetPrivilege", 419 SE_TIME_ZONE_NAME = "SeTimeZonePrivilege", 420 SE_CREATE_SYMBOLIC_LINK_NAME = "SeCreateSymbolicLinkPrivilege"; 421 422 const DWORD 423 SE_GROUP_MANDATORY = 0x00000001, 424 SE_GROUP_ENABLED_BY_DEFAULT = 0x00000002, 425 SE_GROUP_ENABLED = 0x00000004, 426 SE_GROUP_OWNER = 0x00000008, 427 SE_GROUP_USE_FOR_DENY_ONLY = 0x00000010, 428 SE_GROUP_INTEGRITY = 0x00000020, 429 SE_GROUP_INTEGRITY_ENABLED = 0x00000040, 430 SE_GROUP_RESOURCE = 0x20000000, 431 SE_GROUP_LOGON_ID = 0xC0000000; 432 433 // Primary language identifiers 434 enum : USHORT { 435 LANG_NEUTRAL, 436 LANG_ARABIC, 437 LANG_BULGARIAN, 438 LANG_CATALAN, 439 LANG_CHINESE, 440 LANG_CZECH, 441 LANG_DANISH, 442 LANG_GERMAN, 443 LANG_GREEK, 444 LANG_ENGLISH, 445 LANG_SPANISH, 446 LANG_FINNISH, 447 LANG_FRENCH, 448 LANG_HEBREW, 449 LANG_HUNGARIAN, 450 LANG_ICELANDIC, 451 LANG_ITALIAN, 452 LANG_JAPANESE, 453 LANG_KOREAN, 454 LANG_DUTCH, 455 LANG_NORWEGIAN, 456 LANG_POLISH, 457 LANG_PORTUGUESE, // = 0x16 458 LANG_ROMANIAN = 0x18, 459 LANG_RUSSIAN, 460 LANG_CROATIAN, // = 0x1A 461 LANG_SERBIAN = 0x1A, 462 LANG_BOSNIAN = 0x1A, 463 LANG_SLOVAK, 464 LANG_ALBANIAN, 465 LANG_SWEDISH, 466 LANG_THAI, 467 LANG_TURKISH, 468 LANG_URDU, 469 LANG_INDONESIAN, 470 LANG_UKRAINIAN, 471 LANG_BELARUSIAN, 472 LANG_SLOVENIAN, 473 LANG_ESTONIAN, 474 LANG_LATVIAN, 475 LANG_LITHUANIAN, // = 0x27 476 LANG_FARSI = 0x29, 477 LANG_PERSIAN = 0x29, 478 LANG_VIETNAMESE, 479 LANG_ARMENIAN, 480 LANG_AZERI, 481 LANG_BASQUE, 482 LANG_LOWER_SORBIAN, // = 0x2E 483 LANG_UPPER_SORBIAN = 0x2E, 484 LANG_MACEDONIAN, // = 0x2F 485 LANG_TSWANA = 0x32, 486 LANG_XHOSA = 0x34, 487 LANG_ZULU, 488 LANG_AFRIKAANS, 489 LANG_GEORGIAN, 490 LANG_FAEROESE, 491 LANG_HINDI, 492 LANG_MALTESE, 493 LANG_SAMI, 494 LANG_IRISH, // = 0x3C 495 LANG_MALAY = 0x3E, 496 LANG_KAZAK, 497 LANG_KYRGYZ, 498 LANG_SWAHILI, // = 0x41 499 LANG_UZBEK = 0x43, 500 LANG_TATAR, 501 LANG_BENGALI, 502 LANG_PUNJABI, 503 LANG_GUJARATI, 504 LANG_ORIYA, 505 LANG_TAMIL, 506 LANG_TELUGU, 507 LANG_KANNADA, 508 LANG_MALAYALAM, 509 LANG_ASSAMESE, 510 LANG_MARATHI, 511 LANG_SANSKRIT, 512 LANG_MONGOLIAN, 513 LANG_TIBETAN, 514 LANG_WELSH, 515 LANG_KHMER, 516 LANG_LAO, // = 0x54 517 LANG_GALICIAN = 0x56, 518 LANG_KONKANI, 519 LANG_MANIPURI, 520 LANG_SINDHI, 521 LANG_SYRIAC, 522 LANG_SINHALESE, // = 0x5B 523 LANG_INUKTITUT = 0x5D, 524 LANG_AMHARIC, 525 LANG_TAMAZIGHT, 526 LANG_KASHMIRI, 527 LANG_NEPALI, 528 LANG_FRISIAN, 529 LANG_PASHTO, 530 LANG_FILIPINO, 531 LANG_DIVEHI, // = 0x65 532 LANG_HAUSA = 0x68, 533 LANG_YORUBA = 0x6A, 534 LANG_QUECHUA, 535 LANG_SOTHO, 536 LANG_BASHKIR, 537 LANG_LUXEMBOURGISH, 538 LANG_GREENLANDIC, 539 LANG_IGBO, // = 0x70 540 LANG_TIGRIGNA = 0x73, 541 LANG_YI = 0x78, 542 LANG_MAPUDUNGUN = 0x7A, 543 LANG_MOHAWK = 0x7C, 544 LANG_BRETON = 0x7E, 545 LANG_UIGHUR = 0x80, 546 LANG_MAORI, 547 LANG_OCCITAN, 548 LANG_CORSICAN, 549 LANG_ALSATIAN, 550 LANG_YAKUT, 551 LANG_KICHE, 552 LANG_KINYARWANDA, 553 LANG_WOLOF, // = 0x88 554 LANG_DARI = 0x8C, 555 LANG_MALAGASY, // = 0x8D 556 557 LANG_SERBIAN_NEUTRAL = 0x7C1A, 558 LANG_BOSNIAN_NEUTRAL = 0x781A, 559 560 LANG_INVARIANT = 0x7F 561 } 562 563 564 // Sublanguage identifiers 565 enum : USHORT { 566 SUBLANG_NEUTRAL, 567 SUBLANG_DEFAULT, 568 SUBLANG_SYS_DEFAULT, 569 SUBLANG_CUSTOM_DEFAULT, // = 3 570 SUBLANG_UI_CUSTOM_DEFAULT = 3, 571 SUBLANG_CUSTOM_UNSPECIFIED, // = 4 572 573 SUBLANG_AFRIKAANS_SOUTH_AFRICA = 1, 574 SUBLANG_ALBANIAN_ALBANIA = 1, 575 SUBLANG_ALSATIAN_FRANCE = 1, 576 SUBLANG_AMHARIC_ETHIOPIA = 1, 577 578 SUBLANG_ARABIC_SAUDI_ARABIA = 1, 579 SUBLANG_ARABIC_IRAQ, 580 SUBLANG_ARABIC_EGYPT, 581 SUBLANG_ARABIC_LIBYA, 582 SUBLANG_ARABIC_ALGERIA, 583 SUBLANG_ARABIC_MOROCCO, 584 SUBLANG_ARABIC_TUNISIA, 585 SUBLANG_ARABIC_OMAN, 586 SUBLANG_ARABIC_YEMEN, 587 SUBLANG_ARABIC_SYRIA, 588 SUBLANG_ARABIC_JORDAN, 589 SUBLANG_ARABIC_LEBANON, 590 SUBLANG_ARABIC_KUWAIT, 591 SUBLANG_ARABIC_UAE, 592 SUBLANG_ARABIC_BAHRAIN, 593 SUBLANG_ARABIC_QATAR, // = 16 594 595 SUBLANG_ARMENIAN_ARMENIA = 1, 596 SUBLANG_ASSAMESE_INDIA = 1, 597 598 SUBLANG_AZERI_LATIN = 1, 599 SUBLANG_AZERI_CYRILLIC, // = 2 600 601 SUBLANG_BASHKIR_RUSSIA = 1, 602 SUBLANG_BASQUE_BASQUE = 1, 603 SUBLANG_BELARUSIAN_BELARUS = 1, 604 SUBLANG_BENGALI_INDIA = 1, 605 606 SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN = 5, 607 SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC = 8, 608 609 SUBLANG_BRETON_FRANCE = 1, 610 SUBLANG_BULGARIAN_BULGARIA = 1, 611 SUBLANG_CATALAN_CATALAN = 1, 612 613 SUBLANG_CHINESE_TRADITIONAL = 1, 614 SUBLANG_CHINESE_SIMPLIFIED, 615 SUBLANG_CHINESE_HONGKONG, 616 SUBLANG_CHINESE_SINGAPORE, 617 SUBLANG_CHINESE_MACAU, // = 5 618 619 SUBLANG_CORSICAN_FRANCE = 1, 620 621 SUBLANG_CROATIAN_CROATIA = 1, 622 SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN = 4, 623 624 SUBLANG_CZECH_CZECH_REPUBLIC = 1, 625 SUBLANG_DANISH_DENMARK = 1, 626 SUBLANG_DIVEHI_MALDIVES = 1, 627 628 SUBLANG_DUTCH = 1, 629 SUBLANG_DUTCH_BELGIAN, // = 2 630 631 SUBLANG_ENGLISH_US = 1, 632 SUBLANG_ENGLISH_UK, 633 SUBLANG_ENGLISH_AUS, 634 SUBLANG_ENGLISH_CAN, 635 SUBLANG_ENGLISH_NZ, 636 SUBLANG_ENGLISH_EIRE, // = 6 637 SUBLANG_ENGLISH_IRELAND = 6, 638 SUBLANG_ENGLISH_SOUTH_AFRICA, 639 SUBLANG_ENGLISH_JAMAICA, 640 SUBLANG_ENGLISH_CARIBBEAN, 641 SUBLANG_ENGLISH_BELIZE, 642 SUBLANG_ENGLISH_TRINIDAD, 643 SUBLANG_ENGLISH_ZIMBABWE, 644 SUBLANG_ENGLISH_PHILIPPINES, // = 13 645 SUBLANG_ENGLISH_INDIA = 16, 646 SUBLANG_ENGLISH_MALAYSIA, 647 SUBLANG_ENGLISH_SINGAPORE, // = 18 648 649 SUBLANG_ESTONIAN_ESTONIA = 1, 650 SUBLANG_FAEROESE_FAROE_ISLANDS = 1, 651 SUBLANG_FILIPINO_PHILIPPINES = 1, 652 SUBLANG_FINNISH_FINLAND = 1, 653 654 SUBLANG_FRENCH = 1, 655 SUBLANG_FRENCH_BELGIAN, 656 SUBLANG_FRENCH_CANADIAN, 657 SUBLANG_FRENCH_SWISS, 658 SUBLANG_FRENCH_LUXEMBOURG, 659 SUBLANG_FRENCH_MONACO, // = 6 660 661 SUBLANG_FRISIAN_NETHERLANDS = 1, 662 SUBLANG_GALICIAN_GALICIAN = 1, 663 SUBLANG_GEORGIAN_GEORGIA = 1, 664 665 SUBLANG_GERMAN = 1, 666 SUBLANG_GERMAN_SWISS, 667 SUBLANG_GERMAN_AUSTRIAN, 668 SUBLANG_GERMAN_LUXEMBOURG, 669 SUBLANG_GERMAN_LIECHTENSTEIN, // = 5 670 671 SUBLANG_GREEK_GREECE = 1, 672 SUBLANG_GREENLANDIC_GREENLAND = 1, 673 SUBLANG_GUJARATI_INDIA = 1, 674 SUBLANG_HAUSA_NIGERIA = 1, 675 SUBLANG_HEBREW_ISRAEL = 1, 676 SUBLANG_HINDI_INDIA = 1, 677 SUBLANG_HUNGARIAN_HUNGARY = 1, 678 SUBLANG_ICELANDIC_ICELAND = 1, 679 SUBLANG_IGBO_NIGERIA = 1, 680 SUBLANG_INDONESIAN_INDONESIA = 1, 681 682 SUBLANG_INUKTITUT_CANADA = 1, 683 SUBLANG_INUKTITUT_CANADA_LATIN = 1, 684 685 SUBLANG_IRISH_IRELAND = 1, 686 687 SUBLANG_ITALIAN = 1, 688 SUBLANG_ITALIAN_SWISS, // = 2 689 690 SUBLANG_JAPANESE_JAPAN = 1, 691 692 SUBLANG_KASHMIRI_INDIA = 2, 693 SUBLANG_KASHMIRI_SASIA = 2, 694 695 SUBLANG_KAZAK_KAZAKHSTAN = 1, 696 SUBLANG_KHMER_CAMBODIA = 1, 697 SUBLANG_KICHE_GUATEMALA = 1, 698 SUBLANG_KINYARWANDA_RWANDA = 1, 699 SUBLANG_KONKANI_INDIA = 1, 700 SUBLANG_KOREAN = 1, 701 SUBLANG_KYRGYZ_KYRGYZSTAN = 1, 702 SUBLANG_LAO_LAO_PDR = 1, 703 SUBLANG_LATVIAN_LATVIA = 1, 704 705 SUBLANG_LITHUANIAN = 1, 706 SUBLANG_LITHUANIAN_LITHUANIA = 1, 707 708 SUBLANG_LOWER_SORBIAN_GERMANY = 1, 709 SUBLANG_LUXEMBOURGISH_LUXEMBOURG = 1, 710 SUBLANG_MACEDONIAN_MACEDONIA = 1, 711 SUBLANG_MALAYALAM_INDIA = 1, 712 SUBLANG_MALTESE_MALTA = 1, 713 SUBLANG_MAORI_NEW_ZEALAND = 1, 714 SUBLANG_MAPUDUNGUN_CHILE = 1, 715 SUBLANG_MARATHI_INDIA = 1, 716 SUBLANG_MOHAWK_MOHAWK = 1, 717 718 SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA = 1, 719 SUBLANG_MONGOLIAN_PRC, // = 2 720 721 SUBLANG_MALAY_MALAYSIA = 1, 722 SUBLANG_MALAY_BRUNEI_DARUSSALAM, // = 2 723 724 SUBLANG_NEPALI_NEPAL = 1, 725 SUBLANG_NEPALI_INDIA, // = 2 726 727 SUBLANG_NORWEGIAN_BOKMAL = 1, 728 SUBLANG_NORWEGIAN_NYNORSK, // = 2 729 730 SUBLANG_OCCITAN_FRANCE = 1, 731 SUBLANG_ORIYA_INDIA = 1, 732 SUBLANG_PASHTO_AFGHANISTAN = 1, 733 SUBLANG_PERSIAN_IRAN = 1, 734 SUBLANG_POLISH_POLAND = 1, 735 736 SUBLANG_PORTUGUESE_BRAZILIAN = 1, 737 SUBLANG_PORTUGUESE = 2, 738 SUBLANG_PORTUGUESE_PORTUGAL, // = 2 739 740 SUBLANG_PUNJABI_INDIA = 1, 741 742 SUBLANG_QUECHUA_BOLIVIA = 1, 743 SUBLANG_QUECHUA_ECUADOR, 744 SUBLANG_QUECHUA_PERU, // = 3 745 746 SUBLANG_ROMANIAN_ROMANIA = 1, 747 SUBLANG_ROMANSH_SWITZERLAND = 1, 748 SUBLANG_RUSSIAN_RUSSIA = 1, 749 750 SUBLANG_SAMI_NORTHERN_NORWAY = 1, 751 SUBLANG_SAMI_NORTHERN_SWEDEN, 752 SUBLANG_SAMI_NORTHERN_FINLAND, // = 3 753 SUBLANG_SAMI_SKOLT_FINLAND = 3, 754 SUBLANG_SAMI_INARI_FINLAND = 3, 755 SUBLANG_SAMI_LULE_NORWAY, 756 SUBLANG_SAMI_LULE_SWEDEN, 757 SUBLANG_SAMI_SOUTHERN_NORWAY, 758 SUBLANG_SAMI_SOUTHERN_SWEDEN, // = 7 759 760 SUBLANG_SANSKRIT_INDIA = 1, 761 762 SUBLANG_SERBIAN_LATIN = 2, 763 SUBLANG_SERBIAN_CYRILLIC, // = 3 764 SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN = 6, 765 SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC = 7, 766 767 SUBLANG_SINDHI_AFGHANISTAN = 2, 768 SUBLANG_SINHALESE_SRI_LANKA = 1, 769 SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA = 1, 770 SUBLANG_SLOVAK_SLOVAKIA = 1, 771 SUBLANG_SLOVENIAN_SLOVENIA = 1, 772 773 SUBLANG_SPANISH = 1, 774 SUBLANG_SPANISH_MEXICAN, 775 SUBLANG_SPANISH_MODERN, 776 SUBLANG_SPANISH_GUATEMALA, 777 SUBLANG_SPANISH_COSTA_RICA, 778 SUBLANG_SPANISH_PANAMA, 779 SUBLANG_SPANISH_DOMINICAN_REPUBLIC, 780 SUBLANG_SPANISH_VENEZUELA, 781 SUBLANG_SPANISH_COLOMBIA, 782 SUBLANG_SPANISH_PERU, 783 SUBLANG_SPANISH_ARGENTINA, 784 SUBLANG_SPANISH_ECUADOR, 785 SUBLANG_SPANISH_CHILE, 786 SUBLANG_SPANISH_URUGUAY, 787 SUBLANG_SPANISH_PARAGUAY, 788 SUBLANG_SPANISH_BOLIVIA, 789 SUBLANG_SPANISH_EL_SALVADOR, 790 SUBLANG_SPANISH_HONDURAS, 791 SUBLANG_SPANISH_NICARAGUA, 792 SUBLANG_SPANISH_PUERTO_RICO, 793 SUBLANG_SPANISH_US, // = 21 794 795 SUBLANG_SWEDISH = 1, 796 SUBLANG_SWEDISH_SWEDEN = 1, 797 SUBLANG_SWEDISH_FINLAND, // = 2 798 799 SUBLANG_SYRIAC = 1, 800 SUBLANG_TAJIK_TAJIKISTAN = 1, 801 SUBLANG_TAMAZIGHT_ALGERIA_LATIN = 2, 802 SUBLANG_TAMIL_INDIA = 1, 803 SUBLANG_TATAR_RUSSIA = 1, 804 SUBLANG_TELUGU_INDIA = 1, 805 SUBLANG_THAI_THAILAND = 1, 806 SUBLANG_TIBETAN_PRC = 1, 807 SUBLANG_TIBETAN_BHUTAN = 2, 808 SUBLANG_TIGRIGNA_ERITREA = 1, 809 SUBLANG_TSWANA_SOUTH_AFRICA = 1, 810 SUBLANG_TURKISH_TURKEY = 1, 811 SUBLANG_TURKMEN_TURKMENISTAN = 1, 812 SUBLANG_UIGHUR_PRC = 1, 813 SUBLANG_UKRAINIAN_UKRAINE = 1, 814 SUBLANG_UPPER_SORBIAN_GERMANY = 1, 815 816 SUBLANG_URDU_PAKISTAN = 1, 817 SUBLANG_URDU_INDIA, // = 2 818 819 SUBLANG_UZBEK_LATIN = 1, 820 SUBLANG_UZBEK_CYRILLIC, // = 2 821 822 SUBLANG_VIETNAMESE_VIETNAM = 1, 823 SUBLANG_WELSH_UNITED_KINGDOM = 1, 824 SUBLANG_WOLOF_SENEGAL = 1, 825 SUBLANG_YORUBA_NIGERIA = 1, 826 SUBLANG_XHOSA_SOUTH_AFRICA = 1, 827 SUBLANG_YAKUT_RUSSIA = 1, 828 SUBLANG_YI_PRC = 1, 829 SUBLANG_ZULU_SOUTH_AFRICA = 1 830 } 831 832 // This is not documented on MSDN 833 const NLS_VALID_LOCALE_MASK = 1048575; 834 835 // Sorting identifiers 836 enum : WORD { 837 SORT_DEFAULT = 0, 838 SORT_JAPANESE_XJIS = 0, 839 SORT_JAPANESE_UNICODE = 1, 840 SORT_CHINESE_BIG5 = 0, 841 SORT_CHINESE_PRCP = 0, 842 SORT_CHINESE_UNICODE = 1, 843 SORT_CHINESE_PRC = 2, 844 SORT_CHINESE_BOPOMOFO = 3, 845 SORT_KOREAN_KSC = 0, 846 SORT_KOREAN_UNICODE = 1, 847 SORT_GERMAN_PHONE_BOOK = 1, 848 SORT_HUNGARIAN_DEFAULT = 0, 849 SORT_HUNGARIAN_TECHNICAL = 1, 850 SORT_GEORGIAN_TRADITIONAL = 0, 851 SORT_GEORGIAN_MODERN = 1 852 } 853 854 WORD MAKELANGID(USHORT p, USHORT s) { return cast(WORD)((s << 10) | p); } 855 WORD PRIMARYLANGID(WORD lgid) { return cast(WORD)(lgid & 0x3FF); } 856 WORD SUBLANGID(WORD lgid) { return cast(WORD)(lgid >>> 10); } 857 858 DWORD MAKELCID(WORD lgid, WORD srtid) { return (cast(DWORD) srtid << 16) | cast(DWORD) lgid; } 859 // ??? 860 //DWORD MAKESORTLCID(WORD lgid, WORD srtid, WORD ver) { return (MAKELCID(lgid, srtid)) | ((cast(DWORD)ver) << 20); } 861 WORD LANGIDFROMLCID(LCID lcid) { return cast(WORD) lcid; } 862 WORD SORTIDFROMLCID(LCID lcid) { return cast(WORD) ((lcid >>> 16) & 0x0F); } 863 WORD SORTVERSIONFROMLCID(LCID lcid) { return cast(WORD) ((lcid >>> 20) & 0x0F); } 864 865 const WORD LANG_SYSTEM_DEFAULT = (SUBLANG_SYS_DEFAULT << 10) | LANG_NEUTRAL; 866 const WORD LANG_USER_DEFAULT = (SUBLANG_DEFAULT << 10) | LANG_NEUTRAL; 867 const DWORD LOCALE_NEUTRAL = (SORT_DEFAULT << 16) 868 | (SUBLANG_NEUTRAL << 10) | LANG_NEUTRAL; 869 870 // --- 871 enum : BYTE { 872 ACL_REVISION = 2, 873 ACL_REVISION_DS = 4 874 } 875 876 // These are not documented on MSDN 877 enum : BYTE { 878 ACL_REVISION1 = 1, 879 ACL_REVISION2, 880 ACL_REVISION3, 881 ACL_REVISION4 // = 4 882 } 883 884 const BYTE 885 MIN_ACL_REVISION = 2, 886 MAX_ACL_REVISION = 4; 887 888 /+ 889 // These aren't necessary for D. 890 const MINCHAR=0x80; 891 const MAXCHAR=0x7f; 892 const MINSHORT=0x8000; 893 const MAXSHORT=0x7fff; 894 const MINLONG=0x80000000; 895 const MAXLONG=0x7fffffff; 896 const MAXBYTE=0xff; 897 const MAXWORD=0xffff; 898 const MAXDWORD=0xffffffff; 899 +/ 900 901 // SYSTEM_INFO.dwProcessorType 902 enum : DWORD { 903 PROCESSOR_INTEL_386 = 386, 904 PROCESSOR_INTEL_486 = 486, 905 PROCESSOR_INTEL_PENTIUM = 586, 906 PROCESSOR_MIPS_R4000 = 4000, 907 PROCESSOR_ALPHA_21064 = 21064, 908 PROCESSOR_INTEL_IA64 = 2200 909 } 910 911 // SYSTEM_INFO.wProcessorArchitecture 912 enum : WORD { 913 PROCESSOR_ARCHITECTURE_INTEL, 914 PROCESSOR_ARCHITECTURE_MIPS, 915 PROCESSOR_ARCHITECTURE_ALPHA, 916 PROCESSOR_ARCHITECTURE_PPC, 917 PROCESSOR_ARCHITECTURE_SHX, 918 PROCESSOR_ARCHITECTURE_ARM, 919 PROCESSOR_ARCHITECTURE_IA64, 920 PROCESSOR_ARCHITECTURE_ALPHA64, 921 PROCESSOR_ARCHITECTURE_MSIL, 922 PROCESSOR_ARCHITECTURE_AMD64, 923 PROCESSOR_ARCHITECTURE_IA32_ON_WIN64, // = 10 924 PROCESSOR_ARCHITECTURE_UNKNOWN = 0xFFFF 925 } 926 927 // IsProcessorFeaturePresent() 928 enum : DWORD { 929 PF_FLOATING_POINT_PRECISION_ERRATA, 930 PF_FLOATING_POINT_EMULATED, 931 PF_COMPARE_EXCHANGE_DOUBLE, 932 PF_MMX_INSTRUCTIONS_AVAILABLE, 933 PF_PPC_MOVEMEM_64BIT_OK, 934 PF_ALPHA_BYTE_INSTRUCTIONS, 935 PF_XMMI_INSTRUCTIONS_AVAILABLE, 936 PF_3DNOW_INSTRUCTIONS_AVAILABLE, 937 PF_RDTSC_INSTRUCTION_AVAILABLE, 938 PF_PAE_ENABLED, 939 PF_XMMI64_INSTRUCTIONS_AVAILABLE 940 } 941 942 // MinGW: also in ddk/ntifs.h 943 enum : DWORD { 944 FILE_ACTION_ADDED = 1, 945 FILE_ACTION_REMOVED, 946 FILE_ACTION_MODIFIED, 947 FILE_ACTION_RENAMED_OLD_NAME, 948 FILE_ACTION_RENAMED_NEW_NAME, 949 FILE_ACTION_ADDED_STREAM, 950 FILE_ACTION_REMOVED_STREAM, 951 FILE_ACTION_MODIFIED_STREAM, 952 FILE_ACTION_REMOVED_BY_DELETE, 953 FILE_ACTION_ID_NOT_TUNNELLED, 954 FILE_ACTION_TUNNELLED_ID_COLLISION // = 11 955 } 956 // MinGW: end ntifs.h 957 958 const DWORD 959 HEAP_NO_SERIALIZE = 0x01, 960 HEAP_GROWABLE = 0x02, 961 HEAP_GENERATE_EXCEPTIONS = 0x04, 962 HEAP_ZERO_MEMORY = 0x08, 963 HEAP_REALLOC_IN_PLACE_ONLY = 0x10, 964 HEAP_TAIL_CHECKING_ENABLED = 0x20, 965 HEAP_FREE_CHECKING_ENABLED = 0x40, 966 HEAP_DISABLE_COALESCE_ON_FREE = 0x80; 967 968 // These are not documented on MSDN 969 const HEAP_CREATE_ALIGN_16 = 0; 970 const HEAP_CREATE_ENABLE_TRACING = 0x020000; 971 const HEAP_MAXIMUM_TAG = 0x000FFF; 972 const HEAP_PSEUDO_TAG_FLAG = 0x008000; 973 const HEAP_TAG_SHIFT = 16; 974 // ??? 975 //MACRO #define HEAP_MAKE_TAG_FLAGS(b,o) ((DWORD)((b)+(o)<<16))) 976 977 const ACCESS_MASK 978 KEY_QUERY_VALUE = 0x000001, 979 KEY_SET_VALUE = 0x000002, 980 KEY_CREATE_SUB_KEY = 0x000004, 981 KEY_ENUMERATE_SUB_KEYS = 0x000008, 982 KEY_NOTIFY = 0x000010, 983 KEY_CREATE_LINK = 0x000020, 984 KEY_WRITE = 0x020006, 985 KEY_EXECUTE = 0x020019, 986 KEY_READ = 0x020019, 987 KEY_ALL_ACCESS = 0x0F003F; 988 989 static if (WINVER >= 0x502) { 990 const ACCESS_MASK 991 KEY_WOW64_64KEY = 0x000100, 992 KEY_WOW64_32KEY = 0x000200; 993 } 994 995 const DWORD 996 REG_WHOLE_HIVE_VOLATILE = 1, 997 REG_REFRESH_HIVE = 2, 998 REG_NO_LAZY_FLUSH = 4; 999 1000 const DWORD 1001 REG_OPTION_RESERVED = 0, 1002 REG_OPTION_NON_VOLATILE = 0, 1003 REG_OPTION_VOLATILE = 1, 1004 REG_OPTION_CREATE_LINK = 2, 1005 REG_OPTION_BACKUP_RESTORE = 4, 1006 REG_OPTION_OPEN_LINK = 8, 1007 REG_LEGAL_OPTION = 15; 1008 1009 const SECURITY_INFORMATION 1010 OWNER_SECURITY_INFORMATION = 0x00000001, 1011 GROUP_SECURITY_INFORMATION = 0x00000002, 1012 DACL_SECURITY_INFORMATION = 0x00000004, 1013 SACL_SECURITY_INFORMATION = 0x00000008, 1014 LABEL_SECURITY_INFORMATION = 0x00000010, 1015 UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000, 1016 UNPROTECTED_DACL_SECURITY_INFORMATION = 0x20000000, 1017 PROTECTED_SACL_SECURITY_INFORMATION = 0x40000000, 1018 PROTECTED_DACL_SECURITY_INFORMATION = 0x80000000; 1019 1020 const DWORD MAXIMUM_PROCESSORS = 32; 1021 1022 // VirtualAlloc(), etc 1023 // ------------------- 1024 1025 enum : DWORD { 1026 PAGE_NOACCESS = 0x0001, 1027 PAGE_READONLY = 0x0002, 1028 PAGE_READWRITE = 0x0004, 1029 PAGE_WRITECOPY = 0x0008, 1030 PAGE_EXECUTE = 0x0010, 1031 PAGE_EXECUTE_READ = 0x0020, 1032 PAGE_EXECUTE_READWRITE = 0x0040, 1033 PAGE_EXECUTE_WRITECOPY = 0x0080, 1034 PAGE_GUARD = 0x0100, 1035 PAGE_NOCACHE = 0x0200 1036 } 1037 1038 enum : DWORD { 1039 MEM_COMMIT = 0x00001000, 1040 MEM_RESERVE = 0x00002000, 1041 MEM_DECOMMIT = 0x00004000, 1042 MEM_RELEASE = 0x00008000, 1043 MEM_FREE = 0x00010000, 1044 MEM_PRIVATE = 0x00020000, 1045 MEM_MAPPED = 0x00040000, 1046 MEM_RESET = 0x00080000, 1047 MEM_TOP_DOWN = 0x00100000, 1048 MEM_WRITE_WATCH = 0x00200000, // MinGW (???): 98/Me 1049 MEM_PHYSICAL = 0x00400000, 1050 MEM_4MB_PAGES = 0x80000000 1051 } 1052 1053 // MinGW: also in ddk/ntifs.h 1054 // CreateFileMapping() 1055 const DWORD 1056 SEC_BASED = 0x00200000, 1057 SEC_NO_CHANGE = 0x00400000, 1058 SEC_FILE = 0x00800000, 1059 SEC_IMAGE = 0x01000000, 1060 SEC_VLM = 0x02000000, 1061 SEC_RESERVE = 0x04000000, 1062 SEC_COMMIT = 0x08000000, 1063 SEC_NOCACHE = 0x10000000, 1064 MEM_IMAGE = SEC_IMAGE; 1065 // MinGW: end ntifs.h 1066 1067 // ??? 1068 const ACCESS_MASK 1069 SECTION_QUERY = 0x000001, 1070 SECTION_MAP_WRITE = 0x000002, 1071 SECTION_MAP_READ = 0x000004, 1072 SECTION_MAP_EXECUTE = 0x000008, 1073 SECTION_EXTEND_SIZE = 0x000010, 1074 SECTION_ALL_ACCESS = 0x0F001F; 1075 1076 // These are not documented on MSDN 1077 const MESSAGE_RESOURCE_UNICODE = 1; 1078 const RTL_CRITSECT_TYPE = 0; 1079 const RTL_RESOURCE_TYPE = 1; 1080 1081 // COFF file format 1082 // ---------------- 1083 1084 // IMAGE_FILE_HEADER.Characteristics 1085 const WORD 1086 IMAGE_FILE_RELOCS_STRIPPED = 0x0001, 1087 IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002, 1088 IMAGE_FILE_LINE_NUMS_STRIPPED = 0x0004, 1089 IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x0008, 1090 IMAGE_FILE_AGGRESIVE_WS_TRIM = 0x0010, 1091 IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020, 1092 IMAGE_FILE_BYTES_REVERSED_LO = 0x0080, 1093 IMAGE_FILE_32BIT_MACHINE = 0x0100, 1094 IMAGE_FILE_DEBUG_STRIPPED = 0x0200, 1095 IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400, 1096 IMAGE_FILE_NET_RUN_FROM_SWAP = 0x0800, 1097 IMAGE_FILE_SYSTEM = 0x1000, 1098 IMAGE_FILE_DLL = 0x2000, 1099 IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000, 1100 IMAGE_FILE_BYTES_REVERSED_HI = 0x8000; 1101 1102 // IMAGE_FILE_HEADER.Machine 1103 enum : WORD { 1104 IMAGE_FILE_MACHINE_UNKNOWN = 0x0000, 1105 IMAGE_FILE_MACHINE_I386 = 0x014C, 1106 IMAGE_FILE_MACHINE_R3000 = 0x0162, 1107 IMAGE_FILE_MACHINE_R4000 = 0x0166, 1108 IMAGE_FILE_MACHINE_R10000 = 0x0168, 1109 IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x0169, 1110 IMAGE_FILE_MACHINE_ALPHA = 0x0184, 1111 IMAGE_FILE_MACHINE_SH3 = 0x01A2, 1112 IMAGE_FILE_MACHINE_SH3DSP = 0x01A3, 1113 IMAGE_FILE_MACHINE_SH4 = 0x01A6, 1114 IMAGE_FILE_MACHINE_SH5 = 0x01A8, 1115 IMAGE_FILE_MACHINE_ARM = 0x01C0, 1116 IMAGE_FILE_MACHINE_THUMB = 0x01C2, 1117 IMAGE_FILE_MACHINE_AM33 = 0x01D3, 1118 IMAGE_FILE_MACHINE_POWERPC = 0x01F0, 1119 IMAGE_FILE_MACHINE_POWERPCFP = 0x01F1, 1120 IMAGE_FILE_MACHINE_IA64 = 0x0200, 1121 IMAGE_FILE_MACHINE_MIPS16 = 0x0266, 1122 IMAGE_FILE_MACHINE_MIPSFPU = 0x0366, 1123 IMAGE_FILE_MACHINE_MIPSFPU16 = 0x0466, 1124 IMAGE_FILE_MACHINE_EBC = 0x0EBC, 1125 IMAGE_FILE_MACHINE_AMD64 = 0x8664, 1126 IMAGE_FILE_MACHINE_M32R = 0x9041 1127 } 1128 1129 // ??? 1130 enum { 1131 IMAGE_DOS_SIGNATURE = 0x5A4D, 1132 IMAGE_OS2_SIGNATURE = 0x454E, 1133 IMAGE_OS2_SIGNATURE_LE = 0x454C, 1134 IMAGE_VXD_SIGNATURE = 0x454C, 1135 IMAGE_NT_SIGNATURE = 0x4550 1136 } 1137 1138 // IMAGE_OPTIONAL_HEADER.Magic 1139 enum : WORD { 1140 IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x010B, 1141 IMAGE_ROM_OPTIONAL_HDR_MAGIC = 0x0107, 1142 IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x020B 1143 } 1144 1145 // IMAGE_OPTIONAL_HEADER.Subsystem 1146 enum : WORD { 1147 IMAGE_SUBSYSTEM_UNKNOWN = 0, 1148 IMAGE_SUBSYSTEM_NATIVE, 1149 IMAGE_SUBSYSTEM_WINDOWS_GUI, 1150 IMAGE_SUBSYSTEM_WINDOWS_CUI, // = 3 1151 IMAGE_SUBSYSTEM_OS2_CUI = 5, 1152 IMAGE_SUBSYSTEM_POSIX_CUI = 7, 1153 IMAGE_SUBSYSTEM_NATIVE_WINDOWS, 1154 IMAGE_SUBSYSTEM_WINDOWS_CE_GUI, 1155 IMAGE_SUBSYSTEM_EFI_APPLICATION, 1156 IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, 1157 IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER, 1158 IMAGE_SUBSYSTEM_EFI_ROM, 1159 IMAGE_SUBSYSTEM_XBOX, // = 14 1160 IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 1161 } 1162 1163 // IMAGE_OPTIONAL_HEADER.DllCharacteristics 1164 const WORD 1165 IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040, 1166 IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080, 1167 IMAGE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100, 1168 IMAGE_DLLCHARACTERISTICS_NO_ISOLATION = 0x0200, 1169 IMAGE_DLLCHARACTERISTICS_NO_SEH = 0x0400, 1170 IMAGE_DLLCHARACTERISTICS_NO_BIND = 0x0800, 1171 IMAGE_DLLCHARACTERISTICS_WDM_DRIVER = 0x2000, 1172 IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000; 1173 1174 // ??? 1175 const IMAGE_SEPARATE_DEBUG_SIGNATURE = 0x4944; 1176 1177 const size_t 1178 IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16, 1179 IMAGE_SIZEOF_ROM_OPTIONAL_HEADER = 56, 1180 IMAGE_SIZEOF_STD_OPTIONAL_HEADER = 28, 1181 IMAGE_SIZEOF_NT_OPTIONAL_HEADER = 224, 1182 IMAGE_SIZEOF_SHORT_NAME = 8, 1183 IMAGE_SIZEOF_SECTION_HEADER = 40, 1184 IMAGE_SIZEOF_SYMBOL = 18, 1185 IMAGE_SIZEOF_AUX_SYMBOL = 18, 1186 IMAGE_SIZEOF_RELOCATION = 10, 1187 IMAGE_SIZEOF_BASE_RELOCATION = 8, 1188 IMAGE_SIZEOF_LINENUMBER = 6, 1189 IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR = 60, 1190 SIZEOF_RFPO_DATA = 16; 1191 1192 PIMAGE_SECTION_HEADER IMAGE_FIRST_SECTION(PIMAGE_NT_HEADERS h) { 1193 return cast(PIMAGE_SECTION_HEADER) 1194 (&h.OptionalHeader + h.FileHeader.SizeOfOptionalHeader); 1195 } 1196 1197 // ImageDirectoryEntryToDataEx() 1198 enum : USHORT { 1199 IMAGE_DIRECTORY_ENTRY_EXPORT = 0, 1200 IMAGE_DIRECTORY_ENTRY_IMPORT, 1201 IMAGE_DIRECTORY_ENTRY_RESOURCE, 1202 IMAGE_DIRECTORY_ENTRY_EXCEPTION, 1203 IMAGE_DIRECTORY_ENTRY_SECURITY, 1204 IMAGE_DIRECTORY_ENTRY_BASERELOC, 1205 IMAGE_DIRECTORY_ENTRY_DEBUG, 1206 IMAGE_DIRECTORY_ENTRY_COPYRIGHT, // = 7 1207 IMAGE_DIRECTORY_ENTRY_ARCHITECTURE = 7, 1208 IMAGE_DIRECTORY_ENTRY_GLOBALPTR, 1209 IMAGE_DIRECTORY_ENTRY_TLS, 1210 IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG, 1211 IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT, 1212 IMAGE_DIRECTORY_ENTRY_IAT, 1213 IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT, 1214 IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR, // = 14 1215 } 1216 1217 // IMAGE_SECTION_HEADER.Characteristics 1218 const DWORD 1219 IMAGE_SCN_TYPE_REG = 0x00000000, 1220 IMAGE_SCN_TYPE_DSECT = 0x00000001, 1221 IMAGE_SCN_TYPE_NOLOAD = 0x00000002, 1222 IMAGE_SCN_TYPE_GROUP = 0x00000004, 1223 IMAGE_SCN_TYPE_NO_PAD = 0x00000008, 1224 IMAGE_SCN_TYPE_COPY = 0x00000010, 1225 IMAGE_SCN_CNT_CODE = 0x00000020, 1226 IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040, 1227 IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080, 1228 IMAGE_SCN_LNK_OTHER = 0x00000100, 1229 IMAGE_SCN_LNK_INFO = 0x00000200, 1230 IMAGE_SCN_TYPE_OVER = 0x00000400, 1231 IMAGE_SCN_LNK_REMOVE = 0x00000800, 1232 IMAGE_SCN_LNK_COMDAT = 0x00001000, 1233 IMAGE_SCN_MEM_FARDATA = 0x00008000, 1234 IMAGE_SCN_GPREL = 0x00008000, 1235 IMAGE_SCN_MEM_PURGEABLE = 0x00020000, 1236 IMAGE_SCN_MEM_16BIT = 0x00020000, 1237 IMAGE_SCN_MEM_LOCKED = 0x00040000, 1238 IMAGE_SCN_MEM_PRELOAD = 0x00080000, 1239 IMAGE_SCN_ALIGN_1BYTES = 0x00100000, 1240 IMAGE_SCN_ALIGN_2BYTES = 0x00200000, 1241 IMAGE_SCN_ALIGN_4BYTES = 0x00300000, 1242 IMAGE_SCN_ALIGN_8BYTES = 0x00400000, 1243 IMAGE_SCN_ALIGN_16BYTES = 0x00500000, 1244 IMAGE_SCN_ALIGN_32BYTES = 0x00600000, 1245 IMAGE_SCN_ALIGN_64BYTES = 0x00700000, 1246 IMAGE_SCN_ALIGN_128BYTES = 0x00800000, 1247 IMAGE_SCN_ALIGN_256BYTES = 0x00900000, 1248 IMAGE_SCN_ALIGN_512BYTES = 0x00A00000, 1249 IMAGE_SCN_ALIGN_1024BYTES = 0x00B00000, 1250 IMAGE_SCN_ALIGN_2048BYTES = 0x00C00000, 1251 IMAGE_SCN_ALIGN_4096BYTES = 0x00D00000, 1252 IMAGE_SCN_ALIGN_8192BYTES = 0x00E00000, 1253 IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000, 1254 IMAGE_SCN_MEM_DISCARDABLE = 0x02000000, 1255 IMAGE_SCN_MEM_NOT_CACHED = 0x04000000, 1256 IMAGE_SCN_MEM_NOT_PAGED = 0x08000000, 1257 IMAGE_SCN_MEM_SHARED = 0x10000000, 1258 IMAGE_SCN_MEM_EXECUTE = 0x20000000, 1259 IMAGE_SCN_MEM_READ = 0x40000000, 1260 IMAGE_SCN_MEM_WRITE = 0x80000000; 1261 1262 /* The following constants are mostlydocumented at 1263 * http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/pecoff.doc 1264 * but don't seem to be defined in the HTML docs. 1265 */ 1266 enum : SHORT { 1267 IMAGE_SYM_UNDEFINED = 0, 1268 IMAGE_SYM_ABSOLUTE = -1, 1269 IMAGE_SYM_DEBUG = -2 1270 } 1271 1272 enum : ubyte { 1273 IMAGE_SYM_TYPE_NULL, 1274 IMAGE_SYM_TYPE_VOID, 1275 IMAGE_SYM_TYPE_CHAR, 1276 IMAGE_SYM_TYPE_SHORT, 1277 IMAGE_SYM_TYPE_INT, 1278 IMAGE_SYM_TYPE_LONG, 1279 IMAGE_SYM_TYPE_FLOAT, 1280 IMAGE_SYM_TYPE_DOUBLE, 1281 IMAGE_SYM_TYPE_STRUCT, 1282 IMAGE_SYM_TYPE_UNION, 1283 IMAGE_SYM_TYPE_ENUM, 1284 IMAGE_SYM_TYPE_MOE, 1285 IMAGE_SYM_TYPE_BYTE, 1286 IMAGE_SYM_TYPE_WORD, 1287 IMAGE_SYM_TYPE_UINT, 1288 IMAGE_SYM_TYPE_DWORD // = 15 1289 } 1290 const IMAGE_SYM_TYPE_PCODE = 32768; // ??? 1291 1292 enum : ubyte { 1293 IMAGE_SYM_DTYPE_NULL, 1294 IMAGE_SYM_DTYPE_POINTER, 1295 IMAGE_SYM_DTYPE_FUNCTION, 1296 IMAGE_SYM_DTYPE_ARRAY 1297 } 1298 1299 enum : BYTE { 1300 IMAGE_SYM_CLASS_END_OF_FUNCTION = 0xFF, 1301 IMAGE_SYM_CLASS_NULL = 0, 1302 IMAGE_SYM_CLASS_AUTOMATIC, 1303 IMAGE_SYM_CLASS_EXTERNAL, 1304 IMAGE_SYM_CLASS_STATIC, 1305 IMAGE_SYM_CLASS_REGISTER, 1306 IMAGE_SYM_CLASS_EXTERNAL_DEF, 1307 IMAGE_SYM_CLASS_LABEL, 1308 IMAGE_SYM_CLASS_UNDEFINED_LABEL, 1309 IMAGE_SYM_CLASS_MEMBER_OF_STRUCT, 1310 IMAGE_SYM_CLASS_ARGUMENT, 1311 IMAGE_SYM_CLASS_STRUCT_TAG, 1312 IMAGE_SYM_CLASS_MEMBER_OF_UNION, 1313 IMAGE_SYM_CLASS_UNION_TAG, 1314 IMAGE_SYM_CLASS_TYPE_DEFINITION, 1315 IMAGE_SYM_CLASS_UNDEFINED_STATIC, 1316 IMAGE_SYM_CLASS_ENUM_TAG, 1317 IMAGE_SYM_CLASS_MEMBER_OF_ENUM, 1318 IMAGE_SYM_CLASS_REGISTER_PARAM, 1319 IMAGE_SYM_CLASS_BIT_FIELD, // = 18 1320 IMAGE_SYM_CLASS_FAR_EXTERNAL = 68, 1321 IMAGE_SYM_CLASS_BLOCK = 100, 1322 IMAGE_SYM_CLASS_FUNCTION, 1323 IMAGE_SYM_CLASS_END_OF_STRUCT, 1324 IMAGE_SYM_CLASS_FILE, 1325 IMAGE_SYM_CLASS_SECTION, 1326 IMAGE_SYM_CLASS_WEAK_EXTERNAL,// = 105 1327 IMAGE_SYM_CLASS_CLR_TOKEN = 107 1328 } 1329 1330 enum : BYTE { 1331 IMAGE_COMDAT_SELECT_NODUPLICATES = 1, 1332 IMAGE_COMDAT_SELECT_ANY, 1333 IMAGE_COMDAT_SELECT_SAME_SIZE, 1334 IMAGE_COMDAT_SELECT_EXACT_MATCH, 1335 IMAGE_COMDAT_SELECT_ASSOCIATIVE, 1336 IMAGE_COMDAT_SELECT_LARGEST, 1337 IMAGE_COMDAT_SELECT_NEWEST // = 7 1338 } 1339 1340 enum : DWORD { 1341 IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1, 1342 IMAGE_WEAK_EXTERN_SEARCH_LIBRARY, 1343 IMAGE_WEAK_EXTERN_SEARCH_ALIAS 1344 } 1345 1346 enum : WORD { 1347 IMAGE_REL_I386_ABSOLUTE = 0x0000, 1348 IMAGE_REL_I386_DIR16 = 0x0001, 1349 IMAGE_REL_I386_REL16 = 0x0002, 1350 IMAGE_REL_I386_DIR32 = 0x0006, 1351 IMAGE_REL_I386_DIR32NB = 0x0007, 1352 IMAGE_REL_I386_SEG12 = 0x0009, 1353 IMAGE_REL_I386_SECTION = 0x000A, 1354 IMAGE_REL_I386_SECREL = 0x000B, 1355 IMAGE_REL_I386_TOKEN = 0x000C, 1356 IMAGE_REL_I386_SECREL7 = 0x000D, 1357 IMAGE_REL_I386_REL32 = 0x0014 1358 } 1359 1360 enum : WORD { 1361 IMAGE_REL_AMD64_ABSOLUTE = 0x0000, 1362 IMAGE_REL_AMD64_ADDR64 = 0x0001, 1363 IMAGE_REL_AMD64_ADDR32 = 0x0002, 1364 IMAGE_REL_AMD64_ADDR32NB = 0x0003, 1365 IMAGE_REL_AMD64_REL32 = 0x0004, 1366 IMAGE_REL_AMD64_REL32_1 = 0x0005, 1367 IMAGE_REL_AMD64_REL32_2 = 0x0006, 1368 IMAGE_REL_AMD64_REL32_3 = 0x0007, 1369 IMAGE_REL_AMD64_REL32_4 = 0x0008, 1370 IMAGE_REL_AMD64_REL32_5 = 0x0009, 1371 IMAGE_REL_AMD64_SECTION = 0x000A, 1372 IMAGE_REL_AMD64_SECREL = 0x000B, 1373 IMAGE_REL_AMD64_SECREL7 = 0x000C, 1374 IMAGE_REL_AMD64_TOKEN = 0x000D, 1375 IMAGE_REL_AMD64_SREL32 = 0x000E, 1376 IMAGE_REL_AMD64_PAIR = 0x000F, 1377 IMAGE_REL_AMD64_SSPAN32 = 0x0010 1378 } 1379 1380 enum : WORD { 1381 IMAGE_REL_IA64_ABSOLUTE = 0x0000, 1382 IMAGE_REL_IA64_IMM14 = 0x0001, 1383 IMAGE_REL_IA64_IMM22 = 0x0002, 1384 IMAGE_REL_IA64_IMM64 = 0x0003, 1385 IMAGE_REL_IA64_DIR32 = 0x0004, 1386 IMAGE_REL_IA64_DIR64 = 0x0005, 1387 IMAGE_REL_IA64_PCREL21B = 0x0006, 1388 IMAGE_REL_IA64_PCREL21M = 0x0007, 1389 IMAGE_REL_IA64_PCREL21F = 0x0008, 1390 IMAGE_REL_IA64_GPREL22 = 0x0009, 1391 IMAGE_REL_IA64_LTOFF22 = 0x000A, 1392 IMAGE_REL_IA64_SECTION = 0x000B, 1393 IMAGE_REL_IA64_SECREL22 = 0x000C, 1394 IMAGE_REL_IA64_SECREL64I = 0x000D, 1395 IMAGE_REL_IA64_SECREL32 = 0x000E, 1396 IMAGE_REL_IA64_DIR32NB = 0x0010, 1397 IMAGE_REL_IA64_SREL14 = 0x0011, 1398 IMAGE_REL_IA64_SREL22 = 0x0012, 1399 IMAGE_REL_IA64_SREL32 = 0x0013, 1400 IMAGE_REL_IA64_UREL32 = 0x0014, 1401 IMAGE_REL_IA64_PCREL60X = 0x0015, 1402 IMAGE_REL_IA64_PCREL60B = 0x0016, 1403 IMAGE_REL_IA64_PCREL60F = 0x0017, 1404 IMAGE_REL_IA64_PCREL60I = 0x0018, 1405 IMAGE_REL_IA64_PCREL60M = 0x0019, 1406 IMAGE_REL_IA64_IMMGPREL64 = 0x001A, 1407 IMAGE_REL_IA64_TOKEN = 0x001B, 1408 IMAGE_REL_IA64_GPREL32 = 0x001C, 1409 IMAGE_REL_IA64_ADDEND = 0x001F 1410 } 1411 1412 enum : WORD { 1413 IMAGE_REL_SH3_ABSOLUTE = 0x0000, 1414 IMAGE_REL_SH3_DIRECT16 = 0x0001, 1415 IMAGE_REL_SH3_DIRECT32 = 0x0002, 1416 IMAGE_REL_SH3_DIRECT8 = 0x0003, 1417 IMAGE_REL_SH3_DIRECT8_WORD = 0x0004, 1418 IMAGE_REL_SH3_DIRECT8_LONG = 0x0005, 1419 IMAGE_REL_SH3_DIRECT4 = 0x0006, 1420 IMAGE_REL_SH3_DIRECT4_WORD = 0x0007, 1421 IMAGE_REL_SH3_DIRECT4_LONG = 0x0008, 1422 IMAGE_REL_SH3_PCREL8_WORD = 0x0009, 1423 IMAGE_REL_SH3_PCREL8_LONG = 0x000A, 1424 IMAGE_REL_SH3_PCREL12_WORD = 0x000B, 1425 IMAGE_REL_SH3_STARTOF_SECTION = 0x000C, 1426 IMAGE_REL_SH3_SIZEOF_SECTION = 0x000D, 1427 IMAGE_REL_SH3_SECTION = 0x000E, 1428 IMAGE_REL_SH3_SECREL = 0x000F, 1429 IMAGE_REL_SH3_DIRECT32_NB = 0x0010, 1430 IMAGE_REL_SH3_GPREL4_LONG = 0x0011, 1431 IMAGE_REL_SH3_TOKEN = 0x0012, 1432 IMAGE_REL_SHM_PCRELPT = 0x0013, 1433 IMAGE_REL_SHM_REFLO = 0x0014, 1434 IMAGE_REL_SHM_REFHALF = 0x0015, 1435 IMAGE_REL_SHM_RELLO = 0x0016, 1436 IMAGE_REL_SHM_RELHALF = 0x0017, 1437 IMAGE_REL_SHM_PAIR = 0x0018, 1438 IMAGE_REL_SHM_NOMODE = 0x8000 1439 } 1440 1441 enum : WORD { 1442 IMAGE_REL_M32R_ABSOLUTE = 0x0000, 1443 IMAGE_REL_M32R_ADDR32 = 0x0001, 1444 IMAGE_REL_M32R_ADDR32NB = 0x0002, 1445 IMAGE_REL_M32R_ADDR24 = 0x0003, 1446 IMAGE_REL_M32R_GPREL16 = 0x0004, 1447 IMAGE_REL_M32R_PCREL24 = 0x0005, 1448 IMAGE_REL_M32R_PCREL16 = 0x0006, 1449 IMAGE_REL_M32R_PCREL8 = 0x0007, 1450 IMAGE_REL_M32R_REFHALF = 0x0008, 1451 IMAGE_REL_M32R_REFHI = 0x0009, 1452 IMAGE_REL_M32R_REFLO = 0x000A, 1453 IMAGE_REL_M32R_PAIR = 0x000B, 1454 IMAGE_REL_M32R_SECTION = 0x000C, 1455 IMAGE_REL_M32R_SECREL = 0x000D, 1456 IMAGE_REL_M32R_TOKEN = 0x000E 1457 } 1458 1459 enum : WORD { 1460 IMAGE_REL_MIPS_ABSOLUTE = 0x0000, 1461 IMAGE_REL_MIPS_REFHALF = 0x0001, 1462 IMAGE_REL_MIPS_REFWORD = 0x0002, 1463 IMAGE_REL_MIPS_JMPADDR = 0x0003, 1464 IMAGE_REL_MIPS_REFHI = 0x0004, 1465 IMAGE_REL_MIPS_REFLO = 0x0005, 1466 IMAGE_REL_MIPS_GPREL = 0x0006, 1467 IMAGE_REL_MIPS_LITERAL = 0x0007, 1468 IMAGE_REL_MIPS_SECTION = 0x000A, 1469 IMAGE_REL_MIPS_SECREL = 0x000B, 1470 IMAGE_REL_MIPS_SECRELLO = 0x000C, 1471 IMAGE_REL_MIPS_SECRELHI = 0x000D, 1472 IMAGE_REL_MIPS_JMPADDR16 = 0x0010, 1473 IMAGE_REL_MIPS_REFWORDNB = 0x0022, 1474 IMAGE_REL_MIPS_PAIR = 0x0025 1475 } 1476 1477 1478 enum : WORD { 1479 IMAGE_REL_ALPHA_ABSOLUTE, 1480 IMAGE_REL_ALPHA_REFLONG, 1481 IMAGE_REL_ALPHA_REFQUAD, 1482 IMAGE_REL_ALPHA_GPREL32, 1483 IMAGE_REL_ALPHA_LITERAL, 1484 IMAGE_REL_ALPHA_LITUSE, 1485 IMAGE_REL_ALPHA_GPDISP, 1486 IMAGE_REL_ALPHA_BRADDR, 1487 IMAGE_REL_ALPHA_HINT, 1488 IMAGE_REL_ALPHA_INLINE_REFLONG, 1489 IMAGE_REL_ALPHA_REFHI, 1490 IMAGE_REL_ALPHA_REFLO, 1491 IMAGE_REL_ALPHA_PAIR, 1492 IMAGE_REL_ALPHA_MATCH, 1493 IMAGE_REL_ALPHA_SECTION, 1494 IMAGE_REL_ALPHA_SECREL, 1495 IMAGE_REL_ALPHA_REFLONGNB, 1496 IMAGE_REL_ALPHA_SECRELLO, 1497 IMAGE_REL_ALPHA_SECRELHI // = 18 1498 } 1499 1500 enum : WORD { 1501 IMAGE_REL_PPC_ABSOLUTE, 1502 IMAGE_REL_PPC_ADDR64, 1503 IMAGE_REL_PPC_ADDR32, 1504 IMAGE_REL_PPC_ADDR24, 1505 IMAGE_REL_PPC_ADDR16, 1506 IMAGE_REL_PPC_ADDR14, 1507 IMAGE_REL_PPC_REL24, 1508 IMAGE_REL_PPC_REL14, 1509 IMAGE_REL_PPC_TOCREL16, 1510 IMAGE_REL_PPC_TOCREL14, 1511 IMAGE_REL_PPC_ADDR32NB, 1512 IMAGE_REL_PPC_SECREL, 1513 IMAGE_REL_PPC_SECTION, 1514 IMAGE_REL_PPC_IFGLUE, 1515 IMAGE_REL_PPC_IMGLUE, 1516 IMAGE_REL_PPC_SECREL16, 1517 IMAGE_REL_PPC_REFHI, 1518 IMAGE_REL_PPC_REFLO, 1519 IMAGE_REL_PPC_PAIR // = 18 1520 } 1521 1522 // ??? 1523 const IMAGE_REL_PPC_TYPEMASK = 0x00FF; 1524 const IMAGE_REL_PPC_NEG = 0x0100; 1525 const IMAGE_REL_PPC_BRTAKEN = 0x0200; 1526 const IMAGE_REL_PPC_BRNTAKEN = 0x0400; 1527 const IMAGE_REL_PPC_TOCDEFN = 0x0800; 1528 1529 enum { 1530 IMAGE_REL_BASED_ABSOLUTE, 1531 IMAGE_REL_BASED_HIGH, 1532 IMAGE_REL_BASED_LOW, 1533 IMAGE_REL_BASED_HIGHLOW, 1534 IMAGE_REL_BASED_HIGHADJ, 1535 IMAGE_REL_BASED_MIPS_JMPADDR 1536 } 1537 // End of constants documented in pecoff.doc 1538 1539 const size_t IMAGE_ARCHIVE_START_SIZE = 8; 1540 1541 const TCHAR[] 1542 IMAGE_ARCHIVE_START = "!<arch>\n", 1543 IMAGE_ARCHIVE_END = "`\n", 1544 IMAGE_ARCHIVE_PAD = "\n", 1545 IMAGE_ARCHIVE_LINKER_MEMBER = "/ ", 1546 IMAGE_ARCHIVE_LONGNAMES_MEMBER = "// "; 1547 1548 const IMAGE_ORDINAL_FLAG32 = 0x80000000; 1549 1550 ulong IMAGE_ORDINAL64(ulong Ordinal) { return Ordinal & 0xFFFF; } 1551 uint IMAGE_ORDINAL32(uint Ordinal) { return Ordinal & 0xFFFF; } 1552 1553 bool IMAGE_SNAP_BY_ORDINAL32(uint Ordinal) { 1554 return (Ordinal & IMAGE_ORDINAL_FLAG32) != 0; 1555 } 1556 1557 const ulong IMAGE_ORDINAL_FLAG64 = 0x8000000000000000; 1558 1559 bool IMAGE_SNAP_BY_ORDINAL64(ulong Ordinal) { 1560 return (Ordinal & IMAGE_ORDINAL_FLAG64) != 0; 1561 } 1562 1563 // ??? 1564 const IMAGE_RESOURCE_NAME_IS_STRING = 0x80000000; 1565 const IMAGE_RESOURCE_DATA_IS_DIRECTORY = 0x80000000; 1566 1567 enum : DWORD { 1568 IMAGE_DEBUG_TYPE_UNKNOWN, 1569 IMAGE_DEBUG_TYPE_COFF, 1570 IMAGE_DEBUG_TYPE_CODEVIEW, 1571 IMAGE_DEBUG_TYPE_FPO, 1572 IMAGE_DEBUG_TYPE_MISC, 1573 IMAGE_DEBUG_TYPE_EXCEPTION, 1574 IMAGE_DEBUG_TYPE_FIXUP, 1575 IMAGE_DEBUG_TYPE_OMAP_TO_SRC, 1576 IMAGE_DEBUG_TYPE_OMAP_FROM_SRC, 1577 IMAGE_DEBUG_TYPE_BORLAND // = 9 1578 } 1579 1580 enum : ubyte { 1581 FRAME_FPO, 1582 FRAME_TRAP, 1583 FRAME_TSS, 1584 FRAME_NONFPO 1585 } 1586 1587 // ??? 1588 const IMAGE_DEBUG_MISC_EXENAME = 1; 1589 1590 // ??? 1591 const N_BTMASK = 0x000F; 1592 const N_TMASK = 0x0030; 1593 const N_TMASK1 = 0x00C0; 1594 const N_TMASK2 = 0x00F0; 1595 const N_BTSHFT = 4; 1596 const N_TSHIFT = 2; 1597 1598 const int 1599 IS_TEXT_UNICODE_ASCII16 = 0x0001, 1600 IS_TEXT_UNICODE_STATISTICS = 0x0002, 1601 IS_TEXT_UNICODE_CONTROLS = 0x0004, 1602 IS_TEXT_UNICODE_SIGNATURE = 0x0008, 1603 IS_TEXT_UNICODE_REVERSE_ASCII16 = 0x0010, 1604 IS_TEXT_UNICODE_REVERSE_STATISTICS = 0x0020, 1605 IS_TEXT_UNICODE_REVERSE_CONTROLS = 0x0040, 1606 IS_TEXT_UNICODE_REVERSE_SIGNATURE = 0x0080, 1607 IS_TEXT_UNICODE_ILLEGAL_CHARS = 0x0100, 1608 IS_TEXT_UNICODE_ODD_LENGTH = 0x0200, 1609 IS_TEXT_UNICODE_NULL_BYTES = 0x1000, 1610 IS_TEXT_UNICODE_UNICODE_MASK = 0x000F, 1611 IS_TEXT_UNICODE_REVERSE_MASK = 0x00F0, 1612 IS_TEXT_UNICODE_NOT_UNICODE_MASK = 0x0F00, 1613 IS_TEXT_UNICODE_NOT_ASCII_MASK = 0xF000; 1614 1615 const DWORD 1616 SERVICE_KERNEL_DRIVER = 0x0001, 1617 SERVICE_FILE_SYSTEM_DRIVER = 0x0002, 1618 SERVICE_ADAPTER = 0x0004, 1619 SERVICE_RECOGNIZER_DRIVER = 0x0008, 1620 SERVICE_WIN32_OWN_PROCESS = 0x0010, 1621 SERVICE_WIN32_SHARE_PROCESS = 0x0020, 1622 SERVICE_INTERACTIVE_PROCESS = 0x0100, 1623 SERVICE_DRIVER = 0x000B, 1624 SERVICE_WIN32 = 0x0030, 1625 SERVICE_TYPE_ALL = 0x013F; 1626 1627 enum : DWORD { 1628 SERVICE_BOOT_START = 0, 1629 SERVICE_SYSTEM_START = 1, 1630 SERVICE_AUTO_START = 2, 1631 SERVICE_DEMAND_START = 3, 1632 SERVICE_DISABLED = 4 1633 } 1634 1635 enum : DWORD { 1636 SERVICE_ERROR_IGNORE = 0, 1637 SERVICE_ERROR_NORMAL = 1, 1638 SERVICE_ERROR_SEVERE = 2, 1639 SERVICE_ERROR_CRITICAL = 3 1640 } 1641 1642 1643 const uint 1644 SE_OWNER_DEFAULTED = 0x0001, 1645 SE_GROUP_DEFAULTED = 0x0002, 1646 SE_DACL_PRESENT = 0x0004, 1647 SE_DACL_DEFAULTED = 0x0008, 1648 SE_SACL_PRESENT = 0x0010, 1649 SE_SACL_DEFAULTED = 0x0020, 1650 SE_DACL_AUTO_INHERIT_REQ = 0x0100, 1651 SE_SACL_AUTO_INHERIT_REQ = 0x0200, 1652 SE_DACL_AUTO_INHERITED = 0x0400, 1653 SE_SACL_AUTO_INHERITED = 0x0800, 1654 SE_DACL_PROTECTED = 0x1000, 1655 SE_SACL_PROTECTED = 0x2000, 1656 SE_SELF_RELATIVE = 0x8000; 1657 1658 enum SECURITY_IMPERSONATION_LEVEL { 1659 SecurityAnonymous, 1660 SecurityIdentification, 1661 SecurityImpersonation, 1662 SecurityDelegation 1663 } 1664 alias SECURITY_IMPERSONATION_LEVEL* PSECURITY_IMPERSONATION_LEVEL; 1665 1666 alias BOOLEAN SECURITY_CONTEXT_TRACKING_MODE; 1667 alias BOOLEAN* PSECURITY_CONTEXT_TRACKING_MODE; 1668 1669 const size_t SECURITY_DESCRIPTOR_MIN_LENGTH = 20; 1670 1671 const DWORD 1672 SECURITY_DESCRIPTOR_REVISION = 1, 1673 SECURITY_DESCRIPTOR_REVISION1 = 1; 1674 1675 const DWORD 1676 SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001, 1677 SE_PRIVILEGE_ENABLED = 0x00000002, 1678 SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000; 1679 1680 const DWORD PRIVILEGE_SET_ALL_NECESSARY = 1; 1681 1682 const SECURITY_IMPERSONATION_LEVEL 1683 SECURITY_MAX_IMPERSONATION_LEVEL = SECURITY_IMPERSONATION_LEVEL.SecurityDelegation, 1684 DEFAULT_IMPERSONATION_LEVEL = SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation; 1685 1686 const BOOLEAN 1687 SECURITY_DYNAMIC_TRACKING = true, 1688 SECURITY_STATIC_TRACKING = false; 1689 1690 // also in ddk/ntifs.h 1691 const DWORD 1692 TOKEN_ASSIGN_PRIMARY = 0x0001, 1693 TOKEN_DUPLICATE = 0x0002, 1694 TOKEN_IMPERSONATE = 0x0004, 1695 TOKEN_QUERY = 0x0008, 1696 TOKEN_QUERY_SOURCE = 0x0010, 1697 TOKEN_ADJUST_PRIVILEGES = 0x0020, 1698 TOKEN_ADJUST_GROUPS = 0x0040, 1699 TOKEN_ADJUST_DEFAULT = 0x0080, 1700 1701 TOKEN_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED 1702 | TOKEN_ASSIGN_PRIMARY 1703 | TOKEN_DUPLICATE 1704 | TOKEN_IMPERSONATE 1705 | TOKEN_QUERY 1706 | TOKEN_QUERY_SOURCE 1707 | TOKEN_ADJUST_PRIVILEGES 1708 | TOKEN_ADJUST_GROUPS 1709 | TOKEN_ADJUST_DEFAULT, 1710 TOKEN_READ = STANDARD_RIGHTS_READ | TOKEN_QUERY, 1711 TOKEN_WRITE = STANDARD_RIGHTS_WRITE 1712 | TOKEN_ADJUST_PRIVILEGES 1713 | TOKEN_ADJUST_GROUPS 1714 | TOKEN_ADJUST_DEFAULT, 1715 TOKEN_EXECUTE = STANDARD_RIGHTS_EXECUTE; 1716 1717 const size_t TOKEN_SOURCE_LENGTH = 8; 1718 // end ddk/ntifs.h 1719 1720 enum : DWORD { 1721 DLL_PROCESS_DETACH, 1722 DLL_PROCESS_ATTACH, 1723 DLL_THREAD_ATTACH, 1724 DLL_THREAD_DETACH 1725 } 1726 1727 enum : DWORD { 1728 DBG_CONTINUE = 0x00010002, 1729 DBG_TERMINATE_THREAD = 0x40010003, 1730 DBG_TERMINATE_PROCESS = 0x40010004, 1731 DBG_CONTROL_C = 0x40010005, 1732 DBG_CONTROL_BREAK = 0x40010008, 1733 DBG_EXCEPTION_NOT_HANDLED = 0x80010001 1734 } 1735 1736 enum : DWORD { 1737 TAPE_ABSOLUTE_POSITION, 1738 TAPE_LOGICAL_POSITION, 1739 TAPE_PSEUDO_LOGICAL_POSITION 1740 } 1741 1742 enum : DWORD { 1743 TAPE_REWIND, 1744 TAPE_ABSOLUTE_BLOCK, 1745 TAPE_LOGICAL_BLOCK, 1746 TAPE_PSEUDO_LOGICAL_BLOCK, 1747 TAPE_SPACE_END_OF_DATA, 1748 TAPE_SPACE_RELATIVE_BLOCKS, 1749 TAPE_SPACE_FILEMARKS, 1750 TAPE_SPACE_SEQUENTIAL_FMKS, 1751 TAPE_SPACE_SETMARKS, 1752 TAPE_SPACE_SEQUENTIAL_SMKS 1753 } 1754 1755 const DWORD 1756 TAPE_DRIVE_FIXED = 0x00000001, 1757 TAPE_DRIVE_SELECT = 0x00000002, 1758 TAPE_DRIVE_INITIATOR = 0x00000004, 1759 TAPE_DRIVE_ERASE_SHORT = 0x00000010, 1760 TAPE_DRIVE_ERASE_LONG = 0x00000020, 1761 TAPE_DRIVE_ERASE_BOP_ONLY = 0x00000040, 1762 TAPE_DRIVE_ERASE_IMMEDIATE = 0x00000080, 1763 TAPE_DRIVE_TAPE_CAPACITY = 0x00000100, 1764 TAPE_DRIVE_TAPE_REMAINING = 0x00000200, 1765 TAPE_DRIVE_FIXED_BLOCK = 0x00000400, 1766 TAPE_DRIVE_VARIABLE_BLOCK = 0x00000800, 1767 TAPE_DRIVE_WRITE_PROTECT = 0x00001000, 1768 TAPE_DRIVE_EOT_WZ_SIZE = 0x00002000, 1769 TAPE_DRIVE_ECC = 0x00010000, 1770 TAPE_DRIVE_COMPRESSION = 0x00020000, 1771 TAPE_DRIVE_PADDING = 0x00040000, 1772 TAPE_DRIVE_REPORT_SMKS = 0x00080000, 1773 TAPE_DRIVE_GET_ABSOLUTE_BLK = 0x00100000, 1774 TAPE_DRIVE_GET_LOGICAL_BLK = 0x00200000, 1775 TAPE_DRIVE_SET_EOT_WZ_SIZE = 0x00400000, 1776 TAPE_DRIVE_EJECT_MEDIA = 0x01000000, 1777 TAPE_DRIVE_CLEAN_REQUESTS = 0x02000000, 1778 TAPE_DRIVE_SET_CMP_BOP_ONLY = 0x04000000, 1779 TAPE_DRIVE_RESERVED_BIT = 0x80000000; 1780 1781 const DWORD 1782 TAPE_DRIVE_LOAD_UNLOAD = 0x80000001, 1783 TAPE_DRIVE_TENSION = 0x80000002, 1784 TAPE_DRIVE_LOCK_UNLOCK = 0x80000004, 1785 TAPE_DRIVE_REWIND_IMMEDIATE = 0x80000008, 1786 TAPE_DRIVE_SET_BLOCK_SIZE = 0x80000010, 1787 TAPE_DRIVE_LOAD_UNLD_IMMED = 0x80000020, 1788 TAPE_DRIVE_TENSION_IMMED = 0x80000040, 1789 TAPE_DRIVE_LOCK_UNLK_IMMED = 0x80000080, 1790 TAPE_DRIVE_SET_ECC = 0x80000100, 1791 TAPE_DRIVE_SET_COMPRESSION = 0x80000200, 1792 TAPE_DRIVE_SET_PADDING = 0x80000400, 1793 TAPE_DRIVE_SET_REPORT_SMKS = 0x80000800, 1794 TAPE_DRIVE_ABSOLUTE_BLK = 0x80001000, 1795 TAPE_DRIVE_ABS_BLK_IMMED = 0x80002000, 1796 TAPE_DRIVE_LOGICAL_BLK = 0x80004000, 1797 TAPE_DRIVE_LOG_BLK_IMMED = 0x80008000, 1798 TAPE_DRIVE_END_OF_DATA = 0x80010000, 1799 TAPE_DRIVE_RELATIVE_BLKS = 0x80020000, 1800 TAPE_DRIVE_FILEMARKS = 0x80040000, 1801 TAPE_DRIVE_SEQUENTIAL_FMKS = 0x80080000, 1802 TAPE_DRIVE_SETMARKS = 0x80100000, 1803 TAPE_DRIVE_SEQUENTIAL_SMKS = 0x80200000, 1804 TAPE_DRIVE_REVERSE_POSITION = 0x80400000, 1805 TAPE_DRIVE_SPACE_IMMEDIATE = 0x80800000, 1806 TAPE_DRIVE_WRITE_SETMARKS = 0x81000000, 1807 TAPE_DRIVE_WRITE_FILEMARKS = 0x82000000, 1808 TAPE_DRIVE_WRITE_SHORT_FMKS = 0x84000000, 1809 TAPE_DRIVE_WRITE_LONG_FMKS = 0x88000000, 1810 TAPE_DRIVE_WRITE_MARK_IMMED = 0x90000000, 1811 TAPE_DRIVE_FORMAT = 0xA0000000, 1812 TAPE_DRIVE_FORMAT_IMMEDIATE = 0xC0000000, 1813 TAPE_DRIVE_HIGH_FEATURES = 0x80000000; 1814 1815 enum : DWORD { 1816 TAPE_FIXED_PARTITIONS = 0, 1817 TAPE_SELECT_PARTITIONS = 1, 1818 TAPE_INITIATOR_PARTITIONS = 2 1819 } 1820 1821 enum : DWORD { 1822 TAPE_SETMARKS, 1823 TAPE_FILEMARKS, 1824 TAPE_SHORT_FILEMARKS, 1825 TAPE_LONG_FILEMARKS 1826 } 1827 1828 enum : DWORD { 1829 TAPE_ERASE_SHORT, 1830 TAPE_ERASE_LONG 1831 } 1832 1833 enum : DWORD { 1834 TAPE_LOAD, 1835 TAPE_UNLOAD, 1836 TAPE_TENSION, 1837 TAPE_LOCK, 1838 TAPE_UNLOCK, 1839 TAPE_FORMAT 1840 } 1841 1842 enum : ULONG32 { 1843 VER_PLATFORM_WIN32s, 1844 VER_PLATFORM_WIN32_WINDOWS, 1845 VER_PLATFORM_WIN32_NT 1846 } 1847 1848 enum : UCHAR { 1849 VER_NT_WORKSTATION = 1, 1850 VER_NT_DOMAIN_CONTROLLER, 1851 VER_NT_SERVER 1852 } 1853 1854 const USHORT 1855 VER_SUITE_SMALLBUSINESS = 0x0001, 1856 VER_SUITE_ENTERPRISE = 0x0002, 1857 VER_SUITE_BACKOFFICE = 0x0004, 1858 VER_SUITE_TERMINAL = 0x0010, 1859 VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x0020, 1860 VER_SUITE_EMBEDDEDNT = 0x0040, 1861 VER_SUITE_DATACENTER = 0x0080, 1862 VER_SUITE_SINGLEUSERTS = 0x0100, 1863 VER_SUITE_PERSONAL = 0x0200, 1864 VER_SUITE_BLADE = 0x0400, 1865 VER_SUITE_STORAGE_SERVER = 0x2000, 1866 VER_SUITE_COMPUTE_SERVER = 0x4000; 1867 1868 const ULONG 1869 WT_EXECUTEDEFAULT = 0x00000000, 1870 WT_EXECUTEINIOTHREAD = 0x00000001, 1871 WT_EXECUTEINWAITTHREAD = 0x00000004, 1872 WT_EXECUTEONLYONCE = 0x00000008, 1873 WT_EXECUTELONGFUNCTION = 0x00000010, 1874 WT_EXECUTEINTIMERTHREAD = 0x00000020, 1875 WT_EXECUTEINPERSISTENTTHREAD = 0x00000080, 1876 WT_TRANSFER_IMPERSONATION = 0x00000100; 1877 1878 static if (_WIN32_WINNT_ONLY) { 1879 static if (_WIN32_WINNT >= 0x500) { 1880 const DWORD 1881 VER_MINORVERSION = 0x01, 1882 VER_MAJORVERSION = 0x02, 1883 VER_BUILDNUMBER = 0x04, 1884 VER_PLATFORMID = 0x08, 1885 VER_SERVICEPACKMINOR = 0x10, 1886 VER_SERVICEPACKMAJOR = 0x20, 1887 VER_SUITENAME = 0x40, 1888 VER_PRODUCT_TYPE = 0x80; 1889 1890 enum : DWORD { 1891 VER_EQUAL = 1, 1892 VER_GREATER, 1893 VER_GREATER_EQUAL, 1894 VER_LESS, 1895 VER_LESS_EQUAL, 1896 VER_AND, 1897 VER_OR // = 7 1898 } 1899 } 1900 1901 static if (_WIN32_WINNT >= 0x501) { 1902 enum : ULONG { 1903 ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION = 1, 1904 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, 1905 ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, 1906 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, 1907 ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION, 1908 ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION, 1909 ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION, // = 7 1910 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES = 9 1911 } 1912 } 1913 } 1914 1915 // Macros 1916 BYTE BTYPE(BYTE x) { return cast(BYTE) (x & N_BTMASK); } 1917 bool ISPTR(uint x) { return (x & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT); } 1918 bool ISFCN(uint x) { return (x & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT); } 1919 bool ISARY(uint x) { return (x & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT); } 1920 bool ISTAG(uint x) { 1921 return x == IMAGE_SYM_CLASS_STRUCT_TAG 1922 || x == IMAGE_SYM_CLASS_UNION_TAG 1923 || x == IMAGE_SYM_CLASS_ENUM_TAG; 1924 } 1925 uint INCREF(uint x) { 1926 return ((x & ~N_BTMASK) << N_TSHIFT) | (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT) 1927 | (x & N_BTMASK); 1928 } 1929 uint DECREF(uint x) { return ((x >>> N_TSHIFT) & ~N_BTMASK) | (x & N_BTMASK); } 1930 1931 const DWORD TLS_MINIMUM_AVAILABLE = 64; 1932 1933 const ULONG 1934 IO_REPARSE_TAG_RESERVED_ZERO = 0, 1935 IO_REPARSE_TAG_RESERVED_ONE = 1, 1936 IO_REPARSE_TAG_RESERVED_RANGE = IO_REPARSE_TAG_RESERVED_ONE, 1937 IO_REPARSE_TAG_SYMBOLIC_LINK = IO_REPARSE_TAG_RESERVED_ZERO, 1938 IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003, 1939 IO_REPARSE_TAG_SYMLINK = 0xA000000C, 1940 IO_REPARSE_TAG_VALID_VALUES = 0xE000FFFF; 1941 1942 /* Although these are semantically boolean, they are documented and 1943 * implemented to return ULONG; this behaviour is preserved for compatibility 1944 */ 1945 ULONG IsReparseTagMicrosoft(ULONG x) { return x & 0x80000000; } 1946 ULONG IsReparseTagHighLatency(ULONG x) { return x & 0x40000000; } 1947 ULONG IsReparseTagNameSurrogate(ULONG x) { return x & 0x20000000; } 1948 1949 bool IsReparseTagValid(ULONG x) { 1950 return !(x & ~IO_REPARSE_TAG_VALID_VALUES) && (x > IO_REPARSE_TAG_RESERVED_RANGE); 1951 } 1952 1953 // Doesn't seem to make sense, but anyway.... 1954 ULONG WT_SET_MAX_THREADPOOL_THREADS(ref ULONG Flags, ushort Limit) { 1955 return Flags |= Limit << 16; 1956 } 1957 1958 import win32.basetyps; 1959 /* also in win32.basetyps 1960 struct GUID { 1961 uint Data1; 1962 ushort Data2; 1963 ushort Data3; 1964 ubyte Data4[8]; 1965 } 1966 alias GUID* REFGUID, LPGUID; 1967 */ 1968 1969 struct GENERIC_MAPPING { 1970 ACCESS_MASK GenericRead; 1971 ACCESS_MASK GenericWrite; 1972 ACCESS_MASK GenericExecute; 1973 ACCESS_MASK GenericAll; 1974 } 1975 alias GENERIC_MAPPING* PGENERIC_MAPPING; 1976 1977 struct ACE_HEADER { 1978 BYTE AceType; 1979 BYTE AceFlags; 1980 WORD AceSize; 1981 } 1982 alias ACE_HEADER* PACE_HEADER; 1983 1984 struct ACCESS_ALLOWED_ACE { 1985 ACE_HEADER Header; 1986 ACCESS_MASK Mask; 1987 DWORD SidStart; 1988 } 1989 alias ACCESS_ALLOWED_ACE* PACCESS_ALLOWED_ACE; 1990 1991 struct ACCESS_DENIED_ACE { 1992 ACE_HEADER Header; 1993 ACCESS_MASK Mask; 1994 DWORD SidStart; 1995 } 1996 alias ACCESS_DENIED_ACE* PACCESS_DENIED_ACE; 1997 1998 struct SYSTEM_AUDIT_ACE { 1999 ACE_HEADER Header; 2000 ACCESS_MASK Mask; 2001 DWORD SidStart; 2002 } 2003 alias SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE; 2004 2005 struct SYSTEM_ALARM_ACE { 2006 ACE_HEADER Header; 2007 ACCESS_MASK Mask; 2008 DWORD SidStart; 2009 } 2010 alias SYSTEM_ALARM_ACE* PSYSTEM_ALARM_ACE; 2011 2012 struct ACCESS_ALLOWED_OBJECT_ACE { 2013 ACE_HEADER Header; 2014 ACCESS_MASK Mask; 2015 DWORD Flags; 2016 GUID ObjectType; 2017 GUID InheritedObjectType; 2018 DWORD SidStart; 2019 } 2020 alias ACCESS_ALLOWED_OBJECT_ACE* PACCESS_ALLOWED_OBJECT_ACE; 2021 2022 struct ACCESS_DENIED_OBJECT_ACE { 2023 ACE_HEADER Header; 2024 ACCESS_MASK Mask; 2025 DWORD Flags; 2026 GUID ObjectType; 2027 GUID InheritedObjectType; 2028 DWORD SidStart; 2029 } 2030 alias ACCESS_DENIED_OBJECT_ACE* PACCESS_DENIED_OBJECT_ACE; 2031 2032 struct SYSTEM_AUDIT_OBJECT_ACE { 2033 ACE_HEADER Header; 2034 ACCESS_MASK Mask; 2035 DWORD Flags; 2036 GUID ObjectType; 2037 GUID InheritedObjectType; 2038 DWORD SidStart; 2039 } 2040 alias SYSTEM_AUDIT_OBJECT_ACE* PSYSTEM_AUDIT_OBJECT_ACE; 2041 2042 struct SYSTEM_ALARM_OBJECT_ACE { 2043 ACE_HEADER Header; 2044 ACCESS_MASK Mask; 2045 DWORD Flags; 2046 GUID ObjectType; 2047 GUID InheritedObjectType; 2048 DWORD SidStart; 2049 } 2050 alias SYSTEM_ALARM_OBJECT_ACE* PSYSTEM_ALARM_OBJECT_ACE; 2051 2052 struct ACL { 2053 BYTE AclRevision; 2054 BYTE Sbz1; 2055 WORD AclSize; 2056 WORD AceCount; 2057 WORD Sbz2; 2058 } 2059 alias ACL* PACL; 2060 2061 struct ACL_REVISION_INFORMATION { 2062 DWORD AclRevision; 2063 } 2064 2065 struct ACL_SIZE_INFORMATION { 2066 DWORD AceCount; 2067 DWORD AclBytesInUse; 2068 DWORD AclBytesFree; 2069 } 2070 2071 version (X86) { 2072 // ??? 2073 const SIZE_OF_80387_REGISTERS = 80; 2074 const CONTEXT_i386 = 0x010000; 2075 const CONTEXT_i486 = 0x010000; 2076 const CONTEXT_CONTROL = CONTEXT_i386 | 0x01; 2077 const CONTEXT_INTEGER = CONTEXT_i386 | 0x02; 2078 const CONTEXT_SEGMENTS = CONTEXT_i386 | 0x04; 2079 const CONTEXT_FLOATING_POINT = CONTEXT_i386 | 0x08; 2080 const CONTEXT_DEBUG_REGISTERS = CONTEXT_i386 | 0x10; 2081 const CONTEXT_EXTENDED_REGISTERS = CONTEXT_i386 | 0x20; 2082 const CONTEXT_FULL = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS; 2083 const MAXIMUM_SUPPORTED_EXTENSION = 512; 2084 2085 struct FLOATING_SAVE_AREA { 2086 DWORD ControlWord; 2087 DWORD StatusWord; 2088 DWORD TagWord; 2089 DWORD ErrorOffset; 2090 DWORD ErrorSelector; 2091 DWORD DataOffset; 2092 DWORD DataSelector; 2093 BYTE[80] RegisterArea; 2094 DWORD Cr0NpxState; 2095 } 2096 2097 struct CONTEXT { 2098 DWORD ContextFlags; 2099 DWORD Dr0; 2100 DWORD Dr1; 2101 DWORD Dr2; 2102 DWORD Dr3; 2103 DWORD Dr6; 2104 DWORD Dr7; 2105 FLOATING_SAVE_AREA FloatSave; 2106 DWORD SegGs; 2107 DWORD SegFs; 2108 DWORD SegEs; 2109 DWORD SegDs; 2110 DWORD Edi; 2111 DWORD Esi; 2112 DWORD Ebx; 2113 DWORD Edx; 2114 DWORD Ecx; 2115 DWORD Eax; 2116 DWORD Ebp; 2117 DWORD Eip; 2118 DWORD SegCs; 2119 DWORD EFlags; 2120 DWORD Esp; 2121 DWORD SegSs; 2122 BYTE[MAXIMUM_SUPPORTED_EXTENSION] ExtendedRegisters; 2123 } 2124 2125 } else { 2126 static assert(false, "Unsupported CPU"); 2127 // Versions for PowerPC, Alpha, SHX, and MIPS removed. 2128 } 2129 2130 alias CONTEXT* PCONTEXT, LPCONTEXT; 2131 2132 struct EXCEPTION_RECORD { 2133 DWORD ExceptionCode; 2134 DWORD ExceptionFlags; 2135 EXCEPTION_RECORD* ExceptionRecord; 2136 PVOID ExceptionAddress; 2137 DWORD NumberParameters; 2138 DWORD[EXCEPTION_MAXIMUM_PARAMETERS] ExceptionInformation; 2139 } 2140 alias EXCEPTION_RECORD* PEXCEPTION_RECORD, LPEXCEPTION_RECORD; 2141 2142 struct EXCEPTION_POINTERS { 2143 PEXCEPTION_RECORD ExceptionRecord; 2144 PCONTEXT ContextRecord; 2145 } 2146 alias EXCEPTION_POINTERS* PEXCEPTION_POINTERS, LPEXCEPTION_POINTERS; 2147 2148 union LARGE_INTEGER { 2149 struct { 2150 uint LowPart; 2151 int HighPart; 2152 } 2153 long QuadPart; 2154 } 2155 alias LARGE_INTEGER* PLARGE_INTEGER; 2156 2157 union ULARGE_INTEGER { 2158 struct { 2159 uint LowPart; 2160 uint HighPart; 2161 } 2162 ulong QuadPart; 2163 } 2164 alias ULARGE_INTEGER* PULARGE_INTEGER; 2165 2166 alias LARGE_INTEGER LUID; 2167 alias LUID* PLUID; 2168 2169 const LUID SYSTEM_LUID = { QuadPart:999 }; 2170 2171 align(4) struct LUID_AND_ATTRIBUTES { 2172 LUID Luid; 2173 DWORD Attributes; 2174 } 2175 alias LUID_AND_ATTRIBUTES* PLUID_AND_ATTRIBUTES; 2176 2177 struct PRIVILEGE_SET { 2178 DWORD PrivilegeCount; 2179 DWORD Control; 2180 LUID_AND_ATTRIBUTES _Privilege; 2181 2182 LUID_AND_ATTRIBUTES* Privilege() { return &_Privilege; } 2183 } 2184 alias PRIVILEGE_SET* PPRIVILEGE_SET; 2185 2186 struct SECURITY_ATTRIBUTES { 2187 DWORD nLength; 2188 LPVOID lpSecurityDescriptor; 2189 BOOL bInheritHandle; 2190 } 2191 alias SECURITY_ATTRIBUTES* PSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES; 2192 2193 struct SECURITY_QUALITY_OF_SERVICE { 2194 DWORD Length; 2195 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 2196 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; 2197 BOOLEAN EffectiveOnly; 2198 } 2199 alias SECURITY_QUALITY_OF_SERVICE* PSECURITY_QUALITY_OF_SERVICE; 2200 2201 alias PVOID PACCESS_TOKEN; 2202 2203 struct SE_IMPERSONATION_STATE { 2204 PACCESS_TOKEN Token; 2205 BOOLEAN CopyOnOpen; 2206 BOOLEAN EffectiveOnly; 2207 SECURITY_IMPERSONATION_LEVEL Level; 2208 } 2209 alias SE_IMPERSONATION_STATE* PSE_IMPERSONATION_STATE; 2210 2211 struct SID_IDENTIFIER_AUTHORITY { 2212 BYTE[6] Value; 2213 } 2214 alias SID_IDENTIFIER_AUTHORITY* PSID_IDENTIFIER_AUTHORITY, LPSID_IDENTIFIER_AUTHORITY; 2215 2216 alias PVOID PSID; 2217 2218 struct SID { 2219 BYTE Revision; 2220 BYTE SubAuthorityCount; 2221 SID_IDENTIFIER_AUTHORITY IdentifierAuthority; 2222 DWORD _SubAuthority; 2223 2224 DWORD* SubAuthority() { return &_SubAuthority; } 2225 } 2226 alias SID* PISID; 2227 2228 struct SID_AND_ATTRIBUTES { 2229 PSID Sid; 2230 DWORD Attributes; 2231 } 2232 alias SID_AND_ATTRIBUTES* PSID_AND_ATTRIBUTES; 2233 2234 struct TOKEN_SOURCE { 2235 CHAR[TOKEN_SOURCE_LENGTH] SourceName; 2236 LUID SourceIdentifier; 2237 } 2238 alias TOKEN_SOURCE* PTOKEN_SOURCE; 2239 2240 struct TOKEN_CONTROL { 2241 LUID TokenId; 2242 LUID AuthenticationId; 2243 LUID ModifiedId; 2244 TOKEN_SOURCE TokenSource; 2245 } 2246 alias TOKEN_CONTROL* PTOKEN_CONTROL; 2247 2248 struct TOKEN_DEFAULT_DACL { 2249 PACL DefaultDacl; 2250 } 2251 alias TOKEN_DEFAULT_DACL* PTOKEN_DEFAULT_DACL; 2252 2253 struct TOKEN_GROUPS { 2254 DWORD GroupCount; 2255 SID_AND_ATTRIBUTES _Groups; 2256 2257 SID_AND_ATTRIBUTES* Groups() { return &_Groups; } 2258 } 2259 alias TOKEN_GROUPS* PTOKEN_GROUPS, LPTOKEN_GROUPS; 2260 2261 struct TOKEN_OWNER { 2262 PSID Owner; 2263 } 2264 alias TOKEN_OWNER* PTOKEN_OWNER; 2265 2266 struct TOKEN_PRIMARY_GROUP { 2267 PSID PrimaryGroup; 2268 } 2269 alias TOKEN_PRIMARY_GROUP* PTOKEN_PRIMARY_GROUP; 2270 2271 struct TOKEN_PRIVILEGES { 2272 DWORD PrivilegeCount; 2273 LUID_AND_ATTRIBUTES _Privileges; 2274 2275 LUID_AND_ATTRIBUTES* Privileges() { return &_Privileges; } 2276 } 2277 alias TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES, LPTOKEN_PRIVILEGES; 2278 2279 enum TOKEN_TYPE { 2280 TokenPrimary = 1, 2281 TokenImpersonation 2282 } 2283 alias TOKEN_TYPE* PTOKEN_TYPE; 2284 2285 struct TOKEN_STATISTICS { 2286 LUID TokenId; 2287 LUID AuthenticationId; 2288 LARGE_INTEGER ExpirationTime; 2289 TOKEN_TYPE TokenType; 2290 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 2291 DWORD DynamicCharged; 2292 DWORD DynamicAvailable; 2293 DWORD GroupCount; 2294 DWORD PrivilegeCount; 2295 LUID ModifiedId; 2296 } 2297 alias TOKEN_STATISTICS* PTOKEN_STATISTICS; 2298 2299 struct TOKEN_USER { 2300 SID_AND_ATTRIBUTES User; 2301 } 2302 alias TOKEN_USER* PTOKEN_USER; 2303 2304 alias DWORD SECURITY_INFORMATION; 2305 alias SECURITY_INFORMATION* PSECURITY_INFORMATION; 2306 alias WORD SECURITY_DESCRIPTOR_CONTROL; 2307 alias SECURITY_DESCRIPTOR_CONTROL* PSECURITY_DESCRIPTOR_CONTROL; 2308 2309 struct SECURITY_DESCRIPTOR { 2310 BYTE Revision; 2311 BYTE Sbz1; 2312 SECURITY_DESCRIPTOR_CONTROL Control; 2313 PSID Owner; 2314 PSID Group; 2315 PACL Sacl; 2316 PACL Dacl; 2317 } 2318 alias SECURITY_DESCRIPTOR* PSECURITY_DESCRIPTOR, PISECURITY_DESCRIPTOR; 2319 2320 enum TOKEN_INFORMATION_CLASS { 2321 TokenUser = 1, 2322 TokenGroups, 2323 TokenPrivileges, 2324 TokenOwner, 2325 TokenPrimaryGroup, 2326 TokenDefaultDacl, 2327 TokenSource, 2328 TokenType, 2329 TokenImpersonationLevel, 2330 TokenStatistics, 2331 TokenRestrictedSids, 2332 TokenSessionId, 2333 TokenGroupsAndPrivileges, 2334 TokenSessionReference, 2335 TokenSandBoxInert, 2336 TokenAuditPolicy, 2337 TokenOrigin 2338 } 2339 2340 enum SID_NAME_USE { 2341 SidTypeUser = 1, 2342 SidTypeGroup, 2343 SidTypeDomain, 2344 SidTypeAlias, 2345 SidTypeWellKnownGroup, 2346 SidTypeDeletedAccount, 2347 SidTypeInvalid, 2348 SidTypeUnknown, 2349 SidTypeComputer 2350 } 2351 alias SID_NAME_USE* PSID_NAME_USE; 2352 2353 struct QUOTA_LIMITS { 2354 SIZE_T PagedPoolLimit; 2355 SIZE_T NonPagedPoolLimit; 2356 SIZE_T MinimumWorkingSetSize; 2357 SIZE_T MaximumWorkingSetSize; 2358 SIZE_T PagefileLimit; 2359 LARGE_INTEGER TimeLimit; 2360 } 2361 alias QUOTA_LIMITS* PQUOTA_LIMITS; 2362 2363 struct IO_COUNTERS { 2364 ULONGLONG ReadOperationCount; 2365 ULONGLONG WriteOperationCount; 2366 ULONGLONG OtherOperationCount; 2367 ULONGLONG ReadTransferCount; 2368 ULONGLONG WriteTransferCount; 2369 ULONGLONG OtherTransferCount; 2370 } 2371 alias IO_COUNTERS* PIO_COUNTERS; 2372 2373 struct FILE_NOTIFY_INFORMATION { 2374 DWORD NextEntryOffset; 2375 DWORD Action; 2376 DWORD FileNameLength; 2377 WCHAR _FileName; 2378 2379 WCHAR* FileName() { return &_FileName; } 2380 } 2381 alias FILE_NOTIFY_INFORMATION* PFILE_NOTIFY_INFORMATION; 2382 2383 struct TAPE_ERASE { 2384 DWORD Type; 2385 BOOLEAN Immediate; 2386 } 2387 alias TAPE_ERASE* PTAPE_ERASE; 2388 2389 struct TAPE_GET_DRIVE_PARAMETERS { 2390 BOOLEAN ECC; 2391 BOOLEAN Compression; 2392 BOOLEAN DataPadding; 2393 BOOLEAN ReportSetmarks; 2394 DWORD DefaultBlockSize; 2395 DWORD MaximumBlockSize; 2396 DWORD MinimumBlockSize; 2397 DWORD MaximumPartitionCount; 2398 DWORD FeaturesLow; 2399 DWORD FeaturesHigh; 2400 DWORD EOTWarningZoneSize; 2401 } 2402 alias TAPE_GET_DRIVE_PARAMETERS* PTAPE_GET_DRIVE_PARAMETERS; 2403 2404 struct TAPE_GET_MEDIA_PARAMETERS { 2405 LARGE_INTEGER Capacity; 2406 LARGE_INTEGER Remaining; 2407 DWORD BlockSize; 2408 DWORD PartitionCount; 2409 BOOLEAN WriteProtected; 2410 } 2411 alias TAPE_GET_MEDIA_PARAMETERS* PTAPE_GET_MEDIA_PARAMETERS; 2412 2413 struct TAPE_GET_POSITION { 2414 ULONG Type; 2415 ULONG Partition; 2416 ULONG OffsetLow; 2417 ULONG OffsetHigh; 2418 } 2419 alias TAPE_GET_POSITION* PTAPE_GET_POSITION; 2420 2421 struct TAPE_PREPARE { 2422 DWORD Operation; 2423 BOOLEAN Immediate; 2424 } 2425 alias TAPE_PREPARE* PTAPE_PREPARE; 2426 2427 struct TAPE_SET_DRIVE_PARAMETERS { 2428 BOOLEAN ECC; 2429 BOOLEAN Compression; 2430 BOOLEAN DataPadding; 2431 BOOLEAN ReportSetmarks; 2432 ULONG EOTWarningZoneSize; 2433 } 2434 alias TAPE_SET_DRIVE_PARAMETERS* PTAPE_SET_DRIVE_PARAMETERS; 2435 2436 struct TAPE_SET_MEDIA_PARAMETERS { 2437 ULONG BlockSize; 2438 } 2439 alias TAPE_SET_MEDIA_PARAMETERS* PTAPE_SET_MEDIA_PARAMETERS; 2440 2441 struct TAPE_SET_POSITION { 2442 DWORD Method; 2443 DWORD Partition; 2444 LARGE_INTEGER Offset; 2445 BOOLEAN Immediate; 2446 } 2447 alias TAPE_SET_POSITION* PTAPE_SET_POSITION; 2448 2449 struct TAPE_WRITE_MARKS { 2450 DWORD Type; 2451 DWORD Count; 2452 BOOLEAN Immediate; 2453 } 2454 alias TAPE_WRITE_MARKS* PTAPE_WRITE_MARKS; 2455 2456 struct TAPE_CREATE_PARTITION { 2457 DWORD Method; 2458 DWORD Count; 2459 DWORD Size; 2460 } 2461 alias TAPE_CREATE_PARTITION* PTAPE_CREATE_PARTITION; 2462 2463 struct MEMORY_BASIC_INFORMATION { 2464 PVOID BaseAddress; 2465 PVOID AllocationBase; 2466 DWORD AllocationProtect; 2467 DWORD RegionSize; 2468 DWORD State; 2469 DWORD Protect; 2470 DWORD Type; 2471 } 2472 alias MEMORY_BASIC_INFORMATION* PMEMORY_BASIC_INFORMATION; 2473 2474 struct MESSAGE_RESOURCE_ENTRY { 2475 WORD Length; 2476 WORD Flags; 2477 BYTE _Text; 2478 2479 BYTE* Text() { return &_Text; } 2480 } 2481 alias MESSAGE_RESOURCE_ENTRY* PMESSAGE_RESOURCE_ENTRY; 2482 2483 struct MESSAGE_RESOURCE_BLOCK { 2484 DWORD LowId; 2485 DWORD HighId; 2486 DWORD OffsetToEntries; 2487 } 2488 alias MESSAGE_RESOURCE_BLOCK* PMESSAGE_RESOURCE_BLOCK; 2489 2490 struct MESSAGE_RESOURCE_DATA { 2491 DWORD NumberOfBlocks; 2492 MESSAGE_RESOURCE_BLOCK _Blocks; 2493 2494 MESSAGE_RESOURCE_BLOCK* Blocks() { return &_Blocks; } 2495 } 2496 alias MESSAGE_RESOURCE_DATA* PMESSAGE_RESOURCE_DATA; 2497 2498 struct LIST_ENTRY { 2499 LIST_ENTRY* Flink; 2500 LIST_ENTRY* Blink; 2501 } 2502 alias LIST_ENTRY* PLIST_ENTRY; 2503 2504 struct SINGLE_LIST_ENTRY { 2505 SINGLE_LIST_ENTRY* Next; 2506 } 2507 alias SINGLE_LIST_ENTRY SLIST_ENTRY; 2508 alias SINGLE_LIST_ENTRY* PSINGLE_LIST_ENTRY, PSLIST_ENTRY; 2509 2510 union SLIST_HEADER { 2511 ULONGLONG Alignment; 2512 struct { 2513 SLIST_ENTRY Next; 2514 WORD Depth; 2515 WORD Sequence; 2516 } 2517 } 2518 alias SLIST_HEADER* PSLIST_HEADER; 2519 2520 struct RTL_CRITICAL_SECTION_DEBUG { 2521 WORD Type; 2522 WORD CreatorBackTraceIndex; 2523 RTL_CRITICAL_SECTION* CriticalSection; 2524 LIST_ENTRY ProcessLocksList; 2525 DWORD EntryCount; 2526 DWORD ContentionCount; 2527 DWORD[2] Spare; 2528 } 2529 alias RTL_CRITICAL_SECTION_DEBUG* PRTL_CRITICAL_SECTION_DEBUG; 2530 2531 struct RTL_CRITICAL_SECTION { 2532 PRTL_CRITICAL_SECTION_DEBUG DebugInfo; 2533 LONG LockCount; 2534 LONG RecursionCount; 2535 HANDLE OwningThread; 2536 HANDLE LockSemaphore; 2537 DWORD Reserved; 2538 } 2539 alias RTL_CRITICAL_SECTION* PRTL_CRITICAL_SECTION; 2540 2541 struct EVENTLOGRECORD { 2542 DWORD Length; 2543 DWORD Reserved; 2544 DWORD RecordNumber; 2545 DWORD TimeGenerated; 2546 DWORD TimeWritten; 2547 DWORD EventID; 2548 WORD EventType; 2549 WORD NumStrings; 2550 WORD EventCategory; 2551 WORD ReservedFlags; 2552 DWORD ClosingRecordNumber; 2553 DWORD StringOffset; 2554 DWORD UserSidLength; 2555 DWORD UserSidOffset; 2556 DWORD DataLength; 2557 DWORD DataOffset; 2558 } 2559 alias EVENTLOGRECORD* PEVENTLOGRECORD; 2560 2561 struct OSVERSIONINFOA { 2562 DWORD dwOSVersionInfoSize; 2563 DWORD dwMajorVersion; 2564 DWORD dwMinorVersion; 2565 DWORD dwBuildNumber; 2566 DWORD dwPlatformId; 2567 CHAR[128] szCSDVersion; 2568 } 2569 alias OSVERSIONINFOA* POSVERSIONINFOA, LPOSVERSIONINFOA; 2570 2571 struct OSVERSIONINFOW { 2572 DWORD dwOSVersionInfoSize; 2573 DWORD dwMajorVersion; 2574 DWORD dwMinorVersion; 2575 DWORD dwBuildNumber; 2576 DWORD dwPlatformId; 2577 WCHAR[128] szCSDVersion; 2578 } 2579 alias OSVERSIONINFOW* POSVERSIONINFOW, LPOSVERSIONINFOW; 2580 2581 struct OSVERSIONINFOEXA { 2582 DWORD dwOSVersionInfoSize; 2583 DWORD dwMajorVersion; 2584 DWORD dwMinorVersion; 2585 DWORD dwBuildNumber; 2586 DWORD dwPlatformId; 2587 CHAR[128] szCSDVersion; 2588 WORD wServicePackMajor; 2589 WORD wServicePackMinor; 2590 WORD wSuiteMask; 2591 BYTE wProductType; 2592 BYTE wReserved; 2593 } 2594 alias OSVERSIONINFOEXA* POSVERSIONINFOEXA, LPOSVERSIONINFOEXA; 2595 2596 struct OSVERSIONINFOEXW { 2597 DWORD dwOSVersionInfoSize; 2598 DWORD dwMajorVersion; 2599 DWORD dwMinorVersion; 2600 DWORD dwBuildNumber; 2601 DWORD dwPlatformId; 2602 WCHAR[128] szCSDVersion; 2603 WORD wServicePackMajor; 2604 WORD wServicePackMinor; 2605 WORD wSuiteMask; 2606 BYTE wProductType; 2607 BYTE wReserved; 2608 } 2609 alias OSVERSIONINFOEXW* POSVERSIONINFOEXW, LPOSVERSIONINFOEXW; 2610 2611 align(2) struct IMAGE_VXD_HEADER { 2612 WORD e32_magic; 2613 BYTE e32_border; 2614 BYTE e32_worder; 2615 DWORD e32_level; 2616 WORD e32_cpu; 2617 WORD e32_os; 2618 DWORD e32_ver; 2619 DWORD e32_mflags; 2620 DWORD e32_mpages; 2621 DWORD e32_startobj; 2622 DWORD e32_eip; 2623 DWORD e32_stackobj; 2624 DWORD e32_esp; 2625 DWORD e32_pagesize; 2626 DWORD e32_lastpagesize; 2627 DWORD e32_fixupsize; 2628 DWORD e32_fixupsum; 2629 DWORD e32_ldrsize; 2630 DWORD e32_ldrsum; 2631 DWORD e32_objtab; 2632 DWORD e32_objcnt; 2633 DWORD e32_objmap; 2634 DWORD e32_itermap; 2635 DWORD e32_rsrctab; 2636 DWORD e32_rsrccnt; 2637 DWORD e32_restab; 2638 DWORD e32_enttab; 2639 DWORD e32_dirtab; 2640 DWORD e32_dircnt; 2641 DWORD e32_fpagetab; 2642 DWORD e32_frectab; 2643 DWORD e32_impmod; 2644 DWORD e32_impmodcnt; 2645 DWORD e32_impproc; 2646 DWORD e32_pagesum; 2647 DWORD e32_datapage; 2648 DWORD e32_preload; 2649 DWORD e32_nrestab; 2650 DWORD e32_cbnrestab; 2651 DWORD e32_nressum; 2652 DWORD e32_autodata; 2653 DWORD e32_debuginfo; 2654 DWORD e32_debuglen; 2655 DWORD e32_instpreload; 2656 DWORD e32_instdemand; 2657 DWORD e32_heapsize; 2658 BYTE[12] e32_res3; 2659 DWORD e32_winresoff; 2660 DWORD e32_winreslen; 2661 WORD e32_devid; 2662 WORD e32_ddkver; 2663 } 2664 alias IMAGE_VXD_HEADER* PIMAGE_VXD_HEADER; 2665 2666 align(4): 2667 struct IMAGE_FILE_HEADER { 2668 WORD Machine; 2669 WORD NumberOfSections; 2670 DWORD TimeDateStamp; 2671 DWORD PointerToSymbolTable; 2672 DWORD NumberOfSymbols; 2673 WORD SizeOfOptionalHeader; 2674 WORD Characteristics; 2675 } 2676 alias IMAGE_FILE_HEADER* PIMAGE_FILE_HEADER; 2677 // const IMAGE_SIZEOF_FILE_HEADER = IMAGE_FILE_HEADER.sizeof; 2678 2679 struct IMAGE_DATA_DIRECTORY { 2680 DWORD VirtualAddress; 2681 DWORD Size; 2682 } 2683 alias IMAGE_DATA_DIRECTORY* PIMAGE_DATA_DIRECTORY; 2684 2685 struct IMAGE_OPTIONAL_HEADER32 { 2686 WORD Magic; 2687 BYTE MajorLinkerVersion; 2688 BYTE MinorLinkerVersion; 2689 DWORD SizeOfCode; 2690 DWORD SizeOfInitializedData; 2691 DWORD SizeOfUninitializedData; 2692 DWORD AddressOfEntryPoint; 2693 DWORD BaseOfCode; 2694 DWORD BaseOfData; 2695 DWORD ImageBase; 2696 DWORD SectionAlignment; 2697 DWORD FileAlignment; 2698 WORD MajorOperatingSystemVersion; 2699 WORD MinorOperatingSystemVersion; 2700 WORD MajorImageVersion; 2701 WORD MinorImageVersion; 2702 WORD MajorSubsystemVersion; 2703 WORD MinorSubsystemVersion; 2704 DWORD Win32VersionValue; 2705 DWORD SizeOfImage; 2706 DWORD SizeOfHeaders; 2707 DWORD CheckSum; 2708 WORD Subsystem; 2709 WORD DllCharacteristics; 2710 DWORD SizeOfStackReserve; 2711 DWORD SizeOfStackCommit; 2712 DWORD SizeOfHeapReserve; 2713 DWORD SizeOfHeapCommit; 2714 DWORD LoaderFlags; 2715 DWORD NumberOfRvaAndSizes; 2716 IMAGE_DATA_DIRECTORY[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] DataDirectory; 2717 } 2718 alias IMAGE_OPTIONAL_HEADER32* PIMAGE_OPTIONAL_HEADER32; 2719 2720 struct IMAGE_OPTIONAL_HEADER64 { 2721 WORD Magic; 2722 BYTE MajorLinkerVersion; 2723 BYTE MinorLinkerVersion; 2724 DWORD SizeOfCode; 2725 DWORD SizeOfInitializedData; 2726 DWORD SizeOfUninitializedData; 2727 DWORD AddressOfEntryPoint; 2728 DWORD BaseOfCode; 2729 ULONGLONG ImageBase; 2730 DWORD SectionAlignment; 2731 DWORD FileAlignment; 2732 WORD MajorOperatingSystemVersion; 2733 WORD MinorOperatingSystemVersion; 2734 WORD MajorImageVersion; 2735 WORD MinorImageVersion; 2736 WORD MajorSubsystemVersion; 2737 WORD MinorSubsystemVersion; 2738 DWORD Win32VersionValue; 2739 DWORD SizeOfImage; 2740 DWORD SizeOfHeaders; 2741 DWORD CheckSum; 2742 WORD Subsystem; 2743 WORD DllCharacteristics; 2744 ULONGLONG SizeOfStackReserve; 2745 ULONGLONG SizeOfStackCommit; 2746 ULONGLONG SizeOfHeapReserve; 2747 ULONGLONG SizeOfHeapCommit; 2748 DWORD LoaderFlags; 2749 DWORD NumberOfRvaAndSizes; 2750 IMAGE_DATA_DIRECTORY[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] DataDirectory; 2751 } 2752 alias IMAGE_OPTIONAL_HEADER64* PIMAGE_OPTIONAL_HEADER64; 2753 2754 struct IMAGE_ROM_OPTIONAL_HEADER { 2755 WORD Magic; 2756 BYTE MajorLinkerVersion; 2757 BYTE MinorLinkerVersion; 2758 DWORD SizeOfCode; 2759 DWORD SizeOfInitializedData; 2760 DWORD SizeOfUninitializedData; 2761 DWORD AddressOfEntryPoint; 2762 DWORD BaseOfCode; 2763 DWORD BaseOfData; 2764 DWORD BaseOfBss; 2765 DWORD GprMask; 2766 DWORD[4] CprMask; 2767 DWORD GpValue; 2768 } 2769 alias IMAGE_ROM_OPTIONAL_HEADER* PIMAGE_ROM_OPTIONAL_HEADER; 2770 2771 align(2): 2772 struct IMAGE_DOS_HEADER { 2773 WORD e_magic; 2774 WORD e_cblp; 2775 WORD e_cp; 2776 WORD e_crlc; 2777 WORD e_cparhdr; 2778 WORD e_minalloc; 2779 WORD e_maxalloc; 2780 WORD e_ss; 2781 WORD e_sp; 2782 WORD e_csum; 2783 WORD e_ip; 2784 WORD e_cs; 2785 WORD e_lfarlc; 2786 WORD e_ovno; 2787 WORD[4] e_res; 2788 WORD e_oemid; 2789 WORD e_oeminfo; 2790 WORD[10] e_res2; 2791 LONG e_lfanew; 2792 } 2793 alias IMAGE_DOS_HEADER* PIMAGE_DOS_HEADER; 2794 2795 struct IMAGE_OS2_HEADER { 2796 WORD ne_magic; 2797 CHAR ne_ver; 2798 CHAR ne_rev; 2799 WORD ne_enttab; 2800 WORD ne_cbenttab; 2801 LONG ne_crc; 2802 WORD ne_flags; 2803 WORD ne_autodata; 2804 WORD ne_heap; 2805 WORD ne_stack; 2806 LONG ne_csip; 2807 LONG ne_sssp; 2808 WORD ne_cseg; 2809 WORD ne_cmod; 2810 WORD ne_cbnrestab; 2811 WORD ne_segtab; 2812 WORD ne_rsrctab; 2813 WORD ne_restab; 2814 WORD ne_modtab; 2815 WORD ne_imptab; 2816 LONG ne_nrestab; 2817 WORD ne_cmovent; 2818 WORD ne_align; 2819 WORD ne_cres; 2820 BYTE ne_exetyp; 2821 BYTE ne_flagsothers; 2822 WORD ne_pretthunks; 2823 WORD ne_psegrefbytes; 2824 WORD ne_swaparea; 2825 WORD ne_expver; 2826 } 2827 alias IMAGE_OS2_HEADER* PIMAGE_OS2_HEADER; 2828 2829 align(4) struct IMAGE_NT_HEADERS32 { 2830 DWORD Signature; 2831 IMAGE_FILE_HEADER FileHeader; 2832 IMAGE_OPTIONAL_HEADER OptionalHeader; 2833 } 2834 alias IMAGE_NT_HEADERS32* PIMAGE_NT_HEADERS32; 2835 2836 align(4) struct IMAGE_NT_HEADERS64 { 2837 DWORD Signature; 2838 IMAGE_FILE_HEADER FileHeader; 2839 IMAGE_OPTIONAL_HEADER OptionalHeader; 2840 } 2841 alias IMAGE_NT_HEADERS64* PIMAGE_NT_HEADERS64; 2842 2843 struct IMAGE_ROM_HEADERS { 2844 IMAGE_FILE_HEADER FileHeader; 2845 IMAGE_ROM_OPTIONAL_HEADER OptionalHeader; 2846 } 2847 alias IMAGE_ROM_HEADERS* PIMAGE_ROM_HEADERS; 2848 2849 struct IMAGE_SECTION_HEADER { 2850 BYTE[IMAGE_SIZEOF_SHORT_NAME] Name; 2851 union _Misc { 2852 DWORD PhysicalAddress; 2853 DWORD VirtualSize; 2854 } 2855 _Misc Misc; 2856 DWORD VirtualAddress; 2857 DWORD SizeOfRawData; 2858 DWORD PointerToRawData; 2859 DWORD PointerToRelocations; 2860 DWORD PointerToLinenumbers; 2861 WORD NumberOfRelocations; 2862 WORD NumberOfLinenumbers; 2863 DWORD Characteristics; 2864 } 2865 alias IMAGE_SECTION_HEADER* PIMAGE_SECTION_HEADER; 2866 2867 struct IMAGE_SYMBOL { 2868 union _N { 2869 BYTE[8] ShortName; 2870 struct Name { 2871 DWORD Short; 2872 DWORD Long; 2873 } 2874 PBYTE[2] LongName; 2875 } 2876 _N N; 2877 DWORD Value; 2878 SHORT SectionNumber; 2879 WORD Type; 2880 BYTE StorageClass; 2881 BYTE NumberOfAuxSymbols; 2882 } 2883 alias IMAGE_SYMBOL* PIMAGE_SYMBOL; 2884 2885 union IMAGE_AUX_SYMBOL { 2886 struct _Sym { 2887 DWORD TagIndex; 2888 union _Misc { 2889 struct _LnSz { 2890 WORD Linenumber; 2891 WORD Size; 2892 } 2893 _LnSz LnSz; 2894 DWORD TotalSize; 2895 } 2896 _Misc Misc; 2897 union _FcnAry { 2898 struct _Function { 2899 DWORD PointerToLinenumber; 2900 DWORD PointerToNextFunction; 2901 } 2902 _Function Function; 2903 struct _Array { 2904 WORD[4] Dimension; 2905 } 2906 _Array Array; 2907 } 2908 _FcnAry FcnAry; 2909 WORD TvIndex; 2910 } 2911 _Sym Sym; 2912 struct _File { 2913 BYTE[IMAGE_SIZEOF_SYMBOL] Name; 2914 } 2915 _File File; 2916 struct _Section { 2917 DWORD Length; 2918 WORD NumberOfRelocations; 2919 WORD NumberOfLinenumbers; 2920 DWORD CheckSum; 2921 SHORT Number; 2922 BYTE Selection; 2923 } 2924 _Section Section; 2925 } 2926 alias IMAGE_AUX_SYMBOL* PIMAGE_AUX_SYMBOL; 2927 2928 struct IMAGE_COFF_SYMBOLS_HEADER { 2929 DWORD NumberOfSymbols; 2930 DWORD LvaToFirstSymbol; 2931 DWORD NumberOfLinenumbers; 2932 DWORD LvaToFirstLinenumber; 2933 DWORD RvaToFirstByteOfCode; 2934 DWORD RvaToLastByteOfCode; 2935 DWORD RvaToFirstByteOfData; 2936 DWORD RvaToLastByteOfData; 2937 } 2938 alias IMAGE_COFF_SYMBOLS_HEADER* PIMAGE_COFF_SYMBOLS_HEADER; 2939 2940 struct IMAGE_RELOCATION { 2941 union { 2942 DWORD VirtualAddress; 2943 DWORD RelocCount; 2944 } 2945 DWORD SymbolTableIndex; 2946 WORD Type; 2947 } 2948 alias IMAGE_RELOCATION* PIMAGE_RELOCATION; 2949 2950 align(4) struct IMAGE_BASE_RELOCATION { 2951 DWORD VirtualAddress; 2952 DWORD SizeOfBlock; 2953 } 2954 alias IMAGE_BASE_RELOCATION* PIMAGE_BASE_RELOCATION; 2955 2956 align(2) struct IMAGE_LINENUMBER { 2957 union _Type { 2958 DWORD SymbolTableIndex; 2959 DWORD VirtualAddress; 2960 } 2961 _Type Type; 2962 WORD Linenumber; 2963 } 2964 alias IMAGE_LINENUMBER* PIMAGE_LINENUMBER; 2965 2966 align(4): 2967 struct IMAGE_ARCHIVE_MEMBER_HEADER { 2968 BYTE[16] Name; 2969 BYTE[12] Date; 2970 BYTE[6] UserID; 2971 BYTE[6] GroupID; 2972 BYTE[8] Mode; 2973 BYTE[10] Size; 2974 BYTE[2] EndHeader; 2975 } 2976 alias IMAGE_ARCHIVE_MEMBER_HEADER* PIMAGE_ARCHIVE_MEMBER_HEADER; 2977 2978 struct IMAGE_EXPORT_DIRECTORY { 2979 DWORD Characteristics; 2980 DWORD TimeDateStamp; 2981 WORD MajorVersion; 2982 WORD MinorVersion; 2983 DWORD Name; 2984 DWORD Base; 2985 DWORD NumberOfFunctions; 2986 DWORD NumberOfNames; 2987 DWORD AddressOfFunctions; 2988 DWORD AddressOfNames; 2989 DWORD AddressOfNameOrdinals; 2990 } 2991 alias IMAGE_EXPORT_DIRECTORY* PIMAGE_EXPORT_DIRECTORY; 2992 2993 struct IMAGE_IMPORT_BY_NAME { 2994 WORD Hint; 2995 BYTE _Name; 2996 2997 BYTE* Name() { 2998 return &_Name; 2999 } 3000 } 3001 alias IMAGE_IMPORT_BY_NAME* PIMAGE_IMPORT_BY_NAME; 3002 3003 struct IMAGE_THUNK_DATA32 { 3004 union _u1 { 3005 DWORD ForwarderString; 3006 DWORD Function; 3007 DWORD Ordinal; 3008 DWORD AddressOfData; 3009 } 3010 _u1 u1; 3011 } 3012 alias IMAGE_THUNK_DATA32* PIMAGE_THUNK_DATA32; 3013 3014 struct IMAGE_THUNK_DATA64 { 3015 union _u1 { 3016 ULONGLONG ForwarderString; 3017 ULONGLONG Function; 3018 ULONGLONG Ordinal; 3019 ULONGLONG AddressOfData; 3020 } 3021 _u1 u1; 3022 } 3023 alias IMAGE_THUNK_DATA64* PIMAGE_THUNK_DATA64; 3024 3025 struct IMAGE_IMPORT_DESCRIPTOR { 3026 union { 3027 DWORD Characteristics; 3028 DWORD OriginalFirstThunk; 3029 } 3030 DWORD TimeDateStamp; 3031 DWORD ForwarderChain; 3032 DWORD Name; 3033 DWORD FirstThunk; 3034 } 3035 alias IMAGE_IMPORT_DESCRIPTOR* PIMAGE_IMPORT_DESCRIPTOR; 3036 3037 struct IMAGE_BOUND_IMPORT_DESCRIPTOR { 3038 DWORD TimeDateStamp; 3039 WORD OffsetModuleName; 3040 WORD NumberOfModuleForwarderRefs; 3041 } 3042 alias IMAGE_BOUND_IMPORT_DESCRIPTOR* PIMAGE_BOUND_IMPORT_DESCRIPTOR; 3043 3044 struct IMAGE_BOUND_FORWARDER_REF { 3045 DWORD TimeDateStamp; 3046 WORD OffsetModuleName; 3047 WORD Reserved; 3048 } 3049 alias IMAGE_BOUND_FORWARDER_REF* PIMAGE_BOUND_FORWARDER_REF; 3050 3051 struct IMAGE_TLS_DIRECTORY32 { 3052 DWORD StartAddressOfRawData; 3053 DWORD EndAddressOfRawData; 3054 DWORD AddressOfIndex; 3055 DWORD AddressOfCallBacks; 3056 DWORD SizeOfZeroFill; 3057 DWORD Characteristics; 3058 } 3059 alias IMAGE_TLS_DIRECTORY32* PIMAGE_TLS_DIRECTORY32; 3060 3061 struct IMAGE_TLS_DIRECTORY64 { 3062 ULONGLONG StartAddressOfRawData; 3063 ULONGLONG EndAddressOfRawData; 3064 ULONGLONG AddressOfIndex; 3065 ULONGLONG AddressOfCallBacks; 3066 DWORD SizeOfZeroFill; 3067 DWORD Characteristics; 3068 } 3069 alias IMAGE_TLS_DIRECTORY64* PIMAGE_TLS_DIRECTORY64; 3070 3071 struct IMAGE_RESOURCE_DIRECTORY { 3072 DWORD Characteristics; 3073 DWORD TimeDateStamp; 3074 WORD MajorVersion; 3075 WORD MinorVersion; 3076 WORD NumberOfNamedEntries; 3077 WORD NumberOfIdEntries; 3078 } 3079 alias IMAGE_RESOURCE_DIRECTORY* PIMAGE_RESOURCE_DIRECTORY; 3080 3081 struct IMAGE_RESOURCE_DIRECTORY_ENTRY { 3082 union { 3083 /+struct { 3084 DWORD NameOffset:31; 3085 DWORD NameIsString:1; 3086 }+/ 3087 DWORD Name; 3088 WORD Id; 3089 } 3090 DWORD OffsetToData; 3091 /+struct { 3092 DWORD OffsetToDirectory:31; 3093 DWORD DataIsDirectory:1; 3094 }+/ 3095 3096 uint NameOffset() { return Name & 0x7FFFFFFF; } 3097 bool NameIsString() { return cast(bool)(Name & 0x80000000); } 3098 uint OffsetToDirectory() { return OffsetToData & 0x7FFFFFFF; } 3099 bool DataIsDirectory() { return cast(bool)(OffsetToData & 0x80000000); } 3100 3101 uint NameOffset(uint n) { 3102 Name = (Name & 0x80000000) | (n & 0x7FFFFFFF); 3103 return n & 0x7FFFFFFF; 3104 } 3105 3106 bool NameIsString(bool n) { 3107 Name = (Name & 0x7FFFFFFF) | (n << 31); return n; 3108 } 3109 3110 uint OffsetToDirectory(uint o) { 3111 OffsetToData = (OffsetToData & 0x80000000) | (o & 0x7FFFFFFF); 3112 return o & 0x7FFFFFFF; 3113 } 3114 3115 bool DataIsDirectory(bool d) { 3116 OffsetToData = (OffsetToData & 0x7FFFFFFF) | (d << 31); return d; 3117 } 3118 } 3119 alias IMAGE_RESOURCE_DIRECTORY_ENTRY* PIMAGE_RESOURCE_DIRECTORY_ENTRY; 3120 3121 struct IMAGE_RESOURCE_DIRECTORY_STRING { 3122 WORD Length; 3123 CHAR _NameString; 3124 3125 CHAR* NameString() { return &_NameString; } 3126 } 3127 alias IMAGE_RESOURCE_DIRECTORY_STRING* PIMAGE_RESOURCE_DIRECTORY_STRING; 3128 3129 struct IMAGE_RESOURCE_DIR_STRING_U { 3130 WORD Length; 3131 WCHAR _NameString; 3132 3133 WCHAR* NameString() { return &_NameString; } 3134 } 3135 alias IMAGE_RESOURCE_DIR_STRING_U* PIMAGE_RESOURCE_DIR_STRING_U; 3136 3137 struct IMAGE_RESOURCE_DATA_ENTRY { 3138 DWORD OffsetToData; 3139 DWORD Size; 3140 DWORD CodePage; 3141 DWORD Reserved; 3142 } 3143 alias IMAGE_RESOURCE_DATA_ENTRY* PIMAGE_RESOURCE_DATA_ENTRY; 3144 3145 struct IMAGE_LOAD_CONFIG_DIRECTORY { 3146 DWORD Characteristics; 3147 DWORD TimeDateStamp; 3148 WORD MajorVersion; 3149 WORD MinorVersion; 3150 DWORD GlobalFlagsClear; 3151 DWORD GlobalFlagsSet; 3152 DWORD CriticalSectionDefaultTimeout; 3153 DWORD DeCommitFreeBlockThreshold; 3154 DWORD DeCommitTotalFreeThreshold; 3155 PVOID LockPrefixTable; 3156 DWORD MaximumAllocationSize; 3157 DWORD VirtualMemoryThreshold; 3158 DWORD ProcessHeapFlags; 3159 DWORD[4] Reserved; 3160 } 3161 alias IMAGE_LOAD_CONFIG_DIRECTORY* PIMAGE_LOAD_CONFIG_DIRECTORY; 3162 3163 struct IMAGE_LOAD_CONFIG_DIRECTORY64 { 3164 DWORD Characteristics; 3165 DWORD TimeDateStamp; 3166 WORD MajorVersion; 3167 WORD MinorVersion; 3168 DWORD GlobalFlagsClear; 3169 DWORD GlobalFlagsSet; 3170 DWORD CriticalSectionDefaultTimeout; 3171 ULONGLONG DeCommitFreeBlockThreshold; 3172 ULONGLONG DeCommitTotalFreeThreshold; 3173 ULONGLONG LockPrefixTable; 3174 ULONGLONG MaximumAllocationSize; 3175 ULONGLONG VirtualMemoryThreshold; 3176 ULONGLONG ProcessAffinityMask; 3177 DWORD ProcessHeapFlags; 3178 WORD CSDFlags; 3179 WORD Reserved1; 3180 ULONGLONG EditList; 3181 DWORD[2] Reserved; 3182 } 3183 alias IMAGE_LOAD_CONFIG_DIRECTORY64* PIMAGE_LOAD_CONFIG_DIRECTORY64; 3184 3185 struct IMAGE_RUNTIME_FUNCTION_ENTRY { 3186 DWORD BeginAddress; 3187 DWORD EndAddress; 3188 PVOID ExceptionHandler; 3189 PVOID HandlerData; 3190 DWORD PrologEndAddress; 3191 } 3192 alias IMAGE_RUNTIME_FUNCTION_ENTRY* PIMAGE_RUNTIME_FUNCTION_ENTRY; 3193 3194 struct IMAGE_CE_RUNTIME_FUNCTION_ENTRY { 3195 uint FuncStart; 3196 union { 3197 ubyte PrologLen; 3198 uint _bf; 3199 } 3200 /+ 3201 unsigned int FuncLen:22; 3202 unsigned int ThirtyTwoBit:1; 3203 unsigned int ExceptionFlag:1; 3204 +/ 3205 uint FuncLen() { return (_bf >> 8) & 0x3FFFFF; } 3206 bool ThirtyTwoBit() { return cast(bool)(_bf & 0x40000000); } 3207 bool ExceptionFlag() { return cast(bool)(_bf & 0x80000000); } 3208 3209 uint FuncLen(uint f) { 3210 _bf = (_bf & ~0x3FFFFF00) | ((f & 0x3FFFFF) << 8); return f & 0x3FFFFF; 3211 } 3212 3213 bool ThirtyTwoBit(bool t) { 3214 _bf = (_bf & ~0x40000000) | (t << 30); return t; 3215 } 3216 3217 bool ExceptionFlag(bool e) { 3218 _bf = (_bf & ~0x80000000) | (e << 31); return e; 3219 } 3220 } 3221 alias IMAGE_CE_RUNTIME_FUNCTION_ENTRY* PIMAGE_CE_RUNTIME_FUNCTION_ENTRY; 3222 3223 struct IMAGE_DEBUG_DIRECTORY { 3224 DWORD Characteristics; 3225 DWORD TimeDateStamp; 3226 WORD MajorVersion; 3227 WORD MinorVersion; 3228 DWORD Type; 3229 DWORD SizeOfData; 3230 DWORD AddressOfRawData; 3231 DWORD PointerToRawData; 3232 } 3233 alias IMAGE_DEBUG_DIRECTORY* PIMAGE_DEBUG_DIRECTORY; 3234 3235 struct FPO_DATA { 3236 DWORD ulOffStart; 3237 DWORD cbProcSize; 3238 DWORD cdwLocals; 3239 WORD cdwParams; 3240 ubyte cbProlog; 3241 ubyte _bf; 3242 /+ 3243 WORD cbRegs:3; 3244 WORD fHasSEH:1; 3245 WORD fUseBP:1; 3246 WORD reserved:1; 3247 WORD cbFrame:2; 3248 +/ 3249 ubyte cbRegs() { return cast(ubyte)(_bf & 0x07); } 3250 bool fHasSEH() { return cast(bool)(_bf & 0x08); } 3251 bool fUseBP() { return cast(bool)(_bf & 0x10); } 3252 bool reserved() { return cast(bool)(_bf & 0x20); } 3253 ubyte cbFrame() { return cast(ubyte)(_bf >> 6); } 3254 3255 ubyte cbRegs(ubyte c) { 3256 _bf = cast(ubyte) ((_bf & ~0x07) | (c & 0x07)); 3257 return cast(ubyte)(c & 0x07); 3258 } 3259 3260 bool fHasSEH(bool f) { _bf = cast(ubyte)((_bf & ~0x08) | (f << 3)); return f; } 3261 bool fUseBP(bool f) { _bf = cast(ubyte)((_bf & ~0x10) | (f << 4)); return f; } 3262 bool reserved(bool r) { _bf = cast(ubyte)((_bf & ~0x20) | (r << 5)); return r; } 3263 3264 ubyte cbFrame(ubyte c) { 3265 _bf = cast(ubyte) ((_bf & ~0xC0) | ((c & 0x03) << 6)); 3266 return cast(ubyte)(c & 0x03); 3267 } 3268 } 3269 alias FPO_DATA* PFPO_DATA; 3270 3271 struct IMAGE_DEBUG_MISC { 3272 DWORD DataType; 3273 DWORD Length; 3274 BOOLEAN Unicode; 3275 BYTE[3] Reserved; 3276 BYTE _Data; 3277 3278 BYTE* Data() { return &_Data; } 3279 } 3280 alias IMAGE_DEBUG_MISC* PIMAGE_DEBUG_MISC; 3281 3282 struct IMAGE_FUNCTION_ENTRY { 3283 DWORD StartingAddress; 3284 DWORD EndingAddress; 3285 DWORD EndOfPrologue; 3286 } 3287 alias IMAGE_FUNCTION_ENTRY* PIMAGE_FUNCTION_ENTRY; 3288 3289 struct IMAGE_FUNCTION_ENTRY64 { 3290 ULONGLONG StartingAddress; 3291 ULONGLONG EndingAddress; 3292 union { 3293 ULONGLONG EndOfPrologue; 3294 ULONGLONG UnwindInfoAddress; 3295 } 3296 } 3297 alias IMAGE_FUNCTION_ENTRY64* PIMAGE_FUNCTION_ENTRY64; 3298 3299 struct IMAGE_SEPARATE_DEBUG_HEADER { 3300 WORD Signature; 3301 WORD Flags; 3302 WORD Machine; 3303 WORD Characteristics; 3304 DWORD TimeDateStamp; 3305 DWORD CheckSum; 3306 DWORD ImageBase; 3307 DWORD SizeOfImage; 3308 DWORD NumberOfSections; 3309 DWORD ExportedNamesSize; 3310 DWORD DebugDirectorySize; 3311 DWORD SectionAlignment; 3312 DWORD[2] Reserved; 3313 } 3314 alias IMAGE_SEPARATE_DEBUG_HEADER* PIMAGE_SEPARATE_DEBUG_HEADER; 3315 3316 enum SERVICE_NODE_TYPE { 3317 DriverType = SERVICE_KERNEL_DRIVER, 3318 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, 3319 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, 3320 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, 3321 AdapterType = SERVICE_ADAPTER, 3322 RecognizerType = SERVICE_RECOGNIZER_DRIVER 3323 } 3324 3325 enum SERVICE_LOAD_TYPE { 3326 BootLoad = SERVICE_BOOT_START, 3327 SystemLoad = SERVICE_SYSTEM_START, 3328 AutoLoad = SERVICE_AUTO_START, 3329 DemandLoad = SERVICE_DEMAND_START, 3330 DisableLoad = SERVICE_DISABLED 3331 } 3332 3333 enum SERVICE_ERROR_TYPE { 3334 IgnoreError = SERVICE_ERROR_IGNORE, 3335 NormalError = SERVICE_ERROR_NORMAL, 3336 SevereError = SERVICE_ERROR_SEVERE, 3337 CriticalError = SERVICE_ERROR_CRITICAL 3338 } 3339 alias SERVICE_ERROR_TYPE _CM_ERROR_CONTROL_TYPE; 3340 3341 //DAC: According to MSJ, 'UnderTheHood', May 1996, this 3342 // structure is not documented in any official Microsoft header file. 3343 alias void EXCEPTION_REGISTRATION_RECORD; 3344 3345 align: 3346 struct NT_TIB { 3347 EXCEPTION_REGISTRATION_RECORD *ExceptionList; 3348 PVOID StackBase; 3349 PVOID StackLimit; 3350 PVOID SubSystemTib; 3351 union { 3352 PVOID FiberData; 3353 DWORD Version; 3354 } 3355 PVOID ArbitraryUserPointer; 3356 NT_TIB *Self; 3357 } 3358 alias NT_TIB* PNT_TIB; 3359 3360 struct REPARSE_DATA_BUFFER { 3361 DWORD ReparseTag; 3362 WORD ReparseDataLength; 3363 WORD Reserved; 3364 union { 3365 struct _GenericReparseBuffer { 3366 BYTE _DataBuffer; 3367 3368 BYTE* DataBuffer() { return &_DataBuffer; } 3369 } 3370 _GenericReparseBuffer GenericReparseBuffer; 3371 struct _SymbolicLinkReparseBuffer { 3372 WORD SubstituteNameOffset; 3373 WORD SubstituteNameLength; 3374 WORD PrintNameOffset; 3375 WORD PrintNameLength; 3376 // ??? This is in MinGW, but absent in MSDN docs 3377 ULONG Flags; 3378 WCHAR _PathBuffer; 3379 3380 WCHAR* PathBuffer() { return &_PathBuffer; } 3381 } 3382 _SymbolicLinkReparseBuffer SymbolicLinkReparseBuffer; 3383 struct _MountPointReparseBuffer { 3384 WORD SubstituteNameOffset; 3385 WORD SubstituteNameLength; 3386 WORD PrintNameOffset; 3387 WORD PrintNameLength; 3388 WCHAR _PathBuffer; 3389 3390 WCHAR* PathBuffer() { return &_PathBuffer; } 3391 } 3392 _MountPointReparseBuffer MountPointReparseBuffer; 3393 } 3394 } 3395 alias REPARSE_DATA_BUFFER *PREPARSE_DATA_BUFFER; 3396 3397 struct REPARSE_GUID_DATA_BUFFER { 3398 DWORD ReparseTag; 3399 WORD ReparseDataLength; 3400 WORD Reserved; 3401 GUID ReparseGuid; 3402 struct _GenericReparseBuffer { 3403 BYTE _DataBuffer; 3404 3405 BYTE* DataBuffer() { return &_DataBuffer; } 3406 } 3407 _GenericReparseBuffer GenericReparseBuffer; 3408 } 3409 alias REPARSE_GUID_DATA_BUFFER* PREPARSE_GUID_DATA_BUFFER; 3410 3411 const size_t 3412 REPARSE_DATA_BUFFER_HEADER_SIZE = REPARSE_DATA_BUFFER.GenericReparseBuffer.offsetof, 3413 REPARSE_GUID_DATA_BUFFER_HEADER_SIZE = REPARSE_GUID_DATA_BUFFER.GenericReparseBuffer.offsetof, 3414 MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384; 3415 3416 3417 struct REPARSE_POINT_INFORMATION { 3418 WORD ReparseDataLength; 3419 WORD UnparsedNameLength; 3420 } 3421 alias REPARSE_POINT_INFORMATION* PREPARSE_POINT_INFORMATION; 3422 3423 union FILE_SEGMENT_ELEMENT { 3424 PVOID64 Buffer; 3425 ULONGLONG Alignment; 3426 } 3427 alias FILE_SEGMENT_ELEMENT* PFILE_SEGMENT_ELEMENT; 3428 3429 // JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags constants 3430 const DWORD 3431 JOB_OBJECT_LIMIT_WORKINGSET = 0x0001, 3432 JOB_OBJECT_LIMIT_PROCESS_TIME = 0x0002, 3433 JOB_OBJECT_LIMIT_JOB_TIME = 0x0004, 3434 JOB_OBJECT_LIMIT_ACTIVE_PROCESS = 0x0008, 3435 JOB_OBJECT_LIMIT_AFFINITY = 0x0010, 3436 JOB_OBJECT_LIMIT_PRIORITY_CLASS = 0x0020, 3437 JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME = 0x0040, 3438 JOB_OBJECT_LIMIT_SCHEDULING_CLASS = 0x0080, 3439 JOB_OBJECT_LIMIT_PROCESS_MEMORY = 0x0100, 3440 JOB_OBJECT_LIMIT_JOB_MEMORY = 0x0200, 3441 JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x0400, 3442 JOB_OBJECT_BREAKAWAY_OK = 0x0800, 3443 JOB_OBJECT_SILENT_BREAKAWAY = 0x1000; 3444 3445 // JOBOBJECT_BASIC_UI_RESTRICTIONS.UIRestrictionsClass constants 3446 const DWORD 3447 JOB_OBJECT_UILIMIT_HANDLES = 0x0001, 3448 JOB_OBJECT_UILIMIT_READCLIPBOARD = 0x0002, 3449 JOB_OBJECT_UILIMIT_WRITECLIPBOARD = 0x0004, 3450 JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = 0x0008, 3451 JOB_OBJECT_UILIMIT_DISPLAYSETTINGS = 0x0010, 3452 JOB_OBJECT_UILIMIT_GLOBALATOMS = 0x0020, 3453 JOB_OBJECT_UILIMIT_DESKTOP = 0x0040, 3454 JOB_OBJECT_UILIMIT_EXITWINDOWS = 0x0080; 3455 3456 // JOBOBJECT_SECURITY_LIMIT_INFORMATION.SecurityLimitFlags constants 3457 const DWORD 3458 JOB_OBJECT_SECURITY_NO_ADMIN = 0x0001, 3459 JOB_OBJECT_SECURITY_RESTRICTED_TOKEN = 0x0002, 3460 JOB_OBJECT_SECURITY_ONLY_TOKEN = 0x0004, 3461 JOB_OBJECT_SECURITY_FILTER_TOKENS = 0x0008; 3462 3463 // JOBOBJECT_END_OF_JOB_TIME_INFORMATION.EndOfJobTimeAction constants 3464 enum : DWORD { 3465 JOB_OBJECT_TERMINATE_AT_END_OF_JOB, 3466 JOB_OBJECT_POST_AT_END_OF_JOB 3467 } 3468 3469 enum : DWORD { 3470 JOB_OBJECT_MSG_END_OF_JOB_TIME = 1, 3471 JOB_OBJECT_MSG_END_OF_PROCESS_TIME, 3472 JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT, 3473 JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO, 3474 JOB_OBJECT_MSG_NEW_PROCESS, 3475 JOB_OBJECT_MSG_EXIT_PROCESS, 3476 JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS, 3477 JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT, 3478 JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 3479 } 3480 3481 enum JOBOBJECTINFOCLASS { 3482 JobObjectBasicAccountingInformation = 1, 3483 JobObjectBasicLimitInformation, 3484 JobObjectBasicProcessIdList, 3485 JobObjectBasicUIRestrictions, 3486 JobObjectSecurityLimitInformation, 3487 JobObjectEndOfJobTimeInformation, 3488 JobObjectAssociateCompletionPortInformation, 3489 JobObjectBasicAndIoAccountingInformation, 3490 JobObjectExtendedLimitInformation, 3491 JobObjectJobSetInformation, 3492 MaxJobObjectInfoClass 3493 } 3494 3495 struct JOBOBJECT_BASIC_ACCOUNTING_INFORMATION { 3496 LARGE_INTEGER TotalUserTime; 3497 LARGE_INTEGER TotalKernelTime; 3498 LARGE_INTEGER ThisPeriodTotalUserTime; 3499 LARGE_INTEGER ThisPeriodTotalKernelTime; 3500 DWORD TotalPageFaultCount; 3501 DWORD TotalProcesses; 3502 DWORD ActiveProcesses; 3503 DWORD TotalTerminatedProcesses; 3504 } 3505 alias JOBOBJECT_BASIC_ACCOUNTING_INFORMATION* PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION; 3506 3507 struct JOBOBJECT_BASIC_LIMIT_INFORMATION { 3508 LARGE_INTEGER PerProcessUserTimeLimit; 3509 LARGE_INTEGER PerJobUserTimeLimit; 3510 DWORD LimitFlags; 3511 SIZE_T MinimumWorkingSetSize; 3512 SIZE_T MaximumWorkingSetSize; 3513 DWORD ActiveProcessLimit; 3514 ULONG_PTR Affinity; 3515 DWORD PriorityClass; 3516 DWORD SchedulingClass; 3517 } 3518 alias JOBOBJECT_BASIC_LIMIT_INFORMATION* PJOBOBJECT_BASIC_LIMIT_INFORMATION; 3519 3520 struct JOBOBJECT_BASIC_PROCESS_ID_LIST { 3521 DWORD NumberOfAssignedProcesses; 3522 DWORD NumberOfProcessIdsInList; 3523 ULONG_PTR _ProcessIdList; 3524 3525 ULONG_PTR* ProcessIdList() { return &_ProcessIdList; } 3526 } 3527 alias JOBOBJECT_BASIC_PROCESS_ID_LIST* PJOBOBJECT_BASIC_PROCESS_ID_LIST; 3528 3529 struct JOBOBJECT_BASIC_UI_RESTRICTIONS { 3530 DWORD UIRestrictionsClass; 3531 } 3532 alias JOBOBJECT_BASIC_UI_RESTRICTIONS* PJOBOBJECT_BASIC_UI_RESTRICTIONS; 3533 3534 struct JOBOBJECT_SECURITY_LIMIT_INFORMATION { 3535 DWORD SecurityLimitFlags; 3536 HANDLE JobToken; 3537 PTOKEN_GROUPS SidsToDisable; 3538 PTOKEN_PRIVILEGES PrivilegesToDelete; 3539 PTOKEN_GROUPS RestrictedSids; 3540 } 3541 alias JOBOBJECT_SECURITY_LIMIT_INFORMATION* PJOBOBJECT_SECURITY_LIMIT_INFORMATION; 3542 3543 struct JOBOBJECT_END_OF_JOB_TIME_INFORMATION { 3544 DWORD EndOfJobTimeAction; 3545 } 3546 alias JOBOBJECT_END_OF_JOB_TIME_INFORMATION* PJOBOBJECT_END_OF_JOB_TIME_INFORMATION; 3547 3548 struct JOBOBJECT_ASSOCIATE_COMPLETION_PORT { 3549 PVOID CompletionKey; 3550 HANDLE CompletionPort; 3551 } 3552 alias JOBOBJECT_ASSOCIATE_COMPLETION_PORT* PJOBOBJECT_ASSOCIATE_COMPLETION_PORT; 3553 3554 struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION { 3555 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo; 3556 IO_COUNTERS IoInfo; 3557 } 3558 alias JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION; 3559 3560 struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION { 3561 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation; 3562 IO_COUNTERS IoInfo; 3563 SIZE_T ProcessMemoryLimit; 3564 SIZE_T JobMemoryLimit; 3565 SIZE_T PeakProcessMemoryUsed; 3566 SIZE_T PeakJobMemoryUsed; 3567 } 3568 alias JOBOBJECT_EXTENDED_LIMIT_INFORMATION* PJOBOBJECT_EXTENDED_LIMIT_INFORMATION; 3569 3570 struct JOBOBJECT_JOBSET_INFORMATION { 3571 DWORD MemberLevel; 3572 } 3573 alias JOBOBJECT_JOBSET_INFORMATION* PJOBOBJECT_JOBSET_INFORMATION; 3574 3575 // MinGW: Making these defines conditional on WINVER will break ddk includes 3576 //static if (WINVER >= 0x0500) { 3577 3578 const DWORD 3579 ES_SYSTEM_REQUIRED = 0x00000001, 3580 ES_DISPLAY_REQUIRED = 0x00000002, 3581 ES_USER_PRESENT = 0x00000004, 3582 ES_CONTINUOUS = 0x80000000; 3583 3584 enum LATENCY_TIME { 3585 LT_DONT_CARE, 3586 LT_LOWEST_LATENCY 3587 } 3588 alias LATENCY_TIME* PLATENCY_TIME; 3589 3590 enum SYSTEM_POWER_STATE { 3591 PowerSystemUnspecified, 3592 PowerSystemWorking, 3593 PowerSystemSleeping1, 3594 PowerSystemSleeping2, 3595 PowerSystemSleeping3, 3596 PowerSystemHibernate, 3597 PowerSystemShutdown, 3598 PowerSystemMaximum 3599 } 3600 alias SYSTEM_POWER_STATE* PSYSTEM_POWER_STATE; 3601 3602 const POWER_SYSTEM_MAXIMUM = SYSTEM_POWER_STATE.PowerSystemMaximum; 3603 3604 enum POWER_ACTION { 3605 PowerActionNone, 3606 PowerActionReserved, 3607 PowerActionSleep, 3608 PowerActionHibernate, 3609 PowerActionShutdown, 3610 PowerActionShutdownReset, 3611 PowerActionShutdownOff, 3612 PowerActionWarmEject 3613 } 3614 alias POWER_ACTION* PPOWER_ACTION; 3615 3616 static if (WINVER >= 0x600) { 3617 enum SYSTEM_POWER_CONDITION { 3618 PoAc, 3619 PoDc, 3620 PoHot, 3621 PoConditionMaximum 3622 } 3623 alias SYSTEM_POWER_CONDITION* PSYSTEM_POWER_CONDITION; 3624 } 3625 3626 enum DEVICE_POWER_STATE { 3627 PowerDeviceUnspecified, 3628 PowerDeviceD0, 3629 PowerDeviceD1, 3630 PowerDeviceD2, 3631 PowerDeviceD3, 3632 PowerDeviceMaximum 3633 } 3634 alias DEVICE_POWER_STATE* PDEVICE_POWER_STATE; 3635 3636 align(4): 3637 struct BATTERY_REPORTING_SCALE { 3638 DWORD Granularity; 3639 DWORD Capacity; 3640 } 3641 alias BATTERY_REPORTING_SCALE* PBATTERY_REPORTING_SCALE; 3642 3643 struct POWER_ACTION_POLICY { 3644 POWER_ACTION Action; 3645 ULONG Flags; 3646 ULONG EventCode; 3647 } 3648 alias POWER_ACTION_POLICY* PPOWER_ACTION_POLICY; 3649 3650 // POWER_ACTION_POLICY.Flags constants 3651 const ULONG 3652 POWER_ACTION_QUERY_ALLOWED = 0x00000001, 3653 POWER_ACTION_UI_ALLOWED = 0x00000002, 3654 POWER_ACTION_OVERRIDE_APPS = 0x00000004, 3655 POWER_ACTION_LIGHTEST_FIRST = 0x10000000, 3656 POWER_ACTION_LOCK_CONSOLE = 0x20000000, 3657 POWER_ACTION_DISABLE_WAKES = 0x40000000, 3658 POWER_ACTION_CRITICAL = 0x80000000; 3659 3660 // POWER_ACTION_POLICY.EventCode constants 3661 const ULONG 3662 POWER_LEVEL_USER_NOTIFY_TEXT = 0x00000001, 3663 POWER_LEVEL_USER_NOTIFY_SOUND = 0x00000002, 3664 POWER_LEVEL_USER_NOTIFY_EXEC = 0x00000004, 3665 POWER_USER_NOTIFY_BUTTON = 0x00000008, 3666 POWER_USER_NOTIFY_SHUTDOWN = 0x00000010, 3667 POWER_FORCE_TRIGGER_RESET = 0x80000000; 3668 3669 const size_t 3670 DISCHARGE_POLICY_CRITICAL = 0, 3671 DISCHARGE_POLICY_LOW = 1, 3672 NUM_DISCHARGE_POLICIES = 4; 3673 3674 enum : BYTE { 3675 PO_THROTTLE_NONE, 3676 PO_THROTTLE_CONSTANT, 3677 PO_THROTTLE_DEGRADE, 3678 PO_THROTTLE_ADAPTIVE, 3679 PO_THROTTLE_MAXIMUM 3680 } 3681 3682 struct SYSTEM_POWER_LEVEL { 3683 BOOLEAN Enable; 3684 UCHAR[3] Spare; 3685 ULONG BatteryLevel; 3686 POWER_ACTION_POLICY PowerPolicy; 3687 SYSTEM_POWER_STATE MinSystemState; 3688 } 3689 alias SYSTEM_POWER_LEVEL* PSYSTEM_POWER_LEVEL; 3690 3691 struct SYSTEM_POWER_POLICY { 3692 ULONG Revision; 3693 POWER_ACTION_POLICY PowerButton; 3694 POWER_ACTION_POLICY SleepButton; 3695 POWER_ACTION_POLICY LidClose; 3696 SYSTEM_POWER_STATE LidOpenWake; 3697 ULONG Reserved; 3698 POWER_ACTION_POLICY Idle; 3699 ULONG IdleTimeout; 3700 UCHAR IdleSensitivity; 3701 UCHAR DynamicThrottle; 3702 UCHAR[2] Spare2; 3703 SYSTEM_POWER_STATE MinSleep; 3704 SYSTEM_POWER_STATE MaxSleep; 3705 SYSTEM_POWER_STATE ReducedLatencySleep; 3706 ULONG WinLogonFlags; 3707 ULONG Spare3; 3708 ULONG DozeS4Timeout; 3709 ULONG BroadcastCapacityResolution; 3710 SYSTEM_POWER_LEVEL[NUM_DISCHARGE_POLICIES] DischargePolicy; 3711 ULONG VideoTimeout; 3712 BOOLEAN VideoDimDisplay; 3713 ULONG[3] VideoReserved; 3714 ULONG SpindownTimeout; 3715 BOOLEAN OptimizeForPower; 3716 UCHAR FanThrottleTolerance; 3717 UCHAR ForcedThrottle; 3718 UCHAR MinThrottle; 3719 POWER_ACTION_POLICY OverThrottled; 3720 } 3721 alias SYSTEM_POWER_POLICY* PSYSTEM_POWER_POLICY; 3722 3723 struct SYSTEM_POWER_CAPABILITIES { 3724 BOOLEAN PowerButtonPresent; 3725 BOOLEAN SleepButtonPresent; 3726 BOOLEAN LidPresent; 3727 BOOLEAN SystemS1; 3728 BOOLEAN SystemS2; 3729 BOOLEAN SystemS3; 3730 BOOLEAN SystemS4; 3731 BOOLEAN SystemS5; 3732 BOOLEAN HiberFilePresent; 3733 BOOLEAN FullWake; 3734 BOOLEAN VideoDimPresent; 3735 BOOLEAN ApmPresent; 3736 BOOLEAN UpsPresent; 3737 BOOLEAN ThermalControl; 3738 BOOLEAN ProcessorThrottle; 3739 UCHAR ProcessorMinThrottle; 3740 UCHAR ProcessorMaxThrottle; 3741 UCHAR[4] spare2; 3742 BOOLEAN DiskSpinDown; 3743 UCHAR[8] spare3; 3744 BOOLEAN SystemBatteriesPresent; 3745 BOOLEAN BatteriesAreShortTerm; 3746 BATTERY_REPORTING_SCALE[3] BatteryScale; 3747 SYSTEM_POWER_STATE AcOnLineWake; 3748 SYSTEM_POWER_STATE SoftLidWake; 3749 SYSTEM_POWER_STATE RtcWake; 3750 SYSTEM_POWER_STATE MinDeviceWakeState; 3751 SYSTEM_POWER_STATE DefaultLowLatencyWake; 3752 } 3753 alias SYSTEM_POWER_CAPABILITIES* PSYSTEM_POWER_CAPABILITIES; 3754 3755 struct SYSTEM_BATTERY_STATE { 3756 BOOLEAN AcOnLine; 3757 BOOLEAN BatteryPresent; 3758 BOOLEAN Charging; 3759 BOOLEAN Discharging; 3760 BOOLEAN[4] Spare1; 3761 ULONG MaxCapacity; 3762 ULONG RemainingCapacity; 3763 ULONG Rate; 3764 ULONG EstimatedTime; 3765 ULONG DefaultAlert1; 3766 ULONG DefaultAlert2; 3767 } 3768 alias SYSTEM_BATTERY_STATE* PSYSTEM_BATTERY_STATE; 3769 3770 enum POWER_INFORMATION_LEVEL { 3771 SystemPowerPolicyAc, 3772 SystemPowerPolicyDc, 3773 VerifySystemPolicyAc, 3774 VerifySystemPolicyDc, 3775 SystemPowerCapabilities, 3776 SystemBatteryState, 3777 SystemPowerStateHandler, 3778 ProcessorStateHandler, 3779 SystemPowerPolicyCurrent, 3780 AdministratorPowerPolicy, 3781 SystemReserveHiberFile, 3782 ProcessorInformation, 3783 SystemPowerInformation, 3784 ProcessorStateHandler2, 3785 LastWakeTime, 3786 LastSleepTime, 3787 SystemExecutionState, 3788 SystemPowerStateNotifyHandler, 3789 ProcessorPowerPolicyAc, 3790 ProcessorPowerPolicyDc, 3791 VerifyProcessorPowerPolicyAc, 3792 VerifyProcessorPowerPolicyDc, 3793 ProcessorPowerPolicyCurrent 3794 } 3795 3796 //#if 1 /* (WIN32_WINNT >= 0x0500) */ 3797 struct SYSTEM_POWER_INFORMATION { 3798 ULONG MaxIdlenessAllowed; 3799 ULONG Idleness; 3800 ULONG TimeRemaining; 3801 UCHAR CoolingMode; 3802 } 3803 alias SYSTEM_POWER_INFORMATION* PSYSTEM_POWER_INFORMATION; 3804 //#endif 3805 3806 struct PROCESSOR_POWER_POLICY_INFO { 3807 ULONG TimeCheck; 3808 ULONG DemoteLimit; 3809 ULONG PromoteLimit; 3810 UCHAR DemotePercent; 3811 UCHAR PromotePercent; 3812 UCHAR[2] Spare; 3813 uint _bf; 3814 3815 bool AllowDemotion() { return cast(bool)(_bf & 1); } 3816 bool AllowPromotion() { return cast(bool)(_bf & 2); } 3817 3818 bool AllowDemotion(bool a) { _bf = (_bf & ~1) | a; return a; } 3819 bool AllowPromotion(bool a) { _bf = (_bf & ~2) | (a << 1); return a; } 3820 /+ 3821 ULONG AllowDemotion : 1; 3822 ULONG AllowPromotion : 1; 3823 ULONG Reserved : 30; 3824 +/ 3825 } 3826 alias PROCESSOR_POWER_POLICY_INFO* PPROCESSOR_POWER_POLICY_INFO; 3827 3828 struct PROCESSOR_POWER_POLICY { 3829 ULONG Revision; 3830 UCHAR DynamicThrottle; 3831 UCHAR[3] Spare; 3832 ULONG Reserved; 3833 ULONG PolicyCount; 3834 PROCESSOR_POWER_POLICY_INFO[3] Policy; 3835 } 3836 alias PROCESSOR_POWER_POLICY* PPROCESSOR_POWER_POLICY; 3837 3838 struct ADMINISTRATOR_POWER_POLICY { 3839 SYSTEM_POWER_STATE MinSleep; 3840 SYSTEM_POWER_STATE MaxSleep; 3841 ULONG MinVideoTimeout; 3842 ULONG MaxVideoTimeout; 3843 ULONG MinSpindownTimeout; 3844 ULONG MaxSpindownTimeout; 3845 } 3846 alias ADMINISTRATOR_POWER_POLICY* PADMINISTRATOR_POWER_POLICY; 3847 3848 //}//#endif /* WINVER >= 0x0500 */ 3849 3850 extern (Windows) { 3851 alias void function(PVOID, DWORD, PVOID) PIMAGE_TLS_CALLBACK; 3852 3853 static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) { 3854 alias LONG function(PEXCEPTION_POINTERS) PVECTORED_EXCEPTION_HANDLER; 3855 alias void function(PVOID, BOOLEAN) WAITORTIMERCALLBACKFUNC; 3856 } 3857 } 3858 3859 static if (WINVER >= 0x501) { 3860 enum HEAP_INFORMATION_CLASS { 3861 HeapCompatibilityInformation 3862 } 3863 3864 enum ACTIVATION_CONTEXT_INFO_CLASS { 3865 ActivationContextBasicInformation = 1, 3866 ActivationContextDetailedInformation, 3867 AssemblyDetailedInformationInActivationContext, 3868 FileInformationInAssemblyOfAssemblyInActivationContext 3869 } 3870 3871 struct ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION { 3872 DWORD ulFlags; 3873 DWORD ulEncodedAssemblyIdentityLength; 3874 DWORD ulManifestPathType; 3875 DWORD ulManifestPathLength; 3876 LARGE_INTEGER liManifestLastWriteTime; 3877 DWORD ulPolicyPathType; 3878 DWORD ulPolicyPathLength; 3879 LARGE_INTEGER liPolicyLastWriteTime; 3880 DWORD ulMetadataSatelliteRosterIndex; 3881 DWORD ulManifestVersionMajor; 3882 DWORD ulManifestVersionMinor; 3883 DWORD ulPolicyVersionMajor; 3884 DWORD ulPolicyVersionMinor; 3885 DWORD ulAssemblyDirectoryNameLength; 3886 PCWSTR lpAssemblyEncodedAssemblyIdentity; 3887 PCWSTR lpAssemblyManifestPath; 3888 PCWSTR lpAssemblyPolicyPath; 3889 PCWSTR lpAssemblyDirectoryName; 3890 } 3891 alias ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION* 3892 PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION; 3893 alias CPtr!(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION) 3894 PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION; 3895 3896 struct ACTIVATION_CONTEXT_DETAILED_INFORMATION { 3897 DWORD dwFlags; 3898 DWORD ulFormatVersion; 3899 DWORD ulAssemblyCount; 3900 DWORD ulRootManifestPathType; 3901 DWORD ulRootManifestPathChars; 3902 DWORD ulRootConfigurationPathType; 3903 DWORD ulRootConfigurationPathChars; 3904 DWORD ulAppDirPathType; 3905 DWORD ulAppDirPathChars; 3906 PCWSTR lpRootManifestPath; 3907 PCWSTR lpRootConfigurationPath; 3908 PCWSTR lpAppDirPath; 3909 } 3910 alias ACTIVATION_CONTEXT_DETAILED_INFORMATION* 3911 PACTIVATION_CONTEXT_DETAILED_INFORMATION; 3912 alias CPtr!(ACTIVATION_CONTEXT_DETAILED_INFORMATION) 3913 PCACTIVATION_CONTEXT_DETAILED_INFORMATION; 3914 3915 struct ACTIVATION_CONTEXT_QUERY_INDEX { 3916 ULONG ulAssemblyIndex; 3917 ULONG ulFileIndexInAssembly; 3918 } 3919 alias ACTIVATION_CONTEXT_QUERY_INDEX* PACTIVATION_CONTEXT_QUERY_INDEX; 3920 alias CPtr!(ACTIVATION_CONTEXT_QUERY_INDEX) PCACTIVATION_CONTEXT_QUERY_INDEX; 3921 3922 struct ASSEMBLY_FILE_DETAILED_INFORMATION { 3923 DWORD ulFlags; 3924 DWORD ulFilenameLength; 3925 DWORD ulPathLength; 3926 PCWSTR lpFileName; 3927 PCWSTR lpFilePath; 3928 } 3929 alias ASSEMBLY_FILE_DETAILED_INFORMATION* 3930 PASSEMBLY_FILE_DETAILED_INFORMATION; 3931 alias CPtr!(ASSEMBLY_FILE_DETAILED_INFORMATION) 3932 PCASSEMBLY_FILE_DETAILED_INFORMATION; 3933 } 3934 3935 version (Unicode) { 3936 alias OSVERSIONINFOW OSVERSIONINFO; 3937 alias OSVERSIONINFOEXW OSVERSIONINFOEX; 3938 } else { 3939 alias OSVERSIONINFOA OSVERSIONINFO; 3940 alias OSVERSIONINFOEXA OSVERSIONINFOEX; 3941 } 3942 3943 alias OSVERSIONINFO* POSVERSIONINFO, LPOSVERSIONINFO; 3944 alias OSVERSIONINFOEX* POSVERSIONINFOEX, LPOSVERSIONINFOEX; 3945 3946 3947 static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) { 3948 extern (Windows) ULONGLONG VerSetConditionMask(ULONGLONG, DWORD, BYTE); 3949 } 3950 3951 version (Win64) { 3952 const WORD IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR64_MAGIC; 3953 3954 alias IMAGE_ORDINAL_FLAG64 IMAGE_ORDINAL_FLAG; 3955 alias IMAGE_SNAP_BY_ORDINAL64 IMAGE_SNAP_BY_ORDINAL; 3956 alias IMAGE_ORDINAL64 IMAGE_ORDINAL; 3957 alias IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER; 3958 alias IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS; 3959 alias IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA; 3960 alias IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY; 3961 } else { 3962 const WORD IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR32_MAGIC; 3963 3964 alias IMAGE_ORDINAL_FLAG32 IMAGE_ORDINAL_FLAG; 3965 alias IMAGE_ORDINAL32 IMAGE_ORDINAL; 3966 alias IMAGE_SNAP_BY_ORDINAL32 IMAGE_SNAP_BY_ORDINAL; 3967 alias IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER; 3968 alias IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS; 3969 alias IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA; 3970 alias IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY; 3971 } 3972 3973 alias IMAGE_OPTIONAL_HEADER* PIMAGE_OPTIONAL_HEADER; 3974 alias IMAGE_NT_HEADERS* PIMAGE_NT_HEADERS; 3975 alias IMAGE_THUNK_DATA* PIMAGE_THUNK_DATA; 3976 alias IMAGE_TLS_DIRECTORY* PIMAGE_TLS_DIRECTORY; 3977 3978 // TODO: MinGW implements these in assembly. How to translate? 3979 PVOID GetCurrentFiber(); 3980 PVOID GetFiberData();