| 1 | /* $Id: initterm.cpp,v 1.17 2001/09/05 10:26:30 bird Exp $
 | 
|---|
| 2 |  *
 | 
|---|
| 3 |  * RSAENH 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 <win32api.h>
 | 
|---|
| 19 | #include <winconst.h>
 | 
|---|
| 20 | #include <odinlx.h>
 | 
|---|
| 21 | #include <cpuhlp.h>
 | 
|---|
| 22 | #include <dbglog.h>
 | 
|---|
| 23 | #include <initdll.h>
 | 
|---|
| 24 | 
 | 
|---|
| 25 | //#define DBG_LOCALLOG    DBG_initterm
 | 
|---|
| 26 | //#include "dbglocal.h"
 | 
|---|
| 27 | 
 | 
|---|
| 28 | // Win32 resource table (produced by wrc)
 | 
|---|
| 29 | //extern DWORD rsaenh_PEResTab;
 | 
|---|
| 30 | 
 | 
|---|
| 31 | static HMODULE dllHandle = 0;
 | 
|---|
| 32 | 
 | 
|---|
| 33 | BOOL WINAPI RsaenhDllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved);
 | 
|---|
| 34 | 
 | 
|---|
| 35 | static BOOL WINAPI OdinLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
 | 
|---|
| 36 | {
 | 
|---|
| 37 |     BOOL ret;
 | 
|---|
| 38 | 
 | 
|---|
| 39 |     switch (fdwReason)
 | 
|---|
| 40 |     {
 | 
|---|
| 41 |     case DLL_PROCESS_ATTACH:
 | 
|---|
| 42 |         return RsaenhDllMain(hinstDLL, fdwReason, fImpLoad);
 | 
|---|
| 43 | 
 | 
|---|
| 44 |     case DLL_THREAD_ATTACH:
 | 
|---|
| 45 |     case DLL_THREAD_DETACH:
 | 
|---|
| 46 |         return RsaenhDllMain(hinstDLL, fdwReason, fImpLoad);
 | 
|---|
| 47 | 
 | 
|---|
| 48 |     case DLL_PROCESS_DETACH:
 | 
|---|
| 49 |         ret = RsaenhDllMain(hinstDLL, fdwReason, fImpLoad);
 | 
|---|
| 50 |         return ret;
 | 
|---|
| 51 |     }
 | 
|---|
| 52 |     return FALSE;
 | 
|---|
| 53 | }
 | 
|---|
| 54 | 
 | 
|---|
| 55 | ULONG SYSTEM DLL_InitRsaEnh(ULONG hModule)
 | 
|---|
| 56 | {
 | 
|---|
| 57 |     if (!InitializeKernel32())
 | 
|---|
| 58 |         return -1;
 | 
|---|
| 59 | 
 | 
|---|
| 60 |     //CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
 | 
|---|
| 61 | 
 | 
|---|
| 62 |     dllHandle = RegisterLxDll(hModule, OdinLibMain, NULL);
 | 
|---|
| 63 |     if (dllHandle == 0)
 | 
|---|
| 64 |         return -1;
 | 
|---|
| 65 | 
 | 
|---|
| 66 |     dprintf(("Rsaenh init %s %s (%x)", __DATE__, __TIME__, DLL_InitRsaEnh));
 | 
|---|
| 67 | 
 | 
|---|
| 68 |     return 0;
 | 
|---|
| 69 | }
 | 
|---|
| 70 | 
 | 
|---|
| 71 | void SYSTEM DLL_TermRsaEnh(ULONG hModule)
 | 
|---|
| 72 | {
 | 
|---|
| 73 |     if (dllHandle)
 | 
|---|
| 74 |        UnregisterLxDll(dllHandle);
 | 
|---|
| 75 | }
 | 
|---|
| 76 | 
 | 
|---|
| 77 | ULONG SYSTEM DLL_Init(ULONG hModule)
 | 
|---|
| 78 | {
 | 
|---|
| 79 |     if (DLL_InitDefault(hModule) == -1)
 | 
|---|
| 80 |         return -1;
 | 
|---|
| 81 |     return DLL_InitRsaEnh(hModule);
 | 
|---|
| 82 | }
 | 
|---|
| 83 | 
 | 
|---|
| 84 | void SYSTEM DLL_Term(ULONG hModule)
 | 
|---|
| 85 | {
 | 
|---|
| 86 |     DLL_TermRsaEnh(hModule);
 | 
|---|
| 87 |     DLL_TermDefault(hModule);
 | 
|---|
| 88 | }
 | 
|---|