2016-09-05 21:47:26 +02:00
|
|
|
/**
|
2016-09-11 22:20:15 +02:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-05 21:47:26 +02:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-09-06 18:44:05 +02:00
|
|
|
#ifndef _DYNLOADER_H
|
|
|
|
#define _DYNLOADER_H
|
2016-09-05 21:47:26 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2017-02-24 00:55:06 +01:00
|
|
|
#ifdef _WIN
|
|
|
|
#include <windows.h>
|
|
|
|
#else
|
2016-09-05 21:47:26 +02:00
|
|
|
#include <dlfcn.h>
|
2016-09-07 22:29:57 +02:00
|
|
|
#if defined (__APPLE__)
|
2016-09-05 21:47:26 +02:00
|
|
|
#include <mach-o/dyld.h>
|
|
|
|
#endif // __APPLE__
|
2017-02-24 00:55:06 +01:00
|
|
|
#endif // _WIN
|
2016-09-05 21:47:26 +02:00
|
|
|
|
2016-10-01 13:03:31 +02:00
|
|
|
#ifdef _WIN
|
2019-01-14 10:11:23 +01:00
|
|
|
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);
|
2016-09-05 21:47:26 +02:00
|
|
|
#else
|
2019-01-14 10:11:23 +01:00
|
|
|
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);
|
2016-09-05 21:47:26 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define HC_LOAD_FUNC2(ptr,name,type,var,libname,noerr) \
|
2019-11-10 01:42:50 +01:00
|
|
|
do { \
|
|
|
|
ptr->name = (type) hc_dlsym (ptr->var, #name); \
|
|
|
|
if (noerr != -1) { \
|
|
|
|
if (!ptr->name) { \
|
|
|
|
if (noerr == 1) { \
|
|
|
|
event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
|
|
|
|
return -1; \
|
|
|
|
} \
|
|
|
|
if (noerr != 1) { \
|
|
|
|
event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
|
|
|
|
return 0; \
|
|
|
|
} \
|
2016-09-05 21:47:26 +02:00
|
|
|
} \
|
|
|
|
} \
|
2019-11-10 01:42:50 +01:00
|
|
|
} while (0)
|
2016-09-05 21:47:26 +02:00
|
|
|
|
|
|
|
#define HC_LOAD_FUNC(ptr,name,type,libname,noerr) \
|
2019-11-10 01:42:50 +01:00
|
|
|
do { \
|
|
|
|
ptr->name = (type) hc_dlsym (ptr->lib, #name); \
|
|
|
|
if (noerr != -1) { \
|
|
|
|
if (!ptr->name) { \
|
|
|
|
if (noerr == 1) { \
|
|
|
|
event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
|
|
|
|
return -1; \
|
|
|
|
} \
|
|
|
|
if (noerr != 1) { \
|
|
|
|
event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
|
|
|
|
return 0; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define HC_LOAD_ADDR(ptr,name,type,func,addr,libname,noerr) \
|
|
|
|
do { \
|
|
|
|
ptr->name = (type) (*ptr->func) (addr); \
|
2016-09-05 21:47:26 +02:00
|
|
|
if (!ptr->name) { \
|
|
|
|
if (noerr == 1) { \
|
2019-11-10 01:42:50 +01:00
|
|
|
event_log_error (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \
|
2016-09-05 21:47:26 +02:00
|
|
|
return -1; \
|
2017-11-05 07:39:03 +01:00
|
|
|
} \
|
|
|
|
if (noerr != 1) { \
|
2019-11-10 01:42:50 +01:00
|
|
|
event_log_warning (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \
|
2016-10-09 22:41:55 +02:00
|
|
|
return 0; \
|
2016-09-05 21:47:26 +02:00
|
|
|
} \
|
|
|
|
} \
|
2019-11-10 01:42:50 +01:00
|
|
|
} while (0)
|
2016-09-06 18:44:05 +02:00
|
|
|
|
2016-09-30 17:41:40 +02:00
|
|
|
#endif // _DYNALOADER_H
|