Remove workaround with multiple include folders; Instead use a naive escape function
[hashcat.git] / src / shared.c
index 9c08856..5f99c73 100644 (file)
@@ -83,7 +83,7 @@ u64 byte_swap_64 (const u64 n)
 
 int last_len = 0;
 
-void log_final (FILE *fp, const char *fmt, va_list ap)
+int log_final (FILE *fp, const char *fmt, va_list ap)
 {
   if (last_len)
   {
@@ -110,84 +110,96 @@ void log_final (FILE *fp, const char *fmt, va_list ap)
   fflush (fp);
 
   last_len = len;
+
+  return len;
 }
 
-void log_out_nn (FILE *fp, const char *fmt, ...)
+int log_out_nn (FILE *fp, const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (fp, fmt, ap);
+  const int len = log_final (fp, fmt, ap);
 
   va_end (ap);
+
+  return len;
 }
 
-void log_info_nn (const char *fmt, ...)
+int log_info_nn (const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (stdout, fmt, ap);
+  const int len = log_final (stdout, fmt, ap);
 
   va_end (ap);
+
+  return len;
 }
 
-void log_error_nn (const char *fmt, ...)
+int log_error_nn (const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (stderr, fmt, ap);
+  const int len = log_final (stderr, fmt, ap);
 
   va_end (ap);
+
+  return len;
 }
 
-void log_out (FILE *fp, const char *fmt, ...)
+int log_out (FILE *fp, const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (fp, fmt, ap);
+  const int len = log_final (fp, fmt, ap);
 
   va_end (ap);
 
   fputc ('\n', fp);
 
   last_len = 0;
+
+  return len;
 }
 
-void log_info (const char *fmt, ...)
+int log_info (const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (stdout, fmt, ap);
+  const int len = log_final (stdout, fmt, ap);
 
   va_end (ap);
 
   fputc ('\n', stdout);
 
   last_len = 0;
+
+  return len;
 }
 
-void log_error (const char *fmt, ...)
+int log_error (const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   fputc ('\n', stderr);
   fputc ('\n', stderr);
@@ -196,7 +208,7 @@ void log_error (const char *fmt, ...)
 
   va_start (ap, fmt);
 
-  log_final (stderr, fmt, ap);
+  const int len = log_final (stderr, fmt, ap);
 
   va_end (ap);
 
@@ -204,6 +216,8 @@ void log_error (const char *fmt, ...)
   fputc ('\n', stderr);
 
   last_len = 0;
+
+  return len;
 }
 
 /**
@@ -2639,7 +2653,7 @@ void lock_file (FILE *fp)
   {
     if (errno != EINTR)
     {
-      log_error ("ERROR: failed acquiring write lock: %s", strerror (errno));
+      log_error ("ERROR: Failed acquiring write lock: %s", strerror (errno));
 
       exit (-1);
     }
@@ -2657,7 +2671,7 @@ void unlock_file (FILE *fp)
 }
 #endif // F_SETLKW
 
-#ifdef _WIN
+#ifdef WIN
 void fsync (int fd)
 {
   HANDLE h = (HANDLE) _get_osfhandle (fd);
@@ -2671,53 +2685,8 @@ void fsync (int fd)
  */
 
 #ifdef HAVE_HWMON
-#if defined(_WIN) && defined(HAVE_NVAPI)
-int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
-{
-  NvU32 pGpuCount;
-
-  if (hm_NvAPI_EnumPhysicalGPUs (data.hm_nv, nvGPUHandle, &pGpuCount) != NVAPI_OK) return (0);
-
-  if (pGpuCount == 0)
-  {
-    log_info ("WARN: No NvAPI adapters found");
 
-    return (0);
-  }
-
-  return (pGpuCount);
-}
-#endif // _WIN && HAVE_NVAPI
-
-#if defined(LINUX) && defined(HAVE_NVML)
-int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
-{
-  int pGpuCount = 0;
-
-  for (uint i = 0; i < DEVICES_MAX; i++)
-  {
-    if (hm_NVML_nvmlDeviceGetHandleByIndex (data.hm_nv, 1, i, &nvGPUHandle[i]) != NVML_SUCCESS) break;
-
-    // can be used to determine if the device by index matches the cuda device by index
-    // char name[100]; memset (name, 0, sizeof (name));
-    // hm_NVML_nvmlDeviceGetName (data.hm_nv, nvGPUHandle[i], name, sizeof (name) - 1);
-
-    pGpuCount++;
-  }
-
-  if (pGpuCount == 0)
-  {
-    log_info ("WARN: No NVML adapters found");
-
-    return (0);
-  }
-
-  return (pGpuCount);
-}
-#endif // LINUX && HAVE_NVML
-
-#ifdef HAVE_ADL
-int get_adapters_num_amd (void *adl, int *iNumberAdapters)
+int get_adapters_num_adl (void *adl, int *iNumberAdapters)
 {
   if (hm_ADL_Adapter_NumberOfAdapters_Get ((ADL_PTR *) adl, iNumberAdapters) != ADL_OK) return -1;
 
@@ -2767,7 +2736,7 @@ int hm_show_performance_level (HM_LIB hm_dll, int iAdapterIndex)
 }
 */
 
-LPAdapterInfo hm_get_adapter_info_amd (void *adl, int iNumberAdapters)
+LPAdapterInfo hm_get_adapter_info_adl (void *adl, int iNumberAdapters)
 {
   size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo);
 
@@ -2778,9 +2747,50 @@ LPAdapterInfo hm_get_adapter_info_amd (void *adl, int iNumberAdapters)
   return lpAdapterInfo;
 }
 
