diff --git a/include/ext_nvapi.h b/include/ext_nvapi.h index f59332d73..39654ed52 100644 --- a/include/ext_nvapi.h +++ b/include/ext_nvapi.h @@ -12,8 +12,8 @@ #define NVAPI_INTERFACE extern NvAPI_Status -typedef unsigned long NvU32; -typedef signed long NvS32; +typedef unsigned int NvU32; +typedef signed int NvS32; #define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name diff --git a/include/hwmon.h b/include/hwmon.h index a793820bf..18c99fd21 100644 --- a/include/hwmon.h +++ b/include/hwmon.h @@ -4,6 +4,9 @@ */ #include +#if defined (__CYGWIN__) +#include +#endif #ifndef _HWMON_H #define _HWMON_H diff --git a/src/hwmon.c b/src/hwmon.c index b912dde56..11dc3f570 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -549,6 +549,49 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) hcfree (Buffer); } + #elif defined (__CYGWIN__) + + nvml->lib = hc_dlopen("nvml.dll", RTLD_NOW); + + if (!nvml->lib) + { + FILE *nvml_lib = fopen ("/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb"); + + if (nvml_lib == NULL) + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "NVML library load failed: %m, proceed without NVML HWMon enabled"); + + return -1; + } + + char *nvml_winpath, *nvml_cygpath; + + nvml_winpath = (char *) hcmalloc (100); + + fread (nvml_winpath, 100, 1, nvml_lib); + + ssize_t size = cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, NULL, 0); + + if (size > 0) + { + nvml_cygpath = (char *) hcmalloc (size + 9); + + cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, nvml_cygpath, size); + } + else + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "Could not find NVML in the system, proceed without NVML HWMon enabled"); + + return -1; + } + + strcat (nvml_cygpath, "/nvml.dll"); + + nvml->lib = hc_dlopen (nvml_cygpath, RTLD_NOW); + } + #elif defined (_POSIX) nvml->lib = hc_dlopen ("libnvidia-ml.so", RTLD_NOW); #endif @@ -1052,15 +1095,29 @@ static int nvapi_init (hashcat_ctx_t *hashcat_ctx) memset (nvapi, 0, sizeof (NVAPI_PTR)); #if defined (_WIN) + #if defined (_WIN64) nvapi->lib = hc_dlopen ("nvapi64.dll"); #else nvapi->lib = hc_dlopen ("nvapi.dll"); #endif + + #else + + #if defined (__CYGWIN__) + + #if defined (__x86_x64__) + nvapi->lib = hc_dlopen ("nvapi64.dll", RTLD_NOW); + #else + nvapi->lib = hc_dlopen ("nvapi.dll", RTLD_NOW); + #endif + #else nvapi->lib = hc_dlopen ("nvapi.so", RTLD_NOW); // uhm yes, but .. yeah #endif + #endif + if (!nvapi->lib) { //if (user_options->quiet == false) diff --git a/src/opencl.c b/src/opencl.c index 8adac3e6c..f85576630 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -2884,6 +2884,10 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) #if defined (_WIN) need_nvapi = true; #endif + + #if defined (__CYGWIN__) + need_nvapi = true; + #endif } }