Added --gpu-temp-retain support for windows through nvapi
[hashcat.git] / src / shared.c
index d987c09..5f7f5fb 100644 (file)
@@ -3194,13 +3194,7 @@ int hm_get_fanpolicy_with_device_id (const uint device_id)
 
     if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
     {
-      #if defined(LINUX)
-      return 0;
-      #endif
-
-      #if defined(WIN)
       return 1;
-      #endif
     }
   }
 
@@ -3444,6 +3438,43 @@ int hm_set_fanspeed_with_device_id_adl (const uint device_id, const int fanspeed
   return -1;
 }
 
+int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fanspeed, const int fanpolicy)
+{
+  if (data.hm_device[device_id].fan_set_supported == 1)
+  {
+    if (data.hm_nvapi)
+    {
+      NV_GPU_COOLER_LEVELS CoolerLevels = { 0 };
+
+      CoolerLevels.Version = GPU_COOLER_LEVELS_VER | sizeof (NV_GPU_COOLER_LEVELS);
+
+      CoolerLevels.Levels[0].Level  = fanspeed;
+      CoolerLevels.Levels[0].Policy = fanpolicy;
+
+      if (hm_NvAPI_GPU_SetCoolerLevels (data.hm_nvapi, data.hm_device[device_id].nvapi, 0, &CoolerLevels) != NVAPI_OK) return -1;
+
+      return 0;
+    }
+  }
+
+  return -1;
+}
+
+int hm_set_fanspeed_with_device_id_xnvctrl (const uint device_id, const int fanspeed)
+{
+  if (data.hm_device[device_id].fan_set_supported == 1)
+  {
+    if (data.hm_xnvctrl)
+    {
+      if (set_fan_speed_target (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, fanspeed) != 0) return -1;
+
+      return 0;
+    }
+  }
+
+  return -1;
+}
+
 #endif // HAVE_HWMON
 
 /**
@@ -12095,7 +12126,7 @@ int pstoken_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   pstoken->pc_offset = 0;
 
-  for (int i = 0; i < (int) pstoken->salt_len - 64; i += 64)
+  for (int i = 0; i < (int) pstoken->salt_len - 63; i += 64)
   {
     uint w[16];