diff --git a/src/backend.c b/src/backend.c index 4120f449d..197792f42 100644 --- a/src/backend.c +++ b/src/backend.c @@ -4384,6 +4384,17 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) hip_close (hashcat_ctx); } + #if defined (_WIN) + if ((rc_hip_init == 0) && (rc_hiprtc_init == -1)) + { + event_log_warning (hashcat_ctx, "Support for HIPRTC was dropped by AMD Adrenalin Edition 22.7.1 and later."); + event_log_warning (hashcat_ctx, "This is not a hashcat problem."); + event_log_warning (hashcat_ctx, NULL); + event_log_warning (hashcat_ctx, "Please install the AMD HIP SDK"); + event_log_warning (hashcat_ctx, NULL); + } + #endif + /** * Load and map HIPRTC library calls */ @@ -4401,17 +4412,6 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) hiprtc_close (hashcat_ctx); } - if ((rc_hip_init == 0) && (rc_hiprtc_init == -1)) - { - #if defined (_WIN) - event_log_warning (hashcat_ctx, "Support for HIPRTC was dropped by AMD Adrenalin Edition 22.7.1 and later."); - event_log_warning (hashcat_ctx, "This is not a hashcat problem."); - event_log_warning (hashcat_ctx, NULL); - event_log_warning (hashcat_ctx, "Please install the AMD HIP SDK"); - event_log_warning (hashcat_ctx, NULL); - #endif - } - /** * Check if both HIP and HIPRTC were load successful */ @@ -7149,6 +7149,39 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->pcie_bus = amdtopo.pcie.bus; device_param->pcie_device = amdtopo.pcie.device; device_param->pcie_function = amdtopo.pcie.function; + + if (user_options->stdout_flag == false) + { + // recommend HIP + + if ((backend_ctx->hip == NULL) || (backend_ctx->hiprtc == NULL)) + { + if (user_options->backend_ignore_hip == false) + { + if (backend_ctx->rc_hip_init == -1) + { + event_log_warning (hashcat_ctx, "Failed to initialize the AMD main driver HIP runtime library. Please install the AMD HIP SDK."); + event_log_warning (hashcat_ctx, NULL); + } + else + { + event_log_warning (hashcat_ctx, "Successfully initialized the AMD main driver HIP runtime library."); + event_log_warning (hashcat_ctx, NULL); + } + + if (backend_ctx->rc_hiprtc_init == -1) + { + event_log_warning (hashcat_ctx, "Failed to initialize AMD HIP RTC library. Please install the AMD HIP SDK."); + event_log_warning (hashcat_ctx, NULL); + } + else + { + event_log_warning (hashcat_ctx, "Successfully initialized AMD HIP RTC library."); + event_log_warning (hashcat_ctx, NULL); + } + } + } + } } if ((device_param->opencl_platform_vendor_id == VENDOR_ID_NV) && (device_param->opencl_device_vendor_id == VENDOR_ID_NV)) diff --git a/src/ext_hip.c b/src/ext_hip.c index 95bec69e1..5d5bf0510 100644 --- a/src/ext_hip.c +++ b/src/ext_hip.c @@ -8,9 +8,39 @@ #include "memory.h" #include "event.h" #include "ext_hip.h" +#include "shared.h" #include "dynloader.h" +char *hipDllPath (char *hipSDKPath) +{ + /* + AMD HIP DLLs is stored at "C:\Program Files\ROCm\X.Y\bin\amdhip64_X.dll" + + This function can return complete dll path based on major release version + X.Y parsed from the ENV variable HIP_PATH. + */ + + const char *marker = "\\ROCm\\"; + + int major = 0; + int minor = 0; + + const char *version_start = strstr (hipSDKPath, marker); + + if (version_start == NULL) return NULL; + + version_start += strlen (marker); // now points at "6.2\\" + + if (sscanf (version_start, "%d.%d", &major, &minor) != 2) return NULL; + + char *hipdllpath = NULL; + + hc_asprintf (&hipdllpath, "%s\\bin\\amdhip64_%d.dll", hipSDKPath, major); + + return (hipdllpath); +} + int hip_init (void *hashcat_ctx) { backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx; @@ -20,7 +50,22 @@ int hip_init (void *hashcat_ctx) memset (hip, 0, sizeof (HIP_PTR)); #if defined (_WIN) - hip->lib = hc_dlopen ("amdhip64.dll"); + char *hipSDKPath = getenv ("HIP_PATH"); + + if (hipSDKPath == NULL) return -1; + + char *hipdllpath = hipDllPath (hipSDKPath); + + if (hipdllpath) + { + hip->lib = hc_dlopen (hipdllpath); + + free (hipdllpath); + } + else + { + return -1; + } #elif defined (__APPLE__) hip->lib = hc_dlopen ("fixme.dylib"); #elif defined (__CYGWIN__)