Ignore:
Timestamp:
Sep 2, 2000, 10:49:29 PM (25 years ago)
Author:
bird
Message:

Bugfixing, DevSegDf.h,...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GRACE/src/win32k/dev32/d32init.c

    r4117 r4162  
    1 /* $Id: d32init.c,v 1.19.4.12 2000-08-30 04:11:28 bird Exp $
     1/* $Id: d32init.c,v 1.19.4.13 2000-09-02 20:49:11 bird Exp $
    22 *
    33 * d32init.c - 32-bits init routines.
     
    3232#include <string.h>
    3333
     34#include "devSegDf.h"
    3435#include "OS2Krnl.h"
    3536#include "options.h"
     
    166167                break;
    167168
     169            case 'j':
     170            case 'J': /* -Java:<Yes|No> */
     171                pszTmp2 = strpbrk(pszTmp, ":=/- ");
     172                options.fJava =
     173                    pszTmp2 != NULL
     174                    && (int)(pszTmp2-pszTmp) < cch-1
     175                    && (*pszTmp2 == ':' || *pszTmp2 == '=')
     176                    && (pszTmp2[1] == 'Y' || pszTmp2[1] == 'y');
     177                break;
     178
    168179            case 'l':
    169180            case 'L': /* -L[..]<:|=| >[<Y..|E..| > | <N..|D..>] */
     
    209220
    210221            case 'r':
    211             case 'R': /* ResHeap options */
     222            case 'R': /* ResHeap options or REXX option */
    212223                pszTmp2 = strpbrk(pszTmp, ":=/- ");
    213                 if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '='))
    214                 {
    215                     ul = readnum(pszTmp2 + 1);
    216                     if (ul > 0x1000UL && ul < 0x700000UL) /* 4KB < ul < 7MB */
     224                if (   (pszTmp[1] == 'E' || pszTmp[1] == 'e')
     225                    && (pszTmp[2] == 'X' || pszTmp[2] == 'x'))
     226                {   /* REXX */
     227                    options.fREXXScript =
     228                        pszTmp2 != NULL
     229                        && (int)(pszTmp2-pszTmp) < cch-1
     230                        && (*pszTmp2 == ':' || *pszTmp2 == '=')
     231                        && (pszTmp2[1] == 'Y' || pszTmp2[1] == 'y');
     232                }
     233                else
     234                {   /* ResHeap options */
     235                    if (pszTmp2 != NULL && (*pszTmp2 == ':' || *pszTmp2 == '='))
    217236                    {
    218                         if (strnicmp(pszTmp, "resheapm", 8) == 0)
    219                             options.cbResHeapMax = ul;
    220                         else
    221                             options.cbResHeapInit = ul;
     237                        ul = readnum(pszTmp2 + 1);
     238                        if (ul > 0x1000UL && ul < 0x700000UL) /* 4KB < ul < 7MB */
     239                        {
     240                            if (strnicmp(pszTmp, "resheapm", 8) == 0)
     241                                options.cbResHeapMax = ul;
     242                            else
     243                                options.cbResHeapInit = ul;
     244                        }
    222245                    }
    223246                }
     
    10491072         */
    10501073        kprintf2(("VerifyImportTab32: procedure no.%d is being checked: %s addr=0x%08x iObj=%d offObj=%d\n",
    1051                   i, &_aImportTab[i].achName[0], _aImportTab[i].ulAddress,
    1052                   _aImportTab[i].iObject, _aImportTab[i].offObject));
     1074                  i, &aImportTab[i].achName[0], aImportTab[i].ulAddress,
     1075                  aImportTab[i].iObject, aImportTab[i].offObject));
    10531076
    10541077        /* Verify that it is found */
    1055         if (!_aImportTab[i].fFound)
    1056         {
    1057             if (_aImportTab[i].fType & EPT_NOT_REQ)
     1078        if (!aImportTab[i].fFound)
     1079        {
     1080            if (aImportTab[i].fType & EPT_NOT_REQ)
    10581081                continue;
    10591082            else
     
    10651088
    10661089        /* Verify read/writeable. */
    1067         if (_aImportTab[i].iObject >= pKrnlSMTE->smte_objcnt                                /* object index valid? */
    1068             || _aImportTab[i].ulAddress < pKrnlOTE[_aImportTab[i].iObject].ote_base         /* address valid? */
    1069             || _aImportTab[i].ulAddress + 16 > (pKrnlOTE[_aImportTab[i].iObject].ote_base +
    1070                                                 pKrnlOTE[_aImportTab[i].iObject].ote_size)  /* address valid? */
    1071             || _aImportTab[i].ulAddress - _aImportTab[i].offObject
    1072                != pKrnlOTE[_aImportTab[i].iObject].ote_base                                 /* offObject ok?  */
     1090        if (aImportTab[i].iObject >= pKrnlSMTE->smte_objcnt                                /* object index valid? */
     1091            || aImportTab[i].ulAddress < pKrnlOTE[aImportTab[i].iObject].ote_base          /* address valid? */
     1092            || aImportTab[i].ulAddress + 16 > (pKrnlOTE[aImportTab[i].iObject].ote_base +
     1093                                                pKrnlOTE[aImportTab[i].iObject].ote_size)  /* address valid? */
     1094            || aImportTab[i].ulAddress - aImportTab[i].offObject
     1095               != pKrnlOTE[aImportTab[i].iObject].ote_base                                 /* offObject ok?  */
    10731096            )
    10741097        {
    10751098            kprintf(("VerifyImportTab32: procedure no.%d has an invalid address or object number.!\n"
    10761099                     "                   %s  addr=0x%08x iObj=%d offObj=%d\n",
    1077                      i, &_aImportTab[i].achName[0], _aImportTab[i].ulAddress,
    1078                      _aImportTab[i].iObject, _aImportTab[i].offObject));
     1100                     i, &aImportTab[i].achName[0], aImportTab[i].ulAddress,
     1101                     aImportTab[i].iObject, aImportTab[i].offObject));
    10791102            return STATUS_DONE | STERR | ERROR_D32_INVALID_OBJ_OR_ADDR;
    10801103        }
     
    10821105
    10831106        #ifndef R3TST
    1084         if (_aImportTab[i].ulAddress < 0xff400000UL)
     1107        if (aImportTab[i].ulAddress < 0xff400000UL)
    10851108        {
    10861109            kprintf(("VerifyImportTab32: procedure no.%d has an invalid address, %#08x!\n",
    1087                      i, _aImportTab[i].ulAddress));
     1110                     i, aImportTab[i].ulAddress));
    10881111            return STATUS_DONE | STERR | ERROR_D32_INVALID_ADDRESS;
    10891112        }
    10901113        #endif
    10911114
    1092         switch (_aImportTab[i].fType & ~(EPT_BIT_MASK | EPT_NOT_REQ))
     1115        switch (aImportTab[i].fType & ~(EPT_BIT_MASK | EPT_NOT_REQ))
    10931116        {
    10941117            case EPT_PROC:
     
    10971120                 * Verify known function prolog.
    10981121                 */
    1099                 if (EPT32BitEntry(_aImportTab[i]))
     1122                if (EPT32BitEntry(aImportTab[i]))
    11001123                {
    1101                     cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress,
    1102                                                    _aImportTab[i].fType == EPT_PROC32);
     1124                    cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress,
     1125                                                   aImportTab[i].fType == EPT_PROC32);
    11031126                    cbmin = 5; /* Size of the jump instruction */
    11041127                }
    11051128                else
    11061129                {
    1107                     cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress,
    1108                                                    _aImportTab[i].fType == EPT_PROC16);
     1130                    cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress,
     1131                                                   aImportTab[i].fType == EPT_PROC16);
    11091132                    cbmin = 7; /* Size of the far jump instruction */
    11101133                }
     
    12041227    {
    12051228        /* EPT_VARIMPORTs are skipped */
    1206         if ((_aImportTab[i].fType & ~EPT_BIT_MASK) == EPT_VARIMPORT)
     1229        if ((aImportTab[i].fType & ~EPT_BIT_MASK) == EPT_VARIMPORT)
    12071230            continue;
    12081231        /* EPT_NOT_REQ which is not found are set pointing to the nop function provided. */
    1209         if (!_aImportTab[i].fFound && (_aImportTab[i].fType & EPT_NOT_REQ))
    1210         {
    1211             _aImportTab[i].ulAddress = auFuncs[i];
     1232        if (!aImportTab[i].fFound && (aImportTab[i].fType & EPT_NOT_REQ))
     1233        {
     1234            aImportTab[i].ulAddress = auFuncs[i];
    12121235            continue;
    12131236        }
    12141237
    1215         if (EPT32BitEntry(_aImportTab[i]))
    1216         {
    1217             cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC32);
     1238        if (EPT32BitEntry(aImportTab[i]))
     1239        {
     1240            cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, aImportTab[i].fType == EPT_PROC32);
    12181241            cbmin = 5; /* Size of the jump instruction */
    12191242        }
    12201243        else
    12211244        {
    1222             cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC16);
     1245            cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, aImportTab[i].fType == EPT_PROC16);
    12231246            cbmin = 7; /* Size of the far jump instruction */
    12241247        }
     
    12351258    for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
    12361259    {
    1237         switch (_aImportTab[i].fType & ~EPT_NOT_REQ)
     1260        switch (aImportTab[i].fType & ~EPT_NOT_REQ)
    12381261        {
    12391262            /*
     
    12451268            case EPT_PROC32:
    12461269            {
    1247                 cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, TRUE);
    1248                 _aImportTab[i].cbProlog = (char)cb;
     1270                cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, TRUE);
     1271                aImportTab[i].cbProlog = (char)cb;
    12491272                if (cb >= 5 && cb + 5 < MAXSIZE_PROLOG) /* 5(1st): size of jump instruction in the function prolog which jumps to my overloading function */
    12501273                {                                       /* 5(2nd): size of jump instruction which jumps back to the original function after executing the prolog copied to the callTab entry for this function. */
     
    12521275                     * Copy function prolog which will be overwritten by the jmp to calltabl.
    12531276                     */
    1254                     memcpy(callTab[i], (void*)_aImportTab[i].ulAddress, (size_t)cb);
     1277                    memcpy(callTab[i], (void*)aImportTab[i].ulAddress, (size_t)cb);
    12551278
    12561279                    /*
     
    12601283                     */
    12611284                    callTab[i][cb] = 0xE9; /* jmp */
    1262                     *(unsigned long*)(void*)&callTab[i][cb+1] = _aImportTab[i].ulAddress + cb - (unsigned long)&callTab[i][cb+5];
     1285                    *(unsigned long*)(void*)&callTab[i][cb+1] = aImportTab[i].ulAddress + cb - (unsigned long)&callTab[i][cb+5];
    12631286
    12641287                    /*
    12651288                     * Jump from original function to my function - an cli(?) could be needed here
    12661289                     */
    1267                     *(char*)_aImportTab[i].ulAddress = 0xE9; /* jmp */
    1268                     *(unsigned long*)(_aImportTab[i].ulAddress + 1) = auFuncs[i] - (_aImportTab[i].ulAddress + 5);
     1290                    *(char*)aImportTab[i].ulAddress = 0xE9; /* jmp */
     1291                    *(unsigned long*)(aImportTab[i].ulAddress + 1) = auFuncs[i] - (aImportTab[i].ulAddress + 5);
    12691292                }
    12701293                else
     
    12871310                Int3();
    12881311
    1289                 cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, TRUE);
    1290                 _aImportTab[i].cbProlog = (char)cb;
     1312                cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, TRUE);
     1313                aImportTab[i].cbProlog = (char)cb;
    12911314                if (cb >= 8 && cb + 7 < MAXSIZE_PROLOG) /* 8: size of a 16:32 jump which jumps to my overloading function (prefixed with 66h in a 16-bit segment) */
    12921315                {                                       /* 7: size of a 16:32 jump which is added to the call tab */
     
    12941317                     * Copy function prolog which is to be overwritten.
    12951318                     */
    1296                     memcpy(callTab[i], (void*)_aImportTab[i].ulAddress, (size_t)cb);
     1319                    memcpy(callTab[i], (void*)aImportTab[i].ulAddress, (size_t)cb);
    12971320
    12981321                    /*
     
    13011324                     */
    13021325                    callTab[i][cb] = 0xEA; /* jmp far ptr */
    1303                     *(unsigned long*)(void*)&callTab[i][cb+1] = _aImportTab[i].offObject;
    1304                     *(unsigned short*)(void*)&callTab[i][cb+5] = _aImportTab[i].usSel;
     1326                    *(unsigned long*)(void*)&callTab[i][cb+1] = aImportTab[i].offObject;
     1327                    *(unsigned short*)(void*)&callTab[i][cb+5] = aImportTab[i].usSel;
    13051328
    13061329                    /*
     
    13081331                     * 0x66 0xEA <four byte target address> <two byte target selector>
    13091332                     */
    1310                     *(char*)(_aImportTab[i].ulAddress    ) = 0x66;    /* operandsize prefix */
    1311                     *(char*)(_aImportTab[i].ulAddress + 1) = 0xEA;    /* jmp far ptr */
    1312                     *(unsigned long*)(_aImportTab[i].ulAddress + 2) = auFuncs[i];   /* FIXME? */
    1313                     *(unsigned short*)(_aImportTab[i].ulAddress + 6) = _R0FlatCS16; /* FIXME */
     1333                    *(char*)(aImportTab[i].ulAddress    ) = 0x66;    /* operandsize prefix */
     1334                    *(char*)(aImportTab[i].ulAddress + 1) = 0xEA;    /* jmp far ptr */
     1335                    *(unsigned long*)(aImportTab[i].ulAddress + 2) = auFuncs[i];   /* FIXME? */
     1336                    *(unsigned short*)(aImportTab[i].ulAddress + 6) = _R0FlatCS16; /* FIXME */
    13141337                }
    13151338                else
     
    13291352            case EPT_PROCIMPORT32:
    13301353            {
    1331                 cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, FALSE);
    1332                 _aImportTab[i].cbProlog = (char)cb;
     1354                cb = interpretFunctionProlog32((char*)aImportTab[i].ulAddress, FALSE);
     1355                aImportTab[i].cbProlog = (char)cb;
    13331356                if (cb > 0) /* Since no prolog part is copied to the function table, it's ok as long as the prolog has been recognzied. */
    13341357                {
     
    13391362                     */
    13401363                    callTab[i][0] = 0xE9; /* jmp */
    1341                     *(unsigned*)(void*)&callTab[i][1] = _aImportTab[i].ulAddress - (unsigned)&callTab[i][5];
     1364                    *(unsigned*)(void*)&callTab[i][1] = aImportTab[i].ulAddress - (unsigned)&callTab[i][5];
    13421365                }
    13431366                else
     
    13571380            case EPT_PROCIMPORT16:
    13581381            {
    1359                 cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, FALSE);
    1360                 _aImportTab[i].cbProlog = (char)cb;
     1382                cb = interpretFunctionProlog16((char*)aImportTab[i].ulAddress, FALSE);
     1383                aImportTab[i].cbProlog = (char)cb;
    13611384                if (cb > 0) /* Since no prolog part is copied to the function table, it's ok as long as the prolog has been recognzied. */
    13621385                {
     
    13661389                     */
    13671390                    callTab[i][0] = 0xEA; /* jmp far ptr */
    1368                     *(unsigned long*)(void*)&callTab[i][1] = _aImportTab[i].offObject;
    1369                     *(unsigned short*)(void*)&callTab[i][5] = _aImportTab[i].usSel;
     1391                    *(unsigned long*)(void*)&callTab[i][1] = aImportTab[i].offObject;
     1392                    *(unsigned short*)(void*)&callTab[i][5] = aImportTab[i].usSel;
    13701393                }
    13711394                else
     
    13891412            case EPT_VARIMPORT32:
    13901413            case EPT_VARIMPORT16:
    1391                 _aImportTab[i].cbProlog = (char)0;
    1392                 *(unsigned long*)(void*)&callTab[i][0] = _aImportTab[i].ulAddress;
    1393                 *(unsigned long*)(void*)&callTab[i][4] = _aImportTab[i].offObject;
    1394                 *(unsigned short*)(void*)&callTab[i][8] = _aImportTab[i].usSel;
    1395                 *(unsigned short*)(void*)&callTab[i][0xa] = (unsigned short)_aImportTab[i].offObject;
    1396                 *(unsigned short*)(void*)&callTab[i][0xc] = _aImportTab[i].usSel;
     1414                aImportTab[i].cbProlog = (char)0;
     1415                *(unsigned long*)(void*)&callTab[i][0] = aImportTab[i].ulAddress;
     1416                *(unsigned long*)(void*)&callTab[i][4] = aImportTab[i].offObject;
     1417                *(unsigned short*)(void*)&callTab[i][8] = aImportTab[i].usSel;
     1418                *(unsigned short*)(void*)&callTab[i][0xa] = (unsigned short)aImportTab[i].offObject;
     1419                *(unsigned short*)(void*)&callTab[i][0xc] = aImportTab[i].usSel;
    13971420                break;
    13981421
     
    14291452/**
    14301453 * -Ring-3 testing-
    1431  * Changes the entries in _aImportTab to point to their fake equivalents.
     1454 * Changes the entries in aImportTab to point to their fake equivalents.
    14321455 * @returns void
    14331456 * @param   void
    14341457 * @status  completely implemented.
    14351458 * @author  knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
    1436  * @remark  Called before the _aImportTab array is used/verified.
     1459 * @remark  Called before the aImportTab array is used/verified.
    14371460 */
    14381461VOID R3TstFixImportTab(VOID)
     
    14921515    for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
    14931516    {
    1494         switch (_aImportTab[i].fType)
     1517        switch (aImportTab[i].fType)
    14951518        {
    14961519            case EPT_PROC32:
     
    15131536        } /* switch - type */
    15141537
    1515         _aImportTab[i].ulAddress = aTstFakers[i].uAddress;
     1538        aImportTab[i].ulAddress = aTstFakers[i].uAddress;
    15161539        switch (aTstFakers[i].fObj)
    15171540        {
    15181541            case 1:
    1519                 _aImportTab[i].usSel = GetSelectorCODE32();
    1520                 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE32START;
     1542                aImportTab[i].usSel = GetSelectorCODE32();
     1543                aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE32START;
    15211544                break;
    15221545            case 2:
    1523                 _aImportTab[i].usSel = GetSelectorCODE16();
    1524                 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE16START;
     1546                aImportTab[i].usSel = GetSelectorCODE16();
     1547                aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&CODE16START;
    15251548                break;
    15261549            case 3:
    1527                 _aImportTab[i].usSel = GetSelectorDATA32();
    1528                 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA32START;
     1550                aImportTab[i].usSel = GetSelectorDATA32();
     1551                aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA32START;
    15291552                break;
    15301553            case 4:
    1531                 _aImportTab[i].usSel = GetSelectorDATA16();
    1532                 _aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA16START;
     1554                aImportTab[i].usSel = GetSelectorDATA16();
     1555                aImportTab[i].offObject = aTstFakers[i].uAddress - (unsigned)&DATA16START;
    15331556                break;
    15341557            default:
Note: See TracChangeset for help on using the changeset viewer.