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