mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 08:08:10 +00:00
show all fans in hwmon output
This commit is contained in:
parent
65b41fcb8f
commit
3a6481da4e
@ -18,6 +18,7 @@
|
||||
#define KERNEL_INDEX_SMC 2
|
||||
|
||||
#define DATATYPE_FPE2 "fpe2"
|
||||
#define DATATYPE_FLT "flt "
|
||||
#define DATATYPE_UINT8 "ui8 "
|
||||
#define DATATYPE_UINT16 "ui16"
|
||||
#define DATATYPE_UINT32 "ui32"
|
||||
@ -119,7 +120,7 @@ kern_return_t hm_IOKIT_SMCReadKey (UInt32Char_t key, SMCVal_t *val, io_connect_t
|
||||
int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx);
|
||||
int hm_IOKIT_SMCGetTemperature (void *hashcat_ctx, char *key, double *temp);
|
||||
bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret);
|
||||
int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed);
|
||||
int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf);
|
||||
bool iokit_init (void *hashcat_ctx);
|
||||
bool iokit_close (void *hashcat_ctx);
|
||||
#endif // __APPLE__
|
||||
|
@ -16,6 +16,9 @@ int hm_get_threshold_shutdown_with_devices_idx (hashcat_ctx_t *hashcat_ctx, cons
|
||||
int hm_get_temperature_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx);
|
||||
int hm_get_fanpolicy_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx);
|
||||
int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx);
|
||||
#if defined(__APPLE__)
|
||||
int hm_get_fanspeed_apple (hashcat_ctx_t *hashcat_ctx, char *fan_speed_buf);
|
||||
#endif
|
||||
int hm_get_buslanes_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx);
|
||||
int hm_get_utilization_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx);
|
||||
int hm_get_memoryspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx);
|
||||
|
@ -98,6 +98,9 @@ char *status_get_brain_link_send_bytes_sec_dev (const hashcat_ctx_t *hash
|
||||
char *status_get_brain_rx_all (const hashcat_ctx_t *hashcat_ctx);
|
||||
char *status_get_brain_tx_all (const hashcat_ctx_t *hashcat_ctx);
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
char *status_get_hwmon_fan_dev (const hashcat_ctx_t *hashcat_ctx);
|
||||
#endif
|
||||
char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx);
|
||||
int status_get_corespeed_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx);
|
||||
int status_get_memoryspeed_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx);
|
||||
|
@ -2251,6 +2251,9 @@ typedef struct device_info
|
||||
double exec_msec_dev;
|
||||
char *speed_sec_dev;
|
||||
char *guess_candidates_dev;
|
||||
#if defined(__APPLE__)
|
||||
char *hwmon_fan_dev;
|
||||
#endif
|
||||
char *hwmon_dev;
|
||||
int corespeed_dev;
|
||||
int memoryspeed_dev;
|
||||
|
@ -202,6 +202,13 @@ bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret)
|
||||
{
|
||||
if (val.dataSize > 0)
|
||||
{
|
||||
if (strcmp(val.dataType, DATATYPE_FLT) == 0)
|
||||
{
|
||||
*ret = *(float *) val.bytes;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcmp(val.dataType, DATATYPE_FPE2) == 0)
|
||||
{
|
||||
// convert fpe2 value to RPM
|
||||
@ -218,10 +225,8 @@ bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret)
|
||||
return false;
|
||||
}
|
||||
|
||||
int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed)
|
||||
int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf)
|
||||
{
|
||||
*fan_speed = 0;
|
||||
|
||||
hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx;
|
||||
|
||||
IOKIT_PTR *iokit = hwmon_ctx->hm_iokit;
|
||||
@ -236,8 +241,13 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed)
|
||||
{
|
||||
int totalFans = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10);
|
||||
|
||||
if (totalFans <= 0) return -1;
|
||||
|
||||
char tmp_buf[16];
|
||||
|
||||
for (int i = 0; i < totalFans; i++)
|
||||
{
|
||||
int fan_speed = 0;
|
||||
float actual_speed = 0.0f;
|
||||
float maximum_speed = 0.0f;
|
||||
|
||||
@ -251,10 +261,16 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed)
|
||||
hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &maximum_speed);
|
||||
if (maximum_speed < 0.f) continue;
|
||||
|
||||
*fan_speed = (actual_speed / maximum_speed) * 100.f;
|
||||
fan_speed = (actual_speed / maximum_speed) * 100.f;
|
||||
|
||||
break;
|
||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||
snprintf (tmp_buf, sizeof (tmp_buf) - 1, "Fan%d: %d%%, ", i, fan_speed);
|
||||
strncat (fan_speed_buf, tmp_buf, strlen (tmp_buf));
|
||||
}
|
||||
|
||||
// remove last two bytes
|
||||
size_t out_len = strlen (fan_speed_buf);
|
||||
fan_speed_buf[out_len-2] = '\0';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1806,6 +1806,9 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st
|
||||
device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id);
|
||||
device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id);
|
||||
device_info->guess_candidates_dev = status_get_guess_candidates_dev (hashcat_ctx, device_id);
|
||||
#if defined(__APPLE__)
|
||||
device_info->hwmon_fan_dev = status_get_hwmon_fan_dev (hashcat_ctx);
|
||||
#endif
|
||||
device_info->hwmon_dev = status_get_hwmon_dev (hashcat_ctx, device_id);
|
||||
device_info->corespeed_dev = status_get_corespeed_dev (hashcat_ctx, device_id);
|
||||
device_info->memoryspeed_dev = status_get_memoryspeed_dev (hashcat_ctx, device_id);
|
||||
|
45
src/hwmon.c
45
src/hwmon.c
@ -418,6 +418,25 @@ int hm_get_fanpolicy_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int bac
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
int hm_get_fanspeed_apple (hashcat_ctx_t *hashcat_ctx, char *fan_speed_buf)
|
||||
{
|
||||
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
||||
|
||||
if (hwmon_ctx->enabled == false) return -1;
|
||||
|
||||
if (hwmon_ctx->hm_iokit)
|
||||
{
|
||||
if (hm_IOKIT_get_fan_speed_current (hashcat_ctx, fan_speed_buf) == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
||||
{
|
||||
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
||||
@ -446,26 +465,7 @@ int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back
|
||||
|
||||
if (backend_ctx->devices_param[backend_device_idx].is_opencl == true)
|
||||
{
|
||||
#if defined (__APPLE__)
|
||||
if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE)
|
||||
{
|
||||
if (hwmon_ctx->hm_iokit)
|
||||
{
|
||||
int speed = 0;
|
||||
|
||||
if (hm_IOKIT_get_fan_speed_current (hashcat_ctx, &speed) == -1)
|
||||
{
|
||||
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return speed;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
|
||||
#endif
|
||||
|
||||
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD)
|
||||
{
|
||||
@ -1117,13 +1117,6 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hwmon_ctx->hm_iokit = NULL;
|
||||
}
|
||||
|
||||
if (hwmon_ctx->hm_adl)
|
||||
{
|
||||
hcfree (hwmon_ctx->hm_iokit);
|
||||
|
||||
hwmon_ctx->hm_iokit = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
17
src/status.c
17
src/status.c
@ -1959,6 +1959,23 @@ char *status_get_brain_link_send_bytes_sec_dev (const hashcat_ctx_t *hashcat_ctx
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
char *status_get_hwmon_fan_dev (const hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
char *fanspeed_str = (char *) hcmalloc (HCBUFSIZ_TINY);
|
||||
|
||||
hc_thread_mutex_lock (status_ctx->mux_hwmon);
|
||||
|
||||
hm_get_fanspeed_apple ((hashcat_ctx_t *) hashcat_ctx, fanspeed_str);
|
||||
|
||||
hc_thread_mutex_unlock (status_ctx->mux_hwmon);
|
||||
|
||||
return fanspeed_str;
|
||||
}
|
||||
#endif
|
||||
|
||||
char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx)
|
||||
{
|
||||
const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
||||
|
@ -1781,6 +1781,10 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (hwmon_ctx->enabled == true)
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
bool first_dev = true;
|
||||
#endif
|
||||
|
||||
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
|
||||
{
|
||||
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
|
||||
@ -1791,6 +1795,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (device_info->hwmon_dev == NULL) continue;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
if (first_dev && device_info->hwmon_fan_dev)
|
||||
{
|
||||
event_log_info (hashcat_ctx, "Hardware.Mon.SMC.: %s", device_info->hwmon_fan_dev);
|
||||
first_dev = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
event_log_info (hashcat_ctx,
|
||||
"Hardware.Mon.#%d..: %s", device_id + 1,
|
||||
device_info->hwmon_dev);
|
||||
|
Loading…
Reference in New Issue
Block a user