1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 09:58:16 +00:00

Update hwmon.c function parameters

This commit is contained in:
jsteube 2016-10-06 11:10:00 +02:00
parent 684a28af36
commit f084aaf61b
5 changed files with 93 additions and 52 deletions

View File

@ -6,21 +6,21 @@
#ifndef _HWMON_H
#define _HWMON_H
int hm_get_threshold_slowdown_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_threshold_shutdown_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_temperature_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_fanpolicy_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_fanspeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_buslanes_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_utilization_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_memoryspeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_corespeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_get_throttle_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id);
int hm_set_fanspeed_with_device_id_adl (const hwmon_ctx_t *hwmon_ctx, const u32 device_id, const int fanspeed, const int fanpolicy);
int hm_set_fanspeed_with_device_id_nvapi (const hwmon_ctx_t *hwmon_ctx, const u32 device_id, const int fanspeed, const int fanpolicy);
int hm_set_fanspeed_with_device_id_xnvctrl (const hwmon_ctx_t *hwmon_ctx, const u32 device_id, const int fanspeed);
int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_threshold_shutdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_fanpolicy_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_fanspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_buslanes_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_utilization_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_memoryspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_corespeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id);
int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 device_id, const int fanspeed, const int fanpolicy);
int hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx_t *hashcat_ctx, const u32 device_id, const int fanspeed, const int fanpolicy);
int hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u32 device_id, const int fanspeed);
int hwmon_ctx_init (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options, const opencl_ctx_t *opencl_ctx);
void hwmon_ctx_destroy (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options, const opencl_ctx_t *opencl_ctx);
int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx);
void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _HWMON_H

View File

