VirtualBox

Ignore:
Timestamp:
Feb 18, 2009 11:42:57 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
43082
Message:

IPRT/PDM,SUPLIb,REM: Extended RTLdrOpen with an architecture argument for use with FAT R0.r0 images later some day. Also added fFlags argument that's currently MBZ case.

File:
1 edited

Legend:

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

    r13837 r16933  
    944944 * @param   pFileHdr    Pointer to the file header that needs validating.
    945945 * @param   pszLogName  The log name to  prefix the errors with.
    946  */
    947 int rtldrPEValidateFileHeader(PIMAGE_FILE_HEADER pFileHdr, const char *pszLogName)
     946 * @param   penmArch    Where to store the CPU architecture.
     947 */
     948int rtldrPEValidateFileHeader(PIMAGE_FILE_HEADER pFileHdr, const char *pszLogName, PRTLDRARCH penmArch)
    948949{
    949950    size_t cbOptionalHeader;
     
    952953        case IMAGE_FILE_MACHINE_I386:
    953954            cbOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER32);
     955            *penmArch = RTLDRARCH_X86_32;
    954956            break;
    955957        case IMAGE_FILE_MACHINE_AMD64:
    956958            cbOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER64);
     959            *penmArch = RTLDRARCH_AMD64;
    957960            break;
    958961
     
    960963            Log(("rtldrPEOpen: %s: Unsupported Machine=%#x\n",
    961964                 pszLogName, pFileHdr->Machine));
     965            *penmArch = RTLDRARCH_INVALID;
    962966            return VERR_BAD_EXE_FORMAT;
    963967    }
     
    14171421 * @returns iprt status code.
    14181422 * @param   pReader     The loader reader instance which will provide the raw image bits.
     1423 * @param   fFlags      Reserved, MBZ.
     1424 * @param   enmArch     Architecture specifier.
    14191425 * @param   offNtHdrs   The offset of the NT headers (where you find "PE\0\0").
    14201426 * @param   phLdrMod    Where to store the handle.
    14211427 */
    1422 int rtldrPEOpen(PRTLDRREADER pReader, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod)
     1428int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod)
    14231429{
    14241430    /*
     
    14291435    if (RT_FAILURE(rc))
    14301436        return rc;
     1437    RTLDRARCH enmArchImage;
    14311438    const char *pszLogName = pReader->pfnLogName(pReader);
    1432     rc = rtldrPEValidateFileHeader(&FileHdr, pszLogName);
     1439    rc = rtldrPEValidateFileHeader(&FileHdr, pszLogName, &enmArchImage);
    14331440    if (RT_FAILURE(rc))
    14341441        return rc;
     1442
     1443    /*
     1444     * Match the CPU architecture.
     1445     */
     1446    if (    enmArch != RTLDRARCH_WHATEVER
     1447        &&  enmArch != enmArchImage)
     1448        return VERR_LDR_ARCH_MISMATCH;
    14351449
    14361450    /*
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