mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-15 12:29:35 +00:00
Merge pull request #144 from gm4tr1x/master
About issue #120 and issue #63
This commit is contained in:
commit
811afddeda
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ oclHashcat
|
||||
*.dictstat
|
||||
*.pot
|
||||
*.log
|
||||
*.dSYM
|
||||
deps/**
|
||||
kernels/**
|
||||
lib/*.a
|
||||
|
@ -43,11 +43,15 @@
|
||||
#ifdef OSX
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
typedef void *HM_LIB;
|
||||
#endif
|
||||
|
||||
#endif // _POSIX
|
||||
|
||||
#ifdef _WIN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
@ -70,11 +74,13 @@ typedef INT64 int64_t;
|
||||
typedef UINT32 uint;
|
||||
typedef UINT64 uint64_t;
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
typedef HINSTANCE HM_LIB;
|
||||
#endif
|
||||
|
||||
#define mkdir(name,mode) mkdir (name)
|
||||
|
||||
#endif
|
||||
#endif // _WIN
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
@ -104,4 +110,4 @@ void log_error (const char *fmt, ...);
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
#endif
|
||||
#endif // COMMON_H
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef EXT_ADL_H
|
||||
#define EXT_ADL_H
|
||||
|
||||
#if defined(HAVE_HWMON) && defined(HAVE_ADL)
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#include <adl_sdk.h>
|
||||
@ -89,4 +91,6 @@ int hc_ADL_Overdrive_State_Set (HM_LIB hDLL, int iAdapterIndex, int type, ADLOD6
|
||||
int hc_ADL_Overdrive6_PowerControl_Caps (HM_LIB hDLL, int iAdapterIndex, int *lpSupported);
|
||||
int hc_ADL_Overdrive6_TargetTemperatureData_Get (HM_LIB hDLL, int iAdapterIndex, int *cur_temp, int *default_temp);
|
||||
|
||||
#endif
|
||||
#endif // HAVE_HWMON && HAVE_ADL
|
||||
|
||||
#endif // EXT_ADL_H
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
|
||||
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
|
||||
|
||||
#ifdef OSX
|
||||
#include <OpenCL/cl.h>
|
||||
#endif
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef EXT_SMI_H
|
||||
#define EXT_SMI_H
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef EXT_NVAPI_H
|
||||
#define EXT_NVAPI_H
|
||||
|
||||
#if defined(HAVE_HWMON) && defined(HAVE_NVAPI)
|
||||
|
||||
#include <common.h>
|
||||
|
||||
// Just annotations (they do nothing special)
|
||||
@ -61,4 +63,6 @@ int hc_NvAPI_GPU_GetThermalSettings (NvPhysicalGpuHandle hPhysicalGpu, NvU32 sen
|
||||
int hc_NvAPI_GPU_GetTachReading (NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue);
|
||||
int hc_NvAPI_GPU_GetDynamicPstatesInfoEx (NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx);
|
||||
|
||||
#endif // HAVE_HWMON && HAVE_NVAPI
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef EXT_NVML_H
|
||||
#define EXT_NVML_H
|
||||
|
||||
#if defined(HAVE_HWMON) && defined(HAVE_NVML)
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#include <nvml.h>
|
||||
@ -31,4 +33,6 @@ nvmlReturn_t hc_NVML_nvmlDeviceGetFanSpeed (HM_LIB hDLL, int, nvmlDevice_t devic
|
||||
nvmlReturn_t hc_NVML_nvmlDeviceGetPowerUsage (HM_LIB hDLL, nvmlDevice_t device, unsigned int *power);
|
||||
nvmlReturn_t hc_NVML_nvmlDeviceGetUtilizationRates (HM_LIB hDLL, nvmlDevice_t device, nvmlUtilization_t *utilization);
|
||||
|
||||
#endif // HAVE_HWMON && HAVE_NVML
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef EXT_SMI_H
|
||||
#define EXT_SMI_H
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#define SMI_OK 0
|
||||
@ -13,4 +15,6 @@
|
||||
|
||||
int hc_nvidia_smi (int dev, int *temperature, int *gpu);
|
||||
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
#endif
|
||||
|
@ -1670,14 +1670,19 @@ void logfile_append (const char *fmt, ...);
|
||||
void fsync (int fd);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
|
||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||
int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]);
|
||||
#endif
|
||||
|
||||
int get_adapters_num_amd (HM_LIB hm_dll_amd, int *iNumberAdapters);
|
||||
|
||||
int hm_get_device_num (HM_LIB hm_dll_amd, HM_ADAPTER_AMD hm_adapter_index, int *hm_device_num);
|
||||
// int hm_get_device_num (HM_LIB hm_dll_amd, HM_ADAPTER_AMD hm_adapter_index, int *hm_device_num);
|
||||
|
||||
// void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices);
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
int get_adapters_num_amd (HM_LIB hm_dll_amd, int *iNumberAdapters);
|
||||
|
||||
int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
|
||||
|
||||
LPAdapterInfo hm_get_adapter_info_amd (HM_LIB hm_dll_amd, int iNumberAdapters);
|
||||
@ -1686,10 +1691,13 @@ u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters,
|
||||
|
||||
int hm_get_overdrive_version (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
|
||||
int hm_check_fanspeed_control (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
|
||||
#endif // HAVE_ADL
|
||||
|
||||
#if defined(HAVE_ADL) || defined(HAVE_NVML)
|
||||
void hm_close (HM_LIB hm_dll);
|
||||
|
||||
HM_LIB hm_init (const cl_uint vendor_id);
|
||||
#endif
|
||||
|
||||
int hm_get_temperature_with_device_id (const uint device_id);
|
||||
int hm_get_fanspeed_with_device_id (const uint device_id);
|
||||
@ -1698,6 +1706,7 @@ int hm_get_utilization_with_device_id (const uint device_id);
|
||||
int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed);
|
||||
|
||||
void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value);
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
void myabort ();
|
||||
void myquit ();
|
||||
@ -1955,4 +1964,4 @@ void *thread_runtime (void *p);
|
||||
|
||||
#include "cpu-aes.h"
|
||||
|
||||
#endif
|
||||
#endif // SHARED_H
|
||||
|
@ -978,12 +978,18 @@ struct __hc_device_param
|
||||
|
||||
typedef struct __hc_device_param hc_device_param_t;
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
#ifdef HAVE_ADL
|
||||
HM_ADAPTER_AMD amd;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||
HM_ADAPTER_NV nv;
|
||||
#endif
|
||||
|
||||
} adapter_index;
|
||||
|
||||
@ -995,6 +1001,7 @@ typedef struct
|
||||
// int devid; // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPUs
|
||||
|
||||
} hm_attrs_t;
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -1044,9 +1051,11 @@ typedef struct
|
||||
* hardware watchdog
|
||||
*/
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
HM_LIB hm_dll_nv;
|
||||
HM_LIB hm_dll_amd;
|
||||
hm_attrs_t hm_device[DEVICES_MAX];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* hashes
|
||||
@ -1154,9 +1163,11 @@ typedef struct
|
||||
uint dgst_pos2;
|
||||
uint dgst_pos3;
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
uint gpu_temp_disable;
|
||||
uint gpu_temp_abort;
|
||||
uint gpu_temp_retain;
|
||||
#endif
|
||||
|
||||
char **rp_files;
|
||||
uint rp_files_cnt;
|
||||
|
234
src/Makefile
234
src/Makefile
@ -1,16 +1,34 @@
|
||||
##
|
||||
## Author......: Jens Steube <jens.steube@gmail.com>
|
||||
## Authors.....: Jens Steube <jens.steube@gmail.com>
|
||||
## Gabriele Gristina <matrix@hashcat.net>
|
||||
##
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
PROG_NAME := oclHashcat
|
||||
|
||||
##
|
||||
## Detect Operating System
|
||||
##
|
||||
|
||||
UNAME := $(shell uname -s)
|
||||
|
||||
ifeq (,$(filter $(UNAME),Linux Darwin))
|
||||
$(error "! Your Operating System ($(UNAME)) is not supported by $(PROG_NAME) Makefile")
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
$(warning "## Detected Operating System : $(UNAME)")
|
||||
endif
|
||||
|
||||
##
|
||||
## Makefile flags
|
||||
##
|
||||
|
||||
MAKEFLAGS += -l -j -rR --no-print-directory
|
||||
MAKEFLAGS += -l -j -rR --no-print-directory
|
||||
|
||||
ifneq ($(findstring clean,$(MAKECMDGOALS)),)
|
||||
MAKEFLAGS += -j 1
|
||||
MAKEFLAGS += -j 1
|
||||
endif
|
||||
|
||||
##
|
||||
@ -20,11 +38,11 @@ endif
|
||||
PREFIX ?= /usr/local
|
||||
|
||||
INSTALL_FOLDER ?= $(PREFIX)/bin
|
||||
SHARED_FOLDER ?= $(PREFIX)/share/oclHashcat
|
||||
DOCUMENT_FOLDER ?= $(PREFIX)/share/doc/oclHashcat
|
||||
SHARED_FOLDER ?= $(PREFIX)/share/$(PROG_NAME)
|
||||
DOCUMENT_FOLDER ?= $(PREFIX)/share/doc/$(PROG_NAME)
|
||||
|
||||
##
|
||||
## Depencies
|
||||
## Dependencies
|
||||
##
|
||||
|
||||
ADL := deps/adl-sdk
|
||||
@ -32,7 +50,7 @@ GDK := deps/nvidia-gdk
|
||||
NVAPI := deps/R352-developer
|
||||
|
||||
##
|
||||
## Depencies, cross compilation only
|
||||
## Dependencies, cross compilation only
|
||||
##
|
||||
|
||||
OPENCL_HEADERS_KHRONOS := deps/OpenCL-Headers
|
||||
@ -43,6 +61,32 @@ OPENCL_HEADERS_KHRONOS := deps/OpenCL-Headers
|
||||
|
||||
NVML := $(GDK)/usr/include/nvidia/gdk
|
||||
|
||||
##
|
||||
## Check dependencies
|
||||
##
|
||||
|
||||
FOUND_ADL := 0
|
||||
FOUND_NVML := 0
|
||||
FOUND_NVAPI := 0
|
||||
|
||||
ifneq ($(wildcard $(ADL)/include/adl_sdk.h),)
|
||||
FOUND_ADL := 1
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard $(NVML)/nvml.h),)
|
||||
FOUND_NVML := 1
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard $(NVAPI)/nvapi.h),)
|
||||
FOUND_NVAPI := 1
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
$(warning "## ADL is found ? $(FOUND_ADL)")
|
||||
$(warning "## NVML is found ? $(FOUND_NVML)")
|
||||
$(warning "## NVAPI is found ? $(FOUND_NVAPI)")
|
||||
endif
|
||||
|
||||
##
|
||||
## Native compiler paths
|
||||
##
|
||||
@ -76,35 +120,86 @@ NOW := $(shell date +%s)
|
||||
## Compiler flags
|
||||
##
|
||||
|
||||
CFLAGS := -O2 -s -pipe -W -Wall -std=c99 -Iinclude/
|
||||
#CFLAGS := -g -ggdb -pipe -W -Wall -std=c99 -Iinclude/ -fsanitize=undefined -fno-omit-frame-pointer
|
||||
CFLAGS := -O2 -pipe -W -Wall -std=c99 -Iinclude/
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -g -ggdb -fsanitize=address -fno-omit-frame-pointer
|
||||
endif
|
||||
|
||||
##
|
||||
## Native compilation target
|
||||
##
|
||||
|
||||
CFLAGS_NATIVE := -D_POSIX -DLINUX
|
||||
CFLAGS_NATIVE += $(CFLAGS)
|
||||
CFLAGS_NATIVE += -I$(ADL)/include/
|
||||
CFLAGS_NATIVE += -I$(NVML)/
|
||||
BINARY_NATIVE := $(PROG_NAME)
|
||||
|
||||
LFLAGS_NATIVE := -lpthread -lOpenCL -ldl
|
||||
ifeq ($(UNAME),Darwin)
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.9
|
||||
|
||||
BINARY_NATIVE := $(PROG_NAME).app
|
||||
|
||||
CFLAGS_NATIVE := -D_POSIX -DOSX
|
||||
CFLAGS_NATIVE += $(CFLAGS)
|
||||
|
||||
LFLAGS_NATIVE := -framework OpenCL -lpthread
|
||||
|
||||
FOUND_ADL := 0
|
||||
FOUND_NVML := 0
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME),Linux)
|
||||
CFLAGS_NATIVE := -D_POSIX -DLINUX
|
||||
CFLAGS_NATIVE += -s $(CFLAGS)
|
||||
|
||||
LFLAGS_NATIVE := -lOpenCL -lpthread
|
||||
|
||||
ifneq (,$(filter 1,$(FOUND_ADL) $(FOUND_NVML)))
|
||||
LFLAGS_NATIVE += -ldl
|
||||
CFLAGS_NATIVE += -DHAVE_HWMON
|
||||
ifeq ($(FOUND_ADL),1)
|
||||
CFLAGS_NATIVE += -DHAVE_ADL -I$(ADL)/include/
|
||||
endif
|
||||
ifeq ($(FOUND_NVML),1)
|
||||
CFLAGS_NATIVE += -DHAVE_NVML -I$(NVML)/
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
##
|
||||
## Cross compilation target
|
||||
##
|
||||
|
||||
CFLAGS_CROSS_LINUX := -D_POSIX -DLINUX
|
||||
CFLAGS_CROSS_LINUX += $(CFLAGS)
|
||||
CFLAGS_CROSS_LINUX += -s $(CFLAGS)
|
||||
CFLAGS_CROSS_LINUX += -I$(OPENCL_HEADERS_KHRONOS)/
|
||||
CFLAGS_CROSS_LINUX += -I$(ADL)/include/
|
||||
CFLAGS_CROSS_LINUX += -I$(NVML)/
|
||||
|
||||
ifneq (,$(filter 1,$(FOUND_ADL) $(FOUND_NVML)))
|
||||
CFLAGS_CROSS_LINUX += -DHAVE_HWMON
|
||||
|
||||
ifeq ($(FOUND_ADL),1)
|
||||
CFLAGS_CROSS_LINUX += -DHAVE_ADL -I$(ADL)/include/
|
||||
endif
|
||||
|
||||
ifeq ($(FOUND_NVML),1)
|
||||
CFLAGS_CROSS_LINUX += -DHAVE_NVML -I$(NVML)/
|
||||
endif
|
||||
endif
|
||||
|
||||
CFLAGS_CROSS_WIN := -D_WIN -DWIN -D__MSVCRT__ -D__USE_MINGW_ANSI_STDIO=1
|
||||
CFLAGS_CROSS_WIN += $(CFLAGS)
|
||||
CFLAGS_CROSS_WIN += -s $(filter-out -fsanitize=address,$(CFLAGS))
|
||||
CFLAGS_CROSS_WIN += -I$(OPENCL_HEADERS_KHRONOS)/
|
||||
CFLAGS_CROSS_WIN += -I$(ADL)/include/
|
||||
CFLAGS_CROSS_WIN += -I$(NVAPI)/
|
||||
|
||||
ifneq (,$(filter 1,$(FOUND_ADL) $(FOUND_NVAPI)))
|
||||
CFLAGS_CROSS_WIN += -DHAVE_HWMON
|
||||
|
||||
ifeq ($(FOUND_ADL),1)
|
||||
CFLAGS_CROSS_WIN += -DHAVE_ADL -I$(ADL)/include/
|
||||
endif
|
||||
|
||||
ifeq ($(FOUND_NVAPI),1)
|
||||
CFLAGS_CROSS_WIN += -DHAVE_NVAPI -I$(NVAPI)/
|
||||
endif
|
||||
endif
|
||||
|
||||
CFLAGS_CROSS_32 := -m32
|
||||
CFLAGS_CROSS_64 := -m64
|
||||
@ -112,6 +207,46 @@ CFLAGS_CROSS_64 := -m64
|
||||
LFLAGS_CROSS_LINUX := -lpthread -lOpenCL -ldl
|
||||
LFLAGS_CROSS_WIN := -lpsapi
|
||||
|
||||
##
|
||||
## Objects
|
||||
##
|
||||
|
||||
NATIVE_OBJS := obj/ext_OpenCL.NATIVE.o obj/shared.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o
|
||||
|
||||
ifneq (,$(filter 1,$(FOUND_ADL) $(FOUND_NVML)))
|
||||
ifeq ($(FOUND_ADL),1)
|
||||
NATIVE_OBJS += obj/ext_ADL.NATIVE.o
|
||||
endif
|
||||
|
||||
ifeq ($(FOUND_NVML),1)
|
||||
NATIVE_OBJS += obj/ext_nvml.NATIVE.o
|
||||
endif
|
||||
endif
|
||||
|
||||
LINUX_32_OBJS := obj/ext_OpenCL.LINUX.32.o obj/shared.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o
|
||||
LINUX_64_OBJS := obj/ext_OpenCL.LINUX.64.o obj/shared.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o
|
||||
|
||||
WIN_32_OBJS := obj/ext_OpenCL.WIN.32.o obj/shared.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o
|
||||
WIN_64_OBJS := obj/ext_OpenCL.WIN.64.o obj/shared.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o
|
||||
|
||||
ifeq ($(FOUND_ADL),1)
|
||||
LINUX_32_OBJS += obj/ext_ADL.LINUX.32.o
|
||||
LINUX_64_OBJS += obj/ext_ADL.LINUX.64.o
|
||||
|
||||
WIN_32_OBJS += obj/ext_ADL.WIN.32.o
|
||||
WIN_64_OBJS += obj/ext_ADL.WIN.64.o
|
||||
endif
|
||||
|
||||
ifeq ($(FOUND_NVML),1)
|
||||
LINUX_32_OBJS += obj/ext_nvml.LINUX.32.o
|
||||
LINUX_64_OBJS += obj/ext_nvml.LINUX.64.o
|
||||
endif
|
||||
|
||||
ifeq ($(FOUND_NVAPI),1)
|
||||
WIN_32_OBJS += obj/ext_nvapi.WIN.32.o $(NVAPI)/x86/nvapi.lib
|
||||
WIN_64_OBJS += obj/ext_nvapi.WIN.64.o $(NVAPI)/amd64/nvapi64.lib
|
||||
endif
|
||||
|
||||
##
|
||||
## Targets: Global
|
||||
##
|
||||
@ -121,16 +256,17 @@ native: oclHashcat
|
||||
binaries: linux32 linux64 win32 win64
|
||||
|
||||
clean:
|
||||
$(RM) -f obj/*.o lib/*.a ./*.bin ./*.exe ./*.app *.restore *.out *.pot *.dictstat *.log oclHashcat core
|
||||
$(RM) -f obj/*.o lib/*.a *.bin *.exe *.app *.restore *.out *.pot *.dictstat *.log oclHashcat core
|
||||
$(RM) -rf *.induct
|
||||
$(RM) -rf *.outfiles
|
||||
$(RM) -rf *.dSYM
|
||||
$(RM) -rf kernels
|
||||
|
||||
linux32: oclHashcat32.bin
|
||||
linux64: oclHashcat64.bin
|
||||
linux32: oclHashcat32.bin
|
||||
linux64: oclHashcat64.bin
|
||||
|
||||
win32: oclHashcat32.exe
|
||||
win64: oclHashcat64.exe
|
||||
win32: oclHashcat32.exe
|
||||
win64: oclHashcat64.exe
|
||||
|
||||
##
|
||||
## Targets: Linux install
|
||||
@ -154,16 +290,16 @@ install: native
|
||||
$(INSTALL) -m 644 include/constants.h $(SHARED_FOLDER)/include/
|
||||
$(INSTALL) -m 644 include/kernel_functions.c $(SHARED_FOLDER)/include/
|
||||
$(INSTALL) -m 644 include/kernel_vendor.h $(SHARED_FOLDER)/include/
|
||||
$(INSTALL) -m 644 include/rp_kernel.h $(SHARED_FOLDER)/include/
|
||||
$(INSTALL) -m 644 include/rp_kernel.h $(SHARED_FOLDER)/include/
|
||||
$(INSTALL) -m 755 -d $(SHARED_FOLDER)/OpenCL
|
||||
$(CP) -a OpenCL/* $(SHARED_FOLDER)/OpenCL/
|
||||
$(INSTALL) -m 755 -d $(SHARED_FOLDER)/rules
|
||||
$(CP) -a rules/* $(SHARED_FOLDER)/rules/
|
||||
$(INSTALL) -m 644 hashcat.hcstat $(SHARED_FOLDER)/
|
||||
$(INSTALL) -m 755 oclHashcat $(INSTALL_FOLDER)/
|
||||
$(INSTALL) -m 755 $(BINARY_NATIVE) $(INSTALL_FOLDER)/
|
||||
|
||||
uninstall:
|
||||
$(RM) -f $(INSTALL_FOLDER)/oclHashcat
|
||||
$(RM) -f $(INSTALL_FOLDER)/$(BINARY_NATIVE)
|
||||
$(RM) -rf $(SHARED_FOLDER)
|
||||
$(RM) -rf $(DOCUMENT_FOLDER)
|
||||
|
||||
@ -172,45 +308,45 @@ uninstall:
|
||||
##
|
||||
|
||||
lib/libOpenCL.a:
|
||||
${DLL_WIN_32} -A -k -l lib/libOpenCL.a -d lib/OpenCL.def
|
||||
$(DLL_WIN_32) -A -k -l lib/libOpenCL.a -d lib/OpenCL.def
|
||||
|
||||
lib/libOpenCL64.a:
|
||||
${DLL_WIN_64} -A -k -l lib/libOpenCL64.a -d lib/OpenCL64.def
|
||||
$(DLL_WIN_64) -A -k -l lib/libOpenCL64.a -d lib/OpenCL64.def
|
||||
|
||||
##
|
||||
## native compiled oclHashcat
|
||||
##
|
||||
|
||||
obj/%.oclHashcat.NATIVE.o: src/%.c
|
||||
obj/%.NATIVE.o: src/%.c
|
||||
$(CC_NATIVE) $(CFLAGS_NATIVE) -c -o $@ $<
|
||||
|
||||
oclHashcat: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.NATIVE.o obj/ext_nvml.oclHashcat.NATIVE.o obj/ext_ADL.oclHashcat.NATIVE.o obj/shared.oclHashcat.NATIVE.o obj/rp_kernel_on_cpu.oclHashcat.NATIVE.o
|
||||
$(CC_NATIVE) $(CFLAGS_NATIVE) -o $@ $^ $(LFLAGS_NATIVE) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
oclHashcat: src/oclHashcat.c $(NATIVE_OBJS)
|
||||
$(CC_NATIVE) $(CFLAGS_NATIVE) -o $(BINARY_NATIVE) $^ $(LFLAGS_NATIVE) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
|
||||
##
|
||||
## cross compiled oclHashcat for binary release version
|
||||
##
|
||||
|
||||
obj/%.oclHashcat.LINUX.32.o: src/%.c
|
||||
$(CC_LINUX_32) $(CFLAGS_CROSS) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -c -o $@ $<
|
||||
obj/%.LINUX.32.o: src/%.c
|
||||
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -c -o $@ $<
|
||||
|
||||
obj/%.oclHashcat.LINUX.64.o: src/%.c
|
||||
$(CC_LINUX_64) $(CFLAGS_CROSS) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -c -o $@ $<
|
||||
obj/%.LINUX.64.o: src/%.c
|
||||
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -c -o $@ $<
|
||||
|
||||
obj/%.oclHashcat.WIN.32.o: src/%.c
|
||||
$(CC_WIN_32) $(CFLAGS_CROSS) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -c -o $@ $<
|
||||
obj/%.WIN.32.o: src/%.c
|
||||
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -c -o $@ $<
|
||||
|
||||
obj/%.oclHashcat.WIN.64.o: src/%.c
|
||||
$(CC_WIN_64) $(CFLAGS_CROSS) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -c -o $@ $<
|
||||
obj/%.WIN.64.o: src/%.c
|
||||
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -c -o $@ $<
|
||||
|
||||
oclHashcat32.bin: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.LINUX.32.o obj/ext_nvml.oclHashcat.LINUX.32.o obj/ext_ADL.oclHashcat.LINUX.32.o obj/shared.oclHashcat.LINUX.32.o obj/rp_kernel_on_cpu.oclHashcat.LINUX.32.o
|
||||
$(CC_LINUX_32) $(CFLAGS_CROSS) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
oclHashcat32.bin: src/oclHashcat.c $(LINUX_32_OBJS)
|
||||
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
|
||||
oclHashcat64.bin: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.LINUX.64.o obj/ext_nvml.oclHashcat.LINUX.64.o obj/ext_ADL.oclHashcat.LINUX.64.o obj/shared.oclHashcat.LINUX.64.o obj/rp_kernel_on_cpu.oclHashcat.LINUX.64.o
|
||||
$(CC_LINUX_64) $(CFLAGS_CROSS) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
oclHashcat64.bin: src/oclHashcat.c $(LINUX_64_OBJS)
|
||||
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
|
||||
oclHashcat32.exe: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.WIN.32.o obj/ext_nvapi.oclHashcat.WIN.32.o obj/ext_ADL.oclHashcat.WIN.32.o obj/shared.oclHashcat.WIN.32.o obj/rp_kernel_on_cpu.oclHashcat.WIN.32.o lib/libOpenCL.a /usr/i686-w64-mingw32/lib/CRT_glob.o $(NVAPI)/x86/nvapi.lib
|
||||
$(CC_WIN_32) $(CFLAGS_CROSS) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(NOW) -static-libgcc
|
||||
oclHashcat32.exe: src/oclHashcat.c $(WIN_32_OBJS) lib/libOpenCL.a
|
||||
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(NOW) -static-libgcc
|
||||
|
||||
oclHashcat64.exe: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.WIN.64.o obj/ext_nvapi.oclHashcat.WIN.64.o obj/ext_ADL.oclHashcat.WIN.64.o obj/shared.oclHashcat.WIN.64.o obj/rp_kernel_on_cpu.oclHashcat.WIN.64.o lib/libOpenCL64.a /usr/x86_64-w64-mingw32/lib/CRT_glob.o $(NVAPI)/amd64/nvapi64.lib
|
||||
$(CC_WIN_64) $(CFLAGS_CROSS) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(NOW) -static-libgcc
|
||||
oclHashcat64.exe: src/oclHashcat.c $(WIN_64_OBJS) lib/libOpenCL64.a
|
||||
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(NOW) -static-libgcc
|
||||
|
144
src/oclHashcat.c
144
src/oclHashcat.c
@ -3,6 +3,10 @@
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifdef OSX
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <common.h>
|
||||
#include <shared.h>
|
||||
#include <rp_kernel_on_cpu.h>
|
||||
@ -215,7 +219,7 @@ static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
|
||||
1000,
|
||||
1100,
|
||||
2100,
|
||||
12800,
|
||||
12800,
|
||||
1500,
|
||||
12400,
|
||||
500,
|
||||
@ -385,7 +389,11 @@ const char *USAGE_BIG[] =
|
||||
" -c, --segment-size=NUM Size in MB to cache from the wordfile",
|
||||
" --bitmap-min=NUM Minimum number of bits allowed for bitmaps",
|
||||
" --bitmap-max=NUM Maximum number of bits allowed for bitmaps",
|
||||
#ifndef OSX
|
||||
" --cpu-affinity=STR Locks to CPU devices, separate with comma",
|
||||
#else
|
||||
" --cpu-affinity=STR Locks to CPU devices, separate with comma (disabled on OSX)",
|
||||
#endif
|
||||
" --opencl-platforms=STR OpenCL platforms to use, separate with comma",
|
||||
" -d, --opencl-devices=STR OpenCL devices to use, separate with comma",
|
||||
" --opencl-device-types=STR OpenCL device-types to use, separate with comma, see references below",
|
||||
@ -393,10 +401,14 @@ const char *USAGE_BIG[] =
|
||||
" -w, --workload-profile=NUM Enable a specific workload profile, see references below",
|
||||
" -n, --kernel-accel=NUM Workload tuning: 1, 8, 40, 80, 160",
|
||||
" -u, --kernel-loops=NUM Workload fine-tuning: 8 - 1024",
|
||||
#ifdef HAVE_HWMON
|
||||
" --gpu-temp-disable Disable temperature and fanspeed readings and triggers",
|
||||
" --gpu-temp-abort=NUM Abort session if GPU temperature reaches NUM degrees celsius",
|
||||
" --gpu-temp-retain=NUM Try to retain GPU temperature at NUM degrees celsius (AMD only)",
|
||||
#ifdef HAVE_ADL
|
||||
" --powertune-enable Enable automatic power tuning option (AMD OverDrive 6 only)",
|
||||
#endif
|
||||
#endif
|
||||
" --scrypt-tmto=NUM Manually override automatically calculated TMTO value for scrypt",
|
||||
"",
|
||||
"* Distributed:",
|
||||
@ -843,6 +855,7 @@ void status_display_automat ()
|
||||
* temperature
|
||||
*/
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
if (data.gpu_temp_disable == 0)
|
||||
{
|
||||
fprintf (out, "TEMP\t");
|
||||
@ -862,6 +875,7 @@ void status_display_automat ()
|
||||
|
||||
hc_thread_mutex_unlock (mux_adl);
|
||||
}
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
#ifdef _WIN
|
||||
fputc ('\r', out);
|
||||
@ -1507,6 +1521,7 @@ void status_display ()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
if (data.gpu_temp_disable == 0)
|
||||
{
|
||||
hc_thread_mutex_lock (mux_adl);
|
||||
@ -1557,6 +1572,7 @@ void status_display ()
|
||||
|
||||
hc_thread_mutex_unlock (mux_adl);
|
||||
}
|
||||
#endif // HAVE_HWMON
|
||||
}
|
||||
|
||||
static void status_benchmark ()
|
||||
@ -3366,13 +3382,15 @@ static void *thread_monitor (void *p)
|
||||
uint runtime_check = 0;
|
||||
uint remove_check = 0;
|
||||
uint status_check = 0;
|
||||
uint hwmon_check = 0;
|
||||
uint restore_check = 0;
|
||||
|
||||
uint restore_left = data.restore_timer;
|
||||
uint remove_left = data.remove_timer;
|
||||
uint status_left = data.status_timer;
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
uint hwmon_check = 0;
|
||||
|
||||
// these variables are mainly used for fan control (AMD only)
|
||||
|
||||
int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
|
||||
@ -3382,12 +3400,15 @@ static void *thread_monitor (void *p)
|
||||
int *temp_diff_old = (int *) mycalloc (data.devices_cnt, sizeof (int));
|
||||
int *temp_diff_sum = (int *) mycalloc (data.devices_cnt, sizeof (int));
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
int temp_threshold = 1; // degrees celcius
|
||||
|
||||
int fan_speed_min = 15; // in percentage
|
||||
int fan_speed_max = 100;
|
||||
#endif // HAVE_ADL
|
||||
|
||||
time_t last_temp_check_time;
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
uint sleep_time = 1;
|
||||
|
||||
@ -3411,15 +3432,20 @@ static void *thread_monitor (void *p)
|
||||
status_check = 1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
if (data.gpu_temp_disable == 0)
|
||||
{
|
||||
time (&last_temp_check_time);
|
||||
|
||||
hwmon_check = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((runtime_check == 0) && (remove_check == 0) && (status_check == 0) && (hwmon_check == 0) && (restore_check == 0))
|
||||
if ((runtime_check == 0) && (remove_check == 0) && (status_check == 0) && (restore_check == 0))
|
||||
{
|
||||
#ifdef HAVE_HWMON
|
||||
if (hwmon_check == 0)
|
||||
#endif
|
||||
return (p);
|
||||
}
|
||||
|
||||
@ -3429,6 +3455,7 @@ static void *thread_monitor (void *p)
|
||||
|
||||
if (data.devices_status != STATUS_RUNNING) continue;
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
if (hwmon_check == 1)
|
||||
{
|
||||
hc_thread_mutex_lock (mux_adl);
|
||||
@ -3460,6 +3487,7 @@ static void *thread_monitor (void *p)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
const int gpu_temp_retain = data.gpu_temp_retain;
|
||||
|
||||
if (gpu_temp_retain) // VENDOR_ID_AMD implied
|
||||
@ -3514,10 +3542,12 @@ static void *thread_monitor (void *p)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // HAVE_ADL
|
||||
}
|
||||
|
||||
hc_thread_mutex_unlock (mux_adl);
|
||||
}
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
if (restore_check == 1)
|
||||
{
|
||||
@ -3590,10 +3620,12 @@ static void *thread_monitor (void *p)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
myfree (fan_speed_chgd);
|
||||
|
||||
myfree (temp_diff_old);
|
||||
myfree (temp_diff_sum);
|
||||
#endif
|
||||
|
||||
p = NULL;
|
||||
|
||||
@ -4948,10 +4980,12 @@ static uint hlfmt_detect (FILE *fp, uint max_check)
|
||||
|
||||
// wrapper around mymalloc for ADL
|
||||
|
||||
#if defined(HAVE_HWMON) && defined(HAVE_ADL)
|
||||
void *__stdcall ADL_Main_Memory_Alloc (const int iSize)
|
||||
{
|
||||
return mymalloc (iSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, const uint dgst_shifts, char *digests_buf_ptr, const uint bitmap_mask, const uint bitmap_size, uint *bitmap_a, uint *bitmap_b, uint *bitmap_c, uint *bitmap_d, const u64 collisions_max)
|
||||
{
|
||||
@ -5109,7 +5143,9 @@ int main (int argc, char **argv)
|
||||
uint increment = INCREMENT;
|
||||
uint increment_min = INCREMENT_MIN;
|
||||
uint increment_max = INCREMENT_MAX;
|
||||
#ifndef OSX
|
||||
char *cpu_affinity = NULL;
|
||||
#endif
|
||||
char *opencl_devices = NULL;
|
||||
char *opencl_platforms = NULL;
|
||||
char *opencl_device_types = NULL;
|
||||
@ -5118,10 +5154,14 @@ int main (int argc, char **argv)
|
||||
uint workload_profile = WORKLOAD_PROFILE;
|
||||
uint kernel_accel = KERNEL_ACCEL;
|
||||
uint kernel_loops = KERNEL_LOOPS;
|
||||
#ifdef HAVE_HWMON
|
||||
uint gpu_temp_disable = GPU_TEMP_DISABLE;
|
||||
uint gpu_temp_abort = GPU_TEMP_ABORT;
|
||||
uint gpu_temp_retain = GPU_TEMP_RETAIN;
|
||||
#ifdef HAVE_ADL
|
||||
uint powertune_enable = POWERTUNE_ENABLE;
|
||||
#endif
|
||||
#endif
|
||||
uint logfile_disable = LOGFILE_DISABLE;
|
||||
uint segment_size = SEGMENT_SIZE;
|
||||
uint scrypt_tmto = SCRYPT_TMTO;
|
||||
@ -5267,7 +5307,9 @@ int main (int argc, char **argv)
|
||||
{"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC},
|
||||
{"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD},
|
||||
{"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT},
|
||||
#ifndef OSX
|
||||
{"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
|
||||
#endif
|
||||
{"opencl-devices", required_argument, 0, IDX_OPENCL_DEVICES},
|
||||
{"opencl-platforms", required_argument, 0, IDX_OPENCL_PLATFORMS},
|
||||
{"opencl-device-types", required_argument, 0, IDX_OPENCL_DEVICE_TYPES},
|
||||
@ -5275,10 +5317,14 @@ int main (int argc, char **argv)
|
||||
{"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE},
|
||||
{"kernel-accel", required_argument, 0, IDX_KERNEL_ACCEL},
|
||||
{"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS},
|
||||
#ifdef HAVE_HWMON
|
||||
{"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE},
|
||||
{"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
|
||||
{"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
|
||||
#ifdef HAVE_ADL
|
||||
{"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
|
||||
#endif
|
||||
#endif // HAVE_HWMON
|
||||
{"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
|
||||
{"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
|
||||
{"segment-size", required_argument, 0, IDX_SEGMENT_SIZE},
|
||||
@ -5303,12 +5349,11 @@ int main (int argc, char **argv)
|
||||
|
||||
char **rp_files = (char **) mycalloc (argc, sizeof (char *));
|
||||
|
||||
int option_index;
|
||||
int c;
|
||||
int option_index = 0;
|
||||
int c = -1;
|
||||
|
||||
optind = 1;
|
||||
optopt = 0;
|
||||
option_index = 0;
|
||||
|
||||
while (((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1) && optopt == 0)
|
||||
{
|
||||
@ -5499,8 +5544,10 @@ int main (int argc, char **argv)
|
||||
uint remove_timer_chgd = 0;
|
||||
uint increment_min_chgd = 0;
|
||||
uint increment_max_chgd = 0;
|
||||
uint gpu_temp_abort_chgd = 0;
|
||||
#if defined(HAVE_HWMON) && defined(HAVE_ADL)
|
||||
uint gpu_temp_retain_chgd = 0;
|
||||
uint gpu_temp_abort_chgd = 0;
|
||||
#endif
|
||||
|
||||
optind = 1;
|
||||
optopt = 0;
|
||||
@ -5571,7 +5618,9 @@ int main (int argc, char **argv)
|
||||
case IDX_HEX_CHARSET: hex_charset = 1; break;
|
||||
case IDX_HEX_SALT: hex_salt = 1; break;
|
||||
case IDX_HEX_WORDLIST: hex_wordlist = 1; break;
|
||||
#ifndef OSX
|
||||
case IDX_CPU_AFFINITY: cpu_affinity = optarg; break;
|
||||
#endif
|
||||
case IDX_OPENCL_DEVICES: opencl_devices = optarg; break;
|
||||
case IDX_OPENCL_PLATFORMS: opencl_platforms = optarg; break;
|
||||
case IDX_OPENCL_DEVICE_TYPES:
|
||||
@ -5583,12 +5632,22 @@ int main (int argc, char **argv)
|
||||
kernel_accel_chgd = 1; break;
|
||||
case IDX_KERNEL_LOOPS: kernel_loops = atoi (optarg);
|
||||
kernel_loops_chgd = 1; break;
|
||||
#ifdef HAVE_HWMON
|
||||
case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break;
|
||||
case IDX_GPU_TEMP_ABORT: gpu_temp_abort_chgd = 1;
|
||||
gpu_temp_abort = atoi (optarg); break;
|
||||
case IDX_GPU_TEMP_RETAIN: gpu_temp_retain_chgd = 1;
|
||||
gpu_temp_retain = atoi (optarg); break;
|
||||
case IDX_GPU_TEMP_ABORT: gpu_temp_abort = atoi (optarg);
|
||||
#ifdef HAVE_ADL
|
||||
gpu_temp_abort_chgd = 1;
|
||||
#endif
|
||||
break;
|
||||
case IDX_GPU_TEMP_RETAIN: gpu_temp_retain = atoi (optarg);
|
||||
#ifdef HAVE_ADL
|
||||
gpu_temp_retain_chgd = 1;
|
||||
#endif
|
||||
break;
|
||||
#ifdef HAVE_ADL
|
||||
case IDX_POWERTUNE_ENABLE: powertune_enable = 1; break;
|
||||
#endif
|
||||
#endif // HAVE_HWMON
|
||||
case IDX_LOGFILE_DISABLE: logfile_disable = 1; break;
|
||||
case IDX_TRUECRYPT_KEYFILES: truecrypt_keyfiles = optarg; break;
|
||||
case IDX_SEGMENT_SIZE: segment_size = atoi (optarg); break;
|
||||
@ -6299,7 +6358,9 @@ int main (int argc, char **argv)
|
||||
data.benchmark = benchmark;
|
||||
data.skip = skip;
|
||||
data.limit = limit;
|
||||
#if defined(HAVE_HWMON) && defined(HAVE_ADL)
|
||||
data.powertune_enable = powertune_enable;
|
||||
#endif
|
||||
data.logfile_disable = logfile_disable;
|
||||
data.truecrypt_keyfiles = truecrypt_keyfiles;
|
||||
data.scrypt_tmto = scrypt_tmto;
|
||||
@ -6308,10 +6369,12 @@ int main (int argc, char **argv)
|
||||
* cpu affinity
|
||||
*/
|
||||
|
||||
#ifndef OSX
|
||||
if (cpu_affinity)
|
||||
{
|
||||
set_cpu_affinity (cpu_affinity);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rp_gen_seed_chgd == 0)
|
||||
{
|
||||
@ -6375,9 +6438,11 @@ int main (int argc, char **argv)
|
||||
logfile_top_uint (force);
|
||||
logfile_top_uint (kernel_accel);
|
||||
logfile_top_uint (kernel_loops);
|
||||
#ifdef HAVE_HWMON
|
||||
logfile_top_uint (gpu_temp_abort);
|
||||
logfile_top_uint (gpu_temp_disable);
|
||||
logfile_top_uint (gpu_temp_retain);
|
||||
#endif
|
||||
logfile_top_uint (hash_mode);
|
||||
logfile_top_uint (hex_charset);
|
||||
logfile_top_uint (hex_salt);
|
||||
@ -6396,7 +6461,9 @@ int main (int argc, char **argv)
|
||||
logfile_top_uint (outfile_check_timer);
|
||||
logfile_top_uint (outfile_format);
|
||||
logfile_top_uint (potfile_disable);
|
||||
#if defined(HAVE_HWMON) && defined(HAVE_ADL)
|
||||
logfile_top_uint (powertune_enable);
|
||||
#endif
|
||||
logfile_top_uint (scrypt_tmto);
|
||||
logfile_top_uint (quiet);
|
||||
logfile_top_uint (remove);
|
||||
@ -6422,7 +6489,9 @@ int main (int argc, char **argv)
|
||||
logfile_top_uint64 (limit);
|
||||
logfile_top_uint64 (skip);
|
||||
logfile_top_char (separator);
|
||||
#ifndef OSX
|
||||
logfile_top_string (cpu_affinity);
|
||||
#endif
|
||||
logfile_top_string (custom_charset_1);
|
||||
logfile_top_string (custom_charset_2);
|
||||
logfile_top_string (custom_charset_3);
|
||||
@ -12421,6 +12490,8 @@ int main (int argc, char **argv)
|
||||
|
||||
hc_clGetPlatformInfo (platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL);
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||
if (strcmp (platform_vendor, CL_VENDOR_NV) == 0)
|
||||
{
|
||||
// make sure that we do not directly control the fan for NVidia
|
||||
@ -12429,6 +12500,8 @@ int main (int argc, char **argv)
|
||||
|
||||
data.gpu_temp_retain = gpu_temp_retain;
|
||||
}
|
||||
#endif // HAVE_NVML || HAVE_NVAPI
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -12789,11 +12862,15 @@ int main (int argc, char **argv)
|
||||
* OpenCL devices: allocate buffer for device specific information
|
||||
*/
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
int *temp_retain_fanspeed_value = (int *) mycalloc (devices_cnt, sizeof (int));
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (devices_cnt, sizeof (ADLOD6MemClockState));
|
||||
|
||||
int *od_power_control_status = (int *) mycalloc (devices_cnt, sizeof (int));
|
||||
#endif // ADL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* enable custom signal handler(s)
|
||||
@ -12812,6 +12889,7 @@ int main (int argc, char **argv)
|
||||
* User-defined GPU temp handling
|
||||
*/
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
if (gpu_temp_disable == 1)
|
||||
{
|
||||
gpu_temp_abort = 0;
|
||||
@ -12831,6 +12909,7 @@ int main (int argc, char **argv)
|
||||
data.gpu_temp_disable = gpu_temp_disable;
|
||||
data.gpu_temp_abort = gpu_temp_abort;
|
||||
data.gpu_temp_retain = gpu_temp_retain;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* inform the user
|
||||
@ -12863,6 +12942,7 @@ int main (int argc, char **argv)
|
||||
* Watchdog and Temperature balance
|
||||
*/
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
if (gpu_temp_abort == 0)
|
||||
{
|
||||
log_info ("Watchdog: Temperature abort trigger disabled");
|
||||
@ -12880,6 +12960,7 @@ int main (int argc, char **argv)
|
||||
{
|
||||
log_info ("Watchdog: Temperature retain trigger set to %uc", gpu_temp_retain);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (data.quiet == 0) log_info ("");
|
||||
@ -12888,12 +12969,18 @@ int main (int argc, char **argv)
|
||||
* HM devices: init
|
||||
*/
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||
hm_attrs_t hm_adapters_nv[DEVICES_MAX] = { { { 0 }, 0, 0 } };
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
hm_attrs_t hm_adapters_amd[DEVICES_MAX] = { { { 0 }, 0, 0 } };
|
||||
#endif
|
||||
|
||||
if (gpu_temp_disable == 0)
|
||||
{
|
||||
#ifdef WIN
|
||||
#if defined(WIN) && defined(HAVE_NVAPI)
|
||||
if (NvAPI_Initialize () == NVAPI_OK)
|
||||
{
|
||||
HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX];
|
||||
@ -12914,9 +13001,9 @@ int main (int argc, char **argv)
|
||||
if (NvAPI_GPU_GetTachReading (hm_adapters_nv[i].adapter_index.nv, &speed) != NVAPI_NOT_SUPPORTED) hm_adapters_nv[i].fan_supported = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // WIN && HAVE_NVAPI
|
||||
|
||||
#ifdef LINUX
|
||||
#if defined(LINUX) && defined(HAVE_NVML)
|
||||
HM_LIB hm_dll_nv = hm_init (VENDOR_ID_NV);
|
||||
|
||||
data.hm_dll_nv = hm_dll_nv;
|
||||
@ -12944,8 +13031,9 @@ int main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // LINUX && HAVE_NVML
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
HM_LIB hm_dll_amd = hm_init (VENDOR_ID_AMD);
|
||||
|
||||
data.hm_dll_amd = hm_dll_amd;
|
||||
@ -12990,6 +13078,7 @@ int main (int argc, char **argv)
|
||||
myfree (lpAdapterInfo);
|
||||
}
|
||||
}
|
||||
#endif // HAVE_ADL
|
||||
}
|
||||
|
||||
/**
|
||||
@ -13008,15 +13097,19 @@ int main (int argc, char **argv)
|
||||
|
||||
const uint platform_devices_id = device_param->platform_devices_id;
|
||||
|
||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||
if (device_param->vendor_id == VENDOR_ID_NV)
|
||||
{
|
||||
memcpy (&data.hm_device[device_id], &hm_adapters_nv[platform_devices_id], sizeof (hm_attrs_t));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
if (device_param->vendor_id == VENDOR_ID_AMD)
|
||||
{
|
||||
memcpy (&data.hm_device[device_id], &hm_adapters_amd[platform_devices_id], sizeof (hm_attrs_t));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -13028,6 +13121,7 @@ int main (int argc, char **argv)
|
||||
* Driver / ADL bug?
|
||||
*/
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
if (powertune_enable == 1)
|
||||
{
|
||||
hc_thread_mutex_lock (mux_adl);
|
||||
@ -13077,6 +13171,8 @@ int main (int argc, char **argv)
|
||||
|
||||
hc_thread_mutex_unlock (mux_adl);
|
||||
}
|
||||
#endif // HAVE_ADK
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
uint kernel_blocks_all = 0;
|
||||
|
||||
@ -14092,6 +14188,7 @@ int main (int argc, char **argv)
|
||||
* Store initial fanspeed if gpu_temp_retain is enabled
|
||||
*/
|
||||
|
||||
#if defined(HAVE_HWMON) && defined(HAVE_ADL)
|
||||
int gpu_temp_retain_set = 0;
|
||||
|
||||
if (gpu_temp_disable == 0)
|
||||
@ -14262,6 +14359,7 @@ int main (int argc, char **argv)
|
||||
|
||||
hc_thread_mutex_unlock (mux_adl);
|
||||
}
|
||||
#endif // HAVE_HWMON && HAVE_ADL
|
||||
}
|
||||
|
||||
data.kernel_blocks_all = kernel_blocks_all;
|
||||
@ -16365,8 +16463,10 @@ int main (int argc, char **argv)
|
||||
|
||||
// reset default fan speed
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
if (gpu_temp_disable == 0)
|
||||
{
|
||||
#ifdef HAVE_ADL
|
||||
if (gpu_temp_retain != 0) // VENDOR_ID_AMD is implied here
|
||||
{
|
||||
hc_thread_mutex_lock (mux_adl);
|
||||
@ -16391,10 +16491,12 @@ int main (int argc, char **argv)
|
||||
|
||||
hc_thread_mutex_unlock (mux_adl);
|
||||
}
|
||||
#endif // HAVE_ADL
|
||||
}
|
||||
|
||||
// reset power tuning
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
if (powertune_enable == 1) // VENDOR_ID_AMD is implied here
|
||||
{
|
||||
hc_thread_mutex_lock (mux_adl);
|
||||
@ -16454,10 +16556,11 @@ int main (int argc, char **argv)
|
||||
|
||||
hc_thread_mutex_unlock (mux_adl);
|
||||
}
|
||||
#endif // HAVE_ADL
|
||||
|
||||
if (gpu_temp_disable == 0)
|
||||
{
|
||||
#ifdef LINUX
|
||||
#if defined(LINUX) && defined(HAVE_NVML)
|
||||
if (data.hm_dll_nv)
|
||||
{
|
||||
hc_NVML_nvmlShutdown (data.hm_dll_nv);
|
||||
@ -16466,17 +16569,20 @@ int main (int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WIN
|
||||
#if defined(WIN) && (HAVE_NVAPI)
|
||||
NvAPI_Unload ();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
if (data.hm_dll_amd)
|
||||
{
|
||||
hc_ADL_Main_Control_Destroy (data.hm_dll_amd);
|
||||
|
||||
hm_close (data.hm_dll_amd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
// free memory
|
||||
|
||||
@ -16515,9 +16621,13 @@ int main (int argc, char **argv)
|
||||
local_free (bitmap_s2_c);
|
||||
local_free (bitmap_s2_d);
|
||||
|
||||
#ifdef HAVE_HWMON
|
||||
local_free (temp_retain_fanspeed_value);
|
||||
#ifdef HAVE_ADL
|
||||
local_free (od_clock_mem_status);
|
||||
local_free (od_power_control_status);
|
||||
#endif // ADL
|
||||
#endif
|
||||
|
||||
global_free (devices_param);
|
||||
|
||||
|
122
src/shared.c
122
src/shared.c
@ -1,8 +1,14 @@
|
||||
/**
|
||||
* Author......: Jens Steube <jens.steube@gmail.com>
|
||||
* Authors.....: Jens Steube <jens.steube@gmail.com>
|
||||
* Gabriele Gristina <matrix@hashcat.net>
|
||||
*
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifdef OSX
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <shared.h>
|
||||
#include <limits.h>
|
||||
|
||||
@ -2634,7 +2640,8 @@ void fsync (int fd)
|
||||
* thermal
|
||||
*/
|
||||
|
||||
#ifdef _WIN
|
||||
#ifdef HAVE_HWMON
|
||||
#if defined(_WIN) && defined(HAVE_NVAPI)
|
||||
int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
|
||||
{
|
||||
NvU32 pGpuCount;
|
||||
@ -2650,9 +2657,9 @@ int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
|
||||
|
||||
return (pGpuCount);
|
||||
}
|
||||
#endif
|
||||
#endif // _WIN && HAVE_NVAPI
|
||||
|
||||
#ifdef LINUX
|
||||
#if defined(LINUX) && defined(HAVE_NVML)
|
||||
int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
|
||||
{
|
||||
int pGpuCount = 0;
|
||||
@ -2677,8 +2684,9 @@ int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
|
||||
|
||||
return (pGpuCount);
|
||||
}
|
||||
#endif
|
||||
#endif // LINUX && HAVE_NVML
|
||||
|
||||
#if defined(HAVE_ADL) || defined(HAVE_NVML)
|
||||
void hm_close (HM_LIB hm_dll)
|
||||
{
|
||||
#ifdef _POSIX
|
||||
@ -2694,6 +2702,7 @@ HM_LIB hm_init (const cl_uint vendor_id)
|
||||
{
|
||||
HM_LIB hm_dll = NULL;
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
if (vendor_id == VENDOR_ID_AMD)
|
||||
{
|
||||
#ifdef _POSIX
|
||||
@ -2709,8 +2718,9 @@ HM_LIB hm_init (const cl_uint vendor_id)
|
||||
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#if defined(LINUX) && defined(HAVE_NVML)
|
||||
if (vendor_id == VENDOR_ID_NV)
|
||||
{
|
||||
hm_dll = dlopen ("libnvidia-ml.so", RTLD_LAZY | RTLD_GLOBAL);
|
||||
@ -2719,7 +2729,9 @@ HM_LIB hm_init (const cl_uint vendor_id)
|
||||
|
||||
return hm_dll;
|
||||
}
|
||||
#endif // HAVE_ADL || HAVE_NVML
|
||||
|
||||
#ifdef HAVE_ADL
|
||||
int get_adapters_num_amd (HM_LIB hm_dll_amd, int *iNumberAdapters)
|
||||
{
|
||||
if (hc_ADL_Adapter_NumberOfAdapters_Get (hm_dll_amd, iNumberAdapters) != ADL_OK) return -1;
|
||||
@ -3058,11 +3070,13 @@ int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list,
|
||||
|
||||
return num_adl_adapters;
|
||||
}
|
||||
#endif // HAVE_ADL
|
||||
|
||||
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].vendor_id == VENDOR_ID_AMD)
|
||||
{
|
||||
if (data.hm_dll_amd)
|
||||
@ -3087,9 +3101,12 @@ int hm_get_temperature_with_device_id (const uint device_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||
if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
|
||||
{
|
||||
#ifdef LINUX
|
||||
#if defined(LINUX) && defined(HAVE_NVML)
|
||||
int temperature = 0;
|
||||
|
||||
hc_NVML_nvmlDeviceGetTemperature (data.hm_dll_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (unsigned int *) &temperature);
|
||||
@ -3097,7 +3114,7 @@ int hm_get_temperature_with_device_id (const uint device_id)
|
||||
return temperature;
|
||||
#endif
|
||||
|
||||
#ifdef WIN
|
||||
#if defined(WIN) && defined(HAVE_NVAPI)
|
||||
NV_GPU_THERMAL_SETTINGS pThermalSettings;
|
||||
|
||||
pThermalSettings.version = NV_GPU_THERMAL_SETTINGS_VER;
|
||||
@ -3108,8 +3125,9 @@ int hm_get_temperature_with_device_id (const uint device_id)
|
||||
if (hc_NvAPI_GPU_GetThermalSettings (data.hm_device[device_id].adapter_index.nv, 0, &pThermalSettings) != NVAPI_OK) return -1;
|
||||
|
||||
return pThermalSettings.sensor[0].currentTemp;
|
||||
#endif
|
||||
#endif // WIN && HAVE_NVAPI
|
||||
}
|
||||
#endif // HAVE_NVML || HAVE_NVAPI
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -3121,6 +3139,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
|
||||
|
||||
if (data.hm_device[device_id].fan_supported == 1)
|
||||
{
|
||||
#ifdef HAVE_ADL
|
||||
if (data.devices_param[device_id].vendor_id == VENDOR_ID_AMD)
|
||||
{
|
||||
if (data.hm_dll_amd)
|
||||
@ -3151,9 +3170,12 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
|
||||
#endif // HAVE_ADL
|
||||
|
||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||
if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
|
||||
{
|
||||
#ifdef LINUX
|
||||
#if defined(LINUX) && defined(HAVE_NVML)
|
||||
int speed = 0;
|
||||
|
||||
hc_NVML_nvmlDeviceGetFanSpeed (data.hm_dll_nv, 1, data.hm_device[device_id].adapter_index.nv, (unsigned int *) &speed);
|
||||
@ -3161,7 +3183,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
|
||||
return speed;
|
||||
#endif
|
||||
|
||||
#ifdef WIN
|
||||
#if defined(WIN) && defined(HAVE_NVAPI)
|
||||
NvU32 speed = 0;
|
||||
|
||||
hc_NvAPI_GPU_GetTachReading (data.hm_device[device_id].adapter_index.nv, &speed);
|
||||
@ -3169,6 +3191,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
|
||||
return speed;
|
||||
#endif
|
||||
}
|
||||
#endif // HAVE_NVML || HAVE_NVAPI
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -3178,6 +3201,7 @@ 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].vendor_id == VENDOR_ID_AMD)
|
||||
{
|
||||
if (data.hm_dll_amd)
|
||||
@ -3191,9 +3215,12 @@ int hm_get_utilization_with_device_id (const uint device_id)
|
||||
return PMActivity.iActivityPercent;
|
||||
}
|
||||
}
|
||||
else if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
|
||||
#endif // HAVE_ADL
|
||||
|
||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||
if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
|
||||
{
|
||||
#ifdef LINUX
|
||||
#if defined(LINUX) && defined(HAVE_NVML)
|
||||
nvmlUtilization_t utilization;
|
||||
|
||||
hc_NVML_nvmlDeviceGetUtilizationRates (data.hm_dll_nv, data.hm_device[device_id].adapter_index.nv, &utilization);
|
||||
@ -3201,7 +3228,7 @@ int hm_get_utilization_with_device_id (const uint device_id)
|
||||
return utilization.gpu;
|
||||
#endif
|
||||
|
||||
#ifdef WIN
|
||||
#if defined(WIN) && defined(HAVE_NVAPI)
|
||||
NV_GPU_DYNAMIC_PSTATES_INFO_EX pDynamicPstatesInfoEx;
|
||||
|
||||
pDynamicPstatesInfoEx.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER;
|
||||
@ -3211,10 +3238,12 @@ int hm_get_utilization_with_device_id (const uint device_id)
|
||||
return pDynamicPstatesInfoEx.utilization[0].percentage;
|
||||
#endif
|
||||
}
|
||||
#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)
|
||||
{
|
||||
if (data.hm_device[device_id].fan_supported == 1)
|
||||
@ -3254,6 +3283,7 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// helper function for status display
|
||||
|
||||
@ -3270,6 +3300,7 @@ void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int
|
||||
snprintf (target_buf, max_buf_size, "%2d%s", value, suffix);
|
||||
}
|
||||
}
|
||||
#endif // HAVE_HWMON
|
||||
|
||||
/**
|
||||
* maskprocessor
|
||||
@ -4105,12 +4136,25 @@ char *get_exec_path ()
|
||||
|
||||
const int len = readlink (tmp, exec_path, exec_path_len - 1);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WIN
|
||||
#elif WIN
|
||||
|
||||
const int len = GetModuleFileName (NULL, exec_path, exec_path_len - 1);
|
||||
|
||||
#elif OSX
|
||||
|
||||
uint size = exec_path_len;
|
||||
|
||||
if (_NSGetExecutablePath (exec_path, &size) != 0)
|
||||
{
|
||||
log_error("! executable path buffer too small\n");
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
const int len = strlen (exec_path);
|
||||
|
||||
#else
|
||||
#error Your Operating System is not supported or detected
|
||||
#endif
|
||||
|
||||
exec_path[len] = 0;
|
||||
@ -4204,11 +4248,8 @@ void set_cpu_affinity (char *cpu_affinity)
|
||||
{
|
||||
#ifdef WIN
|
||||
DWORD_PTR aff_mask = 0;
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#elif LINUX
|
||||
cpu_set_t cpuset;
|
||||
|
||||
CPU_ZERO (&cpuset);
|
||||
#endif
|
||||
|
||||
@ -4226,9 +4267,7 @@ void set_cpu_affinity (char *cpu_affinity)
|
||||
{
|
||||
#ifdef WIN
|
||||
aff_mask = 0;
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#elif LINUX
|
||||
CPU_ZERO (&cpuset);
|
||||
#endif
|
||||
|
||||
@ -4244,9 +4283,7 @@ void set_cpu_affinity (char *cpu_affinity)
|
||||
|
||||
#ifdef WIN
|
||||
aff_mask |= 1 << (cpu_id - 1);
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#elif LINUX
|
||||
CPU_SET ((cpu_id - 1), &cpuset);
|
||||
#endif
|
||||
|
||||
@ -4258,9 +4295,7 @@ void set_cpu_affinity (char *cpu_affinity)
|
||||
#ifdef WIN
|
||||
SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
|
||||
SetThreadAffinityMask (GetCurrentThread (), aff_mask);
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#elif LINUX
|
||||
pthread_t thread = pthread_self ();
|
||||
pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset);
|
||||
#endif
|
||||
@ -4472,7 +4507,7 @@ int sort_by_dictstat (const void *s1, const void *s2)
|
||||
dictstat_t *d1 = (dictstat_t *) s1;
|
||||
dictstat_t *d2 = (dictstat_t *) s2;
|
||||
|
||||
#ifdef _POSIX
|
||||
#ifdef LINUX
|
||||
d2->stat.st_atim = d1->stat.st_atim;
|
||||
#else
|
||||
d2->stat.st_atime = d1->stat.st_atime;
|
||||
@ -4835,7 +4870,7 @@ void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const
|
||||
|
||||
#ifdef _POSIX
|
||||
#ifdef __x86_64__
|
||||
fprintf (out_fp, "%lu", crackpos);
|
||||
fprintf (out_fp, "%lu", (unsigned long) crackpos);
|
||||
#else
|
||||
fprintf (out_fp, "%llu", crackpos);
|
||||
#endif
|
||||
@ -5405,14 +5440,31 @@ char **scan_directory (const char *path)
|
||||
|
||||
int num_files = 0;
|
||||
|
||||
DIR *d;
|
||||
DIR *d = NULL;
|
||||
|
||||
if ((d = opendir (tmp_path)) != NULL)
|
||||
{
|
||||
#ifdef OSX
|
||||
struct dirent e;
|
||||
|
||||
for (;;) {
|
||||
memset (&e, 0, sizeof (e));
|
||||
struct dirent *de = NULL;
|
||||
|
||||
if (readdir_r (d, &e, &de) != 0)
|
||||
{
|
||||
log_error ("ERROR: readdir_r() failed");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user