source: trunk/src/wnaspi32/initterm.cpp

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

Merge branch gcc-kmk to trunk.

File size: 2.3 KB
RevLine 
[21900]1/* $Id: initterm.cpp,v 1.8 2001-10-15 17:06:18 sandervl Exp $
[7063]2 *
[21900]3 * WNASPI322 DLL entry point
[7063]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>
[8134]19#include <win32api.h>
[7063]20#include <winconst.h>
21#include <odinlx.h>
22#include <misc.h> /*PLF Wed 98-03-18 23:18:15*/
23#include <initdll.h>
[8134]24#include <custombuild.h>
[8601]25#include "cdio.h"
[7063]26
[21900]27// Win32 resource table (produced by wrc)
28extern DWORD wnaspi32_PEResTab;
29
[7063]30static HMODULE dllHandle = 0;
[21900]31
[8601]32BOOL fASPIAvailable = TRUE;
[8098]33
34void WIN32API DisableASPI()
35{
[21900]36 dprintf(("DisableASPI"));
37 fASPIAvailable = FALSE;
[8098]38}
[21900]39
[7063]40BOOL WINAPI Wnaspi32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
41{
[21900]42 switch (fdwReason)
43 {
44 case DLL_PROCESS_ATTACH:
45 {
46 if(fASPIAvailable == FALSE) return TRUE;
[8134]47
[21900]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 }
[7063]59
[21900]60 case DLL_THREAD_ATTACH:
61 case DLL_THREAD_DETACH:
62 return TRUE;
[7063]63
[21900]64 case DLL_PROCESS_DETACH:
65 OSLibCdIoTerminate();
66 return TRUE;
67 }
68 return FALSE;
[7063]69}
[21900]70
71ULONG SYSTEM DLL_InitWinAspi32(ULONG hModule)
[7063]72{
[21900]73 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
[7063]74
[21900]75 dllHandle = RegisterLxDll(hModule, Wnaspi32LibMain, (PVOID)&wnaspi32_PEResTab);
76 if (dllHandle == 0)
77 return -1;
[7063]78
[21900]79 return 0;
80}
[7063]81
[21900]82void SYSTEM DLL_TermWinAspi32(ULONG hModule)
83{
84 if (dllHandle)
85 UnregisterLxDll(dllHandle);
86}
[7063]87
[21900]88ULONG SYSTEM DLL_Init(ULONG hModule)
89{
90 if (DLL_InitDefault(hModule) == -1)
91 return -1;
92 return DLL_InitWinAspi32(hModule);
[7063]93}
[21900]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.