Add --mangle switch for mangling password before hashing
[hashcat.git] / include / ext_nvapi.h
1 /**
2 * Authors.....: Jens Steube <jens.steube@gmail.com>
3 * Gabriele Gristina <matrix@hashcat.net>
4 *
5 * License.....: MIT
6 */
7
8 #ifndef EXT_NVAPI_H
9 #define EXT_NVAPI_H
10
11 #if defined(HAVE_HWMON)
12
13 #include <common.h>
14
15 /**
16 * Declarations from nvapi.h and subheaders
17 */
18
19 #define NVAPI_INTERFACE extern NvAPI_Status
20
21 typedef unsigned long NvU32;
22 typedef signed long NvS32;
23
24 #define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
25
26 NV_DECLARE_HANDLE(NvPhysicalGpuHandle); // A single physical GPU
27
28 #define NVAPI_GENERIC_STRING_MAX 4096
29 #define NVAPI_LONG_STRING_MAX 256
30 #define NVAPI_SHORT_STRING_MAX 64
31
32 typedef char NvAPI_String[NVAPI_GENERIC_STRING_MAX];
33 typedef char NvAPI_LongString[NVAPI_LONG_STRING_MAX];
34 typedef char NvAPI_ShortString[NVAPI_SHORT_STRING_MAX];
35
36 #define MAKE_NVAPI_VERSION(typeName,ver) (NvU32)(sizeof(typeName) | ((ver)<<16))
37
38 #define NVAPI_MAX_PHYSICAL_GPUS 64
39 #define NVAPI_MAX_COOLER_PER_GPU 20
40
41 #define GPU_COOLER_LEVELS_VER 0x10000
42
43 typedef enum _NvAPI_Status
44 {
45 NVAPI_OK = 0, // Success. Request is completed.
46 NVAPI_ERROR = -1, // Generic error
47 NVAPI_LIBRARY_NOT_FOUND = -2, // NVAPI support library cannot be loaded.
48 NVAPI_NO_IMPLEMENTATION = -3, // not implemented in current driver installation
49 NVAPI_API_NOT_INITIALIZED = -4, // NvAPI_Initialize has not been called (successfully)
50 NVAPI_INVALID_ARGUMENT = -5, // The argument/parameter value is not valid or NULL.
51 NVAPI_NVIDIA_DEVICE_NOT_FOUND = -6, // No NVIDIA display driver, or NVIDIA GPU driving a display, was found.
52 NVAPI_END_ENUMERATION = -7, // No more items to enumerate
53 NVAPI_INVALID_HANDLE = -8, // Invalid handle
54 NVAPI_INCOMPATIBLE_STRUCT_VERSION = -9, // An argument's structure version is not supported
55 NVAPI_HANDLE_INVALIDATED = -10, // The handle is no longer valid (likely due to GPU or display re-configuration)
56 NVAPI_OPENGL_CONTEXT_NOT_CURRENT = -11, // No NVIDIA OpenGL context is current (but needs to be)
57 NVAPI_INVALID_POINTER = -14, // An invalid pointer, usually NULL, was passed as a parameter
58 NVAPI_NO_GL_EXPERT = -12, // OpenGL Expert is not supported by the current drivers
59 NVAPI_INSTRUMENTATION_DISABLED = -13, // OpenGL Expert is supported, but driver instrumentation is currently disabled
60 NVAPI_NO_GL_NSIGHT = -15, // OpenGL does not support Nsight
61
62 NVAPI_EXPECTED_LOGICAL_GPU_HANDLE = -100, // Expected a logical GPU handle for one or more parameters
63 NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE = -101, // Expected a physical GPU handle for one or more parameters
64 NVAPI_EXPECTED_DISPLAY_HANDLE = -102, // Expected an NV display handle for one or more parameters
65 NVAPI_INVALID_COMBINATION = -103, // The combination of parameters is not valid.
66 NVAPI_NOT_SUPPORTED = -104, // Requested feature is not supported in the selected GPU
67 NVAPI_PORTID_NOT_FOUND = -105, // No port ID was found for the I2C transaction
68 NVAPI_EXPECTED_UNATTACHED_DISPLAY_HANDLE = -106, // Expected an unattached display handle as one of the input parameters.
69 NVAPI_INVALID_PERF_LEVEL = -107, // Invalid perf level
70 NVAPI_DEVICE_BUSY = -108, // Device is busy; request not fulfilled
71 NVAPI_NV_PERSIST_FILE_NOT_FOUND = -109, // NV persist file is not found
72 NVAPI_PERSIST_DATA_NOT_FOUND = -110, // NV persist data is not found
73 NVAPI_EXPECTED_TV_DISPLAY = -111, // Expected a TV output display
74 NVAPI_EXPECTED_TV_DISPLAY_ON_DCONNECTOR = -112, // Expected a TV output on the D Connector - HDTV_EIAJ4120.
75 NVAPI_NO_ACTIVE_SLI_TOPOLOGY = -113, // SLI is not active on this device.
76 NVAPI_SLI_RENDERING_MODE_NOTALLOWED = -114, // Setup of SLI rendering mode is not possible right now.
77 NVAPI_EXPECTED_DIGITAL_FLAT_PANEL = -115, // Expected a digital flat panel.
78 NVAPI_ARGUMENT_EXCEED_MAX_SIZE = -116, // Argument exceeds the expected size.
79 NVAPI_DEVICE_SWITCHING_NOT_ALLOWED = -117, // Inhibit is ON due to one of the flags in NV_GPU_DISPLAY_CHANGE_INHIBIT or SLI active.
80 NVAPI_TESTING_CLOCKS_NOT_SUPPORTED = -118, // Testing of clocks is not supported.
81 NVAPI_UNKNOWN_UNDERSCAN_CONFIG = -119, // The specified underscan config is from an unknown source (e.g. INF)
82 NVAPI_TIMEOUT_RECONFIGURING_GPU_TOPO = -120, // Timeout while reconfiguring GPUs
83 NVAPI_DATA_NOT_FOUND = -121, // Requested data was not found
84 NVAPI_EXPECTED_ANALOG_DISPLAY = -122, // Expected an analog display
85 NVAPI_NO_VIDLINK = -123, // No SLI video bridge is present
86 NVAPI_REQUIRES_REBOOT = -124, // NVAPI requires a reboot for the settings to take effect
87 NVAPI_INVALID_HYBRID_MODE = -125, // The function is not supported with the current Hybrid mode.
88 NVAPI_MIXED_TARGET_TYPES = -126, // The target types are not all the same
89 NVAPI_SYSWOW64_NOT_SUPPORTED = -127, // The function is not supported from 32-bit on a 64-bit system.
90 NVAPI_IMPLICIT_SET_GPU_TOPOLOGY_CHANGE_NOT_ALLOWED = -128, // There is no implicit GPU topology active. Use NVAPI_SetHybridMode to change topology.
91 NVAPI_REQUEST_USER_TO_CLOSE_NON_MIGRATABLE_APPS = -129, // Prompt the user to close all non-migratable applications.
92 NVAPI_OUT_OF_MEMORY = -130, // Could not allocate sufficient memory to complete the call.
93 NVAPI_WAS_STILL_DRAWING = -131, // The previous operation that is transferring information to or from this surface is incomplete.
94 NVAPI_FILE_NOT_FOUND = -132, // The file was not found.
95 NVAPI_TOO_MANY_UNIQUE_STATE_OBJECTS = -133, // There are too many unique instances of a particular type of state object.
96 NVAPI_INVALID_CALL = -134, // The method call is invalid. For example, a method's parameter may not be a valid pointer.
97 NVAPI_D3D10_1_LIBRARY_NOT_FOUND = -135, // d3d10_1.dll cannot be loaded.
98 NVAPI_FUNCTION_NOT_FOUND = -136, // Couldn't find the function in the loaded DLL.
99 NVAPI_INVALID_USER_PRIVILEGE = -137, // Current User is not Admin.
100 NVAPI_EXPECTED_NON_PRIMARY_DISPLAY_HANDLE = -138, // The handle corresponds to GDIPrimary.
101 NVAPI_EXPECTED_COMPUTE_GPU_HANDLE = -139, // Setting Physx GPU requires that the GPU is compute-capable.
102 NVAPI_STEREO_NOT_INITIALIZED = -140, // The Stereo part of NVAPI failed to initialize completely. Check if the stereo driver is installed.
103 NVAPI_STEREO_REGISTRY_ACCESS_FAILED = -141, // Access to stereo-related registry keys or values has failed.
104 NVAPI_STEREO_REGISTRY_PROFILE_TYPE_NOT_SUPPORTED = -142, // The given registry profile type is not supported.
105 NVAPI_STEREO_REGISTRY_VALUE_NOT_SUPPORTED = -143, // The given registry value is not supported.
106 NVAPI_STEREO_NOT_ENABLED = -144, // Stereo is not enabled and the function needed it to execute completely.
107 NVAPI_STEREO_NOT_TURNED_ON = -145, // Stereo is not turned on and the function needed it to execute completely.
108 NVAPI_STEREO_INVALID_DEVICE_INTERFACE = -146, // Invalid device interface.
109 NVAPI_STEREO_PARAMETER_OUT_OF_RANGE = -147, // Separation percentage or JPEG image capture quality is out of [0-100] range.
110 NVAPI_STEREO_FRUSTUM_ADJUST_MODE_NOT_SUPPORTED = -148, // The given frustum adjust mode is not supported.
111 NVAPI_TOPO_NOT_POSSIBLE = -149, // The mosaic topology is not possible given the current state of the hardware.
112 NVAPI_MODE_CHANGE_FAILED = -150, // An attempt to do a display resolution mode change has failed.
113 NVAPI_D3D11_LIBRARY_NOT_FOUND = -151, // d3d11.dll/d3d11_beta.dll cannot be loaded.
114 NVAPI_INVALID_ADDRESS = -152, // Address is outside of valid range.
115 NVAPI_STRING_TOO_SMALL = -153, // The pre-allocated string is too small to hold the result.
116 NVAPI_MATCHING_DEVICE_NOT_FOUND = -154, // The input does not match any of the available devices.
117 NVAPI_DRIVER_RUNNING = -155, // Driver is running.
118 NVAPI_DRIVER_NOTRUNNING = -156, // Driver is not running.
119 NVAPI_ERROR_DRIVER_RELOAD_REQUIRED = -157, // A driver reload is required to apply these settings.
120 NVAPI_SET_NOT_ALLOWED = -158, // Intended setting is not allowed.
121 NVAPI_ADVANCED_DISPLAY_TOPOLOGY_REQUIRED = -159, // Information can't be returned due to "advanced display topology".
122 NVAPI_SETTING_NOT_FOUND = -160, // Setting is not found.
123 NVAPI_SETTING_SIZE_TOO_LARGE = -161, // Setting size is too large.
124 NVAPI_TOO_MANY_SETTINGS_IN_PROFILE = -162, // There are too many settings for a profile.
125 NVAPI_PROFILE_NOT_FOUND = -163, // Profile is not found.
126 NVAPI_PROFILE_NAME_IN_USE = -164, // Profile name is duplicated.
127 NVAPI_PROFILE_NAME_EMPTY = -165, // Profile name is empty.
128 NVAPI_EXECUTABLE_NOT_FOUND = -166, // Application not found in the Profile.
129 NVAPI_EXECUTABLE_ALREADY_IN_USE = -167, // Application already exists in the other profile.
130 NVAPI_DATATYPE_MISMATCH = -168, // Data Type mismatch
131 NVAPI_PROFILE_REMOVED = -169, // The profile passed as parameter has been removed and is no longer valid.
132 NVAPI_UNREGISTERED_RESOURCE = -170, // An unregistered resource was passed as a parameter.
133 NVAPI_ID_OUT_OF_RANGE = -171, // The DisplayId corresponds to a display which is not within the normal outputId range.
134 NVAPI_DISPLAYCONFIG_VALIDATION_FAILED = -172, // Display topology is not valid so the driver cannot do a mode set on this configuration.
135 NVAPI_DPMST_CHANGED = -173, // Display Port Multi-Stream topology has been changed.
136 NVAPI_INSUFFICIENT_BUFFER = -174, // Input buffer is insufficient to hold the contents.
137 NVAPI_ACCESS_DENIED = -175, // No access to the caller.
138 NVAPI_MOSAIC_NOT_ACTIVE = -176, // The requested action cannot be performed without Mosaic being enabled.
139 NVAPI_SHARE_RESOURCE_RELOCATED = -177, // The surface is relocated away from video memory.
140 NVAPI_REQUEST_USER_TO_DISABLE_DWM = -178, // The user should disable DWM before calling NvAPI.
141 NVAPI_D3D_DEVICE_LOST = -179, // D3D device status is D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET - the user has to reset the device.
142 NVAPI_INVALID_CONFIGURATION = -180, // The requested action cannot be performed in the current state.
143 NVAPI_STEREO_HANDSHAKE_NOT_DONE = -181, // Call failed as stereo handshake not completed.
144 NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS = -182, // The path provided was too short to determine the correct NVDRS_APPLICATION
145 NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED = -183, // Default stereo profile is not currently defined
146 NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST = -184, // Default stereo profile does not exist
147 NVAPI_CLUSTER_ALREADY_EXISTS = -185, // A cluster is already defined with the given configuration.
148 NVAPI_DPMST_DISPLAY_ID_EXPECTED = -186, // The input display id is not that of a multi stream enabled connector or a display device in a multi stream topology
149 NVAPI_INVALID_DISPLAY_ID = -187, // The input display id is not valid or the monitor associated to it does not support the current operation
150 NVAPI_STREAM_IS_OUT_OF_SYNC = -188, // While playing secure audio stream, stream goes out of sync
151 NVAPI_INCOMPATIBLE_AUDIO_DRIVER = -189, // Older audio driver version than required
152 NVAPI_VALUE_ALREADY_SET = -190, // Value already set, setting again not allowed.
153 NVAPI_TIMEOUT = -191, // Requested operation timed out
154 NVAPI_GPU_WORKSTATION_FEATURE_INCOMPLETE = -192, // The requested workstation feature set has incomplete driver internal allocation resources
155 NVAPI_STEREO_INIT_ACTIVATION_NOT_DONE = -193, // Call failed because InitActivation was not called.
156 NVAPI_SYNC_NOT_ACTIVE = -194, // The requested action cannot be performed without Sync being enabled.
157 NVAPI_SYNC_MASTER_NOT_FOUND = -195, // The requested action cannot be performed without Sync Master being enabled.
158 NVAPI_INVALID_SYNC_TOPOLOGY = -196, // Invalid displays passed in the NV_GSYNC_DISPLAY pointer.
159 NVAPI_ECID_SIGN_ALGO_UNSUPPORTED = -197, // The specified signing algorithm is not supported. Either an incorrect value was entered or the current installed driver/hardware does not support the input value.
160 NVAPI_ECID_KEY_VERIFICATION_FAILED = -198, // The encrypted public key verification has failed.
161 NVAPI_FIRMWARE_OUT_OF_DATE = -199, // The device's firmware is out of date.
162 NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED = -200, // The device's firmware is not supported.
163 } NvAPI_Status;
164
165 typedef struct
166 {
167 // total size (of memset) is always: 76 = 0x4c
168
169 NvU32 version;
170
171 NvU32 a;
172 NvU32 info_value;
173
174 unsigned char x[64];
175
176 } NV_GPU_PERF_POLICIES_INFO_PARAMS_V1;
177
178 typedef struct
179 {
180 // total size (of memset) is always: 1360 = 0x550
181
182 NvU32 version;
183 NvU32 info_value;
184
185 NvU32 a;
186 NvU32 b;
187
188 NvU32 throttle;
189
190 unsigned char x[1340];
191
192 } NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1;
193
194 typedef struct
195 {
196 NvS32 Level;
197 NvS32 Policy;
198
199 } NvLevel;
200
201 typedef struct
202 {
203 NvU32 Version;
204 NvLevel Levels[NVAPI_MAX_COOLER_PER_GPU];
205
206 } NV_GPU_COOLER_LEVELS;
207
208 NVAPI_INTERFACE NvAPI_QueryInterface (uint offset);
209 NVAPI_INTERFACE NvAPI_Initialize ();
210 NVAPI_INTERFACE NvAPI_Unload ();
211 NVAPI_INTERFACE NvAPI_GetErrorMessage (NvAPI_Status nr,NvAPI_ShortString szDesc);
212 NVAPI_INTERFACE NvAPI_EnumPhysicalGPUs (NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
213 NVAPI_INTERFACE NvAPI_GPU_GetPerfPoliciesInfo (NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info);
214 NVAPI_INTERFACE NvAPI_GPU_GetPerfPoliciesStatus (NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status);
215 NVAPI_INTERFACE NvAPI_GPU_SetCoolerLevels (NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
216 NVAPI_INTERFACE NvAPI_GPU_RestoreCoolerSettings (NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex);
217
218 /*
219 * End of declarations from nvapi.h and subheaders
220 **/
221
222 typedef NvPhysicalGpuHandle HM_ADAPTER_NVAPI;
223
224 #include <shared.h>
225
226 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
227 #define NVAPI_API_CALL __stdcall
228 #else
229 #define NVAPI_API_CALL
230 #endif
231
232 typedef int *(*NVAPI_API_CALL NVAPI_QUERYINTERFACE) (uint);
233 typedef int (*NVAPI_API_CALL NVAPI_INITIALIZE) (void);
234 typedef int (*NVAPI_API_CALL NVAPI_UNLOAD) (void);
235 typedef int (*NVAPI_API_CALL NVAPI_GETERRORMESSAGE) (NvAPI_Status, NvAPI_ShortString);
236 typedef int (*NVAPI_API_CALL NVAPI_ENUMPHYSICALGPUS) (NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *);
237 typedef int (*NVAPI_API_CALL NVAPI_GPU_GETPERFPOLICIESINFO) (NvPhysicalGpuHandle, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *);
238 typedef int (*NVAPI_API_CALL NVAPI_GPU_GETPERFPOLICIESSTATUS) (NvPhysicalGpuHandle, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *);
239 typedef int (*NVAPI_API_CALL NVAPI_GPU_SETCOOLERLEVELS) (NvPhysicalGpuHandle, NvU32, NV_GPU_COOLER_LEVELS *);
240 typedef int (*NVAPI_API_CALL NVAPI_GPU_RESTORECOOLERSETTINGS) (NvPhysicalGpuHandle, NvU32);
241
242 typedef struct
243 {
244 NVAPI_LIB lib;
245
246 NVAPI_QUERYINTERFACE nvapi_QueryInterface;
247 NVAPI_INITIALIZE NvAPI_Initialize;
248 NVAPI_UNLOAD NvAPI_Unload;
249 NVAPI_GETERRORMESSAGE NvAPI_GetErrorMessage;
250 NVAPI_ENUMPHYSICALGPUS NvAPI_EnumPhysicalGPUs;
251 NVAPI_GPU_GETPERFPOLICIESINFO NvAPI_GPU_GetPerfPoliciesInfo;
252 NVAPI_GPU_GETPERFPOLICIESSTATUS NvAPI_GPU_GetPerfPoliciesStatus;
253 NVAPI_GPU_SETCOOLERLEVELS NvAPI_GPU_SetCoolerLevels;
254 NVAPI_GPU_RESTORECOOLERSETTINGS NvAPI_GPU_RestoreCoolerSettings;
255
256 } hm_nvapi_lib_t;
257
258 #define NVAPI_PTR hm_nvapi_lib_t
259
260 int nvapi_init (NVAPI_PTR *nvapi);
261 void nvapi_close (NVAPI_PTR *nvapi);
262
263 int hm_NvAPI_QueryInterface (NVAPI_PTR *nvapi, uint offset);
264 int hm_NvAPI_Initialize (NVAPI_PTR *nvapi);
265 int hm_NvAPI_Unload (NVAPI_PTR *nvapi);
266 int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status nr, NvAPI_ShortString szDesc);
267 int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
268 int hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info);
269 int hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status);
270 int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
271 int hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex);
272
273 #endif // HAVE_HWMON
274
275 #endif // EXT_NVAPI_H