Changeset 46 for trunk/src/helpers/dosh2.c
- Timestamp:
- Mar 13, 2001, 9:56:01 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dosh2.c
r21 r46 792 792 *@@added V0.9.0 [umoeller] 793 793 *@@changed V0.9.1 (2000-02-13) [umoeller]: fixed 32-bits flag 794 *@@changed V0.9.7 (2000-12-20) [lafaix]: fixed ulNewHeaderOfs 794 795 */ 795 796 … … 1195 1196 1196 1197 return (arc); 1198 } 1199 1200 /* 1201 *@@ doshExecQueryImportedModules: 1202 * returns an array of FSYSMODULE structure describing all 1203 * imported modules. 1204 * 1205 * *pcModules receives the # of items in the array (not the 1206 * array size!). Use doshFreeImportedModules to clean up. 1207 * 1208 *@@added V0.9.9 (2001-03-11) [lafaix] 1209 */ 1210 1211 PFSYSMODULE doshExecQueryImportedModules(PEXECUTABLE pExec, 1212 PULONG pcModules) 1213 { 1214 return (NULL); 1215 } 1216 1217 /* 1218 *@@ doshExecFreeImportedModules: 1219 * frees resources allocated by doshExecQueryImportedModules. 1220 * 1221 *@@added V0.9.9 (2001-03-11) 1222 */ 1223 1224 APIRET doshExecFreeImportedModules(PFSYSMODULE paModules) 1225 { 1226 free(paModules); 1227 return (NO_ERROR); 1228 } 1229 1230 /* 1231 *@@ doshExecQueryExportedFunctions: 1232 * returns an array of FSYSFUNCTION structure describing all 1233 * exported functions. 1234 * 1235 * *pcFunctions receives the # of items in the array (not the 1236 * array size!). Use doshFreeExportedFunctions to clean up. 1237 * 1238 * Note that the returned array only contains entry for exported 1239 * functions. Empty export entries are _not_ included. 1240 * 1241 *@@added V0.9.9 (2001-03-11) [lafaix] 1242 */ 1243 1244 PFSYSFUNCTION doshExecQueryExportedFunctions(PEXECUTABLE pExec, 1245 PULONG pcFunctions) 1246 { 1247 return (NULL); 1248 } 1249 1250 /* 1251 *@@ doshExecFreeExportedFunctions: 1252 * frees resources allocated by doshExecQueryExportedFunctions. 1253 * 1254 *@@added V0.9.9 (2001-03-11) 1255 */ 1256 1257 APIRET doshExecFreeExportedFunctions(PFSYSFUNCTION paFunctions) 1258 { 1259 free(paFunctions); 1260 return (NO_ERROR); 1261 } 1262 1263 /* 1264 *@@ doshExecQueryResources: 1265 * returns an array of FSYSRESOURCE structures describing all 1266 * available resources in the module. 1267 * 1268 * *pcResources receives the no. of items in the array 1269 * (not the array size!). Use doshExecFreeResources to clean up. 1270 * 1271 *@@added V0.9.7 (2000-12-18) [lafaix] 1272 */ 1273 1274 PFSYSRESOURCE doshExecQueryResources(PEXECUTABLE pExec, PULONG pcResources) 1275 { 1276 ULONG cResources = 0; 1277 PFSYSRESOURCE paResources = NULL; 1278 int i; 1279 1280 if (pExec) 1281 { 1282 if (pExec->ulOS == EXEOS_OS2) 1283 { 1284 ULONG ulDummy; 1285 1286 if (pExec->ulExeFormat == EXEFORMAT_LX) 1287 { 1288 // It's a 32bit OS/2 executable 1289 cResources = pExec->pLXHeader->ulResTblCnt; 1290 1291 if (cResources) 1292 { 1293 struct rsrc32 /* Resource Table Entry */ 1294 { 1295 unsigned short type; /* Resource type */ 1296 unsigned short name; /* Resource name */ 1297 unsigned long cb; /* Resource size */ 1298 unsigned short obj; /* Object number */ 1299 unsigned long offset; /* Offset within object */ 1300 } rs; 1301 1302 struct o32_obj /* Flat .EXE object table entry */ 1303 { 1304 unsigned long o32_size; /* Object virtual size */ 1305 unsigned long o32_base; /* Object base virtual address */ 1306 unsigned long o32_flags; /* Attribute flags */ 1307 unsigned long o32_pagemap; /* Object page map index */ 1308 unsigned long o32_mapsize; /* Number of entries in object page map */ 1309 unsigned long o32_reserved; /* Reserved */ 1310 } ot; 1311 1312 paResources = (PFSYSRESOURCE)malloc(sizeof(FSYSRESOURCE) * cResources); 1313 1314 DosSetFilePtr(pExec->hfExe, 1315 pExec->pLXHeader->ulResTblOfs 1316 + pExec->pDosExeHeader->ulNewHeaderOfs, 1317 FILE_BEGIN, 1318 &ulDummy); 1319 1320 for (i = 0; i < cResources; i++) 1321 { 1322 DosRead(pExec->hfExe, &rs, 14, &ulDummy); 1323 paResources[i].ulID = rs.name; 1324 paResources[i].ulType = rs.type; 1325 paResources[i].ulSize = rs.cb; 1326 paResources[i].ulFlag = rs.obj; // Temp storage for Object 1327 // number. Will be filled 1328 // with resource flag 1329 // later. 1330 } 1331 1332 for (i = 0; i < cResources; i++) 1333 { 1334 DosSetFilePtr(pExec->hfExe, 1335 pExec->pLXHeader->ulObjTblOfs 1336 + pExec->pDosExeHeader->ulNewHeaderOfs 1337 + ( sizeof(ot) 1338 * (paResources[i].ulFlag - 1)), 1339 FILE_BEGIN, 1340 &ulDummy); 1341 DosRead(pExec->hfExe, &ot, sizeof(ot), &ulDummy); 1342 1343 paResources[i].ulFlag = (ot.o32_flags & OBJWRITE) ? 0 : RNPURE; 1344 paResources[i].ulFlag |= (ot.o32_flags & OBJDISCARD) ? 4096 : 0; 1345 paResources[i].ulFlag |= (ot.o32_flags & OBJSHARED) ? RNMOVE : 0; 1346 paResources[i].ulFlag |= (ot.o32_flags & OBJPRELOAD) ? RNPRELOAD : 0; 1347 } 1348 } 1349 } 1350 else 1351 if (pExec->ulExeFormat == EXEFORMAT_NE) 1352 { 1353 // It's a 16bit OS/2 executable 1354 cResources = pExec->pNEHeader->usResSegmCount; 1355 1356 if (cResources) 1357 { 1358 struct {unsigned short type; unsigned short name;} rti; 1359 struct new_seg /* New .EXE segment table entry */ 1360 { 1361 unsigned short ns_sector; /* File sector of start of segment */ 1362 unsigned short ns_cbseg; /* Number of bytes in file */ 1363 unsigned short ns_flags; /* Attribute flags */ 1364 unsigned short ns_minalloc; /* Minimum allocation in bytes */ 1365 } ns; 1366 1367 paResources = (PFSYSRESOURCE)malloc(sizeof(FSYSRESOURCE) * cResources); 1368 1369 // We first read the resources IDs and types 1370 DosSetFilePtr(pExec->hfExe, 1371 pExec->pNEHeader->usResTblOfs 1372 + pExec->pDosExeHeader->ulNewHeaderOfs, 1373 FILE_BEGIN, 1374 &ulDummy); 1375 1376 for (i = 0; i < cResources; i++) 1377 { 1378 DosRead(pExec->hfExe, &rti, sizeof(rti), &ulDummy); 1379 paResources[i].ulID = rti.name; 1380 paResources[i].ulType = rti.type; 1381 } 1382 1383 // And we then read their sizes and flags 1384 for (i = 0; i < cResources; i++) 1385 { 1386 DosSetFilePtr(pExec->hfExe, 1387 pExec->pDosExeHeader->ulNewHeaderOfs 1388 + pExec->pNEHeader->usSegTblOfs 1389 + (sizeof(ns) 1390 * ( pExec->pNEHeader->usSegTblEntries 1391 - pExec->pNEHeader->usResSegmCount 1392 + i)), 1393 FILE_BEGIN, 1394 &ulDummy); 1395 DosRead(pExec->hfExe, &ns, sizeof(ns), &ulDummy); 1396 1397 paResources[i].ulSize = ns.ns_cbseg; 1398 1399 paResources[i].ulFlag = (ns.ns_flags & OBJPRELOAD) ? RNPRELOAD : 0; 1400 paResources[i].ulFlag |= (ns.ns_flags & OBJSHARED) ? RNPURE : 0; 1401 paResources[i].ulFlag |= (ns.ns_flags & OBJDISCARD) ? RNMOVE : 0; 1402 paResources[i].ulFlag |= (ns.ns_flags & OBJDISCARD) ? 4096 : 0; 1403 } 1404 } 1405 } 1406 1407 *pcResources = cResources; 1408 } 1409 } 1410 1411 return (paResources); 1412 } 1413 1414 /* 1415 *@@ doshExecFreeResources: 1416 * frees resources allocated by doshExecQueryResources. 1417 * 1418 *@@added V0.9.7 (2000-12-18) [lafaix] 1419 */ 1420 1421 APIRET doshExecFreeResources(PFSYSRESOURCE paResources) 1422 { 1423 free(paResources); 1424 return (NO_ERROR); 1197 1425 } 1198 1426
Note:
See TracChangeset
for help on using the changeset viewer.