Changeset 4347 for trunk/src/win32k/dev32/d32init.c
- Timestamp:
- Oct 1, 2000, 4:58:21 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/dev32/d32init.c
r4307 r4347 1 /* $Id: d32init.c,v 1.2 4 2000-09-22 09:22:35 bird Exp $1 /* $Id: d32init.c,v 1.25 2000-10-01 02:58:15 bird Exp $ 2 2 * 3 3 * d32init.c - 32-bits init routines. … … 12 12 * Defined Constants * 13 13 *******************************************************************************/ 14 #define MAXSIZE_PROLOG 0x18 /* Note that this must be synced with */ 15 /* the one used in calltab.asm. */ 16 #if 0 /* Enable this to have extra debug logging. */ 14 /* 15 * Calltab entry sizes. 16 */ 17 #define OVERLOAD16_ENTRY 0x18 18 #define OVERLOAD32_ENTRY 0x14 19 #define IMPORT16_ENTRY 0x08 20 #define IMPORT32_ENTRY 0x08 21 #define VARIMPORT_ENTRY 0x10 22 23 #if 0 17 24 #define kprintf2(a) kprintf 18 25 #else 19 #define kprintf2(a) (void)026 #define kprintf2(a) {}// 20 27 #endif 21 28 … … 87 94 88 95 /* extern(s) located in calltab.asm */ 89 extern char callTab[NBR_OF_KRNLIMPORTS][MAXSIZE_PROLOG]; 90 91 /* extern(s) located in mytkExecPgm.asm */ 92 extern char mytkExecPgm; 93 extern char mytkStartProcess; 96 extern char callTab[1]; 97 extern unsigned auFuncs[NBR_OF_KRNLIMPORTS]; 94 98 95 99 … … 1059 1063 int i; 1060 1064 int cb; 1061 int cbm in;1065 int cbmax; 1062 1066 1063 1067 /* VerifyImporTab32 is called before the initroutine! */ … … 1084 1088 if (!aImportTab[i].fFound) 1085 1089 { 1086 if ( aImportTab[i].fType & EPT_NOT_REQ)1090 if (EPTNotReq(aImportTab[i])) 1087 1091 continue; 1088 1092 else … … 1119 1123 #endif 1120 1124 1121 switch (aImportTab[i].fType & ~(EPT_BIT_MASK | EPT_NOT_REQ ))1125 switch (aImportTab[i].fType & ~(EPT_BIT_MASK | EPT_NOT_REQ | EPT_WRAPPED)) 1122 1126 { 1123 1127 case EPT_PROC: … … 1128 1132 if (EPT32BitEntry(aImportTab[i])) 1129 1133 { 1130 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, 1131 aImportTab[i].fType == EPT_PROC32); 1132 cbmin = 5; /* Size of the jump instruction */ 1134 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, EPT32Proc(aImportTab[i])); 1135 cbmax = OVERLOAD32_ENTRY - 5; /* 5 = Size of the jump instruction */ 1133 1136 } 1134 1137 else 1135 1138 { 1136 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, 1137 aImportTab[i].fType == EPT_PROC16); 1138 cbmin = 7; /* Size of the far jump instruction */ 1139 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, EPT16Proc(aImportTab[i])); 1140 cbmax = OVERLOAD16_ENTRY - 7; /* 7 = Size of the far jump instruction */ 1139 1141 } 1140 1142 … … 1142 1144 * Check result of the function prolog interpretations. 1143 1145 */ 1144 if (cb <= 0 || cb + cbmin >= MAXSIZE_PROLOG)1146 if (cb <= 0 || cb > cbmax) 1145 1147 { /* failed, too small or too large. */ 1146 kprintf(("VerifyImportTab32: verify failed for procedure no.%d (cb=%d) \n", i, cb));1148 kprintf(("VerifyImportTab32: verify failed for procedure no.%d (cb=%d), %s\n", i, cb, aImportTab[i].achName)); 1147 1149 return (USHORT)(ERROR_D32_TOO_INVALID_PROLOG | (i << ERROR_D32_PROC_SHIFT) | ERROR_D32_PROC_FLAG); 1148 1150 } … … 1154 1156 1155 1157 default: 1156 kprintf(("VerifyImportTab32: invalid type/type not implemented \n",i));1158 kprintf(("VerifyImportTab32: invalid type/type not implemented. Proc no.%d, %s\n",i, aImportTab[i].achName)); 1157 1159 Int3(); /* temporary fix! */ 1158 1160 return (USHORT)(ERROR_D32_NOT_IMPLEMENTED | (i << ERROR_D32_PROC_SHIFT) | ERROR_D32_PROC_FLAG); … … 1171 1173 int importTabInit(void) 1172 1174 { 1173 /* This table must be updated with the overloading functions. 1174 * It should also hold NOP functions for functions which are of the 1175 * not required type. 1175 int i; 1176 int cb; 1177 int cbmax; 1178 char * pchCTEntry; /* Pointer to current calltab entry. */ 1179 1180 /* 1181 * Apply build specific changes to the auFuncs table 1176 1182 */ 1177 static unsigned auFuncs[NBR_OF_KRNLIMPORTS] = 1178 { 1179 (unsigned)myldrRead, /* 0 */ 1180 (unsigned)myldrOpen, /* 1 */ 1181 (unsigned)myldrClose, /* 2 */ 1182 (unsigned)myLDRQAppType, /* 3 */ 1183 (unsigned)myldrEnum32bitRelRecs,/* 4 */ 1184 0, /* 5 */ 1185 0, /* 6 */ 1186 0, /* 7 */ 1187 0, /* 8 */ 1188 0, /* 9 */ 1189 0, /* 10 */ 1190 0, /* 11 */ 1191 0, /* 12 */ 1192 (unsigned)&mytkExecPgm, /* 13 */ 1193 (unsigned)&mytkStartProcess, /* 14 */ 1194 0, /* 15 */ 1195 0, /* 16 */ 1196 0, /* 17 */ 1197 0, /* 18 */ 1198 0, /* 19 */ 1199 (unsigned)myldrOpenPath_old, /* 20 */ 1200 0, /* 21 */ 1201 0, /* 22 */ 1202 0, /* 23 */ 1203 0, /* 24 */ 1204 0, /* 25 */ 1205 0, /* 26 */ 1206 0, /* 27 */ 1207 0, /* 28 */ 1208 0, /* 29 */ 1209 0, /* 30 */ 1210 0, /* 31 */ 1211 0, /* 32 */ 1212 0, /* 33 */ 1213 0, /* 34 */ 1214 0, /* 35 */ 1215 0, /* 36 */ 1216 0, /* 37 */ 1217 0, /* 38 */ 1218 0, /* 39 */ 1219 0, /* 40 */ 1220 (unsigned)nopSecPathFromSFN /* 41 */ 1221 #if 0 /* experimenting */ 1222 ,(unsigned)myldrSetVMflags, /* 42 */ 1223 #endif 1224 }; 1225 int i; 1226 int cb; 1227 int cbmin; 1228 1229 #ifndef R3TST //New function not currently not implemented by fake.c 1230 /* 1231 * Build specific changes to the auFuncs table 1232 */ 1233 if (options.ulBuild >= 14053) 1183 if (options.ulBuild < 14053) 1234 1184 { 1235 1185 #ifdef DEBUG 1236 if (auFuncs[ 20] != (unsigned)myldrOpenPath_old)1186 if (auFuncs[0] != (unsigned)myldrOpenPath) 1237 1187 { 1238 1188 kprintf(("importTabInit: ASSERTION FAILED auFuncs don't point at myldrOpenPath\n")); … … 1240 1190 } 1241 1191 #endif 1242 auFuncs[ 20] = (unsigned)myldrOpenPath;1192 auFuncs[0] = (unsigned)myldrOpenPath_old; 1243 1193 } 1244 #endif1245 1194 1246 1195 #ifdef R3TST … … 1254 1203 { 1255 1204 /* EPT_VARIMPORTs are skipped */ 1256 if ((aImportTab[i].fType & ~ EPT_BIT_MASK) == EPT_VARIMPORT)1205 if ((aImportTab[i].fType & ~(EPT_BIT_MASK | EPT_NOT_REQ)) == EPT_VARIMPORT) 1257 1206 continue; 1258 1207 /* EPT_NOT_REQ which is not found are set pointing to the nop function provided. */ 1259 if (!aImportTab[i].fFound && (aImportTab[i].fType & EPT_NOT_REQ)) 1260 { 1261 aImportTab[i].ulAddress = auFuncs[i]; 1208 if (!aImportTab[i].fFound && EPTNotReq(aImportTab[i])) 1262 1209 continue; 1263 }1264 1210 1265 1211 if (EPT32BitEntry(aImportTab[i])) 1266 1212 { 1267 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, aImportTab[i].fType == EPT_PROC32); 1268 cbmin = 5; /* Size of the jump instruction */ 1213 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, EPT32Proc(aImportTab[i])); 1214 1215 cbmax = OVERLOAD16_ENTRY - 5; /* 5 = Size of the jump instruction */ 1269 1216 } 1270 1217 else 1271 1218 { 1272 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, aImportTab[i].fType == EPT_PROC16);1273 cbm in = 7; /*Size of the far jump instruction */1219 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, EPT16Proc(aImportTab[i])); 1220 cbmax = OVERLOAD16_ENTRY - 7; /* 7 = Size of the far jump instruction */ 1274 1221 } 1275 if (cb <= 0 || cb + cbmin >= MAXSIZE_PROLOG)1222 if (cb <= 0 || cb > cbmax) 1276 1223 { 1277 1224 kprintf(("ImportTabInit: Verify failed for procedure no.%d, cb=%d\n", i, cb)); … … 1283 1230 * rehook / import 1284 1231 */ 1232 pchCTEntry = &callTab[0]; 1285 1233 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 1286 1234 { 1287 switch (aImportTab[i].fType & ~EPT_ NOT_REQ)1235 switch (aImportTab[i].fType & ~EPT_WRAPPED) 1288 1236 { 1289 1237 /* … … 1297 1245 cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, TRUE); 1298 1246 aImportTab[i].cbProlog = (char)cb; 1299 if (cb >= 5 && cb + 5 < MAXSIZE_PROLOG) /* 5(1st): size of jump instruction in the function prolog which jumps to my overloading function */1300 { /* 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. */1247 if (cb >= 5 && cb + 5 < OVERLOAD32_ENTRY) /* 5(1st): size of jump instruction in the function prolog which jumps to my overloading function */ 1248 { /* 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. */ 1301 1249 /* 1302 1250 * Copy function prolog which will be overwritten by the jmp to calltabl. 1303 1251 */ 1304 memcpy( callTab[i], (void*)aImportTab[i].ulAddress, (size_t)cb);1252 memcpy(pchCTEntry, (void*)aImportTab[i].ulAddress, (size_t)cb); 1305 1253 1306 1254 /* … … 1309 1257 * Note: the displacement is relative to the next instruction 1310 1258 */ 1311 callTab[i][cb] = 0xE9; /* jmp */1312 *(unsigned long*)(void*)& callTab[i][cb+1] = aImportTab[i].ulAddress + cb - (unsigned long)&callTab[i][cb+5];1259 pchCTEntry[cb] = 0xE9; /* jmp */ 1260 *(unsigned long*)(void*)&pchCTEntry[cb+1] = aImportTab[i].ulAddress + cb - (unsigned long)&pchCTEntry[cb+5]; 1313 1261 1314 1262 /* … … 1324 1272 return ERROR_D32_IPE | (i << ERROR_D32_PROC_SHIFT) | ERROR_D32_PROC_FLAG; 1325 1273 } 1274 pchCTEntry += OVERLOAD32_ENTRY; 1326 1275 break; 1327 1276 } … … 1339 1288 cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, TRUE); 1340 1289 aImportTab[i].cbProlog = (char)cb; 1341 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) */1342 { /* 7: size of a 16:32 jump which is added to the call tab */1290 if (cb >= 8 && cb + 7 < OVERLOAD16_ENTRY) /* 8: size of a 16:32 jump which jumps to my overloading function (prefixed with 66h in a 16-bit segment) */ 1291 { /* 7: size of a 16:32 jump which is added to the call tab */ 1343 1292 /* 1344 1293 * Copy function prolog which is to be overwritten. 1345 1294 */ 1346 memcpy( callTab[i], (void*)aImportTab[i].ulAddress, (size_t)cb);1295 memcpy(pchCTEntry, (void*)aImportTab[i].ulAddress, (size_t)cb); 1347 1296 1348 1297 /* … … 1350 1299 * 0xEA <four byte target address> <two byte target selector> 1351 1300 */ 1352 callTab[i][cb] = 0xEA; /* jmp far ptr */1353 *(unsigned long*)(void*)& callTab[i][cb+1] = aImportTab[i].offObject;1354 *(unsigned short*)(void*)& callTab[i][cb+5] = aImportTab[i].usSel;1301 pchCTEntry[cb] = 0xEA; /* jmp far ptr */ 1302 *(unsigned long*)(void*)&pchCTEntry[cb+1] = aImportTab[i].offObject; 1303 *(unsigned short*)(void*)&pchCTEntry[cb+5] = aImportTab[i].usSel; 1355 1304 1356 1305 /* … … 1369 1318 return ERROR_D32_IPE | (i << ERROR_D32_PROC_SHIFT) | ERROR_D32_PROC_FLAG; 1370 1319 } 1320 pchCTEntry += OVERLOAD16_ENTRY; 1371 1321 break; 1372 1322 } … … 1374 1324 1375 1325 /* 1376 * 32-bit imported procedure 1326 * 32-bit imported procedure. 1377 1327 * This is called by issuing a near call to the callTab entry. 1378 1328 */ 1329 case EPT_PROCIMPORTNR32: /* Not required */ 1330 if (!(pchCTEntry[6] = aImportTab[i].fFound)) 1331 aImportTab[i].ulAddress = auFuncs[i]; 1379 1332 case EPT_PROCIMPORT32: 1380 1333 { … … 1388 1341 * Note: the displacement is relative to the next instruction 1389 1342 */ 1390 callTab[i][0] = 0xE9; /* jmp */1391 *(unsigned*)(void*)& callTab[i][1] = aImportTab[i].ulAddress - (unsigned)&callTab[i][5];1343 pchCTEntry[0] = 0xE9; /* jmp */ 1344 *(unsigned*)(void*)&pchCTEntry[1] = aImportTab[i].ulAddress - (unsigned)&pchCTEntry[5]; 1392 1345 } 1393 1346 else … … 1397 1350 return ERROR_D32_IPE | (i << ERROR_D32_PROC_SHIFT) | ERROR_D32_PROC_FLAG; 1398 1351 } 1352 pchCTEntry += IMPORT32_ENTRY; 1399 1353 break; 1400 1354 } … … 1405 1359 * This is called by issuing a far call to the calltab entry. 1406 1360 */ 1361 case EPT_PROCIMPORTNR16: /* Not required */ 1362 if (!(pchCTEntry[7] = aImportTab[i].fFound)) 1363 { 1364 aImportTab[i].ulAddress = auFuncs[i]; 1365 Int3(); 1366 break; 1367 } 1407 1368 case EPT_PROCIMPORT16: 1408 1369 { … … 1415 1376 * 0xEA <four byte target address> <two byte target selector> 1416 1377 */ 1417 callTab[i][0] = 0xEA; /* jmp far ptr */1418 *(unsigned long*)(void*)& callTab[i][1] = aImportTab[i].offObject;1419 *(unsigned short*)(void*)& callTab[i][5] = aImportTab[i].usSel;1378 pchCTEntry[0] = 0xEA; /* jmp far ptr */ 1379 *(unsigned long*)(void*)&pchCTEntry[1] = aImportTab[i].offObject; 1380 *(unsigned short*)(void*)&pchCTEntry[5] = aImportTab[i].usSel; 1420 1381 } 1421 1382 else … … 1425 1386 return ERROR_D32_IPE | (i << ERROR_D32_PROC_SHIFT) | ERROR_D32_PROC_FLAG; 1426 1387 } 1388 pchCTEntry += IMPORT16_ENTRY; 1427 1389 break; 1428 1390 } … … 1440 1402 case EPT_VARIMPORT16: 1441 1403 aImportTab[i].cbProlog = (char)0; 1442 *(unsigned long*)(void*)&callTab[i][0] = aImportTab[i].ulAddress; 1443 *(unsigned long*)(void*)&callTab[i][4] = aImportTab[i].offObject; 1444 *(unsigned short*)(void*)&callTab[i][8] = aImportTab[i].usSel; 1445 *(unsigned short*)(void*)&callTab[i][0xa] = (unsigned short)aImportTab[i].offObject; 1446 *(unsigned short*)(void*)&callTab[i][0xc] = aImportTab[i].usSel; 1404 *(unsigned long*)(void*)&pchCTEntry[0] = aImportTab[i].ulAddress; 1405 *(unsigned long*)(void*)&pchCTEntry[4] = aImportTab[i].offObject; 1406 *(unsigned short*)(void*)&pchCTEntry[8] = aImportTab[i].usSel; 1407 *(unsigned short*)(void*)&pchCTEntry[0xa] = (unsigned short)aImportTab[i].offObject; 1408 *(unsigned short*)(void*)&pchCTEntry[0xc] = aImportTab[i].usSel; 1409 pchCTEntry += VARIMPORT_ENTRY; 1447 1410 break; 1448 1411 … … 1488 1451 VOID R3TstFixImportTab(VOID) 1489 1452 { 1490 struct _TstFaker1491 {1492 unsigned uAddress;1493 int fObj; /* 1 = CODE32, 2 = CODE16, 3 = DATA32, 4 = DATA16 */1494 }1495 aTstFakers[NBR_OF_KRNLIMPORTS] =1496 {1497 {(unsigned)fakeldrRead, 1},1498 {(unsigned)fakeldrOpen, 1},1499 {(unsigned)fakeldrClose, 1},1500 {(unsigned)fakeLDRQAppType, 1},1501 {(unsigned)fakeldrEnum32bitRelRecs, 1},1502 {(unsigned)fakeIOSftOpen, 1},1503 {(unsigned)fakeIOSftClose, 1},1504 {(unsigned)fakeIOSftTransPath, 1},1505 {(unsigned)fakeIOSftReadAt, 1},1506 {(unsigned)fakeIOSftWriteAt, 1},1507 {(unsigned)fakeSftFileSize, 1},1508 {(unsigned)fakeVMAllocMem, 1},1509 {(unsigned)fakeVMGetOwner, 1},1510 {(unsigned)fakeg_tkExecPgm, 1},1511 {(unsigned)fake_tkStartProcess, 1},1512 {(unsigned)fakef_FuStrLenZ, 2},1513 {(unsigned)fakef_FuStrLen, 2},1514 {(unsigned)fakef_FuBuff, 2},1515 {(unsigned)fakeVMObjHandleInfo, 1},1516 {(unsigned)fakeldrASMpMTEFromHandle,1},1517 {(unsigned)fakeldrOpenPath, 1},1518 {(unsigned)fakeLDRClearSem, 1},1519 {(unsigned)fakeldrFindModule, 1},1520 {(unsigned)fakeKSEMRequestMutex, 1},1521 {(unsigned)fakeKSEMReleaseMutex, 1},1522 {(unsigned)fakeKSEMQueryMutex, 1},1523 {(unsigned)fakeKSEMInit, 1},1524 {(unsigned)&fakeLDRSem, 3},1525 {(unsigned)&fakeLDRLibPath, 3},1526 {(unsigned)fakeTKSuBuff, 1},1527 {(unsigned)fakeTKFuBuff, 1},1528 {(unsigned)fakeTKFuBufLen, 1},1529 {(unsigned)fakeldrValidateMteHandle,1},1530 {(unsigned)&fakepTCBCur, 4},1531 {(unsigned)&fakepPTDACur, 4},1532 {(unsigned)&fakeptda_start, 4},1533 {(unsigned)&fakeptda_environ, 4},1534 {(unsigned)&fakeptda_ptdasem, 4},1535 {(unsigned)&fakeptda_module, 4},1536 {(unsigned)&fakeptda_pBeginLIBPATH, 4},1537 {(unsigned)&fakeldrpFileNameBuf, 3},1538 {(unsigned)&fakeSecPathFromSFN, 3}1539 #if 0 /* experimenting */1540 ,{(unsigned)&fakeldrSetVMflags, 1}1541 #endif1542 };1543 1453 int i; 1544 1454 1545 1455 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 1546 1456 { 1547 switch (aImportTab[i].fType )1457 switch (aImportTab[i].fType & ~EPT_NOT_REQ) 1548 1458 { 1549 1459 case EPT_PROC32:
Note:
See TracChangeset
for help on using the changeset viewer.