VirtualBox

Ignore:
Timestamp:
Aug 17, 2015 11:54:27 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
102142
Message:

SUPDrv: Modified SUP_IOCTL_LDR_LOAD to return an error string, major support driver version bump, and removed the long obsolete VMMR0EntryInt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

    r57358 r57378  
    18431843
    18441844/**
    1845  * memcmp + log.
     1845 * memcmp + errormsg + log.
    18461846 *
    18471847 * @returns Same as memcmp.
     
    18501850 * @param   uRva            The RVA to start comparing at.
    18511851 * @param   cb              The number of bytes to compare.
    1852  */
    1853 static int supdrvNtCompare(PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, uint32_t uRva, uint32_t cb)
     1852 * @param   pReq            The load request.
     1853 */
     1854static int supdrvNtCompare(PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, uint32_t uRva, uint32_t cb, PSUPLDRLOAD pReq)
    18541855{
    18551856    int iDiff = memcmp((uint8_t const *)pImage->pvImage + uRva, pbImageBits + uRva, cb);
     
    18611862            if (pbNativeBits[off] != pbImageBits[off])
    18621863            {
    1863                 char szBytes[128];
    1864                 RTStrPrintf(szBytes, sizeof(szBytes), "native: %.*Rhxs  our: %.*Rhxs",
    1865                             RT_MIN(12, cbLeft), &pbNativeBits[off],
    1866                             RT_MIN(12, cbLeft), &pbImageBits[off]);
    1867                 SUPR0Printf("VBoxDrv: Mismatch at %#x of %s: %s\n", off, pImage->szName, szBytes);
     1864                /* Note! We need to copy image bits into a temporary stack buffer here as we'd
     1865                         otherwise risk overwriting them while formatting the error message. */
     1866                uint8_t abBytes[64];
     1867                memcpy(abBytes, &pbImageBits[off], RT_MIN(64, cbLeft));
     1868                supdrvLdrLoadError(VERR_LDR_MISMATCH_NATIVE, pReq,
     1869                                   "Mismatch at %#x of %s:\n"
     1870                                   "ntld: %.*Rhxs\n"
     1871                                   "iprt: %.*Rhxs",
     1872                                   off, pImage->szName,
     1873                                   RT_MIN(64, cbLeft), &pbNativeBits[off],
     1874                                   RT_MIN(64, cbLeft), &abBytes[0]);
     1875                SUPR0Printf("VBoxDrv: %s", pReq->u.Out.szError);
    18681876                break;
    18691877            }
     
    18721880}
    18731881
     1882
    18741883int  VBOXCALL   supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq)
    18751884{
    1876     NOREF(pDevExt); NOREF(pReq);
     1885    NOREF(pDevExt);
    18771886    if (pImage->pvNtSectionObj)
    18781887    {
     
    19551964            {
    19561965                if (uRvaNext < aExcludeRgns[i].uRva)
    1957                     iDiff = supdrvNtCompare(pImage, pbImageBits, uRvaNext, aExcludeRgns[i].uRva - uRvaNext);
     1966                    iDiff = supdrvNtCompare(pImage, pbImageBits, uRvaNext, aExcludeRgns[i].uRva - uRvaNext, pReq);
    19581967                uRvaNext = aExcludeRgns[i].uRva + aExcludeRgns[i].cb;
    19591968            }
    19601969            if (!iDiff && uRvaNext < pImage->cbImageBits)
    1961                 iDiff = supdrvNtCompare(pImage, pbImageBits, uRvaNext, pImage->cbImageBits - uRvaNext);
     1970                iDiff = supdrvNtCompare(pImage, pbImageBits, uRvaNext, pImage->cbImageBits - uRvaNext, pReq);
    19621971            if (!iDiff)
    19631972                return VINF_SUCCESS;
    19641973        }
    19651974        else
    1966             supdrvNtCompare(pImage, pbImageBits, 0, pImage->cbImageBits);
     1975            supdrvNtCompare(pImage, pbImageBits, 0, pImage->cbImageBits, pReq);
    19671976        return VERR_LDR_MISMATCH_NATIVE;
    19681977    }
    1969     return VERR_INTERNAL_ERROR_4;
     1978    return supdrvLdrLoadError(VERR_INTERNAL_ERROR_4, pReq, "No NT section object! Impossible!");
    19701979}
    19711980
Note: See TracChangeset for help on using the changeset viewer.

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