source: trunk/src/wnaspi32/initterm.cpp@ 22012

Last change on this file since 22012 was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 2.3 KB
Line 
1/* $Id: initterm.cpp,v 1.8 2001-10-15 17:06:18 sandervl Exp $
2 *
3 * WNASPI322 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 <win32type.h>
19#include <win32api.h>
20#include <winconst.h>
21#include <odinlx.h>
22#include <misc.h> /*PLF Wed 98-03-18 23:18:15*/
23#include <initdll.h>
24#include <custombuild.h>
25#include "cdio.h"
26
27// Win32 resource table (produced by wrc)
28extern DWORD wnaspi32_PEResTab;
29
30static HMODULE dllHandle = 0;
31
32BOOL fASPIAvailable = TRUE;
33
34void WIN32API DisableASPI()
35{
36 dprintf(("DisableASPI"));
37 fASPIAvailable = FALSE;
38}
39
40BOOL WINAPI Wnaspi32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
41{
42 switch (fdwReason)
43 {
44 case DLL_PROCESS_ATTACH:
45 {
46 if(fASPIAvailable == FALSE) return TRUE;
47
48 if(OSLibCdIoInitialize() == FALSE)
49 {
50 dprintf(("WNASPI32: LibMain; can't allocate aspi object! APIs will not work!"));
51 // @@@AH 20011020 we shouldn't prevent DLL loading in this case
52 // just make sure that all API calls fail
53 return TRUE;
54 }
55 fASPIAvailable = TRUE;
56 dprintf(("WNASPI32: LibMain; os2cdrom.dmd ASPI interface available"));
57 return TRUE;
58 }
59
60 case DLL_THREAD_ATTACH:
61 case DLL_THREAD_DETACH:
62 return TRUE;
63
64 case DLL_PROCESS_DETACH:
65 OSLibCdIoTerminate();
66 return TRUE;
67 }
68 return FALSE;
69}
70
71ULONG SYSTEM DLL_InitWinAspi32(ULONG hModule)
72{
73 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
74
75 dllHandle = RegisterLxDll(hModule, Wnaspi32LibMain, (PVOID)&wnaspi32_PEResTab);
76 if (dllHandle == 0)
77 return -1;
78
79 return 0;
80}
81
82void SYSTEM DLL_TermWinAspi32(ULONG hModule)
83{
84 if (dllHandle)
85 UnregisterLxDll(dllHandle);
86}
87
88ULONG SYSTEM DLL_Init(ULONG hModule)
89{
90 if (DLL_InitDefault(hModule) == -1)
91 return -1;
92 return DLL_InitWinAspi32(hModule);
93}
94
95void SYSTEM DLL_Term(ULONG hModule)
96{
97 DLL_TermWinAspi32(hModule);
98 DLL_TermDefault(hModule);
99}
Note: See TracBrowser for help on using the repository browser.