* License.....: MIT
*/
-#ifdef OSX
+#ifdef __APPLE__
#include <stdio.h>
#endif
+#ifdef __FreeBSD__
+#include <stdio.h>
+#include <pthread_np.h>
+#endif
+
#include <shared.h>
#include <limits.h>
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)
{
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);
va_start (ap, fmt);
- log_final (stderr, fmt, ap);
+ const int len = log_final (stderr, fmt, ap);
va_end (ap);
fputc ('\n', stderr);
last_len = 0;
+
+ return len;
}
/**
* tty
*/
-#ifdef LINUX
-static struct termio savemodes;
+#ifdef __linux__
+static struct termios savemodes;
static int havemodes = 0;
int tty_break()
{
- struct termio modmodes;
+ struct termios modmodes;
- if (ioctl (fileno (stdin), TCGETA, &savemodes) < 0) return -1;
+ if (tcgetattr (fileno (stdin), &savemodes) < 0) return -1;
havemodes = 1;
modmodes.c_cc[VMIN] = 1;
modmodes.c_cc[VTIME] = 0;
- return ioctl (fileno (stdin), TCSETAW, &modmodes);
+ return tcsetattr (fileno (stdin), TCSANOW, &modmodes);
}
int tty_getchar()
{
if (!havemodes) return 0;
- return ioctl (fileno (stdin), TCSETAW, &savemodes);
+ return tcsetattr (fileno (stdin), TCSADRAIN, &savemodes);
}
#endif
-#ifdef OSX
+#if defined(__APPLE__) || defined(__FreeBSD__)
static struct termios savemodes;
static int havemodes = 0;
{
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);
}
}
#endif // F_SETLKW
-#ifdef _WIN
+#ifdef WIN
void fsync (int fd)
{
HANDLE h = (HANDLE) _get_osfhandle (fd);
{
NvU32 pGpuCount;
- if (hm_NvAPI_EnumPhysicalGPUs (data.hm_nvapi, nvapiGPUHandle, &pGpuCount) != NVAPI_OK) return (0);
+ 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 0;
}
return (pGpuCount);
{
log_info ("WARN: No NVML adapters found");
- return (0);
+ return 0;
}
return (pGpuCount);
int opencl_device_index = i;
- hm_device[opencl_device_index].adapter_index.adl = info.iAdapterIndex;
+ hm_device[opencl_device_index].adl = info.iAdapterIndex;
}
return num_adl_adapters;
int CurrentValue = 0;
int DefaultValue = 0;
- if (hm_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_adl, data.hm_device[device_id].adapter_index.adl, &CurrentValue, &DefaultValue) != ADL_OK) return -1;
+ 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.
{
int target = 0;
- if (hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) != NVML_SUCCESS) return -1;
+ 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;
}
{
int target = 0;
- if (hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) != NVML_SUCCESS) return -1;
+ 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;
}
Temperature.iSize = sizeof (ADLTemperature);
- if (hm_ADL_Overdrive5_Temperature_Get (data.hm_adl, data.hm_device[device_id].adapter_index.adl, 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;
}
{
int Temperature = 0;
- if (hm_ADL_Overdrive6_Temperature_Get (data.hm_adl, data.hm_device[device_id].adapter_index.adl, &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;
}
{
int temperature = 0;
- if (hm_NVML_nvmlDeviceGetTemperature (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, NVML_TEMPERATURE_GPU, (uint *) &temperature) != NVML_SUCCESS) return -1;
+ 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;
}
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].adapter_index.adl, 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 & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1;
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
- #if defined(LINUX)
- return 0;
- #endif
-
- #if defined(WIN)
return 1;
- #endif
}
}
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_adl, data.hm_device[device_id].adapter_index.adl, 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;
}
memset (&faninfo, 0, sizeof (faninfo));
- if (hm_ADL_Overdrive6_FanSpeed_Get (data.hm_adl, data.hm_device[device_id].adapter_index.adl, &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;
}
{
int speed = 0;
- if (hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nvml, 0, data.hm_device[device_id].adapter_index.nvml, (uint *) &speed) != NVML_SUCCESS) return -1;
+ if (hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nvml, 0, data.hm_device[device_id].nvml, (uint *) &speed) != NVML_SUCCESS) return -1;
return speed;
}
PMActivity.iSize = sizeof (ADLPMActivity);
- if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adapter_index.adl, &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.iCurrentBusLanes;
}
{
unsigned int currLinkWidth;
- if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, &currLinkWidth) != NVML_SUCCESS) return -1;
+ if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (data.hm_nvml, 1, data.hm_device[device_id].nvml, &currLinkWidth) != NVML_SUCCESS) return -1;
return currLinkWidth;
}
PMActivity.iSize = sizeof (ADLPMActivity);
- if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adapter_index.adl, &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;
}
{
nvmlUtilization_t utilization;
- if (hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, &utilization) != NVML_SUCCESS) return -1;
+ if (hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nvml, 1, data.hm_device[device_id].nvml, &utilization) != NVML_SUCCESS) return -1;
return utilization.gpu;
}
PMActivity.iSize = sizeof (ADLPMActivity);
- if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adapter_index.adl, &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.iMemoryClock / 100;
}
{
unsigned int clock;
- if (hm_NVML_nvmlDeviceGetClockInfo (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, NVML_CLOCK_MEM, &clock) != NVML_SUCCESS) return -1;
+ if (hm_NVML_nvmlDeviceGetClockInfo (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_CLOCK_MEM, &clock) != NVML_SUCCESS) return -1;
return clock;
}
PMActivity.iSize = sizeof (ADLPMActivity);
- if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adapter_index.adl, &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.iEngineClock / 100;
}
{
unsigned int clock;
- if (hm_NVML_nvmlDeviceGetClockInfo (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, NVML_CLOCK_SM, &clock) != NVML_SUCCESS) return -1;
+ if (hm_NVML_nvmlDeviceGetClockInfo (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_CLOCK_SM, &clock) != NVML_SUCCESS) return -1;
return clock;
}
unsigned long long clocksThrottleReasons = 0;
unsigned long long supportedThrottleReasons = 0;
- if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, &clocksThrottleReasons) != NVML_SUCCESS) return -1;
- if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (data.hm_nvml, 1, data.hm_device[device_id].adapter_index.nvml, &supportedThrottleReasons) != NVML_SUCCESS) return -1;
+ 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 &= supportedThrottleReasons;
+ clocksThrottleReasons &= ~nvmlClocksThrottleReasonGpuIdle;
+ clocksThrottleReasons &= ~nvmlClocksThrottleReasonApplicationsClocksSetting;
+ clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown;
- return (clocksThrottleReasons > 0);
+ if (data.kernel_power_final)
+ {
+ clocksThrottleReasons &= ~nvmlClocksThrottleReasonHwSlowdown;
+ }
+
+ return (clocksThrottleReasons != nvmlClocksThrottleReasonNone);
}
return -1;
{
if (data.hm_adl)
{
- if (data.hm_device[device_id].od_version == 5)
+ if (fanpolicy == 1)
{
- ADLFanSpeedValue lpFanSpeedValue;
+ if (data.hm_device[device_id].od_version == 5)
+ {
+ ADLFanSpeedValue lpFanSpeedValue;
- memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
+ memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
- lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue);
- lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
- lpFanSpeedValue.iFlags = (fanpolicy == 1) ? ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED : 0;
- lpFanSpeedValue.iFanSpeed = fanspeed;
+ lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue);
+ lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
+ lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
+ lpFanSpeedValue.iFanSpeed = fanspeed;
- if (hm_ADL_Overdrive5_FanSpeed_Set (data.hm_adl, data.hm_device[device_id].adapter_index.adl, 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;
+ return 0;
+ }
+ else // od_version == 6
+ {
+ ADLOD6FanSpeedValue fan_speed_value;
+
+ memset (&fan_speed_value, 0, sizeof (fan_speed_value));
+
+ fan_speed_value.iSpeedType = ADL_OD6_FANSPEED_TYPE_PERCENT;
+ fan_speed_value.iFanSpeed = fanspeed;
+
+ if (hm_ADL_Overdrive6_FanSpeed_Set (data.hm_adl, data.hm_device[device_id].adl, &fan_speed_value) != ADL_OK) return -1;
+
+ return 0;
+ }
}
- else // od_version == 6
+ else
{
- ADLOD6FanSpeedValue fan_speed_value;
+ if (data.hm_device[device_id].od_version == 5)
+ {
+ if (hm_ADL_Overdrive5_FanSpeedToDefault_Set (data.hm_adl, data.hm_device[device_id].adl, 0) != ADL_OK) return -1;
- memset (&fan_speed_value, 0, sizeof (fan_speed_value));
+ return 0;
+ }
+ else // od_version == 6
+ {
+ if (hm_ADL_Overdrive6_FanSpeed_Reset (data.hm_adl, data.hm_device[device_id].adl) != ADL_OK) return -1;
- fan_speed_value.iSpeedType = ADL_OD6_FANSPEED_TYPE_PERCENT;
- fan_speed_value.iFanSpeed = fanspeed;
+ return 0;
+ }
+ }
+ }
+ }
- if (hm_ADL_Overdrive6_FanSpeed_Set (data.hm_adl, data.hm_device[device_id].adapter_index.adl, &fan_speed_value) != ADL_OK) return -1;
+ 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)
+ {
+ if (fanpolicy == 1)
+ {
+ NV_GPU_COOLER_LEVELS CoolerLevels;
+
+ memset (&CoolerLevels, 0, sizeof (NV_GPU_COOLER_LEVELS));
+
+ CoolerLevels.Version = GPU_COOLER_LEVELS_VER | sizeof (NV_GPU_COOLER_LEVELS);
+
+ CoolerLevels.Levels[0].Level = fanspeed;
+ CoolerLevels.Levels[0].Policy = 1;
+
+ if (hm_NvAPI_GPU_SetCoolerLevels (data.hm_nvapi, data.hm_device[device_id].nvapi, 0, &CoolerLevels) != NVAPI_OK) return -1;
+
+ return 0;
+ }
+ else
+ {
+ if (hm_NvAPI_GPU_RestoreCoolerSettings (data.hm_nvapi, data.hm_device[device_id].nvapi, 0) != 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
/**
if (css_cnt > SP_PW_MAX)
{
- log_error ("ERROR: mask length is too long");
+ log_error ("ERROR: Mask length is too long");
exit (-1);
}
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);
}
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);
}
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);
}
}
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);
}
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);
}
if (css_pos == 0)
{
- log_error ("ERROR: invalid mask length (0)");
+ log_error ("ERROR: Invalid mask length (0)");
exit (-1);
}
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);
}
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);
}
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);
}
char *exec_path = (char *) mymalloc (exec_path_len);
- #ifdef LINUX
+ #ifdef __linux__
char tmp[32] = { 0 };
const int len = GetModuleFileName (NULL, exec_path, exec_path_len - 1);
- #elif OSX
+ #elif __APPLE__
uint size = exec_path_len;
const int len = strlen (exec_path);
+ #elif __FreeBSD__
+
+ #include <sys/sysctl.h>
+
+ int mib[4];
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PATHNAME;
+ mib[3] = -1;
+
+ char tmp[32] = { 0 };
+
+ size_t size = exec_path_len;
+ sysctl(mib, 4, exec_path, &size, NULL, 0);
+
+ const int len = readlink (tmp, exec_path, exec_path_len - 1);
+
#else
#error Your Operating System is not supported or detected
#endif
myfree (buf);
}
-#ifdef OSX
+#ifdef __APPLE__
int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t *cpu_set)
{
int core;
void set_cpu_affinity (char *cpu_affinity)
{
- #ifdef WIN
+ #ifdef _WIN
DWORD_PTR aff_mask = 0;
+ #elif __FreeBSD__
+ cpuset_t cpuset;
+ CPU_ZERO (&cpuset);
#elif _POSIX
cpu_set_t cpuset;
CPU_ZERO (&cpuset);
if (cpu_id == 0)
{
- #ifdef WIN
+ #ifdef _WIN
aff_mask = 0;
#elif _POSIX
CPU_ZERO (&cpuset);
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
- aff_mask |= 1 << (cpu_id - 1);
+ #ifdef _WIN
+ aff_mask |= 1u << (cpu_id - 1);
#elif _POSIX
CPU_SET ((cpu_id - 1), &cpuset);
#endif
free (devices);
}
- #ifdef WIN
+ #ifdef _WIN
SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
SetThreadAffinityMask (GetCurrentThread (), aff_mask);
+ #elif __FreeBSD__
+ pthread_t thread = pthread_self ();
+ pthread_setaffinity_np (thread, sizeof (cpuset_t), &cpuset);
#elif _POSIX
pthread_t thread = pthread_self ();
pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset);
while (n--)
{
if (s1->salt_buf[n] > s2->salt_buf[n]) return ( 1);
- if (s1->salt_buf[n] < s2->salt_buf[n]) return (-1);
+ if (s1->salt_buf[n] < s2->salt_buf[n]) return -1;
}
n = 8;
while (n--)
{
if (s1->salt_buf_pc[n] > s2->salt_buf_pc[n]) return ( 1);
- if (s1->salt_buf_pc[n] < s2->salt_buf_pc[n]) return (-1);
+ if (s1->salt_buf_pc[n] < s2->salt_buf_pc[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_salt_buf (const void *v1, const void *v2)
while (n--)
{
if (s1->salt_buf[n] > s2->salt_buf[n]) return ( 1);
- if (s1->salt_buf[n] < s2->salt_buf[n]) return (-1);
+ if (s1->salt_buf[n] < s2->salt_buf[n]) return -1;
}
return 0;
while (n--)
{
if (s1->salt_buf[n] > s2->salt_buf[n]) return ( 1);
- if (s1->salt_buf[n] < s2->salt_buf[n]) return (-1);
+ if (s1->salt_buf[n] < s2->salt_buf[n]) return -1;
}
/* original code, seems buggy since salt_len can be very big (had a case with 131 len)
also it thinks salt_buf[x] is a char but its a uint so salt_len should be / 4
if (s1->salt_len > s2->salt_len) return ( 1);
- if (s1->salt_len < s2->salt_len) return (-1);
+ if (s1->salt_len < s2->salt_len) return -1;
uint n = s1->salt_len;
while (n--)
{
if (s1->salt_buf[n] > s2->salt_buf[n]) return ( 1);
- if (s1->salt_buf[n] < s2->salt_buf[n]) return (-1);
+ if (s1->salt_buf[n] < s2->salt_buf[n]) return -1;
}
*/
const salt_t *s1 = h1->salt;
const salt_t *s2 = h2->salt;
- // 16 - 2 (since last 2 uints contain the digest)
- uint n = 14;
+ // last 2: salt_buf[10] and salt_buf[11] contain the digest (skip them)
+
+ uint n = 9; // 9 * 4 = 36 bytes (max length of ESSID)
while (n--)
{
if (s1->salt_buf[n] > s2->salt_buf[n]) return ( 1);
- if (s1->salt_buf[n] < s2->salt_buf[n]) return (-1);
+ if (s1->salt_buf[n] < s2->salt_buf[n]) return -1;
}
return 0;
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;
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_4_4 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_4_5 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_4_6 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_4_8 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_4_16 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_4_32 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_4_64 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_8_8 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_8_16 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_8_25 (const void *v1, const void *v2)
while (n--)
{
if (d1[n] > d2[n]) return ( 1);
- if (d1[n] < d2[n]) return (-1);
+ if (d1[n] < d2[n]) return -1;
}
- return (0);
+ return 0;
}
int sort_by_digest_p0p1 (const void *v1, const void *v2)
const uint dgst_pos3 = data.dgst_pos3;
if (d1[dgst_pos3] > d2[dgst_pos3]) return ( 1);
- if (d1[dgst_pos3] < d2[dgst_pos3]) return (-1);
+ if (d1[dgst_pos3] < d2[dgst_pos3]) return -1;
if (d1[dgst_pos2] > d2[dgst_pos2]) return ( 1);
- if (d1[dgst_pos2] < d2[dgst_pos2]) return (-1);
+ if (d1[dgst_pos2] < d2[dgst_pos2]) return -1;
if (d1[dgst_pos1] > d2[dgst_pos1]) return ( 1);
- if (d1[dgst_pos1] < d2[dgst_pos1]) return (-1);
+ if (d1[dgst_pos1] < d2[dgst_pos1]) return -1;
if (d1[dgst_pos0] > d2[dgst_pos0]) return ( 1);
- if (d1[dgst_pos0] < d2[dgst_pos0]) return (-1);
+ if (d1[dgst_pos0] < d2[dgst_pos0]) return -1;
- return (0);
+ return 0;
}
int sort_by_tuning_db_alias (const void *v1, const void *v2)
#endif
}
- fputc ('\n', out_fp);
+ fputs (EOL, out_fp);
}
void handle_show_request (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp)
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);
}
- opencl_platforms_filter |= 1 << (platform - 1);
+ opencl_platforms_filter |= 1u << (platform - 1);
} while ((next = strtok (NULL, ",")) != NULL);
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);
}
- devices_filter |= 1 << (device_id - 1);
+ devices_filter |= 1u << (device_id - 1);
} while ((next = strtok (NULL, ",")) != NULL);
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);
}
- device_types_filter |= 1 << device_type;
+ device_types_filter |= 1u << device_type;
} while ((next = strtok (NULL, ",")) != NULL);
if ((d = opendir (tmp_path)) != NULL)
{
- #ifdef OSX
+ #ifdef __APPLE__
+
struct dirent e;
- for (;;) {
+ for (;;)
+ {
memset (&e, 0, sizeof (e));
+
struct dirent *de = NULL;
if (readdir_r (d, &e, &de) != 0)
}
if (de == NULL) break;
+
#else
+
struct dirent *de;
while ((de = readdir (d)) != NULL)
{
+
#endif
+
if ((strcmp (de->d_name, ".") == 0) || (strcmp (de->d_name, "..") == 0)) continue;
int path_size = strlen (tmp_path) + 1 + strlen (de->d_name);
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;
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");
uint len = 4096;
- uint digest_buf[64] = { 0 };
+ u8 datax[256] = { 0 };
- u64 *digest_buf64 = (u64 *) digest_buf;
+ u64 *digest_buf64 = (u64 *) datax;
+ u32 *digest_buf = (u32 *) datax;
char *digests_buf_ptr = (char *) data.digests_buf;
{
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)
void SuspendThreads ()
{
- if (data.devices_status == STATUS_RUNNING)
- {
- hc_timer_set (&data.timer_paused);
+ if (data.devices_status != STATUS_RUNNING) return;
- data.devices_status = STATUS_PAUSED;
+ hc_timer_set (&data.timer_paused);
- log_info ("Paused");
- }
+ data.devices_status = STATUS_PAUSED;
+
+ log_info ("Paused");
}
void ResumeThreads ()
{
- if (data.devices_status == STATUS_PAUSED)
- {
- double ms_paused;
+ if (data.devices_status != STATUS_PAUSED) return;
- hc_timer_get (data.timer_paused, ms_paused);
+ double ms_paused;
- data.ms_paused += ms_paused;
+ hc_timer_get (data.timer_paused, ms_paused);
- data.devices_status = STATUS_RUNNING;
+ data.ms_paused += ms_paused;
- log_info ("Resumed");
- }
+ data.devices_status = STATUS_RUNNING;
+
+ log_info ("Resumed");
}
void bypass ()
{
- if (data.devices_status != STATUS_RUNNING) return;
-
data.devices_status = STATUS_BYPASS;
log_info ("Next dictionary / mask in queue selected, bypassing current one");
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;
}
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
{
void myabort ()
{
- if (data.devices_status == STATUS_INIT) return;
- if (data.devices_status == STATUS_STARTING) return;
-
data.devices_status = STATUS_ABORTED;
}
void myquit ()
{
- if (data.devices_status == STATUS_INIT) return;
- if (data.devices_status == STATUS_STARTING) return;
-
data.devices_status = STATUS_QUIT;
}
+void naive_replace (char *s, const u8 key_char, const u8 replace_char)
+{
+ const size_t len = strlen (s);
+
+ for (size_t in = 0; in < len; in++)
+ {
+ const u8 c = s[in];
+
+ if (c == key_char)
+ {
+ s[in] = replace_char;
+ }
+ }
+}
+
+void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char)
+{
+ char s_escaped[1024] = { 0 };
+
+ size_t s_escaped_max = sizeof (s_escaped);
+
+ const size_t len = strlen (s);
+
+ for (size_t in = 0, out = 0; in < len; in++, out++)
+ {
+ const u8 c = s[in];
+
+ if (c == key_char)
+ {
+ s_escaped[out] = escape_char;
+
+ out++;
+ }
+
+ if (out == s_escaped_max - 2) break;
+
+ s_escaped[out] = c;
+ }
+
+ strncpy (s, s_escaped, s_max - 1);
+}
+
void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources)
{
FILE *fp = fopen (kernel_file, "rb");
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);
}
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);
}
{
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);
}
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);
}
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);
}
{
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);
}
{
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));
}
}
char *iter_pos = input_buf + 4;
- salt->salt_iter = 1 << atoi (iter_pos);
+ salt->salt_iter = 1u << atoi (iter_pos);
char *salt_pos = strchr (iter_pos, '$');
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);
}
char *iter_pos = input_buf + 3;
- uint salt_iter = 1 << itoa64_to_int (iter_pos[0]);
+ uint salt_iter = 1u << itoa64_to_int (iter_pos[0]);
if (salt_iter > 0x80000000) return (PARSER_SALT_ITERATION);
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);
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);
}
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];
salt->salt_sign[0] = atoi (salt_iter);
- salt->salt_iter = (1 << atoi (salt_iter)) - 1;
+ salt->salt_iter = (1u << atoi (salt_iter)) - 1;
hash_pos++;
salt->salt_sign[0] = atoi (salt_iter);
- salt->salt_iter = (1 << atoi (salt_iter)) - 1;
+ salt->salt_iter = (1u << atoi (salt_iter)) - 1;
hash_pos++;
salt->salt_sign[0] = atoi (salt_iter);
- salt->salt_iter = (1 << atoi (salt_iter)) - 1;
+ salt->salt_iter = (1u << atoi (salt_iter)) - 1;
hash_pos++;
char *iter_pos = input_buf + 3;
- uint salt_iter = 1 << itoa64_to_int (iter_pos[0]);
+ uint salt_iter = 1u << itoa64_to_int (iter_pos[0]);
if (salt_iter > 0x80000000) return (PARSER_SALT_ITERATION);
int enc_md = atoi (enc_md_pos);
- if (enc_md != 1) return (PARSER_SALT_VALUE);
+ if ((enc_md != 0) && (enc_md != 1)) return (PARSER_SALT_VALUE);
const uint id_len = atoi (id_len_pos);
const uint u_len = atoi (u_len_pos);
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);
salt->salt_sign[0] = iter;
- salt->salt_iter = 1 << iter;
+ salt->salt_iter = 1u << iter;
/**
* digest
salt->salt_sign[0] = iterations;
- salt->salt_iter = ((1 << iterations) + 32) - 1;
+ salt->salt_iter = ((1u << iterations) + 32) - 1;
/**
* digest 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
*/
{
case CTRL_CLOSE_EVENT:
- myabort ();
+ myquit ();
SetConsoleCtrlHandler (NULL, TRUE);
void *thread_keypress (void *p)
{
- int benchmark = *((int *) p);
-
uint quiet = data.quiet;
tty_break();
- while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
+ while (data.shutdown_outer == 0)
{
int ch = tty_getchar();
log_info ("");
- if (benchmark == 1) break;
-
stop_at_checkpoint ();
log_info ("");
log_info ("");
- if (benchmark == 1)
- {
- myquit ();
- }
- else
- {
- myabort ();
- }
+ myabort ();
break;
}
break;
case RULE_OP_MANGLE_PURGECHAR:
- return (-1);
+ SET_NAME (rule, rule_buf[rule_pos]);
+ SET_P0 (rule, rule_buf[rule_pos]);
break;
case RULE_OP_MANGLE_TOGGLECASE_REC:
- return (-1);
+ return -1;
break;
case RULE_OP_MANGLE_DUPECHAR_FIRST:
break;
default:
- return (-1);
+ return -1;
break;
}
}
- if (rule_pos < rule_len) return (-1);
+ if (rule_pos < rule_len) return -1;
- return (0);
+ return 0;
}
int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
break;
case RULE_OP_MANGLE_PURGECHAR:
- return (-1);
+ rule_buf[rule_pos] = rule_cmd;
+ GET_P0 (rule);
break;
case RULE_OP_MANGLE_TOGGLECASE_REC:
- return (-1);
+ return -1;
break;
case RULE_OP_MANGLE_DUPECHAR_FIRST:
break;
default:
- return (-1);
+ return -1;
break;
}
}
return rule_pos;
}
- return (-1);
+ return -1;
}
/**