File: dynloader.h

package info (click to toggle)
hashcat 6.2.6%2Bds2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 62,716 kB
  • sloc: lisp: 584,043; ansic: 372,246; perl: 24,890; sh: 3,927; python: 868; makefile: 726
file content (79 lines) | stat: -rw-r--r-- 2,229 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
 * Author......: See docs/credits.txt
 * License.....: MIT
 */

#ifndef _DYNLOADER_H
#define _DYNLOADER_H

#include <stdlib.h>

#ifdef _WIN
#include <windows.h>
#else
#include <dlfcn.h>
#if defined (__APPLE__)
#include <mach-o/dyld.h>
#endif // __APPLE__
#endif // _WIN

#ifdef _WIN
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
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) \
  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; \
        } \
      } \
    } \
  } while (0)

#define HC_LOAD_FUNC(ptr,name,type,libname,noerr) \
  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); \
    if (!ptr->name) { \
      if (noerr == 1) { \
        event_log_error (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \
        return -1; \
      } \
      if (noerr != 1) { \
        event_log_warning (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \
        return 0; \
      } \
    } \
  } while (0)

#endif // _DYNALOADER_H