source: trunk/src/mmi_customdll.c@ 3

Last change on this file since 3 was 3, checked in by erdmann, 8 years ago

fixing 2 bugs in mmi_customdll.c, unpacking STDCODE.RAR into its own directory, removing all binaries (.obj, .exe) from repo

File size: 39.2 KB
Line 
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#include <mmi_customdll.h>
46
47
48PSZ FakedConfigSysFile[] = {
49 "IFS=C:\\OS2\\HPFS.IFS",
50 "LIBPATH=C:\\OS2\\DLL",
51 "SET PATH=C:\\OS2",
52 "SET DPATH=C:\\OS2",
53 "BASEDEV=IBMKBD.SYS",
54 "DEVICE=C:\\OS2\\FAKED.SYS" };
55#define FakedConfigSysFileMaxNo 5
56
57PMINSTINIHEADER CustomAPI_INIChange1stEntryPtr = 0;
58PMINSTINIHEADER CustomAPI_INIChangeLastEntryPtr = 0;
59
60PCONFIGSYSACTION CustomAPI_ConfigSysActionArrayPtr = 0;
61PCONFIGSYSACTION CustomAPI_ConfigSysActionCurPtr = 0;
62PCONFIGSYSACTSTR CustomAPI_ConfigSysStringArrayPtr = 0;
63PCONFIGSYSACTSTR CustomAPI_ConfigSysStringCurPtr = 0;
64ULONG CustomAPI_ConfigSysActionCount = 0;
65
66// ****************************************************************************
67
68PMINSTINIHEADER MINSTALL_CustomAPIAllocINIChange (ULONG EntryID, ULONG EntrySize) {
69 PMINSTINIHEADER CurEntryPtr = malloc(EntrySize);
70
71 if (CurEntryPtr) {
72 // It worked, so set public variable or update last entry
73 if (CustomAPI_INIChangeLastEntryPtr) {
74 CustomAPI_INIChangeLastEntryPtr->NextPtr = CurEntryPtr;
75 } else {
76 CustomAPI_INIChange1stEntryPtr = CurEntryPtr;
77 }
78 memset (CurEntryPtr, 0, EntrySize);
79 CurEntryPtr->ID = EntryID;
80 CurEntryPtr->Size = EntrySize;
81 CustomAPI_INIChangeLastEntryPtr = CurEntryPtr;
82 }
83 return CurEntryPtr;
84 }
85
86VOID CustomAPI_AnalyseSYSINFOCalls (ULONG SysInfoID, PVOID SysInfoParms) {
87 PMCI_SYSINFO_LOGDEVICE CurSysInfoLogDev = NULL;
88 PMCI_SYSINFO_CONPARAMS CurSysInfoConn = NULL;
89 PMCI_SYSINFO_DEVPARAMS CurSysInfoParams = NULL;
90 USHORT i;
91 USHORT j;
92
93 MINSTLOG_ToFile (" SYSINFO message content:\n");
94 MINSTLOG_ToFile (" - SysInfoCode = %d", SysInfoID);
95 switch (SysInfoID) {
96 case 1: MINSTLOG_ToFile (" (INSTALL_DRIVER)"); break;
97 case 2: MINSTLOG_ToFile (" (QUERY_DRIVER)"); break;
98 case 4: MINSTLOG_ToFile (" (DELETE_DRIVER)"); break;
99 case 8: MINSTLOG_ToFile (" (SET_PARAMS)"); break;
100 case 16: MINSTLOG_ToFile (" (QUERY_PARAMS)"); break;
101 case 32: MINSTLOG_ToFile (" (SET_CONNECTORS)"); break;
102 case 64: MINSTLOG_ToFile (" (QUERY_CONNECTORS)"); break;
103 case 128: MINSTLOG_ToFile (" (SET_EXTENSIONS)"); break;
104 case 256: MINSTLOG_ToFile (" (QUERY_EXTENSIONS)"); break;
105 case 512: MINSTLOG_ToFile (" (SET_ALIAS)"); break;
106 case 1024: MINSTLOG_ToFile (" (QUERY_NAMES)"); break;
107 case 2048: MINSTLOG_ToFile (" (SET_DEFAULT)"); break;
108 case 4096: MINSTLOG_ToFile (" (QUERY_DEFAULT)"); break;
109 case 8192: MINSTLOG_ToFile (" (SET_TYPES)"); break;
110 case 16384: MINSTLOG_ToFile (" (QUERY_TYPES)"); break;
111 }
112 MINSTLOG_ToFile ("\n");
113 switch (SysInfoID) {
114 case 1:
115 case 2:
116 case 4:
117 CurSysInfoLogDev = (PMCI_SYSINFO_LOGDEVICE)SysInfoParms;
118 MINSTLOG_ToFile (" - Name %s\n", CurSysInfoLogDev->szInstallName);
119 if (SysInfoID==1) {
120 MINSTLOG_ToFile (" - DeviceType %d\n", CurSysInfoLogDev->usDeviceType);
121 MINSTLOG_ToFile (" - DeviceFlag %d\n", CurSysInfoLogDev->ulDeviceFlag);
122 MINSTLOG_ToFile (" - ResourceClasses %d\n", CurSysInfoLogDev->usResourceClasses);
123 }
124 break;
125 case 32:
126 CurSysInfoConn = (PMCI_SYSINFO_CONPARAMS)SysInfoParms;
127 MINSTLOG_ToFile (" - Name %s\n", CurSysInfoConn->szInstallName);
128 MINSTLOG_ToFile (" - ConnectorCount %d\n", CurSysInfoConn->usNumConnectors);
129 for (i=0; i<CurSysInfoConn->usNumConnectors; i++) {
130 MINSTLOG_ToFile (" - ConnectorType[%d] %d\n", i, CurSysInfoConn->ConnectorList[i].usConnectType);
131 MINSTLOG_ToFile (" - ConnectorTo[%d] %s\n", i, CurSysInfoConn->ConnectorList[i].szToInstallName);
132 MINSTLOG_ToFile (" - ConnectorIndex[%d] %d\n", i, CurSysInfoConn->ConnectorList[i].usToConnectIndex);
133 }
134 break;
135 case 8:
136 CurSysInfoParams = (PMCI_SYSINFO_DEVPARAMS)SysInfoParms;
137 MINSTLOG_ToFile (" - Name %s\n", CurSysInfoParams->szInstallName);
138 MINSTLOG_ToFile (" - Parameters %s\n", CurSysInfoParams->szDevParams);
139 break;
140 }
141 }
142
143// This procedure needs MINSTALL_LinkInImports()!
144MRESULT EXPENTRY MINSTALL_CustomAPIProcedure (HWND WindowHandle, ULONG MsgID, MPARAM mp1, MPARAM mp2) {
145 MRESULT WResult;
146 ULONG APIResult = 0;
147 PMINSTOLD_CONFIGDATA ConfigData;
148 ULONG TmpLen;
149 CHAR TempBuffer[MAXFILELENGTH];
150 ULONG CRC32;
151 PMINSTFILE CurFilePtr = NULL;
152 PMINSTOLD_MCI_SENDCOMMAND CurSendCommand = NULL;
153 PMINSTINIHEADER INIChangeEntryPtr = NULL;
154 PCHAR CurPos, EndPos, WritePos;
155 ULONG WriteLeft;
156 PMCI_SYSINFO_PARMS CurSysInfoParms = NULL;
157 PMCI_NETWORK_DEFAULT_CONNECTION_PARMS CurNetDefConn = NULL;
158 USHORT i;
159 BOOL IsBannedOp = FALSE;
160
161// printf("MsgID=%d\n", MsgID);
162
163 switch (MsgID) {
164 case MINSTOLD_LOG_ERROR_MSGID:
165 MINSTLOG_ToFile ("Log: %s\n", (PSZ)mp1);
166 break;
167 case MINSTOLD_QUERYPATH_MSGID:
168 if (!STRING_CombinePSZ (TempBuffer, MAXFILELENGTH, (PSZ)mp1, ""))
169 break;
170 strlwr (TempBuffer); // Filename needs to be low-cased
171 FILE_SetDefaultExtension (TempBuffer, MAXFILELENGTH, ".dll");
172 CRC32 = CRC32_GetFromPSZ(TempBuffer);
173 CurFilePtr = MINSTALL_SearchFileCRC32(CRC32);
174 MINSTLOG_ToFile ("Querying path for %s...", TempBuffer);
175 if (CurFilePtr) {
176 STRING_CombinePSZ((PSZ)mp2, CCHMAXPATH, CurFilePtr->SourcePtr->FQName, TempBuffer);
177 MINSTLOG_ToFile ("found\n");
178 } else {
179 memset ((PSZ)mp2, 0, CCHMAXPATH);
180 MINSTLOG_ToFile ("not found\n");
181 }
182 break;
183 case MINSTOLD_MCI_SYSINFO_MSGID:
184 // Cheap wrapper to MCI - Extended SYSINFO
185 // mp1 got FunctionID, mp2 got SysInfoParm
186 MINSTLOG_ToFile ("Doing MCI-SYSINFO...\n");
187 CustomAPI_AnalyseSYSINFOCalls ((ULONG)LONGFROMMP(mp1), PVOIDFROMMP(mp2));
188 APIResult = MCIINI_SendSysInfoExtCommand ((ULONG)LONGFROMMP(mp1), PVOIDFROMMP(mp2));
189 break;
190 case MINSTOLD_MCI_SENDCOMMAND_MSGID:
191 // Wrapper to send an MCI command
192 // mp2 got MciSendCommand
193 MINSTLOG_ToFile ("Doing MCI-SendCommand...\n");
194 CurSendCommand = (PMINSTOLD_MCI_SENDCOMMAND)mp2;
195 MINSTLOG_ToFile (" - wDeviceID = %d\n", CurSendCommand->wDeviceID);
196 MINSTLOG_ToFile (" - wMessage = %d\n", CurSendCommand->wMessage);
197 MINSTLOG_ToFile (" - dwParam1 = %d\n", CurSendCommand->dwParam1);
198 MINSTLOG_ToFile (" - dwParam2 = %d\n", CurSendCommand->dwParam2);
199 MINSTLOG_ToFile (" - wUserParm = %d\n", CurSendCommand->wUserParm);
200 switch (CurSendCommand->wMessage) {
201 case 15:
202 CurSysInfoParms = (PMCI_SYSINFO_PARMS)CurSendCommand->dwParam2;
203 CustomAPI_AnalyseSYSINFOCalls (CurSysInfoParms->ulItem, (PVOID)CurSysInfoParms->pSysInfoParm);
204 break;
205 case 35:
206 CurNetDefConn = (PMCI_NETWORK_DEFAULT_CONNECTION_PARMS)CurSendCommand->dwParam2;
207 MINSTLOG_ToFile (" NETWORK_DEFAULT_CONNECTION message content:\n");
208 MINSTLOG_ToFile (" - Name %s\n", CurNetDefConn->szInstallName);
209 MINSTLOG_ToFile (" - ulNumDevices %d\n", CurNetDefConn->ulNumDevices);
210 MINSTLOG_ToFile (" - ulNumPlayConnections %d\n", CurNetDefConn->ulNumPlayConnections);
211 MINSTLOG_ToFile (" - ulNumRecordConnections %d\n", CurNetDefConn->ulNumRecordConnections);
212 for (i=0; i< CurNetDefConn->ulNumDevices; i++) {
213 MINSTLOG_ToFile (" - Devices[%d] %s\n", i, CurNetDefConn->pDevices[i]);
214 }
215 MINSTLOG_ToFile (" - PLAYBACK\n");
216 MINSTLOG_ToFile (" - ulFromDevice = %d\n", CurNetDefConn->pPlayConnections->ulFromDevice);
217 MINSTLOG_ToFile (" - ulSrcConnType = %d\n", CurNetDefConn->pPlayConnections->ulSrcConnType);
218 MINSTLOG_ToFile (" - ulSrcConnType = %d\n", CurNetDefConn->pPlayConnections->ulSrcConnType);
219 MINSTLOG_ToFile (" - ulSrcConnNum = %d\n", CurNetDefConn->pPlayConnections->ulSrcConnNum);
220 MINSTLOG_ToFile (" - ulToDevice = %d\n", CurNetDefConn->pPlayConnections->ulToDevice);
221 MINSTLOG_ToFile (" - ulTgtConnType = %d\n", CurNetDefConn->pPlayConnections->ulTgtConnType);
222 MINSTLOG_ToFile (" - ulTgtConnNum = %d\n", CurNetDefConn->pPlayConnections->ulTgtConnNum);
223 MINSTLOG_ToFile (" - RECORD\n");
224 MINSTLOG_ToFile (" - ulFromDevice = %d\n", CurNetDefConn->pRecordConnections->ulFromDevice);
225 MINSTLOG_ToFile (" - ulSrcConnType = %d\n", CurNetDefConn->pRecordConnections->ulSrcConnType);
226 MINSTLOG_ToFile (" - ulSrcConnType = %d\n", CurNetDefConn->pRecordConnections->ulSrcConnType);
227 MINSTLOG_ToFile (" - ulSrcConnNum = %d\n", CurNetDefConn->pRecordConnections->ulSrcConnNum);
228 MINSTLOG_ToFile (" - ulToDevice = %d\n", CurNetDefConn->pRecordConnections->ulToDevice);
229 MINSTLOG_ToFile (" - ulTgtConnType = %d\n", CurNetDefConn->pRecordConnections->ulTgtConnType);
230 MINSTLOG_ToFile (" - ulTgtConnNum = %d\n", CurNetDefConn->pRecordConnections->ulTgtConnNum);
231 }
232 APIResult = (*MCIINI_MciSendCommandFunc) (CurSendCommand->wDeviceID, CurSendCommand->wMessage,
233 CurSendCommand->dwParam1, CurSendCommand->dwParam2, CurSendCommand->wUserParm);
234 break;
235 case MINSTOLD_CONFIG_ENUMERATE_MSGID:
236 case MINSTOLD_CONFIG_UPDATE_MSGID:
237 case MINSTOLD_CONFIG_MERGE_MSGID:
238 case MINSTOLD_CONFIG_REPLACE_MSGID:
239 case MINSTOLD_CONFIG_NEW_MSGID:
240 case MINSTOLD_CONFIG_DELETE_MSGID:
241 case MINSTOLD_CONFIG_QUERYCHANGED_MSGID:
242 ConfigData = (PMINSTOLD_CONFIGDATA)mp1;
243 switch (ConfigData->lLine) {
244 case MINSTOLD_CONFIG_TOP: CustomAPI_ConfigSysLine = 0; break;
245 case MINSTOLD_CONFIG_BOTTOM: CustomAPI_ConfigSysLine = FakedConfigSysFileMaxNo; break;
246 case MINSTOLD_CONFIG_NEXT:
247 CustomAPI_ConfigSysLine++;
248 if (CustomAPI_ConfigSysLine>=FakedConfigSysFileMaxNo) {
249 CustomAPI_ConfigSysLine = FakedConfigSysFileMaxNo;
250 APIResult = MINSTOLD_RETATBOTTOM;
251 }
252 break;
253 case MINSTOLD_CONFIG_PREV:
254 CustomAPI_ConfigSysLine--;
255 if (CustomAPI_ConfigSysLine>=FakedConfigSysFileMaxNo) {
256 CustomAPI_ConfigSysLine = 0;
257 APIResult = MINSTOLD_RETATTOP;
258 }
259 break;
260 case MINSTOLD_CONFIG_CURRENT:
261 break;
262 default:
263 CustomAPI_ConfigSysLine = ConfigData->lLine;
264 }
265 if (CustomAPI_ConfigSysLine>FakedConfigSysFileMaxNo) {
266 APIResult = MINSTOLD_RETLINENOTFOUND;
267 } else {
268 switch (MsgID) {
269 case MINSTOLD_CONFIG_ENUMERATE_MSGID:
270 // Get that specific line and copy it into destination buffer
271 TmpLen = strlen(FakedConfigSysFile[CustomAPI_ConfigSysLine]);
272 if (TmpLen<ConfigData->lBufferLen) {
273 strcpy (ConfigData->pszBuffer, FakedConfigSysFile[CustomAPI_ConfigSysLine]);
274 } else {
275 if (!APIResult) APIResult = MINSTOLD_RETBUFFEROVERFLOW;
276 }
277 break;
278 case MINSTOLD_CONFIG_UPDATE_MSGID:
279 case MINSTOLD_CONFIG_NEW_MSGID:
280 case MINSTOLD_CONFIG_MERGE_MSGID:
281 switch (MsgID) {
282 case MINSTOLD_CONFIG_UPDATE_MSGID:
283 MINSTLOG_ToFile ("CONFIG.SYS-Update: %s\n", ConfigData->pszBuffer);
284 MINSTLOG_ToFile (" -> Converted to insert line command\n");
285 break;
286 case MINSTOLD_CONFIG_NEW_MSGID:
287 MINSTLOG_ToFile ("CONFIG.SYS-Add: %s\n", ConfigData->pszBuffer);
288 break;
289 case MINSTOLD_CONFIG_MERGE_MSGID:
290 MINSTLOG_ToFile ("Merge: %s\n", ConfigData->pszBuffer);
291 MINSTLOG_ToFile (" -> Converted to merge line command\n");
292 break;
293 }
294 // Allocate memory for CFGSYS-API, if not already done
295 if ((!CustomAPI_ConfigSysActionArrayPtr) || (!CustomAPI_ConfigSysStringArrayPtr)) {
296 CustomAPI_ConfigSysActionArrayPtr = malloc(128*sizeof(CONFIGSYSACTION));
297 if (!CustomAPI_ConfigSysActionArrayPtr) {
298 APIResult = MINSTOLD_RETOUTOFMEMORY; break; }
299 CustomAPI_ConfigSysStringArrayPtr = malloc(128*sizeof(CONFIGSYSACTSTR));
300 if (!CustomAPI_ConfigSysStringArrayPtr) {
301 APIResult = MINSTOLD_RETOUTOFMEMORY; break; }
302
303 memset (CustomAPI_ConfigSysActionArrayPtr, 0, 128*sizeof(CONFIGSYSACTION));
304 memset (CustomAPI_ConfigSysStringArrayPtr, 0, 128*sizeof(CONFIGSYSACTSTR));
305 CustomAPI_ConfigSysActionCurPtr = CustomAPI_ConfigSysActionArrayPtr;
306 CustomAPI_ConfigSysStringCurPtr = CustomAPI_ConfigSysStringArrayPtr;
307 CustomAPI_ConfigSysActionCount = 0;
308 }
309 // Don't allow more than 128 changes to CONFIG.SYS
310 if (CustomAPI_ConfigSysActionCount==128) {
311 APIResult = MINSTOLD_RETOUTOFMEMORY; break; }
312
313 // Don't allow lines that are bigger than 1024 bytes (our limit)
314 CurPos = ConfigData->pszBuffer;
315 if (strlen(CurPos)>=1024) {
316 APIResult = MINSTOLD_RETOUTOFMEMORY; break; }
317 EndPos = (PCHAR)(((ULONG)CurPos)+strlen(CurPos));
318
319 // Now those changes are converted into CFGSYS-API commands...
320 CustomAPI_ConfigSysActionCurPtr->Flags = 0;
321 CustomAPI_ConfigSysActionCurPtr->CommandStrPtr = CustomAPI_ConfigSysStringCurPtr->CommandStr;
322 CustomAPI_ConfigSysActionCurPtr->MatchStrPtr = CustomAPI_ConfigSysStringCurPtr->MatchStr;
323 CustomAPI_ConfigSysActionCurPtr->MatchInLineStrPtr = CustomAPI_ConfigSysStringCurPtr->MatchInLineStr;
324 CustomAPI_ConfigSysActionCurPtr->ValueStrPtr = CustomAPI_ConfigSysStringCurPtr->ValueStr;
325
326 WritePos = CustomAPI_ConfigSysStringCurPtr->CommandStr;
327 WriteLeft = CONFIGSYSACTSTR_MAXLENGTH-1;
328 while (CurPos<EndPos) {
329 if ((*CurPos=='=') || (*CurPos==' ')) {
330 CurPos++; break; }
331 if (WriteLeft>0) {
332 *WritePos = *CurPos; WritePos++; WriteLeft--; }
333 CurPos++;
334 }
335
336 WritePos = CustomAPI_ConfigSysStringCurPtr->ValueStr;
337 WriteLeft = CONFIGSYSACTSTR_MAXLENGTH-1;
338 while (CurPos<EndPos) {
339 if (WriteLeft>0) {
340 *WritePos = *CurPos; WritePos++; WriteLeft--; }
341 CurPos++;
342 }
343
344 switch (MsgID) {
345 case MINSTOLD_CONFIG_UPDATE_MSGID:
346 case MINSTOLD_CONFIG_NEW_MSGID:
347 // Get filename on BASEDEV/DEVICE and RUN operations and compare
348 // it to our blacklist - ignore if its found...
349 strcpy(TempBuffer, CustomAPI_ConfigSysStringCurPtr->ValueStr);
350 strlwr (TempBuffer); // operation needs to be low-cased
351 // Find out where actual filename starts
352 CurPos = (PCHAR)&TempBuffer;
353 EndPos = (PCHAR)(((ULONG)&TempBuffer)+strlen(TempBuffer));
354 while ((CurPos<EndPos) && (*CurPos!=' '))
355 CurPos++;
356 // First space occurance -> put NUL there
357 if (*CurPos==' ') *CurPos = 0;
358 CurPos = EndPos;
359 while ((CurPos>(PCHAR)&TempBuffer) && (*CurPos!='\\'))
360 CurPos--;
361 // Set CurPos to start of filename
362 if (*CurPos=='\\') {
363 CurPos++;
364 } else {
365 CurPos = (PCHAR)&TempBuffer;
366 }
367
368 CRC32 = CRC32_GetFromPSZ(CurPos);
369 switch (CRC32) {
370 case 0xB8E85432: // timer0.sys (Timing PDD)
371 case 0x84F52EBF: // clock01.sys (Timing PDD)
372 case 0xC355546F: // clock02.sys (Timing PDD)
373 case 0x6DDDA492: // resource.sys (Resource Manager)
374 IsBannedOp = TRUE;
375 break;
376 }
377 MINSTLOG_ToFile (" -> Converted INSERT '%s' - '%s'\n", CustomAPI_ConfigSysStringCurPtr->CommandStr, CustomAPI_ConfigSysStringCurPtr->ValueStr);
378 break;
379 case MINSTOLD_CONFIG_MERGE_MSGID:
380 CustomAPI_ConfigSysActionCurPtr->Flags |= CONFIGSYSACTION_Flags_Merge;
381 MINSTLOG_ToFile (" -> Converted MERGE '%s' - '%s'\n", CustomAPI_ConfigSysStringCurPtr->CommandStr, CustomAPI_ConfigSysStringCurPtr->ValueStr);
382 break;
383 }
384 if (IsBannedOp) {
385 MINSTLOG_ToFile (" (!BANNED OPERATION, GOT IGNORED!)\n");
386 } else {
387 // Copy ValueStr to MatchStr, so duplicates will get overwritten
388 strcpy (CustomAPI_ConfigSysStringCurPtr->MatchStr, CustomAPI_ConfigSysStringCurPtr->ValueStr);
389 CustomAPI_ConfigSysActionCurPtr++; CustomAPI_ConfigSysStringCurPtr++;
390 CustomAPI_ConfigSysActionCount++;
391 }
392 break;
393 case MINSTOLD_CONFIG_QUERYCHANGED_MSGID:
394 APIResult = TRUE; // We reply TRUE at any time
395 break;
396 // Unsupported functions...
397 case MINSTOLD_CONFIG_REPLACE_MSGID:
398 MINSTLOG_ToFile ("Tried to replace CONFIG.SYS, not supported!\n");
399 break;
400 case MINSTOLD_CONFIG_DELETE_MSGID:
401 MINSTLOG_ToFile ("Tried to delete line, not supported!\n");
402 break;
403 }
404 }
405 break;
406 case MINSTOLD_EA_JOIN_MSGID:
407 // Joins EAs from a file onto a file/path
408 MINSTLOG_ToFile ("Delaying EA_JOINEA...\n");
409 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(EA_JOINEA_ID, sizeof(EA_JOINEA)))!=0) {
410 strcpy (((PEA_JOINEA)INIChangeEntryPtr)->JoinFileName, ((PMINSTOLD_EA_JOIN)mp2)->achFileName);
411 strcpy (((PEA_JOINEA)INIChangeEntryPtr)->JoinEAFileName, ((PMINSTOLD_EA_JOIN)mp2)->achEAFileName);
412 }
413 break;
414 case MINSTOLD_EA_LONGNAMEJOIN_MSGID:
415 // Joins EAs from a file onto a file/path, also sets long-name
416 MINSTLOG_ToFile ("Delaying EA_LONGNAMEJOIN...\n");
417 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(EA_JOINLONGNAMEEA_ID, sizeof(EA_JOINLONGNAMEEA)))!=0) {
418 strcpy (((PEA_JOINLONGNAMEEA)INIChangeEntryPtr)->JoinLongName, ((PMINSTOLD_EA_LONGNAMEJOIN)mp2)->achLongName);
419 strcpy (((PEA_JOINLONGNAMEEA)INIChangeEntryPtr)->JoinLongFileName, ((PMINSTOLD_EA_LONGNAMEJOIN)mp2)->achLongFileName);
420 strcpy (((PEA_JOINLONGNAMEEA)INIChangeEntryPtr)->JoinEALongFileName, ((PMINSTOLD_EA_LONGNAMEJOIN)mp2)->achEALongFileName);
421 }
422 break;
423 case MINSTOLD_MMIO_INSTALL_MSGID:
424 // Installs an IO-Proc (using obscure MINSTALL format)
425 MINSTLOG_ToFile ("Delaying MMIO_INSTALL...\n");
426 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(MMIO_MMIOINSTALL_ID, sizeof(MMIO_MMIOINSTALL)))!=0) {
427 ((PMMIO_MMIOINSTALL)INIChangeEntryPtr)->fccIOProc = (ULONG)((PMINSTOLD_MMIO_INSTALL)mp2)->fccIOProc;
428 strcpy (((PMMIO_MMIOINSTALL)INIChangeEntryPtr)->szDLLName, ((PMINSTOLD_MMIO_INSTALL)mp2)->szDLLName);
429 strcpy (((PMMIO_MMIOINSTALL)INIChangeEntryPtr)->szProcName, ((PMINSTOLD_MMIO_INSTALL)mp2)->szProcName);
430 ((PMMIO_MMIOINSTALL)INIChangeEntryPtr)->dwFlags = ((PMINSTOLD_MMIO_INSTALL)mp2)->ulFlags;
431 ((PMMIO_MMIOINSTALL)INIChangeEntryPtr)->dwExtendLen = ((PMINSTOLD_MMIO_INSTALL)mp2)->ulExtendLen;
432 ((PMMIO_MMIOINSTALL)INIChangeEntryPtr)->dwMediaType = ((PMINSTOLD_MMIO_INSTALL)mp2)->ulMediaType;
433 ((PMMIO_MMIOINSTALL)INIChangeEntryPtr)->dwIOProcType = ((PMINSTOLD_MMIO_INSTALL)mp2)->ulIOProcType;
434 strcpy (((PMMIO_MMIOINSTALL)INIChangeEntryPtr)->szDefExt, ((PMINSTOLD_MMIO_INSTALL)mp2)->szDefExt);
435 }
436 break;
437 case MINSTOLD_MMIO_CODEC1INSTALL_MSGID:
438 case MINSTOLD_MMIO_CODEC2INSTALL_MSGID:
439 // Installs an IO-Codec (using ulCodecCompType or fccCodecCompType)
440 MINSTLOG_ToFile ("Delaying MMIO_CODECxINSTALL...\n");
441 // We get an MMIOCODEC1INSTALL-Block, in fact it doesnt matter because
442 // process routine handles both the same way (due same buffer format)
443 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(MMIO_MMIOCODEC1INSTALL_ID, sizeof(MMIO_MMIOCODEC)))!=0) {
444 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulStructLen = ((PMINSTOLD_MMIO_CODEC)mp2)->ulStructLen;
445 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->fcc = (ULONG)((PMINSTOLD_MMIO_CODEC)mp2)->fcc;
446 strcpy (((PMMIO_MMIOCODEC)INIChangeEntryPtr)->szDLLName, ((PMINSTOLD_MMIO_CODEC)mp2)->szDLLName);
447 strcpy (((PMMIO_MMIOCODEC)INIChangeEntryPtr)->szProcName, ((PMINSTOLD_MMIO_CODEC)mp2)->szProcName);
448 if (MsgID==MINSTOLD_MMIO_CODEC1INSTALL_MSGID) {
449 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulCompressType = ((PMINSTOLD_MMIO_CODEC)mp2)->x.ulCodecCompType;
450 } else {
451 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulCompressType = (ULONG)((PMINSTOLD_MMIO_CODEC)mp2)->x.fccCodecCompType;
452 }
453 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulCompressSubType = ((PMINSTOLD_MMIO_CODEC)mp2)->ulCompressSubType;
454 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulMediaType = ((PMINSTOLD_MMIO_CODEC)mp2)->ulMediaType;
455 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulCapsFlags = ((PMINSTOLD_MMIO_CODEC)mp2)->ulCapsFlags;
456 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulFlags = ((PMINSTOLD_MMIO_CODEC)mp2)->ulFlags;
457 strcpy (((PMMIO_MMIOCODEC)INIChangeEntryPtr)->szHWID, ((PMINSTOLD_MMIO_CODEC)mp2)->szHWID);
458 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulMaxSrcBufLen = ((PMINSTOLD_MMIO_CODEC)mp2)->ulMaxSrcBufLen;
459 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulSyncMethod = ((PMINSTOLD_MMIO_CODEC)mp2)->ulSyncMethod;
460 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->fccPreferredFormat = ((PMINSTOLD_MMIO_CODEC)mp2)->fccPreferredFormat;
461 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulXalignment = ((PMINSTOLD_MMIO_CODEC)mp2)->ulXalignment;
462 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulYalignment = ((PMINSTOLD_MMIO_CODEC)mp2)->ulYalignment;
463 strcpy (((PMMIO_MMIOCODEC)INIChangeEntryPtr)->szSpecInfo, ((PMINSTOLD_MMIO_CODEC)mp2)->szSpecInfo);
464 }
465 break;
466 case MINSTOLD_MMIO_CODECDELETE_MSGID:
467 // Deletes an IO-Codec
468 MINSTLOG_ToFile ("Delaying MMIO_CODECDELETE...\n");
469 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(MMIO_MMIOCODECDELETE_ID, sizeof(MMIO_MMIOCODEC)))!=0) {
470 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulStructLen = ((PMINSTOLD_MMIO_CODEC)mp2)->ulStructLen;
471 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->fcc = (ULONG)((PMINSTOLD_MMIO_CODEC)mp2)->fcc;
472 strcpy (((PMMIO_MMIOCODEC)INIChangeEntryPtr)->szDLLName, ((PMINSTOLD_MMIO_CODEC)mp2)->szDLLName);
473 strcpy (((PMMIO_MMIOCODEC)INIChangeEntryPtr)->szProcName, ((PMINSTOLD_MMIO_CODEC)mp2)->szProcName);
474 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulCompressType = ((PMINSTOLD_MMIO_CODEC)mp2)->x.ulCodecCompType;
475 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulCompressSubType = ((PMINSTOLD_MMIO_CODEC)mp2)->ulCompressSubType;
476 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulMediaType = ((PMINSTOLD_MMIO_CODEC)mp2)->ulMediaType;
477 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulCapsFlags = ((PMINSTOLD_MMIO_CODEC)mp2)->ulCapsFlags;
478 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulFlags = ((PMINSTOLD_MMIO_CODEC)mp2)->ulFlags;
479 strcpy (((PMMIO_MMIOCODEC)INIChangeEntryPtr)->szHWID, ((PMINSTOLD_MMIO_CODEC)mp2)->szHWID);
480 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulMaxSrcBufLen = ((PMINSTOLD_MMIO_CODEC)mp2)->ulMaxSrcBufLen;
481 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulSyncMethod = ((PMINSTOLD_MMIO_CODEC)mp2)->ulSyncMethod;
482 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->fccPreferredFormat = ((PMINSTOLD_MMIO_CODEC)mp2)->fccPreferredFormat;
483 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulXalignment = ((PMINSTOLD_MMIO_CODEC)mp2)->ulXalignment;
484 ((PMMIO_MMIOCODEC)INIChangeEntryPtr)->ulYalignment = ((PMINSTOLD_MMIO_CODEC)mp2)->ulYalignment;
485 strcpy (((PMMIO_MMIOCODEC)INIChangeEntryPtr)->szSpecInfo, ((PMINSTOLD_MMIO_CODEC)mp2)->szSpecInfo);
486 }
487 break;
488 case MINSTOLD_PRF_STRINGDATA_MSGID:
489 // Adds a profile string to an INI file
490 MINSTLOG_ToFile ("Delaying PRF_STRINGDATA...\n");
491 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(PRF_PROFILESTRING_ID, sizeof(PRF_PROFILESTRING)))!=0) {
492 strcpy (((PPRF_PROFILESTRING)INIChangeEntryPtr)->Inis, ((PMINSTOLD_PRF_STRINGDATA)mp2)->achInisName);
493 strcpy (((PPRF_PROFILESTRING)INIChangeEntryPtr)->AppNames, ((PMINSTOLD_PRF_STRINGDATA)mp2)->achAppsName);
494 strcpy (((PPRF_PROFILESTRING)INIChangeEntryPtr)->KeyNames, ((PMINSTOLD_PRF_STRINGDATA)mp2)->achKeysName);
495 strcpy (((PPRF_PROFILESTRING)INIChangeEntryPtr)->Datas, ((PMINSTOLD_PRF_STRINGDATA)mp2)->achDatasName);
496 }
497 break;
498 case MINSTOLD_PRF_APPENDDATA_MSGID:
499 // Appends a string onto an INI file
500 MINSTLOG_ToFile ("Delaying PRF_APPENDDATA (UNSUPPORTED!)...\n");
501 break;
502 case MINSTOLD_SPI_INSTALL_MSGID:
503 // Just an SpiInstall (primitive forward)
504 MINSTLOG_ToFile ("Delaying SPI_INSTALL...\n");
505 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(SPI_SPIINSTALL_ID, sizeof(SPI_SPIINSTALL)))!=0) {
506 strcpy (((PSPI_SPIINSTALL)INIChangeEntryPtr)->SpiDllName, (PSZ)mp2);
507 }
508 break;
509 case MINSTOLD_WPS_CREATEOBJECT_MSGID:
510 // Generates a WPS-object
511 MINSTLOG_ToFile ("Delaying WPS_CREATEOBJECT...\n");
512 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(WPS_CREATEOBJECT_ID, sizeof(WPS_CREATEOBJECT)))!=0) {
513 strcpy (((PWPS_CREATEOBJECT)INIChangeEntryPtr)->WPClassName, ((PMINSTOLD_WPS_CREATEOBJECT)mp2)->achClassName);
514 strcpy (((PWPS_CREATEOBJECT)INIChangeEntryPtr)->WPTitle, ((PMINSTOLD_WPS_CREATEOBJECT)mp2)->achTitle);
515 strcpy (((PWPS_CREATEOBJECT)INIChangeEntryPtr)->WPSetupString, ((PMINSTOLD_WPS_CREATEOBJECT)mp2)->achSetupString);
516 strcpy (((PWPS_CREATEOBJECT)INIChangeEntryPtr)->WPLocation, ((PMINSTOLD_WPS_CREATEOBJECT)mp2)->achLocation);
517 ((PWPS_CREATEOBJECT)INIChangeEntryPtr)->WPFlags = ((PMINSTOLD_WPS_CREATEOBJECT)mp2)->ulFlags;
518 }
519 break;
520 case MINSTOLD_WPS_DESTROYOBJECT_MSGID:
521 // Removes a WPS-object
522 MINSTLOG_ToFile ("Delaying WPS_DESTROYOBJECT...\n");
523 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(WPS_DESTROYOBJECT_ID, sizeof(WPS_DESTROYOBJECT)))!=0) {
524 strcpy (((PWPS_DESTROYOBJECT)INIChangeEntryPtr)->WPDestroyObjectID, (PSZ)mp2);
525 }
526 break;
527 case MINSTOLD_WPS_WPCLASS_MSGID:
528 // Registers a WPS-class and is able to replace another class with it
529 MINSTLOG_ToFile ("Delaying WPS_WPCLASS...\n");
530 if ((INIChangeEntryPtr = MINSTALL_CustomAPIAllocINIChange(WPS_WPCLASS_ID, sizeof(WPS_WPCLASS)))!=0) {
531 strcpy (((PWPS_WPCLASS)INIChangeEntryPtr)->WPClassNameNew, ((PMINSTOLD_WPS_WPCLASS)mp2)->achClassNewName);
532 strcpy (((PWPS_WPCLASS)INIChangeEntryPtr)->WPDllName, ((PMINSTOLD_WPS_WPCLASS)mp2)->achDllName);
533 strcpy (((PWPS_WPCLASS)INIChangeEntryPtr)->WPReplaceClass, ((PMINSTOLD_WPS_WPCLASS)mp2)->achReplaceClass);
534 }
535 break;
536 case MINSTOLD_MIDIMAP_INSTALL_MSGID:
537 // Installs a MIDIMAP
538 MINSTLOG_ToFile ("Delaying MIDIMAP_INSTALL (UNSUPPORTED!)...\n");
539 break;
540 default:
541 MINSTLOG_ToFile ("Unsupported MsgID: MsgID %d\n", MsgID);
542 WResult = WinDefWindowProc(WindowHandle, MsgID, mp1, mp2);
543 return WResult;
544 }
545 WResult = (PVOID)APIResult;
546 return WResult;
547 }
548
549VOID MINSTALL_CustomAPIThread (PVOID pvoid) {
550 QMSG qmsg;
551 ERRORID ErrorID;
552
553 do {
554 // We need our own PM and message queue handle in here...
555 if (!(CustomAPI_PMHandle = WinInitialize(0)))
556 break;
557
558 if (!(CustomAPI_MSGQHandle = WinCreateMsgQueue(CustomAPI_PMHandle, 0)))
559 break;
560
561 if (!WinRegisterClass(CustomAPI_PMHandle, "OBJECTWINDOW", (PFNWP)MINSTALL_CustomAPIProcedure, 0, 0))
562 break;
563
564 if (!(CustomAPI_WindowHandle = WinCreateWindow(HWND_OBJECT, "OBJECTWINDOW",
565 NULL, 0, 0, 0, 0, 0, NULLHANDLE, HWND_TOP, 1, NULL, NULL)))
566 break;
567
568 CustomAPI_ThreadCreated = TRUE;
569 DosPostEventSem (CustomAPI_InitEventHandle);
570 /* Message loop */
571 while(WinGetMsg(CustomAPI_MSGQHandle, &qmsg, NULLHANDLE, 0UL, 0UL))
572 WinDispatchMsg (CustomAPI_MSGQHandle, &qmsg);
573 } while (0);
574
575 if (WinIsWindow(CustomAPI_PMHandle, CustomAPI_WindowHandle))
576 WinDestroyWindow (CustomAPI_WindowHandle);
577 CustomAPI_WindowHandle = 0;
578
579 /* Release CONFIG-SYS API related memory */
580 if (CustomAPI_ConfigSysStringArrayPtr) free (CustomAPI_ConfigSysStringArrayPtr);
581 if (CustomAPI_ConfigSysActionArrayPtr) free (CustomAPI_ConfigSysActionArrayPtr);
582
583 if (CustomAPI_MSGQHandle) WinDestroyMsgQueue (CustomAPI_MSGQHandle);
584 if (CustomAPI_WindowHandle) WinTerminate (CustomAPI_WindowHandle);
585
586 if (!CustomAPI_ThreadCreated)
587 DosPostEventSem (CustomAPI_InitEventHandle);
588 return;
589 }
590
591BOOL MINSTALL_CreateCustomAPIThread (void) {
592 APIRET rc;
593
594 CustomAPI_ThreadCreated = FALSE;
595 if (!(DosCreateEventSem(NULL, &CustomAPI_InitEventHandle, DC_SEM_SHARED, FALSE))) {
596 if ((CustomAPI_ThreadID = _beginthread ((THREADFUNC)&MINSTALL_CustomAPIThread, NULL, 65536, NULL))!=-1) {
597 DosWaitEventSem (CustomAPI_InitEventHandle, -1);
598 }
599 DosCloseEventSem (CustomAPI_InitEventHandle);
600 }
601 return CustomAPI_ThreadCreated;
602 }
603
604VOID MINSTALL_RemoveCustomAPIThread (void) {
605 if (!WinPostMsg(CustomAPI_WindowHandle, WM_QUIT, NULL, NULL)) {
606 DosWaitThread (&CustomAPI_ThreadID, DCWW_WAIT);
607 }
608 }
609
610// 10.07.2005 - compatibility code for bad custom DLLs
611// This code executes the custom entrypoints via their own
612// threads, so if the custom DLL closes things like PM handle
613// we won't be affected
614
615VOID MINSTALL_CallCustomEntryPointThread (PVOID pvoid) {
616 HAB ThreadPMHandle = 0;
617 HMQ ThreadMSGQHandle = 0;
618
619 do {
620 // We initiate PM in this thread as well
621 if (!(ThreadPMHandle = WinInitialize(0)))
622 break;
623
624 if (!(ThreadMSGQHandle = WinCreateMsgQueue(ThreadPMHandle, 0)))
625 break;
626
627 ((PCUSTOMDLL_ENTRYFUNC)CustomDLL_EntryPoint) (0, MINSTALL_SourcePath, MINSTALL_MMBaseDrive,
628 CustomDLL_EntryParms, CustomAPI_WindowHandle, CustomDLL_CustomData);
629 } while (0);
630
631 if (ThreadMSGQHandle) WinDestroyMsgQueue (ThreadMSGQHandle);
632 if (ThreadPMHandle) WinTerminate (ThreadPMHandle);
633 return;
634 }
635
636// Creates another thread, that calls the entrypoint and waits for this thread
637// to finish.
638VOID MINSTALL_CallCustomEntryPoint (PCUSTOMDLL_ENTRYFUNC EntryPoint, PSZ EntryParms, PSZ CustomData) {
639 TID CustomEntryPointThread = 0;
640 // Set public variables, so that the thread knows what to do...
641 CustomDLL_EntryPoint = (PVOID)EntryPoint;
642 CustomDLL_EntryParms = EntryParms;
643 CustomDLL_CustomData = CustomData;
644 if ((CustomEntryPointThread = _beginthread ((THREADFUNC)&MINSTALL_CallCustomEntryPointThread, NULL, 131072, NULL))!=-1) {
645 DosWaitThread(&CustomEntryPointThread, DCWW_WAIT);
646 }
647 }
648
649BOOL MINSTALL_ExecuteCustomDLLs (void) {
650 PMINSTGRP CurGroupPtr = MCF_GroupArrayPtr;
651 PMINSTFILE CurFilePtr = 0;
652 USHORT CurNo = 0;
653 USHORT CurChangeNo = 0;
654 CHAR DLLFileName[MINSTMAX_PATHLENGTH];
655 HMODULE DLLHandle = 0;
656 PCUSTOMDLL_ENTRYFUNC CustomDLLEntryPoint = 0;
657 BOOL GotDLL = FALSE;
658
659 while (CurNo<MCF_GroupCount) {
660 if (CurGroupPtr->Flags & MINSTGRP_Flags_Selected) {
661 if (CurGroupPtr->DLLFilePtr) {
662 // CustomDLL got defined...
663 if (!GotDLL) {
664 // Initiate Custom-API Thread
665 if (!MINSTALL_CreateCustomAPIThread()) {
666 MINSTLOG_ToFile ("Custom-API: Thread init failed\n"); return FALSE; }
667 MINSTLOG_ToAll ("Custom-API: Thread opened\n");
668 GotDLL = TRUE;
669 /* 26.06.2005 - implemented compatibility code */
670 /* saves current drive and directory and sets */
671 /* current directory to be in source path */
672 /* Some badly custom DLLs need this */
673 MINSTALL_SaveCurrentDirectory();
674 MINSTALL_SetCurrentDirectoryToSource();
675 }
676 CurFilePtr = CurGroupPtr->DLLFilePtr;
677 if (STRING_CombinePSZ(DLLFileName, MINSTMAX_PATHLENGTH, CurFilePtr->SourcePtr->FQName, CurFilePtr->Name)) {
678 if ((DLLHandle = DLL_Load(DLLFileName))!=0) {
679 if (!(CustomDLLEntryPoint = (PCUSTOMDLL_ENTRYFUNC)DLL_GetEntryPoint (DLLHandle, CurGroupPtr->DLLEntry))) {
680 MINSTLOG_ToAll ("Custom-API: Entrypoint not found\n");
681 } else {
682 MINSTLOG_ToAll (" - Calling custom entrypoint\n");
683 CustomAPI_ConfigSysLine = 0;
684 // 10.07.2005 - compatibility code for bad custom DLLs
685 MINSTALL_CallCustomEntryPoint(CustomDLLEntryPoint, CurGroupPtr->DLLParms, CurGroupPtr->CustomData);
686// (CustomDLLEntryPoint) (0, MINSTALL_SourcePath, MINSTALL_MMBaseDrive,
687// CurGroupPtr->DLLParms, CustomAPI_WindowHandle, CurGroupPtr->CustomData);
688 }
689 DLL_UnLoad (DLLHandle);
690 }
691 }
692 }
693 }
694 CurGroupPtr++; CurNo++;
695 }
696 if (GotDLL) {
697 MINSTLOG_ToFile ("Total Custom-API-CONFIG.SYS Actions: %d\n", CustomAPI_ConfigSysActionCount);
698 if (CustomAPI_ConfigSysActionCount) {
699 MINSTALL_ProcessConfigControl (CustomAPI_ConfigSysActionCount, CustomAPI_ConfigSysActionArrayPtr);
700 }
701 MINSTALL_RemoveCustomAPIThread();
702 MINSTLOG_ToAll ("Custom-API: Thread closed\n");
703 /* 26.06.2005 - implemented compatibility code */
704 /* restores current directory in case */
705 MINSTALL_RestoreCurrentDirectory();
706 }
707 return TRUE;
708 }
709
710BOOL MINSTALL_ExecuteCustomTermDLLs (void) {
711 PMINSTGRP CurGroupPtr = MCF_GroupArrayPtr;
712 PMINSTFILE CurFilePtr = 0;
713 USHORT CurNo = 0;
714 USHORT CurChangeNo = 0;
715 CHAR DLLFileName[MINSTMAX_PATHLENGTH];
716 HMODULE DLLHandle = 0;
717 PCUSTOMDLL_ENTRYFUNC CustomDLLEntryPoint = 0;
718 CHAR CustomData[MINSTMAX_CUSTOMDATALENGTH];
719 BOOL GotDLL = FALSE;
720
721 while (CurNo<MCF_GroupCount) {
722 if (CurGroupPtr->Flags & MINSTGRP_Flags_Selected) {
723 if (CurGroupPtr->TermDLLFilePtr) {
724 // CustomDLL got defined...
725 if (!GotDLL) {
726 // Initiate Custom-API Thread
727 if (!MINSTALL_CreateCustomAPIThread()) {
728 MINSTLOG_ToFile ("Custom-Terminate-API: Thread init failed\n"); return FALSE; }
729 MINSTLOG_ToAll ("Custom-Terminate-API: Thread opened\n");
730 GotDLL = TRUE;
731 /* 26.06.2005 - implemented compatibility code */
732 /* saves current drive and directory and sets */
733 /* current directory to be in source path */
734 /* Some badly custom DLLs need this */
735 MINSTALL_SaveCurrentDirectory();
736 MINSTALL_SetCurrentDirectoryToSource();
737 }
738 CurFilePtr = CurGroupPtr->TermDLLFilePtr;
739 if (STRING_CombinePSZ(DLLFileName, MINSTMAX_PATHLENGTH, CurFilePtr->SourcePtr->FQName, CurFilePtr->Name)) {
740 if ((DLLHandle = DLL_Load(DLLFileName))!=0) {
741 if (!(CustomDLLEntryPoint = (PCUSTOMDLL_ENTRYFUNC)DLL_GetEntryPoint (DLLHandle, CurGroupPtr->TermDLLEntry))) {
742 MINSTLOG_ToFile ("Custom-Terminate-API: Entrypoint not found\n");
743 } else {
744 MINSTLOG_ToAll (" - Calling custom terminate-entrypoint\n");
745 memset (CustomData, 0, sizeof(CustomData));
746 CustomAPI_ConfigSysLine = 0;
747 // 10.07.2005 - compatibility code for bad custom DLLs
748 MINSTALL_CallCustomEntryPoint(CustomDLLEntryPoint, CurGroupPtr->DLLParms, CurGroupPtr->CustomData);
749// (CustomDLLEntryPoint) (0, MINSTALL_SourcePath, MINSTALL_MMBaseDrive,
750// "", CustomAPI_WindowHandle, CustomData);
751 }
752 DLL_UnLoad (DLLHandle);
753 }
754 }
755 }
756 }
757 CurGroupPtr++; CurNo++;
758 }
759 if (GotDLL) {
760 MINSTLOG_ToFile ("Total Custom-API-CONFIG.SYS Actions: %d\n", CustomAPI_ConfigSysActionCount);
761 if (CustomAPI_ConfigSysActionCount) {
762 MINSTALL_ProcessConfigControl (CustomAPI_ConfigSysActionCount, CustomAPI_ConfigSysActionArrayPtr);
763 }
764 MINSTALL_RemoveCustomAPIThread();
765 MINSTLOG_ToAll ("Custom-Terminate-API: Thread closed\n");
766 /* 26.06.2005 - implemented compatibility code */
767 /* restores current directory in case */
768 MINSTALL_RestoreCurrentDirectory();
769 }
770 return TRUE;
771 }
Note: See TracBrowser for help on using the repository browser.