2016-09-05 19:47:26 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-05 19:47:26 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-09-06 16:44:05 +00:00
|
|
|
#ifndef _DYNLOADER_H
|
|
|
|
#define _DYNLOADER_H
|
2016-09-05 19:47:26 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2017-02-23 23:55:06 +00:00
|
|
|
#ifdef _WIN
|
|
|
|
#include <windows.h>
|
|
|
|
#else
|
2016-09-05 19:47:26 +00:00
|
|
|
#include <dlfcn.h>
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (__APPLE__)
|
2016-09-05 19:47:26 +00:00
|
|
|
#include <mach-o/dyld.h>
|
|
|
|
#endif // __APPLE__
|
2017-02-23 23:55:06 +00:00
|
|
|
#endif // _WIN
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2016-10-01 11:03:31 +00:00
|
|
|
#ifdef _WIN
|
|
|
|
HMODULE hc_dlopen (LPCSTR lpLibFileName);
|
|
|
|
BOOL hc_dlclose (HMODULE hLibModule);
|
|
|
|
FARPROC hc_dlsym (HMODULE hModule, LPCSTR lpProcName);
|
2016-09-05 19:47:26 +00:00
|
|
|
#else
|
2016-10-01 11:03:31 +00:00
|
|
|
void *hc_dlopen (const char *fileName, int flag);
|
|
|
|
int hc_dlclose (void *handle);
|
|
|
|
void *hc_dlsym (void *module, const char *symbol);
|
2016-09-05 19:47:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define HC_LOAD_FUNC2(ptr,name,type,var,libname,noerr) \
|
|
|
|
ptr->name = (type) hc_dlsym (ptr->var, #name); \
|
|
|
|
if (noerr != -1) { \
|
|
|
|
if (!ptr->name) { \
|
|
|
|
if (noerr == 1) { \
|
2016-10-09 20:41:55 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
|
2016-09-05 19:47:26 +00:00
|
|
|
return -1; \
|
2016-10-09 20:41:55 +00:00
|
|
|
} else { \
|
|
|
|
event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
|
|
|
|
return 0; \
|
2016-09-05 19:47:26 +00:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HC_LOAD_FUNC(ptr,name,type,libname,noerr) \
|
|
|
|
ptr->name = (type) hc_dlsym (ptr->lib, #name); \
|
|
|
|
if (noerr != -1) { \
|
|
|
|
if (!ptr->name) { \
|
|
|
|
if (noerr == 1) { \
|
2016-10-09 20:41:55 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
|
2016-09-05 19:47:26 +00:00
|
|
|
return -1; \
|
2016-10-09 20:41:55 +00:00
|
|
|
} else { \
|
|
|
|
event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
|
|
|
|
return 0; \
|
2016-09-05 19:47:26 +00:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HC_LOAD_ADDR(ptr,name,type,func,addr,libname,noerr) \
|
|
|
|
ptr->name = (type) (*ptr->func) (addr); \
|
|
|
|
if (!ptr->name) { \
|
|
|
|
if (noerr == 1) { \
|
2016-10-09 20:41:55 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \
|
2016-09-05 19:47:26 +00:00
|
|
|
return -1; \
|
2016-10-09 20:41:55 +00:00
|
|
|
} else { \
|
|
|
|
event_log_warning (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \
|
|
|
|
return 0; \
|
2016-09-05 19:47:26 +00:00
|
|
|
} \
|
|
|
|
}
|
2016-09-06 16:44:05 +00:00
|
|
|
|
2016-09-30 15:41:40 +00:00
|
|
|
#endif // _DYNALOADER_H
|