Ignore:
Timestamp:
Aug 14, 2000, 10:57:07 AM (25 years ago)
Author:
bird
Message:

Corrections...
Testing is now done with real kernel image!!!

File:
1 edited

Legend:

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

    r3834 r4010  
    1 /* $Id: d32init.c,v 1.19.4.1 2000-07-16 22:42:03 bird Exp $
     1/* $Id: d32init.c,v 1.19.4.2 2000-08-14 08:57:04 bird Exp $
    22 *
    33 * d32init.c - 32-bits init routines.
     
    4444#include "ldrCalls.h"
    4545#include "macros.h"
     46#include "errors.h"
    4647
    4748#ifdef R3TST
     
    471472                    for (i = 0; i < 2 && pKrnlInfo->ulBuild == 0; i++)
    472473                    {
    473                         #ifndef R3TST
    474474                        const char *psz = (const char*)pKrnlOTE[i].ote_base;
    475475                        const char *pszEnd = psz + pKrnlOTE[i].ote_size - 50; /* Last possible search position. */
    476                         #else
    477                         extern const char *pszInternalRevision; /* defined in win32ktst.c */
    478                         const char *psz =  pszInternalRevision;
    479                         const char *pszEnd = psz + 3;
    480                         #endif
    481476
    482477                        while (psz < pszEnd)
     
    524519
    525520                                /* Check if its a debug kernel (look for DEBUG at start of object 3-5) */
    526                             #ifndef R3TST
    527521                                j = 3;
    528522                                while (j < 5)
     
    541535                                    j++;
    542536                                }
    543                             #else
    544                                 NOREF(j);
    545                             #endif
    546537
    547538                                /* Display info */
     
    598589        || ((bModRM & 0xc0) == 0 && (bModRM & 0x07) == 5)) /* ex. mov ebp,[0ff231234h] */
    599590    {   /* 32-bit displacement */
    600         return 5;
     591        return 5 + ((bModRM & 0x7) == 0x4); // + SIB
    601592    }
    602593    else if ((bModRM & 0xc0) == 0x40) /* ex. mov ecx,[esi]+4fh */
    603594    {   /* 8-bit displacement */
    604         return 2;
     595        return 2 + ((bModRM & 0x7) == 0x4); // + SIB
    605596    }
    606597    /* no displacement (only /r byte) */
     
    670661     *     push ebp
    671662     *  or
     663     *     mov ecx, r/m32
     664     *  or
     665     *     jmp dword
     666     *  or
     667     *     sub esp, imm8
     668     *  or
    672669     *     mov eax, msoff32
    673670     *
    674671     */
    675     if ((pach[0] == 0x55 && (pach[1] == 0x8b || pach[1] == 0xa1)) /* two first prologs */
     672    if ((pach[0] == 0x55 && (pach[1] == 0x8b || pach[1] == 0xa1)) /* the two first prologs */
    676673        ||
    677         (pach[0] == 0xB8 && (pach[5] == 0xEB || pach[5] == 0x55 ) && !fOverload) /* two next prologs */
     674        (pach[0] == 0xB8 && (pach[5] == 0xEB || pach[5] == 0x55) && !fOverload) /* the two next prologs */
     675        ||
     676        (pach[0] == 0x8B && !fOverload) /* the next prolog */
     677        ||
     678        (pach[0] == 0xFF && !fOverload) /* the next prolog */
     679        ||
     680        (pach[0] == 0x83 && !fOverload) /* the next prolog */
    678681        ||
    679682        (pach[0] == 0xa1 && !fOverload) /* last prolog */
     
    762765                case 0x8b:              /* mov /r */
    763766                case 0x8d:              /* lea /r */
    764                     if ((pach[1] & 0x7) == 4 && (pach[1] & 0xc0) != 0xc0) /* invalid instruction!?! */
    765                         return -1;
    766767                    cb += cb2 = ModR_M_32bit(pach[1]);
    767768                    pach += cb2;
     
    801802                    break;
    802803
     804                /*
     805                 * jmp /digit
     806                 */
     807                case 0xff:
     808                    cb += cb2 = 4 + ModR_M_32bit(pach[1]); /* 4 is the size of the imm32 */
     809                    pach += cb2;
     810                    break;
     811
    803812                default:
    804813                    kprintf(("interpretFunctionProlog32: unknown instruction 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
     
    811820    else
    812821    {
    813         kprintf(("interpretFunctionProlog32: unknown prolog start. 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
     822        kprintf(("interpretFunctionProlog32: unknown prolog start. 0x%x 0x%x 0x%x 0x%x 0x%x\n",
     823                 pach[0], pach[1], pach[2], pach[3], pach[4]));
    814824        cb = 0;
    815825    }
     
    947957                    else
    948958                    {
    949                         kprintf(("interpretFunctionProlog32: unknown instruction (-3) 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
     959                        kprintf(("interpretFunctionProlog16: unknown instruction (-3) 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
    950960                        return -3;
    951961                    }
     
    986996    pulTKSSBase32 = (PULONG)_TKSSBase16;
    987997
    988 #ifdef R3TST
    989     R3TstFixImportTab();
    990 #endif
    991 
    992998    /* Check that pKrnlOTE is set */
    993999    usRc = GetKernelInfo32(NULL);
     
    10141020        }
    10151021
    1016     #ifndef R3TST
    10171022        /* Verify read/writeable. */
    10181023        if (_aImportTab[i].iObject >= pKrnlSMTE->smte_objcnt                                /* object index valid? */
     
    10321037
    10331038
    1034 
     1039        #ifndef R3TST
    10351040        if (_aImportTab[i].ulAddress < 0xffe00000UL)
    10361041        {
     
    10391044            return STATUS_DONE | STERR | ERROR_D32_INVALID_ADDRESS;
    10401045        }
    1041     #endif
     1046        #endif
    10421047
    10431048        switch (_aImportTab[i].fType & ~EPT_BIT_MASK)
     
    10661071                if (cb <= 0 || cb + cbmin >= MAXSIZE_PROLOG)
    10671072                {   /* failed, too small or too large. */
    1068                     kprintf(("VerifyImportTab32: verify failed for procedure no.%d (cd=%d)\n", i, cb));
     1073                    kprintf(("VerifyImportTab32: verify failed for procedure no.%d (cb=%d)\n", i, cb));
    10691074                    return STATUS_DONE | STERR | ERROR_D32_TOO_INVALID_PROLOG;
    10701075                }
     
    12001205                else
    12011206                {   /* !fatal! - this could never happen really... */
    1202                     kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when rehooking it!\n",i));
     1207                    kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when rehooking it!\n", i));
    12031208                    Int3(); /* ipe - later! */
    12041209                    return ERROR_D32_VERIFY_FAILED;
     
    12451250                else
    12461251                {   /* !fatal! - this could never happen really... */
    1247                     kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when rehooking it!\n",i));
     1252                    kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when rehooking it!\n", i));
    12481253                    Int3(); /* ipe - later! */
    12491254                    return ERROR_D32_VERIFY_FAILED;
     
    12731278                else
    12741279                {   /* !fatal! - this should never really happen... */
    1275                     kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when importing it!\n",i));
     1280                    kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when importing it!\n", i));
    12761281                    Int3(); /* ipe - later! */
    12771282                    return ERROR_D32_VERIFY_FAILED;
     
    13011306                else
    13021307                {   /* !fatal! - this should never really happen... */
    1303                     kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when importing it!\n",i));
     1308                    kprintf(("ImportTabInit: FATAL verify failed for procedure no.%d when importing it!\n", i));
    13041309                    Int3(); /* ipe - later! */
    13051310                    return ERROR_D32_VERIFY_FAILED;
     
    13501355    static MTE    KrnlMTE;
    13511356    static SMTE   KrnlSMTE;
    1352     static OTE    aKrnlOTE[17];
    1353 
    1354     extern int  cObjectsFake; /* defined in win32ktst.c */
    13551357
    13561358    KrnlMTE.mte_swapmte = &KrnlSMTE;
    13571359    KrnlSMTE.smte_objtab = &aKrnlOTE[0];
    13581360    KrnlSMTE.smte_objcnt = cObjectsFake;
    1359 
    1360     aKrnlOTE[0].ote_size     = 0x00000FB4;
    1361     aKrnlOTE[0].ote_base     = 0xffe10000;
    1362     aKrnlOTE[0].ote_flags    = 0x80001063;
    1363     aKrnlOTE[0].ote_pagemap  = 1;
    1364     aKrnlOTE[0].ote_mapsize  = 1;
    1365     aKrnlOTE[0].ote_sel      = 0;
    1366     aKrnlOTE[0].ote_hob      = 0;
    1367 
    1368     aKrnlOTE[1].ote_size     = 0x0000A7CD;
    1369     aKrnlOTE[1].ote_base     = 0xffe20000;
    1370     aKrnlOTE[1].ote_flags    = 0x80001063;
    1371     aKrnlOTE[1].ote_pagemap  = 0x00000002;
    1372     aKrnlOTE[1].ote_mapsize  = 0x0000000B;
    1373     aKrnlOTE[1].ote_sel      = 0x0;
    1374     aKrnlOTE[1].ote_hob      = 0x0;
    1375 
    1376     aKrnlOTE[2].ote_size     = 0x000084C9;
    1377     aKrnlOTE[2].ote_base     = 0xffe30000;
    1378     aKrnlOTE[2].ote_flags    = 0x80001045;
    1379     aKrnlOTE[2].ote_pagemap  = 0x0000000D;
    1380     aKrnlOTE[2].ote_mapsize  = 0x00000009;
    1381     aKrnlOTE[2].ote_sel      = 0x0;
    1382     aKrnlOTE[2].ote_hob      = 0x0;
    1383 
    1384     aKrnlOTE[3].ote_size     = 0x00010000;
    1385     aKrnlOTE[3].ote_base     = 0xffe40000;
    1386     aKrnlOTE[3].ote_flags    = 0x800090A3;
    1387     aKrnlOTE[3].ote_pagemap  = 0x00000016;
    1388     aKrnlOTE[3].ote_mapsize  = 0x00000010;
    1389     aKrnlOTE[3].ote_sel      = 0x0;
    1390     aKrnlOTE[3].ote_hob      = 0x0;
    1391 
    1392     aKrnlOTE[4].ote_size     = 0x00002A80;
    1393     aKrnlOTE[4].ote_base     = 0xffe50000;
    1394     aKrnlOTE[4].ote_flags    = 0x80009023;
    1395     aKrnlOTE[4].ote_pagemap  = 0x00000026;
    1396     aKrnlOTE[4].ote_mapsize  = 0x00000003;
    1397     aKrnlOTE[4].ote_sel      = 0x0;
    1398     aKrnlOTE[4].ote_hob      = 0x0;
    1399 
    1400     aKrnlOTE[5].ote_size     = 0x00005734;
    1401     aKrnlOTE[5].ote_base     = 0xffe60000;
    1402     aKrnlOTE[5].ote_flags    = 0x80001023;
    1403     aKrnlOTE[5].ote_pagemap  = 0x00000029;
    1404     aKrnlOTE[5].ote_mapsize  = 0x00000003;
    1405     aKrnlOTE[5].ote_sel      = 0x0;
    1406     aKrnlOTE[5].ote_hob      = 0x0;
    1407 
    1408     aKrnlOTE[6].ote_size     = 0x00002833;
    1409     aKrnlOTE[6].ote_base     = 0xffe70000;
    1410     aKrnlOTE[6].ote_flags    = 0x80001015;
    1411     aKrnlOTE[6].ote_pagemap  = 0x0000002C;
    1412     aKrnlOTE[6].ote_mapsize  = 0x00000003;
    1413     aKrnlOTE[6].ote_sel      = 0x0;
    1414     aKrnlOTE[6].ote_hob      = 0x0;
    1415 
    1416     aKrnlOTE[7].ote_size     = 0x000001B0;
    1417     aKrnlOTE[7].ote_base     = 0xffe80000;
    1418     aKrnlOTE[7].ote_flags    = 0x80002213;
    1419     aKrnlOTE[7].ote_pagemap  = 0x0000002F;
    1420     aKrnlOTE[7].ote_mapsize  = 0x00000001;
    1421     aKrnlOTE[7].ote_sel      = 0x0;
    1422     aKrnlOTE[7].ote_hob      = 0x0;
    1423 
    1424     aKrnlOTE[8].ote_size     = 0x000027CC;
    1425     aKrnlOTE[8].ote_base     = 0xffe90000;
    1426     aKrnlOTE[8].ote_flags    = 0x80002013;
    1427     aKrnlOTE[8].ote_pagemap  = 0x00000030;
    1428     aKrnlOTE[8].ote_mapsize  = 0x00000003;
    1429     aKrnlOTE[8].ote_sel      = 0x0;
    1430     aKrnlOTE[8].ote_hob      = 0x0;
    1431 
    1432     aKrnlOTE[9].ote_size     = 0x0000FDA8;
    1433     aKrnlOTE[9].ote_base     = 0xffeA0000;
    1434     aKrnlOTE[9].ote_flags    = 0x80002033;
    1435     aKrnlOTE[9].ote_pagemap  = 0x00000033;
    1436     aKrnlOTE[9].ote_mapsize  = 0x0000000D;
    1437     aKrnlOTE[9].ote_sel      = 0x0;
    1438     aKrnlOTE[9].ote_hob      = 0x0;
    1439 
    1440     aKrnlOTE[10].ote_size     = 0x0000ECD6;
    1441     aKrnlOTE[10].ote_base     = 0xffeB0000;
    1442     aKrnlOTE[10].ote_flags    = 0x80001015;
    1443     aKrnlOTE[10].ote_pagemap  = 0x00000040;
    1444     aKrnlOTE[10].ote_mapsize  = 0x0000000F;
    1445     aKrnlOTE[10].ote_sel      = 0x0;
    1446     aKrnlOTE[10].ote_hob      = 0x0;
    1447 
    1448     aKrnlOTE[11].ote_size     = 0x0000EAF4;
    1449     aKrnlOTE[11].ote_base     = 0xffeC0000;
    1450     aKrnlOTE[11].ote_flags    = 0x80001015;
    1451     aKrnlOTE[11].ote_pagemap  = 0x0000004F;
    1452     aKrnlOTE[11].ote_mapsize  = 0x0000000F;
    1453     aKrnlOTE[11].ote_sel      = 0x0;
    1454     aKrnlOTE[11].ote_hob      = 0x0;
    1455 
    1456     aKrnlOTE[12].ote_size     = 0x0000D900;
    1457     aKrnlOTE[12].ote_base     = 0xffeD0000;
    1458     aKrnlOTE[12].ote_flags    = 0x80001015;
    1459     aKrnlOTE[12].ote_pagemap  = 0x0000005E;
    1460     aKrnlOTE[12].ote_mapsize  = 0x0000000E;
    1461     aKrnlOTE[12].ote_sel      = 0x0;
    1462     aKrnlOTE[12].ote_hob      = 0x0;
    1463 
    1464     aKrnlOTE[13].ote_size     = 0x0000D6DC;
    1465     aKrnlOTE[13].ote_base     = 0xffeE0000;
    1466     aKrnlOTE[13].ote_flags    = 0x80001015;
    1467     aKrnlOTE[13].ote_pagemap  = 0x0000006C;
    1468     aKrnlOTE[13].ote_mapsize  = 0x0000000E;
    1469     aKrnlOTE[13].ote_sel      = 0x0;
    1470     aKrnlOTE[13].ote_hob      = 0x0;
    1471 
    1472     aKrnlOTE[14].ote_size     = 0x000B684B;
    1473     aKrnlOTE[14].ote_base     = 0xffeF0000;
    1474     aKrnlOTE[14].ote_flags    = 0x80002015;
    1475     aKrnlOTE[14].ote_pagemap  = 0x0000007A;
    1476     aKrnlOTE[14].ote_mapsize  = 0x000000B7;
    1477     aKrnlOTE[14].ote_sel      = 0x0;
    1478     aKrnlOTE[14].ote_hob      = 0x0;
    1479 
    1480     aKrnlOTE[15].ote_size     = 0x000B684B;
    1481     aKrnlOTE[15].ote_base     = 0xffeF0000;
    1482     aKrnlOTE[15].ote_flags    = 0x80002015;
    1483     aKrnlOTE[15].ote_pagemap  = 0x0000007A;
    1484     aKrnlOTE[15].ote_mapsize  = 0x000000B7;
    1485     aKrnlOTE[15].ote_sel      = 0x0;
    1486     aKrnlOTE[15].ote_hob      = 0x0;
    1487 
    1488     aKrnlOTE[16].ote_size     = 0x000B684B;
    1489     aKrnlOTE[16].ote_base     = 0xffeF0000;
    1490     aKrnlOTE[16].ote_flags    = 0x80002015;
    1491     aKrnlOTE[16].ote_pagemap  = 0x0000007A;
    1492     aKrnlOTE[16].ote_mapsize  = 0x000000B7;
    1493     aKrnlOTE[16].ote_sel      = 0x0;
    1494     aKrnlOTE[16].ote_hob      = 0x0;
    14951361
    14961362    return &KrnlMTE;
Note: See TracChangeset for help on using the changeset viewer.