From 495d89f831deaee49d4d48569dfef86a7b33154e Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 1 May 2019 07:27:10 +0200 Subject: [PATCH] Find alias devices across different backend API's --- include/types.h | 4 ++++ src/backend.c | 23 ++++++++++++++++++----- src/terminal.c | 22 +++++++++++++++++++--- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/include/types.h b/include/types.h index 3317f37cd..8052bea6f 100644 --- a/include/types.h +++ b/include/types.h @@ -996,6 +996,10 @@ typedef struct hc_device_param { int device_id; + // this occurs if the same device (pci address) is used by multiple backend API + int device_id_alias_cnt; + int device_id_alias_buf[DEVICES_MAX]; + u8 pcie_bus; u8 pcie_device; u8 pcie_function; diff --git a/src/backend.c b/src/backend.c index 9a24b81fe..72e084762 100644 --- a/src/backend.c +++ b/src/backend.c @@ -46,7 +46,7 @@ static bool is_same_device (const hc_device_param_t *src, const hc_device_param_ return true; } -static int backend_ctx_find_duplicate_devices (hashcat_ctx_t *hashcat_ctx) +static int backend_ctx_find_alias_devices (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; @@ -68,7 +68,16 @@ static int backend_ctx_find_duplicate_devices (hashcat_ctx_t *hashcat_ctx) if (is_same_device (device_param_src, device_param_dst) == false) continue; - device_param_dst->skipped = true; + device_param_src->device_id_alias_buf[device_param_src->device_id_alias_cnt] = device_param_dst->device_id; + device_param_src->device_id_alias_cnt++; + + device_param_dst->device_id_alias_buf[device_param_dst->device_id_alias_cnt] = device_param_src->device_id; + device_param_dst->device_id_alias_cnt++; + + if (device_param_dst->is_opencl == true) + { + device_param_dst->skipped = true; + } } } @@ -579,7 +588,7 @@ int nvrtc_init (hashcat_ctx_t *hashcat_ctx) memset (nvrtc, 0, sizeof (NVRTC_PTR)); #if defined (_WIN) - nvrtc->lib = hc_dlopen ("nvrtc"); + nvrtc->lib = hc_dlopen ("c:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.1\\nvrtc.lib"); #elif defined (__APPLE__) nvrtc->lib = hc_dlopen ("/System/Library/Frameworks/NVRTC.framework/NVRTC"); #elif defined (__CYGWIN__) @@ -764,7 +773,7 @@ int cuda_init (hashcat_ctx_t *hashcat_ctx) memset (cuda, 0, sizeof (CUDA_PTR)); #if defined (_WIN) - cuda->lib = hc_dlopen ("cuda"); + cuda->lib = hc_dlopen ("c:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.1\\cuda.lib"); #elif defined (__APPLE__) cuda->lib = hc_dlopen ("/System/Library/Frameworks/CUDA.framework/CUDA"); #elif defined (__CYGWIN__) @@ -3812,6 +3821,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->cuda_device = cuda_device; + device_param->is_cuda = true; + // device_name char *device_name = (char *) hcmalloc (HCBUFSIZ_TINY); @@ -4119,6 +4130,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->opencl_platform = opencl_platform; + device_param->is_opencl = true; + // opencl_device_type cl_device_type opencl_device_type; @@ -4942,7 +4955,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (user_options->force == false) { - backend_ctx_find_duplicate_devices (hashcat_ctx); + backend_ctx_find_alias_devices (hashcat_ctx); } // 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) diff --git a/src/terminal.c b/src/terminal.c index 1e65b2e53..9d9d2ddcc 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -682,7 +682,15 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx) u32 device_maxclock_frequency = device_param->device_maxclock_frequency; u64 device_global_mem = device_param->device_global_mem; - event_log_info (hashcat_ctx, "Backend Device ID #%d", device_id + 1); + 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); + } + else + { + event_log_info (hashcat_ctx, "Backend Device ID #%d", device_id + 1); + } + event_log_info (hashcat_ctx, " Name...........: %s", device_name); event_log_info (hashcat_ctx, " Processor(s)...: %u", device_processors); event_log_info (hashcat_ctx, " Clock..........: %u", device_maxclock_frequency); @@ -735,7 +743,15 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx) char *opencl_device_version = device_param->opencl_device_version; char *opencl_driver_version = device_param->opencl_driver_version; - event_log_info (hashcat_ctx, " Backend Device ID #%d", device_id + 1); + 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); + } + else + { + event_log_info (hashcat_ctx, " Backend Device ID #%d", device_id + 1); + } + event_log_info (hashcat_ctx, " Type...........: %s", ((opencl_device_type & CL_DEVICE_TYPE_CPU) ? "CPU" : ((opencl_device_type & CL_DEVICE_TYPE_GPU) ? "GPU" : "Accelerator"))); event_log_info (hashcat_ctx, " Vendor.ID......: %u", opencl_device_vendor_id); event_log_info (hashcat_ctx, " Vendor.........: %s", opencl_device_vendor); @@ -789,7 +805,7 @@ void opencl_info_compact (hashcat_ctx_t *hashcat_ctx) if ((device_param->skipped == false) && (device_param->skipped_warning == false)) { - event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 " MB allocatable, %uMCU", + event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 " MB, %uMCU", device_id + 1, device_name, device_global_mem / 1024 / 1024,