|
| 1 | +using System; |
| 2 | + |
| 3 | +namespace PSADT.Interop |
| 4 | +{ |
| 5 | + /// <summary> |
| 6 | + /// Defines flags that specify the characteristics of a Dynamic Link Library (DLL) image, controlling aspects of its |
| 7 | + /// loading, execution, and security behavior in the Windows operating system. |
| 8 | + /// </summary> |
| 9 | + /// <remarks>Use the values of this enumeration to indicate or query specific features and requirements of |
| 10 | + /// a DLL, such as support for address space layout randomization (ASLR), data execution prevention (DEP), control |
| 11 | + /// flow guard (CFG), application container compatibility, and other security or compatibility options. These flags |
| 12 | + /// correspond directly to the IMAGE_DLL_CHARACTERISTICS field in the Windows Portable Executable (PE) file format |
| 13 | + /// and are typically set by the linker or examined by system utilities and loaders. Multiple flags can be combined |
| 14 | + /// to represent the full set of characteristics for a given DLL.</remarks> |
| 15 | + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1028:Enum Storage should be Int32", Justification = "The type is correct for the underlying Win32 API.")] |
| 16 | + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1069:Enums values should not be duplicated", Justification = "These values are precisely as they're defined in the Win32 API.")] |
| 17 | + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "These values are precisely as they're defined in the Win32 API.")] |
| 18 | + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1712:Do not prefix enum values with type name", Justification = "These values are precisely as they're defined in the Win32 API.")] |
| 19 | + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1700:Do not name enum values 'Reserved'", Justification = "These values are precisely as they're defined in the Win32 API.")] |
| 20 | + [Flags] |
| 21 | + public enum IMAGE_DLL_CHARACTERISTICS : ushort |
| 22 | + { |
| 23 | + /// <summary> |
| 24 | + /// Specifies that the DLL supports high entropy virtual addresses, enabling the use of a larger address space |
| 25 | + /// and providing enhanced security through improved address space layout randomization (ASLR). |
| 26 | + /// </summary> |
| 27 | + /// <remarks>This characteristic is primarily relevant for 64-bit applications running on |
| 28 | + /// operating systems that support high entropy virtual addresses. Enabling this flag can help mitigate certain |
| 29 | + /// types of security vulnerabilities by making it more difficult for attackers to predict the location of code |
| 30 | + /// and data in memory.</remarks> |
| 31 | + IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA, |
| 32 | + |
| 33 | + /// <summary> |
| 34 | + /// Represents the dynamic base address characteristic for a DLL, indicating that the DLL can be relocated at |
| 35 | + /// load time. |
| 36 | + /// </summary> |
| 37 | + /// <remarks>When this characteristic is set, the operating system can load the DLL at a different |
| 38 | + /// address than its preferred base address, which helps avoid address space conflicts with other |
| 39 | + /// modules.</remarks> |
| 40 | + IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE, |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Specifies that the DLL enforces code and data integrity checks at load time. |
| 44 | + /// </summary> |
| 45 | + /// <remarks>This flag enhances the security of the DLL by ensuring that its code and data have |
| 46 | + /// not been tampered with. It is part of the IMAGE_DLL_CHARACTERISTICS enumeration and is typically used in |
| 47 | + /// scenarios where integrity verification is required to prevent unauthorized modifications.</remarks> |
| 48 | + IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY, |
| 49 | + |
| 50 | + /// <summary> |
| 51 | + /// Specifies that the DLL is compatible with the NX (No eXecute) processor feature, which helps prevent |
| 52 | + /// execution of code in certain areas of memory to enhance security. |
| 53 | + /// </summary> |
| 54 | + /// <remarks>This flag is part of the IMAGE_DLL_CHARACTERISTICS enumeration and indicates that the |
| 55 | + /// DLL supports Data Execution Prevention (DEP). Enabling NX compatibility can help mitigate certain types of |
| 56 | + /// security vulnerabilities by marking memory regions as non-executable.</remarks> |
| 57 | + IMAGE_DLLCHARACTERISTICS_NX_COMPAT = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_NX_COMPAT, |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Specifies that the DLL does not use isolation, allowing it to share resources with other DLLs. |
| 61 | + /// </summary> |
| 62 | + /// <remarks>This value is used in the context of Windows DLLs to indicate that the DLL can |
| 63 | + /// operate without isolation from other DLLs. Disabling isolation may affect resource sharing and loading |
| 64 | + /// behavior, and is typically relevant when managing application compatibility or resource access across |
| 65 | + /// multiple DLLs.</remarks> |
| 66 | + IMAGE_DLLCHARACTERISTICS_NO_ISOLATION = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_NO_ISOLATION, |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Specifies that the DLL does not use Structured Exception Handling (SEH). |
| 70 | + /// </summary> |
| 71 | + /// <remarks>This characteristic indicates that the DLL is not designed to handle exceptions using |
| 72 | + /// SEH, which may affect how exceptions are managed in applications that load this DLL.</remarks> |
| 73 | + IMAGE_DLLCHARACTERISTICS_NO_SEH = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_NO_SEH, |
| 74 | + |
| 75 | + /// <summary> |
| 76 | + /// Specifies that the DLL does not require binding to any other DLLs at load time. |
| 77 | + /// </summary> |
| 78 | + /// <remarks>This characteristic indicates that the DLL can be loaded without needing to resolve |
| 79 | + /// dependencies, which may improve load performance in certain scenarios.</remarks> |
| 80 | + IMAGE_DLLCHARACTERISTICS_NO_BIND = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_NO_BIND, |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// Indicates that the DLL is intended to run within an application container, enabling additional security and |
| 84 | + /// isolation constraints. |
| 85 | + /// </summary> |
| 86 | + /// <remarks>This value is part of the IMAGE_DLL_CHARACTERISTICS enumeration and is used to |
| 87 | + /// specify that a DLL supports execution in an application container environment. Application containers are |
| 88 | + /// commonly used to restrict the capabilities of applications and enhance security by isolating them from the |
| 89 | + /// rest of the system.</remarks> |
| 90 | + IMAGE_DLLCHARACTERISTICS_APPCONTAINER = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_APPCONTAINER, |
| 91 | + |
| 92 | + /// <summary> |
| 93 | + /// Indicates that the image is a Windows Driver Model (WDM) driver. |
| 94 | + /// </summary> |
| 95 | + /// <remarks>This value is part of the IMAGE_DLL_CHARACTERISTICS enumeration and is used by the |
| 96 | + /// operating system to identify DLLs that implement WDM drivers. Setting this characteristic ensures that the |
| 97 | + /// image is loaded and managed according to WDM driver requirements.</remarks> |
| 98 | + IMAGE_DLLCHARACTERISTICS_WDM_DRIVER = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_WDM_DRIVER, |
| 99 | + |
| 100 | + /// <summary> |
| 101 | + /// Represents the Control Flow Guard (CFG) characteristic for a DLL, indicating that the DLL is protected by |
| 102 | + /// control flow guard security features. |
| 103 | + /// </summary> |
| 104 | + /// <remarks>Control Flow Guard is a security feature that helps prevent indirect call hijacking |
| 105 | + /// by validating the target of indirect calls at runtime. This characteristic is set by the linker when CFG is |
| 106 | + /// enabled for the DLL.</remarks> |
| 107 | + IMAGE_DLLCHARACTERISTICS_GUARD_CF = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_GUARD_CF, |
| 108 | + |
| 109 | + /// <summary> |
| 110 | + /// Specifies that the DLL is aware of and can operate correctly in terminal server environments. |
| 111 | + /// </summary> |
| 112 | + /// <remarks>This constant indicates that the DLL is designed to function properly when loaded in |
| 113 | + /// a terminal server context, which may affect its behavior and resource management. Use this flag to ensure |
| 114 | + /// compatibility with terminal server features such as session isolation and resource redirection.</remarks> |
| 115 | + IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE, |
| 116 | + |
| 117 | + /// <summary> |
| 118 | + /// Specifies that the DLL is compatible with Control-flow Enforcement Technology (CET), a security feature |
| 119 | + /// supported by modern Windows operating systems. |
| 120 | + /// </summary> |
| 121 | + /// <remarks>This value is part of the IMAGE_DLL_CHARACTERISTICS enumeration and indicates that |
| 122 | + /// the DLL supports CET, which helps protect against certain classes of exploits by enforcing control-flow |
| 123 | + /// integrity. Use this flag to ensure compatibility with enhanced security environments on Windows.</remarks> |
| 124 | + IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT, |
| 125 | + |
| 126 | + /// <summary> |
| 127 | + /// Represents the strict mode compatibility setting for Control-flow Enforcement Technology (CET) in DLL |
| 128 | + /// characteristics. |
| 129 | + /// </summary> |
| 130 | + /// <remarks>This constant is used to indicate that a DLL operates in strict CET compatibility |
| 131 | + /// mode. Enabling strict mode may affect how the operating system enforces security features related to |
| 132 | + /// control-flow integrity for the DLL.</remarks> |
| 133 | + IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT_STRICT_MODE = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT_STRICT_MODE, |
| 134 | + |
| 135 | + /// <summary> |
| 136 | + /// Specifies the DLL characteristic that enables relaxed instruction pointer (IP) validation when setting the |
| 137 | + /// execution context for a DLL. |
| 138 | + /// </summary> |
| 139 | + /// <remarks>This characteristic allows for more permissive checks on the instruction pointer |
| 140 | + /// during context switching, which can be useful in certain debugging or diagnostic scenarios. Use with |
| 141 | + /// caution, as relaxed validation may impact security or application stability.</remarks> |
| 142 | + IMAGE_DLLCHARACTERISTICS_EX_CET_SET_CONTEXT_IP_VALIDATION_RELAXED_MODE = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_EX_CET_SET_CONTEXT_IP_VALIDATION_RELAXED_MODE, |
| 143 | + |
| 144 | + /// <summary> |
| 145 | + /// Specifies that dynamic APIs are permitted to be called in-process by the DLL. |
| 146 | + /// </summary> |
| 147 | + /// <remarks>This value is part of the IMAGE_DLLCHARACTERISTICS enumeration and indicates that the |
| 148 | + /// DLL supports dynamic APIs that can be invoked from within the same process. This characteristic may be |
| 149 | + /// relevant for compatibility or security considerations when loading or interacting with DLLs that expose |
| 150 | + /// dynamic APIs.</remarks> |
| 151 | + IMAGE_DLLCHARACTERISTICS_EX_CET_DYNAMIC_APIS_ALLOW_IN_PROC = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_EX_CET_DYNAMIC_APIS_ALLOW_IN_PROC, |
| 152 | + |
| 153 | + /// <summary> |
| 154 | + /// Represents a reserved DLL characteristic flag corresponding to IMAGE_DLLCHARACTERISTICS_EX_CET_RESERVED_1. |
| 155 | + /// </summary> |
| 156 | + /// <remarks>This value is reserved for future use and should not be relied upon in current |
| 157 | + /// applications. It is defined by the Windows API for potential compatibility or security features related to |
| 158 | + /// Control-flow Enforcement Technology (CET).</remarks> |
| 159 | + IMAGE_DLLCHARACTERISTICS_EX_CET_RESERVED_1 = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_EX_CET_RESERVED_1, |
| 160 | + |
| 161 | + /// <summary> |
| 162 | + /// Represents a reserved characteristic for the DLL, specifically the |
| 163 | + /// IMAGE_DLLCHARACTERISTICS_EX_CET_RESERVED_2 value. |
| 164 | + /// </summary> |
| 165 | + /// <remarks>This field is part of the IMAGE_DLL_CHARACTERISTICS enumeration and is reserved for |
| 166 | + /// future use by the Windows operating system. It should not be used or modified in application code.</remarks> |
| 167 | + IMAGE_DLLCHARACTERISTICS_EX_CET_RESERVED_2 = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_EX_CET_RESERVED_2, |
| 168 | + |
| 169 | + /// <summary> |
| 170 | + /// Specifies that the DLL supports forward control flow integrity (CFI) compatibility. |
| 171 | + /// </summary> |
| 172 | + /// <remarks>This value is part of the IMAGE_DLL_CHARACTERISTICS enumeration and indicates that |
| 173 | + /// the DLL is compatible with forward CFI, which helps enhance security by ensuring that control flow is |
| 174 | + /// maintained as intended.</remarks> |
| 175 | + IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT, |
| 176 | + |
| 177 | + /// <summary> |
| 178 | + /// Specifies that the DLL is compatible with hot patching, allowing it to be updated in memory without |
| 179 | + /// requiring an application restart. |
| 180 | + /// </summary> |
| 181 | + /// <remarks>This value is part of the IMAGE_DLL_CHARACTERISTICS enumeration and indicates that |
| 182 | + /// the DLL supports hot patching. Hot patching enables updates to be applied to the DLL while it is loaded, |
| 183 | + /// which can be useful for applying security fixes or updates without interrupting running |
| 184 | + /// applications.</remarks> |
| 185 | + IMAGE_DLLCHARACTERISTICS_EX_HOTPATCH_COMPATIBLE = Windows.Win32.System.Diagnostics.Debug.IMAGE_DLL_CHARACTERISTICS.IMAGE_DLLCHARACTERISTICS_EX_HOTPATCH_COMPATIBLE, |
| 186 | + } |
| 187 | +} |
0 commit comments