-
Notifications
You must be signed in to change notification settings - Fork 0
/
library.c
56 lines (49 loc) · 925 Bytes
/
library.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
55
56
#include <windows.h>
__declspec(dllexport)
VOID RaiseExcept(VOID)
{
__try
{
RaiseException(42, 0, 0, 0);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
}
__declspec(dllexport)
VOID RaiseNoExcept(VOID)
{
RaiseException(42, 0, 0, 0);
}
static DWORD WINAPI ThreadRaiser(PVOID Context)
{
if (Context)
RaiseExcept();
else
RaiseNoExcept();
return 0;
}
static VOID ThreadRaiseXxx(BOOL Except)
{
static int Dummy;
HANDLE Thread = CreateThread(0, 0, ThreadRaiser, Except ? &Dummy : 0, 0, 0);
if (0 != Thread)
{
WaitForSingleObject(Thread, INFINITE);
CloseHandle(Thread);
}
}
__declspec(dllexport)
VOID ThreadRaiseExcept(VOID)
{
ThreadRaiseXxx(TRUE);
}
__declspec(dllexport)
VOID ThreadRaiseNoExcept(VOID)
{
ThreadRaiseXxx(FALSE);
}
BOOL WINAPI DllMain(HINSTANCE Instance, DWORD Reason, PVOID Reserved)
{
return TRUE;
}