-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCDLL.cpp
56 lines (42 loc) · 966 Bytes
/
CDLL.cpp
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
/*
QMM - Q3 MultiMod
Copyright 2004-2024
https://github.com/thecybermind/qmm/
3-clause BSD license: https://opensource.org/license/bsd-3-clause
Created By:
Kevin Masterson < [email protected] >
*/
#include "CDLL.h"
#include "osdef.h"
#include "util.h"
CDLL::CDLL() {
this->hDLL = NULL;
}
CDLL::~CDLL() {
this->Unload();
}
int CDLL::Load(const char* file) {
if (this->hDLL)
return 0;
this->hDLL = dlopen(file, RTLD_NOW);
if (!this->hDLL)
return 0;
//if this handle is already loaded, report a failed load and reset hDLL
if (this->hDLL == get_modulehandle() || ismoduleloaded(this->hDLL)) {
this->hDLL = NULL;
return -1;
}
setmoduleloaded(this->hDLL);
return 1;
}
void* CDLL::GetProc(const char* func) {
if (this->hDLL)
return dlsym(this->hDLL, func);
return NULL;
}
void CDLL::Unload() {
if (this->hDLL) {
dlclose(this->hDLL);
setmoduleunloaded(this->hDLL);
}
};