OLD | NEW |
| (Empty) |
1 //========================================== | |
2 // LIBCTINY - Matt Pietrek 2001 | |
3 // MSDN Magazine, January 2001 | |
4 // FILE: DLLCRT0.CPP | |
5 //========================================== | |
6 #include "libctiny.h" | |
7 #include <windows.h> | |
8 #include "initterm.h" | |
9 | |
10 // Force the linker to include KERNEL32.LIB | |
11 #pragma comment(linker, "/defaultlib:kernel32.lib") | |
12 | |
13 // #pragma comment(linker, "/nodefaultlib:libc.lib") | |
14 // #pragma comment(linker, "/nodefaultlib:libcmt.lib") | |
15 | |
16 // User routine DllMain is called on all notifications | |
17 | |
18 extern BOOL WINAPI DllMain( | |
19 HANDLE hDllHandle, | |
20 DWORD dwReason, | |
21 LPVOID lpreserved | |
22 ) ; | |
23 | |
24 extern "C" void DoInitialization(); | |
25 extern "C" void DoCleanup(); | |
26 | |
27 // | |
28 // Modified version of the Visual C++ startup code. Simplified to | |
29 // make it easier to read. Only supports ANSI programs. | |
30 // | |
31 extern "C" | |
32 BOOL WINAPI _DllMainCRTStartup( | |
33 HANDLE hDllHandle, | |
34 DWORD dwReason, | |
35 LPVOID lpreserved | |
36 ) { | |
37 if (dwReason == DLL_PROCESS_ATTACH) | |
38 { | |
39 // set up our minimal cheezy atexit table | |
40 _atexit_init(); | |
41 | |
42 // Call C++ constructors | |
43 _initterm( __xc_a, __xc_z ); | |
44 | |
45 // DoInitialization(); | |
46 } | |
47 | |
48 BOOL retcode = DllMain(hDllHandle, dwReason, lpreserved); | |
49 | |
50 if (dwReason == DLL_PROCESS_DETACH) | |
51 { | |
52 _DoExit(); | |
53 // DoCleanup(); | |
54 } | |
55 | |
56 return retcode ; | |
57 } | |
OLD | NEW |