1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

Refresh dynloader management

This commit is contained in:
jsteube 2019-01-14 10:11:23 +01:00
parent 0cd2c5ab35
commit 083d6e1fb2
10 changed files with 35 additions and 47 deletions

View File

@ -18,13 +18,13 @@
#endif // _WIN
#ifdef _WIN
HMODULE hc_dlopen (LPCSTR lpLibFileName);
BOOL hc_dlclose (HMODULE hLibModule);
FARPROC hc_dlsym (HMODULE hModule, LPCSTR lpProcName);
hc_dynlib_t hc_dlopen (LPCSTR lpLibFileName);
BOOL hc_dlclose (hc_dynlib_t hLibModule);
hc_dynfunc_t hc_dlsym (hc_dynlib_t hModule, LPCSTR lpProcName);
#else
void *hc_dlopen (const char *filename);
int hc_dlclose (void *handle);
void *hc_dlsym (void *handle, const char *symbol);
hc_dynlib_t hc_dlopen (const char *filename);
int hc_dlclose (hc_dynlib_t handle);
hc_dynfunc_t hc_dlsym (hc_dynlib_t handle, const char *symbol);
#endif
#define HC_LOAD_FUNC2(ptr,name,type,var,libname,noerr) \

View File

@ -282,15 +282,9 @@ typedef int (ADL_API_CALL *ADL_OVERDRIVE6_CAPABILITIES_GET) (int, ADLOD6Capabili
typedef int (ADL_API_CALL *ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET) (int, int *, int *);
typedef int (ADL_API_CALL *ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET) (int, ADLOD6ParameterRange *);
#if defined (_POSIX)
typedef void *ADL_LIB;
#else
typedef HINSTANCE ADL_LIB;
#endif
typedef struct hm_adl_lib
{
ADL_LIB lib;
hc_dynlib_t lib;
ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy;
ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create;

View File

@ -70,15 +70,9 @@ typedef cl_int (CL_API_CALL *OCL_CLRELEASEPROGRAM) (cl_progra
typedef cl_int (CL_API_CALL *OCL_CLSETKERNELARG) (cl_kernel, cl_uint, size_t, const void *);
typedef cl_int (CL_API_CALL *OCL_CLWAITFOREVENTS) (cl_uint, const cl_event *);
#if defined (_POSIX)
typedef void *OCL_LIB;
#else
typedef HINSTANCE OCL_LIB;
#endif
typedef struct hc_opencl_lib
{
OCL_LIB lib;
hc_dynlib_t lib;
OCL_CLBUILDPROGRAM clBuildProgram;
OCL_CLCREATEBUFFER clCreateBuffer;

View File

@ -221,15 +221,9 @@ typedef int (*NVAPI_API_CALL NVAPI_GPU_GETPERFPOLICIESSTATUS) (NvPhysicalGpuHand
typedef int (*NVAPI_API_CALL NVAPI_GPU_GETBUSID) (NvPhysicalGpuHandle, NvU32 *);
typedef int (*NVAPI_API_CALL NVAPI_GPU_GETBUSSLOTID) (NvPhysicalGpuHandle, NvU32 *);
#if defined (_POSIX)
typedef void *NVAPI_LIB;
#else
typedef HINSTANCE NVAPI_LIB;
#endif
typedef struct hm_nvapi_lib
{
NVAPI_LIB lib;
hc_dynlib_t lib;
NVAPI_QUERYINTERFACE nvapi_QueryInterface;
NVAPI_INITIALIZE NvAPI_Initialize;

View File

@ -192,15 +192,9 @@ typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_SET_COMPUTEMODE) (nvmlDevice_t,
typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_SET_OPERATIONMODE) (nvmlDevice_t, nvmlGpuOperationMode_t);
typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_PCIINFO) (nvmlDevice_t, nvmlPciInfo_t *);
#if defined (_POSIX)
typedef void *NVML_LIB;
#else
typedef HINSTANCE NVML_LIB;
#endif
typedef struct hm_nvml_lib
{
NVML_LIB lib;
hc_dynlib_t lib;
NVML_ERROR_STRING nvmlErrorString;
NVML_INIT nvmlInit;

View File

@ -765,6 +765,14 @@ typedef enum brain_link_status
} brain_link_status_t;
#endif
#ifdef _WIN
typedef HMODULE hc_dynlib_t;
typedef FARPROC hc_dynfunc_t;
#else
typedef void * hc_dynlib_t;
typedef void * hc_dynfunc_t;
#endif
/**
* structs
*/
@ -2239,14 +2247,16 @@ typedef struct event_ctx
#define MODULE_DEFAULT (void *) -1
typedef void (*MODULE_INIT) (void *);
typedef struct module_ctx
{
void *module_handle;
size_t module_context_size;
int module_interface_version;
void (*module_init) (struct module_ctx *);
hc_dynlib_t module_handle;
MODULE_INIT module_init;
u32 (*module_attack_exec) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *);
void *(*module_benchmark_esalt) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *);

View File

@ -641,10 +641,10 @@ hashcat64.bin: src/main.c $(LINUX_64_OBJS)
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX64) -o $@ $^ $(LFLAGS_CROSS_LINUX64) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
hashcat32.exe: src/main.c $(WIN_32_OBJS) $(WIN_ICONV_32)/lib/libiconv.a
$(CC_WIN_32) $(CFLAGS_CROSS_WIN32) -o $@ $^ $(LFLAGS_CROSS_WIN32) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
$(CC_WIN_32) $(CFLAGS_CROSS_WIN32) -o $@ $^ $(LFLAGS_CROSS_WIN32) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -Wl,--output-def,host32.def
hashcat64.exe: src/main.c $(WIN_64_OBJS) $(WIN_ICONV_64)/lib/libiconv.a
$(CC_WIN_64) $(CFLAGS_CROSS_WIN64) -o $@ $^ $(LFLAGS_CROSS_WIN64) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
$(CC_WIN_64) $(CFLAGS_CROSS_WIN64) -o $@ $^ $(LFLAGS_CROSS_WIN64) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -Wl,--output-def,host64.def
hashcat32.dll: src/main.c $(WIN_32_OBJS)
$(CC_WIN_32) $(CFLAGS_CROSS_WIN32) -o $@ $^ $(LFLAGS_CROSS_WIN32) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -shared

View File

@ -4,38 +4,39 @@
*/
#include "common.h"
#include "types.h"
#include "dynloader.h"
#ifdef _WIN
HMODULE hc_dlopen (LPCSTR lpLibFileName)
hc_dynlib_t hc_dlopen (LPCSTR lpLibFileName)
{
return LoadLibraryA (lpLibFileName);
}
BOOL hc_dlclose (HMODULE hLibModule)
BOOL hc_dlclose (hc_dynlib_t hLibModule)
{
return FreeLibrary (hLibModule);
}
FARPROC hc_dlsym (HMODULE hModule, LPCSTR lpProcName)
hc_dynfunc_t hc_dlsym (hc_dynlib_t hModule, LPCSTR lpProcName)
{
return GetProcAddress (hModule, lpProcName);
}
#else
void *hc_dlopen (const char *filename)
hc_dynlib_t hc_dlopen (const char *filename)
{
return dlopen (filename, RTLD_NOW);
}
int hc_dlclose (void *handle)
int hc_dlclose (hc_dynlib_t handle)
{
return dlclose (handle);
}
void *hc_dlsym (void *handle, const char *symbol)
hc_dynfunc_t hc_dlsym (hc_dynlib_t handle, const char *symbol)
{
return dlsym (handle, symbol);
}

View File

@ -4,6 +4,7 @@
*/
#include "common.h"
#include "types.h"
#include "ext_ADL.h"
void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize)

View File

@ -397,7 +397,7 @@ static bool module_load (hashcat_ctx_t *hashcat_ctx, module_ctx_t *module_ctx, c
return false;
}
module_ctx->module_init = hc_dlsym (module_ctx->module_handle, "module_init");
module_ctx->module_init = (MODULE_INIT) hc_dlsym (module_ctx->module_handle, "module_init");
if (module_ctx->module_init == NULL)
{
@ -406,7 +406,7 @@ static bool module_load (hashcat_ctx_t *hashcat_ctx, module_ctx_t *module_ctx, c
return false;
}
free (module_file);
hcfree (module_file);
return true;
}