-
Notifications
You must be signed in to change notification settings - Fork 5
/
dllmain.cpp
50 lines (47 loc) · 1.07 KB
/
dllmain.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
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "framework.h"
#include "ConstEncrypt.h"
#include "PELoader.h"
DWORD WINAPI InitPlugin(LPVOID lpThreadParameter);
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
static BOOL IsManualMappingInjection = FALSE;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
wchar_t FilePath[MAX_PATH];
if (!IsManualMappingInjection)
{
if (GetModuleFileNameW(hModule, FilePath, MAX_PATH) != 0)
{
LoadDll(FilePath, -1);
return FALSE;
}
}
wchar_t* FileName;
GetModuleFileNameW(nullptr, FilePath, MAX_PATH);
FileName = wcsrchr(FilePath, '\\');
if (FileName)
{
FileName++;
if (_wcsicmp(FileName, XorString(L"GameApp.exe")) == 0)
{
HANDLE hThread = CreateThread(NULL, 0, InitPlugin, NULL, 0, NULL);
if (hThread)
{
CloseHandle(hThread);
}
break;
}
}
return FALSE;
}
case DLL_PROCESS_DETACH:
break;
case -1:
IsManualMappingInjection = TRUE;
break;
}
return TRUE;
}