| 1 | /* $Id: initterm.cpp,v 1.7 2001-09-05 12:55:49 bird Exp $
 | 
|---|
| 2 |  *
 | 
|---|
| 3 |  * IMAGEHLP DLL entry point
 | 
|---|
| 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*/
 | 
|---|
| 19 | #include <win32type.h>
 | 
|---|
| 20 | #include <winconst.h>
 | 
|---|
| 21 | #include <odinlx.h>
 | 
|---|
| 22 | #include <initdll.h>
 | 
|---|
| 23 | 
 | 
|---|
| 24 | // Win32 resource table (produced by wrc)
 | 
|---|
| 25 | extern DWORD imagehlp_PEResTab;
 | 
|---|
| 26 | 
 | 
|---|
| 27 | static HMODULE dllHandle = 0;
 | 
|---|
| 28 | 
 | 
|---|
| 29 | BOOL WINAPI IMAGEHLP_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
 | 
|---|
| 30 | 
 | 
|---|
| 31 | BOOL WINAPI LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
 | 
|---|
| 32 | {
 | 
|---|
| 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);
 | 
|---|
| 39 | 
 | 
|---|
| 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;
 | 
|---|
| 48 | }
 | 
|---|
| 49 | 
 | 
|---|
| 50 | ULONG SYSTEM DLL_InitImageHlp(ULONG hModule)
 | 
|---|
| 51 | {
 | 
|---|
| 52 |     CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
 | 
|---|
| 53 | 
 | 
|---|
| 54 |     dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&imagehlp_PEResTab);
 | 
|---|
| 55 |     if(dllHandle == 0)
 | 
|---|
| 56 |         return -1;
 | 
|---|
| 57 | 
 | 
|---|
| 58 |     return 0;
 | 
|---|
| 59 | }
 | 
|---|
| 60 | 
 | 
|---|
| 61 | void SYSTEM DLL_TermImageHlp(ULONG hModule)
 | 
|---|
| 62 | {
 | 
|---|
| 63 |     if (dllHandle)
 | 
|---|
| 64 |        UnregisterLxDll(dllHandle);
 | 
|---|
| 65 | }
 | 
|---|
| 66 | 
 | 
|---|
| 67 | ULONG SYSTEM DLL_Init(ULONG hModule)
 | 
|---|
| 68 | {
 | 
|---|
| 69 |     if (DLL_InitDefault(hModule) == -1)
 | 
|---|
| 70 |         return -1;
 | 
|---|
| 71 |     return DLL_InitImageHlp(hModule);
 | 
|---|
| 72 | }
 | 
|---|
| 73 | 
 | 
|---|
| 74 | void SYSTEM DLL_Term(ULONG hModule)
 | 
|---|
| 75 | {
 | 
|---|
| 76 |     DLL_TermImageHlp(hModule);
 | 
|---|
| 77 |     DLL_TermDefault(hModule);
 | 
|---|
| 78 | }
 | 
|---|