1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-14 11:48:57 +00:00

update hm_IOKIT_get_fan_speed_current(), get rid of minimum_speed

This commit is contained in:
Gabriele Gristina 2021-06-19 15:23:59 +02:00
parent 4dc20533bd
commit fc77e1b975

View File

@ -141,10 +141,10 @@ int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx)
memset (&val, 0, sizeof (SMCVal_t));
int alarm = -1;
if (hm_IOKIT_SMCReadKey (HM_IOKIT_SMC_SENSOR_GRAPHICS_HOT, &val, iokit->conn) == kIOReturnSuccess)
{
int alarm = -1;
if (val.dataSize > 0)
{
if (strcmp(val.dataType, DATATYPE_UINT8) == 0)
@ -230,44 +230,28 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed)
UInt32Char_t key;
int i, totalFans = 0;
memset (&val, 0, sizeof (SMCVal_t));
if (hm_IOKIT_SMCReadKey ("FNum", &val, iokit->conn) == kIOReturnSuccess)
{
totalFans = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10);
int totalFans = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10);
for (i = 0; i < totalFans; i++)
for (int i = 0; i < totalFans; i++)
{
float actual_speed = 0.0f;
float minimum_speed = 0.0f;
float maximum_speed = 0.0f;
float rpm = 0.0f;
float pct = 0.0f;
memset (&key, 0, sizeof (UInt32Char_t));
sprintf (key, "F%dAc", i);
hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &actual_speed);
if (actual_speed < 0.f) continue;
memset (&key, 0, sizeof (UInt32Char_t));
sprintf(key, "F%dMn", i);
hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &minimum_speed);
if (minimum_speed < 0.f) continue;
memset (&key, 0, sizeof (UInt32Char_t));
sprintf (key, "F%dMx", i);
hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &maximum_speed);
if (maximum_speed < 0.f) continue;
rpm = actual_speed - minimum_speed;
if (rpm < 0.f) rpm = 0.f;
pct = rpm / (maximum_speed - minimum_speed);
pct *= 100.f;
*fan_speed = pct;
*fan_speed = (actual_speed / maximum_speed) * 100.f;
break;
}