-
Notifications
You must be signed in to change notification settings - Fork 0
/
python3xtest.cpp
60 lines (52 loc) · 1.75 KB
/
python3xtest.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
57
58
59
60
// python3xtest.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <windows.h>
#include <string>
#include <algorithm>
#include "CustomLoadLibrary.h"
#include "CustomLoadLibraryS.h"
typedef BOOL(*_repatch_moudle)(const char*, const char*);
typedef const char* (*_Py_GetVersion)(void);
void test1()
{
CustomLoadLibraryBase* t_clb = CustomLoadLibraryS::instance();
t_clb->AppendCustom("python3x.dll");
HMODULE m_hModule = t_clb->LoadLibraryA("python3x.dll");
if (m_hModule == NULL)
return;
_repatch_moudle t_prepatch_moudle = (_repatch_moudle)t_clb->GetProcAddress(m_hModule, "repatch_moudle");
t_prepatch_moudle("python3xx", "python38");
_Py_GetVersion t_Py_GetVersion = (_Py_GetVersion)t_clb->GetProcAddress(m_hModule, "Py_GetVersion");
const char* t_pyVersion = t_Py_GetVersion();
t_clb->FreeLibrary(m_hModule);
}
void test2()
{
CustomLoadLibraryBase* t_clb = CustomLoadLibrary::instance();
t_clb->AppendCustom("python3x.dll");
HMODULE m_hModule = t_clb->LoadLibraryA("python3x.dll");
if (m_hModule == NULL)
return;
t_clb->AppendMoudleRedirect("python3xx", "python38");
_Py_GetVersion t_Py_GetVersion = (_Py_GetVersion)t_clb->GetProcAddress(m_hModule, "Py_GetVersion");
const char* t_pyVersion = t_Py_GetVersion();
t_clb->FreeLibrary(m_hModule);
}
void test3()
{
HMODULE m_hModule = LoadLibraryA("python3x.dll");
if (m_hModule == NULL)
return;
_repatch_moudle t_prepatch_moudle = (_repatch_moudle)GetProcAddress(m_hModule, "repatch_moudle");
t_prepatch_moudle("python3xx", "python38");
_Py_GetVersion t_Py_GetVersion = (_Py_GetVersion)GetProcAddress(m_hModule, "Py_GetVersion");
const char* t_pyVersion = t_Py_GetVersion();
FreeLibrary(m_hModule);
}
int main()
{
test1();
test2();
test3();
return 1;
}