+int hm_get_adapter_index_nvapi (HM_ADAPTER_NVAPI nvapiGPUHandle[DEVICES_MAX])
+{
+  NvU32 pGpuCount;
+
+  if (hm_NvAPI_EnumPhysicalGPUs (data.hm_nvapi, nvapiGPUHandle, &pGpuCount) != NVAPI_OK) return (0);
+
+  if (pGpuCount == 0)
+  {
+    log_info ("WARN: No NvAPI adapters found");
+
+    return (0);
+  }
+
+  return (pGpuCount);
+}
+
+int hm_get_adapter_index_nvml (HM_ADAPTER_NVML nvmlGPUHandle[DEVICES_MAX])
+{
+  int pGpuCount = 0;
+
+  for (uint i = 0; i < DEVICES_MAX; i++)
+  {
+    if (hm_NVML_nvmlDeviceGetHandleByIndex (data.hm_nvml, 1, i, &nvmlGPUHandle[i]) != NVML_SUCCESS) break;
+
+    // can be used to determine if the device by index matches the cuda device by index
+    // char name[100]; memset (name, 0, sizeof (name));
+    // hm_NVML_nvmlDeviceGetName (data.hm_nvml, nvGPUHandle[i], name, sizeof (name) - 1);
+
+    pGpuCount++;
+  }
+
+  if (pGpuCount == 0)
+  {
+    log_info ("WARN: No NVML adapters found");
+
+    return (0);
+  }
+
+  return (pGpuCount);
+}
+
 /*
 //
-// does not help at all, since AMD does not assign different bus id, device id when we have multi GPU setups
+// does not help at all, since ADL does not assign different bus id, device id when we have multi GPU setups
 //
 
 int hm_get_opencl_device_index (hm_attrs_t *hm_device, uint num_adl_adapters, int bus_num, int dev_num)
@@ -2969,11 +2979,11 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
       if ((FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ) &&
           (FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE))
       {
-        hm_device[opencl_device_index].fan_supported = 1;
+        hm_device[opencl_device_index].fan_get_supported = 1;
       }
       else
       {
-        hm_device[opencl_device_index].fan_supported = 0;
+        hm_device[opencl_device_index].fan_get_supported = 0;
       }
     }
     else // od_version == 6
@@ -2988,11 +2998,11 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
 
       if (faninfo.iSpeedType & ADL_OD6_FANSPEED_TYPE_PERCENT)
       {
-        hm_device[opencl_device_index].fan_supported = 1;
+        hm_device[opencl_device_index].fan_get_supported = 1;
       }
       else
       {
-        hm_device[opencl_device_index].fan_supported = 0;
+        hm_device[opencl_device_index].fan_get_supported = 0;
       }
     }
   }
@@ -3032,7 +3042,7 @@ int hm_get_overdrive_version (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_d
   return 0;
 }
 
-int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
+int hm_get_adapter_index_adl (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
 {
   for (int i = 0; i < num_adl_adapters; i++)
   {
@@ -3050,21 +3060,88 @@ int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list,
 
     int opencl_device_index = i;
 
-    hm_device[opencl_device_index].adapter_index.amd = info.iAdapterIndex;
+    hm_device[opencl_device_index].adl = info.iAdapterIndex;
   }
 
   return num_adl_adapters;
 }
-#endif // HAVE_ADL
+
+int hm_get_threshold_slowdown_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      if (data.hm_device[device_id].od_version == 5)
+      {
+
+      }
+      else if (data.hm_device[device_id].od_version == 6)
+      {
+        int CurrentValue = 0;
+        int DefaultValue = 0;
+
+        if (hm_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_adl, data.hm_device[device_id].adl, &CurrentValue, &DefaultValue) != ADL_OK) return -1;
+
+        // the return value has never been tested since hm_ADL_Overdrive6_TargetTemperatureData_Get() never worked on any system. expect problems.
+
+        return DefaultValue;
+      }
+    }
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    int target = 0;
+
+    if (hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) != NVML_SUCCESS) return -1;
+
+    return target;
+  }
+
+  return -1;
+}
+
+int hm_get_threshold_shutdown_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      if (data.hm_device[device_id].od_version == 5)
+      {
+
+      }
+      else if (data.hm_device[device_id].od_version == 6)
+      {
+
+      }
+    }
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    int target = 0;
+
+    if (hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) != NVML_SUCCESS) return -1;
+
+    return target;
+  }
+
+  return -1;
+}
 
 int hm_get_temperature_with_device_id (const uint device_id)
 {
   if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-  #ifdef HAVE_ADL
   if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
   {
-    if (data.hm_amd)
+    if (data.hm_adl)
     {
       if (data.hm_device[device_id].od_version == 5)
       {
@@ -3072,7 +3149,7 @@ int hm_get_temperature_with_device_id (const uint device_id)
 
         Temperature.iSize = sizeof (ADLTemperature);
 
-        if (hm_ADL_Overdrive5_Temperature_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &Temperature) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive5_Temperature_Get (data.hm_adl, data.hm_device[device_id].adl, 0, &Temperature) != ADL_OK) return -1;
 
         return Temperature.iTemperature / 1000;
       }
@@ -3080,54 +3157,73 @@ int hm_get_temperature_with_device_id (const uint device_id)
       {
         int Temperature = 0;
 
-        if (hm_ADL_Overdrive6_Temperature_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &Temperature) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive6_Temperature_Get (data.hm_adl, data.hm_device[device_id].adl, &Temperature) != ADL_OK) return -1;
 
         return Temperature / 1000;
       }
     }
   }
-  #endif
 
-  #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
   if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
   {
-    #if defined(LINUX) && defined(HAVE_NVML)
     int temperature = 0;
 
-    hm_NVML_nvmlDeviceGetTemperature (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (uint *) &temperature);
+    if (hm_NVML_nvmlDeviceGetTemperature (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_TEMPERATURE_GPU, (uint *) &temperature) != NVML_SUCCESS) return -1;
 
     return temperature;
-    #endif
+  }
 
-    #if defined(WIN) && defined(HAVE_NVAPI)
-    NV_GPU_THERMAL_SETTINGS pThermalSettings;
+  return -1;
+}
 
-    pThermalSettings.version = NV_GPU_THERMAL_SETTINGS_VER;
-    pThermalSettings.count = NVAPI_MAX_THERMAL_SENSORS_PER_GPU;
-    pThermalSettings.sensor[0].controller = NVAPI_THERMAL_CONTROLLER_UNKNOWN;
-    pThermalSettings.sensor[0].target = NVAPI_THERMAL_TARGET_GPU;
+int hm_get_fanpolicy_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-    if (hm_NvAPI_GPU_GetThermalSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pThermalSettings) != NVAPI_OK) return -1;
+  if (data.hm_device[device_id].fan_get_supported == 1)
+  {
+    if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+    {
+      if (data.hm_adl)
+      {
+        if (data.hm_device[device_id].od_version == 5)
+        {
+          ADLFanSpeedValue lpFanSpeedValue;
+
+          memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
 
-    return pThermalSettings.sensor[0].currentTemp;
-    #endif // WIN && HAVE_NVAPI
+          lpFanSpeedValue.iSize      = sizeof (lpFanSpeedValue);
+          lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
+
+          if (hm_ADL_Overdrive5_FanSpeed_Get (data.hm_adl, data.hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1;
+
+          return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1;
+        }
+        else // od_version == 6
+        {
+          return 1;
+        }
+      }
+    }
+
+    if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+    {
+      return 1;
+    }
   }
-  #endif // HAVE_NVML || HAVE_NVAPI
 
   return -1;
 }
 
 int hm_get_fanspeed_with_device_id (const uint device_id)
 {
-  // we shouldn't really need this extra CL_DEVICE_TYPE_GPU check, because fan_supported should not be set w/ CPUs
   if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-  if (data.hm_device[device_id].fan_supported == 1)
+  if (data.hm_device[device_id].fan_get_supported == 1)
   {
-    #ifdef HAVE_ADL
     if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
     {
-      if (data.hm_amd)
+      if (data.hm_adl)
       {
         if (data.hm_device[device_id].od_version == 5)
         {
@@ -3139,7 +3235,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
           lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
           lpFanSpeedValue.iFlags     = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
 
-          if (hm_ADL_Overdrive5_FanSpeed_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
+          if (hm_ADL_Overdrive5_FanSpeed_Get (data.hm_adl, data.hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1;
 
           return lpFanSpeedValue.iFanSpeed;
         }
@@ -3149,37 +3245,51 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
 
           memset (&faninfo, 0, sizeof (faninfo));
 
-          if (hm_ADL_Overdrive6_FanSpeed_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &faninfo) != ADL_OK) return -1;
+          if (hm_ADL_Overdrive6_FanSpeed_Get (data.hm_adl, data.hm_device[device_id].adl, &faninfo) != ADL_OK) return -1;
 
           return faninfo.iFanSpeedPercent;
         }
       }
     }
-    #endif // HAVE_ADL
 
-    #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
     if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
     {
-      #if defined(LINUX) && defined(HAVE_NVML)
       int speed = 0;
 
-      hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nv, 1, data.hm_device[device_id].adapter_index.nv, (uint *) &speed);
+      if (hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nvml, 0, data.hm_device[device_id].nvml, (uint *) &speed) != NVML_SUCCESS) return -1;
 
       return speed;
-      #endif
+    }
+  }
 
-      #if defined(WIN) && defined(HAVE_NVAPI)
+  return -1;
+}
 
-      NV_GPU_COOLER_SETTINGS pCoolerSettings;
+int hm_get_buslanes_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-      pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS);
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      ADLPMActivity PMActivity;
 
-      hm_NvAPI_GPU_GetCoolerSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pCoolerSettings);
+      PMActivity.iSize = sizeof (ADLPMActivity);
 
-      return pCoolerSettings.Cooler[0].CurrentLevel;
-      #endif
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1;
+
+      return PMActivity.iCurrentBusLanes;
     }
-    #endif // HAVE_NVML || HAVE_NVAPI
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    unsigned int currLinkWidth;
+
+    if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (data.hm_nvml, 1, data.hm_device[device_id].nvml, &currLinkWidth) != NVML_SUCCESS) return -1;
+
+    return currLinkWidth;
   }
 
   return -1;
@@ -3189,54 +3299,124 @@ int hm_get_utilization_with_device_id (const uint device_id)
 {
   if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-  #ifdef HAVE_ADL
   if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
   {
-    if (data.hm_amd)
+    if (data.hm_adl)
     {
       ADLPMActivity PMActivity;
 
       PMActivity.iSize = sizeof (ADLPMActivity);
 
-      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &PMActivity) != ADL_OK) return -1;
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1;
 
       return PMActivity.iActivityPercent;
     }
   }
-  #endif // HAVE_ADL
 
-  #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
   if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
   {
-    #if defined(LINUX) && defined(HAVE_NVML)
     nvmlUtilization_t utilization;
 
-    hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &utilization);
+    if (hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nvml, 1, data.hm_device[device_id].nvml, &utilization) != NVML_SUCCESS) return -1;
 
     return utilization.gpu;
-    #endif
+  }
+
+  return -1;
+}
 
-    #if defined(WIN) && defined(HAVE_NVAPI)
-    NV_GPU_DYNAMIC_PSTATES_INFO_EX pDynamicPstatesInfoEx;
+int hm_get_memoryspeed_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-    pDynamicPstatesInfoEx.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER;
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      ADLPMActivity PMActivity;
 
-    if (hm_NvAPI_GPU_GetDynamicPstatesInfoEx (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &pDynamicPstatesInfoEx) != NVAPI_OK) return -1;
+      PMActivity.iSize = sizeof (ADLPMActivity);
 
-    return pDynamicPstatesInfoEx.utilization[0].percentage;
-    #endif
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1;
+
+      return PMActivity.iMemoryClock / 100;
+    }
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    unsigned int clock;
+
+    if (hm_NVML_nvmlDeviceGetClockInfo (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_CLOCK_MEM, &clock) != NVML_SUCCESS) return -1;
+
+    return clock;
   }
-  #endif // HAVE_NVML || HAVE_NVAPI
 
   return -1;
 }
 
-#ifdef HAVE_ADL
-int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed)
+int hm_get_corespeed_with_device_id (const uint device_id)
 {
-  if (data.hm_device[device_id].fan_supported == 1)
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
   {
-    if (data.hm_amd)
+    if (data.hm_adl)
+    {
+      ADLPMActivity PMActivity;
+
+      PMActivity.iSize = sizeof (ADLPMActivity);
+
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1;
+
+      return PMActivity.iEngineClock / 100;
+    }
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    unsigned int clock;
+
+    if (hm_NVML_nvmlDeviceGetClockInfo (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_CLOCK_SM, &clock) != NVML_SUCCESS) return -1;
+
+    return clock;
+  }
+
+  return -1;
+}
+
+int hm_get_throttle_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    unsigned long long clocksThrottleReasons = 0;
+    unsigned long long supportedThrottleReasons = 0;
+
+    if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons   (data.hm_nvml, 1, data.hm_device[device_id].nvml, &clocksThrottleReasons)    != NVML_SUCCESS) return -1;
+    if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (data.hm_nvml, 1, data.hm_device[device_id].nvml, &supportedThrottleReasons) != NVML_SUCCESS) return -1;
+
+    clocksThrottleReasons &= supportedThrottleReasons;
+
+    clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown;
+
+    return (clocksThrottleReasons > 0);
+  }
+
+  return -1;
+}
+
+int hm_set_fanspeed_with_device_id_adl (const uint device_id, const int fanspeed, const int fanpolicy)
+{
+  if (data.hm_device[device_id].fan_set_supported == 1)
+  {
+    if (data.hm_adl)
     {
       if (data.hm_device[device_id].od_version == 5)
       {
@@ -3246,10 +3426,10 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
 
         lpFanSpeedValue.iSize      = sizeof (lpFanSpeedValue);
         lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
-        lpFanSpeedValue.iFlags     = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
+        lpFanSpeedValue.iFlags     = (fanpolicy == 1) ? ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED : 0;
         lpFanSpeedValue.iFanSpeed  = fanspeed;
 
-        if (hm_ADL_Overdrive5_FanSpeed_Set (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive5_FanSpeed_Set (data.hm_adl, data.hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1;
 
         return 0;
       }
@@ -3262,7 +3442,7 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
         fan_speed_value.iSpeedType = ADL_OD6_FANSPEED_TYPE_PERCENT;
         fan_speed_value.iFanSpeed  = fanspeed;
 
-        if (hm_ADL_Overdrive6_FanSpeed_Set (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &fan_speed_value) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive6_FanSpeed_Set (data.hm_adl, data.hm_device[device_id].adl, &fan_speed_value) != ADL_OK) return -1;
 
         return 0;
       }
@@ -3271,23 +3451,44 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
 
   return -1;
 }
-#endif
-
-// helper function for status display
 
-void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value)
+int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fanspeed, const int fanpolicy)
 {
-  #define VALUE_NOT_AVAILABLE "N/A"
-
-  if (value == -1)
+  if (data.hm_device[device_id].fan_set_supported == 1)
   {
-    snprintf (target_buf, max_buf_size, VALUE_NOT_AVAILABLE);
+    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;
+    }
   }
-  else
+
+  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)
   {
-    snprintf (target_buf, max_buf_size, "%2d%s", value, suffix);
+    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
 
 /**
@@ -3300,7 +3501,7 @@ void mp_css_to_uniq_tbl (uint css_cnt, cs_t *css, uint uniq_tbls[SP_PW_MAX][CHAR
 
   if (css_cnt > SP_PW_MAX)
   {
-    log_error ("ERROR: mask length is too long");
+    log_error ("ERROR: Mask length is too long");
 
     exit (-1);
   }
@@ -3412,7 +3613,7 @@ void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, int mp_
 
         if (in_pos == in_len)
         {
-          log_error ("ERROR: the hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", in_buf);
+          log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", in_buf);
 
           exit (-1);
         }
@@ -3421,7 +3622,7 @@ void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, int mp_
 
         if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
         {
-          log_error ("ERROR: invalid hex character detected in mask %s", in_buf);
+          log_error ("ERROR: Invalid hex character detected in mask %s", in_buf);
 
           exit (-1);
         }
@@ -3504,7 +3705,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
                   break;
         case '?': mp_add_cs_buf (&chr, 1, css, css_pos);
                   break;
-        default:  log_error ("ERROR: syntax error: %s", mask_buf);
+        default:  log_error ("ERROR: Syntax error: %s", mask_buf);
                   exit (-1);
       }
     }
@@ -3518,7 +3719,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
 
         if (mask_pos == mask_len)
         {
-          log_error ("ERROR: the hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
+          log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
 
           exit (-1);
         }
@@ -3529,7 +3730,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
 
         if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
         {
-          log_error ("ERROR: invalid hex character detected in mask %s", mask_buf);
+          log_error ("ERROR: Invalid hex character detected in mask %s", mask_buf);
 
           exit (-1);
         }
@@ -3552,7 +3753,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
 
   if (css_pos == 0)
   {
-    log_error ("ERROR: invalid mask length (0)");
+    log_error ("ERROR: Invalid mask length (0)");
 
     exit (-1);
   }
@@ -3637,7 +3838,7 @@ void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index)
 
     if (len == 0)
     {
-      log_info ("WARNING: charset file corrupted");
+      log_info ("WARNING: Charset file corrupted");
 
       mp_expand (buf, strlen (buf), mp_sys, mp_usr, index, 1);
     }
@@ -3687,7 +3888,7 @@ char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len)
 
         if (mask_pos == mask_len)
         {
-          log_error ("ERROR: the hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
+          log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
 
           exit (-1);
         }
@@ -3698,7 +3899,7 @@ char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len)
 
         if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
         {
-          log_error ("ERROR: invalid hex character detected in mask: %s", mask_buf);
+          log_error ("ERROR: Invalid hex character detected in mask: %s", mask_buf);
 
           exit (-1);
         }
@@ -4287,7 +4488,7 @@ int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t *cpu_se
 
 void set_cpu_affinity (char *cpu_affinity)
 {
-  #ifdef WIN
+  #ifdef _WIN
   DWORD_PTR aff_mask = 0;
   #elif _POSIX
   cpu_set_t cpuset;
@@ -4306,7 +4507,7 @@ void set_cpu_affinity (char *cpu_affinity)
 
       if (cpu_id == 0)
       {
-        #ifdef WIN
+        #ifdef _WIN
         aff_mask = 0;
         #elif _POSIX
         CPU_ZERO (&cpuset);
@@ -4317,12 +4518,12 @@ void set_cpu_affinity (char *cpu_affinity)
 
       if (cpu_id > 32)
       {
-        log_error ("ERROR: invalid cpu_id %u specified", cpu_id);
+        log_error ("ERROR: Invalid cpu_id %u specified", cpu_id);
 
         exit (-1);
       }
 
-      #ifdef WIN
+      #ifdef _WIN
       aff_mask |= 1 << (cpu_id - 1);
       #elif _POSIX
       CPU_SET ((cpu_id - 1), &cpuset);
@@ -4333,7 +4534,7 @@ void set_cpu_affinity (char *cpu_affinity)
     free (devices);
   }
 
-  #ifdef WIN
+  #ifdef _WIN
   SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
   SetThreadAffinityMask (GetCurrentThread (), aff_mask);
   #elif _POSIX
@@ -4556,7 +4757,7 @@ int sort_by_dictstat (const void *s1, const void *s2)
   dictstat_t *d1 = (dictstat_t *) s1;
   dictstat_t *d2 = (dictstat_t *) s2;
 
-  #ifdef LINUX
+  #ifdef _LINUX
   d2->stat.st_atim = d1->stat.st_atim;
   #else
   d2->stat.st_atime = d1->stat.st_atime;
@@ -5238,7 +5439,7 @@ uint setup_opencl_platforms_filter (char *opencl_platforms)
 
       if (platform < 1 || platform > 32)
       {
-        log_error ("ERROR: invalid OpenCL platform %u specified", platform);
+        log_error ("ERROR: Invalid OpenCL platform %u specified", platform);
 
         exit (-1);
       }
@@ -5273,7 +5474,7 @@ u32 setup_devices_filter (char *opencl_devices)
 
       if (device_id < 1 || device_id > 32)
       {
-        log_error ("ERROR: invalid device_id %u specified", device_id);
+        log_error ("ERROR: Invalid device_id %u specified", device_id);
 
         exit (-1);
       }
@@ -5308,7 +5509,7 @@ cl_device_type setup_device_types_filter (char *opencl_device_types)
 
       if (device_type < 1 || device_type > 3)
       {
-        log_error ("ERROR: invalid device_type %u specified", device_type);
+        log_error ("ERROR: Invalid device_type %u specified", device_type);
 
         exit (-1);
       }
@@ -5702,7 +5903,6 @@ char *strhashtype (const uint hash_mode)
     case   141: return ((char *) HT_00141); break;
     case   150: return ((char *) HT_00150); break;
     case   160: return ((char *) HT_00160); break;
-    case   190: return ((char *) HT_00190); break;
     case   200: return ((char *) HT_00200); break;
     case   300: return ((char *) HT_00300); break;
     case   400: return ((char *) HT_00400); break;
@@ -5875,6 +6075,7 @@ char *strhashtype (const uint hash_mode)
     case 13761: return ((char *) HT_13761); break;
     case 13762: return ((char *) HT_13762); break;
     case 13763: return ((char *) HT_13763); break;
+    case 13800: return ((char *) HT_13800); break;
   }
 
   return ((char *) "Unknown");
@@ -8581,6 +8782,30 @@ void ascii_digest (char *out_buf, uint salt_pos, uint digest_pos)
   {
     snprintf (out_buf, len-1, "%s", hashfile);
   }
+  else if (hash_mode == 13800)
+  {
+    win8phone_t *esalts = (win8phone_t *) data.esalts_buf;
+
+    win8phone_t *esalt = &esalts[salt_pos];
+
+    char buf[256 + 1] = { 0 };
+
+    for (int i = 0, j = 0; i < 32; i += 1, j += 8)
+    {
+      sprintf (buf + j, "%08x", esalt->salt_buf[i]);
+    }
+
+    snprintf (out_buf, len-1, "%08x%08x%08x%08x%08x%08x%08x%08x:%s",
+      digest_buf[0],
+      digest_buf[1],
+      digest_buf[2],
+      digest_buf[3],
+      digest_buf[4],
+      digest_buf[5],
+      digest_buf[6],
+      digest_buf[7],
+      buf);
+  }
   else
   {
     if (hash_type == HASH_TYPE_MD4)
@@ -8950,7 +9175,7 @@ void stop_at_checkpoint ()
 
   if (data.restore_disable == 1)
   {
-    log_info ("WARNING: this feature is disabled when --restore-disable was specified");
+    log_info ("WARNING: This feature is disabled when --restore-disable is specified");
 
     return;
   }
@@ -8965,7 +9190,7 @@ void stop_at_checkpoint ()
 
     data.checkpoint_cur_words = get_lowest_words_done ();
 
-    log_info ("Checkpoint enabled: will quit at next Restore Point update");
+    log_info ("Checkpoint enabled: Will quit at next Restore Point update");
   }
   else
   {
@@ -8995,6 +9220,29 @@ void myquit ()
   data.devices_status = STATUS_QUIT;
 }
 
+void naive_escape (const char *cpath_real, char *cpath_escaped)
+{
+  const size_t len = MIN (strlen (cpath_real), 1024);
+
+  for (size_t in = 0, out = 0; in < len; in++, out++)
+  {
+    const u8 c = cpath_real[in];
+
+    if (c == ' ')
+    {
+      #if _WIN
+      cpath_escaped[out] = '^';
+      #else
+      cpath_escaped[out] = '\\';
+      #endif
+
+      out++;
+    }
+
+    cpath_escaped[out] = c;
+  }
+}
+
 void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources)
 {
   FILE *fp = fopen (kernel_file, "rb");
@@ -9071,7 +9319,7 @@ restore_data_t *init_restore (int argc, char **argv)
 
       if (nread != 1)
       {
-        log_error ("ERROR: cannot read %s", data.eff_restore_file);
+        log_error ("ERROR: Cannot read %s", data.eff_restore_file);
 
         exit (-1);
       }
@@ -9107,7 +9355,7 @@ restore_data_t *init_restore (int argc, char **argv)
 
           if (strcmp (argv0_r, pidbin_r) == 0)
           {
-            log_error ("ERROR: already an instance %s running on pid %d", pidbin, rd->pid);
+            log_error ("ERROR: Already an instance %s running on pid %d", pidbin, rd->pid);
 
             exit (-1);
           }
@@ -9130,7 +9378,7 @@ restore_data_t *init_restore (int argc, char **argv)
         {
           if (strcmp (pidbin, pidbin2) == 0)
           {
-            log_error ("ERROR: already an instance %s running on pid %d", pidbin2, rd->pid);
+            log_error ("ERROR: Already an instance %s running on pid %d", pidbin2, rd->pid);
 
             exit (-1);
           }
@@ -9145,7 +9393,7 @@ restore_data_t *init_restore (int argc, char **argv)
 
       if (rd->version_bin < RESTORE_MIN)
       {
-        log_error ("ERROR: cannot use outdated %s. Please remove it.", data.eff_restore_file);
+        log_error ("ERROR: Cannot use outdated %s. Please remove it.", data.eff_restore_file);
 
         exit (-1);
       }
@@ -9181,14 +9429,14 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
 
   if (fp == NULL)
   {
-    log_error ("ERROR: restore file '%s': %s", eff_restore_file, strerror (errno));
+    log_error ("ERROR: Restore file '%s': %s", eff_restore_file, strerror (errno));
 
     exit (-1);
   }
 
   if (fread (rd, sizeof (restore_data_t), 1, fp) != 1)
   {
-    log_error ("ERROR: cannot read %s", eff_restore_file);
+    log_error ("ERROR: Can't read %s", eff_restore_file);
 
     exit (-1);
   }
@@ -9201,7 +9449,7 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
   {
     if (fgets (buf, HCBUFSIZ - 1, fp) == NULL)
     {
-      log_error ("ERROR: cannot read %s", eff_restore_file);
+      log_error ("ERROR: Can't read %s", eff_restore_file);
 
       exit (-1);
     }
@@ -9310,13 +9558,13 @@ void cycle_restore ()
   {
     if (unlink (eff_restore_file))
     {
-      log_info ("WARN: unlink file '%s': %s", eff_restore_file, strerror (errno));
+      log_info ("WARN: Unlink file '%s': %s", eff_restore_file, strerror (errno));
     }
   }
 
   if (rename (new_restore_file, eff_restore_file))
   {
-    log_info ("WARN: rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno));
+    log_info ("WARN: Rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno));
   }
 }
 
@@ -10279,7 +10527,7 @@ int wpa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (salt_len > 36)
   {
-    log_info ("WARNING: the length of the ESSID is too long. The hccap file may be invalid or corrupted");
+    log_info ("WARNING: The ESSID length is too long, the hccap file may be invalid or corrupted");
 
     return (PARSER_SALT_LENGTH);
   }
@@ -11779,21 +12027,6 @@ int sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   return (PARSER_OK);
 }
 
-int sha1linkedin_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
-{
-  if ((input_len < DISPLAY_LEN_MIN_100) || (input_len > DISPLAY_LEN_MAX_100)) return (PARSER_GLOBAL_LENGTH);
-
-  u32 *digest = (u32 *) hash_buf->digest;
-
-  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
-  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
-  digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
-  digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
-  digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
-
-  return (PARSER_OK);
-}
-
 int sha1axcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_13300) || (input_len > DISPLAY_LEN_MAX_13300)) return (PARSER_GLOBAL_LENGTH);
@@ -11802,13 +12035,13 @@ int sha1axcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   u32 *digest = (u32 *) hash_buf->digest;
 
-  input_buf +=14;
+  input_buf += 14;
 
   digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
   digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
   digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
   digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
-  digest[4] = 0x00000000;
+  digest[4] = 0;
 
   return (PARSER_OK);
 }
@@ -11914,7 +12147,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];
 
@@ -18380,7 +18613,7 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (directive_pos, "MD5", 3))
   {
-    log_info ("ERROR: only the MD5 directive is currently supported\n");
+    log_info ("ERROR: Only the MD5 directive is currently supported\n");
 
     myfree (temp_input_buf);
 
@@ -20362,6 +20595,50 @@ int zip2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   return (PARSER_OK);
 }
 
+int win8phone_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  if ((input_len < DISPLAY_LEN_MIN_13800) || (input_len > DISPLAY_LEN_MAX_13800)) return (PARSER_GLOBAL_LENGTH);
+
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  win8phone_t *esalt = hash_buf->esalt;
+
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
+  digest[5] = hex_to_u32 ((const u8 *) &input_buf[40]);
+  digest[6] = hex_to_u32 ((const u8 *) &input_buf[48]);
+  digest[7] = hex_to_u32 ((const u8 *) &input_buf[56]);
+
+  if (input_buf[64] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
+
+  char *salt_buf_ptr = input_buf + 64 + 1;
+
+  u32 *salt_buf = esalt->salt_buf;
+
+  for (int i = 0, j = 0; i < 32; i += 1, j += 8)
+  {
+    salt_buf[i] = hex_to_u32 ((const u8 *) &salt_buf_ptr[j]);
+  }
+
+  salt->salt_buf[0] = salt_buf[0];
+  salt->salt_buf[1] = salt_buf[1];
+  salt->salt_buf[2] = salt_buf[2];
+  salt->salt_buf[3] = salt_buf[3];
+  salt->salt_buf[4] = salt_buf[4];
+  salt->salt_buf[5] = salt_buf[5];
+  salt->salt_buf[6] = salt_buf[6];
+  salt->salt_buf[7] = salt_buf[7];
+
+  salt->salt_len = 64;
+
+  return (PARSER_OK);
+}
+
 /**
  * parallel running threads
  */