Changeset 3834 for branches/GRACE/src/win32k/dev32/d32init.c
- Timestamp:
- Jul 17, 2000, 12:43:41 AM (25 years ago)
- File:
-
- 1 edited
-
branches/GRACE/src/win32k/dev32/d32init.c (modified) (47 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/GRACE/src/win32k/dev32/d32init.c
r3485 r3834 1 /* $Id: d32init.c,v 1.19 2000-05-03 10:46:06bird Exp $1 /* $Id: d32init.c,v 1.19.4.1 2000-07-16 22:42:03 bird Exp $ 2 2 * 3 3 * d32init.c - 32-bits init routines. … … 14 14 #define MAXSIZE_PROLOG 0x18 /* Note that this must be synced with */ 15 15 /* the one used in calltab.asm. */ 16 #define static /* just to make all symbols visible in the kernel debugger. */17 16 #if 0 /* Enable this to have extra debug logging. */ 18 17 #define kprintf2(a) kprintf … … 24 23 #define INCL_NOPMAPI 25 24 #define LDR_INCL_INITONLY 25 #define INCL_OS2KRNL_ALL 26 26 27 27 /******************************************************************************* … … 45 45 #include "macros.h" 46 46 47 #ifdef R3TST 48 #include "test.h" 49 #endif 50 47 51 48 52 /******************************************************************************* … … 53 57 static char * apszInfoLevel[] = {"INFOLEVEL_QUIET", "INFOLEVEL_ERROR", "INFOLEVEL_WARNING", "INFOLEVEL_INFO", "INFOLEVEL_INFOALL", "!invalid!"}; 54 58 #endif 55 staticPMTE pKrnlMTE = NULL;56 staticPSMTE pKrnlSMTE = NULL;57 staticPOTE pKrnlOTE = NULL;59 PMTE pKrnlMTE = NULL; 60 PSMTE pKrnlSMTE = NULL; 61 POTE pKrnlOTE = NULL; 58 62 59 63 … … 61 65 * Internal Functions * 62 66 *******************************************************************************/ 63 static ULONG readnum(const char *pszNum); 64 _Inline int ModR_M_32bit(char bModRM); 65 static int interpretFunctionProlog32(char *pach, BOOL fOverload); 66 static int interpretFunctionProlog16(char *pach, BOOL fOverload); 67 static int ImportTabInit(void); 67 ULONG readnum(const char *pszNum); 68 _Inline int ModR_M_32bit(char bModRM); 69 _Inline int ModR_M_16bit(char bModRM); 70 int interpretFunctionProlog32(char *pach, BOOL fOverload); 71 int interpretFunctionProlog16(char *pach, BOOL fOverload); 72 int importTabInit(void); 73 #ifdef R3TST 74 PMTE GetOS2KrnlMTETst(void); 75 void R3TstFixImportTab(void); 76 #endif 77 68 78 69 79 … … 118 128 { 119 129 case 'c': 120 case 'C': /* -C[1|2] - com-port no, def:-C2 */ 121 switch (pszTmp[1]) 122 { 123 case '1': 124 options.usCom = OUTPUT_COM1; 125 break; 126 127 case '2': 128 default: 129 options.usCom = OUTPUT_COM2; 130 } 130 case 'C': /* -C[1|2] or -Com:[1|2] - com-port no, def:-C2 */ 131 pszTmp2 = strpbrk(pszTmp, ":=/- "); 132 if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '=')) 133 pszTmp2++; 134 else 135 pszTmp2 = pszTmp + 1; 136 options.usCom = (USHORT)(*pszTmp2 == '1' ? OUTPUT_COM1 : OUTPUT_COM2); 131 137 break; 132 138 … … 134 140 case 'E':/* ELF */ 135 141 pszTmp2 = strpbrk(pszTmp, ":=/- "); 136 if (pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1142 if (pszTmp2 != NULL 137 143 && (pszTmp2[1] == 'N' ||pszTmp2[1] == 'n' || pszTmp2[1] == 'D' || pszTmp2[1] == 'd') 138 144 ) … … 145 151 case 'H': /* Heap options */ 146 152 pszTmp2 = strpbrk(pszTmp, ":=/- "); 147 if (pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1 148 && (*pszTmp2 == ':' || *pszTmp2 == '=')) 153 if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '=')) 149 154 { 150 155 ul = readnum(pszTmp2 + 1); … … 162 167 case 'L': /* -L[..]<:|=| >[<Y..|E..| > | <N..|D..>] */ 163 168 pszTmp2 = strpbrk(pszTmp, ":=/- "); 164 if (pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1165 && (pszTmp2[1] == ' N' ||pszTmp2[1] == 'n' || pszTmp2[1] == 'D' || pszTmp2[1] == 'd')169 if (pszTmp2 != NULL 170 && (pszTmp2[1] == 'Y' ||pszTmp2[1] == 'y' || pszTmp2[1] == 'E' || pszTmp2[1] == 'e') 166 171 ) 172 options.fLogging = TRUE; 173 else 167 174 options.fLogging = FALSE; 168 else169 options.fLogging = TRUE;170 175 break; 171 176 … … 178 183 case 'P': /* PE */ 179 184 pszTmp2 = strpbrk(pszTmp, ":=/- "); 180 if (pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1 181 && (*pszTmp2 == ':' || *pszTmp2 == '=')) 185 if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '=')) 182 186 { 183 pszTmp ++;184 if (strnicmp(pszTmp , "pe2lx", 5) == 0)187 pszTmp2++; 188 if (strnicmp(pszTmp2, "pe2lx", 5) == 0) 185 189 options.fPE = FLAGS_PE_PE2LX; 186 else if (strnicmp(pszTmp , "pe", 2) == 0)190 else if (strnicmp(pszTmp2, "pe", 2) == 0) 187 191 options.fPE = FLAGS_PE_PE; 188 else if (strnicmp(pszTmp , "mixed", 2) == 0)192 else if (strnicmp(pszTmp2, "mixed", 2) == 0) 189 193 options.fPE = FLAGS_PE_MIXED; 190 else if (strnicmp(pszTmp , "not", 2) == 0)194 else if (strnicmp(pszTmp2, "not", 2) == 0) 191 195 options.fPE = FLAGS_PE_NOT; 192 196 else … … 205 209 case 'R': /* ResHeap options */ 206 210 pszTmp2 = strpbrk(pszTmp, ":=/- "); 207 if (pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1 208 && (*pszTmp2 == ':' || *pszTmp2 == '=')) 211 if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '=')) 209 212 { 210 213 ul = readnum(pszTmp2 + 1); … … 222 225 case 'S': /* Sym:<filename> or Script:<Yes|No> or Smp */ 223 226 /* SMP kernel */ 224 if (pszTmp[1] == 'm' || pszTmp[1] == 'M') 225 options.fKernel = KF_SMP; 226 else 227 pszTmp2 = strpbrk(pszTmp, ":=/- "); 228 if (pszTmp[1] == 'c' || pszTmp[1] == 'C') 227 229 { 228 if (pszTmp[1] == 'c' || pszTmp[1] == 'C') 229 { 230 pszTmp2 = strpbrk(pszTmp, ":=/- "); 231 options.fScript = pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1 232 && (*pszTmp2 == ':' || *pszTmp2 == '=') 233 && (pszTmp2[1] == 'Y' || pszTmp2[1] == 'y'); 234 } 230 options.fUNIXScript = 231 pszTmp2 != NULL 232 && (int)(pszTmp2-pszTmp) < cch-1 233 && (*pszTmp2 == ':' || *pszTmp2 == '=') 234 && (pszTmp2[1] == 'Y' || pszTmp2[1] == 'y'); 235 235 } 236 break;237 238 case 'u':239 case 'U': /* UNI kernel */240 options.fKernel = KF_UNI;241 236 break; 242 237 … … 247 242 248 243 case 'w': 249 case 'W': 244 case 'W': /* ModuleBase info level; -W<n> or -Warning:<n> */ 250 245 if (pszTmp[1] >= '0' && pszTmp[1] <= '4') 251 246 options.ulInfoLevel = pszTmp[1] - '0'; … … 253 248 { 254 249 pszTmp2 = strpbrk(pszTmp, ":=/- "); 255 if (pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1 256 && (*pszTmp2 == ':' || *pszTmp2 == '=') 257 && pszTmp2[1] >= '0' && pszTmp2[1] <= '4' 258 ) 259 options.ulInfoLevel = pszTmp2[1] - '0'; 250 if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '=')) 251 pszTmp2++; 252 else 253 pszTmp2 = pszTmp + 1; 254 255 if (*pszTmp2 >= '0' && *pszTmp2 <= '4') 256 options.ulInfoLevel = *pszTmp2 - '0'; 260 257 } 261 258 break; … … 270 267 if (options.cbResHeapInit > options.cbResHeapMax) 271 268 options.cbResHeapMax = options.cbResHeapInit; 272 273 /* Transfer version and build number from 16-bit probkrnl.c */274 options.ulBuild = _usBuild;275 options.usVerMajor = _usVerMajor;276 options.usVerMinor = _usVerMinor;277 269 278 270 /* Log option summary */ … … 288 280 else 289 281 kprintf(("\tlogging disabled\n")); 290 kprintf(("\tCom port no.% d\n", options.usCom));291 292 kprintf(("\tKernel: v er%d.%d build %d type %s\n",282 kprintf(("\tCom port no.%03xh\n", options.usCom)); 283 284 kprintf(("\tKernel: v%d.%d build %d type ", 293 285 options.usVerMajor, 294 286 options.usVerMinor, 295 options.ulBuild, 296 (options.fKernel & KF_SMP) ? "SMP" : "UNI" 297 )); 298 kprintf(("\tfPE=%d (%s)\n", options.fPE, apszPE[MIN(options.fPE, 5)])); 287 options.ulBuild)); 288 if (options.fKernel & KF_SMP) 289 kprintf(("SMP ")); 290 else if (options.fKernel & KF_W4) 291 kprintf(("W4 ")); 292 else 293 kprintf(("UNI ")); 294 if (options.fKernel & KF_DEBUG) 295 kprintf(("DEBUG\n")); 296 else 297 kprintf(("\n")); 298 299 kprintf(("\tfPE=%d (%s)\n", options.fPE, apszPE[MIN(options.fPE, 5)])); 299 300 kprintf(("\tulInfoLevel=%d (%s)\n", options.ulInfoLevel, apszInfoLevel[MIN(options.ulInfoLevel, 5)])); 300 kprintf(("\tfElf=%d\n", options.fElf)); 301 kprintf(("\tfScript=%d\n", options.fScript)); 302 kprintf(("\tfNoLoader=%d\n", options.fNoLoader)); 301 kprintf(("\tfElf=%d\n", options.fElf)); 302 kprintf(("\tfUNIXScript=%d\n", options.fUNIXScript)); 303 kprintf(("\tfREXXScript=%d\n", options.fREXXScript)); 304 kprintf(("\tfJAVA=%d\n", options.fJava)); 305 kprintf(("\tfNoLoader=%d\n", options.fNoLoader)); 303 306 kprintf(("\tcbSwpHeapInit=0x%08x cbSwpHeapMax=0x%08x\n", 304 307 options.cbSwpHeapInit, options.cbSwpHeapMax)); 305 308 kprintf(("\tcbResHeapInit=0x%08x cbResHeapMax=0x%08x\n", 306 options.cb SwpHeapInit, options.cbSwpHeapMax));309 options.cbResHeapInit, options.cbResHeapMax)); 307 310 kprintf(("Options - Summary - End\n")); 308 311 #endif /* debug */ … … 325 328 /* functionoverrides */ 326 329 if (!options.fNoLoader) 327 if ( ImportTabInit() != NO_ERROR)330 if (importTabInit() != NO_ERROR) 328 331 return STATUS_DONE | STERR | ERROR_I24_QUIET_INIT_FAIL; 329 332 … … 369 372 * @author knut st. osmundsen 370 373 */ 371 staticULONG readnum(const char *pszNum)374 ULONG readnum(const char *pszNum) 372 375 { 373 376 ULONG ulRet = 0; … … 428 431 429 432 /* Find the kernel OTE table */ 433 #ifndef R3TST 430 434 pKrnlMTE = GetOS2KrnlMTE(); 435 #else 436 pKrnlMTE = GetOS2KrnlMTETst(); 437 #endif 431 438 if (pKrnlMTE != NULL) 432 439 { … … 461 468 * Search for internal revision stuff in the two first objects. 462 469 */ 463 pKrnlInfo->u sBuild = 0;464 for (i = 0; i < 2 && pKrnlInfo->u sBuild == 0; i++)470 pKrnlInfo->ulBuild = 0; 471 for (i = 0; i < 2 && pKrnlInfo->ulBuild == 0; i++) 465 472 { 473 #ifndef R3TST 466 474 const char *psz = (const char*)pKrnlOTE[i].ote_base; 467 const char *pszEnd = psz + pKrnlOTE[i].ote_size; 468 469 while (psz + 100 < pszEnd) 475 const char *pszEnd = psz + pKrnlOTE[i].ote_size - 50; /* Last possible search position. */ 476 #else 477 extern const char *pszInternalRevision; /* defined in win32ktst.c */ 478 const char *psz = pszInternalRevision; 479 const char *pszEnd = psz + 3; 480 #endif 481 482 while (psz < pszEnd) 470 483 { 471 484 if (strncmp(psz, "Internal revision ", 18) == 0 && (psz[18] >= '0' && psz[18] <= '9')) 472 485 { 473 486 int j; 474 kprintf2(("Get OTEs32: found internal revision: '%s'\n", psz));487 kprintf2(("GetKernelInfo32: found internal revision: '%s'\n", psz)); 475 488 476 489 /* skip to end of "Internal revision " string. */ … … 481 494 { 482 495 if (*psz != '.') 483 pKrnlInfo->u sBuild = (unsigned short)(pKrnlInfo->usBuild * 10 + (*psz - '0'));496 pKrnlInfo->ulBuild = (unsigned short)(pKrnlInfo->ulBuild * 10 + (*psz - '0')); 484 497 psz++; 485 498 } 486 499 487 500 /* Check if build number seems valid. */ 488 if ( !(pKrnlInfo->u sBuild >= 8254 && pKrnlInfo->usBuild < 8383) /* Warp 3 fp 32 -> fp 60 */489 && !(pKrnlInfo->u sBuild >= 9023 && pKrnlInfo->usBuild <= 9036) /* Warp 4 GA -> fp 12 */490 && !(pKrnlInfo->u sBuild >= 14039 && pKrnlInfo->usBuild < 14080) /* Warp 4.5 GA -> fp 40 */501 if ( !(pKrnlInfo->ulBuild >= 8254 && pKrnlInfo->ulBuild < 8383) /* Warp 3 fp 32 -> fp 60 */ 502 && !(pKrnlInfo->ulBuild >= 9023 && pKrnlInfo->ulBuild <= 9036) /* Warp 4 GA -> fp 12 */ 503 && !(pKrnlInfo->ulBuild >= 14039 && pKrnlInfo->ulBuild < 14080) /* Warp 4.5 GA -> fp 40 */ 491 504 ) 492 505 { 493 kprintf(("Get OTEs32: info summary: Build %d is invalid - invalid fixpack?\n", pKrnlInfo->usBuild));494 usRc = 6;506 kprintf(("GetKernelInfo32: info summary: Build %d is invalid - invalid fixpack?\n", pKrnlInfo->ulBuild)); 507 usRc = ERROR_D32_INVALID_BUILD; 495 508 break; 496 509 } … … 500 513 || (psz[0] == '_' && (psz[1] == 'S' || psz[1] == 's')) /* _SMP */ 501 514 ) 502 pKrnlInfo->fchType = TYPE_SMP; 503 else if (psz[0] == '_' && psz[1] == 'W' && psz[2] == '4') /* _W4 */ 504 pKrnlInfo->fchType = TYPE_W4; 515 pKrnlInfo->fKernel = KF_SMP; 505 516 else 506 pKrnlInfo->fchType = TYPE_UNI; 517 if (*psz != ',' 518 && (psz[0] == '_' && (psz[1] == 'W' || psz[1] == 'w') && psz[2] == '4') /* _W4 */ 519 ) 520 pKrnlInfo->fKernel = KF_W4 | KF_UNI; 521 else 522 pKrnlInfo->fKernel = KF_UNI; 507 523 508 524 509 525 /* Check if its a debug kernel (look for DEBUG at start of object 3-5) */ 526 #ifndef R3TST 510 527 j = 3; 511 pKrnlInfo->fDebug = FALSE;512 528 while (j < 5) 513 529 { … … 520 536 && strncmp((char*)pKrnlOTE[j].ote_base, "DEBUG", 5) == 0) 521 537 { 522 pKrnlInfo->f Debug = TRUE;538 pKrnlInfo->fKernel |= KF_DEBUG; 523 539 break; 524 540 } 525 541 j++; 526 542 } 543 #else 544 NOREF(j); 545 #endif 527 546 528 547 /* Display info */ 529 kprintf(("Get OTEs32: info summary: Build %d, fchType=%d, fDebug=%d\n",530 pKrnlInfo->u sBuild, pKrnlInfo->fchType, pKrnlInfo->fDebug));548 kprintf(("GetKernelInfo32: info summary: Build %d, fKernel=%d\n", 549 pKrnlInfo->ulBuild, pKrnlInfo->fKernel)); 531 550 532 551 /* Break out */ … … 540 559 541 560 /* Set error code if not found */ 542 if (pKrnlInfo->u sBuild == 0)561 if (pKrnlInfo->ulBuild == 0) 543 562 { 544 usRc = 5;545 kprintf(("Get OTEs32: Internal revision was not found!\n"));563 usRc = ERROR_D32_BUILD_INFO_NOT_FOUND; 564 kprintf(("GetKernelInfo32: Internal revision was not found!\n")); 546 565 } 547 566 } 548 567 else 549 usRc = 4;568 usRc = ERROR_D32_NO_OBJECT_TABLE; 550 569 } 551 570 else 552 usRc = 3;571 usRc = ERROR_D32_TOO_MANY_OBJECTS; 553 572 } 554 573 else 555 usRc = 2;574 usRc = ERROR_D32_NO_SWAPMTE; 556 575 } 557 576 else 558 usRc = 1; 559 560 561 if (usRc != 0) 562 kprintf(("GetOTEs32: failed. usRc = %d\n", usRc)); 577 usRc = ERROR_D32_GETOS2KRNL_FAILED; 578 579 if (usRc != NO_ERROR) 580 kprintf(("GetKernelInfo32: failed. usRc = %d\n", usRc)); 563 581 564 582 return (USHORT)(usRc | (usRc != NO_ERROR ? STATUS_DONE | STERR : STATUS_DONE)); … … 575 593 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 576 594 */ 577 _Inlineint ModR_M_32bit(char bModRM)595 int ModR_M_32bit(char bModRM) 578 596 { 579 597 if ((bModRM & 0xc0) == 0x80 /* ex. mov ax,[ebp+11145543h] */ … … 591 609 592 610 611 /** 612 * Functions which cacluates the instructionsize given a ModR/M byte. 613 * @returns Number of bytes to add to cb and pach. 614 * @param bModRM ModR/M byte. 615 * @status completely implemented. 616 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 617 */ 618 int ModR_M_16bit(char bModRM) 619 { 620 if ((bModRM & 0xc0) == 0x80 /* ex. mov ax,[ebp+11145543h] */ 621 || ((bModRM & 0xc0) == 0 && (bModRM & 0x07) == 5)) /* ex. mov ebp,[0ff231234h] */ 622 { /* 16-bit displacement */ 623 return 4; 624 } 625 else if ((bModRM & 0xc0) == 0x40) /* ex. mov ecx,[esi]+4fh */ 626 { /* 8-bit displacement */ 627 return 2; 628 } 629 /* no displacement (only /r byte) */ 630 return 1; 631 } 632 633 593 634 594 635 … … 603 644 * FALSE: Function is to be imported. 604 645 */ 605 staticint interpretFunctionProlog32(char *pach, BOOL fOverload)646 int interpretFunctionProlog32(char *pach, BOOL fOverload) 606 647 { 607 648 int cb = -3; 608 609 649 kprintf2(("interpretFunctionProlog32(0x%08x, %d):\n" 610 650 "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n" … … 787 827 * FALSE: Function is to be imported. 788 828 */ 789 staticint interpretFunctionProlog16(char *pach, BOOL fOverload)829 int interpretFunctionProlog16(char *pach, BOOL fOverload) 790 830 { 791 831 int cb = -7; … … 809 849 while (cb < 8 || fForce) /* 8 is the size of a 66h prefixed far jump instruction. */ 810 850 { 851 int cb2; 811 852 fForce = FALSE; 812 853 switch (*pach) 813 854 { 855 case 0x06: /* push es */ 856 case 0x0e: /* push cs */ 857 case 0x1e: /* push ds */ 858 case 0x16: /* push ss */ 859 break; 860 814 861 case 0x0f: /* push gs and push fs */ 815 862 if (pach[1] != 0xA0 && pach[1] != 0xA8) … … 888 935 break; 889 936 937 /* complex sized instruction - "/5 ib" */ 938 case 0x80: /* 5: sub r/m8, imm8 7: cmp r/m8, imm8 */ 939 case 0x83: /* 5: sub r/m16, imm8 7: cmp r/m16, imm8 */ 940 if ((pach[1] & 0x38) == (5<<3) 941 || (pach[1] & 0x38) == (7<<3) 942 ) 943 { 944 cb += cb2 = 1 + ModR_M_16bit(pach[1]); /* 1 is the size of the imm8 */ 945 pach += cb2; 946 } 947 else 948 { 949 kprintf(("interpretFunctionProlog32: unknown instruction (-3) 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2])); 950 return -3; 951 } 952 break; 953 954 890 955 default: 891 956 kprintf(("interpretFunctionProlog16: unknown instruction 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2])); … … 913 978 USHORT _loadds _Far32 _Pascal VerifyImportTab32(void) 914 979 { 915 int i; 916 int cb; 917 int cbmin; 980 USHORT usRc; 981 int i; 982 int cb; 983 int cbmin; 918 984 919 985 /* VerifyImporTab32 is called before the initroutine! */ 920 986 pulTKSSBase32 = (PULONG)_TKSSBase16; 921 987 988 #ifdef R3TST 989 R3TstFixImportTab(); 990 #endif 991 922 992 /* Check that pKrnlOTE is set */ 923 if (GetKernelInfo32(NULL) != NO_ERROR) 924 return STATUS_DONE | STERR | 1; 993 usRc = GetKernelInfo32(NULL); 994 if (usRc != NO_ERROR) 995 return (USHORT)(STATUS_DONE | STERR | (usRc & STECODE)); 925 996 926 997 /* … … 940 1011 { 941 1012 kprintf(("VerifyImportTab32: procedure no.%d was not fFound!\n", i)); 942 return STATUS_DONE | STERR | 2;1013 return STATUS_DONE | STERR | ERROR_D32_PROC_NOT_FOUND; 943 1014 } 944 1015 1016 #ifndef R3TST 945 1017 /* Verify read/writeable. */ 946 1018 if (_aImportTab[i].iObject >= pKrnlSMTE->smte_objcnt /* object index valid? */ … … 956 1028 i, &_aImportTab[i].achName[0], _aImportTab[i].ulAddress, 957 1029 _aImportTab[i].iObject, _aImportTab[i].offObject)); 958 return STATUS_DONE | STERR | 3;1030 return STATUS_DONE | STERR | ERROR_D32_INVALID_OBJ_OR_ADDR; 959 1031 } 960 1032 … … 965 1037 kprintf(("VerifyImportTab32: procedure no.%d has an invalid address, %#08x!\n", 966 1038 i, _aImportTab[i].ulAddress)); 967 return STATUS_DONE | STERR | 4;1039 return STATUS_DONE | STERR | ERROR_D32_INVALID_ADDRESS; 968 1040 } 1041 #endif 969 1042 970 1043 switch (_aImportTab[i].fType & ~EPT_BIT_MASK) … … 991 1064 * Check result of the function prolog interpretations. 992 1065 */ 993 if (cb <= 0 &&cb + cbmin >= MAXSIZE_PROLOG)1066 if (cb <= 0 || cb + cbmin >= MAXSIZE_PROLOG) 994 1067 { /* failed, too small or too large. */ 995 1068 kprintf(("VerifyImportTab32: verify failed for procedure no.%d (cd=%d)\n", i, cb)); 996 return STATUS_DONE | STERR | 5;1069 return STATUS_DONE | STERR | ERROR_D32_TOO_INVALID_PROLOG; 997 1070 } 998 1071 break; … … 1003 1076 1004 1077 default: 1005 kprintf(("VerifyImportTab32: only EPT_PROC isimplemented\n",i));1078 kprintf(("VerifyImportTab32: invalid type/type not implemented\n",i)); 1006 1079 Int3(); /* temporary fix! */ 1007 return STATUS_DONE | STERR | 6;1080 return STATUS_DONE | STERR | ERROR_D32_NOT_IMPLEMENTED; 1008 1081 } 1009 1082 } … … 1017 1090 * @returns NO_ERROR on success. !0 on error. 1018 1091 */ 1019 staticint importTabInit(void)1092 int importTabInit(void) 1020 1093 { 1021 1094 /* This table must be updated with the overloading functions. */ 1022 1095 static unsigned auFuncs[NBR_OF_KRNLIMPORTS] = 1023 1096 { 1024 (unsigned)myldrRead, 1025 (unsigned)myldrOpen, 1026 (unsigned)myldrClose, 1027 (unsigned)myLDRQAppType, 1028 (unsigned)myldrEnum32bitRelRecs, 1029 0, 1030 0, 1031 0, 1032 0, 1033 0, 1034 0, 1035 0, 1036 0, 1037 (unsigned)&mytkExecPgm, 1038 0, 1039 0, 1040 0, 1041 0 1042 }; 1043 1097 (unsigned)myldrRead, /* 0 */ 1098 (unsigned)myldrOpen, /* 1 */ 1099 (unsigned)myldrClose, /* 2 */ 1100 (unsigned)myLDRQAppType, /* 3 */ 1101 (unsigned)myldrEnum32bitRelRecs,/* 4 */ 1102 0, /* 5 */ 1103 0, /* 6 */ 1104 0, /* 7 */ 1105 0, /* 8 */ 1106 0, /* 9 */ 1107 0, /* 10 */ 1108 0, /* 11 */ 1109 0, /* 12 */ 1110 (unsigned)&mytkExecPgm, /* 13 */ 1111 0, /* 14 */ 1112 0, /* 15 */ 1113 0, /* 16 */ 1114 0, /* 17 */ 1115 (unsigned)myldrOpenPath, /* 18 */ 1116 0, /* 19 */ 1117 0, /* 20 */ 1118 0, /* 21 */ 1119 0, /* 22 */ 1120 0, /* 23 */ 1121 0, /* 24 */ 1122 0, /* 25 */ 1123 0, /* 26 */ 1124 0, /* 27 */ 1125 0, /* 28 */ 1126 0 /* 29 */ 1127 }; 1044 1128 int i; 1045 1129 int cb; 1046 1130 int cbmin; 1131 1132 #ifdef R3TST 1133 R3TstFixImportTab(); 1134 #endif 1047 1135 1048 1136 /* … … 1068 1156 { 1069 1157 kprintf(("ImportTabInit: Verify failed for procedure no.%d, cb=%d\n", i, cb)); 1070 return 1;1158 return ERROR_D32_VERIFY_FAILED; 1071 1159 } 1072 1160 } … … 1114 1202 kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when rehooking it!\n",i)); 1115 1203 Int3(); /* ipe - later! */ 1116 return 1;1204 return ERROR_D32_VERIFY_FAILED; 1117 1205 } 1118 1206 break; … … 1159 1247 kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when rehooking it!\n",i)); 1160 1248 Int3(); /* ipe - later! */ 1161 return 1;1249 return ERROR_D32_VERIFY_FAILED; 1162 1250 } 1163 1251 break; … … 1187 1275 kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when importing it!\n",i)); 1188 1276 Int3(); /* ipe - later! */ 1189 return 1;1277 return ERROR_D32_VERIFY_FAILED; 1190 1278 } 1191 1279 break; … … 1215 1303 kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when importing it!\n",i)); 1216 1304 Int3(); /* ipe - later! */ 1217 return 1;1305 return ERROR_D32_VERIFY_FAILED; 1218 1306 } 1219 1307 break; … … 1242 1330 kprintf(("ImportTabInit: unsupported type. (procedure no.%d, cb=%d)\n", i, cb)); 1243 1331 Int3(); /* ipe - later! */ 1244 return 1;1332 return ERROR_D32_VERIFY_FAILED; 1245 1333 } /* switch - type */ 1246 1334 } /* for */ … … 1250 1338 #endif /* !DEBUGR3 */ 1251 1339 1340 1341 #ifdef R3TST 1342 /** 1343 * Creates a fake kernel MTE, SMTE and OTE for use while testing in Ring3. 1344 * @returns Pointer to the fake kernel MTE. 1345 * @status completely implemented. 1346 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1347 */ 1348 PMTE GetOS2KrnlMTETst(void) 1349 { 1350 static MTE KrnlMTE; 1351 static SMTE KrnlSMTE; 1352 static OTE aKrnlOTE[17]; 1353 1354 extern int cObjectsFake; /* defined in win32ktst.c */ 1355 1356 KrnlMTE.mte_swapmte = &KrnlSMTE; 1357 KrnlSMTE.smte_objtab = &aKrnlOTE[0]; 1358 KrnlSMTE.smte_objcnt = cObjectsFake; 1359 1360 aKrnlOTE[0].ote_size = 0x00000FB4; 1361 aKrnlOTE[0].ote_base = 0xffe10000; 1362 aKrnlOTE[0].ote_flags = 0x80001063; 1363 aKrnlOTE[0].ote_pagemap = 1; 1364 aKrnlOTE[0].ote_mapsize = 1; 1365 aKrnlOTE[0].ote_sel = 0; 1366 aKrnlOTE[0].ote_hob = 0; 1367 1368 aKrnlOTE[1].ote_size = 0x0000A7CD; 1369 aKrnlOTE[1].ote_base = 0xffe20000; 1370 aKrnlOTE[1].ote_flags = 0x80001063; 1371 aKrnlOTE[1].ote_pagemap = 0x00000002; 1372 aKrnlOTE[1].ote_mapsize = 0x0000000B; 1373 aKrnlOTE[1].ote_sel = 0x0; 1374 aKrnlOTE[1].ote_hob = 0x0; 1375 1376 aKrnlOTE[2].ote_size = 0x000084C9; 1377 aKrnlOTE[2].ote_base = 0xffe30000; 1378 aKrnlOTE[2].ote_flags = 0x80001045; 1379 aKrnlOTE[2].ote_pagemap = 0x0000000D; 1380 aKrnlOTE[2].ote_mapsize = 0x00000009; 1381 aKrnlOTE[2].ote_sel = 0x0; 1382 aKrnlOTE[2].ote_hob = 0x0; 1383 1384 aKrnlOTE[3].ote_size = 0x00010000; 1385 aKrnlOTE[3].ote_base = 0xffe40000; 1386 aKrnlOTE[3].ote_flags = 0x800090A3; 1387 aKrnlOTE[3].ote_pagemap = 0x00000016; 1388 aKrnlOTE[3].ote_mapsize = 0x00000010; 1389 aKrnlOTE[3].ote_sel = 0x0; 1390 aKrnlOTE[3].ote_hob = 0x0; 1391 1392 aKrnlOTE[4].ote_size = 0x00002A80; 1393 aKrnlOTE[4].ote_base = 0xffe50000; 1394 aKrnlOTE[4].ote_flags = 0x80009023; 1395 aKrnlOTE[4].ote_pagemap = 0x00000026; 1396 aKrnlOTE[4].ote_mapsize = 0x00000003; 1397 aKrnlOTE[4].ote_sel = 0x0; 1398 aKrnlOTE[4].ote_hob = 0x0; 1399 1400 aKrnlOTE[5].ote_size = 0x00005734; 1401 aKrnlOTE[5].ote_base = 0xffe60000; 1402 aKrnlOTE[5].ote_flags = 0x80001023; 1403 aKrnlOTE[5].ote_pagemap = 0x00000029; 1404 aKrnlOTE[5].ote_mapsize = 0x00000003; 1405 aKrnlOTE[5].ote_sel = 0x0; 1406 aKrnlOTE[5].ote_hob = 0x0; 1407 1408 aKrnlOTE[6].ote_size = 0x00002833; 1409 aKrnlOTE[6].ote_base = 0xffe70000; 1410 aKrnlOTE[6].ote_flags = 0x80001015; 1411 aKrnlOTE[6].ote_pagemap = 0x0000002C; 1412 aKrnlOTE[6].ote_mapsize = 0x00000003; 1413 aKrnlOTE[6].ote_sel = 0x0; 1414 aKrnlOTE[6].ote_hob = 0x0; 1415 1416 aKrnlOTE[7].ote_size = 0x000001B0; 1417 aKrnlOTE[7].ote_base = 0xffe80000; 1418 aKrnlOTE[7].ote_flags = 0x80002213; 1419 aKrnlOTE[7].ote_pagemap = 0x0000002F; 1420 aKrnlOTE[7].ote_mapsize = 0x00000001; 1421 aKrnlOTE[7].ote_sel = 0x0; 1422 aKrnlOTE[7].ote_hob = 0x0; 1423 1424 aKrnlOTE[8].ote_size = 0x000027CC; 1425 aKrnlOTE[8].ote_base = 0xffe90000; 1426 aKrnlOTE[8].ote_flags = 0x80002013; 1427 aKrnlOTE[8].ote_pagemap = 0x00000030; 1428 aKrnlOTE[8].ote_mapsize = 0x00000003; 1429 aKrnlOTE[8].ote_sel = 0x0; 1430 aKrnlOTE[8].ote_hob = 0x0; 1431 1432 aKrnlOTE[9].ote_size = 0x0000FDA8; 1433 aKrnlOTE[9].ote_base = 0xffeA0000; 1434 aKrnlOTE[9].ote_flags = 0x80002033; 1435 aKrnlOTE[9].ote_pagemap = 0x00000033; 1436 aKrnlOTE[9].ote_mapsize = 0x0000000D; 1437 aKrnlOTE[9].ote_sel = 0x0; 1438 aKrnlOTE[9].ote_hob = 0x0; 1439 1440 aKrnlOTE[10].ote_size = 0x0000ECD6; 1441 aKrnlOTE[10].ote_base = 0xffeB0000; 1442 aKrnlOTE[10].ote_flags = 0x80001015; 1443 aKrnlOTE[10].ote_pagemap = 0x00000040; 1444 aKrnlOTE[10].ote_mapsize = 0x0000000F; 1445 aKrnlOTE[10].ote_sel = 0x0; 1446 aKrnlOTE[10].ote_hob = 0x0; 1447 1448 aKrnlOTE[11].ote_size = 0x0000EAF4; 1449 aKrnlOTE[11].ote_base = 0xffeC0000; 1450 aKrnlOTE[11].ote_flags = 0x80001015; 1451 aKrnlOTE[11].ote_pagemap = 0x0000004F; 1452 aKrnlOTE[11].ote_mapsize = 0x0000000F; 1453 aKrnlOTE[11].ote_sel = 0x0; 1454 aKrnlOTE[11].ote_hob = 0x0; 1455 1456 aKrnlOTE[12].ote_size = 0x0000D900; 1457 aKrnlOTE[12].ote_base = 0xffeD0000; 1458 aKrnlOTE[12].ote_flags = 0x80001015; 1459 aKrnlOTE[12].ote_pagemap = 0x0000005E; 1460 aKrnlOTE[12].ote_mapsize = 0x0000000E; 1461 aKrnlOTE[12].ote_sel = 0x0; 1462 aKrnlOTE[12].ote_hob = 0x0; 1463 1464 aKrnlOTE[13].ote_size = 0x0000D6DC; 1465 aKrnlOTE[13].ote_base = 0xffeE0000; 1466 aKrnlOTE[13].ote_flags = 0x80001015; 1467 aKrnlOTE[13].ote_pagemap = 0x0000006C; 1468 aKrnlOTE[13].ote_mapsize = 0x0000000E; 1469 aKrnlOTE[13].ote_sel = 0x0; 1470 aKrnlOTE[13].ote_hob = 0x0; 1471 1472 aKrnlOTE[14].ote_size = 0x000B684B; 1473 aKrnlOTE[14].ote_base = 0xffeF0000; 1474 aKrnlOTE[14].ote_flags = 0x80002015; 1475 aKrnlOTE[14].ote_pagemap = 0x0000007A; 1476 aKrnlOTE[14].ote_mapsize = 0x000000B7; 1477 aKrnlOTE[14].ote_sel = 0x0; 1478 aKrnlOTE[14].ote_hob = 0x0; 1479 1480 aKrnlOTE[15].ote_size = 0x000B684B; 1481 aKrnlOTE[15].ote_base = 0xffeF0000; 1482 aKrnlOTE[15].ote_flags = 0x80002015; 1483 aKrnlOTE[15].ote_pagemap = 0x0000007A; 1484 aKrnlOTE[15].ote_mapsize = 0x000000B7; 1485 aKrnlOTE[15].ote_sel = 0x0; 1486 aKrnlOTE[15].ote_hob = 0x0; 1487 1488 aKrnlOTE[16].ote_size = 0x000B684B; 1489 aKrnlOTE[16].ote_base = 0xffeF0000; 1490 aKrnlOTE[16].ote_flags = 0x80002015; 1491 aKrnlOTE[16].ote_pagemap = 0x0000007A; 1492 aKrnlOTE[16].ote_mapsize = 0x000000B7; 1493 aKrnlOTE[16].ote_sel = 0x0; 1494 aKrnlOTE[16].ote_hob = 0x0; 1495 1496 return &KrnlMTE; 1497 } 1498 1499 /** 1500 * -Ring-3 testing- 1501 * Changes the entries in _aImportTab to point to their fake equivalents. 1502 * @returns void 1503 * @param void 1504 * @status completely implemented. 1505 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1506 * @remark Called before the _aImportTab array is used/verified. 1507 */ 1508 VOID R3TstFixImportTab(VOID) 1509 { 1510 struct _TstFaker 1511 { 1512 unsigned uAddress; 1513 int fObj; /* 1 = CODE32, 2 = CODE16, 3 = DATA32, 4 = DATA16 */ 1514 } 1515 aTstFakers[NBR_OF_KRNLIMPORTS] = 1516 { 1517 {(unsigned)fakeldrRead, 1}, 1518 {(unsigned)fakeldrOpen, 1}, 1519 {(unsigned)fakeldrClose, 1}, 1520 {(unsigned)fakeLDRQAppType, 1}, 1521 {(unsigned)fakeldrEnum32bitRelRecs, 1}, 1522 {(unsigned)fakeIOSftOpen, 1}, 1523 {(unsigned)fakeIOSftClose, 1}, 1524 {(unsigned)fakeIOSftTransPath, 1}, 1525 {(unsigned)fakeIOSftReadAt, 1}, 1526 {(unsigned)fakeIOSftWriteAt, 1}, 1527 {(unsigned)fakeSftFileSize, 1}, 1528 {(unsigned)fakeVMAllocMem, 1}, 1529 {(unsigned)fakeVMGetOwner, 1}, 1530 {(unsigned)fakeg_tkExecPgm, 1}, 1531 {(unsigned)fakef_FuStrLenZ, 2}, 1532 {(unsigned)fakef_FuStrLen, 2}, 1533 {(unsigned)fakef_FuBuff, 2}, 1534 {(unsigned)fakeVMObjHandleInfo, 1}, 1535 {(unsigned)fakeldrOpenPath, 1}, 1536 {(unsigned)fakeLDRClearSem, 1}, 1537 {(unsigned)fakeKSEMRequestMutex, 1}, 1538 {(unsigned)&fakeLDRSem, 3}, 1539 {(unsigned)fakeTKSuBuff, 1}, 1540 {(unsigned)fakeTKFuBuff, 1}, 1541 {(unsigned)fakeTKFuBufLen, 1}, 1542 {(unsigned)fakeldrValidateMteHandle,1}, 1543 {(unsigned)&fakepTCBCur, 4}, 1544 {(unsigned)&fakepPTDACur, 4}, 1545 {(unsigned)&fakeptda_start, 4}, 1546 {(unsigned)&fakeptda_environ, 4} 1547 }; 1548 int i; 1549 1550 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 1551 { 1552 switch (_aImportTab[i].fType) 1553 { 1554 case EPT_PROC32: 1555 if (aTstFakers[i].fObj != 1) 1556 kprintf(("R3TstFixImportTab: invalid segment config for entry %i. (PROC32)\n", i)); 1557 break; 1558 case EPT_PROCIMPORT32: 1559 if (aTstFakers[i].fObj != 1) 1560 kprintf(("R3TstFixImportTab: invalid segment config for entry %i. (PROCIMPORT32)\n", i)); 1561 break; 1562 case EPT_PROCIMPORT16: 1563 if (aTstFakers[i].fObj != 2) 1564 kprintf(("R3TstFixImportTab: invalid segment config for entry %i. (PROCIMPORT16)\n", i)); 1565 break; 1566 case EPT_VARIMPORT32: 1567 case EPT_VARIMPORT16: 1568 if (aTstFakers[i].fObj != 3 && aTstFakers[i].fObj != 4) 1569 kprintf(("R3TstFixImportTab: invalid segment config for entry %i. (VARIMPORT32/16)\n", i)); 1570 break; 1571 } /* switch - type */ 1572 1573 _aImportTab[i].ulAddress = aTstFakers[i].uAddress; 1574 switch (aTstFakers[i].fObj) 1575 { 1576 case 1: 1577 _aImportTab[i].usSel = GetSelectorCODE32(); 1578 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE32START; 1579 break; 1580 case 2: 1581 _aImportTab[i].usSel = GetSelectorCODE16(); 1582 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE16START; 1583 break; 1584 case 3: 1585 _aImportTab[i].usSel = GetSelectorDATA32(); 1586 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA32START; 1587 break; 1588 case 4: 1589 _aImportTab[i].usSel = GetSelectorDATA16(); 1590 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA16START; 1591 break; 1592 default: 1593 kprintf(("R3TstFixImportTab: invalid segment config for entry %i.\n", i)); 1594 } 1595 } /* for */ 1596 } 1597 #endif 1252 1598 1253 1599 … … 1367 1713 0xEC, 0x83, 0xEC, 0x0C, 0x53, 0x57, 0x8D, 0x55, 1368 1714 0xF8 1715 }; 1716 char achf_ldrOpenPath[] = { 1717 0x55, 0xA1, 0xA4, 0x0A, 0x00, 0x00, 0x8B, 0xEC, 1718 0x83, 0xEC, 0x28, 0x66, 0x8B, 0x80, 0xFE, 0x01, 1719 0x00, 0x00, 0x53, 0x57, 0x66, 0x89, 0x45, 0xE2 1369 1720 }; 1370 1721 … … 1390 1741 achf_FuBuff , 1391 1742 achf_VMObjHandleInfo , 1743 achf_ldrOpenPath , 1392 1744 NULL 1393 1745 };
Note:
See TracChangeset
for help on using the changeset viewer.
