Changeset 4110 for branches/GRACE/src


Ignore:
Timestamp:
Aug 29, 2000, 6:08:24 AM (25 years ago)
Author:
bird
Message:

Fixed a relocation bug. Check for empty chunks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GRACE/src/win32k/pe2lx/pe2lx.cpp

    r4099 r4110  
    1 /* $Id: pe2lx.cpp,v 1.18.4.9 2000-08-27 03:38:28 bird Exp $
     1/* $Id: pe2lx.cpp,v 1.18.4.10 2000-08-29 04:08:24 bird Exp $
    22 *
    33 * Pe2Lx class implementation. Ring 0 and Ring 3
     
    481481        dumpSectionHeader(&paSections[i]);
    482482
    483         /* 8a. Convert characteristics to flags */
     483        /* 8a. Convert characteristics to flags and check/fix incompatible flags! */
    484484        for (j = 0; j < (sizeof(paSecChars2Flags)/sizeof(paSecChars2Flags[0])); j++)
    485485            if ((paSections[i].Characteristics & paSecChars2Flags[j].Characteristics) == paSecChars2Flags[j].Characteristics)
    486486                flFlags |= paSecChars2Flags[j].flFlags;
     487        if ((flFlags & (OBJEXEC | OBJWRITE)) == (OBJEXEC | OBJWRITE))
     488            flFlags &= (ULONG)~OBJEXEC;
    487489
    488490        /* 8b. Virtual/physical size */
     
    553555    /* 11.Align section. (Fix which is applied to EXEs/Dlls which contain no fixups and has an
    554556     *    alignment which is not a multiple of 64Kb. The sections are concatenated into one big object. */
     557    /* TODO! this test has to be enhanced a bit. WWPack32, new Borland++ depends on image layout. */
    555558    fAllInOneObject = (pNtHdrs->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED) == IMAGE_FILE_RELOCS_STRIPPED;
    556559    if (fAllInOneObject)
     
    681684    Yield();
    682685    _res_heapmin();
    683     #if 0 /* testing */
     686    #ifndef RING0
     687    #if 1 /* testing */
    684688    testApplyFixups();
     689    #endif
    685690    #endif
    686691
     
    11011106
    11021107        while ((unsigned)pbr - (unsigned)pBaseRelocs + 8 < cbBaseRelocs /* 8= VirtualAddress and SizeOfBlock members */
     1108               && pbr->SizeOfBlock >= 8
    11031109               && pbr->VirtualAddress < ulRVAPage + PAGESIZE)
    11041110        {
     
    15851591    NOREF(pLdrLv);
    15861592    NOREF(pful);
     1593    NOREF(fOdin32PathValid);
    15871594    return ERROR_NOT_SUPPORTED;
    15881595    #endif
     
    16221629    }
    16231630
    1624     rc = readAtRVA(0x00000000, &achPage[0], PAGESIZE);
    1625     if (rc != NO_ERROR)
    1626     {
    1627         printErr(("readAtRVA failed with rc=%d\n"));
    1628         return rc;
    1629     }
    1630     rc = applyFixups(&mte, 0, ~0UL, &achPage[0], 0x125D0000, NULL);
    1631 
    1632     rc = readAtRVA(0x00001000, &achPage[0], PAGESIZE);
    1633     if (rc != NO_ERROR)
    1634     {
    1635         printErr(("readAtRVA failed with rc=%d\n"));
    1636         return rc;
    1637     }
    1638     rc = applyFixups(&mte, 1, 1, &achPage[0], 0x125E0000, NULL);
     1631    /*
     1632     * Test load and apply all (internal) fixups.
     1633     */
     1634    for (i = 0; i < cObjects; i++)
     1635    {
     1636        ULONG ulAddress = smte.smte_objtab[i].ote_base;
     1637        ULONG ulRVA = paObjects[i].ulRVA;
     1638        LONG  cbObject = paObjects[i].cbVirtual;
     1639        for (i=i; cbObject > 0; cbObject -= PAGESIZE, ulAddress += PAGESIZE, ulRVA += PAGESIZE)
     1640        {
     1641            rc = readAtRVA(ulRVA, &achPage[0], PAGESIZE);
     1642            if (rc != NO_ERROR)
     1643            {
     1644                printErr(("readAtRVA failed with rc=%d\n"));
     1645                return rc;
     1646            }
     1647            rc = applyFixups(&mte, 1, 1, &achPage[0], ulAddress, NULL);
     1648            if (rc != NO_ERROR)
     1649            {
     1650                printErr(("applyFixups failed with rc=%d\n"));
     1651                return rc;
     1652            }
     1653        }
     1654    }
    16391655
    16401656    return rc;
     
    16901706        {
    16911707            ULONG cbToRead = min(cbLXFile, sizeof(achReadBuffer));
    1692             rc = read(offLXFile, &achReadBuffer[0], cbToRead, 0UL, NULL);
     1708            rc = read(offLXFile, &achReadBuffer[0], 0UL, cbToRead, NULL);
    16931709            if (rc != NO_ERROR)
    16941710            {
     
    31083124            {
    31093125                PIMAGE_BASE_RELOCATION pbrCur = pBaseRelocs;
    3110                 while ((void*)pbrCur < (void*)((unsigned)pBaseRelocs + cbBaseRelocs))
     3126                while ((void*)pbrCur < (void*)((unsigned)pBaseRelocs + cbBaseRelocs)
     3127                       && pbrCur->SizeOfBlock >= 8)
    31113128                {
    31123129                    if ((unsigned)pbrCur->SizeOfBlock + (unsigned)pbrCur > (unsigned)pBaseRelocs + cbBaseRelocs)
Note: See TracChangeset for help on using the changeset viewer.