-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdllmain.cpp
35 lines (33 loc) · 993 Bytes
/
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
#include <windows.h>
#include <sys/stat.h>
int APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
{
switch (Reason)
{
case DLL_PROCESS_ATTACH:
{
char ini_path[MAX_PATH] = { 0 };
char * temp_path;
struct stat buffer;
/* get our current path so that we can load stuff from our settings */
GetModuleFileNameA(hDLL, ini_path, MAX_PATH);
temp_path = strrchr(ini_path, '\\');
temp_path[1] = '\0';
strcat_s(ini_path, MAX_PATH, "\\bootstrap.ini");
char bootstrap_dll[MAX_PATH] = { 0 };
GetPrivateProfileStringA("bootstrap", "dll", NULL, bootstrap_dll, MAX_PATH, ini_path);
/* at this point we should be in process. we should load our bootstrapped dll here and unload ourselves */
if (bootstrap_dll != NULL && bootstrap_dll[0] != NULL)
if (stat(bootstrap_dll, &buffer) == 0)
LoadLibraryA(bootstrap_dll);
}
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}