Changeset 85


Ignore:
Timestamp:
Sep 6, 2016, 5:21:04 AM (9 years ago)
Author:
bird
Message:

fixes

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/kHlp/Generic/kHlpGetFilename.c

    r29 r85  
    55
    66/*
    7  * Copyright (c) 2006-2007 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
     7 * Copyright (c) 2006-2016 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
    88 *
    99 * Permission is hereby granted, free of charge, to any person
     
    4545KHLP_DECL(char *) kHlpGetFilename(const char *pszFilename)
    4646{
    47     const char *pszLast = NULL;
     47    const char *pszLast = pszFilename;
    4848    for (;;)
    4949    {
     
    6464        }
    6565#endif
    66         if (!ch)
    67             return (char *)(pszLast ? pszLast : pszFilename);
    68         pszFilename++;
     66        if (ch)
     67            pszFilename++;
     68        else
     69            return (char *)pszLast;
    6970    }
    7071}
  • trunk/kLdr/kLdrModPE.c

    r81 r85  
    336336        pMod->aSegments[i + 1].pchName = pch = (const char *)&pModPE->aShdrs[i].Name[0];
    337337        cb = IMAGE_SIZEOF_SHORT_NAME;
    338         while (     cb > 0
    339                &&   (pch[cb - 1] == ' ' || pch[cb - 1] == '\0'))
     338        while (   cb > 0
     339               && (pch[cb - 1] == ' ' || pch[cb - 1] == '\0'))
    340340            cb--;
    341341        pMod->aSegments[i + 1].cchName = cb;
     
    344344        if (!(pModPE->aShdrs[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD))
    345345        {
     346            /* Kluge to deal with wlink ".reloc" sections that has a VirtualSize of 0 bytes. */
     347            KU32 cb = pModPE->aShdrs[i].Misc.VirtualSize;
     348            if (!cb)
     349                cb = K_ALIGN_Z(pModPE->aShdrs[i].SizeOfRawData, pModPE->Hdrs.OptionalHeader.SectionAlignment);
    346350            pMod->aSegments[i + 1].cb          = pModPE->aShdrs[i].Misc.VirtualSize;
    347351            pMod->aSegments[i + 1].LinkAddress = pModPE->aShdrs[i].VirtualAddress
    348352                                               + pModPE->Hdrs.OptionalHeader.ImageBase;
    349353            pMod->aSegments[i + 1].RVA         = pModPE->aShdrs[i].VirtualAddress;
    350             pMod->aSegments[i + 1].cbMapped    = pModPE->aShdrs[i].Misc.VirtualSize;
     354            pMod->aSegments[i + 1].cbMapped    = cb;
    351355            if (i + 2 < pMod->cSegments)
    352356                pMod->aSegments[i + 1].cbMapped= pModPE->aShdrs[i + 1].VirtualAddress
     
    363367        /* file location */
    364368        pMod->aSegments[i + 1].offFile = pModPE->aShdrs[i].PointerToRawData;
    365         pMod->aSegments[i + 1].cbFile = pModPE->aShdrs[i].SizeOfRawData;
     369        pMod->aSegments[i + 1].cbFile  = pModPE->aShdrs[i].SizeOfRawData;
    366370        if (    pMod->aSegments[i + 1].cbMapped > 0 /* if mapped */
    367371            &&  (KLDRSIZE)pMod->aSegments[i + 1].cbFile > pMod->aSegments[i + 1].cbMapped)
Note: See TracChangeset for help on using the changeset viewer.