Changeset 1756 for trunk/src


Ignore:
Timestamp:
Nov 16, 1999, 6:09:31 PM (26 years ago)
Author:
bird
Message:

Another bug - empty baserelocation chunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/pe2lx/pe2lx.cpp

    r1755 r1756  
    1 /* $Id: pe2lx.cpp,v 1.9 1999-11-16 16:11:43 bird Exp $
     1/* $Id: pe2lx.cpp,v 1.10 1999-11-16 17:09:31 bird Exp $
    22 *
    33 * Pe2Lx class implementation. Ring 0 and Ring 3
     
    19091909        rc = pRelocReader->readAtRVA(ulRVABaseReloc, SSToDS(&BaseReloc), sizeof(BaseReloc));
    19101910
    1911 
    19121911    /*
    19131912     *  The Loop! Iterate thru all pages for all objects.
     
    20272026            PWORD pawoffFixup;
    20282027
    2029             pawoffFixup = (PWORD)malloc((size_t)(c * sizeof(WORD)));
    2030             if (pawoffFixup != NULL)
    2031                 rc = pRelocReader->readAtRVA(ulRVABaseReloc + offsetof(IMAGE_BASE_RELOCATION, TypeOffset),
    2032                                              pawoffFixup, c * sizeof(WORD));
    2033             else
    2034                 rc = ERROR_NOT_ENOUGH_MEMORY;
    2035 
    2036             /* loop thru the baserelocation in this chunk. */
    2037             for (ul = 0; ul < c && rc == NO_ERROR; ul++)
     2028            if (c != 0)
    20382029            {
    2039                 WORD  woffFixup;
    2040                 ULONG ulTarget;
    2041                 /* Get relocation type/offset. */
     2030                pawoffFixup = (PWORD)malloc((size_t)(c * sizeof(WORD)));
    20422031                if (pawoffFixup != NULL)
    2043                     woffFixup = pawoffFixup[ul];
    2044 
    2045                 /* Get target. */
    2046                 rc = pPageReader->readAtRVA(BaseReloc.VirtualAddress + (woffFixup & 0x0FFF),
    2047                                             SSToDS(&ulTarget), sizeof(ulTarget));
    2048                 if (rc == NO_ERROR)
     2032                    rc = pRelocReader->readAtRVA(ulRVABaseReloc + offsetof(IMAGE_BASE_RELOCATION, TypeOffset),
     2033                                                 pawoffFixup, c * sizeof(WORD));
     2034                else
     2035                    rc = ERROR_NOT_ENOUGH_MEMORY;
     2036
     2037                /* loop thru the baserelocation in this chunk. */
     2038                for (ul = 0; ul < c && rc == NO_ERROR; ul++)
    20492039                {
    2050                     switch (woffFixup >> 12)
     2040                    WORD  woffFixup;
     2041                    ULONG ulTarget;
     2042                    /* Get relocation type/offset. */
     2043                    if (pawoffFixup != NULL)
     2044                        woffFixup = pawoffFixup[ul];
     2045
     2046                    /* Get target. */
     2047                    rc = pPageReader->readAtRVA(BaseReloc.VirtualAddress + (woffFixup & 0x0FFF),
     2048                                                SSToDS(&ulTarget), sizeof(ulTarget));
     2049                    if (rc == NO_ERROR)
    20512050                    {
    2052                         case IMAGE_REL_BASED_HIGHLOW:
    2053                             rc = add32OffsetFixup((WORD)(woffFixup & 0x0FFF), ulTarget);
    2054                             printInfA(("Fixup: 0x%03x target 0x%08x (rc = %d) %s\n",
    2055                                        (woffFixup & 0x0FFF), ulTarget, rc,
    2056                                        pvCrossPageFixup ? "crosspage" : ""));
    2057                             break;
    2058                         case IMAGE_REL_BASED_ABSOLUTE: /* ignored! */
    2059                             break;
    2060                         default:
    2061                             printWar(("Unknown/unsupported fixup type!, 0x%1x\n", woffFixup >> 12));
     2051                        switch (woffFixup >> 12)
     2052                        {
     2053                            case IMAGE_REL_BASED_HIGHLOW:
     2054                                rc = add32OffsetFixup((WORD)(woffFixup & 0x0FFF), ulTarget);
     2055                                printInfA(("Fixup: 0x%03x target 0x%08x (rc = %d) %s\n",
     2056                                           (woffFixup & 0x0FFF), ulTarget, rc,
     2057                                           pvCrossPageFixup ? "crosspage" : ""));
     2058                                break;
     2059                            case IMAGE_REL_BASED_ABSOLUTE: /* ignored! */
     2060                                break;
     2061                            default:
     2062                                printWar(("Unknown/unsupported fixup type!, 0x%1x\n", woffFixup >> 12));
     2063                        }
    20622064                    }
    20632065                }
    20642066            }
     2067
    20652068            /* cleanup */
    20662069            if (pawoffFixup != NULL)
Note: See TracChangeset for help on using the changeset viewer.