source: trunk/src/rsaenh/initterm.cpp

Last change on this file was 21976, checked in by dmik, 14 years ago

Fix some DLL init code that would return incorrect result on failure.

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