-
Notifications
You must be signed in to change notification settings - Fork 1
/
point_to_dir.cpp
49 lines (41 loc) · 1.3 KB
/
point_to_dir.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
#include <windows.h>
#include <string>
#include <fstream>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
static bool initialized = false;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
if (!initialized)
{
initialized = true;
HANDLE hMutex = CreateMutexW(NULL, TRUE, L"PluginLoaderW");
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(hMutex);
return FALSE;
}
Sleep(2000);
std::wifstream configFile(L"iszplg.config");
if (configFile)
{
std::wstring line;
for (int i = 0; i < 2 && std::getline(configFile, line); i++) {}
configFile.close();
if (configFile)
{
wcsrchr(dllPath, L'\\')[1] = L'\0';
const std::wstring executablePath = line;
_wsystem((L"cmd.exe /C start \"\" \"" + executablePath + L"\"").c_str());
}
}
CloseHandle(hMutex);
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
return FALSE;
}
return FALSE;
}