"Fossies" - the Fresh Open Source Software Archive

Member "hashcat-6.2.6/src/hwmon.c" (2 Sep 2022, 76179 Bytes) of package /linux/privat/hashcat-6.2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "hwmon.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.2.5_vs_6.2.6.

    1 /**
    2  * Author......: See docs/credits.txt
    3  * License.....: MIT
    4  */
    5 
    6 #include "common.h"
    7 #include "types.h"
    8 #include "memory.h"
    9 #include "event.h"
   10 #include "dynloader.h"
   11 #include "shared.h"
   12 #include "folder.h"
   13 #include "hwmon.h"
   14 
   15 // general functions
   16 
   17 static int get_adapters_num_adl (hashcat_ctx_t *hashcat_ctx, int *iNumberAdapters)
   18 {
   19   if (hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx, iNumberAdapters) == -1) return -1;
   20 
   21   if (iNumberAdapters == NULL)
   22   {
   23     event_log_error (hashcat_ctx, "No ADL adapters found.");
   24 
   25     return -1;
   26   }
   27 
   28   return 0;
   29 }
   30 
   31 static int hm_get_adapter_index_nvapi (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVAPI *nvapiGPUHandle)
   32 {
   33   NvU32 pGpuCount;
   34 
   35   if (hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx, nvapiGPUHandle, &pGpuCount) == -1) return 0;
   36 
   37   if (pGpuCount == 0)
   38   {
   39     event_log_error (hashcat_ctx, "No NvAPI adapters found.");
   40 
   41     return 0;
   42   }
   43 
   44   return (pGpuCount);
   45 }
   46 
   47 static int hm_get_adapter_index_nvml (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVML *nvmlGPUHandle)
   48 {
   49   unsigned int deviceCount = 0;
   50 
   51   hm_NVML_nvmlDeviceGetCount (hashcat_ctx, &deviceCount);
   52 
   53   if (deviceCount == 0)
   54   {
   55     event_log_error (hashcat_ctx, "No NVML adapters found.");
   56 
   57     return 0;
   58   }
   59 
   60   for (u32 i = 0; i < deviceCount; i++)
   61   {
   62     if (hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx, i, &nvmlGPUHandle[i]) == -1) break;
   63 
   64     // can be used to determine if the device by index matches the cuda device by index
   65     // char name[100]; memset (name, 0, sizeof (name));
   66     // hm_NVML_nvmlDeviceGetName (hashcat_ctx, nvGPUHandle[i], name, sizeof (name) - 1);
   67   }
   68 
   69   return (deviceCount);
   70 }
   71 
   72 int hm_get_threshold_slowdown_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
   73 {
   74   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
   75   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
   76 
   77   if (hwmon_ctx->enabled == false) return -1;
   78 
   79   if (hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported == false) return -1;
   80 
   81   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
   82   {
   83     if (hwmon_ctx->hm_nvml)
   84     {
   85       int target = 0;
   86 
   87       if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) == -1)
   88       {
   89         hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false;
   90 
   91         return -1;
   92       }
   93 
   94       return target;
   95     }
   96   }
   97 
   98   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
   99   {
  100     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  101     {
  102       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
  103       {
  104         if (hwmon_ctx->hm_adl)
  105         {
  106           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
  107           {
  108 
  109           }
  110           else if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
  111           {
  112 
  113           }
  114         }
  115       }
  116 
  117       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
  118       {
  119         if (hwmon_ctx->hm_nvml)
  120         {
  121           int target = 0;
  122 
  123           if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) == -1)
  124           {
  125             hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false;
  126 
  127             return -1;
  128           }
  129 
  130           return target;
  131         }
  132       }
  133     }
  134   }
  135 
  136   hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false;
  137 
  138   return -1;
  139 }
  140 
  141 int hm_get_threshold_shutdown_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
  142 {
  143   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
  144   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
  145 
  146   if (hwmon_ctx->enabled == false) return -1;
  147 
  148   if (hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported == false) return -1;
  149 
  150   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
  151   {
  152     if (hwmon_ctx->hm_nvml)
  153     {
  154       int target = 0;
  155 
  156       if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) == -1)
  157       {
  158         hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false;
  159 
  160         return -1;
  161       }
  162 
  163       return target;
  164     }
  165   }
  166 
  167   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
  168   {
  169     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  170     {
  171       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
  172       {
  173         if (hwmon_ctx->hm_adl)
  174         {
  175           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
  176           {
  177 
  178           }
  179           else if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
  180           {
  181 
  182           }
  183         }
  184       }
  185 
  186       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
  187       {
  188         if (hwmon_ctx->hm_nvml)
  189         {
  190           int target = 0;
  191 
  192           if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) == -1)
  193           {
  194             hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false;
  195 
  196             return -1;
  197           }
  198 
  199           return target;
  200         }
  201       }
  202     }
  203   }
  204 
  205   hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false;
  206 
  207   return -1;
  208 }
  209 
  210 int hm_get_temperature_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
  211 {
  212   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
  213   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
  214 
  215   if (hwmon_ctx->enabled == false) return -1;
  216 
  217   if (hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported == false) return -1;
  218 
  219   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
  220   {
  221     if (hwmon_ctx->hm_nvml)
  222     {
  223       int temperature = 0;
  224 
  225       if (hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) == -1)
  226       {
  227         hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  228 
  229         return -1;
  230       }
  231 
  232       return temperature;
  233     }
  234   }
  235 
  236   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
  237   {
  238     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_CPU)
  239     {
  240       #if defined (__APPLE__)
  241       if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE)
  242       {
  243         if (hwmon_ctx->hm_iokit)
  244         {
  245           double temperature = 0.0;
  246 
  247           char *key = HM_IOKIT_SMC_CPU_PROXIMITY;
  248 
  249           if (hm_IOKIT_SMCGetTemperature (hashcat_ctx, key, &temperature) == -1)
  250           {
  251             hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  252 
  253             return -1;
  254           }
  255 
  256           return (int) temperature;
  257         }
  258       }
  259       #endif
  260 
  261       if (hwmon_ctx->hm_sysfs_cpu)
  262       {
  263         int temperature = 0;
  264 
  265         if (hm_SYSFS_CPU_get_temperature_current (hashcat_ctx, &temperature) == -1)
  266         {
  267           hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  268 
  269           return -1;
  270         }
  271 
  272         return temperature;
  273       }
  274     }
  275 
  276     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  277     {
  278       #if defined (__APPLE__)
  279       if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE)
  280       {
  281         if (hwmon_ctx->hm_iokit)
  282         {
  283           double temperature = 0.0;
  284 
  285           char *key = HM_IOKIT_SMC_GPU_PROXIMITY;
  286 
  287           if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_INTEL_BEIGNET)
  288           {
  289             key = HM_IOKIT_SMC_PECI_GPU;
  290           }
  291 
  292           if (hm_IOKIT_SMCGetTemperature (hashcat_ctx, key, &temperature) == -1)
  293           {
  294             hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  295 
  296             return -1;
  297           }
  298 
  299           return (int) temperature;
  300         }
  301       }
  302       #endif
  303 
  304       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
  305       {
  306         if (hwmon_ctx->hm_adl)
  307         {
  308           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
  309           {
  310             ADLTemperature Temperature;
  311 
  312             Temperature.iSize = sizeof (ADLTemperature);
  313 
  314             if (hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &Temperature) == -1)
  315             {
  316               hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  317 
  318               return -1;
  319             }
  320 
  321             return Temperature.iTemperature / 1000;
  322           }
  323 
  324           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
  325           {
  326             int Temperature = 0;
  327 
  328             if (hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &Temperature) == -1)
  329             {
  330               hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  331 
  332               return -1;
  333             }
  334 
  335             return Temperature / 1000;
  336           }
  337 
  338           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
  339           {
  340             ADLPMLogDataOutput odlpDataOutput;
  341 
  342             memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
  343 
  344             if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
  345             {
  346               hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  347 
  348               return -1;
  349             }
  350 
  351             return odlpDataOutput.sensors[PMLOG_TEMPERATURE_EDGE].value;
  352           }
  353         }
  354 
  355         if (hwmon_ctx->hm_sysfs_amdgpu)
  356         {
  357           int temperature = 0;
  358 
  359           if (hm_SYSFS_AMDGPU_get_temperature_current (hashcat_ctx, backend_device_idx, &temperature) == -1)
  360           {
  361             hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  362 
  363             return -1;
  364           }
  365 
  366           return temperature;
  367         }
  368       }
  369 
  370       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
  371       {
  372         if (hwmon_ctx->hm_nvml)
  373         {
  374           int temperature = 0;
  375 
  376           if (hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) == -1)
  377           {
  378             hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  379 
  380             return -1;
  381           }
  382 
  383           return temperature;
  384         }
  385       }
  386     }
  387   }
  388 
  389   hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
  390 
  391   return -1;
  392 }
  393 
  394 int hm_get_fanpolicy_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
  395 {
  396   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
  397   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
  398 
  399   if (hwmon_ctx->enabled == false) return -1;
  400 
  401   if (hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported == false) return -1;
  402 
  403   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
  404   {
  405     return 1;
  406   }
  407 
  408   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
  409   {
  410     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  411     {
  412       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
  413       {
  414         if (hwmon_ctx->hm_adl)
  415         {
  416           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
  417           {
  418             ADLFanSpeedValue lpFanSpeedValue;
  419 
  420             memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
  421 
  422             lpFanSpeedValue.iSize      = sizeof (lpFanSpeedValue);
  423             lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
  424 
  425             if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &lpFanSpeedValue) == -1)
  426             {
  427               hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false;
  428               hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported  = false;
  429 
  430               return -1;
  431             }
  432 
  433             return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1;
  434           }
  435 
  436           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
  437           {
  438             ADLOD6FanSpeedInfo lpFanSpeedInfo;
  439 
  440             memset (&lpFanSpeedInfo, 0, sizeof (lpFanSpeedInfo));
  441 
  442             if (hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &lpFanSpeedInfo) == -1)
  443             {
  444               hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false;
  445               hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported  = false;
  446 
  447               return -1;
  448             }
  449 
  450             return 1;
  451           }
  452 
  453           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
  454           {
  455             ADLPMLogDataOutput odlpDataOutput;
  456 
  457             memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
  458 
  459             if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
  460             {
  461               hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false;
  462               hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported  = false;
  463 
  464               return -1;
  465             }
  466 
  467             return odlpDataOutput.sensors[PMLOG_FAN_PERCENTAGE].supported;
  468           }
  469         }
  470 
  471         if (hwmon_ctx->hm_sysfs_amdgpu)
  472         {
  473           return 1;
  474         }
  475       }
  476 
  477       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
  478       {
  479         return 1;
  480       }
  481     }
  482   }
  483 
  484   hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false;
  485   hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported  = false;
  486 
  487   return -1;
  488 }
  489 
  490 #if defined(__APPLE__)
  491 int hm_get_fanspeed_apple (hashcat_ctx_t *hashcat_ctx, char *fan_speed_buf)
  492 {
  493   hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
  494 
  495   if (hwmon_ctx->enabled == false) return -1;
  496 
  497   if (hwmon_ctx->hm_iokit)
  498   {
  499     if (hm_IOKIT_get_fan_speed_current (hashcat_ctx, fan_speed_buf) == 0)
  500     {
  501       return 1;
  502     }
  503   }
  504 
  505   return -1;
  506 }
  507 #endif
  508 
  509 int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
  510 {
  511   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
  512   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
  513 
  514   if (hwmon_ctx->enabled == false) return -1;
  515 
  516   if (hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported == false) return -1;
  517 
  518   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
  519   {
  520     if (hwmon_ctx->hm_nvml)
  521     {
  522       int speed = 0;
  523 
  524       if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, (u32 *) &speed) == -1)
  525       {
  526         hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
  527 
  528         return -1;
  529       }
  530 
  531       return speed;
  532     }
  533   }
  534 
  535   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
  536   {
  537     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  538     {
  539       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
  540       {
  541         if (hwmon_ctx->hm_adl)
  542         {
  543           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
  544           {
  545             ADLFanSpeedValue lpFanSpeedValue;
  546 
  547             memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
  548 
  549             lpFanSpeedValue.iSize      = sizeof (lpFanSpeedValue);
  550             lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
  551             lpFanSpeedValue.iFlags     = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
  552 
  553             if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &lpFanSpeedValue) == -1)
  554             {
  555               hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
  556 
  557               return -1;
  558             }
  559 
  560             return lpFanSpeedValue.iFanSpeed;
  561           }
  562 
  563           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
  564           {
  565             ADLOD6FanSpeedInfo faninfo;
  566 
  567             memset (&faninfo, 0, sizeof (faninfo));
  568 
  569             if (hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &faninfo) == -1)
  570             {
  571               hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
  572 
  573               return -1;
  574             }
  575 
  576             return faninfo.iFanSpeedPercent;
  577           }
  578 
  579           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
  580           {
  581             ADLPMLogDataOutput odlpDataOutput;
  582 
  583             memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
  584 
  585             if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
  586             {
  587               hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
  588 
  589               return -1;
  590             }
  591 
  592             return odlpDataOutput.sensors[PMLOG_FAN_PERCENTAGE].value;
  593           }
  594         }
  595 
  596         if (hwmon_ctx->hm_sysfs_amdgpu)
  597         {
  598           int speed = 0;
  599 
  600           if (hm_SYSFS_AMDGPU_get_fan_speed_current (hashcat_ctx, backend_device_idx, &speed) == -1)
  601           {
  602             hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
  603 
  604             return -1;
  605           }
  606 
  607           return speed;
  608         }
  609       }
  610 
  611       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
  612       {
  613         if (hwmon_ctx->hm_nvml)
  614         {
  615           int speed = 0;
  616 
  617           if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, (u32 *) &speed) == -1)
  618           {
  619             hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
  620 
  621             return -1;
  622           }
  623 
  624           return speed;
  625         }
  626       }
  627     }
  628   }
  629 
  630   hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
  631 
  632   return -1;
  633 }
  634 
  635 int hm_get_buslanes_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
  636 {
  637   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
  638   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
  639 
  640   if (hwmon_ctx->enabled == false) return -1;
  641 
  642   if (hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported == false) return -1;
  643 
  644   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
  645   {
  646     if (hwmon_ctx->hm_nvml)
  647     {
  648       unsigned int currLinkWidth;
  649 
  650       if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &currLinkWidth) == -1)
  651       {
  652         hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
  653 
  654         return -1;
  655       }
  656 
  657       return currLinkWidth;
  658     }
  659   }
  660 
  661   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
  662   {
  663     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  664     {
  665       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
  666       {
  667         if (hwmon_ctx->hm_adl)
  668         {
  669           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
  670           {
  671             ADLPMActivity PMActivity;
  672 
  673             PMActivity.iSize = sizeof (ADLPMActivity);
  674 
  675             if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1)
  676             {
  677               hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
  678 
  679               return -1;
  680             }
  681 
  682             return PMActivity.iCurrentBusLanes;
  683           }
  684 
  685           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
  686           {
  687             ADLPMLogDataOutput odlpDataOutput;
  688 
  689             memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
  690 
  691             if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
  692             {
  693               hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
  694 
  695               return -1;
  696             }
  697 
  698             return odlpDataOutput.sensors[PMLOG_BUS_LANES].value;
  699           }
  700         }
  701 
  702         if (hwmon_ctx->hm_sysfs_amdgpu)
  703         {
  704           int lanes;
  705 
  706           if (hm_SYSFS_AMDGPU_get_pp_dpm_pcie (hashcat_ctx, backend_device_idx, &lanes) == -1)
  707           {
  708             hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
  709 
  710             return -1;
  711           }
  712 
  713           return lanes;
  714         }
  715       }
  716 
  717       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
  718       {
  719         if (hwmon_ctx->hm_nvml)
  720         {
  721           unsigned int currLinkWidth;
  722 
  723           if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &currLinkWidth) == -1)
  724           {
  725             hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
  726 
  727             return -1;
  728           }
  729 
  730           return currLinkWidth;
  731         }
  732       }
  733     }
  734   }
  735 
  736   hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
  737 
  738   return -1;
  739 }
  740 
  741 int hm_get_utilization_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
  742 {
  743   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
  744   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
  745 
  746   if (hwmon_ctx->enabled == false) return -1;
  747 
  748   if (hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported == false) return -1;
  749 
  750   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
  751   {
  752     if (hwmon_ctx->hm_nvml)
  753     {
  754       nvmlUtilization_t utilization;
  755 
  756       if (hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &utilization) == -1)
  757       {
  758         hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
  759 
  760         return -1;
  761       }
  762 
  763       return utilization.gpu;
  764     }
  765   }
  766 
  767   #if defined(__APPLE__)
  768   if (backend_ctx->devices_param[backend_device_idx].is_metal == true || backend_ctx->devices_param[backend_device_idx].is_opencl == true)
  769   {
  770     if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE)
  771     {
  772       if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  773       {
  774         if (hwmon_ctx->hm_iokit)
  775         {
  776           int utilization = 0;
  777 
  778           if (hm_IOKIT_get_utilization_current (hashcat_ctx, &utilization) == -1)
  779           {
  780             hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
  781 
  782             return -1;
  783           }
  784 
  785           return utilization;
  786         }
  787       }
  788     }
  789   }
  790   #endif
  791 
  792   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
  793   {
  794     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  795     {
  796       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
  797       {
  798         if (hwmon_ctx->hm_adl)
  799         {
  800           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
  801           {
  802             ADLPMActivity PMActivity;
  803 
  804             PMActivity.iSize = sizeof (ADLPMActivity);
  805 
  806             if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1)
  807             {
  808               hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
  809 
  810               return -1;
  811             }
  812 
  813             return PMActivity.iActivityPercent;
  814           }
  815 
  816           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
  817           {
  818             ADLPMLogDataOutput odlpDataOutput;
  819 
  820             memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
  821 
  822             if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
  823             {
  824               hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
  825 
  826               return -1;
  827             }
  828 
  829             return odlpDataOutput.sensors[PMLOG_INFO_ACTIVITY_GFX].value;
  830           }
  831         }
  832 
  833         if (hwmon_ctx->hm_sysfs_amdgpu)
  834         {
  835           int util;
  836 
  837           if (hm_SYSFS_AMDGPU_get_gpu_busy_percent (hashcat_ctx, backend_device_idx, &util) == -1)
  838           {
  839             hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
  840 
  841             return -1;
  842           }
  843 
  844           return util;
  845         }
  846       }
  847 
  848       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
  849       {
  850         if (hwmon_ctx->hm_nvml)
  851         {
  852           nvmlUtilization_t utilization;
  853 
  854           if (hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &utilization) == -1)
  855           {
  856             hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
  857 
  858             return -1;
  859           }
  860 
  861           return utilization.gpu;
  862         }
  863       }
  864     }
  865 
  866     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_CPU)
  867     {
  868       if (hwmon_ctx->hm_sysfs_cpu)
  869       {
  870         int utilization = 0;
  871 
  872         if (hm_SYSFS_CPU_get_utilization_current (hashcat_ctx, &utilization) == -1)
  873         {
  874           hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
  875 
  876           return -1;
  877         }
  878 
  879         return utilization;
  880       }
  881     }
  882   }
  883 
  884   hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
  885 
  886   return -1;
  887 }
  888 
  889 int hm_get_memoryspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
  890 {
  891   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
  892   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
  893 
  894   if (hwmon_ctx->enabled == false) return -1;
  895 
  896   if (hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported == false) return -1;
  897 
  898   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
  899   {
  900     if (hwmon_ctx->hm_nvml)
  901     {
  902       unsigned int clockfreq;
  903 
  904       if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_MEM, &clockfreq) == -1)
  905       {
  906         hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
  907 
  908         return -1;
  909       }
  910 
  911       return clockfreq;
  912     }
  913   }
  914 
  915   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
  916   {
  917     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
  918     {
  919       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
  920       {
  921         if (hwmon_ctx->hm_adl)
  922         {
  923           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
  924           {
  925             ADLPMActivity PMActivity;
  926 
  927             PMActivity.iSize = sizeof (ADLPMActivity);
  928 
  929             if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1)
  930             {
  931               hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
  932 
  933               return -1;
  934             }
  935 
  936             return PMActivity.iMemoryClock / 100;
  937           }
  938 
  939           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
  940           {
  941             ADLPMLogDataOutput odlpDataOutput;
  942 
  943             memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
  944 
  945             if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
  946             {
  947               hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
  948 
  949               return -1;
  950             }
  951 
  952             return odlpDataOutput.sensors[PMLOG_CLK_MEMCLK].value;
  953           }
  954         }
  955 
  956         if (hwmon_ctx->hm_sysfs_amdgpu)
  957         {
  958           int clockfreq;
  959 
  960           if (hm_SYSFS_AMDGPU_get_pp_dpm_mclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1)
  961           {
  962             hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
  963 
  964             return -1;
  965           }
  966 
  967           return clockfreq;
  968         }
  969       }
  970 
  971       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
  972       {
  973         if (hwmon_ctx->hm_nvml)
  974         {
  975           unsigned int clockfreq;
  976 
  977           if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_MEM, &clockfreq) == -1)
  978           {
  979             hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
  980 
  981             return -1;
  982           }
  983 
  984           return clockfreq;
  985         }
  986       }
  987     }
  988   }
  989 
  990   hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
  991 
  992   return -1;
  993 }
  994 
  995 int hm_get_corespeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
  996 {
  997   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
  998   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
  999 
 1000   if (hwmon_ctx->enabled == false) return -1;
 1001 
 1002   if (hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported == false) return -1;
 1003 
 1004   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
 1005   {
 1006     if (hwmon_ctx->hm_nvml)
 1007     {
 1008       unsigned int clockfreq;
 1009 
 1010       if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_SM, &clockfreq) == -1)
 1011       {
 1012         hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
 1013 
 1014         return -1;
 1015       }
 1016 
 1017       return clockfreq;
 1018     }
 1019   }
 1020 
 1021   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
 1022   {
 1023     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
 1024     {
 1025       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
 1026       {
 1027         if (hwmon_ctx->hm_adl)
 1028         {
 1029           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
 1030           {
 1031             ADLPMActivity PMActivity;
 1032 
 1033             PMActivity.iSize = sizeof (ADLPMActivity);
 1034 
 1035             if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1)
 1036             {
 1037               hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
 1038 
 1039               return -1;
 1040             }
 1041 
 1042             return PMActivity.iEngineClock / 100;
 1043           }
 1044 
 1045           if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
 1046           {
 1047             ADLPMLogDataOutput odlpDataOutput;
 1048 
 1049             memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
 1050 
 1051             if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
 1052             {
 1053               hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
 1054 
 1055               return -1;
 1056             }
 1057 
 1058             return odlpDataOutput.sensors[PMLOG_CLK_GFXCLK].value;
 1059           }
 1060         }
 1061 
 1062         if (hwmon_ctx->hm_sysfs_amdgpu)
 1063         {
 1064           int clockfreq;
 1065 
 1066           if (hm_SYSFS_AMDGPU_get_pp_dpm_sclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1)
 1067           {
 1068             hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
 1069 
 1070             return -1;
 1071           }
 1072 
 1073           return clockfreq;
 1074         }
 1075       }
 1076 
 1077       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
 1078       {
 1079         if (hwmon_ctx->hm_nvml)
 1080         {
 1081           unsigned int clockfreq;
 1082 
 1083           if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_SM, &clockfreq) == -1)
 1084           {
 1085             hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
 1086 
 1087             return -1;
 1088           }
 1089 
 1090           return clockfreq;
 1091         }
 1092       }
 1093     }
 1094   }
 1095 
 1096   hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
 1097 
 1098   return -1;
 1099 }
 1100 
 1101 int hm_get_throttle_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
 1102 {
 1103   hwmon_ctx_t   *hwmon_ctx   = hashcat_ctx->hwmon_ctx;
 1104   backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
 1105 
 1106   if (hwmon_ctx->enabled == false) return -1;
 1107 
 1108   if (hwmon_ctx->hm_device[backend_device_idx].throttle_get_supported == false) return -1;
 1109 
 1110   if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
 1111   {
 1112     if (hwmon_ctx->hm_nvml)
 1113     {
 1114       /* this is triggered by mask generator, too. therefore useless
 1115       unsigned long long clocksThrottleReasons = 0;
 1116       unsigned long long supportedThrottleReasons = 0;
 1117 
 1118       if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons   (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &clocksThrottleReasons)    == -1) return -1;
 1119       if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &supportedThrottleReasons) == -1) return -1;
 1120 
 1121       clocksThrottleReasons &=  supportedThrottleReasons;
 1122       clocksThrottleReasons &= ~nvmlClocksThrottleReasonGpuIdle;
 1123       clocksThrottleReasons &= ~nvmlClocksThrottleReasonApplicationsClocksSetting;
 1124       clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown;
 1125 
 1126       if (backend_ctx->kernel_power_final)
 1127       {
 1128         clocksThrottleReasons &= ~nvmlClocksThrottleReasonHwSlowdown;
 1129       }
 1130 
 1131       return (clocksThrottleReasons != nvmlClocksThrottleReasonNone);
 1132       */
 1133     }
 1134 
 1135     if (hwmon_ctx->hm_nvapi)
 1136     {
 1137       NV_GPU_PERF_POLICIES_INFO_PARAMS_V1   perfPolicies_info;
 1138       NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status;
 1139 
 1140       memset (&perfPolicies_info,   0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1));
 1141       memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1));
 1142 
 1143       perfPolicies_info.version   = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1);
 1144       perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1);
 1145 
 1146       hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_info);
 1147 
 1148       perfPolicies_status.info_value = perfPolicies_info.info_value;
 1149 
 1150       hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_status);
 1151 
 1152       return perfPolicies_status.throttle & 2;
 1153     }
 1154   }
 1155 
 1156   if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
 1157   {
 1158     if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
 1159     {
 1160       if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
 1161       {
 1162       }
 1163 
 1164       if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
 1165       {
 1166         if (hwmon_ctx->hm_nvml)
 1167         {
 1168           /* this is triggered by mask generator, too. therefore useless
 1169           unsigned long long clocksThrottleReasons = 0;
 1170           unsigned long long supportedThrottleReasons = 0;
 1171 
 1172           if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons   (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &clocksThrottleReasons)    == -1) return -1;
 1173           if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &supportedThrottleReasons) == -1) return -1;
 1174 
 1175           clocksThrottleReasons &=  supportedThrottleReasons;
 1176           clocksThrottleReasons &= ~nvmlClocksThrottleReasonGpuIdle;
 1177           clocksThrottleReasons &= ~nvmlClocksThrottleReasonApplicationsClocksSetting;
 1178           clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown;
 1179 
 1180           if (backend_ctx->kernel_power_final)
 1181           {
 1182             clocksThrottleReasons &= ~nvmlClocksThrottleReasonHwSlowdown;
 1183           }
 1184 
 1185           return (clocksThrottleReasons != nvmlClocksThrottleReasonNone);
 1186           */
 1187         }
 1188 
 1189         if (hwmon_ctx->hm_nvapi)
 1190         {
 1191           NV_GPU_PERF_POLICIES_INFO_PARAMS_V1   perfPolicies_info;
 1192           NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status;
 1193 
 1194           memset (&perfPolicies_info,   0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1));
 1195           memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1));
 1196 
 1197           perfPolicies_info.version   = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1);
 1198           perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1);
 1199 
 1200           hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_info);
 1201 
 1202           perfPolicies_status.info_value = perfPolicies_info.info_value;
 1203 
 1204           hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_status);
 1205 
 1206           return perfPolicies_status.throttle & 2;
 1207         }
 1208       }
 1209     }
 1210   }
 1211 
 1212   hwmon_ctx->hm_device[backend_device_idx].throttle_get_supported = false;
 1213 
 1214   return -1;
 1215 }
 1216 
 1217 int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
 1218 {
 1219   hwmon_ctx_t    *hwmon_ctx    = hashcat_ctx->hwmon_ctx;
 1220   backend_ctx_t  *backend_ctx  = hashcat_ctx->backend_ctx;
 1221   user_options_t *user_options = hashcat_ctx->user_options;
 1222 
 1223   hwmon_ctx->enabled = false;
 1224 
 1225   #if !defined (WITH_HWMON)
 1226   return 0;
 1227   #endif // WITH_HWMON
 1228 
 1229   if (user_options->hash_info     == true) return 0;
 1230   if (user_options->keyspace      == true) return 0;
 1231   if (user_options->left          == true) return 0;
 1232   if (user_options->show          == true) return 0;
 1233   if (user_options->stdout_flag   == true) return 0;
 1234   if (user_options->usage         == true) return 0;
 1235   if (user_options->version       == true) return 0;
 1236   if (user_options->identify      == true) return 0;
 1237   if (user_options->hwmon_disable == true) return 0;
 1238   if (user_options->backend_info   > 0)    return 0;
 1239 
 1240   hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
 1241 
 1242   /**
 1243    * Initialize shared libraries
 1244    */
 1245 
 1246   hm_attrs_t *hm_adapters_adl           = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
 1247   hm_attrs_t *hm_adapters_nvapi         = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
 1248   hm_attrs_t *hm_adapters_nvml          = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
 1249   hm_attrs_t *hm_adapters_sysfs_amdgpu  = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
 1250   hm_attrs_t *hm_adapters_sysfs_cpu     = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
 1251   hm_attrs_t *hm_adapters_iokit         = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
 1252 
 1253   #define FREE_ADAPTERS                \
 1254   do {                                 \
 1255     hcfree (hm_adapters_adl);          \
 1256     hcfree (hm_adapters_nvapi);        \
 1257     hcfree (hm_adapters_nvml);         \
 1258     hcfree (hm_adapters_sysfs_amdgpu); \
 1259     hcfree (hm_adapters_sysfs_cpu);    \
 1260     hcfree (hm_adapters_iokit);        \
 1261   } while (0)
 1262 
 1263   if (backend_ctx->need_nvml == true)
 1264   {
 1265     hwmon_ctx->hm_nvml = (NVML_PTR *) hcmalloc (sizeof (NVML_PTR));
 1266 
 1267     if (nvml_init (hashcat_ctx) == -1)
 1268     {
 1269       hcfree (hwmon_ctx->hm_nvml);
 1270 
 1271       hwmon_ctx->hm_nvml = NULL;
 1272     }
 1273   }
 1274 
 1275   if ((backend_ctx->need_nvapi == true) && (hwmon_ctx->hm_nvml)) // nvapi can't work alone, we need nvml, too
 1276   {
 1277     hwmon_ctx->hm_nvapi = (NVAPI_PTR *) hcmalloc (sizeof (NVAPI_PTR));
 1278 
 1279     if (nvapi_init (hashcat_ctx) == -1)
 1280     {
 1281       hcfree (hwmon_ctx->hm_nvapi);
 1282 
 1283       hwmon_ctx->hm_nvapi = NULL;
 1284     }
 1285   }
 1286 
 1287   if (backend_ctx->need_adl == true)
 1288   {
 1289     hwmon_ctx->hm_adl = (ADL_PTR *) hcmalloc (sizeof (ADL_PTR));
 1290 
 1291     if (adl_init (hashcat_ctx) == -1)
 1292     {
 1293       hcfree (hwmon_ctx->hm_adl);
 1294 
 1295       hwmon_ctx->hm_adl = NULL;
 1296     }
 1297   }
 1298 
 1299   if (backend_ctx->need_sysfs_amdgpu == true)
 1300   {
 1301     hwmon_ctx->hm_sysfs_amdgpu = (SYSFS_AMDGPU_PTR *) hcmalloc (sizeof (SYSFS_AMDGPU_PTR));
 1302 
 1303     if (sysfs_amdgpu_init (hashcat_ctx) == false)
 1304     {
 1305       hcfree (hwmon_ctx->hm_sysfs_amdgpu);
 1306 
 1307       hwmon_ctx->hm_sysfs_amdgpu = NULL;
 1308     }
 1309 
 1310     // also if there's ADL, we don't need sysfs_amdgpu
 1311 
 1312     if (hwmon_ctx->hm_adl)
 1313     {
 1314       hcfree (hwmon_ctx->hm_sysfs_amdgpu);
 1315 
 1316       hwmon_ctx->hm_sysfs_amdgpu = NULL;
 1317     }
 1318   }
 1319 
 1320   if (backend_ctx->need_sysfs_cpu == true)
 1321   {
 1322     hwmon_ctx->hm_sysfs_cpu = (SYSFS_CPU_PTR *) hcmalloc (sizeof (SYSFS_CPU_PTR));
 1323 
 1324     if (sysfs_cpu_init (hashcat_ctx) == false)
 1325     {
 1326       hcfree (hwmon_ctx->hm_sysfs_cpu);
 1327 
 1328       hwmon_ctx->hm_sysfs_cpu = NULL;
 1329     }
 1330   }
 1331 
 1332   #if defined(__APPLE__)
 1333   if (backend_ctx->need_iokit == true)
 1334   {
 1335     hwmon_ctx->hm_iokit = (IOKIT_PTR *) hcmalloc (sizeof (IOKIT_PTR));
 1336 
 1337     if (iokit_init (hashcat_ctx) == false)
 1338     {
 1339       hcfree (hwmon_ctx->hm_iokit);
 1340 
 1341       hwmon_ctx->hm_iokit = NULL;
 1342     }
 1343   }
 1344   #endif
 1345 
 1346   if (hwmon_ctx->hm_nvml)
 1347   {
 1348     if (hm_NVML_nvmlInit (hashcat_ctx) == 0)
 1349     {
 1350       HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVML));
 1351 
 1352       int tmp_in = hm_get_adapter_index_nvml (hashcat_ctx, nvmlGPUHandle);
 1353 
 1354       for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
 1355       {
 1356         hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
 1357 
 1358         if (device_param->skipped == true) continue;
 1359 
 1360         if (device_param->is_cuda == true)
 1361         {
 1362           for (int i = 0; i < tmp_in; i++)
 1363           {
 1364             nvmlPciInfo_t pci;
 1365 
 1366             if (hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci) == -1) continue;
 1367 
 1368             if ((device_param->pcie_bus      == pci.bus)
 1369              && (device_param->pcie_device   == (pci.device >> 3))
 1370              && (device_param->pcie_function == (pci.device & 7)))
 1371             {
 1372               const u32 device_id = device_param->device_id;
 1373 
 1374               hm_adapters_nvml[device_id].nvml = nvmlGPUHandle[i];
 1375 
 1376               hm_adapters_nvml[device_id].buslanes_get_supported            = true;
 1377               hm_adapters_nvml[device_id].corespeed_get_supported           = true;
 1378               hm_adapters_nvml[device_id].fanspeed_get_supported            = true;
 1379               hm_adapters_nvml[device_id].memoryspeed_get_supported         = true;
 1380               hm_adapters_nvml[device_id].temperature_get_supported         = true;
 1381               hm_adapters_nvml[device_id].threshold_shutdown_get_supported  = true;
 1382               hm_adapters_nvml[device_id].threshold_slowdown_get_supported  = true;
 1383               hm_adapters_nvml[device_id].utilization_get_supported         = true;
 1384             }
 1385           }
 1386         }
 1387 
 1388         if (device_param->is_opencl == true)
 1389         {
 1390           if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
 1391 
 1392           if (device_param->opencl_device_vendor_id != VENDOR_ID_NV) continue;
 1393 
 1394           for (int i = 0; i < tmp_in; i++)
 1395           {
 1396             nvmlPciInfo_t pci;
 1397 
 1398             if (hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci) == -1) continue;
 1399 
 1400             if ((device_param->pcie_bus      == pci.bus)
 1401              && (device_param->pcie_device   == (pci.device >> 3))
 1402              && (device_param->pcie_function == (pci.device & 7)))
 1403             {
 1404               const u32 device_id = device_param->device_id;
 1405 
 1406               hm_adapters_nvml[device_id].nvml = nvmlGPUHandle[i];
 1407 
 1408               hm_adapters_nvml[device_id].buslanes_get_supported            = true;
 1409               hm_adapters_nvml[device_id].corespeed_get_supported           = true;
 1410               hm_adapters_nvml[device_id].fanspeed_get_supported            = true;
 1411               hm_adapters_nvml[device_id].memoryspeed_get_supported         = true;
 1412               hm_adapters_nvml[device_id].temperature_get_supported         = true;
 1413               hm_adapters_nvml[device_id].threshold_shutdown_get_supported  = true;
 1414               hm_adapters_nvml[device_id].threshold_slowdown_get_supported  = true;
 1415               hm_adapters_nvml[device_id].utilization_get_supported         = true;
 1416             }
 1417           }
 1418         }
 1419       }
 1420 
 1421       hcfree (nvmlGPUHandle);
 1422     }
 1423   }
 1424 
 1425   if (hwmon_ctx->hm_nvapi)
 1426   {
 1427     if (hm_NvAPI_Initialize (hashcat_ctx) == 0)
 1428     {
 1429       HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (NVAPI_MAX_PHYSICAL_GPUS, sizeof (HM_ADAPTER_NVAPI));
 1430 
 1431       int tmp_in = hm_get_adapter_index_nvapi (hashcat_ctx, nvGPUHandle);
 1432 
 1433       for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
 1434       {
 1435         hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
 1436 
 1437         if (device_param->skipped == true) continue;
 1438 
 1439         if (device_param->is_cuda == true)
 1440         {
 1441           for (int i = 0; i < tmp_in; i++)
 1442           {
 1443             NvU32 BusId     = 0;
 1444             NvU32 BusSlotId = 0;
 1445 
 1446             if (hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId) == -1) continue;
 1447 
 1448             if (hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId) == -1) continue;
 1449 
 1450             if ((device_param->pcie_bus      == BusId)
 1451              && (device_param->pcie_device   == (BusSlotId >> 3))
 1452              && (device_param->pcie_function == (BusSlotId & 7)))
 1453             {
 1454               const u32 device_id = device_param->device_id;
 1455 
 1456               hm_adapters_nvapi[device_id].nvapi = nvGPUHandle[i];
 1457 
 1458               hm_adapters_nvapi[device_id].fanpolicy_get_supported  = true;
 1459               hm_adapters_nvapi[device_id].throttle_get_supported   = true;
 1460             }
 1461           }
 1462         }
 1463 
 1464         if (device_param->is_opencl == true)
 1465         {
 1466           if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
 1467 
 1468           if (device_param->opencl_device_vendor_id != VENDOR_ID_NV) continue;
 1469 
 1470           for (int i = 0; i < tmp_in; i++)
 1471           {
 1472             NvU32 BusId     = 0;
 1473             NvU32 BusSlotId = 0;
 1474 
 1475             if (hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId) == -1) continue;
 1476 
 1477             if (hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId) == -1) continue;
 1478 
 1479             if ((device_param->pcie_bus      == BusId)
 1480              && (device_param->pcie_device   == (BusSlotId >> 3))
 1481              && (device_param->pcie_function == (BusSlotId & 7)))
 1482             {
 1483               const u32 device_id = device_param->device_id;
 1484 
 1485               hm_adapters_nvapi[device_id].nvapi = nvGPUHandle[i];
 1486 
 1487               hm_adapters_nvapi[device_id].fanpolicy_get_supported  = true;
 1488               hm_adapters_nvapi[device_id].throttle_get_supported   = true;
 1489             }
 1490           }
 1491         }
 1492       }
 1493 
 1494       hcfree (nvGPUHandle);
 1495     }
 1496   }
 1497 
 1498   if (hwmon_ctx->hm_adl)
 1499   {
 1500     if (hm_ADL_Main_Control_Create (hashcat_ctx, ADL_Main_Memory_Alloc, 0) == 0)
 1501     {
 1502       // total number of adapters
 1503 
 1504       int tmp_in;
 1505 
 1506       if (get_adapters_num_adl (hashcat_ctx, &tmp_in) == -1)
 1507       {
 1508         FREE_ADAPTERS;
 1509 
 1510         return -1;
 1511       }
 1512 
 1513       // adapter info
 1514 
 1515       LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hccalloc (tmp_in, sizeof (AdapterInfo));
 1516 
 1517       if (hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, tmp_in * sizeof (AdapterInfo)) == -1)
 1518       {
 1519         FREE_ADAPTERS;
 1520 
 1521         return -1;
 1522       }
 1523 
 1524       for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
 1525       {
 1526         hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
 1527 
 1528         if (device_param->skipped == true) continue;
 1529 
 1530         if (device_param->is_cuda == true)
 1531         {
 1532           // nothing to do
 1533         }
 1534 
 1535         if ((device_param->is_opencl == true) || (device_param->is_hip == true))
 1536         {
 1537           if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
 1538 
 1539           if ((device_param->opencl_device_vendor_id != VENDOR_ID_AMD) && (device_param->opencl_device_vendor_id != VENDOR_ID_AMD_USE_HIP)) continue;
 1540 
 1541           for (int i = 0; i < tmp_in; i++)
 1542           {
 1543             if ((device_param->pcie_bus      == lpAdapterInfo[i].iBusNumber)
 1544              && (device_param->pcie_device   == (lpAdapterInfo[i].iDeviceNumber >> 3))
 1545              && (device_param->pcie_function == (lpAdapterInfo[i].iDeviceNumber & 7)))
 1546             {
 1547               const u32 device_id = device_param->device_id;
 1548 
 1549               int od_supported = 0;
 1550               int od_enabled   = 0;
 1551               int od_version   = 0;
 1552 
 1553               hm_ADL2_Overdrive_Caps (hashcat_ctx, lpAdapterInfo[i].iAdapterIndex, &od_supported, &od_enabled, &od_version);
 1554 
 1555               if (od_version < 8) od_version = 5;
 1556 
 1557               hm_adapters_adl[device_id].od_version = od_version;
 1558 
 1559               hm_adapters_adl[device_id].adl = lpAdapterInfo[i].iAdapterIndex;
 1560 
 1561               hm_adapters_adl[device_id].buslanes_get_supported            = true;
 1562               hm_adapters_adl[device_id].corespeed_get_supported           = true;
 1563               hm_adapters_adl[device_id].fanspeed_get_supported            = true;
 1564               hm_adapters_adl[device_id].fanpolicy_get_supported           = true;
 1565               hm_adapters_adl[device_id].memoryspeed_get_supported         = true;
 1566               hm_adapters_adl[device_id].temperature_get_supported         = true;
 1567               hm_adapters_adl[device_id].threshold_slowdown_get_supported  = true;
 1568               hm_adapters_adl[device_id].utilization_get_supported         = true;
 1569             }
 1570           }
 1571         }
 1572       }
 1573 
 1574       hcfree (lpAdapterInfo);
 1575     }
 1576   }
 1577 
 1578   if (hwmon_ctx->hm_sysfs_amdgpu || hwmon_ctx->hm_iokit)
 1579   {
 1580     if (true)
 1581     {
 1582       for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
 1583       {
 1584         hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
 1585 
 1586         if (device_param->skipped == true) continue;
 1587 
 1588         if (device_param->is_cuda == true)
 1589         {
 1590           // nothing to do
 1591         }
 1592 
 1593         #if defined (__APPLE__)
 1594         if (device_param->is_metal == true)
 1595         {
 1596           const u32 device_id = device_param->device_id;
 1597 
 1598           if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (hwmon_ctx->hm_iokit))
 1599           {
 1600             hm_adapters_iokit[device_id].buslanes_get_supported    = false;
 1601             hm_adapters_iokit[device_id].corespeed_get_supported   = false;
 1602             hm_adapters_iokit[device_id].fanspeed_get_supported    = true;
 1603             hm_adapters_iokit[device_id].fanpolicy_get_supported   = false;
 1604             hm_adapters_iokit[device_id].memoryspeed_get_supported = false;
 1605             hm_adapters_iokit[device_id].temperature_get_supported = true;
 1606             hm_adapters_iokit[device_id].utilization_get_supported = true;
 1607           }
 1608         }
 1609         #endif
 1610 
 1611         if ((device_param->is_opencl == true) || (device_param->is_hip == true))
 1612         {
 1613           const u32 device_id = device_param->device_id;
 1614 
 1615           if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (hwmon_ctx->hm_iokit))
 1616           {
 1617             hm_adapters_iokit[device_id].buslanes_get_supported    = false;
 1618             hm_adapters_iokit[device_id].corespeed_get_supported   = false;
 1619             hm_adapters_iokit[device_id].fanspeed_get_supported    = true;
 1620             hm_adapters_iokit[device_id].fanpolicy_get_supported   = false;
 1621             hm_adapters_iokit[device_id].memoryspeed_get_supported = false;
 1622             hm_adapters_iokit[device_id].temperature_get_supported = true;
 1623             hm_adapters_iokit[device_id].utilization_get_supported = true;
 1624           }
 1625 
 1626           if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
 1627 
 1628           if (hwmon_ctx->hm_sysfs_amdgpu)
 1629           {
 1630             hm_adapters_sysfs_amdgpu[device_id].buslanes_get_supported    = true;
 1631             hm_adapters_sysfs_amdgpu[device_id].corespeed_get_supported   = true;
 1632             hm_adapters_sysfs_amdgpu[device_id].fanspeed_get_supported    = true;
 1633             hm_adapters_sysfs_amdgpu[device_id].fanpolicy_get_supported   = true;
 1634             hm_adapters_sysfs_amdgpu[device_id].memoryspeed_get_supported = true;
 1635             hm_adapters_sysfs_amdgpu[device_id].temperature_get_supported = true;
 1636             hm_adapters_sysfs_amdgpu[device_id].utilization_get_supported = true;
 1637           }
 1638         }
 1639       }
 1640     }
 1641   }
 1642 
 1643   if (hwmon_ctx->hm_sysfs_cpu)
 1644   {
 1645     if (true)
 1646     {
 1647       for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
 1648       {
 1649         hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
 1650 
 1651         if (device_param->skipped == true) continue;
 1652 
 1653         if (device_param->is_cuda == true)
 1654         {
 1655           // nothing to do
 1656         }
 1657 
 1658         if ((device_param->is_opencl == true) || (device_param->is_hip == true))
 1659         {
 1660           const u32 device_id = device_param->device_id;
 1661 
 1662           if ((device_param->opencl_device_type & CL_DEVICE_TYPE_CPU) == 0) continue;
 1663 
 1664           if (hwmon_ctx->hm_sysfs_cpu)
 1665           {
 1666             hm_adapters_sysfs_cpu[device_id].buslanes_get_supported    = false;
 1667             hm_adapters_sysfs_cpu[device_id].corespeed_get_supported   = false;
 1668             hm_adapters_sysfs_cpu[device_id].fanspeed_get_supported    = false;
 1669             hm_adapters_sysfs_cpu[device_id].fanpolicy_get_supported   = false;
 1670             hm_adapters_sysfs_cpu[device_id].memoryspeed_get_supported = false;
 1671             hm_adapters_sysfs_cpu[device_id].temperature_get_supported = true;
 1672             hm_adapters_sysfs_cpu[device_id].utilization_get_supported = true;
 1673           }
 1674         }
 1675       }
 1676     }
 1677   }
 1678 
 1679   #if defined(__APPLE__)
 1680   if (backend_ctx->need_iokit == true)
 1681   {
 1682     hwmon_ctx->hm_iokit = (IOKIT_PTR *) hcmalloc (sizeof (IOKIT_PTR));
 1683 
 1684     if (iokit_init (hashcat_ctx) == false)
 1685     {
 1686       hcfree (hwmon_ctx->hm_iokit);
 1687 
 1688       hwmon_ctx->hm_iokit = NULL;
 1689     }
 1690   }
 1691   #endif
 1692 
 1693   if (hwmon_ctx->hm_adl == NULL && hwmon_ctx->hm_nvml == NULL && hwmon_ctx->hm_sysfs_amdgpu == NULL && hwmon_ctx->hm_sysfs_cpu == NULL && hwmon_ctx->hm_iokit == NULL)
 1694   {
 1695     FREE_ADAPTERS;
 1696 
 1697     return 0;
 1698   }
 1699 
 1700   /**
 1701    * looks like we have some manageable device
 1702    */
 1703 
 1704   hwmon_ctx->enabled = true;
 1705 
 1706   /**
 1707    * HM devices: copy
 1708    */
 1709 
 1710   for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
 1711   {
 1712     hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
 1713 
 1714     if (device_param->skipped == true) continue;
 1715 
 1716     const u32 device_id = device_param->device_id;
 1717 
 1718     hwmon_ctx->hm_device[backend_devices_idx].adl           = 0;
 1719     hwmon_ctx->hm_device[backend_devices_idx].sysfs_amdgpu  = 0;
 1720     hwmon_ctx->hm_device[backend_devices_idx].sysfs_cpu     = 0;
 1721     hwmon_ctx->hm_device[backend_devices_idx].iokit         = 0;
 1722     hwmon_ctx->hm_device[backend_devices_idx].nvapi         = 0;
 1723     hwmon_ctx->hm_device[backend_devices_idx].nvml          = 0;
 1724     hwmon_ctx->hm_device[backend_devices_idx].od_version    = 0;
 1725 
 1726     if (device_param->is_cuda == true)
 1727     {
 1728       hwmon_ctx->hm_device[backend_devices_idx].nvapi       = hm_adapters_nvapi[device_id].nvapi;
 1729       hwmon_ctx->hm_device[backend_devices_idx].nvml        = hm_adapters_nvml[device_id].nvml;
 1730 
 1731       if (hwmon_ctx->hm_nvml)
 1732       {
 1733         hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_nvml[device_id].buslanes_get_supported;
 1734         hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_nvml[device_id].corespeed_get_supported;
 1735         hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_nvml[device_id].fanspeed_get_supported;
 1736         hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_nvml[device_id].fanpolicy_get_supported;
 1737         hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_nvml[device_id].memoryspeed_get_supported;
 1738         hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_nvml[device_id].temperature_get_supported;
 1739         hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_nvml[device_id].threshold_shutdown_get_supported;
 1740         hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_nvml[device_id].threshold_slowdown_get_supported;
 1741         hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_nvml[device_id].throttle_get_supported;
 1742         hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_nvml[device_id].utilization_get_supported;
 1743       }
 1744 
 1745       if (hwmon_ctx->hm_nvapi)
 1746       {
 1747         hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_nvapi[device_id].buslanes_get_supported;
 1748         hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_nvapi[device_id].corespeed_get_supported;
 1749         hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_nvapi[device_id].fanspeed_get_supported;
 1750         hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_nvapi[device_id].fanpolicy_get_supported;
 1751         hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_nvapi[device_id].memoryspeed_get_supported;
 1752         hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_nvapi[device_id].temperature_get_supported;
 1753         hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_nvapi[device_id].threshold_shutdown_get_supported;
 1754         hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_nvapi[device_id].threshold_slowdown_get_supported;
 1755         hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_nvapi[device_id].throttle_get_supported;
 1756         hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_nvapi[device_id].utilization_get_supported;
 1757       }
 1758     }
 1759 
 1760     if (device_param->is_metal == true)
 1761     {
 1762       if (hwmon_ctx->hm_iokit)
 1763       {
 1764         hwmon_ctx->hm_device[backend_devices_idx].iokit                              = hm_adapters_iokit[device_id].iokit;
 1765         hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_iokit[device_id].buslanes_get_supported;
 1766         hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_iokit[device_id].corespeed_get_supported;
 1767         hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_iokit[device_id].fanspeed_get_supported;
 1768         hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_iokit[device_id].fanpolicy_get_supported;
 1769         hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_iokit[device_id].memoryspeed_get_supported;
 1770         hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_iokit[device_id].temperature_get_supported;
 1771         hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_iokit[device_id].threshold_shutdown_get_supported;
 1772         hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_iokit[device_id].threshold_slowdown_get_supported;
 1773         hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_iokit[device_id].throttle_get_supported;
 1774         hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_iokit[device_id].utilization_get_supported;
 1775       }
 1776     }
 1777 
 1778     if ((device_param->is_opencl == true) || (device_param->is_hip == true))
 1779     {
 1780       if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)
 1781       {
 1782         #if defined(__APPLE__)
 1783         if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE)
 1784         {
 1785           if (hwmon_ctx->hm_iokit)
 1786           {
 1787             hwmon_ctx->hm_device[backend_devices_idx].iokit                              = hm_adapters_iokit[device_id].iokit;
 1788             hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_iokit[device_id].buslanes_get_supported;
 1789             hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_iokit[device_id].corespeed_get_supported;
 1790             hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_iokit[device_id].fanspeed_get_supported;
 1791             hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_iokit[device_id].fanpolicy_get_supported;
 1792             hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_iokit[device_id].memoryspeed_get_supported;
 1793             hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_iokit[device_id].temperature_get_supported;
 1794             hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_iokit[device_id].threshold_shutdown_get_supported;
 1795             hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_iokit[device_id].threshold_slowdown_get_supported;
 1796             hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_iokit[device_id].throttle_get_supported;
 1797             hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_iokit[device_id].utilization_get_supported;
 1798           }
 1799         }
 1800         #endif
 1801 
 1802         if (hwmon_ctx->hm_sysfs_cpu)
 1803         {
 1804           hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_sysfs_cpu[device_id].buslanes_get_supported;
 1805           hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_sysfs_cpu[device_id].corespeed_get_supported;
 1806           hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_sysfs_cpu[device_id].fanspeed_get_supported;
 1807           hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_sysfs_cpu[device_id].fanpolicy_get_supported;
 1808           hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_sysfs_cpu[device_id].memoryspeed_get_supported;
 1809           hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_sysfs_cpu[device_id].temperature_get_supported;
 1810           hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_sysfs_cpu[device_id].threshold_shutdown_get_supported;
 1811           hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_sysfs_cpu[device_id].threshold_slowdown_get_supported;
 1812           hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_sysfs_cpu[device_id].throttle_get_supported;
 1813           hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_sysfs_cpu[device_id].utilization_get_supported;
 1814         }
 1815       }
 1816 
 1817       if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)
 1818       {
 1819         #if defined(__APPLE__)
 1820         if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE)
 1821         {
 1822           if (hwmon_ctx->hm_iokit)
 1823           {
 1824             hwmon_ctx->hm_device[backend_devices_idx].iokit                              = hm_adapters_iokit[device_id].iokit;
 1825             hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_iokit[device_id].buslanes_get_supported;
 1826             hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_iokit[device_id].corespeed_get_supported;
 1827             hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_iokit[device_id].fanspeed_get_supported;
 1828             hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_iokit[device_id].fanpolicy_get_supported;
 1829             hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_iokit[device_id].memoryspeed_get_supported;
 1830             hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_iokit[device_id].temperature_get_supported;
 1831             hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_iokit[device_id].threshold_shutdown_get_supported;
 1832             hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_iokit[device_id].threshold_slowdown_get_supported;
 1833             hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_iokit[device_id].throttle_get_supported;
 1834             hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_iokit[device_id].utilization_get_supported;
 1835           }
 1836         }
 1837         #endif
 1838 
 1839         if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) || (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
 1840         {
 1841           hwmon_ctx->hm_device[backend_devices_idx].adl           = hm_adapters_adl[device_id].adl;
 1842           hwmon_ctx->hm_device[backend_devices_idx].sysfs_amdgpu  = hm_adapters_sysfs_amdgpu[device_id].sysfs_amdgpu;
 1843 
 1844           if (hwmon_ctx->hm_adl)
 1845           {
 1846             hwmon_ctx->hm_device[backend_devices_idx].od_version = hm_adapters_adl[device_id].od_version;
 1847 
 1848             hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_adl[device_id].buslanes_get_supported;
 1849             hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_adl[device_id].corespeed_get_supported;
 1850             hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_adl[device_id].fanspeed_get_supported;
 1851             hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_adl[device_id].fanpolicy_get_supported;
 1852             hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_adl[device_id].memoryspeed_get_supported;
 1853             hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_adl[device_id].temperature_get_supported;
 1854             hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_adl[device_id].threshold_shutdown_get_supported;
 1855             hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_adl[device_id].threshold_slowdown_get_supported;
 1856             hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_adl[device_id].throttle_get_supported;
 1857             hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_adl[device_id].utilization_get_supported;
 1858           }
 1859 
 1860           if (hwmon_ctx->hm_sysfs_amdgpu)
 1861           {
 1862             hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_sysfs_amdgpu[device_id].buslanes_get_supported;
 1863             hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_sysfs_amdgpu[device_id].corespeed_get_supported;
 1864             hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_sysfs_amdgpu[device_id].fanspeed_get_supported;
 1865             hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_sysfs_amdgpu[device_id].fanpolicy_get_supported;
 1866             hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_sysfs_amdgpu[device_id].memoryspeed_get_supported;
 1867             hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_sysfs_amdgpu[device_id].temperature_get_supported;
 1868             hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_sysfs_amdgpu[device_id].threshold_shutdown_get_supported;
 1869             hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_sysfs_amdgpu[device_id].threshold_slowdown_get_supported;
 1870             hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_sysfs_amdgpu[device_id].throttle_get_supported;
 1871             hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_sysfs_amdgpu[device_id].utilization_get_supported;
 1872           }
 1873         }
 1874 
 1875         if (device_param->opencl_device_vendor_id == VENDOR_ID_NV)
 1876         {
 1877           hwmon_ctx->hm_device[backend_devices_idx].nvapi       = hm_adapters_nvapi[device_id].nvapi;
 1878           hwmon_ctx->hm_device[backend_devices_idx].nvml        = hm_adapters_nvml[device_id].nvml;
 1879 
 1880           if (hwmon_ctx->hm_nvml)
 1881           {
 1882             hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_nvml[device_id].buslanes_get_supported;
 1883             hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_nvml[device_id].corespeed_get_supported;
 1884             hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_nvml[device_id].fanspeed_get_supported;
 1885             hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_nvml[device_id].fanpolicy_get_supported;
 1886             hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_nvml[device_id].memoryspeed_get_supported;
 1887             hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_nvml[device_id].temperature_get_supported;
 1888             hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_nvml[device_id].threshold_shutdown_get_supported;
 1889             hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_nvml[device_id].threshold_slowdown_get_supported;
 1890             hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_nvml[device_id].throttle_get_supported;
 1891             hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_nvml[device_id].utilization_get_supported;
 1892           }
 1893 
 1894           if (hwmon_ctx->hm_nvapi)
 1895           {
 1896             hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported            |= hm_adapters_nvapi[device_id].buslanes_get_supported;
 1897             hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported           |= hm_adapters_nvapi[device_id].corespeed_get_supported;
 1898             hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported            |= hm_adapters_nvapi[device_id].fanspeed_get_supported;
 1899             hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported           |= hm_adapters_nvapi[device_id].fanpolicy_get_supported;
 1900             hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported         |= hm_adapters_nvapi[device_id].memoryspeed_get_supported;
 1901             hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported         |= hm_adapters_nvapi[device_id].temperature_get_supported;
 1902             hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported  |= hm_adapters_nvapi[device_id].threshold_shutdown_get_supported;
 1903             hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported  |= hm_adapters_nvapi[device_id].threshold_slowdown_get_supported;
 1904             hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported            |= hm_adapters_nvapi[device_id].throttle_get_supported;
 1905             hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported         |= hm_adapters_nvapi[device_id].utilization_get_supported;
 1906           }
 1907         }
 1908       }
 1909     }
 1910 
 1911     // by calling the different functions here this will disable them in case they will error out
 1912     // this will also reduce the error itself printed to the user to a single print on startup
 1913 
 1914     hm_get_buslanes_with_devices_idx           (hashcat_ctx, backend_devices_idx);
 1915     hm_get_corespeed_with_devices_idx          (hashcat_ctx, backend_devices_idx);
 1916     hm_get_fanpolicy_with_devices_idx          (hashcat_ctx, backend_devices_idx);
 1917     hm_get_fanspeed_with_devices_idx           (hashcat_ctx, backend_devices_idx);
 1918     hm_get_memoryspeed_with_devices_idx        (hashcat_ctx, backend_devices_idx);
 1919     hm_get_temperature_with_devices_idx        (hashcat_ctx, backend_devices_idx);
 1920     hm_get_threshold_shutdown_with_devices_idx (hashcat_ctx, backend_devices_idx);
 1921     hm_get_threshold_slowdown_with_devices_idx (hashcat_ctx, backend_devices_idx);
 1922     hm_get_throttle_with_devices_idx           (hashcat_ctx, backend_devices_idx);
 1923     hm_get_utilization_with_devices_idx        (hashcat_ctx, backend_devices_idx);
 1924   }
 1925 
 1926   FREE_ADAPTERS;
 1927 
 1928   return 0;
 1929 }
 1930 
 1931 void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
 1932 {
 1933   hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
 1934 
 1935   if (hwmon_ctx->enabled == false) return;
 1936 
 1937   // unload shared libraries
 1938 
 1939   if (hwmon_ctx->hm_nvml)
 1940   {
 1941     hm_NVML_nvmlShutdown (hashcat_ctx);
 1942 
 1943     nvml_close (hashcat_ctx);
 1944   }
 1945 
 1946   if (hwmon_ctx->hm_nvapi)
 1947   {
 1948     hm_NvAPI_Unload (hashcat_ctx);
 1949 
 1950     nvapi_close (hashcat_ctx);
 1951   }
 1952 
 1953   if (hwmon_ctx->hm_adl)
 1954   {
 1955     hm_ADL_Main_Control_Destroy (hashcat_ctx);
 1956 
 1957     adl_close (hashcat_ctx);
 1958   }
 1959 
 1960   if (hwmon_ctx->hm_sysfs_amdgpu)
 1961   {
 1962     sysfs_amdgpu_close (hashcat_ctx);
 1963   }
 1964 
 1965   if (hwmon_ctx->hm_sysfs_cpu)
 1966   {
 1967     sysfs_cpu_close (hashcat_ctx);
 1968   }
 1969 
 1970   #if defined (__APPLE__)
 1971   if (hwmon_ctx->hm_iokit)
 1972   {
 1973     iokit_close (hashcat_ctx);
 1974   }
 1975   #endif
 1976 
 1977   // free memory
 1978 
 1979   hcfree (hwmon_ctx->hm_device);
 1980 
 1981   memset (hwmon_ctx, 0, sizeof (hwmon_ctx_t));
 1982 }