@ -1250,7 +1250,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
folder_config_t *folder_config = hashcat_ctx->folder_config;
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
induct_ctx_t *induct_ctx = hashcat_ctx->induct_ctx;
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx;
@ -1417,7 +1416,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
* HM devices: init
*/
const int rc_hwmon_init = hwmon_ctx_init (hwmon_ctx, user_options, opencl_ctx);
const int rc_hwmon_init = hwmon_ctx_init (hashcat_ctx);
if (rc_hwmon_init == -1)
{
@ -1527,7 +1526,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
user_options_extra_destroy (user_options_extra);
hwmon_ctx_destroy (hwmon_ctx, user_options, opencl_ctx);
hwmon_ctx_destroy (hashcat_ctx);
opencl_ctx_devices_destroy (opencl_ctx);

View File

@ -312,8 +312,11 @@ static int hm_get_adapter_index_adl (hm_attrs_t *hm_device, u32 *valid_adl_devic
return num_adl_adapters;
}
int hm_get_threshold_slowdown_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -352,8 +355,11 @@ int hm_get_threshold_slowdown_with_device_id (const hwmon_ctx_t *hwmon_ctx, cons
return -1;
}
int hm_get_threshold_shutdown_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_threshold_shutdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -385,8 +391,11 @@ int hm_get_threshold_shutdown_with_device_id (const hwmon_ctx_t *hwmon_ctx, cons
return -1;
}
int hm_get_temperature_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -428,8 +437,11 @@ int hm_get_temperature_with_device_id (const hwmon_ctx_t *hwmon_ctx, const openc
return -1;
}
int hm_get_fanpolicy_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_fanpolicy_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -469,8 +481,11 @@ int hm_get_fanpolicy_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_
return -1;
}
int hm_get_fanspeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_fanspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -521,8 +536,11 @@ int hm_get_fanspeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_c
return -1;
}
int hm_get_buslanes_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_buslanes_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -553,8 +571,11 @@ int hm_get_buslanes_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_c
return -1;
}
int hm_get_utilization_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_utilization_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -585,8 +606,11 @@ int hm_get_utilization_with_device_id (const hwmon_ctx_t *hwmon_ctx, const openc
return -1;
}
int hm_get_memoryspeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_memoryspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -617,8 +641,11 @@ int hm_get_memoryspeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const openc
return -1;
}
int hm_get_corespeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_corespeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -649,8 +676,11 @@ int hm_get_corespeed_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_
return -1;
}
int hm_get_throttle_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_ctx_t *opencl_ctx, const u32 device_id)
int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
@ -684,8 +714,10 @@ int hm_get_throttle_with_device_id (const hwmon_ctx_t *hwmon_ctx, const opencl_c
return -1;
}
int hm_set_fanspeed_with_device_id_adl (const hwmon_ctx_t *hwmon_ctx, const u32 device_id, const int fanspeed, const int fanpolicy)
int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 device_id, const int fanspeed, const int fanpolicy)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == true)
@ -744,8 +776,10 @@ int hm_set_fanspeed_with_device_id_adl (const hwmon_ctx_t *hwmon_ctx, const u32
return -1;
}
int hm_set_fanspeed_with_device_id_nvapi (const hwmon_ctx_t *hwmon_ctx, const u32 device_id, const int fanspeed, const int fanpolicy)
int hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx_t *hashcat_ctx, const u32 device_id, const int fanspeed, const int fanpolicy)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == true)
@ -779,8 +813,10 @@ int hm_set_fanspeed_with_device_id_nvapi (const hwmon_ctx_t *hwmon_ctx, const u3
return -1;
}
int hm_set_fanspeed_with_device_id_xnvctrl (const hwmon_ctx_t *hwmon_ctx, const u32 device_id, const int fanspeed)
int hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u32 device_id, const int fanspeed)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == true)
@ -796,8 +832,12 @@ int hm_set_fanspeed_with_device_id_xnvctrl (const hwmon_ctx_t *hwmon_ctx, const
return -1;
}
int hwmon_ctx_init (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options, const opencl_ctx_t *opencl_ctx)
int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
hwmon_ctx->enabled = false;
if (user_options->keyspace == true) return 0;
@ -1218,8 +1258,8 @@ int hwmon_ctx_init (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options,
if (hwmon_ctx->hm_device[device_id].fan_get_supported == true)
{
const int fanspeed = hm_get_fanspeed_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int fanpolicy = hm_get_fanpolicy_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int fanspeed = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id);
const int fanpolicy = hm_get_fanpolicy_with_device_id (hashcat_ctx, device_id);
// we also set it to tell the OS we take control over the fan and it's automatic controller
// if it was set to automatic. we do not control user-defined fanspeeds.
@ -1232,7 +1272,7 @@ int hwmon_ctx_init (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options,
if (device_param->device_vendor_id == VENDOR_ID_AMD)
{
rc = hm_set_fanspeed_with_device_id_adl (hwmon_ctx, device_id, fanspeed, 1);
rc = hm_set_fanspeed_with_device_id_adl (hashcat_ctx, device_id, fanspeed, 1);
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
@ -1267,8 +1307,12 @@ int hwmon_ctx_init (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options,
return 0;
}
void hwmon_ctx_destroy (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options, const opencl_ctx_t *opencl_ctx)
void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
{
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
if (hwmon_ctx->enabled == false) return;
// reset default fan speed
@ -1287,7 +1331,7 @@ void hwmon_ctx_destroy (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_optio
if (device_param->device_vendor_id == VENDOR_ID_AMD)
{
rc = hm_set_fanspeed_with_device_id_adl (hwmon_ctx, device_id, 100, 0);
rc = hm_set_fanspeed_with_device_id_adl (hashcat_ctx, device_id, 100, 0);
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{

View File

@ -170,7 +170,7 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
const int temperature = hm_get_temperature_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int temperature = hm_get_temperature_with_device_id (hashcat_ctx, device_id);
if (temperature > (int) user_options->gpu_temp_abort)
{
@ -207,7 +207,7 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
if (abs (fan_diff_required) >= temp_threshold)
{
const int fan_speed_cur = hm_get_fanspeed_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int fan_speed_cur = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id);
int fan_speed_level = fan_speed_cur;
@ -227,16 +227,16 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
{
if (device_param->device_vendor_id == VENDOR_ID_AMD)
{
hm_set_fanspeed_with_device_id_adl (hwmon_ctx, device_id, fan_speed_new, 1);
hm_set_fanspeed_with_device_id_adl (hashcat_ctx, device_id, fan_speed_new, 1);
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
#if defined (_WIN)
hm_set_fanspeed_with_device_id_nvapi (hwmon_ctx, device_id, fan_speed_new, 1);
hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, fan_speed_new, 1);
#endif
#if defined (__linux__)
hm_set_fanspeed_with_device_id_xnvctrl (hwmon_ctx, device_id, fan_speed_new);
hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx, device_id, fan_speed_new);
#endif
}

View File

@ -150,7 +150,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
hashes_t *hashes = hashcat_ctx->hashes;
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
@ -297,7 +296,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
if (device_param->skipped) continue;
int temp = hm_get_temperature_with_device_id (hwmon_ctx, opencl_ctx, device_id);
int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id);
fprintf (out, "%d\t", temp);
}
@ -319,7 +318,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
@ -1105,13 +1103,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
if (device_param->skipped) continue;
const int num_temperature = hm_get_temperature_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int num_fanspeed = hm_get_fanspeed_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int num_utilization = hm_get_utilization_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int num_corespeed = hm_get_corespeed_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int num_memoryspeed = hm_get_memoryspeed_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int num_buslanes = hm_get_buslanes_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int num_throttle = hm_get_throttle_with_device_id (hwmon_ctx, opencl_ctx, device_id);
const int num_temperature = hm_get_temperature_with_device_id (hashcat_ctx, device_id);
const int num_fanspeed = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id);
const int num_utilization = hm_get_utilization_with_device_id (hashcat_ctx, device_id);
const int num_corespeed = hm_get_corespeed_with_device_id (hashcat_ctx, device_id);
const int num_memoryspeed = hm_get_memoryspeed_with_device_id (hashcat_ctx, device_id);
const int num_buslanes = hm_get_buslanes_with_device_id (hashcat_ctx, device_id);
const int num_throttle = hm_get_throttle_with_device_id (hashcat_ctx, device_id);
char output_buf[256] = { 0 };