source: trunk/src/wnaspi32/initwnaspi32.cpp@ 8098

Last change on this file since 8098 was 8098, checked in by sandervl, 23 years ago

PF: added function to disable ASPI

File size: 4.6 KB
Line 
1/* $Id: initwnaspi32.cpp,v 1.5 2002-03-18 13:04:32 sandervl Exp $
2 *
3 * DLL entry point
4 *
5 * Copyright 1998 Sander van Leeuwen
6 * Copyright 1998 Peter Fitzsimmons
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12
13/*-------------------------------------------------------------*/
14/* INITERM.C -- Source for a custom dynamic link library */
15/* initialization and termination (_DLL_InitTerm) */
16/* function. */
17/* */
18/* When called to perform initialization, this sample function */
19/* gets storage for an array of integers, and initializes its */
20/* elements with random integers. At termination time, it */
21/* frees the array. Substitute your own special processing. */
22/*-------------------------------------------------------------*/
23
24
25/* Include files */
26#define INCL_DOSMODULEMGR
27#define INCL_DOSPROCESS
28#include <os2wrap.h> //Odin32 OS/2 api wrappers
29#include <stdlib.h>
30#include <stdio.h>
31#include <string.h>
32#include <odin.h>
33#include <win32type.h>
34#include <winconst.h>
35#include <odinlx.h>
36#include <misc.h> /*PLF Wed 98-03-18 23:18:15*/
37#include <initdll.h>
38#include "aspilib.h"
39
40extern "C" {
41 //Win32 resource table (produced by wrc)
42 extern DWORD wnaspi32_PEResTab;
43}
44scsiObj *aspi = NULL;
45static HMODULE dllHandle = 0;
46
47//******************************************************************************
48//******************************************************************************
49void WIN32API DisableASPI()
50{
51 if (aspi) delete aspi;
52 aspi = NULL;
53}
54//******************************************************************************
55//******************************************************************************
56BOOL WINAPI Wnaspi32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
57{
58 switch (fdwReason)
59 {
60 case DLL_PROCESS_ATTACH:
61 aspi = new scsiObj();
62 if(aspi == NULL) {
63 dprintf(("WNASPI32: LibMain; can't allocate aspi object! APIs will not work!"));
64 // @@@AH 20011020 we shouldn't prevent DLL loading in this case
65 // just make sure that all API calls fail
66 return TRUE;
67 }
68 if(aspi->init(65535) == FALSE)
69 {
70 delete aspi;
71 aspi = NULL;
72 dprintf(("WNASPI32: LibMain; can't init aspi object!"));
73 // @@@20011026 and also in this case we shouldn't prevent DLL loading...
74 return TRUE;
75 }
76 dprintf(("WNASPI32: LibMain; aspi object created successfully"));
77 return TRUE;
78
79 case DLL_THREAD_ATTACH:
80 case DLL_THREAD_DETACH:
81 return TRUE;
82
83 case DLL_PROCESS_DETACH:
84 if(aspi) {
85 aspi->close();
86 delete aspi;
87 aspi = NULL;
88 }
89 return TRUE;
90 }
91 return FALSE;
92}
93/****************************************************************************/
94/* _DLL_InitTerm is the function that gets called by the operating system */
95/* loader when it loads and frees this DLL for each process that accesses */
96/* this DLL. However, it only gets called the first time the DLL is loaded */
97/* and the last time it is freed for a particular process. The system */
98/* linkage convention MUST be used because the operating system loader is */
99/* calling this function. */
100/****************************************************************************/
101ULONG APIENTRY inittermWnaspi32(ULONG hModule, ULONG ulFlag)
102{
103 size_t i;
104 APIRET rc;
105
106 /*-------------------------------------------------------------------------*/
107 /* If ulFlag is zero then the DLL is being loaded so initialization should */
108 /* be performed. If ulFlag is 1 then the DLL is being freed so */
109 /* termination should be performed. */
110 /*-------------------------------------------------------------------------*/
111
112 switch (ulFlag) {
113 case 0 :
114 dllHandle = RegisterLxDll(hModule, Wnaspi32LibMain, (PVOID)&wnaspi32_PEResTab);
115 if(dllHandle == 0)
116 return 0UL;
117
118 break;
119 case 1 :
120 if(dllHandle) {
121 UnregisterLxDll(dllHandle);
122 }
123 break;
124 default :
125 return 0UL;
126 }
127
128 /***********************************************************/
129 /* A non-zero value must be returned to indicate success. */
130 /***********************************************************/
131 return 1UL;
132}
133//******************************************************************************
134//******************************************************************************
Note: See TracBrowser for help on using the repository browser.