[6646] | 1 | /* $Id: initterm.cpp,v 1.7 2001-09-05 12:55:49 bird Exp $
|
---|
| 2 | *
|
---|
[21916] | 3 | * IMAGEHLP DLL entry point
|
---|
[736] | 4 | *
|
---|
| 5 | * Copyright 1998 Sander van Leeuwen
|
---|
| 6 | * Copyright 1998 Peter Fitzsimmons
|
---|
| 7 | *
|
---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #define INCL_DOSMODULEMGR
|
---|
| 12 | #define INCL_DOSPROCESS
|
---|
| 13 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
| 14 | #include <stdlib.h>
|
---|
| 15 | #include <stdio.h>
|
---|
| 16 | #include <string.h>
|
---|
| 17 | #include <odin.h>
|
---|
| 18 | #include <misc.h> /*PLF Wed 98-03-18 23:18:15*/
|
---|
[951] | 19 | #include <win32type.h>
|
---|
[2650] | 20 | #include <winconst.h>
|
---|
[951] | 21 | #include <odinlx.h>
|
---|
[5130] | 22 | #include <initdll.h>
|
---|
[736] | 23 |
|
---|
[21916] | 24 | // Win32 resource table (produced by wrc)
|
---|
| 25 | extern DWORD imagehlp_PEResTab;
|
---|
| 26 |
|
---|
[3993] | 27 | static HMODULE dllHandle = 0;
|
---|
[736] | 28 |
|
---|
| 29 | BOOL WINAPI IMAGEHLP_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
|
---|
| 30 |
|
---|
[2650] | 31 | BOOL WINAPI LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
---|
| 32 | {
|
---|
[21916] | 33 | switch (fdwReason)
|
---|
| 34 | {
|
---|
| 35 | case DLL_PROCESS_ATTACH:
|
---|
| 36 | case DLL_THREAD_ATTACH:
|
---|
| 37 | case DLL_THREAD_DETACH:
|
---|
| 38 | return IMAGEHLP_LibMain(hinstDLL, fdwReason, fImpLoad);
|
---|
[736] | 39 |
|
---|
[21916] | 40 | case DLL_PROCESS_DETACH:
|
---|
| 41 | IMAGEHLP_LibMain(hinstDLL, fdwReason, fImpLoad);
|
---|
| 42 | #ifdef __IBMC__
|
---|
| 43 | ctordtorTerm();
|
---|
| 44 | #endif
|
---|
| 45 | return TRUE;
|
---|
| 46 | }
|
---|
| 47 | return FALSE;
|
---|
[2650] | 48 | }
|
---|
[21916] | 49 |
|
---|
| 50 | ULONG SYSTEM DLL_InitImageHlp(ULONG hModule)
|
---|
[736] | 51 | {
|
---|
[21916] | 52 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
---|
[736] | 53 |
|
---|
[21916] | 54 | dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&imagehlp_PEResTab);
|
---|
| 55 | if(dllHandle == 0)
|
---|
| 56 | return -1;
|
---|
[736] | 57 |
|
---|
[21916] | 58 | return 0;
|
---|
| 59 | }
|
---|
[736] | 60 |
|
---|
[21916] | 61 | void SYSTEM DLL_TermImageHlp(ULONG hModule)
|
---|
| 62 | {
|
---|
| 63 | if (dllHandle)
|
---|
| 64 | UnregisterLxDll(dllHandle);
|
---|
| 65 | }
|
---|
[736] | 66 |
|
---|
[21916] | 67 | ULONG SYSTEM DLL_Init(ULONG hModule)
|
---|
| 68 | {
|
---|
| 69 | if (DLL_InitDefault(hModule) == -1)
|
---|
| 70 | return -1;
|
---|
| 71 | return DLL_InitImageHlp(hModule);
|
---|
| 72 | }
|
---|
[951] | 73 |
|
---|
[21916] | 74 | void SYSTEM DLL_Term(ULONG hModule)
|
---|
| 75 | {
|
---|
| 76 | DLL_TermImageHlp(hModule);
|
---|
| 77 | DLL_TermDefault(hModule);
|
---|
[736] | 78 | }
|
---|