Ignore:
Timestamp:
Sep 2, 2000, 11:08:23 PM (25 years ago)
Author:
bird
Message:

Merged in the Grace branch. New Win32k!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/dev16/probkrnl.c

    r3411 r4164  
    1 /* $Id: probkrnl.c,v 1.20 2000-04-17 01:56:48 bird Exp $
     1/* $Id: probkrnl.c,v 1.21 2000-09-02 21:07:56 bird Exp $
    22 *
    33 * Description:   Autoprobes the os2krnl file and os2krnl[*].sym files.
     
    1414 *                How this works:
    1515 *                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.
    1920 *                5. the entry points are verified. (elf$)
    2021 *                6. finished.
    2122 *
    22  * Copyright (c) 1998-2000 knut st. osmundsen
     23 * Copyright (c) 1998-2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    2324 *
    2425 * Project Odin Software License can be found in LICENSE.TXT
     
    5152#define INCL_NOPMAPI
    5253
    53 
    5454/*******************************************************************************
    5555*   Header Files                                                               *
     
    6161#include <reqpkt.h>
    6262
     63#include "devSegDf.h"
     64#undef  DATA16_INIT
     65#define DATA16_INIT
     66#undef  CODE16_INIT
     67#define CODE16_INIT
    6368#include "os2krnl.h"                    /* must be included before dev1632.h! */
    6469#include "sym.h"
     
    6873#include "vprntf16.h"
    6974#include "log.h"
    70 
     75#include "options.h"
     76#include "errors.h"
    7177
    7278/*******************************************************************************
     
    7480*   Note: must be inited or else we'll get BSS segment                         *
    7581*******************************************************************************/
    76 /*
    77  * kernel data - !only valid during init!
    78  */
     82
    7983
    8084/*
    8185 * 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 */
     91IMPORTKRNLSYM DATA16_GLOBAL aImportTab[NBR_OF_KRNLIMPORTS] =
    8792{/* iFound     cchName                  offObject    usSel     fType    */
    8893 /*      iObject      achName                 ulAddress  cProlog        */
     
    101106    {FALSE, -1, 11, "_VMGetOwner",          -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 12 */
    102107    {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
    108137};
    109138
    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;
     139char DATA16_GLOBAL  szUsrSym[50] = {0};
     140
    115141
    116142
     
    118144 * privat data
    119145 */
    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)
     147static char     DATA16_INIT szUsrOS2Krnl[50] = {0};
     148static char     DATA16_INIT szOS2Krnl[]      = {"c:\\os2krnl"};
     149#endif
     150static char *   DATA16_INIT apszSym[]        =
    126151{
    127152    {"c:\\os2krnl.sym"},                              /* usual for debugkernel */
     
    144169
    145170/* Result from GetKernelInfo/ReadOS2Krnl. */
    146 static unsigned char  cObjects = 0;
    147 static POTE           paKrnlOTEs = NULL;
    148 
     171static unsigned char DATA16_INIT  cObjects = 0;
     172static POTE          DATA16_INIT  paKrnlOTEs = NULL;
     173
     174
     175/*
     176 *
     177 */
     178static 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
     228USHORT DATA16_INIT usFakeVerMajor = 0;
     229USHORT DATA16_INIT usFakeVerMinor = 0;
     230#ifdef R3TST
     231static DATA16_INIT ach[11] =  {0}; /* works around compiler/linker bug */
     232#endif
     233#endif
    149234
    150235
     
    157242static int      fseek(HFILE hfile, signed long off, int iOrg);
    158243static unsigned long fsize(HFILE hFile);
    159 static void     puts(char *psz);
    160 
    161 /* C-library replacements. */
     244
     245/* C-library replacements and additions. */
    162246static void     kmemcpy(char *psz1, const char *psz2, int cch);
    163247static char *   kstrstr(const char *psz1, const char *psz2);
     
    169253static int      kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen);
    170254
     255static const char * GetErrorMsg(short sErr);
     256
    171257/* Workers */
    172 static int      LookupKrnlEntry(unsigned uBuild, unsigned char chType,
    173                                 unsigned char fchType, unsigned char cObjects);
     258static int      LookupKrnlEntry(unsigned short usBuild, unsigned short fKernel, unsigned char cObjects);
    174259static int      VerifyPrologs(void);
    175260static int      ProbeSymFile(const char *pszFilename);
     
    177262
    178263/* Ouput */
    179 static void     ShowDecNumber(unsigned long ul);
    180 static void     ShowHexNumber(unsigned long ul);
    181264static void     ShowResult(int rc, int iSym);
    182265
     
    187270static int      processFile(const char *pszFilename);
    188271
     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
    189280
    190281
     
    277368
    278369/**
    279  * puts lookalike
    280  */
    281 static void puts(char * psz)
    282 {
    283     DosPutMessage(0, kstrlen(psz), psz);
    284 }
    285 
    286 
    287 /**
    288370 * kmemcpy - memory copy - slow!
    289371 * @param     psz1  target
     
    421503    while (*pszSource != '\0')
    422504        *psz++ = *pszSource++;
    423 
     505    *psz = '\0';
    424506    return pszTarget;
    425507}
     
    478560
    479561    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 */
     572static 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;
    480581}
    481582
     
    493594 *            1 if not found.
    494595 *            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)
    500598 * @param     cObjects      Count of object in the running kernel.
    501599 * @sketch    Loop thru the table.
     
    503601 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
    504602 */
    505 static int LookupKrnlEntry(unsigned uBuild, unsigned char fchBldType, unsigned char fchType, unsigned char cObjects)
     603static int LookupKrnlEntry(unsigned short usBuild, unsigned short fKernel, unsigned char cObjects)
    506604{
    507605    int i;
     
    512610    for (i = 0; aKrnlSymDB[i].usBuild != 0; i++)
    513611    {
    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)
    518615        {   /* found matching entry! */
    519616            int j;
     
    533630                                           + pEntry->aSyms[j].offObject;
    534631                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);
    536633                dprintf(("  %-3d addr=0x%08lx off=0x%08lx  %s\n",
    537634                         j, aImportTab[j].ulAddress, aImportTab[j].offObject,
     
    550647
    551648    /* not found */
    552     return 1;
     649    return ERROR_PROB_SYMDB_KRNL_NOT_FOUND;
    553650}
    554651#endif /* !EXTRACT */
     652
    555653
    556654/**
     
    574672        rc = DosDevIOCtl("", "", D16_IOCTL_VERIFYIMPORTTAB, D16_IOCTL_CAT, hDev0);
    575673        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);
    576685    }
    577686
     
    616725    {
    617726        dprintf(("Error opening file %s\n", pszFilename));
    618         return -50;
     727        return ERROR_PROB_SYM_FILE_NOT_FOUND;
    619728    }
    620729    dprintf(("\nSuccessfully opened symbolfile: %s\n", pszFilename));
     
    629738    {   /* oops! read failed, close file and fail. */
    630739        fclose(hSym);
    631         return -51;
     740        return ERROR_PROB_SYM_READERROR;
    632741    }
    633742    achBuffer[0] = MapDef.achModName[0];
     
    646755        dprintf(("Modulename verify failed\n"));
    647756        fclose(hSym);
    648         return -51;
     757        return ERROR_PROB_SYM_INVALID_MOD_NAME;
    649758    }
    650759
     
    658767        dprintf(("Segment No. verify failed\n"));
    659768        fclose(hSym);
    660         return -52;
     769        return ERROR_PROB_SYM_SEGS_NE_OBJS;
    661770    }
    662771    #endif /* !EXTRACT */
     
    701810        {   /* Failed to seek to the segment definition, fail! */
    702811            fclose(hSym);
    703             return -53;
     812            return ERROR_PROB_SYM_SEG_DEF_SEEK;
    704813        }
    705814        rc = fread(&SegDef, sizeof(SEGDEF), 1, hSym);
     
    707816        {   /* Failed to read the segment definition, fail! */
    708817            fclose(hSym);
    709             return -53;
     818            return ERROR_PROB_SYM_SEG_DEF_READ;
    710819        }
    711820
     
    731840        for (iSym = 0; iSym < SegDef.cSymbols && cLeftToFind; iSym++)
    732841        {
     842            IMPORTKRNLSYM * pImport;
    733843            unsigned cchName;
     844
    734845            /*
    735846             * Fileoffset of the current symbol.
     
    784895             * Search proctable.
    785896             */
    786             for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
     897            for (i = 0, pImport = &aImportTab[0]; i < NBR_OF_KRNLIMPORTS; i++, pImport++)
    787898            {
    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 */
    793903                    )
    794904                {   /* 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;
    799909                    dprintf(("debug: base=%lx, size=%lx iSeg=%d\n", paKrnlOTEs[iSeg].ote_base, paKrnlOTEs[iSeg].ote_size, iSeg));
    800910
    801911                    /* Paranoia test! */
    802912                    #ifndef EXTRACT
    803                     if (aImportTab[i].offObject < paKrnlOTEs[iSeg].ote_size)
     913                    if (pImport->offObject < paKrnlOTEs[iSeg].ote_size)
    804914                    {
    805                         aImportTab[i].fFound = TRUE;
     915                        pImport->fFound = TRUE;
    806916                        cLeftToFind--;
    807917                        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));
    810920                    }
    811921                    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));;
    813923                    #else
    814                     aImportTab[i].fFound = TRUE;
     924                    pImport->fFound = TRUE;
    815925                    cLeftToFind--;
    816926                    #endif /* !EXTRACT */
     
    832942     * If not all procedures were found fail.
    833943     */
    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;
    836947
    837948    /*
     
    843954
    844955/**
    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.
    847960 */
    848961static int   GetKernelInfo(void)
    849962{
    850 #if !defined(DEBUGR3) && !defined(EXTRACT) /* IOCtl not 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};
    852965    APIRET          rc;
    853966    HFILE           hDev0 = 0;
    854967    USHORT          usAction = 0;
    855968
     969    /*
     970     * Issue an IOCtl to elf$ to query kernel information.
     971     */
    856972    rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL,
    857973                 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
     
    863979        if (rc == NO_ERROR)
    864980        {
    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];
    873981            #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++)
    875999                dprintf(("debug: no.%2d base=%lx size=%lx sel=%x\n",
    8761000                         i,
     
    8791003                         paKrnlOTEs[i].ote_sel));
    8801004            #endif
    881 
    8821005        }
    8831006        DosClose(hDev0);
     
    8851008
    8861009    if (rc != NO_ERROR)
    887         printf16("Failed to get kernel OTEs\r\n");
     1010        printf16("Failed to get kernel OTEs. rc=%d\n", rc);
    8881011
    8891012    return rc;
     
    8991022        {
    9001023            rc = ReadOS2Krnl(szUsrOS2Krnl);
    901             if (rc != 0)
     1024            if (rc != NO_ERROR)
    9021025            {
    903                 puts("Warning: Invalid kernel file specified. Tries defaults.\n\r");
     1026                printf16("Warning: Invalid kernel file specified. Tries defaults.\n");
    9041027                szUsrOS2Krnl[0] = '\0';
    9051028                rc = ReadOS2Krnl(szOS2Krnl);
     
    9181041/**
    9191042 * Shows result of kernelprobing if not quiet or on error.
    920  * @param     rc          Return code.
    921  * @param     iSym        index of .sym-file into static struct.
     1043 * @param   rc      Return code.
     1044 * @param   iSym    index of .sym-file into static struct.
    9221045 */
    9231046#ifndef EXTRACT
     
    9291052     * Complain even if quiet on error
    9301053     */
    931     if (!fQuiet || rc != 0)
     1054    if (!options.fQuiet || rc != NO_ERROR)
    9321055    {
    9331056        printf16("Win32k - Odin32 support driver.\n");
     
    9361059         * kernel stuff
    9371060         */
    938         if (rc <= -50 || rc == 0)
     1061        if (rc == NO_ERROR || rc > ERROR_PROB_KRNL_LAST)
    9391062        {
    9401063            #ifdef DEBUGR3
    9411064            printf16("    Found kernel:     %s\n", szOS2Krnl);
    9421065            #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);
    9461071        else
    947             printf16("    Kernel probing failed with rc=%d.\n", rc);
     1072            printf16("    Failed before probing kernel.\n");
    9481073
    9491074        /*
    9501075         * symbol-file
    9511076         */
    952         if (rc == 0)
     1077        if (rc == NO_ERROR || (rc > ERROR_PROB_SYM_LAST && (szUsrSym[0] != '\0' || apszSym[iSym] != NULL)))
    9531078            printf16("    Found symbolfile: %s\n",
    9541079                     szUsrSym[0] == '\0' ? apszSym[iSym] : szUsrSym);
     1080        else if (rc >= ERROR_PROB_SYM_FIRST)
     1081            printf16("    Failed to find symbolfile!\n");
    9551082        else
    956             printf16("    Failed to find symbolfile! rc=%d\n", rc);
     1083            printf16("    Failed before searching for symbolfile.\n");
    9571084
    9581085        /*
    9591086         * function listing
    9601087         */
    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        }
    9701110    }
    9711111}
     
    10031143                switch (pReqPack->InitArgs[i])
    10041144                {
     1145                    #if defined(DEBUGR3)
    10051146                    case 'k':
    10061147                    case 'K': /* Kernel file */
     
    10081149                        i += kargncpy(szUsrOS2Krnl, &pReqPack->InitArgs[i], sizeof(szUsrOS2Krnl));
    10091150                        break;
     1151                    #endif
    10101152
    10111153                    case 'n':
    10121154                    case 'N': /* NoLoader */
     1155                        options.fNoLoader = TRUE;
    10131156                        return 0;
    10141157
    10151158                    case 'q':
    10161159                    case 'Q': /* Quiet */
    1017                         fQuiet = 1;
     1160                        options.fQuiet = TRUE;
    10181161                        break;
    10191162
     
    10211164                    case 'S': /* Symbol file */
    10221165                        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 */
    10241169                            i += kargncpy(szUsrSym, &pReqPack->InitArgs[i], sizeof(szUsrSym));
    10251170                        break;
     
    10271172                    case 'v':
    10281173                    case 'V': /* Verbose */
    1029                         fQuiet = 0;
     1174                        options.fQuiet = FALSE;
    10301175                        break;
    10311176                }
     
    10441189    pGIS = MAKEPGINFOSEG(selGIS);
    10451190    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
    10481203    dprintf(("BootDrive: %d\n", usBootDrive));
    10491204
    10501205    /* set driveletter in constants strings */
    10511206    usBootDrive = (char)usBootDrive + (char)'a' - 1;
     1207    #if defined(DEBUGR3)
    10521208    szOS2Krnl[0] = (char)usBootDrive;
     1209    #endif
    10531210    for (i = 0; apszSym[i] != NULL; i++)
    10541211        apszSym[i][0] = (char)usBootDrive;
     
    10581215    /*-----------------*/
    10591216    rc = GetKernelInfo();
    1060     if (rc != NO_ERROR)
    1061         return rc;
    10621217
    10631218    /*--------------*/
     
    10721227            if (rc)
    10731228            {
    1074                 puts("Warning: Invalid symbol file specified. Tries defaults.\n\r");
     1229                printf16("Warning: Invalid symbol file specified. Tries defaults.\n");
    10751230                szUsrSym[0] = '\0';
    10761231            }
    10771232        }
    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. */
    10791234        {
    10801235            /*
    10811236             * Check database - only if not a debug kernel!
    10821237             * 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...)
    10841240             */
    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
    10871246                )
    10881247            {
     1248                #if 1 /* ndef R3TST */
     1249                APIRET rc2;
    10891250                /* search on disk */
    10901251                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                {
    10921256                    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
    10931263            }
    10941264        }
     
    10991269    ShowResult(rc, i);
    11001270
     1271    /* Copy the symbol file name to szUsrSym. */
     1272    if (szUsrSym[0] == '\0' && apszSym[i] != NULL)
     1273        kstrcpy(szUsrSym, apszSym[i]);
     1274
    11011275    return rc;
    11021276}
     
    11131287    int VerMinor, VerMajor;
    11141288
    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;
    11201294}
    11211295
     
    11231297/**
    11241298 * 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.
    11281303 * @remark    This step will be eliminated by searching thru the DOSGROUP datasegment
    11291304 *            in the kernel memory. This segment have a string "Internal revision 9.034[smp|uni]"
     
    11401315    if (hKrnl != 0)
    11411316    {
     1317        /*
     1318         * Get size of kernel file.
     1319         */
    11421320        cbKrnl = fsize(hKrnl);
    11431321        if (!fseek(hKrnl, 0, SEEK_SET))
     1322        {
     1323            /*
     1324             * Call worker with filehandle and size.
     1325             */
    11441326            rc = ReadOS2Krnl2(hKrnl, cbKrnl);
     1327        }
    11451328        else
    1146             rc = -2;
     1329            rc = ERROR_PROB_KRNL_SEEK_SIZE;
    11471330        fclose(hKrnl);
    11481331    }
     
    11501333    {
    11511334        dprintf(("Could not open file\n"));
    1152         rc = -1;
     1335        rc = ERROR_PROB_KRNL_OPEN_FAILED;
    11531336    }
    11541337    return rc;
     
    11591342 * Worker function for ReadOS2Krnl
    11601343 * @returns   0 on success.
    1161  *            errorcodes on failure. (-1 >= rc >= -14)
     1344 *            One of the ERROR_PROB_KRNL_* defines on error.
    11621345 * @param     hKrnl   Handle to the kernel file.
    11631346 * @param     cbKrnl  Size of the kernel file.
     
    11671350{
    11681351    #if defined(DEBUGR3) || !defined(EXTRACT)
    1169     static KRNLINFO KrnlInfo = {0};
     1352    static KRNLINFO DATA16_INIT KrnlInfo = {0};
    11701353    #endif
    11711354    int            i, j;
     
    11761359
    11771360
    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     */
    11791365    if (fseek(hKrnl, 0, SEEK_SET))
    1180         return -2;
     1366        return ERROR_PROB_KRNL_SEEK_FIRST;
    11811367
    11821368    if (!fread(&achBuffer[KERNEL_ID_STRING_LENGTH], 1, KERNEL_READ_SIZE, hKrnl))
    1183         return -3;
     1369        return ERROR_PROB_KRNL_READ_FIRST;
    11841370
    11851371    i = KERNEL_ID_STRING_LENGTH;
     
    11911377            kmemcpy(achBuffer, &achBuffer[KERNEL_READ_SIZE], KERNEL_ID_STRING_LENGTH);
    11921378            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;
    11941380
    11951381            i = 0;
     
    12041390    }
    12051391
     1392    /* found it? */
    12061393    if (cbKrnl == 0)
    12071394    {
    12081395        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     */
    12111403
    12121404    /* displacement */
     
    12171409    /* verify signature */
    12181410    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;
    12231417    if (achBuffer[i+7] != '.')
    12241418    {
    12251419        /* 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;
    12281422        i++;
    12291423        j--;
    12301424        if (achBuffer[i+7] != '.')
    12311425        {
    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;
    12341428            i++;
    12351429            j--;
     
    12391433    if (j == 0)
    12401434    {
    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;
    12431437    }
    12441438    else
    12451439    {
    12461440        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     */
    12531451    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));
    12561454
    12571455    /* get segment number */
    12581456    /* read-MZheader */
    12591457    if (fseek(hKrnl,0,SEEK_SET))
    1260         return -2;
     1458        return ERROR_PROB_KRNL_MZ_SEEK;
    12611459
    12621460    if (!fread(achBuffer, 1, 0x40, hKrnl))
    1263         return -3;
     1461        return ERROR_PROB_KRNL_MZ_READ;
    12641462
    12651463    offLXHdr = *(unsigned long int *)&achBuffer[0x3c];
    12661464
    12671465    if (offLXHdr > 0x2000 && offLXHdr < 0x80) /* just to detect garbage */
    1268         return -6;
     1466        return ERROR_PROB_KRNL_NEOFF_INVALID;
    12691467
    12701468    if (fseek(hKrnl, offLXHdr, SEEK_SET))
    1271         return -2;
     1469        return ERROR_PROB_KRNL_NEOFF_SEEK;
    12721470
    12731471    if (!fread(achBuffer, 1, sizeof(struct e32_exe), hKrnl))
    1274         return -3;
     1472        return ERROR_PROB_KRNL_LX_READ;
    12751473
    12761474    /* check LX-magic */
    12771475    if (achBuffer[0] != 'L' || achBuffer[1] != 'X')
    1278         return -7;
     1476        return ERROR_PROB_KRNL_LX_SIGNATURE;
    12791477
    12801478#if !defined(DEBUGR3) && !defined(EXTRACT)
     
    12821480    pLXHdr = (struct e32_exe *)achBuffer;
    12831481    if ((UCHAR)pLXHdr->e32_objcnt != cObjects)
    1284         return -8;
     1482        return ERROR_PROB_KRNL_OBJECT_CNT;
    12851483
    12861484    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. */
    12901488    if (!fseek(hKrnl, (LONG)offLXHdr + (LONG)pLXHdr->e32_objtab, SEEK_SET))
    12911489    {
     
    12941492        {
    12951493            if (!fread(achBuffer, 1, sizeof(OTE), hKrnl))
    1296                 return -11;
     1494                return ERROR_PROB_KRNL_OTE_READ;
    12971495            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;
    13041497        }
    13051498    }
    13061499    else
    1307         return -10;
     1500        return ERROR_PROB_KRNL_OTE_SEEK;
    13081501#else
    13091502    /* Since we can't get the OTEs from the kernel when debugging in RING-3,
     
    13221515        for (i = 0; i < (int)cObjects; i++)
    13231516            if (!fread(&paKrnlOTEs[i], 1, sizeof(struct o32_obj), hKrnl))
    1324                 return -11;
     1517                return ERROR_PROB_KRNL_OTE_READ;
    13251518    }
    13261519    else
    1327         return -10;
     1520        return ERROR_PROB_KRNL_OTE_SEEK;
    13281521#endif
    13291522
    1330     return 0;
     1523    return NO_ERROR;
    13311524}
    13321525
     
    13701563 * Where: n - are the build number 4 or 5 digits.
    13711564 *        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+
    13731566 * @returns   NO_ERROR on success. Untracable error code on error.
    13741567 * @param     pszFilename  Pointer to read only filename of the .sym-file.
     
    13811574    APIRET   rc;
    13821575    int      cch = kstrlen(pszFilename);
     1576
     1577    DosWrite(2, (char*)pszFilename, cch, &rc);
     1578    DosWrite(2, "\r\n", 2, &rc);
    13831579
    13841580    /* Filename check */
     
    13971593    }
    13981594
    1399     /** @remark
    1400      * All a/h-strict files are currently ignored.
    1401      * When a debug kernel is used we'll have to use the
    1402      * .sym-file for it. This is so because I can't distinguish
    1403      * between a all-strick and a half-strick kernel (yet).
    1404      */
    1405     if (pszFilename[cch-6] != 'R')
    1406         return 0;
    1407 
    14081595    /*
    14091596     * Probe kernelfile
     
    14191606        int i;
    14201607
     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
    14211616        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"
    14231634                 "        {\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",
    14291635                 aImportTab[0].iObject + 1); /* ASSUMES that DOSCODE32 is the last object. */
    14301636
     
    14321638        {
    14331639            char *psz = aImportTab[i].achName;
    1434             printf16("            {%2d, 0x%08lx}, /* %s */\n",
     1640            printf16("            {%-2d, 0x%08lx}, /* %s */\n",
    14351641                     aImportTab[i].iObject,
    1436                      aImportTab[i].offObject,
     1642                     aImportTab[i].fFound ? aImportTab[i].offObject : 0xFFFFFFFFUL,
    14371643                     (char *)&aImportTab[i].achName[0]
    14381644                     );
     
    14401646        printf16("        }\n"
    14411647                 "    },\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");
    14421656    }
    14431657    else
     
    14601674{
    14611675    APIRET  rc;
    1462 
     1676    const char *  psz;
    14631677
    14641678    /*
    14651679     * Set paKrnlOTEs to point to an zeroed array of OTEs.
    14661680     */
    1467     static KRNLINFO KrnlInfo = {0};
     1681    static KRNLINFO DATA16_INIT  KrnlInfo = {0};
    14681682    paKrnlOTEs = &KrnlInfo.aObjects[0];
    14691683
     
    14741688         */
    14751689        int i;
    1476         for (i = 0; i < argc; i++)
     1690        for (i = 1; i < argc; i++)
    14771691        {
    14781692            rc = processFile(argv[i]);
     
    14801694            {
    14811695                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);
    14831699                return rc;
    14841700            }
     
    14981714        int         i;
    14991715
    1500         printf16("/* $Id: probkrnl.c,v 1.20 2000-04-17 01:56:48 bird Exp $\n"
     1716        printf16("/* $Id: probkrnl.c,v 1.21 2000-09-02 21:07:56 bird Exp $\n"
    15011717                 "*\n"
    15021718                 "* Autogenerated kernel symbol database.\n"
     
    15121728                 "#define INCL_NOBASEAPI\n"
    15131729                 "#include <os2.h>\n"
     1730                 "#include \"DevSegDf.h\"\n"
    15141731                 "#include \"probkrnl.h\"\n"
     1732                 "#include \"options.h\"\n"
    15151733                 "\n");
    15161734
    1517         printf16("KRNLDBENTRY aKrnlSymDB[] = \n"
     1735        printf16("KRNLDBENTRY DATA16_INIT aKrnlSymDB[] = \n"
    15181736                 "{\n");
    15191737
     
    15281746                printf16("processFile failed with rc=%d for file %s\n",
    15291747                         rc, &ffb.achName[0]);
     1748                if (psz = GetErrorMsg(rc))
     1749                    printf16("%s\n", psz);
    15301750                return rc;
    15311751            }
     
    15371757
    15381758        printf16("    { /* Terminating entry */\n"
    1539                  "        0,0,0,0,\n"
     1759                 "        0,0,0,\n"
    15401760                 "        {\n");
    15411761        for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
Note: See TracChangeset for help on using the changeset viewer.