diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index 8243e7f77..e44b6e0ac 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -126,7 +126,7 @@ _hashcat_get_permutations () fi } -_hashcat_opencl_devices () +_hashcat_backend_devices () { local num_devices=0 @@ -180,7 +180,7 @@ _hashcat () local HCCAPX_MESSAGE_PAIRS="0 1 2 3 4 5" local OUTFILE_FORMATS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" local OPENCL_DEVICE_TYPES="1 2 3" - local OPENCL_VECTOR_WIDTH="1 2 4 8 16" + local BACKEND_VECTOR_WIDTH="1 2 4 8 16" local DEBUG_MODE="1 2 3 4" local WORKLOAD_PROFILE="1 2 3 4" local BRAIN_CLIENT_FEATURES="1 2 3" @@ -189,8 +189,8 @@ _hashcat () local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H' local SHORT_OPTS="-m -a -V -v -h -b -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z" - local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --opencl-info --opencl-devices --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" - local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-whitelist-session --stdin-timeout-abort" + local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" + local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-whitelist-session --stdin-timeout-abort" COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" @@ -250,8 +250,8 @@ _hashcat () return 0 ;; - -d|--opencl-devices) - _hashcat_opencl_devices + -d|--backend-devices) + _hashcat_backend_devices local num_devices=${?} _hashcat_get_permutations ${num_devices} @@ -265,8 +265,8 @@ _hashcat () return 0 ;; - --opencl-vector-width) - COMPREPLY=($(compgen -W "${OPENCL_VECTOR_WIDTH}" -- ${cur})) + --backend-vector-width) + COMPREPLY=($(compgen -W "${BACKEND_VECTOR_WIDTH}" -- ${cur})) return 0 ;; @@ -443,13 +443,13 @@ _hashcat () ;; -d*) - _hashcat_opencl_devices + _hashcat_backend_devices local num_devices=${?} _hashcat_get_permutations ${num_devices} - local opencl_devices_var="$(echo " "${hashcat_devices_permutation} | sed 's/ / -d/g')" - COMPREPLY=($(compgen -W "${opencl_devices_var}" -- ${cur})) + local backend_devices_var="$(echo " "${hashcat_devices_permutation} | sed 's/ / -d/g')" + COMPREPLY=($(compgen -W "${backend_devices_var}" -- ${cur})) return 0 ;; esac diff --git a/include/terminal.h b/include/terminal.h index 1687b9a9e..e15d4ef9c 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -43,8 +43,8 @@ void compress_terminal_line_length (char *out_buf, const size_t keep_from_beginn void example_hashes (hashcat_ctx_t *hashcat_ctx); -void opencl_info (hashcat_ctx_t *hashcat_ctx); -void opencl_info_compact (hashcat_ctx_t *hashcat_ctx); +void backend_info (hashcat_ctx_t *hashcat_ctx); +void backend_info_compact (hashcat_ctx_t *hashcat_ctx); void status_progress_machine_readable (hashcat_ctx_t *hashcat_ctx); void status_progress (hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 8052bea6f..9bd78be0c 100644 --- a/include/types.h +++ b/include/types.h @@ -44,13 +44,6 @@ typedef int16_t i16; typedef int32_t i32; typedef int64_t i64; -// import types from opencl - -//typedef uint8_t uchar; -//typedef uint16_t ushort; -//typedef uint32_t uint; -//typedef uint64_t ulong; - #include "inc_types.h" // there's no such thing in plain C, therefore all vector operation cannot work in this emu @@ -133,10 +126,10 @@ typedef enum event_identifier EVENT_MONITOR_PERFORMANCE_HINT = 0x00000086, EVENT_MONITOR_NOINPUT_HINT = 0x00000087, EVENT_MONITOR_NOINPUT_ABORT = 0x00000088, - EVENT_OPENCL_SESSION_POST = 0x00000090, - EVENT_OPENCL_SESSION_PRE = 0x00000091, - EVENT_OPENCL_DEVICE_INIT_POST = 0x00000092, - EVENT_OPENCL_DEVICE_INIT_PRE = 0x00000093, + EVENT_BACKEND_SESSION_POST = 0x00000090, + EVENT_BACKEND_SESSION_PRE = 0x00000091, + EVENT_BACKEND_DEVICE_INIT_POST = 0x00000092, + EVENT_BACKEND_DEVICE_INIT_PRE = 0x00000093, EVENT_OUTERLOOP_FINISHED = 0x000000a0, EVENT_OUTERLOOP_MAINSCREEN = 0x000000a1, EVENT_OUTERLOOP_STARTING = 0x000000a2, @@ -592,8 +585,8 @@ typedef enum user_options_defaults MARKOV_DISABLE = false, MARKOV_THRESHOLD = 0, NONCE_ERROR_CORRECTIONS = 8, - OPENCL_INFO = false, - OPENCL_VECTOR_WIDTH = 0, + BACKEND_INFO = false, + BACKEND_VECTOR_WIDTH = 0, OPTIMIZED_KERNEL_ENABLE = false, OUTFILE_AUTOHEX = true, OUTFILE_CHECK_TIMER = 5, @@ -637,6 +630,9 @@ typedef enum user_options_map { IDX_ADVICE_DISABLE = 0xff00, IDX_ATTACK_MODE = 'a', + IDX_BACKEND_DEVICES = 'd', + IDX_BACKEND_INFO = 'I', + IDX_BACKEND_VECTOR_WIDTH = 0xff27, IDX_BENCHMARK_ALL = 0xff01, IDX_BENCHMARK = 'b', IDX_BITMAP_MAX = 0xff02, @@ -690,10 +686,7 @@ typedef enum user_options_map IDX_MARKOV_HCSTAT2 = 0xff24, IDX_MARKOV_THRESHOLD = 't', IDX_NONCE_ERROR_CORRECTIONS = 0xff25, - IDX_OPENCL_DEVICES = 'd', IDX_OPENCL_DEVICE_TYPES = 'D', - IDX_OPENCL_INFO = 'I', - IDX_OPENCL_VECTOR_WIDTH = 0xff27, IDX_OPTIMIZED_KERNEL_ENABLE = 'O', IDX_OUTFILE_AUTOHEX_DISABLE = 0xff28, IDX_OUTFILE_CHECK_DIR = 0xff29, @@ -1004,8 +997,6 @@ typedef struct hc_device_param u8 pcie_device; u8 pcie_function; - u32 opencl_platform_devices_id; // for mapping with hms devices - bool skipped; // permanent bool skipped_warning; // iteration @@ -1267,7 +1258,7 @@ typedef struct hc_device_param char *opencl_device_version; char *opencl_device_c_version; - cl_platform_id opencl_platform; + //cl_platform_id opencl_platform; cl_device_type opencl_device_type; cl_uint opencl_device_vendor_id; cl_uint opencl_platform_vendor_id; @@ -1361,6 +1352,8 @@ typedef struct backend_ctx int opencl_devices_cnt; int opencl_devices_active; + u64 backend_devices_filter; + hc_device_param_t *devices_param; u32 hardware_power_all; @@ -1368,8 +1361,6 @@ typedef struct backend_ctx u64 kernel_power_all; u64 kernel_power_final; // we save that so that all divisions are done from the same base - u64 devices_filter; - double target_msec; bool need_adl; @@ -1393,6 +1384,7 @@ typedef struct backend_ctx cl_uint *opencl_platforms_devices_cnt; char **opencl_platforms_name; char **opencl_platforms_vendor; + cl_uint *opencl_platforms_vendor_id; char **opencl_platforms_version; cl_device_type opencl_device_types_filter; @@ -1718,7 +1710,7 @@ typedef struct user_options bool kernel_threads_chgd; bool nonce_error_corrections_chgd; bool spin_damp_chgd; - bool opencl_vector_width_chgd; + bool backend_vector_width_chgd; bool outfile_format_chgd; bool remove_timer_chgd; bool rp_gen_seed_chgd; @@ -1750,7 +1742,7 @@ typedef struct user_options bool machine_readable; bool markov_classic; bool markov_disable; - bool opencl_info; + bool backend_info; bool optimized_kernel_enable; bool outfile_autohex; bool potfile_disable; @@ -1782,7 +1774,7 @@ typedef struct user_options char *induction_dir; char *keyboard_layout_mapping; char *markov_hcstat2; - char *opencl_devices; + char *backend_devices; char *opencl_device_types; char *outfile; char *outfile_check_dir; @@ -1821,7 +1813,7 @@ typedef struct user_options u32 markov_threshold; u32 nonce_error_corrections; u32 spin_damp; - u32 opencl_vector_width; + u32 backend_vector_width; u32 outfile_check_timer; u32 outfile_format; u32 remove_timer; diff --git a/src/backend.c b/src/backend.c index 72e084762..b5d743f8b 100644 --- a/src/backend.c +++ b/src/backend.c @@ -182,13 +182,13 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) return 0; } -static bool setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_devices, u64 *out) +static bool setup_backend_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *backend_devices, u64 *out) { u64 backend_devices_filter = 0; - if (opencl_devices) + if (backend_devices) { - char *devices = hcstrdup (opencl_devices); + char *devices = hcstrdup (backend_devices); if (devices == NULL) return false; @@ -378,8 +378,8 @@ static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f if (force_recompile == true) { - // this adds some hopefully unique data to the opencl kernel source - // the effect should be that opencl kernel compiler caching see this as new "uncached" source + // this adds some hopefully unique data to the backend kernel source + // the effect should be that backend kernel compiler caching see this as new "uncached" source // we have to do this since they do not check for the changes only in the #include source time_t tlog = time (NULL); @@ -3356,7 +3356,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co } else { - // it's unclear if 4s is enough to turn on boost mode for all opencl device + // it's unclear if 4s is enough to turn on boost mode for all backend device if ((total_msec > 4000) || (device_param->speed_pos == SPEED_CACHE - 1)) { @@ -3546,19 +3546,19 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) if (rc_ocl_check == -1) return -1; /** - * OpenCL device selection (tbd rename) + * Backend device selection */ - u64 devices_filter; + u64 backend_devices_filter; - const bool rc_devices_filter = setup_devices_filter (hashcat_ctx, user_options->opencl_devices, &devices_filter); + const bool rc_backend_devices_filter = setup_backend_devices_filter (hashcat_ctx, user_options->backend_devices, &backend_devices_filter); - if (rc_devices_filter == false) return -1; + if (rc_backend_devices_filter == false) return -1; - backend_ctx->devices_filter = devices_filter; + backend_ctx->backend_devices_filter = backend_devices_filter; /** - * OpenCL device type selection (tbd rename) + * OpenCL device type selection */ cl_device_type opencl_device_types_filter; @@ -3596,6 +3596,7 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) hcfree (opencl_platforms_devices_cnt); \ hcfree (opencl_platforms_name); \ hcfree (opencl_platforms_vendor); \ + hcfree (opencl_platforms_vendor_id); \ hcfree (opencl_platforms_version); \ } @@ -3605,6 +3606,7 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) cl_uint *opencl_platforms_devices_cnt = (cl_uint *) hccalloc (CL_PLATFORMS_MAX, sizeof (cl_uint)); char **opencl_platforms_name = (char **) hccalloc (CL_PLATFORMS_MAX, sizeof (char *)); char **opencl_platforms_vendor = (char **) hccalloc (CL_PLATFORMS_MAX, sizeof (char *)); + cl_uint *opencl_platforms_vendor_id = (cl_uint *) hccalloc (CL_PLATFORMS_MAX, sizeof (cl_uint)); char **opencl_platforms_version = (char **) hccalloc (CL_PLATFORMS_MAX, sizeof (char *)); int CL_rc = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, opencl_platforms, &opencl_platforms_cnt); @@ -3620,6 +3622,123 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) if (opencl_platforms_cnt) { + for (u32 opencl_platforms_idx = 0; opencl_platforms_idx < opencl_platforms_cnt; opencl_platforms_idx++) + { + cl_platform_id opencl_platform = opencl_platforms[opencl_platforms_idx]; + + size_t param_value_size = 0; + + // platform vendor + + int CL_rc; + + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VENDOR, 0, NULL, ¶m_value_size); + + if (CL_rc == -1) return -1; + + char *opencl_platform_vendor = (char *) hcmalloc (param_value_size); + + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VENDOR, param_value_size, opencl_platform_vendor, NULL); + + if (CL_rc == -1) return -1; + + opencl_platforms_vendor[opencl_platforms_idx] = opencl_platform_vendor; + + // platform name + + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_NAME, 0, NULL, ¶m_value_size); + + if (CL_rc == -1) return -1; + + char *opencl_platform_name = (char *) hcmalloc (param_value_size); + + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_NAME, param_value_size, opencl_platform_name, NULL); + + if (CL_rc == -1) return -1; + + opencl_platforms_name[opencl_platforms_idx] = opencl_platform_name; + + // platform version + + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VERSION, 0, NULL, ¶m_value_size); + + if (CL_rc == -1) return -1; + + char *opencl_platform_version = (char *) hcmalloc (param_value_size); + + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VERSION, param_value_size, opencl_platform_version, NULL); + + if (CL_rc == -1) return -1; + + opencl_platforms_version[opencl_platforms_idx] = opencl_platform_version; + + // find our own platform vendor because pocl and mesa are pushing original vendor_id through opencl + // this causes trouble with vendor id based macros + // we'll assign generic to those without special optimization available + + cl_uint opencl_platform_vendor_id = 0; + + if (strcmp (opencl_platform_vendor, CL_VENDOR_AMD1) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_AMD; + } + else if (strcmp (opencl_platform_vendor, CL_VENDOR_AMD2) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_AMD; + } + else if (strcmp (opencl_platform_vendor, CL_VENDOR_AMD_USE_INTEL) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_AMD_USE_INTEL; + } + else if (strcmp (opencl_platform_vendor, CL_VENDOR_APPLE) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_APPLE; + } + else if (strcmp (opencl_platform_vendor, CL_VENDOR_INTEL_BEIGNET) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_INTEL_BEIGNET; + } + else if (strcmp (opencl_platform_vendor, CL_VENDOR_INTEL_SDK) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_INTEL_SDK; + } + else if (strcmp (opencl_platform_vendor, CL_VENDOR_MESA) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_MESA; + } + else if (strcmp (opencl_platform_vendor, CL_VENDOR_NV) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_NV; + } + else if (strcmp (opencl_platform_vendor, CL_VENDOR_POCL) == 0) + { + opencl_platform_vendor_id = VENDOR_ID_POCL; + } + else + { + opencl_platform_vendor_id = VENDOR_ID_GENERIC; + } + + opencl_platforms_vendor_id[opencl_platforms_idx] = opencl_platform_vendor_id; + + cl_device_id *opencl_platform_devices = (cl_device_id *) hccalloc (DEVICES_MAX, sizeof (cl_device_id)); + + cl_uint opencl_platform_devices_cnt = 0; + + CL_rc = hc_clGetDeviceIDs (hashcat_ctx, opencl_platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, opencl_platform_devices, &opencl_platform_devices_cnt); + + if (CL_rc == -1) + { + event_log_error (hashcat_ctx, "clGetDeviceIDs(): %s", val2cstr_cl (CL_rc)); + + return -1; + } + + opencl_platforms_devices[opencl_platforms_idx] = opencl_platform_devices; + + opencl_platforms_devices_cnt[opencl_platforms_idx] = opencl_platform_devices_cnt; + } + if (user_options->opencl_device_types == NULL) { /** @@ -3631,22 +3750,8 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) for (u32 opencl_platforms_idx = 0; opencl_platforms_idx < opencl_platforms_cnt; opencl_platforms_idx++) { - cl_platform_id opencl_platform = opencl_platforms[opencl_platforms_idx]; - - cl_device_id *opencl_platform_devices = (cl_device_id *) hccalloc (DEVICES_MAX, sizeof (cl_device_id)); - - cl_uint opencl_platform_devices_cnt = 0; - - CL_rc = hc_clGetDeviceIDs (hashcat_ctx, opencl_platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, opencl_platform_devices, &opencl_platform_devices_cnt); - - if (CL_rc == -1) - { - hcfree (opencl_platform_devices); - - FREE_OPENCL_CTX_ON_ERROR; - - continue; - } + cl_device_id *opencl_platform_devices = opencl_platforms_devices[opencl_platforms_idx]; + cl_uint opencl_platform_devices_cnt = opencl_platforms_devices_cnt[opencl_platforms_idx]; for (u32 opencl_platform_devices_idx = 0; opencl_platform_devices_idx < opencl_platform_devices_cnt; opencl_platform_devices_idx++) { @@ -3665,8 +3770,6 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) opencl_device_types_all |= opencl_device_type; } - - hcfree (opencl_platform_devices); } // In such a case, automatically enable CPU device type support, since it's disabled by default. @@ -3697,6 +3800,7 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) backend_ctx->opencl_platforms_devices_cnt = opencl_platforms_devices_cnt; backend_ctx->opencl_platforms_name = opencl_platforms_name; backend_ctx->opencl_platforms_vendor = opencl_platforms_vendor; + backend_ctx->opencl_platforms_vendor_id = opencl_platforms_vendor_id; backend_ctx->opencl_platforms_version = opencl_platforms_version; #undef FREE_OPENCL_CTX_ON_ERROR @@ -3762,6 +3866,7 @@ void backend_ctx_destroy (hashcat_ctx_t *hashcat_ctx) hcfree (backend_ctx->opencl_platforms_devices_cnt); hcfree (backend_ctx->opencl_platforms_name); hcfree (backend_ctx->opencl_platforms_vendor); + hcfree (backend_ctx->opencl_platforms_vendor_id); hcfree (backend_ctx->opencl_platforms_version); memset (backend_ctx, 0, sizeof (backend_ctx_t)); @@ -3962,7 +4067,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // skipped - if ((backend_ctx->devices_filter & (1ULL << device_id)) == 0) + if ((backend_ctx->backend_devices_filter & (1ULL << device_id)) == 0) { device_param->skipped = true; } @@ -3988,127 +4093,16 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) * OpenCL devices: simply push all devices from all platforms into the same device array */ - cl_platform_id *opencl_platforms = backend_ctx->opencl_platforms; cl_uint opencl_platforms_cnt = backend_ctx->opencl_platforms_cnt; cl_device_id **opencl_platforms_devices = backend_ctx->opencl_platforms_devices; cl_uint *opencl_platforms_devices_cnt = backend_ctx->opencl_platforms_devices_cnt; - char **opencl_platforms_name = backend_ctx->opencl_platforms_name; - char **opencl_platforms_vendor = backend_ctx->opencl_platforms_vendor; - char **opencl_platforms_version = backend_ctx->opencl_platforms_version; + cl_uint *opencl_platforms_vendor_id = backend_ctx->opencl_platforms_vendor_id; - for (u32 opencl_platform_idx = 0; opencl_platform_idx < opencl_platforms_cnt; opencl_platform_idx++) + for (u32 opencl_platforms_idx = 0; opencl_platforms_idx < opencl_platforms_cnt; opencl_platforms_idx++) { - size_t param_value_size = 0; - - cl_platform_id opencl_platform = opencl_platforms[opencl_platform_idx]; - - // platform vendor - - int CL_rc; - - CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VENDOR, 0, NULL, ¶m_value_size); - - if (CL_rc == -1) return -1; - - char *opencl_platform_vendor = (char *) hcmalloc (param_value_size); - - CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VENDOR, param_value_size, opencl_platform_vendor, NULL); - - if (CL_rc == -1) return -1; - - opencl_platforms_vendor[opencl_platform_idx] = opencl_platform_vendor; - - // platform name - - CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_NAME, 0, NULL, ¶m_value_size); - - if (CL_rc == -1) return -1; - - char *opencl_platform_name = (char *) hcmalloc (param_value_size); - - CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_NAME, param_value_size, opencl_platform_name, NULL); - - if (CL_rc == -1) return -1; - - opencl_platforms_name[opencl_platform_idx] = opencl_platform_name; - - // platform version - - CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VERSION, 0, NULL, ¶m_value_size); - - if (CL_rc == -1) return -1; - - char *opencl_platform_version = (char *) hcmalloc (param_value_size); - - CL_rc = hc_clGetPlatformInfo (hashcat_ctx, opencl_platform, CL_PLATFORM_VERSION, param_value_size, opencl_platform_version, NULL); - - if (CL_rc == -1) return -1; - - opencl_platforms_version[opencl_platform_idx] = opencl_platform_version; - - // find our own platform vendor because pocl and mesa are pushing original vendor_id through opencl - // this causes trouble with vendor id based macros - // we'll assign generic to those without special optimization available - - cl_uint opencl_platform_vendor_id = 0; - - if (strcmp (opencl_platform_vendor, CL_VENDOR_AMD1) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_AMD; - } - else if (strcmp (opencl_platform_vendor, CL_VENDOR_AMD2) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_AMD; - } - else if (strcmp (opencl_platform_vendor, CL_VENDOR_AMD_USE_INTEL) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_AMD_USE_INTEL; - } - else if (strcmp (opencl_platform_vendor, CL_VENDOR_APPLE) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_APPLE; - } - else if (strcmp (opencl_platform_vendor, CL_VENDOR_INTEL_BEIGNET) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_INTEL_BEIGNET; - } - else if (strcmp (opencl_platform_vendor, CL_VENDOR_INTEL_SDK) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_INTEL_SDK; - } - else if (strcmp (opencl_platform_vendor, CL_VENDOR_MESA) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_MESA; - } - else if (strcmp (opencl_platform_vendor, CL_VENDOR_NV) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_NV; - } - else if (strcmp (opencl_platform_vendor, CL_VENDOR_POCL) == 0) - { - opencl_platform_vendor_id = VENDOR_ID_POCL; - } - else - { - opencl_platform_vendor_id = VENDOR_ID_GENERIC; - } - - cl_device_id *opencl_platform_devices = (cl_device_id *) hccalloc (DEVICES_MAX, sizeof (cl_device_id)); - - cl_uint opencl_platform_devices_cnt = 0; - - CL_rc = hc_clGetDeviceIDs (hashcat_ctx, opencl_platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, opencl_platform_devices, &opencl_platform_devices_cnt); - - if (CL_rc == -1) - { - event_log_error (hashcat_ctx, "clGetDeviceIDs(): %s", val2cstr_cl (CL_rc)); - - return -1; - } - - opencl_platforms_devices[opencl_platform_idx] = opencl_platform_devices; - - opencl_platforms_devices_cnt[opencl_platform_idx] = opencl_platform_devices_cnt; + cl_device_id *opencl_platform_devices = opencl_platforms_devices[opencl_platforms_idx]; + cl_uint opencl_platform_devices_cnt = opencl_platforms_devices_cnt[opencl_platforms_idx]; + cl_uint opencl_platform_vendor_id = opencl_platforms_vendor_id[opencl_platforms_idx]; for (u32 opencl_platform_devices_idx = 0; opencl_platform_devices_idx < opencl_platform_devices_cnt; opencl_platform_devices_idx++, backend_devices_idx++, opencl_devices_cnt++) { @@ -4120,18 +4114,20 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) backend_ctx->backend_device_from_opencl[opencl_devices_cnt] = backend_devices_idx; - backend_ctx->backend_device_from_opencl_platform[opencl_platform_idx][opencl_platform_devices_idx] = backend_devices_idx; + backend_ctx->backend_device_from_opencl_platform[opencl_platforms_idx][opencl_platform_devices_idx] = backend_devices_idx; device_param->opencl_platform_vendor_id = opencl_platform_vendor_id; device_param->opencl_device = opencl_platform_devices[opencl_platform_devices_idx]; - device_param->opencl_platform_devices_id = opencl_platform_devices_idx; - - device_param->opencl_platform = opencl_platform; + //device_param->opencl_platform = opencl_platform; device_param->is_opencl = true; + size_t param_value_size = 0; + + int CL_rc; + // opencl_device_type cl_device_type opencl_device_type; @@ -4493,7 +4489,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // skipped - if ((backend_ctx->devices_filter & (1ULL << device_id)) == 0) + if ((backend_ctx->backend_devices_filter & (1ULL << device_id)) == 0) { device_param->skipped = true; } @@ -4606,7 +4602,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_param->skipped == false) { - if ((user_options->force == false) && (user_options->opencl_info == false)) + if ((user_options->force == false) && (user_options->backend_info == false)) { if (opencl_device_type & CL_DEVICE_TYPE_CPU) { @@ -4785,6 +4781,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_context context; + /* cl_context_properties properties[3]; properties[0] = CL_CONTEXT_PLATFORM; @@ -4792,6 +4789,9 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) properties[2] = 0; CL_rc = hc_clCreateContext (hashcat_ctx, properties, 1, &device_param->opencl_device, NULL, NULL, &context); + */ + + CL_rc = hc_clCreateContext (hashcat_ctx, NULL, 1, &device_param->opencl_device, NULL, NULL, &context); if (CL_rc == -1) return -1; @@ -4960,13 +4960,13 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // additional check to see if the user has chosen a device that is not within the range of available devices (i.e. larger than devices_cnt) - if (backend_ctx->devices_filter != (u64) -1) + if (backend_ctx->backend_devices_filter != (u64) -1) { const u64 backend_devices_cnt_mask = ~(((u64) -1 >> backend_ctx->backend_devices_cnt) << backend_ctx->backend_devices_cnt); - if (backend_ctx->devices_filter > backend_devices_cnt_mask) + if (backend_ctx->backend_devices_filter > backend_devices_cnt_mask) { - event_log_error (hashcat_ctx, "An invalid device was specified using the --opencl-devices parameter."); + event_log_error (hashcat_ctx, "An invalid device was specified using the --backend-devices parameter."); event_log_error (hashcat_ctx, "The specified device was higher than the number of available devices (%u).", backend_ctx->backend_devices_cnt); return -1; @@ -5007,10 +5007,13 @@ void backend_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx) hcfree (device_param->device_name); - hcfree (device_param->opencl_driver_version); - hcfree (device_param->opencl_device_version); - hcfree (device_param->opencl_device_c_version); - hcfree (device_param->opencl_device_vendor); + if (device_param->is_opencl == true) + { + hcfree (device_param->opencl_driver_version); + hcfree (device_param->opencl_device_version); + hcfree (device_param->opencl_device_c_version); + hcfree (device_param->opencl_device_vendor); + } } backend_ctx->backend_devices_cnt = 0; @@ -5374,7 +5377,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped == true) continue; - EVENT_DATA (EVENT_OPENCL_DEVICE_INIT_PRE, &backend_devices_idx, sizeof (int)); + EVENT_DATA (EVENT_BACKEND_DEVICE_INIT_PRE, &backend_devices_idx, sizeof (int)); const int device_id = device_param->device_id; @@ -5403,7 +5406,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) cl_uint vector_width; - if (user_options->opencl_vector_width_chgd == false) + if (user_options->backend_vector_width_chgd == false) { // tuning db @@ -5440,7 +5443,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) } else { - vector_width = user_options->opencl_vector_width; + vector_width = user_options->backend_vector_width; } // We can't have SIMD in kernels where we have an unknown final password length @@ -5600,6 +5603,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) * create context for each device */ + /* cl_context_properties properties[3]; properties[0] = CL_CONTEXT_PLATFORM; @@ -5607,6 +5611,9 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) properties[2] = 0; CL_rc = hc_clCreateContext (hashcat_ctx, properties, 1, &device_param->opencl_device, NULL, NULL, &device_param->context); + */ + + CL_rc = hc_clCreateContext (hashcat_ctx, NULL, 1, &device_param->opencl_device, NULL, NULL, &device_param->context); if (CL_rc == -1) return -1; @@ -7720,7 +7727,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) hardware_power_all += device_param->hardware_power; - EVENT_DATA (EVENT_OPENCL_DEVICE_INIT_POST, &backend_devices_idx, sizeof (int)); + EVENT_DATA (EVENT_BACKEND_DEVICE_INIT_POST, &backend_devices_idx, sizeof (int)); } if (user_options->benchmark == false) diff --git a/src/bitmap.c b/src/bitmap.c index 66f9ebd0f..6b1da1362 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -82,7 +82,7 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/combinator.c b/src/combinator.c index ccf7b4792..a0c3f16eb 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -21,7 +21,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/cpt.c b/src/cpt.c index 90ce8728d..72db45415 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -18,7 +18,7 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/debugfile.c b/src/debugfile.c index f6519534e..5e0a62bbe 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -90,7 +90,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; diff --git a/src/dictstat.c b/src/dictstat.c index 628c15187..7ee0e4297 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -56,7 +56,7 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/hashcat.c b/src/hashcat.c index 11d212243..667b7eecc 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -207,7 +207,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_AUTOTUNE_FINISHED); /** - * find same opencl devices and equal results + * find same backend devices and equal results */ backend_ctx_devices_sync_tuning (hashcat_ctx); @@ -295,7 +295,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) // however, that can create confusion in hashcats RC, because exhausted translates to RC = 1. // but then having RC = 1 does not match our expection if we use for speed-only and progress-only. // to get hashcat to return RC = 0 we have to set it to CRACKED or BYPASS - // note: other options like --show, --left, --benchmark, --keyspace, --opencl-info, etc. + // note: other options like --show, --left, --benchmark, --keyspace, --backend-info, etc. // not not reach this section of the code, they've returned already with rc 0. if ((user_options->speed_only == true) || (user_options->progress_only == true)) @@ -720,13 +720,13 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * inform the user */ - EVENT (EVENT_OPENCL_SESSION_PRE); + EVENT (EVENT_BACKEND_SESSION_PRE); const int rc_session_begin = backend_session_begin (hashcat_ctx); if (rc_session_begin == -1) return -1; - EVENT (EVENT_OPENCL_SESSION_POST); + EVENT (EVENT_BACKEND_SESSION_POST); /** * create self-test threads @@ -879,7 +879,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) potfile_write_close (hashcat_ctx); - // finalize opencl session + // finalize backend session backend_session_destroy (hashcat_ctx); @@ -1169,7 +1169,7 @@ int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder if (rc_user_options_check_files == -1) return -1; /** - * Init OpenCL library loader + * Init backend library loader */ const int rc_backend_init = backend_ctx_init (hashcat_ctx); @@ -1177,7 +1177,7 @@ int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder if (rc_backend_init == -1) return -1; /** - * Init OpenCL devices + * Init backend devices */ const int rc_devices_init = backend_ctx_devices_init (hashcat_ctx, comptime); diff --git a/src/hashes.c b/src/hashes.c index 653123d9d..5306d2341 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -840,7 +840,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) else if (user_options->stdout_flag == true) { } - else if (user_options->opencl_info == true) + else if (user_options->backend_info == true) { } else diff --git a/src/hwmon.c b/src/hwmon.c index 7d710a44c..2bce94a3d 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -1351,49 +1351,69 @@ int hm_get_threshold_slowdown_with_devices_idx (hashcat_ctx_t *hashcat_ctx, cons if (hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) + int target = 0; + + if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) == -1) { + hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false; + return -1; } - else if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) - { - int CurrentValue = 0; - int DefaultValue = 0; - if (hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &CurrentValue, &DefaultValue) == -1) + return target; + } + } + + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) + { + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; + + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + if (hwmon_ctx->hm_adl) + { + if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) { - hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false; - return -1; } + else if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + { + int CurrentValue = 0; + int DefaultValue = 0; + + if (hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &CurrentValue, &DefaultValue) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false; - // the return value has never been tested since hm_ADL_Overdrive6_TargetTemperatureData_Get() never worked on any system. expect problems. + return -1; + } - return DefaultValue; + // the return value has never been tested since hm_ADL_Overdrive6_TargetTemperatureData_Get() never worked on any system. expect problems. + + return DefaultValue; + } } } - } - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) - { - if (hwmon_ctx->hm_nvml) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) { - int target = 0; - - if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) == -1) + if (hwmon_ctx->hm_nvml) { - hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false; + int target = 0; - return -1; - } + if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false; - return target; + return -1; + } + + return target; + } } } @@ -1411,37 +1431,57 @@ int hm_get_threshold_shutdown_with_devices_idx (hashcat_ctx_t *hashcat_ctx, cons if (hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) - { + int target = 0; - } - else if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) == -1) { + hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false; + return -1; } + + return target; } } - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) { - if (hwmon_ctx->hm_nvml) - { - int target = 0; + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) == -1) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + if (hwmon_ctx->hm_adl) { - hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false; + if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) + { - return -1; + } + else if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + { + + } } + } - return target; + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) + { + if (hwmon_ctx->hm_nvml) + { + int target = 0; + + if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false; + + return -1; + } + + return target; + } } } @@ -1459,72 +1499,92 @@ int hm_get_temperature_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b if (hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) + int temperature = 0; + + if (hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) == -1) { - ADLTemperature Temperature; + hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; + + return -1; + } + + return temperature; + } + } - Temperature.iSize = sizeof (ADLTemperature); + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) + { + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - if (hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &Temperature) == -1) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + if (hwmon_ctx->hm_adl) + { + if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) { - hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; + ADLTemperature Temperature; - return -1; + Temperature.iSize = sizeof (ADLTemperature); + + if (hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &Temperature) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; + + return -1; + } + + return Temperature.iTemperature / 1000; } - return Temperature.iTemperature / 1000; + if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + { + int Temperature = 0; + + if (hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &Temperature) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; + + return -1; + } + + return Temperature / 1000; + } } - if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + if (hwmon_ctx->hm_sysfs) { - int Temperature = 0; + int temperature = 0; - if (hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &Temperature) == -1) + if (hm_SYSFS_get_temperature_current (hashcat_ctx, backend_device_idx, &temperature) == -1) { hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; return -1; } - return Temperature / 1000; + return temperature; } } - if (hwmon_ctx->hm_sysfs) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) { - int temperature = 0; - - if (hm_SYSFS_get_temperature_current (hashcat_ctx, backend_device_idx, &temperature) == -1) + if (hwmon_ctx->hm_nvml) { - hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; - - return -1; - } - - return temperature; - } - } + int temperature = 0; - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) - { - if (hwmon_ctx->hm_nvml) - { - int temperature = 0; + if (hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; - if (hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) == -1) - { - hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; + return -1; + } - return -1; + return temperature; } - - return temperature; } } @@ -1542,49 +1602,57 @@ int hm_get_fanpolicy_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int bac if (hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) + { + return 1; + } - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) { - if (hwmon_ctx->hm_adl) + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; + + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) { - if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) + if (hwmon_ctx->hm_adl) { - ADLFanSpeedValue lpFanSpeedValue; + if (hwmon_ctx->hm_device[backend_device_idx].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.iSize = sizeof (lpFanSpeedValue); + lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; - if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &lpFanSpeedValue) == -1) - { - hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false; - hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; + if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &lpFanSpeedValue) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false; + hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; - return -1; + return -1; + } + + return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1; } - return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1; + if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + { + return 1; + } } - if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + if (hwmon_ctx->hm_sysfs) { return 1; } } - if (hwmon_ctx->hm_sysfs) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) { return 1; } } - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) - { - return 1; - } - hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false; hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; @@ -1600,78 +1668,98 @@ int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back if (hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) + int speed = 0; + + if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, (u32 *) &speed) == -1) { - ADLFanSpeedValue lpFanSpeedValue; + hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; - memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue)); + return -1; + } + + return speed; + } + } - lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue); - lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; - lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED; + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) + { + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &lpFanSpeedValue) == -1) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + if (hwmon_ctx->hm_adl) + { + if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5) { - hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; + ADLFanSpeedValue lpFanSpeedValue; - return -1; + memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue)); + + lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue); + lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; + lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED; + + if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &lpFanSpeedValue) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; + + return -1; + } + + return lpFanSpeedValue.iFanSpeed; } - return lpFanSpeedValue.iFanSpeed; + if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + { + ADLOD6FanSpeedInfo faninfo; + + memset (&faninfo, 0, sizeof (faninfo)); + + if (hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &faninfo) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; + + return -1; + } + + return faninfo.iFanSpeedPercent; + } } - if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6) + if (hwmon_ctx->hm_sysfs) { - ADLOD6FanSpeedInfo faninfo; + int speed = 0; - memset (&faninfo, 0, sizeof (faninfo)); - - if (hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &faninfo) == -1) + if (hm_SYSFS_get_fan_speed_current (hashcat_ctx, backend_device_idx, &speed) == -1) { hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; return -1; } - return faninfo.iFanSpeedPercent; + return speed; } } - if (hwmon_ctx->hm_sysfs) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) { - int speed = 0; - - if (hm_SYSFS_get_fan_speed_current (hashcat_ctx, backend_device_idx, &speed) == -1) + if (hwmon_ctx->hm_nvml) { - hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; - - return -1; - } - - return speed; - } - } + int speed = 0; - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) - { - if (hwmon_ctx->hm_nvml) - { - int speed = 0; + if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, (u32 *) &speed) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; - if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, (u32 *) &speed) == -1) - { - hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; + return -1; + } - return -1; + return speed; } - - return speed; } } @@ -1689,55 +1777,75 @@ int hm_get_buslanes_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back if (hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - ADLPMActivity PMActivity; - - PMActivity.iSize = sizeof (ADLPMActivity); + unsigned int currLinkWidth; - if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1) + if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &currLinkWidth) == -1) { hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false; return -1; } - return PMActivity.iCurrentBusLanes; + return currLinkWidth; } + } - if (hwmon_ctx->hm_sysfs) - { - int lanes; + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) + { + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - if (hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx, backend_device_idx, &lanes) == -1) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + if (hwmon_ctx->hm_adl) { - hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false; + ADLPMActivity PMActivity; - return -1; + PMActivity.iSize = sizeof (ADLPMActivity); + + if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false; + + return -1; + } + + return PMActivity.iCurrentBusLanes; } - return lanes; + if (hwmon_ctx->hm_sysfs) + { + int lanes; + + if (hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx, backend_device_idx, &lanes) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false; + + return -1; + } + + return lanes; + } } - } - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) - { - if (hwmon_ctx->hm_nvml) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) { - unsigned int currLinkWidth; - - if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &currLinkWidth) == -1) + if (hwmon_ctx->hm_nvml) { - hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false; + unsigned int currLinkWidth; - return -1; - } + if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &currLinkWidth) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false; - return currLinkWidth; + return -1; + } + + return currLinkWidth; + } } } @@ -1755,41 +1863,61 @@ int hm_get_utilization_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b if (hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - ADLPMActivity PMActivity; - - PMActivity.iSize = sizeof (ADLPMActivity); + nvmlUtilization_t utilization; - if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1) + if (hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &utilization) == -1) { hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false; return -1; } - return PMActivity.iActivityPercent; + return utilization.gpu; } } - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) { - if (hwmon_ctx->hm_nvml) - { - nvmlUtilization_t utilization; + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - if (hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &utilization) == -1) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + if (hwmon_ctx->hm_adl) { - hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false; + ADLPMActivity PMActivity; - return -1; + PMActivity.iSize = sizeof (ADLPMActivity); + + if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false; + + return -1; + } + + return PMActivity.iActivityPercent; } + } - return utilization.gpu; + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) + { + if (hwmon_ctx->hm_nvml) + { + nvmlUtilization_t utilization; + + if (hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &utilization) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false; + + return -1; + } + + return utilization.gpu; + } } } @@ -1807,55 +1935,75 @@ int hm_get_memoryspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b if (hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - ADLPMActivity PMActivity; - - PMActivity.iSize = sizeof (ADLPMActivity); + unsigned int clockfreq; - if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1) + if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_MEM, &clockfreq) == -1) { hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false; return -1; } - return PMActivity.iMemoryClock / 100; + return clockfreq; } + } - if (hwmon_ctx->hm_sysfs) - { - int clockfreq; + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) + { + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - if (hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + if (hwmon_ctx->hm_adl) { - hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false; + ADLPMActivity PMActivity; - return -1; + PMActivity.iSize = sizeof (ADLPMActivity); + + if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false; + + return -1; + } + + return PMActivity.iMemoryClock / 100; } - return clockfreq; + if (hwmon_ctx->hm_sysfs) + { + int clockfreq; + + if (hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false; + + return -1; + } + + return clockfreq; + } } - } - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) - { - if (hwmon_ctx->hm_nvml) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) { - unsigned int clockfreq; - - if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_MEM, &clockfreq) == -1) + if (hwmon_ctx->hm_nvml) { - hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false; + unsigned int clockfreq; - return -1; - } + if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_MEM, &clockfreq) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false; - return clockfreq; + return -1; + } + + return clockfreq; + } } } @@ -1873,55 +2021,75 @@ int hm_get_corespeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int bac if (hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - ADLPMActivity PMActivity; - - PMActivity.iSize = sizeof (ADLPMActivity); + unsigned int clockfreq; - if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1) + if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_SM, &clockfreq) == -1) { hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false; return -1; } - return PMActivity.iEngineClock / 100; + return clockfreq; } + } - if (hwmon_ctx->hm_sysfs) - { - int clockfreq; + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) + { + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - if (hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + if (hwmon_ctx->hm_adl) { - hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false; + ADLPMActivity PMActivity; - return -1; + PMActivity.iSize = sizeof (ADLPMActivity); + + if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false; + + return -1; + } + + return PMActivity.iEngineClock / 100; } - return clockfreq; + if (hwmon_ctx->hm_sysfs) + { + int clockfreq; + + if (hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false; + + return -1; + } + + return clockfreq; + } } - } - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) - { - if (hwmon_ctx->hm_nvml) + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) { - unsigned int clockfreq; - - if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_SM, &clockfreq) == -1) + if (hwmon_ctx->hm_nvml) { - hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false; + unsigned int clockfreq; - return -1; - } + if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_SM, &clockfreq) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false; - return clockfreq; + return -1; + } + + return clockfreq; + } } } @@ -1939,13 +2107,7 @@ int hm_get_throttle_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back if (hwmon_ctx->hm_device[backend_device_idx].throttle_get_supported == false) return -1; - if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) - { - } - - if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) + if (backend_ctx->devices_param[backend_device_idx].is_cuda == true) { if (hwmon_ctx->hm_nvml) { @@ -1991,6 +2153,61 @@ int hm_get_throttle_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back } } + if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) + { + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; + + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) + { + } + + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) + { + if (hwmon_ctx->hm_nvml) + { + /* this is triggered by mask generator, too. therefore useless + unsigned long long clocksThrottleReasons = 0; + unsigned long long supportedThrottleReasons = 0; + + if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &clocksThrottleReasons) == -1) return -1; + if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &supportedThrottleReasons) == -1) return -1; + + clocksThrottleReasons &= supportedThrottleReasons; + clocksThrottleReasons &= ~nvmlClocksThrottleReasonGpuIdle; + clocksThrottleReasons &= ~nvmlClocksThrottleReasonApplicationsClocksSetting; + clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown; + + if (backend_ctx->kernel_power_final) + { + clocksThrottleReasons &= ~nvmlClocksThrottleReasonHwSlowdown; + } + + return (clocksThrottleReasons != nvmlClocksThrottleReasonNone); + */ + } + + if (hwmon_ctx->hm_nvapi) + { + NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info; + NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status; + + memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1)); + memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1)); + + perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1); + perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1); + + hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_info); + + perfPolicies_status.info_value = perfPolicies_info.info_value; + + hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_status); + + return perfPolicies_status.throttle & 2; + } + } + } + hwmon_ctx->hm_device[backend_device_idx].throttle_get_supported = false; return -1; @@ -2008,15 +2225,15 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) return 0; #endif // WITH_HWMON - if (user_options->example_hashes == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->stdout_flag == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; - if (user_options->hwmon_disable == true) return 0; + if (user_options->example_hashes == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->stdout_flag == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->hwmon_disable == true) return 0; hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); @@ -2108,34 +2325,67 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped == true) continue; - if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; + if (device_param->is_cuda == true) + { + for (int i = 0; i < tmp_in; i++) + { + nvmlPciInfo_t pci; - if (device_param->opencl_device_vendor_id != VENDOR_ID_NV) continue; + int rc = hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci); - for (int i = 0; i < tmp_in; i++) - { - nvmlPciInfo_t pci; + if (rc == -1) continue; + + if ((device_param->pcie_bus == pci.bus) + && (device_param->pcie_device == (pci.device >> 3)) + && (device_param->pcie_function == (pci.device & 7))) + { + const u32 device_id = device_param->device_id; + + hm_adapters_nvml[device_id].nvml = nvmlGPUHandle[i]; - int rc = hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci); + hm_adapters_nvml[device_id].buslanes_get_supported = true; + hm_adapters_nvml[device_id].corespeed_get_supported = true; + hm_adapters_nvml[device_id].fanspeed_get_supported = true; + hm_adapters_nvml[device_id].memoryspeed_get_supported = true; + hm_adapters_nvml[device_id].temperature_get_supported = true; + hm_adapters_nvml[device_id].threshold_shutdown_get_supported = true; + hm_adapters_nvml[device_id].threshold_slowdown_get_supported = true; + hm_adapters_nvml[device_id].utilization_get_supported = true; + } + } + } + + if (device_param->is_opencl == true) + { + if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - if (rc == -1) continue; + if (device_param->opencl_device_vendor_id != VENDOR_ID_NV) continue; - if ((device_param->pcie_bus == pci.bus) - && (device_param->pcie_device == (pci.device >> 3)) - && (device_param->pcie_function == (pci.device & 7))) + for (int i = 0; i < tmp_in; i++) { - const u32 platform_devices_id = device_param->opencl_platform_devices_id; - - hm_adapters_nvml[platform_devices_id].nvml = nvmlGPUHandle[i]; - - hm_adapters_nvml[platform_devices_id].buslanes_get_supported = true; - hm_adapters_nvml[platform_devices_id].corespeed_get_supported = true; - hm_adapters_nvml[platform_devices_id].fanspeed_get_supported = true; - hm_adapters_nvml[platform_devices_id].memoryspeed_get_supported = true; - hm_adapters_nvml[platform_devices_id].temperature_get_supported = true; - hm_adapters_nvml[platform_devices_id].threshold_shutdown_get_supported = true; - hm_adapters_nvml[platform_devices_id].threshold_slowdown_get_supported = true; - hm_adapters_nvml[platform_devices_id].utilization_get_supported = true; + nvmlPciInfo_t pci; + + int rc = hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci); + + if (rc == -1) continue; + + if ((device_param->pcie_bus == pci.bus) + && (device_param->pcie_device == (pci.device >> 3)) + && (device_param->pcie_function == (pci.device & 7))) + { + const u32 device_id = device_param->device_id; + + hm_adapters_nvml[device_id].nvml = nvmlGPUHandle[i]; + + hm_adapters_nvml[device_id].buslanes_get_supported = true; + hm_adapters_nvml[device_id].corespeed_get_supported = true; + hm_adapters_nvml[device_id].fanspeed_get_supported = true; + hm_adapters_nvml[device_id].memoryspeed_get_supported = true; + hm_adapters_nvml[device_id].temperature_get_supported = true; + hm_adapters_nvml[device_id].threshold_shutdown_get_supported = true; + hm_adapters_nvml[device_id].threshold_slowdown_get_supported = true; + hm_adapters_nvml[device_id].utilization_get_supported = true; + } } } } @@ -2158,33 +2408,65 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped == true) continue; - if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; + if (device_param->is_cuda == true) + { + for (int i = 0; i < tmp_in; i++) + { + NvU32 BusId = 0; + NvU32 BusSlotId = 0; - if (device_param->opencl_device_vendor_id != VENDOR_ID_NV) continue; + int rc1 = hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId); - for (int i = 0; i < tmp_in; i++) - { - NvU32 BusId = 0; - NvU32 BusSlotId = 0; + if (rc1 == -1) continue; + + int rc2 = hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId); + + if (rc2 == -1) continue; + + if ((device_param->pcie_bus == BusId) + && (device_param->pcie_device == (BusSlotId >> 3)) + && (device_param->pcie_function == (BusSlotId & 7))) + { + const u32 device_id = device_param->device_id; - int rc1 = hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId); + hm_adapters_nvapi[device_id].nvapi = nvGPUHandle[i]; - if (rc1 == -1) continue; + hm_adapters_nvapi[device_id].fanpolicy_get_supported = true; + hm_adapters_nvapi[device_id].throttle_get_supported = true; + } + } + } - int rc2 = hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId); + if (device_param->is_opencl == true) + { + if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - if (rc2 == -1) continue; + if (device_param->opencl_device_vendor_id != VENDOR_ID_NV) continue; - if ((device_param->pcie_bus == BusId) - && (device_param->pcie_device == (BusSlotId >> 3)) - && (device_param->pcie_function == (BusSlotId & 7))) + for (int i = 0; i < tmp_in; i++) { - const u32 platform_devices_id = device_param->opencl_platform_devices_id; + NvU32 BusId = 0; + NvU32 BusSlotId = 0; + + int rc1 = hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId); + + if (rc1 == -1) continue; + + int rc2 = hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId); + + if (rc2 == -1) continue; + + if ((device_param->pcie_bus == BusId) + && (device_param->pcie_device == (BusSlotId >> 3)) + && (device_param->pcie_function == (BusSlotId & 7))) + { + const u32 device_id = device_param->device_id; - hm_adapters_nvapi[platform_devices_id].nvapi = nvGPUHandle[i]; + hm_adapters_nvapi[device_id].nvapi = nvGPUHandle[i]; - hm_adapters_nvapi[platform_devices_id].fanpolicy_get_supported = true; - hm_adapters_nvapi[platform_devices_id].throttle_get_supported = true; + hm_adapters_nvapi[device_id].fanpolicy_get_supported = true; + hm_adapters_nvapi[device_id].throttle_get_supported = true; + } } } } @@ -2227,36 +2509,44 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped == true) continue; - if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - - if (device_param->opencl_device_vendor_id != VENDOR_ID_AMD) continue; - - for (int i = 0; i < tmp_in; i++) + if (device_param->is_cuda == true) { - if ((device_param->pcie_bus == lpAdapterInfo[i].iBusNumber) - && (device_param->pcie_device == (lpAdapterInfo[i].iDeviceNumber >> 3)) - && (device_param->pcie_function == (lpAdapterInfo[i].iDeviceNumber & 7))) - { - const u32 platform_devices_id = device_param->opencl_platform_devices_id; - - int od_supported = 0; - int od_enabled = 0; - int od_version = 0; - - hm_ADL_Overdrive_Caps (hashcat_ctx, lpAdapterInfo[i].iAdapterIndex, &od_supported, &od_enabled, &od_version); + // nothing to do + } - hm_adapters_adl[platform_devices_id].od_version = od_version; + if (device_param->is_opencl == true) + { + if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - hm_adapters_adl[platform_devices_id].adl = lpAdapterInfo[i].iAdapterIndex; + if (device_param->opencl_device_vendor_id != VENDOR_ID_AMD) continue; - hm_adapters_adl[platform_devices_id].buslanes_get_supported = true; - hm_adapters_adl[platform_devices_id].corespeed_get_supported = true; - hm_adapters_adl[platform_devices_id].fanspeed_get_supported = true; - hm_adapters_adl[platform_devices_id].fanpolicy_get_supported = true; - hm_adapters_adl[platform_devices_id].memoryspeed_get_supported = true; - hm_adapters_adl[platform_devices_id].temperature_get_supported = true; - hm_adapters_adl[platform_devices_id].threshold_slowdown_get_supported = true; - hm_adapters_adl[platform_devices_id].utilization_get_supported = true; + for (int i = 0; i < tmp_in; i++) + { + if ((device_param->pcie_bus == lpAdapterInfo[i].iBusNumber) + && (device_param->pcie_device == (lpAdapterInfo[i].iDeviceNumber >> 3)) + && (device_param->pcie_function == (lpAdapterInfo[i].iDeviceNumber & 7))) + { + const u32 device_id = device_param->device_id; + + int od_supported = 0; + int od_enabled = 0; + int od_version = 0; + + hm_ADL_Overdrive_Caps (hashcat_ctx, lpAdapterInfo[i].iAdapterIndex, &od_supported, &od_enabled, &od_version); + + hm_adapters_adl[device_id].od_version = od_version; + + hm_adapters_adl[device_id].adl = lpAdapterInfo[i].iAdapterIndex; + + hm_adapters_adl[device_id].buslanes_get_supported = true; + hm_adapters_adl[device_id].corespeed_get_supported = true; + hm_adapters_adl[device_id].fanspeed_get_supported = true; + hm_adapters_adl[device_id].fanpolicy_get_supported = true; + hm_adapters_adl[device_id].memoryspeed_get_supported = true; + hm_adapters_adl[device_id].temperature_get_supported = true; + hm_adapters_adl[device_id].threshold_slowdown_get_supported = true; + hm_adapters_adl[device_id].utilization_get_supported = true; + } } } } @@ -2275,18 +2565,26 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; - if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; + if (device_param->is_cuda == true) + { + // nothing to do + } + + if (device_param->is_opencl == true) + { + if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - hm_adapters_sysfs[hm_adapters_id].sysfs = backend_devices_idx; // ???? + hm_adapters_sysfs[hm_adapters_id].sysfs = backend_devices_idx; // ???? - hm_adapters_sysfs[hm_adapters_id].buslanes_get_supported = true; - hm_adapters_sysfs[hm_adapters_id].corespeed_get_supported = true; - hm_adapters_sysfs[hm_adapters_id].fanspeed_get_supported = true; - hm_adapters_sysfs[hm_adapters_id].fanpolicy_get_supported = true; - hm_adapters_sysfs[hm_adapters_id].memoryspeed_get_supported = true; - hm_adapters_sysfs[hm_adapters_id].temperature_get_supported = true; + hm_adapters_sysfs[hm_adapters_id].buslanes_get_supported = true; + hm_adapters_sysfs[hm_adapters_id].corespeed_get_supported = true; + hm_adapters_sysfs[hm_adapters_id].fanspeed_get_supported = true; + hm_adapters_sysfs[hm_adapters_id].fanpolicy_get_supported = true; + hm_adapters_sysfs[hm_adapters_id].memoryspeed_get_supported = true; + hm_adapters_sysfs[hm_adapters_id].temperature_get_supported = true; - hm_adapters_id++; + hm_adapters_id++; + } } } } @@ -2320,83 +2618,123 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped == true) continue; - if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; + const u32 device_id = device_param->device_id; - const u32 platform_devices_id = device_param->opencl_platform_devices_id; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + if (device_param->is_cuda == true) { - hwmon_ctx->hm_device[backend_devices_idx].adl = hm_adapters_adl[platform_devices_id].adl; - hwmon_ctx->hm_device[backend_devices_idx].sysfs = hm_adapters_sysfs[platform_devices_id].sysfs; - hwmon_ctx->hm_device[backend_devices_idx].nvapi = 0; - hwmon_ctx->hm_device[backend_devices_idx].nvml = 0; + hwmon_ctx->hm_device[backend_devices_idx].adl = 0; + hwmon_ctx->hm_device[backend_devices_idx].sysfs = 0; + hwmon_ctx->hm_device[backend_devices_idx].nvapi = hm_adapters_nvapi[device_id].nvapi; + hwmon_ctx->hm_device[backend_devices_idx].nvml = hm_adapters_nvml[device_id].nvml; hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; - if (hwmon_ctx->hm_adl) + if (hwmon_ctx->hm_nvml) { - hwmon_ctx->hm_device[backend_devices_idx].od_version = hm_adapters_adl[platform_devices_id].od_version; - - hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_adl[platform_devices_id].buslanes_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_adl[platform_devices_id].corespeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_adl[platform_devices_id].fanspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_adl[platform_devices_id].fanpolicy_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_adl[platform_devices_id].memoryspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_adl[platform_devices_id].temperature_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_adl[platform_devices_id].threshold_shutdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_adl[platform_devices_id].threshold_slowdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_adl[platform_devices_id].throttle_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_adl[platform_devices_id].utilization_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvml[device_id].buslanes_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvml[device_id].corespeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvml[device_id].fanspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvml[device_id].fanpolicy_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvml[device_id].memoryspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvml[device_id].temperature_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvml[device_id].threshold_shutdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvml[device_id].threshold_slowdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvml[device_id].throttle_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvml[device_id].utilization_get_supported; } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_nvapi) { - hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_sysfs[platform_devices_id].buslanes_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_sysfs[platform_devices_id].corespeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_sysfs[platform_devices_id].fanspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_sysfs[platform_devices_id].fanpolicy_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_sysfs[platform_devices_id].memoryspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_sysfs[platform_devices_id].temperature_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_sysfs[platform_devices_id].threshold_shutdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_sysfs[platform_devices_id].threshold_slowdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_sysfs[platform_devices_id].throttle_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_sysfs[platform_devices_id].utilization_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvapi[device_id].buslanes_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvapi[device_id].corespeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvapi[device_id].fanspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvapi[device_id].fanpolicy_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvapi[device_id].memoryspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvapi[device_id].temperature_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvapi[device_id].threshold_shutdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvapi[device_id].threshold_slowdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvapi[device_id].throttle_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvapi[device_id].utilization_get_supported; } } - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + if (device_param->is_opencl == true) { - hwmon_ctx->hm_device[backend_devices_idx].adl = 0; - hwmon_ctx->hm_device[backend_devices_idx].sysfs = 0; - hwmon_ctx->hm_device[backend_devices_idx].nvapi = hm_adapters_nvapi[platform_devices_id].nvapi; - hwmon_ctx->hm_device[backend_devices_idx].nvml = hm_adapters_nvml[platform_devices_id].nvml; - hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; + if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - if (hwmon_ctx->hm_nvml) + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) { - hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvml[platform_devices_id].buslanes_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvml[platform_devices_id].corespeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvml[platform_devices_id].fanspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvml[platform_devices_id].fanpolicy_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvml[platform_devices_id].memoryspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvml[platform_devices_id].temperature_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvml[platform_devices_id].threshold_shutdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvml[platform_devices_id].threshold_slowdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvml[platform_devices_id].throttle_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvml[platform_devices_id].utilization_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].adl = hm_adapters_adl[device_id].adl; + hwmon_ctx->hm_device[backend_devices_idx].sysfs = hm_adapters_sysfs[device_id].sysfs; + hwmon_ctx->hm_device[backend_devices_idx].nvapi = 0; + hwmon_ctx->hm_device[backend_devices_idx].nvml = 0; + hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; + + if (hwmon_ctx->hm_adl) + { + hwmon_ctx->hm_device[backend_devices_idx].od_version = hm_adapters_adl[device_id].od_version; + + hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_adl[device_id].buslanes_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_adl[device_id].corespeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_adl[device_id].fanspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_adl[device_id].fanpolicy_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_adl[device_id].memoryspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_adl[device_id].temperature_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_adl[device_id].threshold_shutdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_adl[device_id].threshold_slowdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_adl[device_id].throttle_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_adl[device_id].utilization_get_supported; + } + + if (hwmon_ctx->hm_sysfs) + { + hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_sysfs[device_id].buslanes_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_sysfs[device_id].corespeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_sysfs[device_id].fanspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_sysfs[device_id].fanpolicy_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_sysfs[device_id].memoryspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_sysfs[device_id].temperature_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_sysfs[device_id].threshold_shutdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_sysfs[device_id].threshold_slowdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_sysfs[device_id].throttle_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_sysfs[device_id].utilization_get_supported; + } } - if (hwmon_ctx->hm_nvapi) + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) { - hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvapi[platform_devices_id].buslanes_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvapi[platform_devices_id].corespeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvapi[platform_devices_id].fanspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvapi[platform_devices_id].fanpolicy_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvapi[platform_devices_id].memoryspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvapi[platform_devices_id].temperature_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvapi[platform_devices_id].threshold_shutdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvapi[platform_devices_id].threshold_slowdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvapi[platform_devices_id].throttle_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvapi[platform_devices_id].utilization_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].adl = 0; + hwmon_ctx->hm_device[backend_devices_idx].sysfs = 0; + hwmon_ctx->hm_device[backend_devices_idx].nvapi = hm_adapters_nvapi[device_id].nvapi; + hwmon_ctx->hm_device[backend_devices_idx].nvml = hm_adapters_nvml[device_id].nvml; + hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; + + if (hwmon_ctx->hm_nvml) + { + hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvml[device_id].buslanes_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvml[device_id].corespeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvml[device_id].fanspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvml[device_id].fanpolicy_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvml[device_id].memoryspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvml[device_id].temperature_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvml[device_id].threshold_shutdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvml[device_id].threshold_slowdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvml[device_id].throttle_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvml[device_id].utilization_get_supported; + } + + if (hwmon_ctx->hm_nvapi) + { + hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvapi[device_id].buslanes_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvapi[device_id].corespeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvapi[device_id].fanspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvapi[device_id].fanpolicy_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvapi[device_id].memoryspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvapi[device_id].temperature_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvapi[device_id].threshold_shutdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvapi[device_id].threshold_slowdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvapi[device_id].throttle_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvapi[device_id].utilization_get_supported; + } } } diff --git a/src/induct.c b/src/induct.c index 42e39e11a..46dc26eb2 100644 --- a/src/induct.c +++ b/src/induct.c @@ -43,7 +43,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; diff --git a/src/loopback.c b/src/loopback.c index db4ab8c1d..057c1e456 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -64,7 +64,7 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; diff --git a/src/main.c b/src/main.c index 9cce0b835..48c357c1a 100644 --- a/src/main.c +++ b/src/main.c @@ -190,7 +190,7 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA status_ctx->shutdown_outer = false; - if ((user_options->example_hashes == false) && (user_options->keyspace == false) && (user_options->stdout_flag == false) && (user_options->opencl_info == false) && (user_options->speed_only == false)) + if ((user_options->example_hashes == false) && (user_options->keyspace == false) && (user_options->stdout_flag == false) && (user_options->backend_info == false) && (user_options->speed_only == false)) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { @@ -263,7 +263,7 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB if (user_options->example_hashes == true) return; if (user_options->keyspace == true) return; - if (user_options->opencl_info == true) return; + if (user_options->backend_info == true) return; if (user_options->stdout_flag == true) return; // if we had a prompt, clear it @@ -512,9 +512,9 @@ static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, { if (hashconfig->has_optimized_kernel == true) { - event_log_advice (hashcat_ctx, "ATTENTION! Pure (unoptimized) OpenCL kernels selected."); + event_log_advice (hashcat_ctx, "ATTENTION! Pure (unoptimized) backend kernels selected."); event_log_advice (hashcat_ctx, "Using pure kernels enables cracking longer passwords but for the price of drastically reduced performance."); - event_log_advice (hashcat_ctx, "If you want to switch to optimized OpenCL kernels, append -O to your commandline."); + event_log_advice (hashcat_ctx, "If you want to switch to optimized backend kernels, append -O to your commandline."); event_log_advice (hashcat_ctx, "See the above message to find out about the exact limits."); event_log_advice (hashcat_ctx, NULL); } @@ -567,7 +567,7 @@ static void main_backend_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory..."); } -static void main_opencl_device_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_backend_device_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -575,10 +575,10 @@ static void main_opencl_device_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx const u32 *device_id = (const u32 *) buf; - event_log_info_nn (hashcat_ctx, "Initializing OpenCL runtime for device #%u...", *device_id + 1); + event_log_info_nn (hashcat_ctx, "Initializing backend runtime for device #%u...", *device_id + 1); } -static void main_opencl_device_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_backend_device_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -586,7 +586,7 @@ static void main_opencl_device_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ct const u32 *device_id = (const u32 *) buf; - event_log_info_nn (hashcat_ctx, "Initialized OpenCL runtime for device #%u...", *device_id + 1); + event_log_info_nn (hashcat_ctx, "Initialized backend runtime for device #%u...", *device_id + 1); } static void main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -735,7 +735,7 @@ static void main_monitor_performance_hint (MAYBE_UNUSED hashcat_ctx_t *hashcat_c event_log_advice (hashcat_ctx, NULL); } - event_log_advice (hashcat_ctx, "* Update your OpenCL runtime / driver the right way:"); + event_log_advice (hashcat_ctx, "* Update your backend API runtime / driver the right way:"); event_log_advice (hashcat_ctx, " https://hashcat.net/faq/wrongdriver"); event_log_advice (hashcat_ctx, NULL); event_log_advice (hashcat_ctx, "* Create more work items to make use of your parallelization power:"); @@ -1022,10 +1022,10 @@ static void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, co case EVENT_MONITOR_PERFORMANCE_HINT: main_monitor_performance_hint (hashcat_ctx, buf, len); break; case EVENT_MONITOR_NOINPUT_HINT: main_monitor_noinput_hint (hashcat_ctx, buf, len); break; case EVENT_MONITOR_NOINPUT_ABORT: main_monitor_noinput_abort (hashcat_ctx, buf, len); break; - case EVENT_OPENCL_SESSION_POST: main_backend_session_post (hashcat_ctx, buf, len); break; - case EVENT_OPENCL_SESSION_PRE: main_backend_session_pre (hashcat_ctx, buf, len); break; - case EVENT_OPENCL_DEVICE_INIT_POST: main_opencl_device_init_post (hashcat_ctx, buf, len); break; - case EVENT_OPENCL_DEVICE_INIT_PRE: main_opencl_device_init_pre (hashcat_ctx, buf, len); break; + case EVENT_BACKEND_SESSION_POST: main_backend_session_post (hashcat_ctx, buf, len); break; + case EVENT_BACKEND_SESSION_PRE: main_backend_session_pre (hashcat_ctx, buf, len); break; + case EVENT_BACKEND_DEVICE_INIT_POST: main_backend_device_init_post (hashcat_ctx, buf, len); break; + case EVENT_BACKEND_DEVICE_INIT_PRE: main_backend_device_init_pre (hashcat_ctx, buf, len); break; case EVENT_OUTERLOOP_FINISHED: main_outerloop_finished (hashcat_ctx, buf, len); break; case EVENT_OUTERLOOP_MAINSCREEN: main_outerloop_mainscreen (hashcat_ctx, buf, len); break; case EVENT_OUTERLOOP_STARTING: main_outerloop_starting (hashcat_ctx, buf, len); break; @@ -1106,7 +1106,7 @@ int main (int argc, char **argv) return 0; } - // init a hashcat session; this initializes opencl devices, hwmon, etc + // init a hashcat session; this initializes backend devices, hwmon, etc welcome_screen (hashcat_ctx, VERSION_TAG); @@ -1128,11 +1128,11 @@ int main (int argc, char **argv) rc_final = 0; } - else if (user_options->opencl_info == true) + else if (user_options->backend_info == true) { - // if this is just opencl_info, no need to execute some real cracking session + // if this is just backend_info, no need to execute some real cracking session - opencl_info (hashcat_ctx); + backend_info (hashcat_ctx); rc_final = 0; } @@ -1140,7 +1140,7 @@ int main (int argc, char **argv) { // now execute hashcat - opencl_info_compact (hashcat_ctx); + backend_info_compact (hashcat_ctx); user_options_info (hashcat_ctx); @@ -1148,7 +1148,7 @@ int main (int argc, char **argv) } } - // finish the hashcat session, this shuts down opencl devices, hwmon, etc + // finish the hashcat session, this shuts down backend devices, hwmon, etc hashcat_session_destroy (hashcat_ctx); diff --git a/src/mpsp.c b/src/mpsp.c index c81f6c2e5..c3a54e47d 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -1398,7 +1398,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/outfile_check.c b/src/outfile_check.c index 4a63e77c8..db15049c0 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -363,7 +363,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->speed_only == true) return 0; if (user_options->progress_only == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (hashconfig->outfile_check_disable == true) return 0; diff --git a/src/potfile.c b/src/potfile.c index b3015e04e..9516d4ae5 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -103,7 +103,7 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->benchmark == true) return 0; if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; if (user_options->progress_only == true) return 0; diff --git a/src/restore.c b/src/restore.c index 042555433..8f61cc6ae 100644 --- a/src/restore.c +++ b/src/restore.c @@ -304,7 +304,7 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; diff --git a/src/straight.c b/src/straight.c index 7b45825cd..0581838ec 100644 --- a/src/straight.c +++ b/src/straight.c @@ -214,7 +214,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/terminal.c b/src/terminal.c index 9d9d2ddcc..2ffd2df55 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -654,7 +654,7 @@ void example_hashes (hashcat_ctx_t *hashcat_ctx) } } -void opencl_info (hashcat_ctx_t *hashcat_ctx) +void backend_info (hashcat_ctx_t *hashcat_ctx) { const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; @@ -684,7 +684,7 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx) if (device_param->device_id_alias_cnt) { - event_log_info (hashcat_ctx, "Backend Device ID #%d (alias: #%d)", device_id + 1, device_param->device_id_alias_buf[0] + 1); + event_log_info (hashcat_ctx, "Backend Device ID #%d (Alias: #%d)", device_id + 1, device_param->device_id_alias_buf[0] + 1); } else { @@ -745,7 +745,7 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx) if (device_param->device_id_alias_cnt) { - event_log_info (hashcat_ctx, " Backend Device ID #%d (alias: #%d)", device_id + 1, device_param->device_id_alias_buf[0] + 1); + event_log_info (hashcat_ctx, " Backend Device ID #%d (Alias: #%d)", device_id + 1, device_param->device_id_alias_buf[0] + 1); } else { @@ -768,7 +768,7 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx) } } -void opencl_info_compact (hashcat_ctx_t *hashcat_ctx) +void backend_info_compact (hashcat_ctx_t *hashcat_ctx) { const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; const user_options_t *user_options = hashcat_ctx->user_options; diff --git a/src/tuningdb.c b/src/tuningdb.c index 91425f306..db88cf57a 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -57,7 +57,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) if (user_options->example_hashes == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->show == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/usage.c b/src/usage.c index 2b564568e..b6d36d379 100644 --- a/src/usage.c +++ b/src/usage.c @@ -89,15 +89,15 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X | --bitmap-max=24", " --cpu-affinity | Str | Locks to CPU devices, separated with commas | --cpu-affinity=1,2,3", " --example-hashes | | Show an example hash for each hash-mode |", - " -I, --opencl-info | | Show info about detected OpenCL platforms/devices | -I", - " -d, --opencl-devices | Str | OpenCL devices to use, separated with commas | -d 1", + " -I, --backend-info | | Show info about detected backend API devices | -I", + " -d, --backend-devices | Str | Backend devices to use, separated with commas | -d 1", " -D, --opencl-device-types | Str | OpenCL device-types to use, separated with commas | -D 1", - " --opencl-vector-width | Num | Manually override OpenCL vector-width to X | --opencl-vector=4", " -O, --optimized-kernel-enable | | Enable optimized kernels (limits password length) |", " -w, --workload-profile | Num | Enable a specific workload profile, see pool below | -w 3", " -n, --kernel-accel | Num | Manual workload tuning, set outerloop step size to X | -n 64", " -u, --kernel-loops | Num | Manual workload tuning, set innerloop step size to X | -u 256", " -T, --kernel-threads | Num | Manual workload tuning, set thread count to X | -T 64", + " --backend-vector-width | Num | Manually override backend vector-width to X | --backend-vector=4", " --spin-damp | Num | Use CPU for device synchronization, in percent | --spin-damp=50", " --hwmon-disable | | Disable temperature and fanspeed reads and triggers |", " --hwmon-temp-abort | Num | Abort if temperature reaches X degrees Celsius | --hwmon-temp-abort=100", diff --git a/src/user_options.c b/src/user_options.c index 2691c565a..89a4b14b2 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -28,6 +28,9 @@ static const struct option long_options[] = { {"advice-disable", no_argument, NULL, IDX_ADVICE_DISABLE}, {"attack-mode", required_argument, NULL, IDX_ATTACK_MODE}, + {"backend-devices", required_argument, NULL, IDX_BACKEND_DEVICES}, + {"backend-info", no_argument, NULL, IDX_BACKEND_INFO}, + {"backend-vector-width", required_argument, NULL, IDX_BACKEND_VECTOR_WIDTH}, {"benchmark-all", no_argument, NULL, IDX_BENCHMARK_ALL}, {"benchmark", no_argument, NULL, IDX_BENCHMARK}, {"bitmap-max", required_argument, NULL, IDX_BITMAP_MAX}, @@ -75,10 +78,7 @@ static const struct option long_options[] = {"markov-hcstat2", required_argument, NULL, IDX_MARKOV_HCSTAT2}, {"markov-threshold", required_argument, NULL, IDX_MARKOV_THRESHOLD}, {"nonce-error-corrections", required_argument, NULL, IDX_NONCE_ERROR_CORRECTIONS}, - {"opencl-devices", required_argument, NULL, IDX_OPENCL_DEVICES}, {"opencl-device-types", required_argument, NULL, IDX_OPENCL_DEVICE_TYPES}, - {"opencl-info", no_argument, NULL, IDX_OPENCL_INFO}, - {"opencl-vector-width", required_argument, NULL, IDX_OPENCL_VECTOR_WIDTH}, {"optimized-kernel-enable", no_argument, NULL, IDX_OPTIMIZED_KERNEL_ENABLE}, {"outfile-autohex-disable", no_argument, NULL, IDX_OUTFILE_AUTOHEX_DISABLE}, {"outfile-check-dir", required_argument, NULL, IDX_OUTFILE_CHECK_DIR}, @@ -151,6 +151,9 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->advice_disable = ADVICE_DISABLE; user_options->attack_mode = ATTACK_MODE; + user_options->backend_devices = NULL; + user_options->backend_info = BACKEND_INFO; + user_options->backend_vector_width = BACKEND_VECTOR_WIDTH; user_options->benchmark_all = BENCHMARK_ALL; user_options->benchmark = BENCHMARK; user_options->bitmap_max = BITMAP_MAX; @@ -202,10 +205,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->markov_hcstat2 = NULL; user_options->markov_threshold = MARKOV_THRESHOLD; user_options->nonce_error_corrections = NONCE_ERROR_CORRECTIONS; - user_options->opencl_devices = NULL; user_options->opencl_device_types = NULL; - user_options->opencl_info = OPENCL_INFO; - user_options->opencl_vector_width = OPENCL_VECTOR_WIDTH; user_options->optimized_kernel_enable = OPTIMIZED_KERNEL_ENABLE; user_options->outfile_autohex = OUTFILE_AUTOHEX; user_options->outfile_check_dir = NULL; @@ -304,7 +304,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_MARKOV_THRESHOLD: case IDX_OUTFILE_FORMAT: case IDX_OUTFILE_CHECK_TIMER: - case IDX_OPENCL_VECTOR_WIDTH: + case IDX_BACKEND_VECTOR_WIDTH: case IDX_WORKLOAD_PROFILE: case IDX_KERNEL_ACCEL: case IDX_KERNEL_LOOPS: @@ -423,11 +423,11 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_HEX_SALT: user_options->hex_salt = true; break; case IDX_HEX_WORDLIST: user_options->hex_wordlist = true; break; case IDX_CPU_AFFINITY: user_options->cpu_affinity = optarg; break; - case IDX_OPENCL_INFO: user_options->opencl_info = true; break; - case IDX_OPENCL_DEVICES: user_options->opencl_devices = optarg; break; + case IDX_BACKEND_INFO: user_options->backend_info = true; break; + case IDX_BACKEND_DEVICES: user_options->backend_devices = optarg; break; + case IDX_BACKEND_VECTOR_WIDTH: user_options->backend_vector_width = hc_strtoul (optarg, NULL, 10); + user_options->backend_vector_width_chgd = true; break; case IDX_OPENCL_DEVICE_TYPES: user_options->opencl_device_types = optarg; break; - case IDX_OPENCL_VECTOR_WIDTH: user_options->opencl_vector_width = hc_strtoul (optarg, NULL, 10); - user_options->opencl_vector_width_chgd = true; break; case IDX_OPTIMIZED_KERNEL_ENABLE: user_options->optimized_kernel_enable = true; break; case IDX_WORKLOAD_PROFILE: user_options->workload_profile = hc_strtoul (optarg, NULL, 10); user_options->workload_profile_chgd = true; break; @@ -856,11 +856,11 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if (user_options->opencl_vector_width_chgd == true) + if (user_options->backend_vector_width_chgd == true) { - if (is_power_of_2 (user_options->opencl_vector_width) == false || user_options->opencl_vector_width > 16) + if (is_power_of_2 (user_options->backend_vector_width) == false || user_options->backend_vector_width > 16) { - event_log_error (hashcat_ctx, "opencl-vector-width %u is not allowed.", user_options->opencl_vector_width); + event_log_error (hashcat_ctx, "backend-vector-width %u is not allowed.", user_options->backend_vector_width); return -1; } @@ -1087,11 +1087,11 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) } } - if (user_options->opencl_devices != NULL) + if (user_options->backend_devices != NULL) { - if (strlen (user_options->opencl_devices) == 0) + if (strlen (user_options->backend_devices) == 0) { - event_log_error (hashcat_ctx, "Invalid --opencl-devices value - must not be empty."); + event_log_error (hashcat_ctx, "Invalid --backend-devices value - must not be empty."); return -1; } @@ -1220,7 +1220,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) show_error = false; } } - else if (user_options->opencl_info == true) + else if (user_options->backend_info == true) { if (user_options->hc_argc == 0) { @@ -1420,9 +1420,9 @@ void user_options_session_auto (hashcat_ctx_t *hashcat_ctx) user_options->session = "stdout"; } - if (user_options->opencl_info == true) + if (user_options->backend_info == true) { - user_options->session = "opencl_info"; + user_options->session = "backend_info"; } if (user_options->show == true) @@ -1469,7 +1469,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) } if (user_options->example_hashes == true - || user_options->opencl_info == true + || user_options->backend_info == true || user_options->keyspace == true || user_options->speed_only == true || user_options->progress_only == true @@ -1546,17 +1546,17 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) if (user_options->slow_candidates == true) { - user_options->opencl_vector_width = 1; + user_options->backend_vector_width = 1; } if (user_options->stdout_flag == true) { - user_options->force = true; - user_options->hash_mode = 2000; - user_options->kernel_accel = 1024; - user_options->opencl_vector_width = 1; - user_options->outfile_format = OUTFILE_FMT_PLAIN; - user_options->quiet = true; + user_options->force = true; + user_options->hash_mode = 2000; + user_options->kernel_accel = 1024; + user_options->backend_vector_width = 1; + user_options->outfile_format = OUTFILE_FMT_PLAIN; + user_options->quiet = true; if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { @@ -1580,9 +1580,9 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) } } - if (user_options->opencl_info == true) + if (user_options->backend_info == true) { - user_options->opencl_devices = NULL; + user_options->backend_devices = NULL; user_options->opencl_device_types = hcstrdup ("1,2,3"); user_options->quiet = true; } @@ -1638,7 +1638,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) { } - else if (user_options->opencl_info == true) + else if (user_options->backend_info == true) { } @@ -1718,9 +1718,9 @@ void user_options_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "* --force"); } - if (user_options->opencl_devices) + if (user_options->backend_devices) { - event_log_info (hashcat_ctx, "* --opencl-devices=%s", user_options->opencl_devices); + event_log_info (hashcat_ctx, "* --backend-devices=%s", user_options->backend_devices); } if (user_options->opencl_device_types) @@ -1733,9 +1733,9 @@ void user_options_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "* --optimized-kernel-enable"); } - if (user_options->opencl_vector_width_chgd == true) + if (user_options->backend_vector_width_chgd == true) { - event_log_info (hashcat_ctx, "* --opencl-vector-width=%u", user_options->opencl_vector_width); + event_log_info (hashcat_ctx, "* --backend-vector-width=%u", user_options->backend_vector_width); } if (user_options->kernel_accel_chgd == true) @@ -1772,9 +1772,9 @@ void user_options_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "# option: --force"); } - if (user_options->opencl_devices) + if (user_options->backend_devices) { - event_log_info (hashcat_ctx, "# option: --opencl-devices=%s", user_options->opencl_devices); + event_log_info (hashcat_ctx, "# option: --backend-devices=%s", user_options->backend_devices); } if (user_options->opencl_device_types) @@ -1787,9 +1787,9 @@ void user_options_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "# option: --optimized-kernel-enable"); } - if (user_options->opencl_vector_width_chgd == true) + if (user_options->backend_vector_width_chgd == true) { - event_log_info (hashcat_ctx, "# option: --opencl-vector-width=%u", user_options->opencl_vector_width); + event_log_info (hashcat_ctx, "# option: --backend-vector-width=%u", user_options->backend_vector_width); } if (user_options->kernel_accel_chgd == true) @@ -1851,7 +1851,7 @@ void user_options_extra_init (hashcat_ctx_t *hashcat_ctx) { } - else if (user_options->opencl_info == true) + else if (user_options->backend_info == true) { } @@ -2563,7 +2563,7 @@ int user_options_check_files (hashcat_ctx_t *hashcat_ctx) hcfree (modulefile); - // same check but for an OpenCL kernel + // same check but for an backend kernel char *kernelfile = (char *) hcmalloc (HCBUFSIZ_TINY); @@ -2694,7 +2694,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_string (user_options->induction_dir); logfile_top_string (user_options->keyboard_layout_mapping); logfile_top_string (user_options->markov_hcstat2); - logfile_top_string (user_options->opencl_devices); + logfile_top_string (user_options->backend_devices); logfile_top_string (user_options->opencl_device_types); logfile_top_string (user_options->outfile); logfile_top_string (user_options->outfile_check_dir); @@ -2740,8 +2740,8 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->markov_classic); logfile_top_uint (user_options->markov_disable); logfile_top_uint (user_options->markov_threshold); - logfile_top_uint (user_options->opencl_info); - logfile_top_uint (user_options->opencl_vector_width); + logfile_top_uint (user_options->backend_info); + logfile_top_uint (user_options->backend_vector_width); logfile_top_uint (user_options->optimized_kernel_enable); logfile_top_uint (user_options->outfile_autohex); logfile_top_uint (user_options->outfile_check_timer); diff --git a/src/wordlist.c b/src/wordlist.c index bafc9a2dd..34b595729 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -560,7 +560,7 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx) if (user_options->benchmark == true) return 0; if (user_options->example_hashes == true) return 0; if (user_options->left == true) return 0; - if (user_options->opencl_info == true) return 0; + if (user_options->backend_info == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0;