-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sync.c
executable file
·54 lines (47 loc) · 967 Bytes
/
Sync.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
48
49
50
51
52
53
54
#include "Sync.h"
HANDLE mutex, thread;
BOOL WINAPI
DllMain(
_In_ HINSTANCE hinstDLL,
_In_ DWORD fdwReason,
_In_ LPVOID lpvReserved
) {
switch (fdwReason) {
case DLL_PROCESS_ATTACH: {
wprintf(L"DllMain: attach process\n");
mutex = CreateMutexExW(
NULL, NULL,
1, // CREATE_MUTEX_INITIAL_OWNER, -- not defined?
EVENT_ALL_ACCESS
);
thread = CreateThread(
NULL, 0,
&ThreadMain, NULL,
0, NULL
);
ReleaseMutex(mutex);
break;
}
case DLL_PROCESS_DETACH: {
wprintf(L"DllMain: detach process\n");
break;
}
case DLL_THREAD_ATTACH: {
wprintf(L"DllMain: attach thread\n");
break;
}
case DLL_THREAD_DETACH: {
wprintf(L"DllMain: detach thread\n");
break;
}
}
return TRUE;
}
long unsigned int ThreadMain() {
wprintf(L"ThreadMain: pre-lock\n");
WaitForSingleObject(mutex, INFINITE);
wprintf(L"ThreadMain: post-lock\n");
}
BOOL Test() {
return TRUE;
}