-
Notifications
You must be signed in to change notification settings - Fork 0
/
whocalls.c
47 lines (34 loc) · 1.22 KB
/
whocalls.c
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
#include <stdio.h>
#include <time.h>
#include <windows.h>
#if defined(__cplusplus)
extern "C" {
#endif
__declspec(dllexport) int DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
if (fdwReason != 1 && fdwReason !=2) { // DLL_PROCESS_ATTACH or DLL_THREAD_ATTACH
return 1;
}
FILE *fp;
fp = fopen ("C:/HONKHONK.TXT", "a"); // You probably want to customise this... ;-)
char hostname[255] = "";
ZeroMemory(hostname, sizeof(hostname) );
DWORD CompBuffer = 255;
GetComputerName(hostname, &CompBuffer);
char username[255] = "";
ZeroMemory(username, sizeof(username) );
DWORD NameBuffer = 255;
GetUserName(username, &NameBuffer);
char dllpath[65535];
GetModuleFileName(hinstDLL, dllpath, sizeof(dllpath));
char exepath[65535];
GetModuleFileName(NULL, exepath, sizeof(exepath));
SYSTEMTIME st;
GetSystemTime(&st); // This is UTC time. GetLocalTime, er, gets the local time
fprintf(fp, "%s|%s|%s|%s|%d|%d/%d/%d %d:%d:%d:%d\n", hostname, username, dllpath, exepath, fdwReason, st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
fclose (fp);
return 1;
}
#if defined(__cplusplus)
}
#endif