VirtualBox

Changeset 82 in kStuff for trunk


Ignore:
Timestamp:
Aug 22, 2016 9:01:51 PM (8 years ago)
Author:
bird
Message:

kLdrModNative.c: Report the actual section load addresses in the aSegments[].MapAddress members.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/k/kLdrFmts/pe.h

    r31 r82  
    375375{
    376376    KU16      Hint;
    377     KU8      Name[1];
     377    KU8       Name[1];
    378378} IMAGE_IMPORT_BY_NAME;
    379379typedef IMAGE_IMPORT_BY_NAME *PIMAGE_IMPORT_BY_NAME;
  • trunk/kHlp/Bare/kHlpBareAssert.c

    r29 r82  
    8282        cbWritten = pszNl - pszMsg;
    8383
    84 #if K_OS == K_OS_OS2
     84# if K_OS == K_OS_OS2
    8585        if (cbWritten)
    8686            DosWrite((HFILE)2, pszMsg, cbWritten, &cbWritten);
    8787        DosWrite((HFILE)2, "\r\n", 2, &cbWritten);
    88 #else /* K_OS == K_OS_WINDOWS */
     88# else /* K_OS == K_OS_WINDOWS */
    8989        if (cbWritten)
    9090            WriteFile((HANDLE)STD_ERROR_HANDLE, pszMsg, cbWritten, &cbWritten, NULL);
    9191        WriteFile((HANDLE)STD_ERROR_HANDLE, "\r\n", 2, &cbWritten, NULL);
    92 #endif
     92# endif
    9393
    9494        /* next */
     
    103103    {
    104104        cbWritten = kHlpStrLen(pszMsg);
    105 #if K_OS == K_OS_OS2
     105# if K_OS == K_OS_OS2
    106106        DosWrite((HFILE)2, pszMsg, cbWritten, &cbWritten);
    107 #else /* K_OS == K_OS_WINDOWS */
     107# else /* K_OS == K_OS_WINDOWS */
    108108        WriteFile((HANDLE)STD_ERROR_HANDLE, pszMsg, cbWritten, &cbWritten, NULL);
    109 #endif
     109# endif
    110110    }
    111111
  • trunk/kLdr/kLdrModNative.c

    r81 r82  
    239239{
    240240    KSIZE cb;
    241     KSIZE cchFilename;
     241    KU32 cchFilename;
    242242    KU32 cSegments;
    243243    PKLDRMOD pMod;
     
    309309     * Calc the instance size, allocate and initialize it.
    310310     */
    311     cchFilename = kHlpStrLen(szFilename);
     311    cchFilename = (KU32)kHlpStrLen(szFilename);
    312312    cb = K_ALIGN_Z(sizeof(KLDRMODNATIVE), 16)
    313313       + K_OFFSETOF(KLDRMOD, aSegments[cSegments])
     
    327327    kHlpMemCopy((char *)pMod->pszFilename, szFilename, cchFilename + 1);
    328328    pMod->pszName = kHlpGetFilename(pMod->pszFilename); /** @todo get soname */
    329     pMod->cchName = cchFilename - (pMod->pszName - pMod->pszFilename);
     329    pMod->cchName = cchFilename - (KU32)(pMod->pszName - pMod->pszFilename);
    330330    pMod->fFlags = 0;
    331331#if defined(__i386__) || defined(__X86__) || defined(_M_IX86)
     
    398398    else
    399399        pMod->aSegments[0].cbMapped = pNtHdrs->OptionalHeader.SizeOfHeaders;
    400     pMod->aSegments[0].MapAddress = 0;
     400    pMod->aSegments[0].MapAddress = uHandle;
    401401
    402402    /* The section headers. */
     
    404404    {
    405405        const char *pch;
     406        KU32        cchSegName;
    406407
    407408        /* unused */
    408409        pMod->aSegments[i + 1].pvUser = NULL;
    409         pMod->aSegments[i + 1].MapAddress = 0;
    410410
    411411        /* name */
    412412        pMod->aSegments[i + 1].pchName = pch = &paShdrs[i].Name[0];
    413         cb = IMAGE_SIZEOF_SHORT_NAME;
    414         while (     cb > 0
    415                &&   (pch[cb - 1] == ' ' || pch[cb - 1] == '\0'))
    416             cb--;
    417         pMod->aSegments[i + 1].cchName = cb;
     413        cchSegName = IMAGE_SIZEOF_SHORT_NAME;
     414        while (    cchSegName > 0
     415               && (pch[cchSegName - 1] == ' ' || pch[cchSegName - 1] == '\0'))
     416            cchSegName--;
     417        pMod->aSegments[i + 1].cchName = cchSegName;
    418418
    419419        /* size and addresses */
     
    421421        {
    422422            pMod->aSegments[i + 1].cb          = paShdrs[i].Misc.VirtualSize;
    423             pMod->aSegments[i + 1].LinkAddress = paShdrs[i].VirtualAddress
    424                                                + pNtHdrs->OptionalHeader.ImageBase;
    425423            pMod->aSegments[i + 1].RVA         = paShdrs[i].VirtualAddress;
     424            pMod->aSegments[i + 1].LinkAddress = paShdrs[i].VirtualAddress + pNtHdrs->OptionalHeader.ImageBase;
     425            pMod->aSegments[i + 1].MapAddress  = paShdrs[i].VirtualAddress + uHandle;
    426426            pMod->aSegments[i + 1].cbMapped    = paShdrs[i].Misc.VirtualSize;
    427427            if (i + 2 < pMod->cSegments)
    428                 pMod->aSegments[i + 1].cbMapped= paShdrs[i + 1].VirtualAddress
    429                                                - paShdrs[i].VirtualAddress;
     428                pMod->aSegments[i + 1].cbMapped = paShdrs[i + 1].VirtualAddress
     429                                                - paShdrs[i].VirtualAddress;
    430430        }
    431431        else
     
    435435            pMod->aSegments[i + 1].LinkAddress = NIL_KLDRADDR;
    436436            pMod->aSegments[i + 1].RVA         = 0;
     437            pMod->aSegments[i + 1].MapAddress  = 0;
    437438        }
    438439
    439440        /* file location */
    440441        pMod->aSegments[i + 1].offFile = paShdrs[i].PointerToRawData;
    441         pMod->aSegments[i + 1].cbFile = paShdrs[i].SizeOfRawData;
     442        pMod->aSegments[i + 1].cbFile  = paShdrs[i].SizeOfRawData;
    442443        if (    pMod->aSegments[i + 1].cbMapped > 0 /* if mapped */
    443444            &&  (KLDRSIZE)pMod->aSegments[i + 1].cbFile > pMod->aSegments[i + 1].cbMapped)
    444             pMod->aSegments[i + 1].cbFile = pMod->aSegments[i + 1].cbMapped;
     445            pMod->aSegments[i + 1].cbFile = (KLDRFOFF)pMod->aSegments[i + 1].cbMapped;
    445446
    446447        /* protection */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette