-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdllmain.cpp
More file actions
56 lines (50 loc) · 1.41 KB
/
dllmain.cpp
File metadata and controls
56 lines (50 loc) · 1.41 KB
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
// dllmain.cpp : Defines the entry point for the DLL application.
/////////////////////////////////////////////////////////////////////////////
#include <SDKDDKVer.h>
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include "./curl.h"
//@see http://pages.cs.wisc.edu/~tlabonne/memleak.html
#include "CrtDbg.h"
void activateMemoryLeakChecks(void) {
# ifndef NDEBUG
# ifndef _CRTDBG_MAP_ALLOC
# pragma message("Define _CRTDBG_MAP_ALLOC for more detailed CRT memory leak report!")
# endif
int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flags |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag(flags);
# endif
}
void reportMemoryLeaks(void) {
# ifndef NDEBUG
_CrtDumpMemoryLeaks();
# endif
}
/////////////////////////////////////////////////////////////////////////////
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
#if 0 //only required in standalone C programs
khp("", -1); //force initialize kdb+ internal memory system
#endif
setm(1); //allow symbols to be created in threads other than the main thread
activateMemoryLeakChecks();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
m9();
reportMemoryLeaks();
break;
}
return TRUE;
}