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