Changeset 25 for trunk/kLdr/kLdrModPE.c


Ignore:
Timestamp:
Feb 19, 2009, 1:56:15 AM (16 years ago)
Author:
bird
Message:

A blind shot at FAT Mach-O images.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdrModPE.c

    r2 r25  
    136136 * @param   pOps            Pointer to the registered method table.
    137137 * @param   pRdr            The file provider instance to use.
     138 * @param   fFlags          Flags, MBZ.
     139 * @param   enmCpuArch      The desired CPU architecture. KCPUARCH_UNKNOWN means
     140 *                          anything goes, but with a preference for the current
     141 *                          host architecture.
    138142 * @param   offNewHdr       The offset of the new header in MZ files. -1 if not found.
    139143 * @param   ppMod           Where to store the module instance pointer.
    140144 */
    141 static int kldrModPECreate(PCKLDRMODOPS pOps, PKRDR pRdr, KLDRFOFF offNewHdr, PPKLDRMOD ppMod)
     145static int kldrModPECreate(PCKLDRMODOPS pOps, PKRDR pRdr, KU32 fFlags, KCPUARCH enmCpuArch, KLDRFOFF offNewHdr, PPKLDRMOD ppMod)
    142146{
    143147    PKLDRMODPE pModPE;
     
    150154    if (!rc)
    151155    {
    152         pModPE->pMod->pOps = pOps;
    153         pModPE->pMod->u32Magic = KLDRMOD_MAGIC;
    154         *ppMod = pModPE->pMod;
    155         return 0;
     156        /*
     157         * Match up against the requested CPU architecture.
     158         */
     159        if (    enmCpuArch == KCPUARCH_UNKNOWN
     160            ||  pModPE->pMod->enmArch == enmCpuArch)
     161        {
     162            pModPE->pMod->pOps = pOps;
     163            pModPE->pMod->u32Magic = KLDRMOD_MAGIC;
     164            *ppMod = pModPE->pMod;
     165            return 0;
     166        }
     167        rc = KLDR_ERR_CPU_ARCH_MISMATCH;
    156168    }
    157169    kHlpFree(pModPE);
Note: See TracChangeset for help on using the changeset viewer.