import ctypes, struct;

# I've started to group some defines that have unique values within a certain
# context and store them in dictionaries in separate files for clarity.
# These dictionaries are imported here and their names and values extracted:
from .dsHResultDefineName_by_uValue import dsHResultDefineName_by_uValue;
from .dsExceptionDefineName_by_uValue import dsExceptionDefineName_by_uValue;
from .dsNTStatusDefineName_by_uValue import dsNTStatusDefineName_by_uValue;
from .dsWin32ErrorCodeDefineName_by_uValue import dsWin32ErrorCodeDefineName_by_uValue;
dxGlobals = globals();
asOriginalGlobalsNames = list(dxGlobals.keys());

################################################################################
# Non-numeric defines
################################################################################
FALSE = False;
NULL = 0;
TRUE = True;

################################################################################
# Numeric defines
################################################################################

#AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ACCESS_SYSTEM_SECURITY                  = 0x01000000;
#CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCHDEVICENAME                           =         32;
CCHFORMNAME                             =         32;
CLR_EXCEPTION_CODE                      = 0xE0434F4D;
CLSCTX_INPROC_SERVER                    =        0x1;
CLSCTX_INPROC_HANDLER                   =        0x2;
CLSCTX_LOCAL_SERVER                     =        0x4;
CLSCTX_INPROC_SERVER16                  =        0x8;
CLSCTX_REMOTE_SERVER                    =       0x10;
CLSCTX_INPROC_HANDLER16                 =       0x20;
CLSCTX_RESERVED1                        =       0x40;
CLSCTX_RESERVED2                        =       0x80;
CLSCTX_RESERVED3                        =      0x100;
CLSCTX_RESERVED4                        =      0x200;
CLSCTX_NO_CODE_DOWNLOAD                 =      0x400;
CLSCTX_RESERVED5                        =      0x800;
CLSCTX_NO_CUSTOM_MARSHAL                =     0x1000;
CLSCTX_ENABLE_CODE_DOWNLOAD             =     0x2000;
CLSCTX_NO_FAILURE_LOG                   =     0x4000;
CLSCTX_DISABLE_AAA                      =     0x8000;
CLSCTX_ENABLE_AAA                       =    0x10000;
CLSCTX_FROM_DEFAULT_CONTEXT             =    0x20000;
CLSCTX_ACTIVATE_32_BIT_SERVER           =    0x40000;
CLSCTX_ACTIVATE_64_BIT_SERVER           =    0x80000;
CLSCTX_INPROC                           = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER;
CLSCTX_SERVER                           = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER;
CLSCTX_ALL                              = CLSCTX_SERVER | CLSCTX_INPROC_HANDLER;
CREATE_ALWAYS                           =          2;
CREATE_BREAKAWAY_FROM_JOB               = 0x01000000;
CREATE_DEFAULT_ERROR_MODE               = 0x04000000;
CREATE_NEW                              =          1;
CREATE_NEW_CONSOLE                      = 0x00000010;
CREATE_NEW_PROCESS_GROUP                = 0x00000200;
CREATE_NO_WINDOW                        = 0x08000000;
CREATE_PROTECTED_PROCESS                = 0x00040000;
CREATE_PRESERVE_CODE_AUTHZ_LEVEL        = 0x02000000;
CREATE_SEPARATE_WOW_VDM                 = 0x00000800;
CREATE_SHARED_WOW_VDM                   = 0x00001000;
CREATE_SUSPENDED                        = 0x00000004;
CREATE_UNICODE_ENVIRONMENT              = 0x00000400;
CTRL_BREAK_EVENT                        =          1; # https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent
CTRL_C_EVENT                            =          0; # https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent
CONTEXT_i386                            =    0x10000;
CONTEXT_i486                            =    0x10000;
CONTEXT_CONTROL                         = CONTEXT_i386 | 0x01; # SS:SP, CS:IP, FLAGS, BP
CONTEXT_INTEGER                         = CONTEXT_i386 | 0x02; # AX, BX, CX, DX, SI, DI
CONTEXT_SEGMENTS                        = CONTEXT_i386 | 0x04; # DS, ES, FS, GS
CONTEXT_FLOATING_POINT                  = CONTEXT_i386 | 0x08; # 387 state
CONTEXT_DEBUG_REGISTERS                 = CONTEXT_i386 | 0x10; # DB 0-3,6,7
CONTEXT_EXTENDED_REGISTERS              = CONTEXT_i386 | 0x20; # cpu specific extensions
CONTEXT_FULL                            = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS;
CONTEXT_ALL                             = CONTEXT_FULL | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS;
#DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
DEBUG_ONLY_THIS_PROCESS                 = 0x00000002;
DEBUG_PROCESS                           = 0x00000001;
DELETE                                  = 0x00010000;
DETACHED_PROCESS                        = 0x00000008;
DISPLAY_DEVICE_ACTIVE                   = 0x00000001;
DISPLAY_DEVICE_ATTACHED                 = 0x00000002;
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP      = 0x00000001;
DISPLAY_DEVICE_MULTI_DRIVER             = 0x00000002;
DISPLAY_DEVICE_PRIMARY_DEVICE           = 0x00000004;
DISPLAY_DEVICE_MIRRORING_DRIVER         = 0x00000008;
DISPLAY_DEVICE_VGA_COMPATIBLE           = 0x00000010;
DISPLAY_DEVICE_REMOVABLE                = 0x00000020;
DISPLAY_DEVICE_ACC_DRIVER               = 0x00000040;
DISPLAY_DEVICE_MODESPRUNED              = 0x08000000;
DISPLAY_DEVICE_RDPUDD                   = 0x01000000;
DISPLAY_DEVICE_REMOTE                   = 0x04000000;
DISPLAY_DEVICE_DISCONNECT               = 0x02000000;
DISPLAY_DEVICE_TS_COMPATIBLE            = 0x00200000;
DISPLAY_DEVICE_UNSAFE_MODES_ON          = 0x00080000;
DMDO_DEFAULT                            = 0x00000000;
DMDO_90                                 = 0x00000001;
DMDO_180                                = 0x00000002;
DMDO_270                                = 0x00000003;
DUPLICATE_CLOSE_SOURCE                  = 0x00000001;
DUPLICATE_SAME_ACCESS                   = 0x00000002;
#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EXTENDED_STARTUPINFO_PRESENT            = 0x00080000;
#FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FACILITY_NT_BIT                         = 0x10000000;
FAST_FAIL_LEGACY_GS_VIOLATION           =          0;
FAST_FAIL_VTGUARD_CHECK_FAILURE         =          1;
FAST_FAIL_STACK_COOKIE_CHECK_FAILURE    =          2;
FAST_FAIL_CORRUPT_LIST_ENTRY            =          3;
FAST_FAIL_INCORRECT_STACK               =          4;
FAST_FAIL_INVALID_ARG                   =          5;
FAST_FAIL_GS_COOKIE_INIT                =          6;
FAST_FAIL_FATAL_APP_EXIT                =          7;
FAST_FAIL_RANGE_CHECK_FAILURE           =          8;
FAST_FAIL_UNSAFE_REGISTRY_ACCESS        =          9;
FAST_FAIL_GUARD_ICALL_CHECK_FAILURE     =         10;
FAST_FAIL_GUARD_WRITE_CHECK_FAILURE     =         11;
FAST_FAIL_INVALID_FIBER_SWITCH          =         12;
FAST_FAIL_INVALID_SET_OF_CONTEXT        =         13;
FAST_FAIL_INVALID_REFERENCE_COUNT       =         14;
FAST_FAIL_INVALID_JUMP_BUFFER           =         18;
FAST_FAIL_MRDATA_MODIFIED               =         19;
FAST_FAIL_CERTIFICATION_FAILURE         =         20;
FAST_FAIL_INVALID_EXCEPTION_CHAIN       =         21;
FAST_FAIL_CRYPTO_LIBRARY                =         22;
FAST_FAIL_INVALID_CALL_IN_DLL_CALLOUT   =         23;
FAST_FAIL_INVALID_IMAGE_BASE            =         24;
FAST_FAIL_DLOAD_PROTECTION_FAILURE      =         25;
FAST_FAIL_UNSAFE_EXTENSION_CALL         =         26;
FAST_FAIL_DEPRECATED_SERVICE_INVOKED    =         27;
FAST_FAIL_INVALID_BUFFER_ACCESS         =         28;
FAST_FAIL_INVALID_BALANCED_TREE         =         29;
FAST_FAIL_INVALID_NEXT_THREAD           =         30;
FAST_FAIL_GUARD_ICALL_CHECK_SUPPRESSED  =         31;
FAST_FAIL_APCS_DISABLED                 =         32;
FAST_FAIL_INVALID_IDLE_STATE            =         33;
FAST_FAIL_MRDATA_PROTECTION_FAILURE     =         34;
FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION     =         35;
FAST_FAIL_INVALID_LOCK_STATE            =         36;
FAST_FAIL_GUARD_JUMPTABLE               =         37;
FAST_FAIL_INVALID_LONGJUMP_TARGET       =         38;
FAST_FAIL_INVALID_DISPATCH_CONTEXT      =         39;
FAST_FAIL_INVALID_THREAD                =         40;
FAST_FAIL_INVALID_SYSCALL_NUMBER        =         41;
FAST_FAIL_INVALID_FILE_OPERATION        =         42;
FAST_FAIL_LPAC_ACCESS_DENIED            =         43;
FAST_FAIL_GUARD_SS_FAILURE              =         44;
FAST_FAIL_LOADER_CONTINUITY_FAILURE     =         45;
FAST_FAIL_GUARD_EXPORT_SUPPRESSION_FAILURE =      46;
FAST_FAIL_INVALID_CONTROL_STACK         =         47;
FAST_FAIL_SET_CONTEXT_DENIED            =         48;
FAST_FAIL_INVALID_IAT                   =         49;
FAST_FAIL_HEAP_METADATA_CORRUPTION      =         50;
FAST_FAIL_PAYLOAD_RESTRICTION_VIOLATION =         51;
FAST_FAIL_LOW_LABEL_ACCESS_DENIED       =         52;
FAST_FAIL_ENCLAVE_CALL_FAILURE          =         53;
FAST_FAIL_UNHANDLED_LSS_EXCEPTON        =         54;
FAST_FAIL_ADMINLESS_ACCESS_DENIED       =         55;
FAST_FAIL_UNEXPECTED_CALL               =         56;
FAST_FAIL_CONTROL_INVALID_RETURN_ADDRESS =        57;
FAST_FAIL_UNEXPECTED_HOST_BEHAVIOR      =         58;
FAST_FAIL_FLAGS_CORRUPTION              =         59;
FAST_FAIL_INVALID_FAST_FAIL_CODE        = 0xFFFFFFFF;
FILE_ATTRIBUTE_ARCHIVE                  =       0x20;
FILE_ATTRIBUTE_COMPRESSED               =      0x800;
FILE_ATTRIBUTE_DEVICE                   =       0x40;
FILE_ATTRIBUTE_DIRECTORY                =       0x10;
FILE_ATTRIBUTE_ENCRYPTED                =     0x4000;
FILE_ATTRIBUTE_HIDDEN                   =        0x2;
FILE_ATTRIBUTE_INTEGRITY_STREAM         =     0x8000;
FILE_ATTRIBUTE_NORMAL                   =       0x80;
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED      =     0x2000;
FILE_ATTRIBUTE_NO_SCRUB_DATA            =    0x20000;
FILE_ATTRIBUTE_OFFLINE                  =     0x1000;
FILE_ATTRIBUTE_READONLY                 =        0x1;
FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS    =   0x400000;
FILE_ATTRIBUTE_RECALL_ON_OPEN           =    0x40000;
FILE_ATTRIBUTE_REPARSE_POINT            =      0x400;
FILE_ATTRIBUTE_SPARSE_FILE              =      0x200;
FILE_ATTRIBUTE_SYSTEM                   =        0x4;
FILE_ATTRIBUTE_TEMPORARY                =      0x100;
FILE_ATTRIBUTE_VIRTUAL                  =    0x10000;
FILE_FLAG_BACKUP_SEMANTICS              = 0x02000000;
FILE_FLAG_DELETE_ON_CLOSE               = 0x04000000;
FILE_FLAG_FIRST_PIPE_INSTANCE           = 0x00080000;
FILE_FLAG_NO_BUFFERING                  = 0x20000000;
FILE_FLAG_OPEN_NO_RECALL                = 0x00100000;
FILE_FLAG_OPEN_REPARSE_POINT            = 0x00200000;
FILE_FLAG_OVERLAPPED                    = 0x40000000;
FILE_FLAG_POSIX_SEMANTICS               = 0x01000000;
FILE_FLAG_RANDOM_ACCESS                 = 0x10000000;
FILE_FLAG_SESSION_AWARE                 = 0x00800000;
FILE_FLAG_SEQUENTIAL_SCAN               = 0x08000000;
FILE_FLAG_WRITE_THROUGH                 = 0x80000000;
FILE_SHARE_DELETE                       = 0x00000004;
FILE_SHARE_READ                         = 0x00000001;
FILE_SHARE_WRITE                        = 0x00000002;
#GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
GENERIC_ALL                             = 0x10000000;
GENERIC_EXECUTE                         = 0x20000000;
GENERIC_READ                            = 0x80000000;
GENERIC_WRITE                           = 0x40000000;
#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HANDLE_FLAG_INHERIT                     = 0x00000001;
HANDLE_FLAG_PROTECT_FROM_CLOSE          = 0x00000002;
HEAP_ZERO_MEMORY                        = 0x00000008;
#IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE   =     0x0040;
IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY =    0x0080;
IMAGE_DLLCHARACTERISTICS_NO_BIND        =     0x0800;
IMAGE_DLLCHARACTERISTICS_NO_ISOLATION   =     0x0200;
IMAGE_DLLCHARACTERISTICS_NO_SEH         =     0x0400;
IMAGE_DLLCHARACTERISTICS_NX_COMPAT      =     0x0100;
IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000;
IMAGE_DLLCHARACTERISTICS_WDM_DRIVER     =     0x2000;
IMAGE_NT_OPTIONAL_HDR32_MAGIC           =      0x10b;
IMAGE_NT_OPTIONAL_HDR64_MAGIC           =      0x20b;
IMAGE_ROM_OPTIONAL_HDR_MAGIC            =      0x107;
IMAGE_SUBSYSTEM_EFI_APPLICATION         =         10;
IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER =         11;
IMAGE_SUBSYSTEM_EFI_ROM                 =         13;
IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER      =         12;
IMAGE_SUBSYSTEM_NATIVE                  =          1;
IMAGE_SUBSYSTEM_OS2_CUI                 =          5;
IMAGE_SUBSYSTEM_POSIX_CUI               =          7;
IMAGE_SUBSYSTEM_UNKNOWN                 =          0;
IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION =        16;
IMAGE_SUBSYSTEM_WINDOWS_CE_GUI          =          9;
IMAGE_SUBSYSTEM_WINDOWS_CUI             =          3;
IMAGE_SUBSYSTEM_WINDOWS_GUI             =          2;
IMAGE_SUBSYSTEM_XBOX                    =         14;
INFINITE                                = 0xFFFFFFFF;
INHERIT_PARENT_AFFINITY                 = 0x00010000
INVALID_FILE_SIZE                       = 0xFFFFFFFF;
INVALID_HANDLE_VALUE                    = ctypes.c_void_p(-1).value;
#JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
JOB_OBJECT_LIMIT_ACTIVE_PROCESS         = 0x00000008;
JOB_OBJECT_LIMIT_AFFINITY               = 0x00000010;
JOB_OBJECT_LIMIT_BREAKAWAY_OK           = 0x00000800;
JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x00000400
JOB_OBJECT_LIMIT_JOB_MEMORY             = 0x00000200;
JOB_OBJECT_LIMIT_JOB_TIME               = 0x00000004;
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE      = 0x00002000;
JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME      = 0x00000040;
JOB_OBJECT_LIMIT_PRIORITY_CLASS         = 0x00000020;
JOB_OBJECT_LIMIT_PROCESS_MEMORY         = 0x00000100;
JOB_OBJECT_LIMIT_PROCESS_TIME           = 0x00000002;
JOB_OBJECT_LIMIT_SCHEDULING_CLASS       = 0x00000080;
JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK    = 0x00001000;
JOB_OBJECT_LIMIT_SUBSET_AFFINITY        = 0x00004000;
JOB_OBJECT_LIMIT_WORKINGSET             = 0x00000001;
JobObjectAssociateCompletionPortInformation =      7;
JobObjectBasicAccountingInformation     =          1;
JobObjectBasicAndIoAccountingInformation =         8;
JobObjectBasicLimitInformation          =          2;
JobObjectBasicProcessIdList             =          3;
JobObjectBasicUIRestrictions            =          4;
JobObjectCpuRateControlInformation      =         15;
JobObjectLimitViolationInformation      =         13;
JobObjectEndOfJobTimeInformation        =          6;
JobObjectExtendedLimitInformation       =          9;
JobObjectGroupInformation               =         11;
JobObjectGroupInformationEx             =         14;
JobObjectLimitViolationInformation2     =         35;
JobObjectNetRateControlInformation      =         32;
JobObjectNotificationLimitInformation   =         12;
JobObjectNotificationLimitInformation2  =         34;
JobObjectSecurityLimitInformation       =          5;
#MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MAX_MODULE_NAME32                       =        255;
MAX_PATH                                =        260;
MEM_COMMIT                              =     0x1000;
MEM_DECOMMIT                            =     0x4000;
MEM_FREE                                =    0x10000;
MEM_IMAGE                               =  0x1000000;
MEM_MAPPED                              =    0x40000;
MEM_PRIVATE                             =    0x20000;
MEM_RELEASE                             =     0x8000;
MEM_RESERVE                             =     0x2000;
#NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
#OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
OPEN_ALWAYS                             =          4;
OPEN_EXISTING                           =          3;
#PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
PAGE_EXECUTE                            =       0x10;
PAGE_EXECUTE_READ                       =       0x20;
PAGE_EXECUTE_READWRITE                  =       0x40;
PAGE_EXECUTE_WRITECOPY                  =       0x80;
PAGE_GUARD                              =      0x100;
PAGE_NOACCESS                           =        0x1;
PAGE_NOCACHE                            =      0x200;
PAGE_READONLY                           =        0x2;
PAGE_READWRITE                          =        0x4;
PAGE_WRITECOMBINE                       =      0x400;
PAGE_WRITECOPY                          =        0x8;
PIPE_ACCESS_DUPLEX                      = 0x00000003;
PIPE_ACCESS_INBOUND                     = 0x00000001;
PIPE_ACCESS_OUTBOUND                    = 0x00000002;
PIPE_READMODE_BYTE                      = 0x00000000;
PIPE_READMODE_MESSAGE                   = 0x00000002;
PIPE_TYPE_BYTE                          = 0x00000000;
PIPE_TYPE_MESSAGE                       = 0x00000004;
PIPE_UNLIMITED_INSTANCES                =        255;
PIPE_WAIT                               = 0x00000000;
PIPE_NOWAIT                             = 0x00000001;
PROCESS_ALL_ACCESS                      =   0x1FFFFF;
PROCESS_CREATE_PROCESS                  =     0x0080;
PROCESS_CREATE_THREAD                   =     0x0002;
PROCESS_DUP_HANDLE                      =     0x0040;
PROCESS_QUERY_INFORMATION               =     0x0400;
PROCESS_QUERY_LIMITED_INFORMATION       =     0x1000;
PROCESS_SET_INFORMATION                 =     0x0200;
PROCESS_SET_QUOTA                       =     0x0100;
PROCESS_SUSPEND_RESUME                  =     0x0800;
PROCESS_TERMINATE                       =     0x0001;
PROCESS_VM_OPERATION                    =     0x0008;
PROCESS_VM_READ                         =     0x0010;
PROCESS_VM_WRITE                        =     0x0020;
ProcessBasicInformation                 =          0;
ProcessDebugPort                        =          7;
ProcessWow64Information                 =         26;
ProcessImageFileName                    =         27;
ProcessBreakOnTermination               =         29;
PROCESSOR_ARCHITECTURE_AMD64            =          9; # x64
PROCESSOR_ARCHITECTURE_ARM              =          5; # arm
PROCESSOR_ARCHITECTURE_IA64             =          6; # Itanium
PROCESSOR_ARCHITECTURE_INTEL            =          0; # x86
PROCESSOR_ARCHITECTURE_UNKNOWN          =     0xFFFF;
#RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
READ_CONTROL                            = 0x00020000;
#SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
SECURITY_MANDATORY_UNTRUSTED_RID        = 0x00000000; # Untrusted.
SECURITY_MANDATORY_LOW_RID              = 0x00001000; # Low integrity.
SECURITY_MANDATORY_MEDIUM_RID           = 0x00002000; #	Medium integrity.
SECURITY_MANDATORY_MEDIUM_PLUS_RID      = SECURITY_MANDATORY_MEDIUM_RID + 0x100; #	Medium high integrity.
SECURITY_MANDATORY_HIGH_RID             = 0X00003000; #	High integrity.
SECURITY_MANDATORY_SYSTEM_RID           = 0x00004000; #	System integrity.
SECURITY_MANDATORY_PROTECTED_PROCESS_RID= 0x00005000; #	Protected process.
STACK_SIZE_PARAM_IS_A_RESERVATION       = 0x00010000;
STARTF_FORCEONFEEDBACK                  = 0x00000040;
STARTF_FORCEOFFFEEDBACK                 = 0x00000080;
STARTF_PREVENTPINNING                   = 0x00002000;
STARTF_RUNFULLSCREEN                    = 0x00000020;
STARTF_TITLEISAPPID                     = 0x00001000;
STARTF_TITLEISLINKNAME                  = 0x00000800;
STARTF_UNTRUSTEDSOURCE                  = 0x00008000;
STARTF_USECOUNTCHARS                    = 0x00000008;
STARTF_USEFILLATTRIBUTE                 = 0x00000010;
STARTF_USEHOTKEY                        = 0x00000200;
STARTF_USEPOSITION                      = 0x00000004;
STARTF_USESHOWWINDOW                    = 0x00000001;
STARTF_USESIZE                          = 0x00000002;
STARTF_USESTDHANDLES                    = 0x00000100;
STATUS_WAIT_0                           = 0x00000000;
STATUS_WAIT_1                           = 0x00000001;
STATUS_WAIT_2                           = 0x00000002;
STATUS_WAIT_3                           = 0x00000003;
STATUS_WAIT_4                           = 0x00000004;
STATUS_WAIT_5                           = 0x00000005;
STATUS_WAIT_6                           = 0x00000006;
STATUS_WAIT_7                           = 0x00000007;
STATUS_WAIT_8                           = 0x00000008;
STATUS_WAIT_9                           = 0x00000009;
STATUS_WAIT_10                          = 0x0000000A;
STATUS_WAIT_11                          = 0x0000000B;
STATUS_WAIT_12                          = 0x0000000C;
STATUS_WAIT_13                          = 0x0000000D;
STATUS_WAIT_14                          = 0x0000000E;
STATUS_WAIT_15                          = 0x0000000F;
STATUS_WAIT_16                          = 0x00000010;
STATUS_WAIT_17                          = 0x00000011;
STATUS_WAIT_18                          = 0x00000012;
STATUS_WAIT_19                          = 0x00000013;
STATUS_WAIT_20                          = 0x00000014;
STATUS_WAIT_21                          = 0x00000015;
STATUS_WAIT_22                          = 0x00000016;
STATUS_WAIT_23                          = 0x00000017;
STATUS_WAIT_24                          = 0x00000018;
STATUS_WAIT_25                          = 0x00000019;
STATUS_WAIT_26                          = 0x0000001A;
STATUS_WAIT_27                          = 0x0000001B;
STATUS_WAIT_28                          = 0x0000001C;
STATUS_WAIT_29                          = 0x0000001D;
STATUS_WAIT_30                          = 0x0000001E;
STATUS_WAIT_31                          = 0x0000001F;
STATUS_WAIT_32                          = 0x00000020;
STATUS_WAIT_33                          = 0x00000021;
STATUS_WAIT_34                          = 0x00000022;
STATUS_WAIT_35                          = 0x00000023;
STATUS_WAIT_36                          = 0x00000024;
STATUS_WAIT_37                          = 0x00000025;
STATUS_WAIT_38                          = 0x00000026;
STATUS_WAIT_39                          = 0x00000027;
STATUS_WAIT_40                          = 0x00000028;
STATUS_WAIT_41                          = 0x00000029;
STATUS_WAIT_42                          = 0x0000002A;
STATUS_WAIT_43                          = 0x0000002B;
STATUS_WAIT_44                          = 0x0000002C;
STATUS_WAIT_45                          = 0x0000002D;
STATUS_WAIT_46                          = 0x0000002E;
STATUS_WAIT_47                          = 0x0000002F;
STATUS_WAIT_48                          = 0x00000030;
STATUS_WAIT_49                          = 0x00000031;
STATUS_WAIT_50                          = 0x00000032;
STATUS_WAIT_51                          = 0x00000033;
STATUS_WAIT_52                          = 0x00000034;
STATUS_WAIT_53                          = 0x00000035;
STATUS_WAIT_54                          = 0x00000036;
STATUS_WAIT_55                          = 0x00000037;
STATUS_WAIT_56                          = 0x00000038;
STATUS_WAIT_57                          = 0x00000039;
STATUS_WAIT_58                          = 0x0000003A;
STATUS_WAIT_59                          = 0x0000003B;
STATUS_WAIT_60                          = 0x0000003C;
STATUS_WAIT_61                          = 0x0000003D;
STATUS_WAIT_62                          = 0x0000003E;
STATUS_WAIT_63                          = 0x0000003F;
STATUS_ABANDONED                        = 0x00000080;
STATUS_ABANDONED_WAIT_0                 = 0x00000080;
STATUS_ABANDONED_WAIT_1                 = 0x00000081;
STATUS_ABANDONED_WAIT_2                 = 0x00000082;
STATUS_ABANDONED_WAIT_3                 = 0x00000083;
STATUS_ABANDONED_WAIT_4                 = 0x00000084;
STATUS_ABANDONED_WAIT_5                 = 0x00000085;
STATUS_ABANDONED_WAIT_6                 = 0x00000086;
STATUS_ABANDONED_WAIT_7                 = 0x00000087;
STATUS_ABANDONED_WAIT_8                 = 0x00000088;
STATUS_ABANDONED_WAIT_9                 = 0x00000089;
STATUS_ABANDONED_WAIT_10                = 0x0000008A;
STATUS_ABANDONED_WAIT_11                = 0x0000008B;
STATUS_ABANDONED_WAIT_12                = 0x0000008C;
STATUS_ABANDONED_WAIT_13                = 0x0000008D;
STATUS_ABANDONED_WAIT_14                = 0x0000008E;
STATUS_ABANDONED_WAIT_15                = 0x0000008F;
STATUS_ABANDONED_WAIT_16                = 0x00000090;
STATUS_ABANDONED_WAIT_17                = 0x00000091;
STATUS_ABANDONED_WAIT_18                = 0x00000092;
STATUS_ABANDONED_WAIT_19                = 0x00000093;
STATUS_ABANDONED_WAIT_20                = 0x00000094;
STATUS_ABANDONED_WAIT_21                = 0x00000095;
STATUS_ABANDONED_WAIT_22                = 0x00000096;
STATUS_ABANDONED_WAIT_23                = 0x00000097;
STATUS_ABANDONED_WAIT_24                = 0x00000098;
STATUS_ABANDONED_WAIT_25                = 0x00000099;
STATUS_ABANDONED_WAIT_26                = 0x0000009A;
STATUS_ABANDONED_WAIT_27                = 0x0000009B;
STATUS_ABANDONED_WAIT_28                = 0x0000009C;
STATUS_ABANDONED_WAIT_29                = 0x0000009D;
STATUS_ABANDONED_WAIT_30                = 0x0000009E;
STATUS_ABANDONED_WAIT_31                = 0x0000009F;
STATUS_ABANDONED_WAIT_32                = 0x000000A0;
STATUS_ABANDONED_WAIT_33                = 0x000000A1;
STATUS_ABANDONED_WAIT_34                = 0x000000A2;
STATUS_ABANDONED_WAIT_35                = 0x000000A3;
STATUS_ABANDONED_WAIT_36                = 0x000000A4;
STATUS_ABANDONED_WAIT_37                = 0x000000A5;
STATUS_ABANDONED_WAIT_38                = 0x000000A6;
STATUS_ABANDONED_WAIT_39                = 0x000000A7;
STATUS_ABANDONED_WAIT_40                = 0x000000A8;
STATUS_ABANDONED_WAIT_41                = 0x000000A9;
STATUS_ABANDONED_WAIT_42                = 0x000000AA;
STATUS_ABANDONED_WAIT_43                = 0x000000AB;
STATUS_ABANDONED_WAIT_44                = 0x000000AC;
STATUS_ABANDONED_WAIT_45                = 0x000000AD;
STATUS_ABANDONED_WAIT_46                = 0x000000AE;
STATUS_ABANDONED_WAIT_47                = 0x000000AF;
STATUS_ABANDONED_WAIT_48                = 0x000000B0;
STATUS_ABANDONED_WAIT_49                = 0x000000B1;
STATUS_ABANDONED_WAIT_50                = 0x000000B2;
STATUS_ABANDONED_WAIT_51                = 0x000000B3;
STATUS_ABANDONED_WAIT_52                = 0x000000B4;
STATUS_ABANDONED_WAIT_53                = 0x000000B5;
STATUS_ABANDONED_WAIT_54                = 0x000000B6;
STATUS_ABANDONED_WAIT_55                = 0x000000B7;
STATUS_ABANDONED_WAIT_56                = 0x000000B8;
STATUS_ABANDONED_WAIT_57                = 0x000000B9;
STATUS_ABANDONED_WAIT_58                = 0x000000BA;
STATUS_ABANDONED_WAIT_59                = 0x000000BB;
STATUS_ABANDONED_WAIT_60                = 0x000000BC;
STATUS_ABANDONED_WAIT_61                = 0x000000BD;
STATUS_ABANDONED_WAIT_62                = 0x000000BE;
STATUS_ABANDONED_WAIT_63                = 0x000000BF;
# These are defined in dsNTStatusDefineName_by_uValue but since they have the
# same value, one of them will be overwritten by the other. To make sure both
# are available, they are defined here as well:
STATUS_FWP_TOO_MANY_BOOTTIME_FILTERS    = 0xC0220018;
STATUS_FWP_TOO_MANY_CALLOUTS            = 0xC0220018;

