1 | //
|
---|
2 | // MINSTALL.DLL (c) Copyright 2002-2005 Martin Kiewitz
|
---|
3 | //
|
---|
4 | // This file is part of MINSTALL.DLL for OS/2 / eComStation
|
---|
5 | //
|
---|
6 | // MINSTALL.DLL is free software: you can redistribute it and/or modify
|
---|
7 | // it under the terms of the GNU General Public License as published by
|
---|
8 | // the Free Software Foundation, either version 3 of the License, or
|
---|
9 | // (at your option) any later version.
|
---|
10 | //
|
---|
11 | // MINSTALL.DLL is distributed in the hope that it will be useful,
|
---|
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | // GNU General Public License for more details.
|
---|
15 | //
|
---|
16 | // You should have received a copy of the GNU General Public License
|
---|
17 | // along with MINSTALL.DLL. If not, see <http://www.gnu.org/licenses/>.
|
---|
18 | //
|
---|
19 |
|
---|
20 | #define INCL_BASE
|
---|
21 | #define INCL_DOSMODULEMGR
|
---|
22 | #define INCL_WINWORKPLACE // for WPS functions
|
---|
23 | #define INCL_WINMESSAGEMGR
|
---|
24 | #define INCL_WINWINDOWMGR
|
---|
25 | #define INCL_OS2MM
|
---|
26 | #include <os2.h>
|
---|
27 | #include <os2me.h>
|
---|
28 | #include <malloc.h>
|
---|
29 |
|
---|
30 | #include <global.h>
|
---|
31 | #include <cfgsys.h>
|
---|
32 | #include <crcs.h>
|
---|
33 | #include <dll.h>
|
---|
34 | #include <file.h>
|
---|
35 | #include <globstr.h>
|
---|
36 | #include <msg.h>
|
---|
37 | #include <mciini.h> // MCI-INI Functions
|
---|
38 | #include <mmi_public.h>
|
---|
39 | #include <mmi_types.h>
|
---|
40 | #include <mmi_main.h>
|
---|
41 | #include <mmi_helper.h>
|
---|
42 | #include <mmi_msg.h>
|
---|
43 | #include <mmi_inistuff.h>
|
---|
44 | #include <mmi_ctrlprc.h>
|
---|
45 |
|
---|
46 | // ****************************************************************************
|
---|
47 |
|
---|
48 | // Reads in CARDINFO.DLL information for all groups on specific file
|
---|
49 | // Will reply DLL-handle or NULLHANDLE, if problem during load (which also an error
|
---|
50 | // got trapped and execution of PackageLoad must abort)
|
---|
51 | //
|
---|
52 | HMODULE MINSTALL_LoadSpecCARDINFODLL (PMINSTFILE CARDINFOFilePtr) {
|
---|
53 | PCHAR ResourcePtr = 0;
|
---|
54 | ULONG ResourceSize = 0;
|
---|
55 | PCHAR ResourceEndPtr = 0;
|
---|
56 | PCHAR ResourceTmpPtr = 0;
|
---|
57 | CHAR CARDINFOFile[MINSTMAX_PATHLENGTH];
|
---|
58 | PMINSTFILE CurFilePtr = 0;
|
---|
59 | PMINSTDIR CurDirPtr = 0;
|
---|
60 | PMINSTGRP CurGroupPtr = 0;
|
---|
61 | PMINSTGENI CurGeninPtr = 0;
|
---|
62 | ULONG DLLGroupNo = 0;
|
---|
63 | ULONG DLLGroupCount = 0;
|
---|
64 | ULONG DLLKnownGroups = 0;
|
---|
65 | ULONG DLLGeninID = 0;
|
---|
66 | ULONG DLLResourceID = 0;
|
---|
67 | ULONG PromptNo = 0;
|
---|
68 | ULONG PromptChoiceNo = 0;
|
---|
69 | ULONG PromptDefault = 0;
|
---|
70 | ULONG DriverNo = 0;
|
---|
71 | ULONG CurNo = 0;
|
---|
72 | ULONG TmpLen = 0;
|
---|
73 | ULONG TempULONG = 0;
|
---|
74 | ULONG TempULONG2 = 0;
|
---|
75 | ULONG CRC32 = 0;
|
---|
76 | HMODULE CARDINFOHandle = NULLHANDLE;
|
---|
77 | PCHAR TruncatePos = NULL;
|
---|
78 |
|
---|
79 | // Remember this action for cleanup...
|
---|
80 | MINSTALL_Done |= MINSTDONE_LOADCARDINFO;
|
---|
81 | FCF_LastCARDINFOHandle = NULLHANDLE;
|
---|
82 |
|
---|
83 | CurDirPtr = MINSTALL_SearchSourceDirID(CARDINFOFilePtr->SourceID);
|
---|
84 | if (!STRING_CombinePSZ ((PCHAR)&CARDINFOFile, MINSTMAX_PATHLENGTH, CurDirPtr->FQName, CARDINFOFilePtr->Name))
|
---|
85 | return NULLHANDLE;
|
---|
86 |
|
---|
87 | // Set Insert 1 to CARDINFO.DLL, because this file is now processed...
|
---|
88 | MSG_SetInsertViaPSZ (1, CARDINFOFile);
|
---|
89 |
|
---|
90 | // Try to load CARDINFO.DLL, if this fails -> fail altogether...
|
---|
91 | if (!(CARDINFOHandle = DLL_Load(CARDINFOFile))) {
|
---|
92 | MINSTALL_TrappedError (MINSTMSG_CouldNotLoad); return NULLHANDLE; }
|
---|
93 |
|
---|
94 | FCF_LastCARDINFOHandle = CARDINFOHandle;
|
---|
95 |
|
---|
96 | // Get ResourceID 1. This contains number of groups in DLL.
|
---|
97 | if (!DLL_GetDataResource(CARDINFOHandle, 1, (PVOID)&ResourcePtr, &ResourceSize))
|
---|
98 | return NULLHANDLE;
|
---|
99 | ResourceEndPtr = (PCHAR)(((ULONG)ResourcePtr)+ResourceSize);
|
---|
100 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue (&DLLGroupCount, ResourcePtr, ResourceEndPtr)))
|
---|
101 | return NULLHANDLE;
|
---|
102 |
|
---|
103 | while (DLLGroupNo<DLLGroupCount) {
|
---|
104 | // Get first resource for that Group... (contains GroupID)
|
---|
105 | DLLResourceID += 10;
|
---|
106 | if (!DLL_GetDataResource(CARDINFOHandle, DLLResourceID, (PVOID)&ResourcePtr, &ResourceSize))
|
---|
107 | return NULLHANDLE;
|
---|
108 | ResourceEndPtr = (PCHAR)(((ULONG)ResourcePtr)+ResourceSize);
|
---|
109 |
|
---|
110 | // Get the Genin-ID for this CARDINFO-entry...
|
---|
111 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue (&DLLGeninID, ResourcePtr, ResourceEndPtr)))
|
---|
112 | return NULLHANDLE;
|
---|
113 | CurGroupPtr = MINSTALL_SearchGroupGeninID(CARDINFOFilePtr, DLLGeninID);
|
---|
114 | // We know this group and it wasnt already processed?
|
---|
115 | if ((CurGroupPtr!=0) && (!CurGroupPtr->GeninPtr)) {
|
---|
116 | MINSTLOG_ToFile (" - Loading data for group %d\n", DLLGeninID);
|
---|
117 | // First allocate Genin-Structure for holding CARDINFO-data...
|
---|
118 | CurGeninPtr = malloc(sizeof(MINSTGENI));
|
---|
119 | if (!CurGeninPtr) {
|
---|
120 | MINSTALL_TrappedError (MINSTMSG_OutOfMemory); return NULLHANDLE; }
|
---|
121 | memset (CurGeninPtr, 0, sizeof(MINSTGENI));
|
---|
122 |
|
---|
123 | CurGroupPtr->GeninPtr = CurGeninPtr;
|
---|
124 | CurGeninPtr->CARDINFOResourceID = DLLResourceID+1;
|
---|
125 |
|
---|
126 | // ============================================ Read basic information
|
---|
127 | // --------------------------------- Element 1 - Maximum Adapter Count
|
---|
128 | if (!DLL_GetDataResource(CARDINFOHandle, DLLResourceID+1, (PVOID)&ResourcePtr, &ResourceSize))
|
---|
129 | return NULLHANDLE;
|
---|
130 | ResourceEndPtr = (PCHAR)(((ULONG)ResourcePtr)+ResourceSize);
|
---|
131 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue (&CurGeninPtr->MaxCardCount, ResourcePtr, ResourceEndPtr)))
|
---|
132 | return NULLHANDLE;
|
---|
133 | CurGeninPtr->SelectedCards = 1; // Defaults to 1 card...
|
---|
134 | if ((CurGeninPtr->MaxCardCount==0) || (CurGeninPtr->MaxCardCount>MINSTMAX_GENINCARDS)) {
|
---|
135 | MINSTALL_TrappedError (MINSTMSG_IllegalAdapterCount); return NULLHANDLE; }
|
---|
136 | // ------------------------------- Element 2 - Skip over Helpfile-Name
|
---|
137 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
138 | return NULLHANDLE;
|
---|
139 | // ----------------------------- Element 3 - Adapter specific DLL Name
|
---|
140 | if (!(ResourcePtr = STRING_GetASCIIZString(CurGeninPtr->CustomDLLFileName, MINSTMAX_PATHLENGTH, ResourcePtr, ResourceEndPtr)))
|
---|
141 | return NULLHANDLE;
|
---|
142 | // ---------------------- Element 4 - Adapter specific DLL Entry Point
|
---|
143 | if (!(ResourcePtr = STRING_GetASCIIZString(CurGeninPtr->CustomDLLEntry, MINSTMAX_STRLENGTH, ResourcePtr, ResourceEndPtr)))
|
---|
144 | return NULLHANDLE;
|
---|
145 | // Check if DLLName&DLLEntry are both set...
|
---|
146 | if ((CurGeninPtr->CustomDLLFileName[0]!=0) && (CurGeninPtr->CustomDLLEntry[0]!=0)) {
|
---|
147 | strlwr(CurGeninPtr->CustomDLLFileName);
|
---|
148 | // If FileName doesn't contain '.dll', add it by ourselves...
|
---|
149 | TmpLen = strlen(CurGeninPtr->CustomDLLFileName);
|
---|
150 | if ((TmpLen<4) || (strcmp(CurGeninPtr->CustomDLLFileName+TmpLen-4,".dll")!=0))
|
---|
151 | if (TmpLen+4<MINSTMAX_PATHLENGTH)
|
---|
152 | strcpy (CurGeninPtr->CustomDLLFileName+TmpLen, ".dll");
|
---|
153 | // We found something, check if the filename got listed...
|
---|
154 | CRC32 = CRC32_GetFromPSZ(CurGeninPtr->CustomDLLFileName);
|
---|
155 | if (!(CurFilePtr = MINSTALL_SearchFileCRC32(CRC32))) {
|
---|
156 | MSG_SetInsertViaPSZ (2, CurGeninPtr->CustomDLLFileName);
|
---|
157 | MINSTALL_TrappedError (MINSTMSG_InstallDLLnotFound);
|
---|
158 | return NULLHANDLE; // if DLL not found in filelisting
|
---|
159 | }
|
---|
160 | // compatibility - there are some DLLs that are also used later
|
---|
161 | // 05.07.2005 so we need to copy those as well
|
---|
162 | switch (CRC32) {
|
---|
163 | case 0xF4621173: // asp4ctrl.dll (Aureal driver, is also support DLL)
|
---|
164 | break;
|
---|
165 | default:
|
---|
166 | // Remove Included-state from file, so it won't get copied...
|
---|
167 | CurFilePtr->Flags &= !MINSTFILE_Flags_Included;
|
---|
168 | }
|
---|
169 | CurGeninPtr->CustomDLLFilePtr = CurFilePtr;
|
---|
170 | } else {
|
---|
171 | CurGeninPtr->CustomDLLFileName[0] = 0; // <-- for safety
|
---|
172 | }
|
---|
173 | // ---------------------------- Element 5 - Number of CONFIG.SYS Lines
|
---|
174 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue (&CurGeninPtr->ConfigSysLinesCount, ResourcePtr, ResourceEndPtr)))
|
---|
175 | return NULLHANDLE;
|
---|
176 | if (CurGeninPtr->ConfigSysLinesCount>MINSTMAX_GENINCONFIGSYSLINES) {
|
---|
177 | MINSTALL_TrappedError (MINSTMSG_IllegalConfigSysLineCount); return NULLHANDLE; }
|
---|
178 |
|
---|
179 | // -------------------------------------- Element 6 - CONFIG.SYS Lines
|
---|
180 | while (CurNo<CurGeninPtr->ConfigSysLinesCount) {
|
---|
181 | if (!(ResourceTmpPtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
182 | return NULLHANDLE;
|
---|
183 | TmpLen = ResourceTmpPtr-ResourcePtr;
|
---|
184 | CurGeninPtr->ConfigSysLinesPtr[CurNo] = ResourcePtr;
|
---|
185 | ResourcePtr = ResourceTmpPtr;
|
---|
186 | CurNo++;
|
---|
187 | }
|
---|
188 |
|
---|
189 | // ------------------------- Element 7 - Number of Drivers per Adapter
|
---|
190 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&CurGeninPtr->DriverCount, ResourcePtr, ResourceEndPtr)))
|
---|
191 | return NULLHANDLE;
|
---|
192 | if ((CurGeninPtr->DriverCount==0) || (CurGeninPtr->DriverCount>MINSTMAX_GENINDRIVERS)) {
|
---|
193 | MINSTALL_TrappedError (MINSTMSG_IllegalDriverCount); return NULLHANDLE; }
|
---|
194 | // ------------------------------------------ Element 8 - Product Name
|
---|
195 | CurGeninPtr->ProductNamePtr = ResourcePtr;
|
---|
196 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
197 | return NULLHANDLE;
|
---|
198 | TmpLen = strlen(CurGeninPtr->ProductNamePtr);
|
---|
199 | if ((TmpLen==0) || (TmpLen>=MCIMAX_PRODLENGTH)) {
|
---|
200 | MSG_SetInsertViaPSZ (2, "ProductName");
|
---|
201 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
202 | // --------------------------------------- Element 9 - Product Version
|
---|
203 | CurGeninPtr->ProductVersionPtr = ResourcePtr;
|
---|
204 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
205 | return NULLHANDLE;
|
---|
206 | TmpLen = strlen(CurGeninPtr->ProductVersionPtr);
|
---|
207 | /* 29.05.2005 - implemented compatibility code */
|
---|
208 | /* warning instead of error if productversion too long */
|
---|
209 | if (TmpLen==0) {
|
---|
210 | MSG_SetInsertViaPSZ (2, "ProductVersion");
|
---|
211 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
212 | if (TmpLen>=MCIMAX_VERSIONLENGTH) {
|
---|
213 | MSG_SetInsertViaPSZ (2, "ProductVersion");
|
---|
214 | MINSTALL_TrappedWarning (MINSTMSG_CIValueTruncatedWarning); }
|
---|
215 | // --------------------------------------------- Element 10 - PDD Name
|
---|
216 | CurGeninPtr->PDDNamePtr = ResourcePtr;
|
---|
217 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
218 | return NULLHANDLE;
|
---|
219 | TmpLen = strlen(CurGeninPtr->PDDNamePtr);
|
---|
220 | /* 29.05.2005 - implemented compatibility code */
|
---|
221 | /* warning instead of error if PDD-Name too long */
|
---|
222 | if (TmpLen>MCIMAX_PDDNAMELENGTH-3) {
|
---|
223 | MSG_SetInsertViaPSZ (2, "PDDName");
|
---|
224 | MINSTALL_TrappedWarning (MINSTMSG_CIValueTruncatedWarning); }
|
---|
225 | // -------------------------------------------- Element 11 - MCD Table
|
---|
226 | CurGeninPtr->MCDTableNamePtr = ResourcePtr;
|
---|
227 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
228 | return NULLHANDLE;
|
---|
229 | TmpLen = strlen(CurGeninPtr->MCDTableNamePtr);
|
---|
230 | if (TmpLen>=MCIMAX_DEVICENAMELENGTH) {
|
---|
231 | MSG_SetInsertViaPSZ (2, "MCDTable");
|
---|
232 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
233 | // -------------------------------------------- Element 12 - VSD Table
|
---|
234 | CurGeninPtr->VSDTableNamePtr = ResourcePtr;
|
---|
235 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
236 | return NULLHANDLE;
|
---|
237 | TmpLen = strlen(CurGeninPtr->VSDTableNamePtr);
|
---|
238 | if (TmpLen>=MCIMAX_DEVICENAMELENGTH) {
|
---|
239 | MSG_SetInsertViaPSZ (2, "VSDTable");
|
---|
240 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
241 |
|
---|
242 | // =================================== Readin driver install resources
|
---|
243 | for (DriverNo=0; DriverNo<CurGeninPtr->DriverCount; DriverNo++) {
|
---|
244 | if (!DLL_GetDataResource(CARDINFOHandle, DLLResourceID+2+DriverNo, (PVOID)&ResourcePtr, &ResourceSize))
|
---|
245 | return NULLHANDLE;
|
---|
246 | ResourceEndPtr = (PCHAR)(((ULONG)ResourcePtr)+ResourceSize);
|
---|
247 |
|
---|
248 | // ---------------------------------------- Element 1 - InstallName
|
---|
249 | CurGeninPtr->Drivers[DriverNo].InstallNamePtr = ResourcePtr;
|
---|
250 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
251 | return NULLHANDLE;
|
---|
252 | TmpLen = strlen(CurGeninPtr->Drivers[DriverNo].InstallNamePtr);
|
---|
253 | if ((TmpLen==0) || (TmpLen>=MCIMAX_DEVICENAMELENGTH-2)) {
|
---|
254 | MSG_SetInsertViaPSZ (2, "InstallName");
|
---|
255 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
256 | // ----------------------------------------- Element 2 - DeviceType
|
---|
257 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
258 | return NULLHANDLE;
|
---|
259 | CurGeninPtr->Drivers[DriverNo].DeviceType = TempULONG;
|
---|
260 | // ----------------------------------------- Element 3 - DeviceFlag
|
---|
261 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&CurGeninPtr->Drivers[DriverNo].DeviceFlag, ResourcePtr, ResourceEndPtr)))
|
---|
262 | return NULLHANDLE;
|
---|
263 | // -------------------------------------- Element 4 - MCDDriverName
|
---|
264 | CurGeninPtr->Drivers[DriverNo].MCDDriverNamePtr = ResourcePtr;
|
---|
265 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
266 | return NULLHANDLE;
|
---|
267 | TmpLen = strlen(CurGeninPtr->Drivers[DriverNo].MCDDriverNamePtr);
|
---|
268 | if ((TmpLen==0) || (TmpLen>=MCIMAX_DEVICENAMELENGTH)) {
|
---|
269 | MSG_SetInsertViaPSZ (2, "MCDDriverName");
|
---|
270 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
271 | // -------------------------------------- Element 5 - VSDDriverName
|
---|
272 | CurGeninPtr->Drivers[DriverNo].VSDDriverNamePtr = ResourcePtr;
|
---|
273 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
274 | return NULLHANDLE;
|
---|
275 | TmpLen = strlen(CurGeninPtr->Drivers[DriverNo].VSDDriverNamePtr);
|
---|
276 | if (TmpLen>=MCIMAX_DEVICENAMELENGTH) {
|
---|
277 | MSG_SetInsertViaPSZ (2, "VSDDriverName");
|
---|
278 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
279 | // ------------------------------------------ Element 6 - ShareType
|
---|
280 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
281 | return NULLHANDLE;
|
---|
282 | CurGeninPtr->Drivers[DriverNo].ShareType = (USHORT)TempULONG;
|
---|
283 | // --------------------------------------- Element 7 - ResourceName
|
---|
284 | CurGeninPtr->Drivers[DriverNo].ResourceNamePtr = ResourcePtr;
|
---|
285 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
286 | return NULLHANDLE;
|
---|
287 | TmpLen = strlen(CurGeninPtr->Drivers[DriverNo].ResourceNamePtr);
|
---|
288 | if ((TmpLen==0) || (TmpLen>=MCIMAX_DEVICENAMELENGTH)) {
|
---|
289 | MSG_SetInsertViaPSZ (2, "ResourceName");
|
---|
290 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
291 | // -------------------------------------- Element 8 - ResourceUnits
|
---|
292 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
293 | return NULLHANDLE;
|
---|
294 | CurGeninPtr->Drivers[DriverNo].ResourceUnits = (USHORT)TempULONG;
|
---|
295 | // --------------------------------- Element 9 - ResourceClassCount
|
---|
296 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
297 | return NULLHANDLE;
|
---|
298 | // No more than 9 classes...
|
---|
299 | if ((TempULONG==0) || (TempULONG>=MCIMAX_CLASSES)) {
|
---|
300 | MSG_SetInsertViaPSZ (2, "ResourceClassCount");
|
---|
301 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
302 | CurGeninPtr->Drivers[DriverNo].ResourceClassCount = (USHORT)TempULONG;
|
---|
303 | // ----------------------------------- Element 10 - ResourceClasses
|
---|
304 | for (CurNo=0; CurNo<CurGeninPtr->Drivers[DriverNo].ResourceClassCount; CurNo++) {
|
---|
305 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
306 | return NULLHANDLE;
|
---|
307 | CurGeninPtr->Drivers[DriverNo].ResourceClassArray[CurNo] = (USHORT)TempULONG;
|
---|
308 | }
|
---|
309 | // --------------------------- Element 11 - ResourceClassComboCount
|
---|
310 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
311 | return NULLHANDLE;
|
---|
312 | if (TempULONG>MCIMAX_CLASSES*MCIMAX_CLASSES) {
|
---|
313 | MSG_SetInsertViaPSZ (2, "ResourceClassComboCount");
|
---|
314 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
315 | CurGeninPtr->Drivers[DriverNo].ResourceClassComboCount = (USHORT)TempULONG;
|
---|
316 | // --------------------------- Element 12 - ResourceClassComboArray
|
---|
317 | for (CurNo=0; CurNo<CurGeninPtr->Drivers[DriverNo].ResourceClassComboCount; CurNo++) {
|
---|
318 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
319 | return NULLHANDLE;
|
---|
320 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG2, ResourcePtr, ResourceEndPtr)))
|
---|
321 | return NULLHANDLE;
|
---|
322 | if ((TempULONG==0) || (TempULONG>=MCIMAX_CLASSES) || (TempULONG2==0) || (TempULONG2>=MCIMAX_CLASSES)) {
|
---|
323 | MSG_SetInsertViaPSZ (2, "ClassComboArray");
|
---|
324 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
325 | CurGeninPtr->Drivers[DriverNo].ResourceClassComboArray[TempULONG][TempULONG2] = 1;
|
---|
326 | CurGeninPtr->Drivers[DriverNo].ResourceClassComboArray[TempULONG2][TempULONG] = 1;
|
---|
327 | }
|
---|
328 | // ------------------------------------ Element 13 - ConnectorCount
|
---|
329 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
330 | return NULLHANDLE;
|
---|
331 | if (TempULONG>MCIMAX_CONNECTORS) {
|
---|
332 | MSG_SetInsertViaPSZ (2, "ConnectorCount");
|
---|
333 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
334 | CurGeninPtr->Drivers[DriverNo].ConnectorCount = (USHORT)TempULONG;
|
---|
335 | // ------------------------------------ Element 14 - ConnectorArray
|
---|
336 | CurGeninPtr->Drivers[DriverNo].ConnectorArrayPtr = ResourcePtr;
|
---|
337 | for (CurNo=0; CurNo<CurGeninPtr->Drivers[DriverNo].ConnectorCount; CurNo++) {
|
---|
338 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
339 | return NULLHANDLE;
|
---|
340 | CurGeninPtr->Drivers[DriverNo].ConnectorType[CurNo] = (USHORT)TempULONG;
|
---|
341 | CurGeninPtr->Drivers[DriverNo].ConnectorToInstallNamePtr[CurNo] = ResourcePtr;
|
---|
342 | if (!(ResourceTmpPtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
343 | return NULLHANDLE;
|
---|
344 | TmpLen = (ULONG)ResourceTmpPtr-(ULONG)ResourcePtr-1;
|
---|
345 | if (TmpLen>=MCIMAX_DEVICENAMELENGTH-2) {
|
---|
346 | MSG_SetInsertViaPSZ (2, "ConnectorName");
|
---|
347 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
348 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourceTmpPtr, ResourceEndPtr)))
|
---|
349 | return NULLHANDLE;
|
---|
350 | CurGeninPtr->Drivers[DriverNo].ConnectorToConnectIndex[CurNo] = (USHORT)TempULONG;
|
---|
351 | }
|
---|
352 | // ------------------------------------ Element 15 - ExtensionCount
|
---|
353 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&TempULONG, ResourcePtr, ResourceEndPtr)))
|
---|
354 | return NULLHANDLE;
|
---|
355 | if (TempULONG>MCIMAX_EXTENSIONS) {
|
---|
356 | MSG_SetInsertViaPSZ (2, "ExtensionCount");
|
---|
357 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
358 | CurGeninPtr->Drivers[DriverNo].ExtensionCount = (USHORT)TempULONG;
|
---|
359 | // ------------------------------------ Element 16 - ExtensionArray
|
---|
360 | for (CurNo=0; CurNo<CurGeninPtr->Drivers[DriverNo].ExtensionCount; CurNo++) {
|
---|
361 | if (!(ResourcePtr = STRING_GetASCIIZString(CurGeninPtr->Drivers[DriverNo].ExtensionArray[CurNo], MCIMAX_EXTENSIONNAMELENGTH, ResourcePtr, ResourceEndPtr))) {
|
---|
362 | MSG_SetInsertViaPSZ (2, "Extensions");
|
---|
363 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
364 | }
|
---|
365 | // ------------------------------------------- Element 17 - EATypes
|
---|
366 | CurGeninPtr->Drivers[DriverNo].EATypesPtr = ResourcePtr;
|
---|
367 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
368 | return NULLHANDLE;
|
---|
369 | TmpLen = strlen(CurGeninPtr->Drivers[DriverNo].EATypesPtr);
|
---|
370 | if (TmpLen>=MCIMAX_TYPELISTLENGTH) {
|
---|
371 | MSG_SetInsertViaPSZ (2, "EATypes");
|
---|
372 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
373 | // ----------------------------------------- Element 18 - AliasName
|
---|
374 | CurGeninPtr->Drivers[DriverNo].AliasNamePtr = ResourcePtr;
|
---|
375 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
376 | return NULLHANDLE;
|
---|
377 | TmpLen = strlen(CurGeninPtr->Drivers[DriverNo].AliasNamePtr);
|
---|
378 | if (TmpLen>=MCIMAX_ALIASNAMELENGTH) {
|
---|
379 | MSG_SetInsertViaPSZ (2, "AliasName");
|
---|
380 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
381 | // ----------------------------------------- Element 19 - DevParams
|
---|
382 | CurGeninPtr->Drivers[DriverNo].DeviceParmsPtr = ResourcePtr;
|
---|
383 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
384 | return NULLHANDLE;
|
---|
385 | TmpLen = strlen(CurGeninPtr->Drivers[DriverNo].DeviceParmsPtr);
|
---|
386 | if (TmpLen>=MCIMAX_DEVPARAMSLENGTH) {
|
---|
387 | MSG_SetInsertViaPSZ (2, "DeviceParams");
|
---|
388 | MINSTALL_TrappedError (MINSTMSG_CIBadValueFor); return NULLHANDLE; }
|
---|
389 | }
|
---|
390 |
|
---|
391 | // ============================= Now we get the User-Prompt data (xx9)
|
---|
392 | if (!DLL_GetDataResource(CARDINFOHandle, DLLResourceID+9, (PVOID)&ResourcePtr, &ResourceSize))
|
---|
393 | return NULLHANDLE;
|
---|
394 | ResourceEndPtr = (PCHAR)(((ULONG)ResourcePtr)+ResourceSize);
|
---|
395 |
|
---|
396 | // ------------------------------------------ Element 1 - Prompt Count
|
---|
397 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&CurGeninPtr->PromptsCount, ResourcePtr, ResourceEndPtr)))
|
---|
398 | return NULLHANDLE;
|
---|
399 | if (CurGeninPtr->PromptsCount>MINSTMAX_GENINPROMPTS) {
|
---|
400 | MINSTALL_TrappedError (MINSTMSG_IllegalPromptCount); return NULLHANDLE; }
|
---|
401 |
|
---|
402 | // And get all the pointers...
|
---|
403 | for (PromptNo=0; PromptNo<CurGeninPtr->PromptsCount; PromptNo++) {
|
---|
404 | // --------------------------------------- Element 2 - Prompt Title
|
---|
405 | CurGeninPtr->PromptTitlePtr[PromptNo] = ResourcePtr;
|
---|
406 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
407 | return NULLHANDLE;
|
---|
408 | // -------------------------------- Element 3 - Prompt Choice Count
|
---|
409 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&PromptChoiceNo, ResourcePtr, ResourceEndPtr)))
|
---|
410 | return NULLHANDLE;
|
---|
411 | CurGeninPtr->PromptChoiceCount[PromptNo] = PromptChoiceNo;
|
---|
412 | if ((PromptChoiceNo==0) || (PromptChoiceNo>MINSTMAX_GENINPROMPTCHOICES)) {
|
---|
413 | MINSTALL_TrappedError (MINSTMSG_IllegalPromptChoicesCount); return NULLHANDLE; }
|
---|
414 | // Get the pointers to the prompts...
|
---|
415 | // ------------------------------------- Element 4 - Prompt Choices
|
---|
416 | CurGeninPtr->PromptChoiceStrings[PromptNo] = ResourcePtr;
|
---|
417 | for (PromptChoiceNo=0; PromptChoiceNo<CurGeninPtr->PromptChoiceCount[PromptNo]; PromptChoiceNo++) {
|
---|
418 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
419 | return NULLHANDLE;
|
---|
420 | }
|
---|
421 |
|
---|
422 | // -------------------------------------- Element 5 - Prompt Values
|
---|
423 | CurGeninPtr->PromptChoiceValues[PromptNo] = ResourcePtr;
|
---|
424 | for (PromptChoiceNo=0; PromptChoiceNo<CurGeninPtr->PromptChoiceCount[PromptNo]; PromptChoiceNo++) {
|
---|
425 | if (!(ResourcePtr = STRING_SkipASCIIZ(ResourcePtr, ResourceEndPtr)))
|
---|
426 | return NULLHANDLE;
|
---|
427 | }
|
---|
428 |
|
---|
429 | // ------------------------------------- Element 6 - Default Prompt
|
---|
430 | if (!(ResourcePtr = STRING_GetASCIIZNumericValue(&PromptDefault, ResourcePtr, ResourceEndPtr)))
|
---|
431 | return NULLHANDLE;
|
---|
432 | if ((PromptDefault==0) || (PromptDefault>MINSTMAX_GENINPROMPTCHOICES)) {
|
---|
433 | MINSTALL_TrappedError (MINSTMSG_IllegalPromptChoicesCount); return NULLHANDLE; }
|
---|
434 | PromptDefault--;
|
---|
435 | CurGeninPtr->PromptChoiceDefault[PromptNo] = PromptDefault;
|
---|
436 | ResourceTmpPtr = CurGeninPtr->PromptChoiceValues[PromptNo];
|
---|
437 |
|
---|
438 | // Get the default selected value
|
---|
439 | for (PromptChoiceNo=0; PromptChoiceNo<PromptDefault; PromptChoiceNo++) {
|
---|
440 | ResourceTmpPtr = STRING_SkipASCIIZ(ResourceTmpPtr, ResourceEndPtr);
|
---|
441 | }
|
---|
442 | for (PromptChoiceNo=0; PromptChoiceNo<MINSTMAX_GENINCARDS; PromptChoiceNo++) {
|
---|
443 | CurGeninPtr->PromptSelectedValue[PromptChoiceNo][PromptNo] = ResourceTmpPtr;
|
---|
444 | CurGeninPtr->PromptSelectedValueNo[PromptChoiceNo][PromptNo] = PromptDefault;
|
---|
445 | }
|
---|
446 | }
|
---|
447 | DLLKnownGroups++; // Remember that we got one...
|
---|
448 | }
|
---|
449 |
|
---|
450 | DLLGroupNo++;
|
---|
451 | }
|
---|
452 |
|
---|
453 | if (DLLKnownGroups==0) { // Error, if no known group
|
---|
454 | MINSTALL_TrappedError (MINSTMSG_NoKnownGroups);
|
---|
455 | return NULLHANDLE;
|
---|
456 | }
|
---|
457 | FCF_LastCARDINFOHandle = NULLHANDLE;
|
---|
458 | return CARDINFOHandle;
|
---|
459 | }
|
---|
460 |
|
---|
461 | // This routine generates CONFIG.SYS change information and also does the MCI
|
---|
462 | // modifications required via GENIN/CARDINFO.
|
---|
463 | // NOTE: CONFIG.SYS gets changed at the end in one pass via cross-call to
|
---|
464 | // MINSTALL_ProcessConfigControl().
|
---|
465 | BOOL MINSTALL_ProcessCARDINFOGroup (PMINSTGRP CurGroupPtr) {
|
---|
466 | PMINSTGENI GeninPtr = CurGroupPtr->GeninPtr;
|
---|
467 | PMINSTFILE CustomDLLFilePtr = 0;
|
---|
468 | HMODULE CustomDLLHandle = 0;
|
---|
469 | PFN CustomDLLFunc = 0;
|
---|
470 | ULONG CardNo = 0;
|
---|
471 | ULONG CardSeqNo = 0;
|
---|
472 | ULONG DriverNo = 0;
|
---|
473 | ULONG CurNo = 0;
|
---|
474 | PMINSTGENIDRV CurDriverPtr = 0;
|
---|
475 | APIRET rc = 0;
|
---|
476 | CHAR MacroPATH[MINSTMAX_PATHLENGTH];
|
---|
477 | CHAR MacroORD[6]; // Maximum is USHORT (5 chars)
|
---|
478 | ULONG CurORDNo;
|
---|
479 | CHAR MacroSPEC[5][259];
|
---|
480 | ULONG CurSPECNo, CurVALNo;
|
---|
481 | PSZ CurValuePtr;
|
---|
482 | CHAR MacroPDD[MCIMAX_PDDNAMELENGTH];
|
---|
483 | CHAR MacroProductVersion[MCIMAX_VERSIONLENGTH];
|
---|
484 | CHAR DriverName[MCIMAX_DEVICENAMELENGTH];
|
---|
485 | CHAR ResourceName[MCIMAX_DEVICENAMELENGTH];
|
---|
486 | CHAR ConnectorToInstallNameArray[MCIMAX_CONNECTORS][MCIMAX_DEVICENAMELENGTH];
|
---|
487 | CHAR TempBuffer[MINSTMAX_PATHLENGTH];
|
---|
488 | CHAR IntelliAliasName[MCIMAX_DEVICENAMELENGTH];
|
---|
489 | CHAR CurAliasName[MCIMAX_DEVICENAMELENGTH];
|
---|
490 | ULONG CurAliasNameLength;
|
---|
491 | PCHAR CurPos, StartPos, EndPos, WritePos, WordPos;
|
---|
492 | ULONG WriteLeft, TmpLength, CRC32;
|
---|
493 | PCONFIGSYSACTION ConfigSysActionArrayPtr;
|
---|
494 | PCONFIGSYSACTION ConfigSysActionCurPtr;
|
---|
495 | PCONFIGSYSACTSTR ConfigSysStringArrayPtr;
|
---|
496 | PCONFIGSYSACTSTR ConfigSysStringCurPtr;
|
---|
497 | ULONG ConfigSysActionCount;
|
---|
498 | BOOL ChangedToMatchInLine;
|
---|
499 | CHAR CurDefaultDeviceName[MCIMAX_DEVICENAMELENGTH];
|
---|
500 | // New variables for compatibility code (undocumented IBM API) 03.07.2005
|
---|
501 | MCIINI_NETCONNECTION NetworkPlayConnections[2];
|
---|
502 | MCIINI_NETCONNECTION NetworkRecordConnections[1];
|
---|
503 | ULONG NetworkDeviceCount;
|
---|
504 | ULONG NetworkPlayCount;
|
---|
505 | ULONG NetworkRecordCount;
|
---|
506 |
|
---|
507 | // Macros for CONFIG.SYS entries:
|
---|
508 | //================================
|
---|
509 | // *PATH* - following filename will get looked up. If it's found, that path
|
---|
510 | // will get inserted. Otherwise MINSTALL_MMBase (fixed)
|
---|
511 | // *ORD* - MCI Ordinal for the 1st driver (multiple)
|
---|
512 | // *SEQ* - Sequential number of card, base is 1 (multiple)
|
---|
513 | // *PDD* - PDD-Name of the card, actually PDD-Name & Seq-No & '$' (single)
|
---|
514 | // *VAL* - User defined value from user prompts (multiple)
|
---|
515 | // *SPEC* - From Custom-DLL (multiple)
|
---|
516 |
|
---|
517 | // Set strings to NUL...
|
---|
518 | MacroPDD[0] = 0;
|
---|
519 |
|
---|
520 | if (GeninPtr->CustomDLLFilePtr) {
|
---|
521 | CustomDLLFilePtr = (PMINSTFILE)GeninPtr->CustomDLLFilePtr;
|
---|
522 | if (!STRING_CombinePSZ(TempBuffer, MINSTMAX_PATHLENGTH, CustomDLLFilePtr->SourcePtr->FQName, GeninPtr->CustomDLLFileName))
|
---|
523 | return FALSE;
|
---|
524 | MINSTLOG_ToFile ("Custom DLL is %s\n", TempBuffer);
|
---|
525 | if ((CustomDLLHandle = DLL_Load(TempBuffer))!=0)
|
---|
526 | CustomDLLFunc = DLL_GetEntryPoint (CustomDLLHandle, GeninPtr->CustomDLLEntry);
|
---|
527 | if (!CustomDLLFunc) {
|
---|
528 | DLL_UnLoad (CustomDLLHandle);
|
---|
529 | MINSTALL_TrappedError (MINSTMSG_CICouldNotLoadCustomDLL); return FALSE; }
|
---|
530 | }
|
---|
531 |
|
---|
532 | memset (&ConnectorToInstallNameArray, 0, sizeof(ConnectorToInstallNameArray));
|
---|
533 |
|
---|
534 | // Allocate space for CONFIG.SYS-Action
|
---|
535 | ConfigSysActionCount = GeninPtr->ConfigSysLinesCount*(GeninPtr->SelectedCards+1);
|
---|
536 | if (ConfigSysActionCount) {
|
---|
537 | ConfigSysActionArrayPtr = malloc(ConfigSysActionCount*sizeof(CONFIGSYSACTION));
|
---|
538 | if (!ConfigSysActionArrayPtr) {
|
---|
539 | MINSTALL_TrappedError (MINSTMSG_OutOfMemory); return FALSE; }
|
---|
540 | ConfigSysStringArrayPtr = malloc(ConfigSysActionCount*sizeof(CONFIGSYSACTSTR));
|
---|
541 | if (!ConfigSysStringArrayPtr) {
|
---|
542 | free (ConfigSysActionArrayPtr);
|
---|
543 | MINSTALL_TrappedError (MINSTMSG_OutOfMemory); return FALSE; }
|
---|
544 |
|
---|
545 | memset (ConfigSysActionArrayPtr, 0, ConfigSysActionCount*sizeof(CONFIGSYSACTION));
|
---|
546 | memset (ConfigSysStringArrayPtr, 0, ConfigSysActionCount*sizeof(CONFIGSYSACTSTR));
|
---|
547 | ConfigSysActionCurPtr = ConfigSysActionArrayPtr;
|
---|
548 | ConfigSysStringCurPtr = ConfigSysStringArrayPtr;
|
---|
549 | }
|
---|
550 |
|
---|
551 | // First remove all existing drivers with the same name and generate removal
|
---|
552 | // instructions for the CONFIG.SYS lines...
|
---|
553 | MINSTLOG_ToAll ("Removing existing MCI-drivers...\n");
|
---|
554 |
|
---|
555 | for (CardNo=0; CardNo<MINSTMAX_GENINCARDS; CardNo++) {
|
---|
556 | CardSeqNo = CardNo+1;
|
---|
557 | for (DriverNo=0; DriverNo<GeninPtr->DriverCount; DriverNo++) {
|
---|
558 | CurDriverPtr = &GeninPtr->Drivers[DriverNo];
|
---|
559 | sprintf (DriverName, "%s0%X", CurDriverPtr->InstallNamePtr, CardSeqNo);
|
---|
560 |
|
---|
561 | // Create MCI-Driver...
|
---|
562 | MCIINI_DeleteDriver (DriverName);
|
---|
563 | }
|
---|
564 | }
|
---|
565 |
|
---|
566 | if (ConfigSysActionCount) {
|
---|
567 | // Generate CONFIG.SYS-removal Actions...
|
---|
568 | // Fill out *PATH*, *PDD*. Leave out *ORD*, *SEQ*, *VAL*, *SPEC*
|
---|
569 | // *PDD* is filled out with just the PDD-Base-Name (w/o SeqNo nor '$')
|
---|
570 | for (CurNo=0; CurNo<GeninPtr->ConfigSysLinesCount; CurNo++) {
|
---|
571 | CurPos = GeninPtr->ConfigSysLinesPtr[CurNo];
|
---|
572 | EndPos = (PCHAR)(((ULONG)CurPos)+strlen(CurPos));
|
---|
573 |
|
---|
574 | WritePos = ConfigSysStringCurPtr->CommandStr;
|
---|
575 | WriteLeft = CONFIGSYSACTSTR_MAXLENGTH-1;
|
---|
576 | while (CurPos<EndPos) {
|
---|
577 | if (*CurPos=='=') {
|
---|
578 | CurPos++; break;
|
---|
579 | }
|
---|
580 | if (WriteLeft>0) {
|
---|
581 | *WritePos = *CurPos; WritePos++; WriteLeft--; }
|
---|
582 | CurPos++;
|
---|
583 | }
|
---|
584 |
|
---|
585 | WritePos = ConfigSysStringCurPtr->MatchStr;
|
---|
586 | WriteLeft = CONFIGSYSACTSTR_MAXLENGTH-1;
|
---|
587 | ChangedToMatchInLine = FALSE;
|
---|
588 | while (CurPos<EndPos) {
|
---|
589 | if (*CurPos=='*') {
|
---|
590 | CurPos++;
|
---|
591 | StartPos = CurPos;
|
---|
592 | while ((CurPos<EndPos) && (*CurPos!='*'))
|
---|
593 | CurPos++;
|
---|
594 | if (CurPos<EndPos) {
|
---|
595 | // We got a macro
|
---|
596 | CRC32 = CRC32_GetFromString(StartPos, CurPos-StartPos);
|
---|
597 | switch (CRC32) {
|
---|
598 | case 0x3DC166BB: // *PATH*
|
---|
599 | TmpLength = strlen(MINSTALL_MMBase);
|
---|
600 | if (TmpLength<WriteLeft) {
|
---|
601 | memcpy (WritePos, &MINSTALL_MMBase, TmpLength);
|
---|
602 | WritePos += TmpLength; WriteLeft -= TmpLength; }
|
---|
603 | break;
|
---|
604 | case 0x7659F82A: // *PDD*
|
---|
605 | TmpLength = strlen(GeninPtr->PDDNamePtr);
|
---|
606 | /* 29.05.2005 - compatibility code */
|
---|
607 | /* truncates PDD name, if too long */
|
---|
608 | if (TmpLength>MCIMAX_PDDNAMELENGTH-3)
|
---|
609 | TmpLength = MCIMAX_PDDNAMELENGTH-3;
|
---|
610 | if (TmpLength<WriteLeft) {
|
---|
611 | memcpy (WritePos, GeninPtr->PDDNamePtr, TmpLength);
|
---|
612 | WritePos += TmpLength; WriteLeft -= TmpLength; }
|
---|
613 | }
|
---|
614 | }
|
---|
615 | } else if ((*CurPos==' ') && (!ChangedToMatchInLine)) {
|
---|
616 | WritePos = ConfigSysStringCurPtr->MatchInLineStr;
|
---|
617 | WriteLeft = CONFIGSYSACTSTR_MAXLENGTH-1;
|
---|
618 | ChangedToMatchInLine = TRUE;
|
---|
619 | } else {
|
---|
620 | if (WriteLeft>0) {
|
---|
621 | *WritePos = *CurPos; WritePos++; WriteLeft--; }
|
---|
622 | }
|
---|
623 | CurPos++;
|
---|
624 | }
|
---|
625 |
|
---|
626 | ConfigSysActionCurPtr->Flags = CONFIGSYSACTION_Flags_RemoveAll;
|
---|
627 | ConfigSysActionCurPtr->CommandStrPtr = ConfigSysStringCurPtr->CommandStr;
|
---|
628 | ConfigSysActionCurPtr->MatchStrPtr = ConfigSysStringCurPtr->MatchStr;
|
---|
629 | ConfigSysActionCurPtr->MatchInLineStrPtr = ConfigSysStringCurPtr->MatchInLineStr;
|
---|
630 | ConfigSysActionCurPtr->ValueStrPtr = ConfigSysStringCurPtr->ValueStr;
|
---|
631 |
|
---|
632 | MINSTLOG_ToFile ("CONFIG/Remove - '%s' - '%s'\n", ConfigSysStringCurPtr->MatchStr, ConfigSysStringCurPtr->MatchInLineStr);
|
---|
633 | ConfigSysActionCurPtr++; ConfigSysStringCurPtr++;
|
---|
634 | }
|
---|
635 | }
|
---|
636 |
|
---|
637 | // Now generate a base alias-name for this device by analyzing the Product-
|
---|
638 | // Information string word by word. Maximum Card-Information: 13 chars
|
---|
639 | // ' xxxxy' is added to string to form the whole alias name
|
---|
640 | // where 'xxxx' is a 4-char name (Wave/Midi) and 'y' is a number
|
---|
641 | // This new alias-name will only get used on WAVE or MIDI devices...
|
---|
642 | MINSTLOG_ToFile ("Getting IntelliAliasname...\n");
|
---|
643 | memset (IntelliAliasName, 0, sizeof(IntelliAliasName));
|
---|
644 | CurPos = GeninPtr->ProductNamePtr;
|
---|
645 | EndPos = (PCHAR)(((ULONG)CurPos)+strlen(CurPos));
|
---|
646 | WritePos = IntelliAliasName; WriteLeft = 13;
|
---|
647 | while ((CurPos = STRING_IsolateWord (&WordPos, &TmpLength, CurPos, EndPos))!=0) {
|
---|
648 | // Got an isolated word
|
---|
649 | if (TmpLength<WriteLeft) { // We got enough bytes left
|
---|
650 | memcpy (&TempBuffer, WordPos, TmpLength);
|
---|
651 | TempBuffer[TmpLength] = 0;
|
---|
652 | strupr (TempBuffer); // we got upcased word here
|
---|
653 | CRC32 = CRC32_GetFromPSZ(TempBuffer);
|
---|
654 | switch (CRC32) {
|
---|
655 | case 0xEF29F425: // 'AUDIO'
|
---|
656 | case 0x7ABDF43D: // 'ADVANCED'
|
---|
657 | case 0xEC91403D: // 'WAVE'
|
---|
658 | case 0xAC649A86: // 'MIDI'
|
---|
659 | break;
|
---|
660 | default:
|
---|
661 | memcpy (WritePos, WordPos, TmpLength); WritePos += TmpLength;
|
---|
662 | *WritePos = 0x20; WritePos++; // Add a space...
|
---|
663 | WriteLeft -= TmpLength+1;
|
---|
664 | }
|
---|
665 | }
|
---|
666 | }
|
---|
667 |
|
---|
668 | // Now generate entries per card, also call custom-DLL, if specified...
|
---|
669 | if (!MINSTALL_ErrorMsgID) {
|
---|
670 | for (CardNo=0; CardNo<GeninPtr->SelectedCards; CardNo++) {
|
---|
671 | CardSeqNo = CardNo+1;
|
---|
672 |
|
---|
673 | MINSTLOG_ToAll ("Generating card...\n");
|
---|
674 | MacroPDD[0] = 0;
|
---|
675 | if (ConfigSysActionCount) {
|
---|
676 | /* 29.05.2005 - compatibility code */
|
---|
677 | /* truncates PDD name, if too long */
|
---|
678 | TmpLength = strlen(GeninPtr->PDDNamePtr);
|
---|
679 | if (TmpLength>MCIMAX_PDDNAMELENGTH-3)
|
---|
680 | TmpLength = MCIMAX_PDDNAMELENGTH-3;
|
---|
681 | memcpy(MacroPDD, GeninPtr->PDDNamePtr, TmpLength);
|
---|
682 | MacroPDD[TmpLength] = 0;
|
---|
683 | sprintf ((PCHAR)((ULONG)MacroPDD)+TmpLength, "%d$", CardSeqNo);
|
---|
684 | }
|
---|
685 | /* 29.05.2005 - compatibility code */
|
---|
686 | /* truncates ProductVersion, if too long */
|
---|
687 | TmpLength = strlen(GeninPtr->ProductVersionPtr);
|
---|
688 | if (TmpLength>MCIMAX_VERSIONLENGTH-1)
|
---|
689 | TmpLength = MCIMAX_VERSIONLENGTH-1;
|
---|
690 | memcpy(MacroProductVersion, GeninPtr->ProductVersionPtr, TmpLength);
|
---|
691 | MacroProductVersion[TmpLength] = 0;
|
---|
692 |
|
---|
693 | // Call Custom-DLL, if specified to get *SPEC* macro...
|
---|
694 | if (CustomDLLFunc) {
|
---|
695 | MINSTLOG_ToAll ("Calling custom DLL-entry...\n");
|
---|
696 | memset (&MacroSPEC, 0, sizeof(MacroSPEC));
|
---|
697 | (CustomDLLFunc) ((USHORT)CardNo+1, &MacroSPEC);
|
---|
698 | }
|
---|
699 | // Now create all drivers for this card...
|
---|
700 | for (DriverNo=0; DriverNo<GeninPtr->DriverCount; DriverNo++) {
|
---|
701 | CurDriverPtr = &GeninPtr->Drivers[DriverNo];
|
---|
702 |
|
---|
703 | sprintf (DriverName, "%s0%X", CurDriverPtr->InstallNamePtr, CardSeqNo);
|
---|
704 | sprintf (ResourceName, "%s0%X", CurDriverPtr->ResourceNamePtr, CardSeqNo);
|
---|
705 | MINSTLOG_ToAll ("Creating MCI-Driver '%s'\n", DriverName);
|
---|
706 |
|
---|
707 | // Create MCI-Driver...
|
---|
708 | if (MCIINI_CreateDriver (DriverName,
|
---|
709 | CurDriverPtr->DeviceType, CurDriverPtr->DeviceFlag,
|
---|
710 | MacroProductVersion, // <-- Product Version (may be truncated)
|
---|
711 | GeninPtr->ProductNamePtr,
|
---|
712 | CurDriverPtr->MCDDriverNamePtr, CurDriverPtr->VSDDriverNamePtr,
|
---|
713 | MacroPDD, // <-- is the PDD-Name with 'x$' extension (may also be truncated)
|
---|
714 | GeninPtr->MCDTableNamePtr, GeninPtr->VSDTableNamePtr,
|
---|
715 | CurDriverPtr->ShareType,
|
---|
716 | ResourceName,
|
---|
717 | CurDriverPtr->ResourceUnits, CurDriverPtr->ResourceClassCount,
|
---|
718 | (PUSHORT)CurDriverPtr->ResourceClassArray,
|
---|
719 | (PUSHORT)CurDriverPtr->ResourceClassComboArray)) {
|
---|
720 | MINSTLOG_ToFile ("Error during MCI Create\n"); break; }
|
---|
721 |
|
---|
722 | if (DriverNo==0) {
|
---|
723 | // Gets total devices of first driver type, which is
|
---|
724 | // automatically the ordinal of the driver. Don't ask me, this
|
---|
725 | // gets messed up in config.sys pretty easy, but this is how
|
---|
726 | // IBM designed it.
|
---|
727 | CurORDNo = MCIINI_GetTotalDevices (CurDriverPtr->DeviceType);
|
---|
728 | itoa (CurORDNo, MacroORD, 10);
|
---|
729 | }
|
---|
730 |
|
---|
731 | // Now create MCI-Driver Connectors...
|
---|
732 | for (CurNo=0; CurNo<CurDriverPtr->ConnectorCount; CurNo++) {
|
---|
733 | if (*CurDriverPtr->ConnectorToInstallNamePtr[CurNo]!=0)
|
---|
734 | sprintf (ConnectorToInstallNameArray[CurNo], "%s0%X", CurDriverPtr->ConnectorToInstallNamePtr[CurNo], CardSeqNo);
|
---|
735 | else
|
---|
736 | ConnectorToInstallNameArray[CurNo][0] = 0;
|
---|
737 | }
|
---|
738 |
|
---|
739 | if (MCIINI_SetConnectors (DriverName,
|
---|
740 | CurDriverPtr->ConnectorCount,
|
---|
741 | CurDriverPtr->ConnectorType, (PCHAR)&ConnectorToInstallNameArray,
|
---|
742 | CurDriverPtr->ConnectorToConnectIndex)) {
|
---|
743 | MINSTLOG_ToFile ("Error during MCI Set Connectors\n"); break; }
|
---|
744 |
|
---|
745 | // 03.07.2005 - implemented undocumented MCI API that sets
|
---|
746 | // additional connections on WAVE and SEQUENCER
|
---|
747 | // devices. This should eliminate later crashes in
|
---|
748 | // MMPM.DLL.
|
---|
749 |
|
---|
750 | memset (&NetworkPlayConnections, 0, sizeof(NetworkPlayConnections));
|
---|
751 | memset (&NetworkRecordConnections, 0, sizeof(NetworkRecordConnections));
|
---|
752 | NetworkDeviceCount = 0;
|
---|
753 | NetworkPlayCount = 0;
|
---|
754 | NetworkRecordCount = 0;
|
---|
755 |
|
---|
756 | // These values were also hardcoded in GENIN.DLL
|
---|
757 | switch (CurDriverPtr->DeviceType) {
|
---|
758 | case MCI_DEVTYPE_WAVEFORM_AUDIO:
|
---|
759 | NetworkDeviceCount = 1;
|
---|
760 | NetworkPlayCount = 1;
|
---|
761 | NetworkRecordCount = 1;
|
---|
762 | NetworkPlayConnections[0].ulFromDevice = 0;
|
---|
763 | NetworkPlayConnections[0].ulSrcConnType = 3;
|
---|
764 | NetworkPlayConnections[0].ulSrcConnNum = 1;
|
---|
765 | NetworkPlayConnections[0].ulToDevice = 1;
|
---|
766 | NetworkPlayConnections[0].ulTgtConnType = 3;
|
---|
767 | NetworkPlayConnections[0].ulTgtConnNum = 1;
|
---|
768 | NetworkRecordConnections[0].ulFromDevice = 1;
|
---|
769 | NetworkRecordConnections[0].ulSrcConnType = 3;
|
---|
770 | NetworkRecordConnections[0].ulSrcConnNum = 1;
|
---|
771 | NetworkRecordConnections[0].ulToDevice = 0;
|
---|
772 | NetworkRecordConnections[0].ulTgtConnType = 3;
|
---|
773 | NetworkRecordConnections[0].ulTgtConnNum = 1;
|
---|
774 | break;
|
---|
775 | case MCI_DEVTYPE_SEQUENCER:
|
---|
776 | // on sequencers, we compare EA types with "Software Synth"
|
---|
777 | // on match, we need to set 2 playback connections otherwise just
|
---|
778 | // one. (taken from GENIN disassembly)
|
---|
779 | if (strcmp(CurDriverPtr->EATypesPtr, "Software Synth")==0) {
|
---|
780 | NetworkDeviceCount = 1;
|
---|
781 | NetworkPlayCount = 2;
|
---|
782 | NetworkPlayConnections[0].ulFromDevice = 0;
|
---|
783 | NetworkPlayConnections[0].ulSrcConnType = 1;
|
---|
784 | NetworkPlayConnections[0].ulSrcConnNum = 1;
|
---|
785 | NetworkPlayConnections[0].ulToDevice = 2;
|
---|
786 | NetworkPlayConnections[0].ulTgtConnType = 22;
|
---|
787 | NetworkPlayConnections[0].ulTgtConnNum = 1;
|
---|
788 | NetworkPlayConnections[1].ulFromDevice = 2;
|
---|
789 | NetworkPlayConnections[1].ulSrcConnType = 3;
|
---|
790 | NetworkPlayConnections[1].ulSrcConnNum = 1;
|
---|
791 | NetworkPlayConnections[1].ulToDevice = 2;
|
---|
792 | NetworkPlayConnections[1].ulTgtConnType = 3;
|
---|
793 | NetworkPlayConnections[1].ulTgtConnNum = 1;
|
---|
794 | } else {
|
---|
795 | NetworkDeviceCount = 1;
|
---|
796 | NetworkPlayCount = 1;
|
---|
797 | NetworkPlayConnections[0].ulFromDevice = 0;
|
---|
798 | NetworkPlayConnections[0].ulSrcConnType = 1;
|
---|
799 | NetworkPlayConnections[0].ulSrcConnNum = 1;
|
---|
800 | NetworkPlayConnections[0].ulToDevice = 1;
|
---|
801 | NetworkPlayConnections[0].ulTgtConnType = 4;
|
---|
802 | NetworkPlayConnections[0].ulTgtConnNum = 1;
|
---|
803 | }
|
---|
804 | }
|
---|
805 |
|
---|
806 | if ((NetworkPlayCount>0) || (NetworkRecordCount>0)) {
|
---|
807 | if (rc = MCIINI_SetNetworkDefaultConnections (DriverName,
|
---|
808 | NetworkDeviceCount, NetworkPlayCount, NetworkRecordCount,
|
---|
809 | "AMPMIX", (PVOID)&NetworkPlayConnections, (PVOID)&NetworkRecordConnections)) {
|
---|
810 | MINSTLOG_ToFile ("Error during MCI Set Network Default Connections (%d)\n", rc); break; }
|
---|
811 | }
|
---|
812 |
|
---|
813 | if (*CurDriverPtr->DeviceParmsPtr!=0) {
|
---|
814 | // Device-parameters defined, so set them...
|
---|
815 | MINSTLOG_ToFile (" - Device-Parameters %s\n", CurDriverPtr->DeviceParmsPtr);
|
---|
816 | if (MCIINI_SetDeviceParameters (DriverName, CurDriverPtr->DeviceParmsPtr)) {
|
---|
817 | MINSTLOG_ToFile ("Error during MCI Set DevParms\n"); break; }
|
---|
818 | }
|
---|
819 |
|
---|
820 | // Create MCI-Driver Extension Association...
|
---|
821 | if (CurDriverPtr->ExtensionCount>0) {
|
---|
822 | rc = MCIINI_SetFileExtensions (DriverName,
|
---|
823 | CurDriverPtr->ExtensionCount,
|
---|
824 | (PCHAR)CurDriverPtr->ExtensionArray);
|
---|
825 | if (rc==MCIERR_DUPLICATE_EXTENSION) {
|
---|
826 | MINSTLOG_ToFile ("Duplicate File-Extension (not critical)\n");
|
---|
827 | } else if (rc!=MCIERR_SUCCESS) {
|
---|
828 | MINSTLOG_ToFile ("Error during MCI Set File-Extensions (not critical) - %d\n", rc);
|
---|
829 | }
|
---|
830 | }
|
---|
831 |
|
---|
832 | if (*CurDriverPtr->EATypesPtr!=0) {
|
---|
833 | // Extended Attributes were defined, so set them...
|
---|
834 | rc = MCIINI_SetEATypes (DriverName, CurDriverPtr->EATypesPtr);
|
---|
835 | if (rc==MCIERR_DUPLICATE_EA) {
|
---|
836 | MINSTLOG_ToFile ("Duplicate EA-Types (not critical)\n");
|
---|
837 | } else if (rc!=MCIERR_SUCCESS) {
|
---|
838 | MINSTLOG_ToFile ("Error during MCI Set EA-Types (not critical) - %d\n", rc);
|
---|
839 | }
|
---|
840 | }
|
---|
841 |
|
---|
842 | // Finally set alias-name...
|
---|
843 | memset (CurAliasName, 0, sizeof(CurAliasName));
|
---|
844 | switch (CurDriverPtr->DeviceType) {
|
---|
845 | case MCI_DEVTYPE_WAVEFORM_AUDIO:
|
---|
846 | STRING_CombinePSZ (CurAliasName, MCIMAX_DEVICENAMELENGTH, IntelliAliasName, "Wave");
|
---|
847 | break;
|
---|
848 | case MCI_DEVTYPE_SEQUENCER:
|
---|
849 | STRING_CombinePSZ (CurAliasName, MCIMAX_DEVICENAMELENGTH, IntelliAliasName, "Midi");
|
---|
850 | break;
|
---|
851 | case MCI_DEVTYPE_CD_AUDIO:
|
---|
852 | strcpy (CurAliasName, "CD-Audio");
|
---|
853 | break;
|
---|
854 | default:
|
---|
855 | strcpy (CurAliasName, CurDriverPtr->AliasNamePtr);
|
---|
856 | }
|
---|
857 | CurAliasNameLength = strlen(CurAliasName);
|
---|
858 | if (CurAliasNameLength) {
|
---|
859 | CurNo = 1;
|
---|
860 | while (CurNo<36) {
|
---|
861 | rc = MCIINI_SetAliasName (DriverName, CurAliasName);
|
---|
862 | if (rc==MCIERR_SUCCESS) break; // <-- success? -> exit
|
---|
863 | if (rc!=MCIERR_DUPLICATE_ALIAS) {
|
---|
864 | MINSTLOG_ToFile ("Error during MCI Set Aliasname (not critical) - %d\n", rc);
|
---|
865 | break;
|
---|
866 | }
|
---|
867 | // We got duplicate Alias, so try again...
|
---|
868 | CurNo++;
|
---|
869 | if (CurNo<10)
|
---|
870 | CurAliasName[CurAliasNameLength] = CurNo+0x30;
|
---|
871 | else
|
---|
872 | CurAliasName[CurAliasNameLength] = CurNo+55;
|
---|
873 | }
|
---|
874 | MINSTLOG_ToFile ("Alias-Name that got set was '%s'\n", CurAliasName);
|
---|
875 | }
|
---|
876 | }
|
---|
877 |
|
---|
878 | if (ConfigSysActionCount) {
|
---|
879 | // Generate CONFIG.SYS modifications...
|
---|
880 | CurSPECNo = CurVALNo = 0;
|
---|
881 | for (CurNo=0; CurNo<GeninPtr->ConfigSysLinesCount; CurNo++) {
|
---|
882 | CurPos = GeninPtr->ConfigSysLinesPtr[CurNo];
|
---|
883 | EndPos = (PCHAR)(((ULONG)CurPos)+strlen(CurPos));
|
---|
884 |
|
---|
885 | WritePos = ConfigSysStringCurPtr->CommandStr;
|
---|
886 | WriteLeft = CONFIGSYSACTSTR_MAXLENGTH-1;
|
---|
887 | while (CurPos<EndPos) {
|
---|
888 | if (*CurPos=='=') {
|
---|
889 | CurPos++; break;
|
---|
890 | }
|
---|
891 | if (WriteLeft>0) {
|
---|
892 | *WritePos = *CurPos; WritePos++; WriteLeft--; }
|
---|
893 | CurPos++;
|
---|
894 | }
|
---|
895 |
|
---|
896 | WritePos = ConfigSysStringCurPtr->ValueStr;
|
---|
897 | WriteLeft = CONFIGSYSACTSTR_MAXLENGTH-1;
|
---|
898 | while (CurPos<EndPos) {
|
---|
899 | if (*CurPos=='*') {
|
---|
900 | CurPos++;
|
---|
901 | StartPos = CurPos;
|
---|
902 | while ((CurPos<EndPos) && (*CurPos!='*'))
|
---|
903 | CurPos++;
|
---|
904 | if (CurPos<EndPos) {
|
---|
905 | // We got a macro
|
---|
906 | CRC32 = CRC32_GetFromString(StartPos, CurPos-StartPos);
|
---|
907 | switch (CRC32) {
|
---|
908 | case 0x3DC166BB: // *PATH*
|
---|
909 | TmpLength = strlen(MINSTALL_MMBase);
|
---|
910 | if (TmpLength<WriteLeft) {
|
---|
911 | memcpy (WritePos, &MINSTALL_MMBase, TmpLength);
|
---|
912 | WritePos += TmpLength; WriteLeft -= TmpLength; }
|
---|
913 | break;
|
---|
914 | case 0x7659F82A: // *PDD*
|
---|
915 | TmpLength = strlen(GeninPtr->PDDNamePtr);
|
---|
916 | /* 29.05.2005 - compatibility code */
|
---|
917 | /* truncates PDD name, if too long */
|
---|
918 | if (TmpLength>MCIMAX_PDDNAMELENGTH-3)
|
---|
919 | TmpLength = MCIMAX_PDDNAMELENGTH-3;
|
---|
920 | if (TmpLength+2<WriteLeft) {
|
---|
921 | memcpy (WritePos, GeninPtr->PDDNamePtr, TmpLength);
|
---|
922 | WritePos += TmpLength; WriteLeft -= TmpLength;
|
---|
923 | *WritePos = CardSeqNo+0x30; WritePos++;
|
---|
924 | *WritePos = '$'; WritePos++; }
|
---|
925 | break;
|
---|
926 | case 0x00D993D9: // *SEQ*
|
---|
927 | if (WriteLeft>0) {
|
---|
928 | *WritePos = CardSeqNo+0x30; WritePos++; }
|
---|
929 | break;
|
---|
930 | case 0x7DBBA9B0: // *ORD*
|
---|
931 | TmpLength = strlen(MacroORD);
|
---|
932 | if (TmpLength<WriteLeft) {
|
---|
933 | memcpy (WritePos, &MacroORD, TmpLength);
|
---|
934 | WritePos += TmpLength; WriteLeft -= TmpLength; }
|
---|
935 | break;
|
---|
936 | case 0xF69BFA8A: // *SPEC*
|
---|
937 | TmpLength = strlen(MacroSPEC[CurSPECNo]);
|
---|
938 | if (TmpLength<WriteLeft) {
|
---|
939 | memcpy (WritePos, &MacroSPEC[CurSPECNo], TmpLength);
|
---|
940 | WritePos += TmpLength; WriteLeft -= TmpLength; }
|
---|
941 | CurSPECNo++; // Go to next SPEC-Macro...
|
---|
942 | if (CurSPECNo==5) CurSPECNo=0; // Handle overflow
|
---|
943 | break;
|
---|
944 | case 0x0178F8EF: // *VAL*
|
---|
945 | CurValuePtr = GeninPtr->PromptSelectedValue[CardNo][CurVALNo];
|
---|
946 | TmpLength = strlen(CurValuePtr);
|
---|
947 | if (TmpLength<WriteLeft) {
|
---|
948 | memcpy (WritePos, CurValuePtr, TmpLength);
|
---|
949 | WritePos += TmpLength; WriteLeft -= TmpLength; }
|
---|
950 | CurVALNo++; // Go to next VAL-Macro...
|
---|
951 | if (CurVALNo==GeninPtr->PromptsCount) CurVALNo=0;
|
---|
952 | break;
|
---|
953 | }
|
---|
954 | }
|
---|
955 | } else {
|
---|
956 | if (WriteLeft>0) {
|
---|
957 | *WritePos = *CurPos; WritePos++; WriteLeft--; }
|
---|
958 | }
|
---|
959 | CurPos++;
|
---|
960 | }
|
---|
961 |
|
---|
962 | ConfigSysActionCurPtr->Flags = 0;
|
---|
963 | ConfigSysActionCurPtr->CommandStrPtr = ConfigSysStringCurPtr->CommandStr;
|
---|
964 | ConfigSysActionCurPtr->MatchStrPtr = ConfigSysStringCurPtr->MatchStr;
|
---|
965 | ConfigSysActionCurPtr->MatchInLineStrPtr = ConfigSysStringCurPtr->MatchInLineStr;
|
---|
966 | ConfigSysActionCurPtr->ValueStrPtr = ConfigSysStringCurPtr->ValueStr;
|
---|
967 |
|
---|
968 | // Copy ValueStr to MatchStr, so there will be no match...
|
---|
969 | strcpy (ConfigSysStringCurPtr->MatchStr, ConfigSysStringCurPtr->ValueStr);
|
---|
970 |
|
---|
971 | MINSTLOG_ToFile ("CONFIG/Add - '%s'\n", ConfigSysStringCurPtr->ValueStr);
|
---|
972 | ConfigSysActionCurPtr++; ConfigSysStringCurPtr++;
|
---|
973 | }
|
---|
974 | }
|
---|
975 | }
|
---|
976 | }
|
---|
977 | if (CustomDLLHandle) DLL_UnLoad (CustomDLLHandle);
|
---|
978 |
|
---|
979 | MINSTLOG_ToFile ("Total CONFIG.SYS Actions: %d\n", ConfigSysActionCount);
|
---|
980 | if (ConfigSysActionCount) {
|
---|
981 | MINSTALL_ProcessConfigControl (ConfigSysActionCount, ConfigSysActionArrayPtr);
|
---|
982 | free (ConfigSysStringArrayPtr);
|
---|
983 | free (ConfigSysActionArrayPtr);
|
---|
984 | }
|
---|
985 | if (MINSTALL_ErrorMsgID) return FALSE;
|
---|
986 | return TRUE;
|
---|
987 | }
|
---|
988 |
|
---|
989 | // Parses CustomData-block and fills out GENIN Selections
|
---|
990 | // Supports both the old and new format
|
---|
991 | // Old: "Yamaha OPL3-SA Series Audio.=NUM=1,V1=7,V1=01,V1=530,V1=388,V1=0,V1=0,V1=390,V1=220,V1=1,201,V1=1,201,"
|
---|
992 | // New: "CARDCOUNT=1;VALUES[1]=9,1,3"
|
---|
993 | BOOL MINSTALL_UseCARDINFOCustomData (PMINSTGRP GroupPtr) {
|
---|
994 | ULONG CardNo = 0;
|
---|
995 | ULONG CardCount = 0;
|
---|
996 | ULONG CardProcessed = 0;
|
---|
997 | ULONG PromptNo = 0;
|
---|
998 | ULONG ValueNo = 0;
|
---|
999 | ULONG ValueCount = 0;
|
---|
1000 | PSZ ValuePtr = 0;
|
---|
1001 | PCHAR StartPos = GroupPtr->CustomData;
|
---|
1002 | PCHAR CurPos = StartPos;
|
---|
1003 | PCHAR EndPos = STRING_SkipASCIIZ (StartPos, NULL)-1;
|
---|
1004 | ULONG CRC32;
|
---|
1005 | ULONG BitCurCard = 0;
|
---|
1006 | ULONG BitAllCards = 0;
|
---|
1007 | ULONG BitGotCards = 0;
|
---|
1008 | PMINSTGENI GeninPtr = GroupPtr->GeninPtr;
|
---|
1009 | ULONG BytesLeft = 0;
|
---|
1010 |
|
---|
1011 | while (*CurPos!='=') {
|
---|
1012 | if (CurPos>=EndPos) { // Unexpected end-of-data
|
---|
1013 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1014 | *CurPos = toupper(*CurPos);
|
---|
1015 | CurPos++;
|
---|
1016 | }
|
---|
1017 | CRC32 = CRC32_GetFromString (StartPos, CurPos-StartPos);
|
---|
1018 | CurPos++;
|
---|
1019 | if (CurPos>=EndPos) { // Unexpected end-of-data
|
---|
1020 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1021 |
|
---|
1022 | if (CRC32==0x700D2834) { // First entry == 'CARDCOUNT'
|
---|
1023 | // =========================================================== New Format
|
---|
1024 | CurPos = STRING_GetNumericValue(&CardCount, CurPos, EndPos);
|
---|
1025 | if (CurPos==NULL) {
|
---|
1026 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1027 | if (CardCount>GeninPtr->MaxCardCount) {
|
---|
1028 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadCardNo); return FALSE; }
|
---|
1029 | GeninPtr->SelectedCards = CardCount;
|
---|
1030 |
|
---|
1031 | // If CardCount is 1 or bigger get values for selections
|
---|
1032 | BitAllCards = (1<<CardCount)-1; BitGotCards = 0;
|
---|
1033 | for (CardProcessed=1; CardProcessed<=CardCount; CardProcessed++) {
|
---|
1034 | if (*CurPos!=';') {
|
---|
1035 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1036 | CurPos++;
|
---|
1037 |
|
---|
1038 | StartPos = CurPos;
|
---|
1039 | while (*CurPos!='[') {
|
---|
1040 | if (CurPos>=EndPos) { // Unexpected end-of-data
|
---|
1041 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1042 | *CurPos = toupper(*CurPos);
|
---|
1043 | CurPos++;
|
---|
1044 | }
|
---|
1045 | CRC32 = CRC32_GetFromString (StartPos, CurPos-StartPos);
|
---|
1046 | CurPos++;
|
---|
1047 | if (CRC32!=0xCA5F8B60) { // It's 'VALUES'?
|
---|
1048 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1049 |
|
---|
1050 | // Extract Array-Number
|
---|
1051 | CurPos = STRING_GetNumericValue(&CardNo, CurPos, EndPos);
|
---|
1052 | if ((CurPos==NULL) || (*CurPos!=']')) {
|
---|
1053 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1054 | CurPos++;
|
---|
1055 | if (*CurPos!='=') {
|
---|
1056 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1057 | CurPos++;
|
---|
1058 | if ((CardNo==0) || (CardNo>CardCount)) { // In Range?
|
---|
1059 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgMismatch); return FALSE; }
|
---|
1060 | CardNo--;
|
---|
1061 | BitCurCard = (1<<CardNo);
|
---|
1062 | if (BitGotCards & BitCurCard) {
|
---|
1063 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgMismatch); return FALSE; }
|
---|
1064 | BitGotCards |= BitCurCard;
|
---|
1065 |
|
---|
1066 | // Now extract all values and set them for the specified card...
|
---|
1067 | for (PromptNo=0; PromptNo<GeninPtr->PromptsCount; PromptNo++) {
|
---|
1068 | if (PromptNo>0) {
|
---|
1069 | if (*CurPos!=',') {
|
---|
1070 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgMismatch); return FALSE; }
|
---|
1071 | CurPos++;
|
---|
1072 | }
|
---|
1073 | if (CurPos>=EndPos) { // Unexpected end-of-data
|
---|
1074 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1075 | CurPos = STRING_GetNumericValue(&ValueNo, CurPos, EndPos);
|
---|
1076 | if (CurPos==NULL) {
|
---|
1077 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1078 | // Check, if given PromptNo seems to be correct
|
---|
1079 | if ((ValueNo==0) || (ValueNo>GeninPtr->PromptChoiceCount[PromptNo])) {
|
---|
1080 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgMismatch); return FALSE; }
|
---|
1081 | ValueNo--;
|
---|
1082 | GeninPtr->PromptSelectedValueNo[CardNo][PromptNo] = ValueNo;
|
---|
1083 | ValuePtr = GeninPtr->PromptChoiceValues[PromptNo];
|
---|
1084 | while (ValueNo) {
|
---|
1085 | ValuePtr = STRING_SkipASCIIZ(ValuePtr, NULL);
|
---|
1086 | ValueNo--;
|
---|
1087 | }
|
---|
1088 | GeninPtr->PromptSelectedValue[CardNo][PromptNo] = ValuePtr;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | if ((*CurPos!=0) && (*CurPos!=';')) {
|
---|
1092 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgMismatch); return FALSE; }
|
---|
1093 | }
|
---|
1094 | } else {
|
---|
1095 | // =========================================================== Old Format
|
---|
1096 | // We assume that it starts with NUM=x and is then followed by values
|
---|
1097 | // using ',Vx=', where x is the card number. All values have to be in
|
---|
1098 | // order (card 1 -> card 2 -> card 3 etc.)
|
---|
1099 | // Also ',' is not enough to detect the end of a string, but ',V' (and
|
---|
1100 | // even that isn't good, but that's bad design by IBM :(
|
---|
1101 | // We also check, if there is a such-called value, find out ValueNo and
|
---|
1102 | // set everything correctly (not directly using the specified value)
|
---|
1103 |
|
---|
1104 | // First search for "NUM=" string (case-sensitive)...
|
---|
1105 | while (1) {
|
---|
1106 | if (CurPos>=EndPos) { // Unexpected end-of-data
|
---|
1107 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1108 | BytesLeft = EndPos-CurPos;
|
---|
1109 | if (BytesLeft<4) {
|
---|
1110 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1111 | if (strncmp(CurPos, "NUM=", 4)==0)
|
---|
1112 | break; // If found -> go out of loop
|
---|
1113 | CurPos++;
|
---|
1114 | }
|
---|
1115 | CurPos += 4;
|
---|
1116 |
|
---|
1117 | CurPos = STRING_GetNumericValue(&CardCount, CurPos, EndPos);
|
---|
1118 | if (CurPos==NULL) {
|
---|
1119 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1120 | if (CardCount>GeninPtr->MaxCardCount) {
|
---|
1121 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadCardNo); return FALSE; }
|
---|
1122 | GeninPtr->SelectedCards = CardCount;
|
---|
1123 |
|
---|
1124 | if ((GeninPtr->PromptsCount) && (CardCount)) {
|
---|
1125 | // If any prompts required & CardCount not 0, assume ',V' next
|
---|
1126 | if (*CurPos!=',') {
|
---|
1127 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1128 | CurPos++;
|
---|
1129 | if (*CurPos!='V') {
|
---|
1130 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1131 | CurPos++;
|
---|
1132 |
|
---|
1133 | for (CardNo=0; CardNo<CardCount; CardNo++) {
|
---|
1134 | for (PromptNo=0; PromptNo<GeninPtr->PromptsCount; PromptNo++) {
|
---|
1135 | if (CurPos>=EndPos) {
|
---|
1136 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgMismatch); return FALSE; }
|
---|
1137 | // Check, if Card-Number matches
|
---|
1138 | CurPos = STRING_GetNumericValue(&CardProcessed, CurPos, EndPos);
|
---|
1139 | if (CurPos==NULL) {
|
---|
1140 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1141 | if ((CardNo+1)!=CardProcessed) { // Card-Number has to match
|
---|
1142 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgMismatch); return FALSE; }
|
---|
1143 | // '=' has to follow...
|
---|
1144 | if (*CurPos!='=') {
|
---|
1145 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgBadFormat); return FALSE; }
|
---|
1146 | CurPos++;
|
---|
1147 |
|
---|
1148 | // Now search for next ',V' in CustomData
|
---|
1149 | StartPos = CurPos;
|
---|
1150 | while (CurPos<EndPos) {
|
---|
1151 | if (*(PUSHORT)CurPos=='V,')
|
---|
1152 | break; // If found -> go out of loop
|
---|
1153 | CurPos++;
|
---|
1154 | }
|
---|
1155 | // If we are at End-Of-Data and LastChar==',', forget ','
|
---|
1156 | BytesLeft = CurPos-StartPos;
|
---|
1157 | if ((CurPos==EndPos) && (*(PCHAR)(((ULONG)CurPos)-1)==','))
|
---|
1158 | BytesLeft--;
|
---|
1159 |
|
---|
1160 | // So now search for the value...
|
---|
1161 | ValueNo = 0;
|
---|
1162 | ValueCount = GeninPtr->PromptChoiceCount[PromptNo];
|
---|
1163 | ValuePtr = GeninPtr->PromptChoiceValues[PromptNo];
|
---|
1164 | while (1) {
|
---|
1165 | if (ValueNo>=ValueCount) {
|
---|
1166 | MINSTALL_TrappedError (MINSTMSG_CARDINFOAutoCfgMismatch); return FALSE; }
|
---|
1167 | if (strlen(ValuePtr)==BytesLeft) {
|
---|
1168 | // Length of Value matches
|
---|
1169 | if (strncmp(ValuePtr, StartPos, BytesLeft)==0)
|
---|
1170 | break;
|
---|
1171 | }
|
---|
1172 | ValueNo++;
|
---|
1173 | ValuePtr = STRING_SkipASCIIZ(ValuePtr, NULL);
|
---|
1174 | }
|
---|
1175 | // We found it, so select this value...
|
---|
1176 | GeninPtr->PromptSelectedValueNo[CardNo][PromptNo] = ValueNo;
|
---|
1177 | GeninPtr->PromptSelectedValue[CardNo][PromptNo] = ValuePtr;
|
---|
1178 |
|
---|
1179 | // Adjust CurPos, if not end-of-data
|
---|
1180 | if ((CurPos+1)<EndPos)
|
---|
1181 | CurPos += 2;
|
---|
1182 | }
|
---|
1183 | }
|
---|
1184 | }
|
---|
1185 | }
|
---|
1186 | return TRUE;
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | VOID MINSTALL_FillCARDINFOCustomData (PMINSTGRP GroupPtr) {
|
---|
1190 | CHAR TempData[MINSTMAX_CUSTOMDATALENGTH];
|
---|
1191 | ULONG WriteLeft = MINSTMAX_CUSTOMDATALENGTH;
|
---|
1192 | PCHAR CurPos = 0;
|
---|
1193 | ULONG CardNo = 0;
|
---|
1194 | ULONG PromptNo = 0;
|
---|
1195 | PMINSTGENI GeninPtr = GroupPtr->GeninPtr;
|
---|
1196 |
|
---|
1197 | // Generate Custom-Data for CID processing...
|
---|
1198 | sprintf (TempData, "CARDCOUNT=%d", GeninPtr->SelectedCards);
|
---|
1199 | WriteLeft = MINSTMAX_CUSTOMDATALENGTH;
|
---|
1200 | CurPos = STRING_BuildEscaped (GroupPtr->CustomData, &WriteLeft, TempData);
|
---|
1201 |
|
---|
1202 | CardNo = 0;
|
---|
1203 | while ((CardNo<GeninPtr->SelectedCards) && (CurPos)) {
|
---|
1204 | sprintf (TempData, ";VALUES[%d]=", CardNo+1);
|
---|
1205 | CurPos = STRING_BuildEscaped (CurPos, &WriteLeft, TempData);
|
---|
1206 |
|
---|
1207 | PromptNo = 0;
|
---|
1208 | while ((PromptNo<GeninPtr->PromptsCount) && (CurPos)) {
|
---|
1209 | if (PromptNo==0) {
|
---|
1210 | sprintf (TempData, "%d", GeninPtr->PromptSelectedValueNo[CardNo][PromptNo]+1);
|
---|
1211 | } else {
|
---|
1212 | sprintf (TempData, ",%d", GeninPtr->PromptSelectedValueNo[CardNo][PromptNo]+1);
|
---|
1213 | }
|
---|
1214 | CurPos = STRING_BuildEscaped (CurPos, &WriteLeft, TempData);
|
---|
1215 | PromptNo++;
|
---|
1216 | }
|
---|
1217 | CardNo++;
|
---|
1218 | }
|
---|
1219 | }
|
---|
1220 |
|
---|
1221 | /* This one is called during PackageLoad and loads all required */
|
---|
1222 | /* GENIN-data DLLs (so called CARDINFO) into memory and fills out pointers */
|
---|
1223 | BOOL MINSTALL_LoadCARDINFO (VOID) {
|
---|
1224 | BOOL CurNo = 0;
|
---|
1225 | PMINSTGRP CurGroupPtr = MCF_GroupArrayPtr;
|
---|
1226 | ULONG LoopNo = 0;
|
---|
1227 | PMINSTGRP LoopGroupPtr = MCF_GroupArrayPtr;
|
---|
1228 | HMODULE CARDINFOHandle = NULLHANDLE;
|
---|
1229 |
|
---|
1230 | // If Genin not used -> skip but SUCCESS
|
---|
1231 | if (!MINSTALL_GeninUsed)
|
---|
1232 | return TRUE;
|
---|
1233 |
|
---|
1234 | while (CurNo<MCF_GroupCount) {
|
---|
1235 | if ((CurGroupPtr->GeninDLLFilePtr) && (CurGroupPtr->GeninDLLHandle==NULLHANDLE)) {
|
---|
1236 | MINSTLOG_ToFile ("LoadCARDINFO(%s)...\n", CurGroupPtr->GeninDLLFileName);
|
---|
1237 | if (!(CARDINFOHandle = MINSTALL_LoadSpecCARDINFODLL (CurGroupPtr->GeninDLLFilePtr))) {
|
---|
1238 | // if it fails, we need to check FCF_LastCARDINFOHandle and close
|
---|
1239 | // it.
|
---|
1240 | if (FCF_LastCARDINFOHandle)
|
---|
1241 | DLL_UnLoad (FCF_LastCARDINFOHandle);
|
---|
1242 | return FALSE;
|
---|
1243 | }
|
---|
1244 | // Now set the Handle in GroupPtr and walk through all further groups
|
---|
1245 | LoopNo = CurNo;
|
---|
1246 | LoopGroupPtr = CurGroupPtr;
|
---|
1247 | while (LoopNo<MCF_GroupCount) {
|
---|
1248 | if (LoopGroupPtr->GeninDLLFilePtr==CurGroupPtr->GeninDLLFilePtr) {
|
---|
1249 | // set DLL-Handle now, so that it won't get loaded twice...
|
---|
1250 | LoopGroupPtr->GeninDLLHandle = CARDINFOHandle;
|
---|
1251 | }
|
---|
1252 | LoopGroupPtr++; LoopNo++;
|
---|
1253 | }
|
---|
1254 | MINSTLOG_ToFile ("LoadCARDINFOGroup(%s) DONE\n", CurGroupPtr->GeninDLLFileName);
|
---|
1255 | }
|
---|
1256 | CurGroupPtr++; CurNo++;
|
---|
1257 | }
|
---|
1258 | return TRUE;
|
---|
1259 | }
|
---|
1260 |
|
---|
1261 | BOOL MINSTALL_ProcessCARDINFO (void) {
|
---|
1262 | BOOL CurNo = 0;
|
---|
1263 | PMINSTGRP CurGroupPtr = MCF_GroupArrayPtr;
|
---|
1264 |
|
---|
1265 | while (CurNo<MCF_GroupCount) {
|
---|
1266 | if ((CurGroupPtr->Flags & MINSTGRP_Flags_Selected) && (CurGroupPtr->GeninPtr)) {
|
---|
1267 | MINSTLOG_ToFile ("ProcessCARDINFOGroup()...\n");
|
---|
1268 | if (!MINSTALL_ProcessCARDINFOGroup (CurGroupPtr))
|
---|
1269 | return FALSE;
|
---|
1270 | MINSTLOG_ToFile ("ProcessCARDINFOGroup() DONE\n");
|
---|
1271 | }
|
---|
1272 | CurGroupPtr++; CurNo++;
|
---|
1273 | }
|
---|
1274 | return TRUE;
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 | // Unloads all CARDINFO-DLLs that got previously loaded by LoadCARDINFO
|
---|
1278 | VOID MINSTALL_CleanUpCARDINFO (void) {
|
---|
1279 | ULONG CurNo = 0;
|
---|
1280 | PMINSTGRP CurGroupPtr = MCF_GroupArrayPtr;
|
---|
1281 | HMODULE DLLHandle = 0;
|
---|
1282 | ULONG LoopNo = 0;
|
---|
1283 | PMINSTGRP LoopGroupPtr = MCF_GroupArrayPtr;
|
---|
1284 |
|
---|
1285 | // Release GENIN-memory-blocks...
|
---|
1286 | while (CurNo<MCF_GroupCount) {
|
---|
1287 | if (CurGroupPtr->GeninPtr) {
|
---|
1288 | // Release Genin-data memory...
|
---|
1289 | free (CurGroupPtr->GeninPtr);
|
---|
1290 | CurGroupPtr->GeninPtr = 0;
|
---|
1291 | }
|
---|
1292 | if (CurGroupPtr->GeninDLLHandle) {
|
---|
1293 | // Unload any CARDINFO-data-DLLs
|
---|
1294 | DLLHandle = CurGroupPtr->GeninDLLHandle;
|
---|
1295 | DLL_UnLoad (DLLHandle);
|
---|
1296 | // Remove handle from the group-list
|
---|
1297 | LoopNo = CurNo;
|
---|
1298 | LoopGroupPtr = CurGroupPtr;
|
---|
1299 | while (LoopNo<MCF_GroupCount) {
|
---|
1300 | if (LoopGroupPtr->GeninDLLHandle==DLLHandle) {
|
---|
1301 | // If freed handle found, we will remove it from Group-List
|
---|
1302 | LoopGroupPtr->GeninDLLHandle = NULLHANDLE;
|
---|
1303 | }
|
---|
1304 | LoopGroupPtr++; LoopNo++;
|
---|
1305 | }
|
---|
1306 | }
|
---|
1307 | CurGroupPtr++; CurNo++;
|
---|
1308 | }
|
---|
1309 |
|
---|
1310 | // Remove this action from cleanup...
|
---|
1311 | MINSTALL_Done &= !MINSTDONE_LOADCARDINFO;
|
---|
1312 | }
|
---|