Changeset 4164 for trunk/src/win32k/dev16/probkrnl.c
- Timestamp:
- Sep 2, 2000, 11:08:23 PM (25 years ago)
- File:
-
- 1 edited
-
trunk/src/win32k/dev16/probkrnl.c (modified) (74 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/dev16/probkrnl.c
r3411 r4164 1 /* $Id: probkrnl.c,v 1.2 0 2000-04-17 01:56:48bird Exp $1 /* $Id: probkrnl.c,v 1.21 2000-09-02 21:07:56 bird Exp $ 2 2 * 3 3 * Description: Autoprobes the os2krnl file and os2krnl[*].sym files. … … 14 14 * How this works: 15 15 * 1. parses the device-line parameters and collects some "SysInfo". 16 * 2. gets the kernel object table. (elf$) 17 * 3. finds the kernel image and scans it for a build number. 18 * 4. locates and scans the symbol-file(s) for the entrypoints which are wanted. 16 * 2. gets the kernel object table and kernel info like build no. (elf$) 17 * 3. if non-debug kernel the symbol database is scanned to get the syms 18 * 4. if Syms not found THEN locates and scans the symbol-file(s) for the 19 * entrypoints which are wanted. 19 20 * 5. the entry points are verified. (elf$) 20 21 * 6. finished. 21 22 * 22 * Copyright (c) 1998-2000 knut st. osmundsen 23 * Copyright (c) 1998-2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no) 23 24 * 24 25 * Project Odin Software License can be found in LICENSE.TXT … … 51 52 #define INCL_NOPMAPI 52 53 53 54 54 /******************************************************************************* 55 55 * Header Files * … … 61 61 #include <reqpkt.h> 62 62 63 #include "devSegDf.h" 64 #undef DATA16_INIT 65 #define DATA16_INIT 66 #undef CODE16_INIT 67 #define CODE16_INIT 63 68 #include "os2krnl.h" /* must be included before dev1632.h! */ 64 69 #include "sym.h" … … 68 73 #include "vprntf16.h" 69 74 #include "log.h" 70 75 #include "options.h" 76 #include "errors.h" 71 77 72 78 /******************************************************************************* … … 74 80 * Note: must be inited or else we'll get BSS segment * 75 81 *******************************************************************************/ 76 /* 77 * kernel data - !only valid during init! 78 */ 82 79 83 80 84 /* 81 85 * aImportTab defines the imported and overloaded OS/2 kernel functions. 82 * IMPORTANT: aImportTab has a sibling array in d32init.c, aulProc, which must 83 * match entry by entry. Adding/removing/shuffling aImportTab, aulProc 84 * has to be updated immediately! 85 */ 86 IMPORTKRNLSYM aImportTab[NBR_OF_KRNLIMPORTS] = 86 * IMPORTANT: aImportTab has two sibling arrays, one in d32init.c, aulProc, and 87 * the calltab.asm, which must match entry by entry. 88 * When adding/removing/shuffling items in aImportTab, aulProc and 89 * calltab.asm has to be updated immediately! 90 */ 91 IMPORTKRNLSYM DATA16_GLOBAL aImportTab[NBR_OF_KRNLIMPORTS] = 87 92 {/* iFound cchName offObject usSel fType */ 88 93 /* iObject achName ulAddress cProlog */ … … 101 106 {FALSE, -1, 11, "_VMGetOwner", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 12 */ 102 107 {FALSE, -1, 11, "g_tkExecPgm", -1, -1, -1, -1, EPT_PROC32}, /* 13 */ 103 {FALSE, -1, 11, "f_FuStrLenZ", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 14 */ 104 {FALSE, -1, 10, "f_FuStrLen", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 15 */ 105 {FALSE, -1, 8, "f_FuBuff", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 16 */ 106 {FALSE, -1, 16, "_VMObjHandleInfo", -1, -1, -1, -1, EPT_PROCIMPORT} /* 17 */ 107 /* {FALSE, -1, 11, "", -1, -1, -1, EPT_PROCIMPORT16} */ /* 16 */ 108 {FALSE, -1, 15, "_tkStartProcess", -1, -1, -1, -1, EPT_PROC32}, /* 14 */ 109 {FALSE, -1, 11, "f_FuStrLenZ", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 15 */ 110 {FALSE, -1, 10, "f_FuStrLen", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 16 */ 111 {FALSE, -1, 8, "f_FuBuff", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 17 */ 112 {FALSE, -1, 16, "_VMObjHandleInfo", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 18 */ 113 {FALSE, -1, 21, "_ldrASMpMTEFromHandle",-1, -1, -1, -1, EPT_PROCIMPORT32}, /* 19 */ 114 {FALSE, -1, 12, "_ldrOpenPath", -1, -1, -1, -1, EPT_PROC32}, /* 20 */ 115 {FALSE, -1, 12, "_LDRClearSem", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 21 */ 116 {FALSE, -1, 14, "_ldrFindModule", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 22 */ 117 {FALSE, -1, 17, "_KSEMRequestMutex", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 23 */ 118 {FALSE, -1, 17, "_KSEMReleaseMutex", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 24 */ 119 {FALSE, -1, 15, "_KSEMQueryMutex", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 25 */ 120 {FALSE, -1, 9, "_KSEMInit", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 26 */ 121 {FALSE, -1, 7, "_LdrSem", -1, -1, -1, -1, EPT_VARIMPORT32}, /* 27 */ 122 {FALSE, -1, 11, "_LDRLibPath", -1, -1, -1, -1, EPT_VARIMPORT32}, /* 28 */ 123 {FALSE, -1, 9, "_TKSuBuff", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 29 */ 124 {FALSE, -1, 9, "_TKFuBuff", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 30 */ 125 {FALSE, -1, 11, "_TKFuBufLen", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 31 */ 126 {FALSE, -1, 21, "_ldrValidateMteHandle",-1, -1, -1, -1, EPT_PROCIMPORT32}, /* 32 */ 127 {FALSE, -1, 8, "_pTCBCur", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 33 */ 128 {FALSE, -1, 9, "_pPTDACur", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 34 */ 129 {FALSE, -1, 10, "ptda_start", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 35 */ 130 {FALSE, -1, 12, "ptda_environ", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 36 */ 131 {FALSE, -1, 12, "ptda_ptdasem", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 37 */ 132 {FALSE, -1, 11, "ptda_module", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 38 */ 133 {FALSE, -1, 18, "ptda_pBeginLIBPATH", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 39 */ 134 {FALSE, -1, 16, "_ldrpFileNameBuf", -1, -1, -1, -1, EPT_VARIMPORT32}, /* 40 */ 135 {FALSE, -1, 14, "SecPathFromSFN", -1, -1, -1, -1, EPT_PROCIMPORTNR32},/* 41 */ 136 108 137 }; 109 138 110 unsigned short int usBuild = 0; 111 unsigned short usVerMajor = 0; 112 unsigned short usVerMinor = 0; 113 unsigned char fchType = TYPE_UNI; /* TYPE_SMP, TYPE_UNI, TYPE_W4 */ 114 unsigned char fDebug = FALSE; 139 char DATA16_GLOBAL szUsrSym[50] = {0}; 140 115 141 116 142 … … 118 144 * privat data 119 145 */ 120 static int fQuiet = 0; 121 static char szUsrOS2Krnl[50] = {0}; 122 static char szOS2Krnl[] = {"c:\\os2krnl"}; 123 124 static char szUsrSym[50] = {0}; 125 static char * apszSym[] = 146 #if defined(DEBUGR3) 147 static char DATA16_INIT szUsrOS2Krnl[50] = {0}; 148 static char DATA16_INIT szOS2Krnl[] = {"c:\\os2krnl"}; 149 #endif 150 static char * DATA16_INIT apszSym[] = 126 151 { 127 152 {"c:\\os2krnl.sym"}, /* usual for debugkernel */ … … 144 169 145 170 /* Result from GetKernelInfo/ReadOS2Krnl. */ 146 static unsigned char cObjects = 0; 147 static POTE paKrnlOTEs = NULL; 148 171 static unsigned char DATA16_INIT cObjects = 0; 172 static POTE DATA16_INIT paKrnlOTEs = NULL; 173 174 175 /* 176 * 177 */ 178 static struct 179 { 180 short sErr; 181 const char *pszMsg; 182 } DATA16_INIT aErrorMsgs[] = 183 { 184 {ERROR_PROB_KRNL_OPEN_FAILED, "Krnl: Failed to open kernel file."}, 185 {ERROR_PROB_KRNL_SEEK_SIZE, "Krnl: Failed to seek to end to of file."}, 186 {ERROR_PROB_KRNL_SEEK_FIRST, "Krnl: Failed to start of file."}, 187 {ERROR_PROB_KRNL_READ_FIRST, "Krnl: Failed to read (first)."}, 188 {ERROR_PROB_KRNL_READ_NEXT, "Krnl: Failed to read."}, 189 {ERROR_PROB_KRNL_TAG_NOT_FOUND, "Krnl: Build level tag was not found."}, 190 {ERROR_PROB_KRNL_INV_SIGANTURE, "Krnl: Invalid build level signature."}, 191 {ERROR_PROB_KRNL_INV_BUILD_NBR, "Krnl: Invalid build level number."}, 192 {ERROR_PROB_KRNL_BUILD_VERSION, "Krnl: Invalid build level version."}, 193 {ERROR_PROB_KRNL_MZ_SEEK, "Krnl: Failed to seek to start of file. (MZ)"}, 194 {ERROR_PROB_KRNL_MZ_READ, "Krnl: Failed to read MZ header."}, 195 {ERROR_PROB_KRNL_NEOFF_INVALID, "Krnl: Invalid new-header offset in MZ header."}, 196 {ERROR_PROB_KRNL_NEOFF_SEEK, "Krnl: Failed to seek to new-header offset."}, 197 {ERROR_PROB_KRNL_LX_READ, "Krnl: Failed to read LX header."}, 198 {ERROR_PROB_KRNL_LX_SIGNATURE, "Krnl: Invalid LX header signature."}, 199 {ERROR_PROB_KRNL_OBJECT_CNT, "Krnl: Object count don't match the running kernel."}, 200 {ERROR_PROB_KRNL_OBJECT_CNR_10, "Krnl: Less than 10 objects - not a valid kernel file!"}, 201 {ERROR_PROB_KRNL_OTE_SEEK, "Krnl: Failed to seek to OTEs."}, 202 {ERROR_PROB_KRNL_OTE_READ, "Krnl: Failed to read OTEs."}, 203 {ERROR_PROB_KRNL_OTE_SIZE_MIS, "Krnl: Size of a OTE didn't match the running kernel."}, 204 205 /* 206 * ProbeSymFile error messages 207 */ 208 {ERROR_PROB_SYM_FILE_NOT_FOUND, "Sym: Symbol file was not found."}, 209 {ERROR_PROB_SYM_READERROR, "Sym: Read failed."}, 210 {ERROR_PROB_SYM_INVALID_MOD_NAME, "Sym: Invalid module name (not OS2KRNL)."}, 211 {ERROR_PROB_SYM_SEGS_NE_OBJS, "Sym: Number of segments don't match the object count of the kernel."}, 212 {ERROR_PROB_SYM_SEG_DEF_SEEK, "Sym: Failed to seek to a segment definition."}, 213 {ERROR_PROB_SYM_SEG_DEF_READ, "Sym: Failed to read a segment definition."}, 214 {ERROR_PROB_SYM_IMPORTS_NOTFOUND, "Sym: All the imports wasn't found."}, 215 {ERROR_PROB_SYM_V_PROC_NOT_FND, "Sym: Verify failed: Procedure not found."}, 216 {ERROR_PROB_SYM_V_OBJ_OR_ADDR, "Sym: Verify failed: Invalid object or address."}, 217 {ERROR_PROB_SYM_V_ADDRESS, "Sym: Verify failed: Invalid address."}, 218 {ERROR_PROB_SYM_V_PROLOG, "Sym: Verify failed: Invalid prolog."}, 219 {ERROR_PROB_SYM_V_NOT_IMPL, "Sym: Verify failed: Not implemented."}, 220 221 {ERROR_PROB_SYMDB_KRNL_NOT_FOUND, "SymDB: Kernel was not found."} 222 }; 223 224 /* 225 * Fake data for Ring-3 testing. 226 */ 227 #ifdef R3TST 228 USHORT DATA16_INIT usFakeVerMajor = 0; 229 USHORT DATA16_INIT usFakeVerMinor = 0; 230 #ifdef R3TST 231 static DATA16_INIT ach[11] = {0}; /* works around compiler/linker bug */ 232 #endif 233 #endif 149 234 150 235 … … 157 242 static int fseek(HFILE hfile, signed long off, int iOrg); 158 243 static unsigned long fsize(HFILE hFile); 159 static void puts(char *psz); 160 161 /* C-library replacements. */ 244 245 /* C-library replacements and additions. */ 162 246 static void kmemcpy(char *psz1, const char *psz2, int cch); 163 247 static char * kstrstr(const char *psz1, const char *psz2); … … 169 253 static int kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen); 170 254 255 static const char * GetErrorMsg(short sErr); 256 171 257 /* Workers */ 172 static int LookupKrnlEntry(unsigned uBuild, unsigned char chType, 173 unsigned char fchType, unsigned char cObjects); 258 static int LookupKrnlEntry(unsigned short usBuild, unsigned short fKernel, unsigned char cObjects); 174 259 static int VerifyPrologs(void); 175 260 static int ProbeSymFile(const char *pszFilename); … … 177 262 178 263 /* Ouput */ 179 static void ShowDecNumber(unsigned long ul);180 static void ShowHexNumber(unsigned long ul);181 264 static void ShowResult(int rc, int iSym); 182 265 … … 187 270 static int processFile(const char *pszFilename); 188 271 272 #if 0 /*ndef CODE16_INIT*/ 273 #pragma alloc_text(CODE16_INIT, fopen, fread, fseek, fsize) 274 #pragma alloc_text(CODE16_INIT, kmemcpy, kstrstr, kstrcmp, kstrncmp, kstrnicmp, kstrlen, kstrcpy, kargncpy) 275 #pragma alloc_text(CODE16_INIT, GetErrorMsg) 276 #pragma alloc_text(CODE16_INIT, LookupKrnlEntry, VerifyPrologs, ProbeSymFile, GetKernelInfo) 277 #pragma alloc_text(CODE16_INIT, ShowResult) 278 #pragma alloc_text(CODE16_INIT, VerifyKernelVer, ReadOS2Krnl, ReadOS2Krnl2, processFile) 279 #endif 189 280 190 281 … … 277 368 278 369 /** 279 * puts lookalike280 */281 static void puts(char * psz)282 {283 DosPutMessage(0, kstrlen(psz), psz);284 }285 286 287 /**288 370 * kmemcpy - memory copy - slow! 289 371 * @param psz1 target … … 421 503 while (*pszSource != '\0') 422 504 *psz++ = *pszSource++; 423 505 *psz = '\0'; 424 506 return pszTarget; 425 507 } … … 478 560 479 561 return i; 562 } 563 564 565 /** 566 * Get the message text for an error message. 567 * @returns Pointer to error text. NULL if not found. 568 * @param sErr Error code id. 569 * @status completely implemented. 570 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 571 */ 572 static const char * GetErrorMsg(short sErr) 573 { 574 int i; 575 for (i = 0; i < sizeof(aErrorMsgs) / sizeof(aErrorMsgs[0]); i++) 576 { 577 if (aErrorMsgs[i].sErr == sErr) 578 return aErrorMsgs[i].pszMsg; 579 } 580 return NULL; 480 581 } 481 582 … … 493 594 * 1 if not found. 494 595 * Error code on error. 495 * @param uBuild Build level. 496 * @param fchBldType 'A' all strict 497 * 'H' half strict 498 * 'R' retail 499 * @param fchType TYPE_SMP, TYPE_UNI, TYPE_W4 596 * @param usBuild Build level. 597 * @param fKernel Kernel (type) flags. (KF_* from options.h) 500 598 * @param cObjects Count of object in the running kernel. 501 599 * @sketch Loop thru the table. … … 503 601 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 504 602 */ 505 static int LookupKrnlEntry(unsigned uBuild, unsigned char fchBldType, unsigned char fchType, unsigned char cObjects)603 static int LookupKrnlEntry(unsigned short usBuild, unsigned short fKernel, unsigned char cObjects) 506 604 { 507 605 int i; … … 512 610 for (i = 0; aKrnlSymDB[i].usBuild != 0; i++) 513 611 { 514 if (aKrnlSymDB[i].usBuild == uBuild 515 && aKrnlSymDB[i].fchBldType == fchBldType 516 && aKrnlSymDB[i].fchType == fchType 517 && aKrnlSymDB[i].cObjects == cObjects) 612 if ( aKrnlSymDB[i].usBuild == usBuild 613 && aKrnlSymDB[i].fKernel == fKernel 614 && aKrnlSymDB[i].cObjects == cObjects) 518 615 { /* found matching entry! */ 519 616 int j; … … 533 630 + pEntry->aSyms[j].offObject; 534 631 aImportTab[j].usSel = paKrnlOTEs[pEntry->aSyms[j].iObject].ote_sel; 535 aImportTab[j].fFound = TRUE;632 aImportTab[j].fFound = (char)((aImportTab[j].offObject != 0xFFFFFFFFUL) ? 1 : 0); 536 633 dprintf((" %-3d addr=0x%08lx off=0x%08lx %s\n", 537 634 j, aImportTab[j].ulAddress, aImportTab[j].offObject, … … 550 647 551 648 /* not found */ 552 return 1;649 return ERROR_PROB_SYMDB_KRNL_NOT_FOUND; 553 650 } 554 651 #endif /* !EXTRACT */ 652 555 653 556 654 /** … … 574 672 rc = DosDevIOCtl("", "", D16_IOCTL_VERIFYIMPORTTAB, D16_IOCTL_CAT, hDev0); 575 673 DosClose(hDev0); 674 if (rc != NO_ERROR) 675 { 676 register APIRET rc2 = rc & STECODE; 677 if (rc2 >= ERROR_D32_VERIFYIMPORTTAB_FIRST && rc2 <= ERROR_D32_VERIFYIMPORTTAB_LAST) 678 rc = rc2 + ERROR_PROB_SYM_VERIFY_FIRST - ERROR_D32_VERIFYIMPORTTAB_FIRST; 679 } 680 } 681 else 682 { 683 dprintf(("DosOpen Failed with rc=%d\n", rc)); 684 DosSleep(2000); 576 685 } 577 686 … … 616 725 { 617 726 dprintf(("Error opening file %s\n", pszFilename)); 618 return -50;727 return ERROR_PROB_SYM_FILE_NOT_FOUND; 619 728 } 620 729 dprintf(("\nSuccessfully opened symbolfile: %s\n", pszFilename)); … … 629 738 { /* oops! read failed, close file and fail. */ 630 739 fclose(hSym); 631 return -51;740 return ERROR_PROB_SYM_READERROR; 632 741 } 633 742 achBuffer[0] = MapDef.achModName[0]; … … 646 755 dprintf(("Modulename verify failed\n")); 647 756 fclose(hSym); 648 return -51;757 return ERROR_PROB_SYM_INVALID_MOD_NAME; 649 758 } 650 759 … … 658 767 dprintf(("Segment No. verify failed\n")); 659 768 fclose(hSym); 660 return -52;769 return ERROR_PROB_SYM_SEGS_NE_OBJS; 661 770 } 662 771 #endif /* !EXTRACT */ … … 701 810 { /* Failed to seek to the segment definition, fail! */ 702 811 fclose(hSym); 703 return -53;812 return ERROR_PROB_SYM_SEG_DEF_SEEK; 704 813 } 705 814 rc = fread(&SegDef, sizeof(SEGDEF), 1, hSym); … … 707 816 { /* Failed to read the segment definition, fail! */ 708 817 fclose(hSym); 709 return -53;818 return ERROR_PROB_SYM_SEG_DEF_READ; 710 819 } 711 820 … … 731 840 for (iSym = 0; iSym < SegDef.cSymbols && cLeftToFind; iSym++) 732 841 { 842 IMPORTKRNLSYM * pImport; 733 843 unsigned cchName; 844 734 845 /* 735 846 * Fileoffset of the current symbol. … … 784 895 * Search proctable. 785 896 */ 786 for (i = 0 ; i < NBR_OF_KRNLIMPORTS; i++)897 for (i = 0, pImport = &aImportTab[0]; i < NBR_OF_KRNLIMPORTS; i++, pImport++) 787 898 { 788 if (!aImportTab[i].fFound /* Not allready found */ 789 && (aImportTab[i].fType & EPT_BIT_MASK) == fSegEPTBitType /* Equal bittype */ 790 && (fCode || (aImportTab[i].fType & EPT_VARIMPORT)) /* Don't look for code in a data segment and vice versa */ 791 && aImportTab[i].cchName == cchName /* Equal name length */ 792 && kstrncmp(aImportTab[i].achName, achBuffer, cchName) == 0 /* Equal name */ 899 if (!pImport->fFound /* Not allready found */ 900 && (pImport->fType & EPT_VARIMPORT ? !fCode : fCode) /* Don't look for code in a data segment */ 901 && pImport->cchName == cchName /* Equal name length */ 902 && kstrncmp(pImport->achName, achBuffer, cchName) == 0 /* Equal name */ 793 903 ) 794 904 { /* Symbol was found */ 795 aImportTab[i].offObject = (SegDef.bFlags & 0x01 ? SymDef32.wSymVal : SymDef16.wSymVal);796 aImportTab[i].ulAddress = aImportTab[i].offObject + paKrnlOTEs[iSeg].ote_base;797 aImportTab[i].iObject = (unsigned char)iSeg;798 aImportTab[i].usSel = paKrnlOTEs[iSeg].ote_sel;905 pImport->offObject = (SegDef.bFlags & 0x01 ? SymDef32.wSymVal : SymDef16.wSymVal); 906 pImport->ulAddress = pImport->offObject + paKrnlOTEs[iSeg].ote_base; 907 pImport->iObject = (unsigned char)iSeg; 908 pImport->usSel = paKrnlOTEs[iSeg].ote_sel; 799 909 dprintf(("debug: base=%lx, size=%lx iSeg=%d\n", paKrnlOTEs[iSeg].ote_base, paKrnlOTEs[iSeg].ote_size, iSeg)); 800 910 801 911 /* Paranoia test! */ 802 912 #ifndef EXTRACT 803 if ( aImportTab[i].offObject < paKrnlOTEs[iSeg].ote_size)913 if (pImport->offObject < paKrnlOTEs[iSeg].ote_size) 804 914 { 805 aImportTab[i].fFound = TRUE;915 pImport->fFound = TRUE; 806 916 cLeftToFind--; 807 917 dprintf(("Found: %s at off 0x%lx addr 0x%lx, sel=0x%x\n", 808 aImportTab[i].achName, aImportTab[i].offObject,809 aImportTab[i].ulAddress, aImportTab[i].usSel));918 pImport->achName, pImport->offObject, 919 pImport->ulAddress, pImport->usSel)); 810 920 } 811 921 else/* test failed, continue on next symbol*/ 812 dprintf(("Error: Paranoia test failed for %s\n", aImportTab[i].achName));;922 dprintf(("Error: Paranoia test failed for %s\n", pImport->achName));; 813 923 #else 814 aImportTab[i].fFound = TRUE;924 pImport->fFound = TRUE; 815 925 cLeftToFind--; 816 926 #endif /* !EXTRACT */ … … 832 942 * If not all procedures were found fail. 833 943 */ 834 if (cLeftToFind != 0) 835 return -57; 944 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 945 if (!aImportTab[i].fFound && !(aImportTab[i].fType & EPT_NOT_REQ)) 946 return ERROR_PROB_SYM_IMPORTS_NOTFOUND; 836 947 837 948 /* … … 843 954 844 955 /** 845 * Gets the os/2 kernel OTE's (object table entries). 846 * @returns 0 on success. Not 0 on error. 956 * Get kernelinformation (OTEs (object table entries), build, type, debug...) 957 * @returns 0 on success. 958 * options.ulBuild, fchType, fDebug, cObjects and paKrnlOTEs is set on successful return. 959 * Not 0 on error. 847 960 */ 848 961 static int GetKernelInfo(void) 849 962 { 850 #if !defined(DEBUGR3) && !defined(EXTRACT) /* IOCtlnot available after inittime! */851 static KRNLINFO KrnlInfo = {0};963 #if !defined(DEBUGR3) && !defined(EXTRACT) /* This IOCtl is not available after inittime! */ 964 static KRNLINFO DATA16_INIT KrnlInfo = {0}; 852 965 APIRET rc; 853 966 HFILE hDev0 = 0; 854 967 USHORT usAction = 0; 855 968 969 /* 970 * Issue an IOCtl to elf$ to query kernel information. 971 */ 856 972 rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL, 857 973 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, … … 863 979 if (rc == NO_ERROR) 864 980 { 865 int i;866 867 /* Set the exported parameters */868 usBuild = KrnlInfo.usBuild;869 fchType = KrnlInfo.fchType;870 fDebug = KrnlInfo.fDebug;871 cObjects = KrnlInfo.cObjects;872 paKrnlOTEs = &KrnlInfo.aObjects[0];873 981 #ifdef DEBUG 874 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 982 unsigned i; 983 #endif 984 985 /* 986 * Set the exported parameters 987 */ 988 options.ulBuild = KrnlInfo.ulBuild; 989 options.fKernel = KrnlInfo.fKernel; 990 cObjects = KrnlInfo.cObjects; 991 paKrnlOTEs = &KrnlInfo.aObjects[0]; 992 993 /* 994 * If debugging probkrnl dump kernel OTEs. 995 */ 996 #ifdef DEBUG 997 dprintf(("debug: kernel OTE:\n")); 998 for (i = 0; i < cObjects; i++) 875 999 dprintf(("debug: no.%2d base=%lx size=%lx sel=%x\n", 876 1000 i, … … 879 1003 paKrnlOTEs[i].ote_sel)); 880 1004 #endif 881 882 1005 } 883 1006 DosClose(hDev0); … … 885 1008 886 1009 if (rc != NO_ERROR) 887 printf16("Failed to get kernel OTEs \r\n");1010 printf16("Failed to get kernel OTEs. rc=%d\n", rc); 888 1011 889 1012 return rc; … … 899 1022 { 900 1023 rc = ReadOS2Krnl(szUsrOS2Krnl); 901 if (rc != 0)1024 if (rc != NO_ERROR) 902 1025 { 903 p uts("Warning: Invalid kernel file specified. Tries defaults.\n\r");1026 printf16("Warning: Invalid kernel file specified. Tries defaults.\n"); 904 1027 szUsrOS2Krnl[0] = '\0'; 905 1028 rc = ReadOS2Krnl(szOS2Krnl); … … 918 1041 /** 919 1042 * Shows result of kernelprobing if not quiet or on error. 920 * @param rcReturn code.921 * @param iSymindex of .sym-file into static struct.1043 * @param rc Return code. 1044 * @param iSym index of .sym-file into static struct. 922 1045 */ 923 1046 #ifndef EXTRACT … … 929 1052 * Complain even if quiet on error 930 1053 */ 931 if (! fQuiet || rc != 0)1054 if (!options.fQuiet || rc != NO_ERROR) 932 1055 { 933 1056 printf16("Win32k - Odin32 support driver.\n"); … … 936 1059 * kernel stuff 937 1060 */ 938 if (rc <= -50 || rc == 0)1061 if (rc == NO_ERROR || rc > ERROR_PROB_KRNL_LAST) 939 1062 { 940 1063 #ifdef DEBUGR3 941 1064 printf16(" Found kernel: %s\n", szOS2Krnl); 942 1065 #endif 943 printf16(" Build: %d - v%d.%d\n", 944 usBuild, usVerMajor, usVerMinor); 945 } 1066 printf16(" Build: %ld - v%d.%d\n", 1067 options.ulBuild, options.usVerMajor, options.usVerMinor); 1068 } 1069 else if (rc >= ERROR_PROB_KRNL_FIRST) 1070 printf16(" Kernel probing failed with rc=%d.\n", rc); 946 1071 else 947 printf16(" Kernel probing failed with rc=%d.\n", rc);1072 printf16(" Failed before probing kernel.\n"); 948 1073 949 1074 /* 950 1075 * symbol-file 951 1076 */ 952 if (rc == 0)1077 if (rc == NO_ERROR || (rc > ERROR_PROB_SYM_LAST && (szUsrSym[0] != '\0' || apszSym[iSym] != NULL))) 953 1078 printf16(" Found symbolfile: %s\n", 954 1079 szUsrSym[0] == '\0' ? apszSym[iSym] : szUsrSym); 1080 else if (rc >= ERROR_PROB_SYM_FIRST) 1081 printf16(" Failed to find symbolfile!\n"); 955 1082 else 956 printf16(" Failed to find symbolfile! rc=%d\n", rc);1083 printf16(" Failed before searching for symbolfile.\n"); 957 1084 958 1085 /* 959 1086 * function listing 960 1087 */ 961 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 962 { 963 printf16(" %-20s at ",aImportTab[i].achName); 964 if (aImportTab[i].fFound) 965 printf16("0x%08lx%s", aImportTab[i].ulAddress, (i % 2) == 0 ? "" : "\n"); 966 else 967 printf16("failed!%s", (i % 2) == 0 ? "" : "\n"); 968 } 969 if (i % 2) printf16("\n"); 1088 if (options.fLogging || rc != NO_ERROR) 1089 { 1090 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++) 1091 { 1092 printf16(" %-21s at ", aImportTab[i].achName); 1093 if (aImportTab[i].fFound) 1094 printf16("0x%08lx%s", aImportTab[i].ulAddress, (i % 2) == 0 ? "" : "\n"); 1095 else 1096 printf16("not found!%s", (i % 2) == 0 ? "" : "\n"); 1097 } 1098 if (i % 2) printf16("\n"); 1099 } 1100 1101 /* 1102 * Display error code. 1103 */ 1104 if (rc != NO_ERROR) 1105 { 1106 const char *psz = GetErrorMsg(rc); 1107 printf16("ProbeKernel failed with rc=%d.\n", rc); 1108 if (psz) printf16("%s\n", psz); 1109 } 970 1110 } 971 1111 } … … 1003 1143 switch (pReqPack->InitArgs[i]) 1004 1144 { 1145 #if defined(DEBUGR3) 1005 1146 case 'k': 1006 1147 case 'K': /* Kernel file */ … … 1008 1149 i += kargncpy(szUsrOS2Krnl, &pReqPack->InitArgs[i], sizeof(szUsrOS2Krnl)); 1009 1150 break; 1151 #endif 1010 1152 1011 1153 case 'n': 1012 1154 case 'N': /* NoLoader */ 1155 options.fNoLoader = TRUE; 1013 1156 return 0; 1014 1157 1015 1158 case 'q': 1016 1159 case 'Q': /* Quiet */ 1017 fQuiet = 1;1160 options.fQuiet = TRUE; 1018 1161 break; 1019 1162 … … 1021 1164 case 'S': /* Symbol file */ 1022 1165 i++; 1023 if (pReqPack->InitArgs[i] == 'Y' || pReqPack->InitArgs[i] == 'y') 1166 if ( pReqPack->InitArgs[i] != 'c' && pReqPack->InitArgs[i] != 'C' 1167 && pReqPack->InitArgs[i] != 'm' && pReqPack->InitArgs[i] != 'M' 1168 ) /* -script and -smp is ignored */ 1024 1169 i += kargncpy(szUsrSym, &pReqPack->InitArgs[i], sizeof(szUsrSym)); 1025 1170 break; … … 1027 1172 case 'v': 1028 1173 case 'V': /* Verbose */ 1029 fQuiet = 0;1174 options.fQuiet = FALSE; 1030 1175 break; 1031 1176 } … … 1044 1189 pGIS = MAKEPGINFOSEG(selGIS); 1045 1190 usBootDrive = pGIS->bootdrive; 1046 usVerMajor = pGIS->uchMajorVersion; 1047 usVerMinor = pGIS->uchMinorVersion; 1191 #ifndef R3TST 1192 options.usVerMajor = pGIS->uchMajorVersion; 1193 options.usVerMinor = pGIS->uchMinorVersion; 1194 #else 1195 if (usFakeVerMajor == 0) 1196 { 1197 usFakeVerMajor = pGIS->uchMajorVersion; 1198 usFakeVerMinor = pGIS->uchMinorVersion; 1199 } 1200 options.usVerMajor = usFakeVerMajor; 1201 options.usVerMinor = usFakeVerMinor; 1202 #endif 1048 1203 dprintf(("BootDrive: %d\n", usBootDrive)); 1049 1204 1050 1205 /* set driveletter in constants strings */ 1051 1206 usBootDrive = (char)usBootDrive + (char)'a' - 1; 1207 #if defined(DEBUGR3) 1052 1208 szOS2Krnl[0] = (char)usBootDrive; 1209 #endif 1053 1210 for (i = 0; apszSym[i] != NULL; i++) 1054 1211 apszSym[i][0] = (char)usBootDrive; … … 1058 1215 /*-----------------*/ 1059 1216 rc = GetKernelInfo(); 1060 if (rc != NO_ERROR)1061 return rc;1062 1217 1063 1218 /*--------------*/ … … 1072 1227 if (rc) 1073 1228 { 1074 p uts("Warning: Invalid symbol file specified. Tries defaults.\n\r");1229 printf16("Warning: Invalid symbol file specified. Tries defaults.\n"); 1075 1230 szUsrSym[0] = '\0'; 1076 1231 } 1077 1232 } 1078 if (rc != 0) /* if user sym failed or don't exists. */1233 if (rc != NO_ERROR) /* if user sym failed or don't exists. */ 1079 1234 { 1080 1235 /* 1081 1236 * Check database - only if not a debug kernel! 1082 1237 * You usually have a .sym-file when using a debug kernel. 1083 * (Currently I am not able to distinguish between half and all strict kernels...) 1238 * (This is because I am unable to distinguish between half and 1239 * all strict kernels...) 1084 1240 */ 1085 if (fDebug || 1086 (rc = LookupKrnlEntry((unsigned short)usBuild, 'R', fchType, cObjects)) != 0 1241 if ((options.fKernel & KF_DEBUG) || 1242 (rc = LookupKrnlEntry((unsigned short)options.ulBuild, 1243 (unsigned short)options.fKernel, 1244 cObjects) 1245 ) != NO_ERROR 1087 1246 ) 1088 1247 { 1248 #if 1 /* ndef R3TST */ 1249 APIRET rc2; 1089 1250 /* search on disk */ 1090 1251 i = 0; 1091 while (apszSym[i] != NULL && (rc = ProbeSymFile(apszSym[i])) != 0) 1252 while (apszSym[i] != NULL 1253 && (rc2 = ProbeSymFile(apszSym[i])) != NO_ERROR 1254 ) 1255 { 1092 1256 i++; 1257 if (rc2 >= ERROR_PROB_SYM_VERIFY_FIRST) 1258 rc = rc2; 1259 } 1260 if (rc == 1 || rc2 == NO_ERROR) 1261 rc = rc2; 1262 #endif 1093 1263 } 1094 1264 } … … 1099 1269 ShowResult(rc, i); 1100 1270 1271 /* Copy the symbol file name to szUsrSym. */ 1272 if (szUsrSym[0] == '\0' && apszSym[i] != NULL) 1273 kstrcpy(szUsrSym, apszSym[i]); 1274 1101 1275 return rc; 1102 1276 } … … 1113 1287 int VerMinor, VerMajor; 1114 1288 1115 VerMajor = usBuild < 20000 ? 20 : 30/*?*/;1116 VerMinor = usBuild < 6600 ? 10 : usBuild < 8000 ? 11 : usBuild < 9000 ? 30 :1117 usBuild < 10000 ? 40 : usBuild < 15000 ? 45 : 50;1118 1119 return VerMajor - (int) usVerMajor | VerMinor - (int)usVerMinor;1289 VerMajor = options.ulBuild < 20000 ? 20 : 30/*?*/; 1290 VerMinor = options.ulBuild < 6600 ? 10 : options.ulBuild < 8000 ? 11 : options.ulBuild < 9000 ? 30 : 1291 options.ulBuild < 10000 ? 40 : options.ulBuild < 15000 ? 45 : 50; 1292 1293 return VerMajor - (int)options.usVerMajor | VerMinor - (int)options.usVerMinor; 1120 1294 } 1121 1295 … … 1123 1297 /** 1124 1298 * Reads and verifies OS/2 kernel. 1125 * @returns 0 on success, not 0 on failure. 1126 * @param filename Filename of the OS/2 kernel. 1127 * @result usBuild is set. 1299 * @returns 0 on success. 1300 * One of the ERROR_PROB_KRNL_* defines on error. 1301 * @param pszFilename Filename of the OS/2 kernel. 1302 * @result options.ulBuild is set. 1128 1303 * @remark This step will be eliminated by searching thru the DOSGROUP datasegment 1129 1304 * in the kernel memory. This segment have a string "Internal revision 9.034[smp|uni]" … … 1140 1315 if (hKrnl != 0) 1141 1316 { 1317 /* 1318 * Get size of kernel file. 1319 */ 1142 1320 cbKrnl = fsize(hKrnl); 1143 1321 if (!fseek(hKrnl, 0, SEEK_SET)) 1322 { 1323 /* 1324 * Call worker with filehandle and size. 1325 */ 1144 1326 rc = ReadOS2Krnl2(hKrnl, cbKrnl); 1327 } 1145 1328 else 1146 rc = -2;1329 rc = ERROR_PROB_KRNL_SEEK_SIZE; 1147 1330 fclose(hKrnl); 1148 1331 } … … 1150 1333 { 1151 1334 dprintf(("Could not open file\n")); 1152 rc = -1;1335 rc = ERROR_PROB_KRNL_OPEN_FAILED; 1153 1336 } 1154 1337 return rc; … … 1159 1342 * Worker function for ReadOS2Krnl 1160 1343 * @returns 0 on success. 1161 * errorcodes on failure. (-1 >= rc >= -14)1344 * One of the ERROR_PROB_KRNL_* defines on error. 1162 1345 * @param hKrnl Handle to the kernel file. 1163 1346 * @param cbKrnl Size of the kernel file. … … 1167 1350 { 1168 1351 #if defined(DEBUGR3) || !defined(EXTRACT) 1169 static KRNLINFO KrnlInfo = {0};1352 static KRNLINFO DATA16_INIT KrnlInfo = {0}; 1170 1353 #endif 1171 1354 int i, j; … … 1176 1359 1177 1360 1178 /* find bldlevel string - "@#IBM:14.020#@ IBM OS/2 Kernel - 14.020F" */ 1361 /* 1362 * Find bldlevel string - for example: "@#IBM:14.020#@ IBM OS/2 Kernel - 14.020F" 1363 * Searching the entire file lineary from the start. 1364 */ 1179 1365 if (fseek(hKrnl, 0, SEEK_SET)) 1180 return -2;1366 return ERROR_PROB_KRNL_SEEK_FIRST; 1181 1367 1182 1368 if (!fread(&achBuffer[KERNEL_ID_STRING_LENGTH], 1, KERNEL_READ_SIZE, hKrnl)) 1183 return -3;1369 return ERROR_PROB_KRNL_READ_FIRST; 1184 1370 1185 1371 i = KERNEL_ID_STRING_LENGTH; … … 1191 1377 kmemcpy(achBuffer, &achBuffer[KERNEL_READ_SIZE], KERNEL_ID_STRING_LENGTH); 1192 1378 if (!fread(&achBuffer[KERNEL_ID_STRING_LENGTH], 1, cbKrnl > KERNEL_READ_SIZE ? KERNEL_READ_SIZE : (int)cbKrnl, hKrnl)) 1193 return -3;1379 return ERROR_PROB_KRNL_READ_NEXT; 1194 1380 1195 1381 i = 0; … … 1204 1390 } 1205 1391 1392 /* found it? */ 1206 1393 if (cbKrnl == 0) 1207 1394 { 1208 1395 fclose(hKrnl); 1209 return -4; 1210 } 1396 return ERROR_PROB_KRNL_TAG_NOT_FOUND; 1397 } 1398 1399 1400 /* 1401 * We've found the @#IBM: tag. So now we'll try read it. 1402 */ 1211 1403 1212 1404 /* displacement */ … … 1217 1409 /* verify signature */ 1218 1410 if (kstrncmp(&achBuffer[i+10+j], "#@ IBM OS/2 Kernel", 19) != 0) 1219 return -5; 1220 1221 /* read usBuild */ 1222 usBuild = (char)(achBuffer[i+6] - '0') * 1000; 1411 return ERROR_PROB_KRNL_INV_SIGANTURE; 1412 1413 /* 1414 * read options.ulBuild 1415 */ 1416 options.ulBuild = (char)(achBuffer[i+6] - '0') * 1000; 1223 1417 if (achBuffer[i+7] != '.') 1224 1418 { 1225 1419 /* this code is for Warp5 */ 1226 usBuild *= 10;1227 usBuild += (char)(achBuffer[i+7] - '0') * 1000;1420 options.ulBuild *= 10; 1421 options.ulBuild += (char)(achBuffer[i+7] - '0') * 1000; 1228 1422 i++; 1229 1423 j--; 1230 1424 if (achBuffer[i+7] != '.') 1231 1425 { 1232 usBuild = usBuild *10;1233 usBuild = usBuild + (unsigned short)(achBuffer[i+7] - '0') * 1000;1426 options.ulBuild *= 10; 1427 options.ulBuild += (unsigned long)(achBuffer[i+7] - '0') * 1000; 1234 1428 i++; 1235 1429 j--; … … 1239 1433 if (j == 0) 1240 1434 { 1241 usBuild += (achBuffer[i+ 8] - '0') * 10;1242 usBuild += (achBuffer[i+ 9] - '0') * 1;1435 options.ulBuild += (achBuffer[i+ 8] - '0') * 10; 1436 options.ulBuild += (achBuffer[i+ 9] - '0') * 1; 1243 1437 } 1244 1438 else 1245 1439 { 1246 1440 if (j == 3) 1247 return -9; 1248 usBuild += (achBuffer[i+ 8] - '0') * 100; 1249 usBuild += (achBuffer[i+ 9] - '0') * 10; 1250 usBuild += (achBuffer[i+10] - '0'); 1251 } 1252 1441 return ERROR_PROB_KRNL_INV_BUILD_NBR; 1442 options.ulBuild += (achBuffer[i+ 8] - '0') * 100; 1443 options.ulBuild += (achBuffer[i+ 9] - '0') * 10; 1444 options.ulBuild += (achBuffer[i+10] - '0'); 1445 } 1446 1447 /* 1448 * We've read the build number. Let's check that it matches the OS/2 1449 * version reported by DosGetInfoSeg. 1450 */ 1253 1451 if (VerifyKernelVer()) 1254 return -9;1255 dprintf((" usBuild: %d\n", usBuild));1452 return ERROR_PROB_KRNL_BUILD_VERSION; 1453 dprintf(("options.ulBuild: %d\n", options.ulBuild)); 1256 1454 1257 1455 /* get segment number */ 1258 1456 /* read-MZheader */ 1259 1457 if (fseek(hKrnl,0,SEEK_SET)) 1260 return -2;1458 return ERROR_PROB_KRNL_MZ_SEEK; 1261 1459 1262 1460 if (!fread(achBuffer, 1, 0x40, hKrnl)) 1263 return -3;1461 return ERROR_PROB_KRNL_MZ_READ; 1264 1462 1265 1463 offLXHdr = *(unsigned long int *)&achBuffer[0x3c]; 1266 1464 1267 1465 if (offLXHdr > 0x2000 && offLXHdr < 0x80) /* just to detect garbage */ 1268 return -6;1466 return ERROR_PROB_KRNL_NEOFF_INVALID; 1269 1467 1270 1468 if (fseek(hKrnl, offLXHdr, SEEK_SET)) 1271 return -2;1469 return ERROR_PROB_KRNL_NEOFF_SEEK; 1272 1470 1273 1471 if (!fread(achBuffer, 1, sizeof(struct e32_exe), hKrnl)) 1274 return -3;1472 return ERROR_PROB_KRNL_LX_READ; 1275 1473 1276 1474 /* check LX-magic */ 1277 1475 if (achBuffer[0] != 'L' || achBuffer[1] != 'X') 1278 return -7;1476 return ERROR_PROB_KRNL_LX_SIGNATURE; 1279 1477 1280 1478 #if !defined(DEBUGR3) && !defined(EXTRACT) … … 1282 1480 pLXHdr = (struct e32_exe *)achBuffer; 1283 1481 if ((UCHAR)pLXHdr->e32_objcnt != cObjects) 1284 return -8;1482 return ERROR_PROB_KRNL_OBJECT_CNT; 1285 1483 1286 1484 if (pLXHdr->e32_objcnt < 10) 1287 return -9;1288 1289 /* check objects (sizes and flags(?))*/1485 return ERROR_PROB_KRNL_OBJECT_CNR_10; 1486 1487 /* check objects sizes. */ 1290 1488 if (!fseek(hKrnl, (LONG)offLXHdr + (LONG)pLXHdr->e32_objtab, SEEK_SET)) 1291 1489 { … … 1294 1492 { 1295 1493 if (!fread(achBuffer, 1, sizeof(OTE), hKrnl)) 1296 return -11;1494 return ERROR_PROB_KRNL_OTE_READ; 1297 1495 if (pObj->o32_size < paKrnlOTEs[i].ote_size) 1298 return -12; 1299 1300 #if 0 /* don't work! */ 1301 if ((pObj->o32_flags & 0xffffUL) != (paKrnlOTEs[i].ote_flags & 0xffffUL)) 1302 return -14; 1303 #endif 1496 return ERROR_PROB_KRNL_OTE_SIZE_MIS; 1304 1497 } 1305 1498 } 1306 1499 else 1307 return -10;1500 return ERROR_PROB_KRNL_OTE_SEEK; 1308 1501 #else 1309 1502 /* Since we can't get the OTEs from the kernel when debugging in RING-3, … … 1322 1515 for (i = 0; i < (int)cObjects; i++) 1323 1516 if (!fread(&paKrnlOTEs[i], 1, sizeof(struct o32_obj), hKrnl)) 1324 return -11;1517 return ERROR_PROB_KRNL_OTE_READ; 1325 1518 } 1326 1519 else 1327 return -10;1520 return ERROR_PROB_KRNL_OTE_SEEK; 1328 1521 #endif 1329 1522 1330 return 0;1523 return NO_ERROR; 1331 1524 } 1332 1525 … … 1370 1563 * Where: n - are the build number 4 or 5 digits. 1371 1564 * t - kernel type. R = retail, H = half strict, A = all strict. 1372 * m - UNI or SMP. U = UNI processor kernel. S = SMP processor kernel. 1565 * m - UNI or SMP. U = UNI processor kernel. S = SMP processor kernel. 4 = Warp 4 FP13+ 1373 1566 * @returns NO_ERROR on success. Untracable error code on error. 1374 1567 * @param pszFilename Pointer to read only filename of the .sym-file. … … 1381 1574 APIRET rc; 1382 1575 int cch = kstrlen(pszFilename); 1576 1577 DosWrite(2, (char*)pszFilename, cch, &rc); 1578 DosWrite(2, "\r\n", 2, &rc); 1383 1579 1384 1580 /* Filename check */ … … 1397 1593 } 1398 1594 1399 /** @remark1400 * All a/h-strict files are currently ignored.1401 * When a debug kernel is used we'll have to use the1402 * .sym-file for it. This is so because I can't distinguish1403 * between a all-strick and a half-strick kernel (yet).1404 */1405 if (pszFilename[cch-6] != 'R')1406 return 0;1407 1408 1595 /* 1409 1596 * Probe kernelfile … … 1419 1606 int i; 1420 1607 1608 /** @remark 1609 * Currently information for retail kernels are usable, but we'll 1610 * generate it for the debug kernels too, but this information 1611 * is enclaved within an "#ifdef ALLKERNELS ... #endif". 1612 */ 1613 if (pszFilename[cch-6] != 'R') 1614 printf16("#ifdef ALLKERNELS\n"); 1615 1421 1616 printf16(" { /* %s */\n" 1422 " %.*s, \'%c\', %s, %d,\n" 1617 " %.*s, ", 1618 pszFilename, 1619 cch - 6, &pszFilename[0] /* build number */ 1620 ); 1621 1622 switch (pszFilename[cch - 5]) 1623 { 1624 case 'S': printf16("KF_SMP"); break; 1625 case '4': printf16("KF_UNI | KF_W4"); break; 1626 case 'U': printf16("KF_UNI"); break; 1627 } 1628 switch (pszFilename[cch - 6]) 1629 { 1630 case 'A': printf16(" | KF_ALLSTRICT"); break; 1631 case 'H': printf16(" | KF_HALFSTRICT"); break; 1632 } 1633 printf16(", %d,\n" 1423 1634 " {\n", 1424 pszFilename,1425 cch - 6, &pszFilename[0], /* build number */1426 pszFilename[cch - 6], /* Type, A=astrict, H=halfstrict, R=Retail */1427 pszFilename[cch - 5] == 'S' ? /* UNI: TYPE_UNI SMP: TYPE_SMP W4: TYPE_W4 */1428 "TYPE_SMP" : pszFilename[cch - 5] == '4' ? "TYPE_W4" : "TYPE_UNI",1429 1635 aImportTab[0].iObject + 1); /* ASSUMES that DOSCODE32 is the last object. */ 1430 1636 … … 1432 1638 { 1433 1639 char *psz = aImportTab[i].achName; 1434 printf16(" {% 2d, 0x%08lx}, /* %s */\n",1640 printf16(" {%-2d, 0x%08lx}, /* %s */\n", 1435 1641 aImportTab[i].iObject, 1436 aImportTab[i]. offObject,1642 aImportTab[i].fFound ? aImportTab[i].offObject : 0xFFFFFFFFUL, 1437 1643 (char *)&aImportTab[i].achName[0] 1438 1644 ); … … 1440 1646 printf16(" }\n" 1441 1647 " },\n"); 1648 1649 /** @remark 1650 * Currently information for retail kernels are usable, but we'll 1651 * generate it for the debug kernels too, but this information 1652 * is enclaved within an "#ifdef ALLKERNELS ... #endif". 1653 */ 1654 if (pszFilename[cch-6] != 'R') 1655 printf16("#endif\n"); 1442 1656 } 1443 1657 else … … 1460 1674 { 1461 1675 APIRET rc; 1462 1676 const char * psz; 1463 1677 1464 1678 /* 1465 1679 * Set paKrnlOTEs to point to an zeroed array of OTEs. 1466 1680 */ 1467 static KRNLINFO KrnlInfo = {0};1681 static KRNLINFO DATA16_INIT KrnlInfo = {0}; 1468 1682 paKrnlOTEs = &KrnlInfo.aObjects[0]; 1469 1683 … … 1474 1688 */ 1475 1689 int i; 1476 for (i = 0; i < argc; i++)1690 for (i = 1; i < argc; i++) 1477 1691 { 1478 1692 rc = processFile(argv[i]); … … 1480 1694 { 1481 1695 printf16("processFile failed with rc=%d for file %s\n", 1482 rc, argv[i]); 1696 rc, argv[i]); 1697 if (psz = GetErrorMsg(rc)) 1698 printf16("%s\n", psz); 1483 1699 return rc; 1484 1700 } … … 1498 1714 int i; 1499 1715 1500 printf16("/* $Id: probkrnl.c,v 1.2 0 2000-04-17 01:56:48bird Exp $\n"1716 printf16("/* $Id: probkrnl.c,v 1.21 2000-09-02 21:07:56 bird Exp $\n" 1501 1717 "*\n" 1502 1718 "* Autogenerated kernel symbol database.\n" … … 1512 1728 "#define INCL_NOBASEAPI\n" 1513 1729 "#include <os2.h>\n" 1730 "#include \"DevSegDf.h\"\n" 1514 1731 "#include \"probkrnl.h\"\n" 1732 "#include \"options.h\"\n" 1515 1733 "\n"); 1516 1734 1517 printf16("KRNLDBENTRY aKrnlSymDB[] = \n"1735 printf16("KRNLDBENTRY DATA16_INIT aKrnlSymDB[] = \n" 1518 1736 "{\n"); 1519 1737 … … 1528 1746 printf16("processFile failed with rc=%d for file %s\n", 1529 1747 rc, &ffb.achName[0]); 1748 if (psz = GetErrorMsg(rc)) 1749 printf16("%s\n", psz); 1530 1750 return rc; 1531 1751 } … … 1537 1757 1538 1758 printf16(" { /* Terminating entry */\n" 1539 " 0,0,0, 0,\n"1759 " 0,0,0,\n" 1540 1760 " {\n"); 1541 1761 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
Note:
See TracChangeset
for help on using the changeset viewer.
