source: trunk/src/mscms/initterm.cpp

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

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

File size: 2.0 KB
Line 
1/* $Id: initterm.cpp,v 1.17 2001/09/05 10:26:30 bird Exp $
2 *
3 * MSCMS 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 mscms_PEResTab;
30
31static HMODULE dllHandle = 0;
32
33BOOL WINAPI mscmsDllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved);
34
35static 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 mscmsDllMain(hinstDLL, fdwReason, fImpLoad);
43
44 case DLL_THREAD_ATTACH:
45 case DLL_THREAD_DETACH:
46 return mscmsDllMain(hinstDLL, fdwReason, fImpLoad);
47
48 case DLL_PROCESS_DETACH:
49 ret = mscmsDllMain(hinstDLL, fdwReason, fImpLoad);
50 return ret;
51 }
52 return FALSE;
53}
54
55ULONG SYSTEM DLL_InitMSCms(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(("mscms init %s %s (%x)", __DATE__, __TIME__, DLL_InitMSCms));
67
68 return 0;
69}
70
71void SYSTEM DLL_TermMSCms(ULONG hModule)
72{
73 if (dllHandle)
74 UnregisterLxDll(dllHandle);
75}
76
77ULONG SYSTEM DLL_Init(ULONG hModule)
78{
79 if (DLL_InitDefault(hModule) == -1)
80 return -1;
81 return DLL_InitMSCms(hModule);
82}
83
84void SYSTEM DLL_Term(ULONG hModule)
85{
86 DLL_TermMSCms(hModule);
87 DLL_TermDefault(hModule);
88}
Note: See TracBrowser for help on using the repository browser.