Changeset 4162 for branches/GRACE/src/win32k/dev32/d32init.c
- Timestamp:
- Sep 2, 2000, 10:49:29 PM (25 years ago)
- File:
-
- 1 edited
-
branches/GRACE/src/win32k/dev32/d32init.c (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/GRACE/src/win32k/dev32/d32init.c
r4117 r4162 1 /* $Id: d32init.c,v 1.19.4.1 2 2000-08-30 04:11:28bird Exp $1 /* $Id: d32init.c,v 1.19.4.13 2000-09-02 20:49:11 bird Exp $ 2 2 * 3 3 * d32init.c - 32-bits init routines. … … 32 32 #include <string.h> 33 33 34 #include "devSegDf.h" 34 35 #include "OS2Krnl.h" 35 36 #include "options.h" … … 166 167 break; 167 168 169 case 'j': 170 case 'J': /* -Java:<Yes|No> */ 171 pszTmp2 = strpbrk(pszTmp, ":=/- "); 172 options.fJava = 173 pszTmp2 != NULL 174 && (int)(pszTmp2-pszTmp) < cch-1 175 && (*pszTmp2 == ':' || *pszTmp2 == '=') 176 && (pszTmp2[1] == 'Y' || pszTmp2[1] == 'y'); 177 break; 178 168 179 case 'l': 169 180 case 'L': /* -L[..]<:|=| >[<Y..|E..| > | <N..|D..>] */ … … 209 220 210 221 case 'r': 211 case 'R': /* ResHeap options */222 case 'R': /* ResHeap options or REXX option */ 212 223 pszTmp2 = strpbrk(pszTmp, ":=/- "); 213 if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '=')) 214 { 215 ul = readnum(pszTmp2 + 1); 216 if (ul > 0x1000UL && ul < 0x700000UL) /* 4KB < ul < 7MB */ 224 if ( (pszTmp[1] == 'E' || pszTmp[1] == 'e') 225 && (pszTmp[2] == 'X' || pszTmp[2] == 'x')) 226 { /* REXX */ 227 options.fREXXScript = 228 pszTmp2 != NULL 229 && (int)(pszTmp2-pszTmp) < cch-1 230 && (*pszTmp2 == ':' || *pszTmp2 == '=') 231 && (pszTmp2[1] == 'Y' || pszTmp2[1] == 'y'); 232 } 233 else 234 { /* ResHeap options */ 235 if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '=')) 217 236 { 218 if (strnicmp(pszTmp, "resheapm", 8) == 0) 219 options.cbResHeapMax = ul; 220 else 221 options.cbResHeapInit = ul; 237 ul = readnum(pszTmp2 + 1); 238 if (ul > 0x1000UL && ul < 0x700000UL) /* 4KB < ul < 7MB */ 239 { 240 if (strnicmp(pszTmp, "resheapm", 8) == 0) 241 options.cbResHeapMax = ul; 242 else 243 options.cbResHeapInit = ul; 244 } 222 245 } 223 246 } … … 1049 1072 */ 1050 1073 kprintf2(("VerifyImportTab32: procedure no.%d is being checked: %s addr=0x%08x iObj=%d offObj=%d\n", 1051 i, & _aImportTab[i].achName[0], _aImportTab[i].ulAddress,1052 _aImportTab[i].iObject, _aImportTab[i].offObject));1074 i, &aImportTab[i].achName[0], aImportTab[i].ulAddress, 1075 aImportTab[i].iObject, aImportTab[i].offObject)); 1053 1076 1054 1077 /* Verify that it is found */ 1055 if (! _aImportTab[i].fFound)1056 { 1057 if ( _aImportTab[i].fType & EPT_NOT_REQ)1078 if (!aImportTab[i].fFound) 1079 { 1080 if (aImportTab[i].fType & EPT_NOT_REQ) 1058 1081 continue; 1059 1082 else … … 1065 1088 1066 1089 /* Verify read/writeable. */ 1067 if ( _aImportTab[i].iObject >= pKrnlSMTE->smte_objcnt /* object index valid? */1068 || _aImportTab[i].ulAddress < pKrnlOTE[_aImportTab[i].iObject].ote_base/* address valid? */1069 || _aImportTab[i].ulAddress + 16 > (pKrnlOTE[_aImportTab[i].iObject].ote_base +1070 pKrnlOTE[ _aImportTab[i].iObject].ote_size) /* address valid? */1071 || _aImportTab[i].ulAddress - _aImportTab[i].offObject1072 != pKrnlOTE[ _aImportTab[i].iObject].ote_base /* offObject ok? */1090 if (aImportTab[i].iObject >= pKrnlSMTE->smte_objcnt /* object index valid? */ 1091 || aImportTab[i].ulAddress < pKrnlOTE[aImportTab[i].iObject].ote_base /* address valid? */ 1092 || aImportTab[i].ulAddress + 16 > (pKrnlOTE[aImportTab[i].iObject].ote_base + 1093 pKrnlOTE[aImportTab[i].iObject].ote_size) /* address valid? */ 1094 || aImportTab[i].ulAddress - aImportTab[i].offObject 1095 != pKrnlOTE[aImportTab[i].iObject].ote_base /* offObject ok? */ 1073 1096 ) 1074 1097 { 1075 1098 kprintf(("VerifyImportTab32: procedure no.%d has an invalid address or object number.!\n" 1076 1099 " %s addr=0x%08x iObj=%d offObj=%d\n", 1077 i, & _aImportTab[i].achName[0], _aImportTab[i].ulAddress,1078 _aImportTab[i].iObject, _aImportTab[i].offObject));1100 i, &aImportTab[i].achName[0], aImportTab[i].ulAddress, 1101 aImportTab[i].iObject, aImportTab[i].offObject)); 1079 1102 return STATUS_DONE | STERR | ERROR_D32_INVALID_OBJ_OR_ADDR; 1080 1103 } … … 1082 1105 1083 1106 #ifndef R3TST 1084 if ( _aImportTab[i].ulAddress < 0xff400000UL)1107 if (aImportTab[i].ulAddress < 0xff400000UL) 1085 1108 { 1086 1109 kprintf(("VerifyImportTab32: procedure no.%d has an invalid address, %#08x!\n", 1087 i, _aImportTab[i].ulAddress));1110 i, aImportTab[i].ulAddress)); 1088 1111 return STATUS_DONE | STERR | ERROR_D32_INVALID_ADDRESS; 1089 1112 } 1090 1113 #endif 1091 1114 1092 switch ( _aImportTab[i].fType & ~(EPT_BIT_MASK | EPT_NOT_REQ))1115 switch (aImportTab[i].fType & ~(EPT_BIT_MASK | EPT_NOT_REQ)) 1093 1116 { 1094 1117 case EPT_PROC: … … 1097 1120 * Verify known function prolog. 1098 1121 */ 1099 if (EPT32BitEntry( _aImportTab[i]))1122 if (EPT32BitEntry(aImportTab[i])) 1100 1123 { 1101 cb = interpretFunctionProlog32((char*) _aImportTab[i].ulAddress,1102 _aImportTab[i].fType == EPT_PROC32);1124 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, 1125 aImportTab[i].fType == EPT_PROC32); 1103 1126 cbmin = 5; /* Size of the jump instruction */ 1104 1127 } 1105 1128 else 1106 1129 { 1107 cb = interpretFunctionProlog16((char*) _aImportTab[i].ulAddress,1108 _aImportTab[i].fType == EPT_PROC16);1130 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, 1131 aImportTab[i].fType == EPT_PROC16); 1109 1132 cbmin = 7; /* Size of the far jump instruction */ 1110 1133 } … … 1204 1227 { 1205 1228 /* EPT_VARIMPORTs are skipped */ 1206 if (( _aImportTab[i].fType & ~EPT_BIT_MASK) == EPT_VARIMPORT)1229 if ((aImportTab[i].fType & ~EPT_BIT_MASK) == EPT_VARIMPORT) 1207 1230 continue; 1208 1231 /* EPT_NOT_REQ which is not found are set pointing to the nop function provided. */ 1209 if (! _aImportTab[i].fFound && (_aImportTab[i].fType & EPT_NOT_REQ))1210 { 1211 _aImportTab[i].ulAddress = auFuncs[i];1232 if (!aImportTab[i].fFound && (aImportTab[i].fType & EPT_NOT_REQ)) 1233 { 1234 aImportTab[i].ulAddress = auFuncs[i]; 1212 1235 continue; 1213 1236 } 1214 1237 1215 if (EPT32BitEntry( _aImportTab[i]))1216 { 1217 cb = interpretFunctionProlog32((char*) _aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC32);1238 if (EPT32BitEntry(aImportTab[i])) 1239 { 1240 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, aImportTab[i].fType == EPT_PROC32); 1218 1241 cbmin = 5; /* Size of the jump instruction */ 1219 1242 } 1220 1243 else 1221 1244 { 1222 cb = interpretFunctionProlog16((char*) _aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC16);1245 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, aImportTab[i].fType == EPT_PROC16); 1223 1246 cbmin = 7; /* Size of the far jump instruction */ 1224 1247 } … … 1235 1258 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 1236 1259 { 1237 switch ( _aImportTab[i].fType & ~EPT_NOT_REQ)1260 switch (aImportTab[i].fType & ~EPT_NOT_REQ) 1238 1261 { 1239 1262 /* … … 1245 1268 case EPT_PROC32: 1246 1269 { 1247 cb = interpretFunctionProlog32((char*) _aImportTab[i].ulAddress, TRUE);1248 _aImportTab[i].cbProlog = (char)cb;1270 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, TRUE); 1271 aImportTab[i].cbProlog = (char)cb; 1249 1272 if (cb >= 5 && cb + 5 < MAXSIZE_PROLOG) /* 5(1st): size of jump instruction in the function prolog which jumps to my overloading function */ 1250 1273 { /* 5(2nd): size of jump instruction which jumps back to the original function after executing the prolog copied to the callTab entry for this function. */ … … 1252 1275 * Copy function prolog which will be overwritten by the jmp to calltabl. 1253 1276 */ 1254 memcpy(callTab[i], (void*) _aImportTab[i].ulAddress, (size_t)cb);1277 memcpy(callTab[i], (void*)aImportTab[i].ulAddress, (size_t)cb); 1255 1278 1256 1279 /* … … 1260 1283 */ 1261 1284 callTab[i][cb] = 0xE9; /* jmp */ 1262 *(unsigned long*)(void*)&callTab[i][cb+1] = _aImportTab[i].ulAddress + cb - (unsigned long)&callTab[i][cb+5];1285 *(unsigned long*)(void*)&callTab[i][cb+1] = aImportTab[i].ulAddress + cb - (unsigned long)&callTab[i][cb+5]; 1263 1286 1264 1287 /* 1265 1288 * Jump from original function to my function - an cli(?) could be needed here 1266 1289 */ 1267 *(char*) _aImportTab[i].ulAddress = 0xE9; /* jmp */1268 *(unsigned long*)( _aImportTab[i].ulAddress + 1) = auFuncs[i] - (_aImportTab[i].ulAddress + 5);1290 *(char*)aImportTab[i].ulAddress = 0xE9; /* jmp */ 1291 *(unsigned long*)(aImportTab[i].ulAddress + 1) = auFuncs[i] - (aImportTab[i].ulAddress + 5); 1269 1292 } 1270 1293 else … … 1287 1310 Int3(); 1288 1311 1289 cb = interpretFunctionProlog16((char*) _aImportTab[i].ulAddress, TRUE);1290 _aImportTab[i].cbProlog = (char)cb;1312 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, TRUE); 1313 aImportTab[i].cbProlog = (char)cb; 1291 1314 if (cb >= 8 && cb + 7 < MAXSIZE_PROLOG) /* 8: size of a 16:32 jump which jumps to my overloading function (prefixed with 66h in a 16-bit segment) */ 1292 1315 { /* 7: size of a 16:32 jump which is added to the call tab */ … … 1294 1317 * Copy function prolog which is to be overwritten. 1295 1318 */ 1296 memcpy(callTab[i], (void*) _aImportTab[i].ulAddress, (size_t)cb);1319 memcpy(callTab[i], (void*)aImportTab[i].ulAddress, (size_t)cb); 1297 1320 1298 1321 /* … … 1301 1324 */ 1302 1325 callTab[i][cb] = 0xEA; /* jmp far ptr */ 1303 *(unsigned long*)(void*)&callTab[i][cb+1] = _aImportTab[i].offObject;1304 *(unsigned short*)(void*)&callTab[i][cb+5] = _aImportTab[i].usSel;1326 *(unsigned long*)(void*)&callTab[i][cb+1] = aImportTab[i].offObject; 1327 *(unsigned short*)(void*)&callTab[i][cb+5] = aImportTab[i].usSel; 1305 1328 1306 1329 /* … … 1308 1331 * 0x66 0xEA <four byte target address> <two byte target selector> 1309 1332 */ 1310 *(char*)( _aImportTab[i].ulAddress ) = 0x66; /* operandsize prefix */1311 *(char*)( _aImportTab[i].ulAddress + 1) = 0xEA; /* jmp far ptr */1312 *(unsigned long*)( _aImportTab[i].ulAddress + 2) = auFuncs[i]; /* FIXME? */1313 *(unsigned short*)( _aImportTab[i].ulAddress + 6) = _R0FlatCS16; /* FIXME */1333 *(char*)(aImportTab[i].ulAddress ) = 0x66; /* operandsize prefix */ 1334 *(char*)(aImportTab[i].ulAddress + 1) = 0xEA; /* jmp far ptr */ 1335 *(unsigned long*)(aImportTab[i].ulAddress + 2) = auFuncs[i]; /* FIXME? */ 1336 *(unsigned short*)(aImportTab[i].ulAddress + 6) = _R0FlatCS16; /* FIXME */ 1314 1337 } 1315 1338 else … … 1329 1352 case EPT_PROCIMPORT32: 1330 1353 { 1331 cb = interpretFunctionProlog32((char*) _aImportTab[i].ulAddress, FALSE);1332 _aImportTab[i].cbProlog = (char)cb;1354 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, FALSE); 1355 aImportTab[i].cbProlog = (char)cb; 1333 1356 if (cb > 0) /* Since no prolog part is copied to the function table, it's ok as long as the prolog has been recognzied. */ 1334 1357 { … … 1339 1362 */ 1340 1363 callTab[i][0] = 0xE9; /* jmp */ 1341 *(unsigned*)(void*)&callTab[i][1] = _aImportTab[i].ulAddress - (unsigned)&callTab[i][5];1364 *(unsigned*)(void*)&callTab[i][1] = aImportTab[i].ulAddress - (unsigned)&callTab[i][5]; 1342 1365 } 1343 1366 else … … 1357 1380 case EPT_PROCIMPORT16: 1358 1381 { 1359 cb = interpretFunctionProlog16((char*) _aImportTab[i].ulAddress, FALSE);1360 _aImportTab[i].cbProlog = (char)cb;1382 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, FALSE); 1383 aImportTab[i].cbProlog = (char)cb; 1361 1384 if (cb > 0) /* Since no prolog part is copied to the function table, it's ok as long as the prolog has been recognzied. */ 1362 1385 { … … 1366 1389 */ 1367 1390 callTab[i][0] = 0xEA; /* jmp far ptr */ 1368 *(unsigned long*)(void*)&callTab[i][1] = _aImportTab[i].offObject;1369 *(unsigned short*)(void*)&callTab[i][5] = _aImportTab[i].usSel;1391 *(unsigned long*)(void*)&callTab[i][1] = aImportTab[i].offObject; 1392 *(unsigned short*)(void*)&callTab[i][5] = aImportTab[i].usSel; 1370 1393 } 1371 1394 else … … 1389 1412 case EPT_VARIMPORT32: 1390 1413 case EPT_VARIMPORT16: 1391 _aImportTab[i].cbProlog = (char)0;1392 *(unsigned long*)(void*)&callTab[i][0] = _aImportTab[i].ulAddress;1393 *(unsigned long*)(void*)&callTab[i][4] = _aImportTab[i].offObject;1394 *(unsigned short*)(void*)&callTab[i][8] = _aImportTab[i].usSel;1395 *(unsigned short*)(void*)&callTab[i][0xa] = (unsigned short) _aImportTab[i].offObject;1396 *(unsigned short*)(void*)&callTab[i][0xc] = _aImportTab[i].usSel;1414 aImportTab[i].cbProlog = (char)0; 1415 *(unsigned long*)(void*)&callTab[i][0] = aImportTab[i].ulAddress; 1416 *(unsigned long*)(void*)&callTab[i][4] = aImportTab[i].offObject; 1417 *(unsigned short*)(void*)&callTab[i][8] = aImportTab[i].usSel; 1418 *(unsigned short*)(void*)&callTab[i][0xa] = (unsigned short)aImportTab[i].offObject; 1419 *(unsigned short*)(void*)&callTab[i][0xc] = aImportTab[i].usSel; 1397 1420 break; 1398 1421 … … 1429 1452 /** 1430 1453 * -Ring-3 testing- 1431 * Changes the entries in _aImportTab to point to their fake equivalents.1454 * Changes the entries in aImportTab to point to their fake equivalents. 1432 1455 * @returns void 1433 1456 * @param void 1434 1457 * @status completely implemented. 1435 1458 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1436 * @remark Called before the _aImportTab array is used/verified.1459 * @remark Called before the aImportTab array is used/verified. 1437 1460 */ 1438 1461 VOID R3TstFixImportTab(VOID) … … 1492 1515 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 1493 1516 { 1494 switch ( _aImportTab[i].fType)1517 switch (aImportTab[i].fType) 1495 1518 { 1496 1519 case EPT_PROC32: … … 1513 1536 } /* switch - type */ 1514 1537 1515 _aImportTab[i].ulAddress = aTstFakers[i].uAddress;1538 aImportTab[i].ulAddress = aTstFakers[i].uAddress; 1516 1539 switch (aTstFakers[i].fObj) 1517 1540 { 1518 1541 case 1: 1519 _aImportTab[i].usSel = GetSelectorCODE32();1520 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE32START;1542 aImportTab[i].usSel = GetSelectorCODE32(); 1543 aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE32START; 1521 1544 break; 1522 1545 case 2: 1523 _aImportTab[i].usSel = GetSelectorCODE16();1524 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE16START;1546 aImportTab[i].usSel = GetSelectorCODE16(); 1547 aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE16START; 1525 1548 break; 1526 1549 case 3: 1527 _aImportTab[i].usSel = GetSelectorDATA32();1528 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA32START;1550 aImportTab[i].usSel = GetSelectorDATA32(); 1551 aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA32START; 1529 1552 break; 1530 1553 case 4: 1531 _aImportTab[i].usSel = GetSelectorDATA16();1532 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA16START;1554 aImportTab[i].usSel = GetSelectorDATA16(); 1555 aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA16START; 1533 1556 break; 1534 1557 default:
Note:
See TracChangeset
for help on using the changeset viewer.