STILL_ACTIVE                            =      0x103;
STD_ERROR_HANDLE                        =        -12;
STD_INPUT_HANDLE                        =        -10;
STD_OUTPUT_HANDLE                       =        -11;
def STOWED_EXCEPTION_INFORMATION_SIGNATURE(sbSignature):
  # This is not actually defined by Windows, but I needed to name this function so I named it similar to
  # STOWED_EXCEPTION_NESTED_TYPE
 return struct.unpack(">L", sbSignature)[0]; 
STOWED_EXCEPTION_INFORMATION_V1_SIGNATURE = STOWED_EXCEPTION_INFORMATION_SIGNATURE(b"SE01");
STOWED_EXCEPTION_INFORMATION_V2_SIGNATURE = STOWED_EXCEPTION_INFORMATION_SIGNATURE(b"SE02");
def STOWED_EXCEPTION_NESTED_TYPE(sbType):
 return struct.unpack("<L", sbType)[0]; 
STOWED_EXCEPTION_NESTED_TYPE_NONE       = 0x00000000;
STOWED_EXCEPTION_NESTED_TYPE_WIN32      = STOWED_EXCEPTION_NESTED_TYPE(b"W32E");
STOWED_EXCEPTION_NESTED_TYPE_STOWED     = STOWED_EXCEPTION_NESTED_TYPE(b"STOW");
STOWED_EXCEPTION_NESTED_TYPE_CLR        = STOWED_EXCEPTION_NESTED_TYPE(b"CLR1");
STOWED_EXCEPTION_NESTED_TYPE_LEO        = STOWED_EXCEPTION_NESTED_TYPE(b"LEO1");
STOWED_EXCEPTION_NESTED_TYPE_LMAX       = STOWED_EXCEPTION_NESTED_TYPE(b"LMAX"); # Undocumented, reversed from detected exceptions.
SYNCHRONIZE                             = 0x00100000;
# From https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa
SW_HIDE                                 = 0x00000000;
SW_SHOWNORMAL                           = 0x00000001;
SW_SHOWMINIMIZED                        = 0x00000002;
SW_MAXIMIZE                             = 0x00000003;
SW_SHOWMAXIMIZED                        = 0x00000003;
SW_SHOWNOACTIVATE                       = 0x00000004;
SW_SHOW                                 = 0x00000005;
SW_MINIMIZE                             = 0x00000006;
SW_SHOWMINNOACTIVE                      = 0x00000007;
SW_SHOWNA                               = 0x00000008;
SW_RESTORE                              = 0x00000009;
SW_SHOWDEFAULT                          = 0x00000010;
SW_FORCEMINIMIZE                        = 0x00000011;

#TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TH32CS_INHERIT                          = 0x80000000;
TH32CS_SNAPALL                          = 0x0000000F;
TH32CS_SNAPHEAPLIST                     = 0x00000001;
TH32CS_SNAPMODULE                       = 0x00000008;
TH32CS_SNAPMODULE32                     = 0x00000010;
TH32CS_SNAPPROCESS                      = 0x00000002;
TH32CS_SNAPTHREAD                       = 0x00000004;
THREAD_ALL_ACCESS                       =   0x100fff; # Not a static number across versions, use with caution!
THREAD_DIRECT_IMPERSONATION             =     0x0200;
THREAD_GET_CONTEXT                      =     0x0008;
THREAD_IMPERSONATE                      =     0x0100;
THREAD_QUERY_INFORMATION                =     0x0040;
THREAD_QUERY_LIMITED_INFORMATION        =     0x0800;
THREAD_SET_CONTEXT                      =     0x0010;
THREAD_SET_INFORMATION                  =     0x0020;
THREAD_SET_LIMITED_INFORMATION          =     0x0400;
THREAD_SET_THREAD_TOKEN                 =     0x0080;
THREAD_SUSPEND_RESUME                   =     0x0002;
THREAD_TERMINATE                        =     0x0001;
ThreadBasicInformation                  =          0;
ThreadTimes                             =          1;
ThreadPriority                          =          2;
ThreadBasePriority                      =          3;
ThreadAffinityMask                      =          4;
ThreadImpersonationToken                =          5;
ThreadDescriptorTableEntry              =          6;
ThreadEnableAlignmentFaultFixup         =          7;
ThreadEventPair_Reusable                =          8;
ThreadQuerySetWin32StartAddress         =          9;
ThreadZeroTlsCell                       =         10;
ThreadPerformanceCount                  =         11;
ThreadAmILastThread                     =         12;
ThreadIdealProcessor                    =         13;
ThreadPriorityBoost                     =         14;
ThreadSetTlsArrayAddress                =         15;
ThreadIsIoPending                       =         16;
ThreadHideFromDebugger                  =         17;
ThreadBreakOnTermination                =         18;
ThreadSwitchLegacyState                 =         19;
ThreadIsTerminated                      =         20;
ThreadLastSystemCall                    =         21;
ThreadIoPriority                        =         22;
ThreadCycleTime                         =         23;
ThreadPagePriority                      =         24;
ThreadActualBasePriority                =         25;
ThreadTebInformation                    =         26;
ThreadCSwitchMon                        =         27;
ThreadCSwitchPmu                        =         28;
ThreadWow64Context                      =         29;
ThreadGroupInformation                  =         30;
ThreadUmsInformation                    =         31;
ThreadCounterProfiling                  =         32;
ThreadIdealProcessorEx                  =         33;
TOKEN_QUERY                             =     0x0008;
TokenIntegrityLevel                     =         25;
TRUNCATE_EXISTING                       =          5;
#UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
UNDNAME_32_BIT_DECODE                   =     0x0800;
UNDNAME_COMPLETE                        =     0x0000;
UNDNAME_NAME_ONLY                       =     0x1000;
UNDNAME_NO_ACCESS_SPECIFIERS            =     0x0080;
UNDNAME_NO_ALLOCATION_LANGUAGE          =     0x0010;
UNDNAME_NO_ALLOCATION_MODEL             =     0x0008;
UNDNAME_NO_ARGUMENTS                    =     0x2000;
UNDNAME_NO_CV_THISTYPE                  =     0x0040;
UNDNAME_NO_FUNCTION_RETURNS             =     0x0004;
UNDNAME_NO_LEADING_UNDERSCORES          =     0x0001;
UNDNAME_NO_MEMBER_TYPE                  =     0x0200;
UNDNAME_NO_MS_KEYWORDS                  =     0x0002;
UNDNAME_NO_MS_THISTYPE                  =     0x0020;
UNDNAME_NO_RETURN_UDT_MODEL             =     0x0400;
UNDNAME_NO_SPECIAL_SYMS                 =     0x4000;
UNDNAME_NO_THISTYPE                     =     0x0060;
UNDNAME_NO_THROW_SIGNATURES             =     0x0100;
#VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
#WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WAIT_ABANDONED                          =        128;
WAIT_FAILED                             = 0xFFFFFFFF;
WAIT_OBJECT_0                           =          0;
WAIT_OBJECT_1                           =          1;
WAIT_OBJECT_2                           =          2;
WAIT_OBJECT_3                           =          3;
WAIT_OBJECT_4                           =          4;
WAIT_OBJECT_5                           =          5;
WAIT_OBJECT_6                           =          6;
WAIT_OBJECT_7                           =          7;
WAIT_OBJECT_8                           =          8;
WAIT_OBJECT_9                           =          9;
WAIT_OBJECT_10                          =         10;
WAIT_OBJECT_11                          =         11;
WAIT_OBJECT_12                          =         12;
WAIT_OBJECT_13                          =         13;
WAIT_OBJECT_14                          =         14;
WAIT_OBJECT_15                          =         15;
WAIT_OBJECT_16                          =         16;
WAIT_OBJECT_17                          =         17;
WAIT_OBJECT_18                          =         18;
WAIT_OBJECT_19                          =         19;
WAIT_OBJECT_20                          =         20;
WAIT_OBJECT_21                          =         21;
WAIT_OBJECT_22                          =         22;
WAIT_OBJECT_23                          =         23;
WAIT_OBJECT_24                          =         24;
WAIT_OBJECT_25                          =         25;
WAIT_OBJECT_26                          =         26;
WAIT_OBJECT_27                          =         27;
WAIT_OBJECT_28                          =         28;
WAIT_OBJECT_29                          =         29;
WAIT_OBJECT_30                          =         30;
WAIT_OBJECT_31                          =         31;
WAIT_OBJECT_32                          =         32;
WAIT_OBJECT_33                          =         33;
WAIT_OBJECT_34                          =         34;
WAIT_OBJECT_35                          =         35;
WAIT_OBJECT_36                          =         36;
WAIT_OBJECT_37                          =         37;
WAIT_OBJECT_38                          =         38;
WAIT_OBJECT_39                          =         39;
WAIT_OBJECT_40                          =         40;
WAIT_OBJECT_41                          =         41;
WAIT_OBJECT_42                          =         42;
WAIT_OBJECT_43                          =         43;
WAIT_OBJECT_44                          =         44;
WAIT_OBJECT_45                          =         45;
WAIT_OBJECT_46                          =         46;
WAIT_OBJECT_47                          =         47;
WAIT_OBJECT_48                          =         48;
WAIT_OBJECT_49                          =         49;
WAIT_OBJECT_50                          =         50;
WAIT_OBJECT_51                          =         51;
WAIT_OBJECT_52                          =         52;
WAIT_OBJECT_53                          =         53;
WAIT_OBJECT_54                          =         54;
WAIT_OBJECT_55                          =         55;
WAIT_OBJECT_56                          =         56;
WAIT_OBJECT_57                          =         57;
WAIT_OBJECT_58                          =         58;
WAIT_OBJECT_59                          =         59;
WAIT_OBJECT_60                          =         60;
WAIT_OBJECT_61                          =         61;
WAIT_OBJECT_62                          =         62;
WAIT_OBJECT_63                          =         63;
WAIT_TIMEOUT                            = 0x00000102;
WPF_SETMINPOSITION                      =     0x0001;
WPF_RESTORETOMAXIMIZED                  =     0x0002;
WPF_ASYNCWINDOWPLACEMENT                =     0x0004;
WRITE_DAC                               = 0x00040000;
WRITE_OWNER                             = 0x00080000;

# __all__ has all globals that we added in the code above.
__all__ = [
  sGlobalsName for sGlobalsName in dxGlobals.keys()
  if sGlobalsName not in asOriginalGlobalsNames
];
# Add all defines from the various sub-modules
for dsDefineName_by_uValue in (
  dsHResultDefineName_by_uValue,
  dsExceptionDefineName_by_uValue,
  dsNTStatusDefineName_by_uValue,
  dsWin32ErrorCodeDefineName_by_uValue,
):
  for (uValue, sName) in dsDefineName_by_uValue.items():
    assert sName not in dxGlobals or dxGlobals[sName] == uValue, \
        "#define %s 0x%X *and* 0x%X!?" % (sName, uValue, duDefineValue_by_sName[sName]);
    dxGlobals[sName] = uValue;
    __all__.append(sName);
