1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-02-16 17:42:04 +00:00

Add NVML and NVAPI support to Cygwin

This commit is contained in:
Rosen Penev 2017-02-07 12:22:20 -08:00
parent 65d5921eda
commit ee0911c26e
4 changed files with 66 additions and 2 deletions

View File

@ -12,8 +12,8 @@
#define NVAPI_INTERFACE extern NvAPI_Status #define NVAPI_INTERFACE extern NvAPI_Status
typedef unsigned long NvU32; typedef unsigned int NvU32;
typedef signed long NvS32; typedef signed int NvS32;
#define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name #define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name

View File

@ -4,6 +4,9 @@
*/ */
#include <errno.h> #include <errno.h>
#if defined (__CYGWIN__)
#include <sys/cygwin.h>
#endif
#ifndef _HWMON_H #ifndef _HWMON_H
#define _HWMON_H #define _HWMON_H

View File

@ -549,6 +549,49 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx)
hcfree (Buffer); 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) #elif defined (_POSIX)
nvml->lib = hc_dlopen ("libnvidia-ml.so", RTLD_NOW); nvml->lib = hc_dlopen ("libnvidia-ml.so", RTLD_NOW);
#endif #endif
@ -1052,15 +1095,29 @@ static int nvapi_init (hashcat_ctx_t *hashcat_ctx)
memset (nvapi, 0, sizeof (NVAPI_PTR)); memset (nvapi, 0, sizeof (NVAPI_PTR));
#if defined (_WIN) #if defined (_WIN)
#if defined (_WIN64) #if defined (_WIN64)
nvapi->lib = hc_dlopen ("nvapi64.dll"); nvapi->lib = hc_dlopen ("nvapi64.dll");
#else #else
nvapi->lib = hc_dlopen ("nvapi.dll"); nvapi->lib = hc_dlopen ("nvapi.dll");
#endif #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 #else
nvapi->lib = hc_dlopen ("nvapi.so", RTLD_NOW); // uhm yes, but .. yeah nvapi->lib = hc_dlopen ("nvapi.so", RTLD_NOW); // uhm yes, but .. yeah
#endif #endif
#endif
if (!nvapi->lib) if (!nvapi->lib)
{ {
//if (user_options->quiet == false) //if (user_options->quiet == false)

View File

@ -2884,6 +2884,10 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
#if defined (_WIN) #if defined (_WIN)
need_nvapi = true; need_nvapi = true;
#endif #endif
#if defined (__CYGWIN__)
need_nvapi = true;
#endif
} }
} }