VirtualBox

Changeset 58727 in vbox


Ignore:
Timestamp:
Nov 18, 2015 12:28:21 AM (9 years ago)
Author:
vboxsync
Message:

rtldrPEOpen: Set pErrInfo on VERR_LDR_ARCH_MISMATCH.

Location:
trunk/src/VBox/Runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/ldr/ldrEx.cpp

    r57358 r58727  
    730730}
    731731
     732
     733/**
     734 * Translates a RTLDRARCH value to a string.
     735 *
     736 * @returns Name corresponding to @a enmArch
     737 * @param   enmArch             The value to name.
     738 */
     739DECLHIDDEN(const char *) rtLdrArchName(RTLDRARCH enmArch)
     740{
     741    switch (enmArch)
     742    {
     743        case RTLDRARCH_INVALID:     return "INVALID";
     744        case RTLDRARCH_WHATEVER:    return "WHATEVER";
     745        case RTLDRARCH_HOST:        return "HOST";
     746        case RTLDRARCH_AMD64:       return "AMD64";
     747        case RTLDRARCH_X86_32:      return "X86_32";
     748
     749        case RTLDRARCH_END:
     750        case RTLDRARCH_32BIT_HACK:
     751            break;
     752    }
     753    return "UNKNOWN";
     754}
  • trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp

    r57974 r58727  
    36233623
    36243624
     3625static const char *rtldrPEGetArchName(uint16_t uMachine)
     3626{
     3627    switch (uMachine)
     3628    {
     3629        case IMAGE_FILE_MACHINE_I386:   return "X86_32";
     3630        case IMAGE_FILE_MACHINE_AMD64:  return "AMD64";
     3631        default:                        return "Unknown";
     3632    }
     3633}
     3634
     3635
     3636
    36253637/**
    36263638 * Open a PE image.
     
    36593671    {
    36603672        if (!(fFlags & RTLDR_O_IGNORE_ARCH_IF_NO_CODE))
    3661             return VERR_LDR_ARCH_MISMATCH;
     3673            return RTErrInfoSetF(pErrInfo, VERR_LDR_ARCH_MISMATCH, "Image is for '%s', only accepting images for '%s'.",
     3674                                 rtldrPEGetArchName(FileHdr.Machine), rtLdrArchName(enmArch));
    36623675        fArchNoCodeCheckPending = true;
    36633676    }
     
    36763689        return rc;
    36773690    if (fArchNoCodeCheckPending && OptHdr.SizeOfCode != 0)
    3678         return VERR_LDR_ARCH_MISMATCH;
     3691        return RTErrInfoSetF(pErrInfo, VERR_LDR_ARCH_MISMATCH,
     3692                             "Image is for '%s' and contains code (%#x), only accepting images for '%s' with code.",
     3693                             rtldrPEGetArchName(FileHdr.Machine), OptHdr.SizeOfCode, rtLdrArchName(enmArch));
    36793694
    36803695    /*
  • trunk/src/VBox/Runtime/include/internal/ldr.h

    r57974 r58727  
    497497
    498498DECLHIDDEN(int) rtLdrReadAt(RTLDRMOD hLdrMod, void *pvBuf, uint32_t iDbgInfo, RTFOFF off, size_t cb);
     499DECLHIDDEN(const char *) rtLdrArchName(RTLDRARCH enmArch);
    499500
    500501RT_C_DECLS_END
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