mirror of
https://github.com/hashcat/hashcat.git
synced 2025-03-08 19:26:11 +00:00
Updated HIP SDK detection to use ENV variable on Windows
This commit is contained in:
parent
c1a10518fd
commit
08f6cf7e0a
@ -11,6 +11,42 @@
|
||||
|
||||
#include "dynloader.h"
|
||||
|
||||
|
||||
char* hiprtcDllPath(char* hipSDKPath)
|
||||
{
|
||||
/*
|
||||
AMD HIP RTC DLLs is stored at "C:\Program Files\ROCm\X.Y\bin\hiprtc0X0Y.dll"
|
||||
Tried using regex to simplify, but had compilation issues on mingw64 (linker
|
||||
had troubles with pcre.h)
|
||||
|
||||
This function can return complete dll path based on major release version
|
||||
X.Y parsed from the ENV variable HIP_PATH.
|
||||
*/
|
||||
|
||||
// Identifying major release version X.Y
|
||||
char* majorVersion = malloc(strlen("X.Y")+1);
|
||||
memcpy(majorVersion, hipSDKPath + (strlen(hipSDKPath) - 4), 3);
|
||||
memcpy(majorVersion+0x3, "\0", 1);
|
||||
|
||||
// Preparing DLL name "hiprtc0X0Y.dll"
|
||||
char* hiprtcDllName = malloc(strlen("hiprtcXXXX.dll")+1);
|
||||
memcpy(hiprtcDllName, "hiprtc0", strlen("hiprtc0"));
|
||||
|
||||
memcpy(hiprtcDllName + 0x7, majorVersion, 1);
|
||||
memcpy(hiprtcDllName + 0x8, "0", 1);
|
||||
memcpy(hiprtcDllName + 0x9, majorVersion + 2, 1);
|
||||
memcpy(hiprtcDllName + 0xa, ".dll\0", 5);
|
||||
|
||||
// Preparing complete path as "C:\Program Files\ROCm\X.Y\bin\hiprtc0X0Y.dll" to
|
||||
// return to the caller.
|
||||
char* hiprtcDllPath = malloc(strlen(hipSDKPath) + strlen("bin/") + strlen("hiprtcXXXX.dll") + 1);
|
||||
strcpy(hiprtcDllPath, hipSDKPath);
|
||||
strcat(hiprtcDllPath, "bin\\");
|
||||
strcat(hiprtcDllPath, hiprtcDllName);
|
||||
return(hiprtcDllPath);
|
||||
}
|
||||
|
||||
|
||||
int hiprtc_make_options_array_from_string (char *string, char **options)
|
||||
{
|
||||
char *saveptr = NULL;
|
||||
@ -41,14 +77,23 @@ int hiprtc_init (void *hashcat_ctx)
|
||||
#if defined (_WIN)
|
||||
hiprtc->lib = hc_dlopen ("hiprtc.dll");
|
||||
|
||||
if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("C:/Program Files/AMD/ROCm/5.5/bin/hiprtc0505.dll");
|
||||
// Check for HIP SDK installation from ENV
|
||||
const char* hipSDKPath = getenv("HIP_PATH");
|
||||
if (hipSDKPath != NULL && hiprtc->lib == NULL)
|
||||
{
|
||||
hiprtc->lib = hc_dlopen (hiprtcDllPath(hipSDKPath));
|
||||
}
|
||||
if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("amdhip64.dll");
|
||||
#elif defined (__APPLE__)
|
||||
hiprtc->lib = hc_dlopen ("fixme.dylib");
|
||||
#elif defined (__CYGWIN__)
|
||||
hiprtc->lib = hc_dlopen ("hiprtc.dll");
|
||||
|
||||
if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("C:/Program Files/AMD/ROCm/5.5/bin/hiprtc0505.dll");
|
||||
// Check for HIP SDK installation from ENV
|
||||
const char* hipSDKPath = getenv("HIP_PATH");
|
||||
if (hipSDKPath != NULL && hiprtc->lib == NULL)
|
||||
{
|
||||
hiprtc->lib = hc_dlopen (hiprtcDllPath(hipSDKPath));
|
||||
}
|
||||
if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("amdhip64.dll");
|
||||
#else
|
||||
hiprtc->lib = hc_dlopen ("libhiprtc.so");
|
||||
|
Loading…
Reference in New Issue
Block a user