Ignore:
Timestamp:
Aug 27, 2007, 9:54:05 PM (18 years ago)
Author:
bird
Message:

Use the new type system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kStuff/kLdr/kLdrModLX.c

    r3537 r3567  
    6565    const void             *pvMapping;
    6666    /** The size of the mapped LX image. */
    67     size_t                  cbMapped;
     67    KSIZE                   cbMapped;
    6868    /** Reserved flags. */
    69     uint32_t                f32Reserved;
     69    KU32                    f32Reserved;
    7070
    7171    /** The offset of the LX header. */
     
    7676    /** Pointer to the loader section.
    7777     * Allocated together with this strcture. */
    78     const uint8_t          *pbLoaderSection;
     78    const KU8              *pbLoaderSection;
    7979    /** Pointer to the last byte in the loader section. */
    80     const uint8_t          *pbLoaderSectionLast;
     80    const KU8              *pbLoaderSectionLast;
    8181    /** Pointer to the object table in the loader section. */
    8282    const struct o32_obj   *paObjs;
     
    8686    const struct rsrc32    *paRsrcs;
    8787    /** Pointer to the resident name table in the loader section. */
    88     const uint8_t          *pbResNameTab;
     88    const KU8              *pbResNameTab;
    8989    /** Pointer to the entry table in the loader section. */
    90     const uint8_t          *pbEntryTab;
     90    const KU8              *pbEntryTab;
    9191
    9292    /** Pointer to the non-resident name table. */
    93     uint8_t                *pbNonResNameTab;
     93    KU8                    *pbNonResNameTab;
    9494    /** Pointer to the last byte in the non-resident name table. */
    95     const uint8_t          *pbNonResNameTabLast;
     95    const KU8              *pbNonResNameTabLast;
    9696
    9797    /** Pointer to the fixup section. */
    98     uint8_t                *pbFixupSection;
     98    KU8                    *pbFixupSection;
    9999    /** Pointer to the last byte in the fixup section. */
    100     const uint8_t          *pbFixupSectionLast;
     100    const KU8              *pbFixupSectionLast;
    101101    /** Pointer to the fixup page table within pvFixupSection. */
    102     const uint32_t         *paoffPageFixups;
     102    const KU32             *paoffPageFixups;
    103103    /** Pointer to the fixup record table within pvFixupSection. */
    104     const uint8_t          *pbFixupRecs;
     104    const KU8              *pbFixupRecs;
    105105    /** Pointer to the import module name table within pvFixupSection. */
    106     const uint8_t          *pbImportMods;
     106    const KU8              *pbImportMods;
    107107    /** Pointer to the import module name table within pvFixupSection. */
    108     const uint8_t          *pbImportProcs;
     108    const KU8              *pbImportProcs;
    109109} KLDRMODLX, *PKLDRMODLX;
    110110
     
    117117                                 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
    118118static int kldrModLXDoCreate(PKLDRRDR pRdr, KLDRFOFF offNewHdr, PKLDRMODLX *ppModLX);
    119 static const uint8_t *kldrModLXDoNameTableLookupByOrdinal(const uint8_t *pbNameTable, int32_t cbNameTable, uint32_t iOrdinal);
    120 static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, uint32_t cchSymbol, uint32_t *piSymbol);
    121 static const uint8_t *kldrModLXDoNameTableLookupByName(const uint8_t *pbNameTable, int32_t cbNameTable,
    122                                                        const char *pchSymbol, size_t cchSymbol);
     119static const KU8 *kldrModLXDoNameTableLookupByOrdinal(const KU8 *pbNameTable, KI32 cbNameTable, KU32 iOrdinal);
     120static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, KU32 cchSymbol, KU32 *piSymbol);
     121static const KU8 *kldrModLXDoNameTableLookupByName(const KU8 *pbNameTable, KI32 cbNameTable,
     122                                                       const char *pchSymbol, KSIZE cchSymbol);
    123123static int kldrModLXDoLoadBits(PKLDRMODLX pModLX, void *pvBits);
    124 static int kldrModLXDoIterDataUnpacking(uint8_t *pbDst, const uint8_t *pbSrc, int cbSrc);
    125 static int kldrModLXDoIterData2Unpacking(uint8_t *pbDst, const uint8_t *pbSrc, int cbSrc);
    126 static void kLdrModLXMemCopyW(uint8_t *pbDst, const uint8_t *pbSrc, int cb);
     124static int kldrModLXDoIterDataUnpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc);
     125static int kldrModLXDoIterData2Unpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc);
     126static void kLdrModLXMemCopyW(KU8 *pbDst, const KU8 *pbSrc, int cb);
    127127static int kldrModLXDoProtect(PKLDRMODLX pModLX, void *pvBits, unsigned fUnprotectOrProtect);
    128 static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, unsigned uOp, uintptr_t uHandle);
     128static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, unsigned uOp, KUPTR uHandle);
    129129static int kldrModLXDoForwarderQuery(PKLDRMODLX pModLX, const struct e32_entry *pEntry,
    130                                      PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t *pfKind);
     130                                     PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind);
    131131static int kldrModLXDoLoadFixupSection(PKLDRMODLX pModLX);
    132 static int32_t kldrModLXDoCall(uintptr_t uEntrypoint, uintptr_t uHandle, uint32_t uOp, void *pvReserved);
    133 static int kldrModLXDoReloc(uint8_t *pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc,
    134                             int iSelector, KLDRADDR uValue, uint32_t fKind);
     132static KI32 kldrModLXDoCall(KUPTR uEntrypoint, KUPTR uHandle, KU32 uOp, void *pvReserved);
     133static int kldrModLXDoReloc(KU8 *pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc,
     134                            int iSelector, KLDRADDR uValue, KU32 fKind);
    135135
    136136
     
    176176    PKLDRMODLX pModLX;
    177177    PKLDRMOD pMod;
    178     size_t cb;
    179     size_t cchFilename;
    180     uint32_t off, offEnd;
    181     uint32_t i;
     178    KSIZE cb;
     179    KSIZE cchFilename;
     180    KU32 off, offEnd;
     181    KU32 i;
    182182    int rc;
    183183    int fCanOptimizeMapping;
    184     uint32_t NextRVA;
     184    KU32 NextRVA;
    185185    *ppModLX = NULL;
    186186
     
    206206
    207207    /* Some rough sanity checks. */
    208     offEnd = kLdrRdrSize(pRdr) >= (KLDRFOFF)~(uint32_t)16 ? ~(uint32_t)16 : (uint32_t)kLdrRdrSize(pRdr);
     208    offEnd = kLdrRdrSize(pRdr) >= (KLDRFOFF)~(KU32)16 ? ~(KU32)16 : (KU32)kLdrRdrSize(pRdr);
    209209    if (    Hdr.e32_itermap > offEnd
    210210        ||  Hdr.e32_datapage > offEnd
     
    278278
    279279    /* KLDRMOD */
    280     pMod = (PKLDRMOD)((uint8_t *)pModLX + KLDR_ALIGN_Z(sizeof(KLDRMODLX), 8));
     280    pMod = (PKLDRMOD)((KU8 *)pModLX + KLDR_ALIGN_Z(sizeof(KLDRMODLX), 8));
    281281    pMod->pvData = pModLX;
    282282    pMod->pRdr = pRdr;
     
    361361    if (rc)
    362362        return rc;
    363     ((uint8_t *)pModLX->pbLoaderSectionLast)[1] = 0;
    364     ((uint8_t *)pModLX->pbLoaderSectionLast)[2] = 0;
     363    ((KU8 *)pModLX->pbLoaderSectionLast)[1] = 0;
     364    ((KU8 *)pModLX->pbLoaderSectionLast)[2] = 0;
    365365    if (pModLX->Hdr.e32_objcnt)
    366366        pModLX->paObjs = (const struct o32_obj *)pModLX->pbLoaderSection;
     
    386386    if (!pMod->pszName)
    387387        return KLDR_ERR_LX_NO_SONAME;
    388     pMod->cchName = *(const uint8_t *)pMod->pszName++;
     388    pMod->cchName = *(const KU8 *)pMod->pszName++;
    389389    if (pMod->cchName != kLdrHlpStrLen(pMod->pszName))
    390390        return KLDR_ERR_LX_BAD_SONAME;
     
    403403            return KLDR_ERR_LX_BAD_OBJECT_TABLE;
    404404        if (    pModLX->paObjs[i].o32_mapsize
    405             &&  (   (uint8_t *)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap] > pModLX->pbLoaderSectionLast
    406                  || (uint8_t *)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap + pModLX->paObjs[i].o32_mapsize]
     405            &&  (   (KU8 *)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap] > pModLX->pbLoaderSectionLast
     406                 || (KU8 *)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap + pModLX->paObjs[i].o32_mapsize]
    407407                     > pModLX->pbLoaderSectionLast))
    408408            return KLDR_ERR_LX_BAD_OBJECT_TABLE;
     
    564564
    565565/** @copydoc kLdrModQuerySymbol */
    566 static int kldrModLXQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t iSymbol,
    567                                 const char *pchSymbol, size_t cchSymbol, const char *pszVersion,
    568                                 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t *pfKind)
     566static int kldrModLXQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol,
     567                                const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion,
     568                                PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind)
    569569{
    570570    PKLDRMODLX                  pModLX = (PKLDRMODLX)pMod->pvData;
    571     uint32_t                    iOrdinal;
     571    KU32                        iOrdinal;
    572572    int                         rc;
    573573    const struct b32_bundle     *pBundle;
     
    598598    while (pBundle->b32_cnt && iOrdinal <= iSymbol)
    599599    {
    600         static const size_t s_cbEntry[] = { 0, 3, 5, 5, 7 };
     600        static const KSIZE s_cbEntry[] = { 0, 3, 5, 5, 7 };
    601601
    602602        /*
     
    606606        if (iSymbol < iOrdinal)
    607607        {
    608             uint32_t offObject;
    609             const struct e32_entry *pEntry = (const struct e32_entry *)((uintptr_t)(pBundle + 1)
     608            KU32 offObject;
     609            const struct e32_entry *pEntry = (const struct e32_entry *)((KUPTR)(pBundle + 1)
    610610                                                                        +   (iSymbol - (iOrdinal - pBundle->b32_cnt))
    611611                                                                          * s_cbEntry[pBundle->b32_type]);
     
    674674        }
    675675        if (pBundle->b32_type == 0)
    676             pBundle = (const struct b32_bundle *)((const uint8_t *)pBundle + 2);
     676            pBundle = (const struct b32_bundle *)((const KU8 *)pBundle + 2);
    677677        else
    678             pBundle = (const struct b32_bundle *)((const uint8_t *)(pBundle + 1) + s_cbEntry[pBundle->b32_type] * pBundle->b32_cnt);
     678            pBundle = (const struct b32_bundle *)((const KU8 *)(pBundle + 1) + s_cbEntry[pBundle->b32_type] * pBundle->b32_cnt);
    679679    }
    680680
     
    692692 * @param   piSymbol    Where to store the symbol ordinal.
    693693 */
    694 static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, uint32_t cchSymbol, uint32_t *piSymbol)
     694static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, KU32 cchSymbol, KU32 *piSymbol)
    695695{
    696696
     
    703703     * Search the name tables.
    704704     */
    705     const uint8_t *pbName = kldrModLXDoNameTableLookupByName(pModLX->pbResNameTab,
    706                                                              pModLX->pbLoaderSectionLast - pModLX->pbResNameTab + 1,
    707                                                              pchSymbol, cchSymbol);
     705    const KU8 *pbName = kldrModLXDoNameTableLookupByName(pModLX->pbResNameTab,
     706                                                         pModLX->pbLoaderSectionLast - pModLX->pbResNameTab + 1,
     707                                                         pchSymbol, cchSymbol);
    708708    if (!pbName)
    709709    {
     
    721721        return KLDR_ERR_SYMBOL_NOT_FOUND;
    722722
    723     *piSymbol = *(const uint16_t *)(pbName + 1 + *pbName);
     723    *piSymbol = *(const KU16 *)(pbName + 1 + *pbName);
    724724    return 0;
    725725}
     
    743743 * elsewhere.
    744744 */
    745 static uint32_t kldrModLXDoHash(const char *pchSymbol, uint8_t cchSymbol)
    746 {
    747     uint32_t hash = 0;
     745static KU32 kldrModLXDoHash(const char *pchSymbol, KU8 cchSymbol)
     746{
     747    KU32 hash = 0;
    748748    int ch;
    749749
     
    767767 * @param   cchSymbol       The length of the symbol name.
    768768 */
    769 static const uint8_t *kldrModLXDoNameTableLookupByName(const uint8_t *pbNameTable, int32_t cbNameTable,
    770                                                        const char *pchSymbol, size_t cchSymbol)
     769static const KU8 *kldrModLXDoNameTableLookupByName(const KU8 *pbNameTable, KI32 cbNameTable,
     770                                                   const char *pchSymbol, KSIZE cchSymbol)
    771771{
    772772    /*
    773773     * Determin the namelength up front so we can skip anything which doesn't matches the length.
    774774     */
    775     uint8_t         cbSymbol8Bit = (uint8_t)cchSymbol;
     775    KU8 cbSymbol8Bit = (KU8)cchSymbol;
    776776    if (cbSymbol8Bit != cchSymbol)
    777777        return NULL; /* too long. */
     
    782782    while (*pbNameTable != 0 && cbNameTable > 0)
    783783    {
    784         const uint8_t  cbName = *pbNameTable;
     784        const KU8 cbName = *pbNameTable;
    785785
    786786        cbNameTable -= cbName + 1 + 2;
     
    812812 */
    813813static int kldrModLXDoForwarderQuery(PKLDRMODLX pModLX, const struct e32_entry *pEntry,
    814                                      PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t *pfKind)
     814                                     PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind)
    815815{
    816816    int rc;
    817     uint32_t iSymbol;
     817    KU32 iSymbol;
    818818    const char *pchSymbol;
    819     uint8_t cchSymbol;
     819    KU8 cchSymbol;
    820820
    821821    if (!pfnGetForwarder)
     
    840840    else
    841841    {
    842         const uint8_t *pbName;
     842        const KU8 *pbName;
    843843
    844844        /* load the fixup section if necessary. */
     
    861861        if (pbName[1] == '#')
    862862        {
    863             uint8_t         cbLeft = *pbName;
    864             const uint8_t  *pb = pbName + 1;
    865             unsigned        uBase;
     863            KU8         cbLeft = *pbName;
     864            const KU8  *pb = pbName + 1;
     865            unsigned    uBase;
    866866
    867867            /* base detection */
     
    934934{
    935935    int rc;
    936     uint32_t off;
     936    KU32 off;
    937937    void *pv;
    938938
     
    950950        KLDRMODLX_ASSERT(!pModLX->paoffPageFixups);
    951951        if (pModLX->Hdr.e32_fpagetab)
    952             pModLX->paoffPageFixups = (const uint32_t *)(pModLX->pbFixupSection + pModLX->Hdr.e32_fpagetab - off);
     952            pModLX->paoffPageFixups = (const KU32 *)(pModLX->pbFixupSection + pModLX->Hdr.e32_fpagetab - off);
    953953        KLDRMODLX_ASSERT(!pModLX->pbFixupRecs);
    954954        if (pModLX->Hdr.e32_frectab)
     
    969969/** @copydoc kLdrModEnumSymbols */
    970970static int kldrModLXEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress,
    971                                 uint32_t fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)
     971                                KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)
    972972{
    973973    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
    974974    const struct b32_bundle *pBundle;
    975     uint32_t iOrdinal;
     975    KU32 iOrdinal;
    976976    int rc = 0;
    977977
     
    986986    while (pBundle->b32_cnt && iOrdinal)
    987987    {
    988         static const size_t s_cbEntry[] = { 0, 3, 5, 5, 7 };
     988        static const KSIZE s_cbEntry[] = { 0, 3, 5, 5, 7 };
    989989
    990990        /*
     
    994994        {
    995995            const struct e32_entry *pEntry;
    996             size_t cbEntry;
     996            KSIZE cbEntry;
    997997            KLDRADDR BundleRVA;
    998998            unsigned cLeft;
     
    10281028            {
    10291029                KLDRADDR uValue;
    1030                 uint32_t fKind;
     1030                KU32 fKind;
    10311031                int fFoundName;
    1032                 const uint8_t *pbName;
     1032                const KU8 *pbName;
    10331033
    10341034                /*
     
    11181118                /* next */
    11191119                iOrdinal++;
    1120                 pEntry = (const struct e32_entry *)((uintptr_t)pEntry + cbEntry);
     1120                pEntry = (const struct e32_entry *)((KUPTR)pEntry + cbEntry);
    11211121            }
    11221122        }
     
    11311131        }
    11321132        if (pBundle->b32_type == 0)
    1133             pBundle = (const struct b32_bundle *)((const uint8_t *)pBundle + 2);
     1133            pBundle = (const struct b32_bundle *)((const KU8 *)pBundle + 2);
    11341134        else
    1135             pBundle = (const struct b32_bundle *)((const uint8_t *)(pBundle + 1) + s_cbEntry[pBundle->b32_type] * pBundle->b32_cnt);
     1135            pBundle = (const struct b32_bundle *)((const KU8 *)(pBundle + 1) + s_cbEntry[pBundle->b32_type] * pBundle->b32_cnt);
    11361136    }
    11371137
     
    11491149 * @param   iOrdinal    The ordinal to search for.
    11501150 */
    1151 static const uint8_t *kldrModLXDoNameTableLookupByOrdinal(const uint8_t *pbNameTable, int32_t cbNameTable, uint32_t iOrdinal)
     1151static const KU8 *kldrModLXDoNameTableLookupByOrdinal(const KU8 *pbNameTable, KI32 cbNameTable, KU32 iOrdinal)
    11521152{
    11531153    while (*pbNameTable != 0 && cbNameTable > 0)
    11541154    {
    1155         const uint8_t   cbName = *pbNameTable;
    1156         uint32_t        iName;
     1155        const KU8   cbName = *pbNameTable;
     1156        KU32        iName;
    11571157
    11581158        cbNameTable -= cbName + 1 + 2;
     
    11741174
    11751175/** @copydoc kLdrModGetImport */
    1176 static int kldrModLXGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName)
    1177 {
    1178     PKLDRMODLX      pModLX = (PKLDRMODLX)pMod->pvData;
    1179     const uint8_t * pb;
    1180     int             rc;
     1176static int kldrModLXGetImport(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName)
     1177{
     1178    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
     1179    const KU8  *pb;
     1180    int         rc;
    11811181
    11821182    /*
     
    12251225
    12261226/** @copydoc kLdrModNumberOfImports */
    1227 static int32_t kldrModLXNumberOfImports(PKLDRMOD pMod, const void *pvBits)
     1227static KI32 kldrModLXNumberOfImports(PKLDRMOD pMod, const void *pvBits)
    12281228{
    12291229    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
     
    12361236{
    12371237    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
    1238     const uint32_t i = pModLX->Hdr.e32_stackobj;
     1238    const KU32 i = pModLX->Hdr.e32_stackobj;
    12391239
    12401240    if (    i
     
    13411341    else
    13421342    {
    1343         pvBase = (void *)(uintptr_t)pMod->aSegments[0].LinkAddress;
    1344         if ((uintptr_t)pvBase != pMod->aSegments[0].LinkAddress)
     1343        pvBase = (void *)(KUPTR)pMod->aSegments[0].LinkAddress;
     1344        if ((KUPTR)pvBase != pMod->aSegments[0].LinkAddress)
    13451345            return KLDR_ERR_ADDRESS_OVERFLOW;
    13461346    }
     
    13571357    if (!rc)
    13581358    {
    1359         uint32_t i;
     1359        KU32 i;
    13601360        for (i = 0; i < pMod->cSegments; i++)
    13611361        {
    13621362            if (pMod->aSegments[i].RVA != NIL_KLDRADDR)
    1363                 pMod->aSegments[i].MapAddress = (uintptr_t)pvBase + (uintptr_t)pMod->aSegments[i].RVA;
     1363                pMod->aSegments[i].MapAddress = (KUPTR)pvBase + (KUPTR)pMod->aSegments[i].RVA;
    13641364        }
    13651365        pModLX->pvMapping = pvBase;
     
    13831383{
    13841384    const PKLDRRDR pRdr = pModLX->pMod->pRdr;
    1385     uint8_t *pbTmpPage = NULL;
     1385    KU8 *pbTmpPage = NULL;
    13861386    int rc = 0;
    1387     uint32_t i;
     1387    KU32 i;
    13881388
    13891389    /*
     
    13931393    {
    13941394        const struct o32_obj * const pObj = &pModLX->paObjs[i];
    1395         const uint32_t  cPages = pModLX->pMod->aSegments[i].cbMapped / OBJPAGELEN;
    1396         uint32_t        iPage;
    1397         uint8_t        *pbPage = (uint8_t *)pvBits + (uintptr_t)pModLX->pMod->aSegments[i].RVA;
     1395        const KU32      cPages = pModLX->pMod->aSegments[i].cbMapped / OBJPAGELEN;
     1396        KU32            iPage;
     1397        KU8            *pbPage = (KU8 *)pvBits + (KUPTR)pModLX->pMod->aSegments[i].RVA;
    13981398
    13991399        /*
     
    14861486 *                      contains 4 additional zero bytes.
    14871487 */
    1488 static int kldrModLXDoIterDataUnpacking(uint8_t *pbDst, const uint8_t *pbSrc, int cbSrc)
     1488static int kldrModLXDoIterDataUnpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc)
    14891489{
    14901490    const struct LX_Iter   *pIter = (const struct LX_Iter *)pbSrc;
     
    15571557 *                      contains 4 additional zero bytes.
    15581558 */
    1559 static int kldrModLXDoIterData2Unpacking(uint8_t *pbDst, const uint8_t *pbSrc, int cbSrc)
     1559static int kldrModLXDoIterData2Unpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc)
    15601560{
    15611561    int cbDst = OBJPAGELEN;
     
    17741774 * @remark  This assumes that unaligned word and dword access is fine.
    17751775 */
    1776 static void kLdrModLXMemCopyW(uint8_t *pbDst, const uint8_t *pbSrc, int cb)
     1776static void kLdrModLXMemCopyW(KU8 *pbDst, const KU8 *pbSrc, int cb)
    17771777{
    17781778    switch (pbDst - pbSrc)
     
    17861786                *pbDst++ = *pbSrc++;
    17871787            for (cb >>= 1; cb > 0; cb--, pbDst += 2, pbSrc += 2)
    1788                 *(uint16_t *)pbDst = *(const uint16_t *)pbSrc;
     1788                *(KU16 *)pbDst = *(const KU16 *)pbSrc;
    17891789            break;
    17901790
     
    17951795            if (cb & 2)
    17961796            {
    1797                 *(uint16_t *)pbDst = *(const uint16_t *)pbSrc;
     1797                *(KU16 *)pbDst = *(const KU16 *)pbSrc;
    17981798                pbDst += 2;
    17991799                pbSrc += 2;
    18001800            }
    18011801            for (cb >>= 2; cb > 0; cb--, pbDst += 4, pbSrc += 4)
    1802                 *(uint32_t *)pbDst = *(const uint32_t *)pbSrc;
     1802                *(KU32 *)pbDst = *(const KU32 *)pbSrc;
    18031803            break;
    18041804    }
     
    18191819static int kldrModLXDoProtect(PKLDRMODLX pModLX, void *pvBits, unsigned fUnprotectOrProtect)
    18201820{
    1821     uint32_t i;
     1821    KU32 i;
    18221822    PKLDRMOD pMod = pModLX->pMod;
    18231823
     
    18651865
    18661866        /* calc the address and set page protection. */
    1867         pv = (uint8_t *)pvBits + pMod->aSegments[i].RVA;
     1867        pv = (KU8 *)pvBits + pMod->aSegments[i].RVA;
    18681868
    18691869        rc = kldrHlpPageProtect(pv, pMod->aSegments[i].cbMapped, enmProt);
     
    18821882{
    18831883    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
    1884     uint32_t    i;
     1884    KU32        i;
    18851885    int         rc;
    18861886
     
    19801980     * Apply fixups and resolve imports.
    19811981     */
    1982     rc = kldrModLXRelocateBits(pMod, (void *)pModLX->pvMapping, (uintptr_t)pModLX->pvMapping,
     1982    rc = kldrModLXRelocateBits(pMod, (void *)pModLX->pvMapping, (KUPTR)pModLX->pvMapping,
    19831983                               pMod->aSegments[0].LinkAddress, pfnGetImport, pvUser);
    19841984
     
    19941994
    19951995/** @copydoc kLdrModCallInit */
    1996 static int kldrModLXCallInit(PKLDRMOD pMod, uintptr_t uHandle)
     1996static int kldrModLXCallInit(PKLDRMOD pMod, KUPTR uHandle)
    19971997{
    19981998    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
     
    20252025 * @param   uHandle         The module handle to present.
    20262026 */
    2027 static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, unsigned uOp, uintptr_t uHandle)
     2027static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, unsigned uOp, KUPTR uHandle)
    20282028{
    20292029    int rc;
     
    20392039     * Invoke the entrypoint and convert the boolean result to a kLdr status code.
    20402040     */
    2041     rc = kldrModLXDoCall((uintptr_t)pModLX->pvMapping
    2042                          + (uintptr_t)pModLX->pMod->aSegments[pModLX->Hdr.e32_startobj - 1].RVA
     2041    rc = kldrModLXDoCall((KUPTR)pModLX->pvMapping
     2042                         + (KUPTR)pModLX->pMod->aSegments[pModLX->Hdr.e32_startobj - 1].RVA
    20432043                         + pModLX->Hdr.e32_eip,
    20442044                         uHandle, uOp, NULL);
     
    20622062 * @param   pvReserved      The third argument, reserved argument. (figure this one out)
    20632063 */
    2064 static int32_t kldrModLXDoCall(uintptr_t uEntrypoint, uintptr_t uHandle, uint32_t uOp, void *pvReserved)
     2064static KI32 kldrModLXDoCall(KUPTR uEntrypoint, KUPTR uHandle, KU32 uOp, void *pvReserved)
    20652065{
    20662066#if defined(__X86__) || defined(__i386__) || defined(_M_IX86)
    2067     int32_t rc;
     2067    KI32 rc;
    20682068/** @todo try/except */
    20692069
     
    21122112
    21132113/** @copydoc kLdrModCallTerm */
    2114 static int kldrModLXCallTerm(PKLDRMOD pMod, uintptr_t uHandle)
     2114static int kldrModLXCallTerm(PKLDRMOD pMod, KUPTR uHandle)
    21152115{
    21162116    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
     
    21332133
    21342134/** @copydoc kLdrModCallThread */
    2135 static int kldrModLXCallThread(PKLDRMOD pMod, uintptr_t uHandle, unsigned fAttachingOrDetaching)
     2135static int kldrModLXCallThread(PKLDRMOD pMod, KUPTR uHandle, unsigned fAttachingOrDetaching)
    21362136{
    21372137    /* no thread attach/detach callout. */
     
    21742174{
    21752175    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
    2176     uint32_t iSeg;
     2176    KU32 iSeg;
    21772177    int rc;
    21782178
     
    22022202        const struct o32_obj * const pObj = &pModLX->paObjs[iSeg];
    22032203        KLDRADDR        PageAddress = NewBaseAddress + pModLX->pMod->aSegments[iSeg].RVA;
    2204         uint32_t        iPage;
    2205         uint8_t        *pbPage = (uint8_t *)pvBits + (uintptr_t)pModLX->pMod->aSegments[iSeg].RVA;
     2204        KU32            iPage;
     2205        KU8            *pbPage = (KU8 *)pvBits + (KUPTR)pModLX->pMod->aSegments[iSeg].RVA;
    22062206
    22072207        /*
     
    22102210        for (iPage = 0, rc = 0; !rc && iPage < pObj->o32_mapsize; iPage++, pbPage += OBJPAGELEN, PageAddress += OBJPAGELEN)
    22112211        {
    2212             const uint8_t * const   pbFixupRecEnd = pModLX->pbFixupRecs + pModLX->paoffPageFixups[iPage + pObj->o32_pagemap];
    2213             const uint8_t          *pb            = pModLX->pbFixupRecs + pModLX->paoffPageFixups[iPage + pObj->o32_pagemap - 1];
    2214             KLDRADDR                uValue;
    2215             int                     iSelector;
    2216             uint32_t                fKind;
     2212            const KU8 * const   pbFixupRecEnd = pModLX->pbFixupRecs + pModLX->paoffPageFixups[iPage + pObj->o32_pagemap];
     2213            const KU8          *pb            = pModLX->pbFixupRecs + pModLX->paoffPageFixups[iPage + pObj->o32_pagemap - 1];
     2214            KLDRADDR            uValue;
     2215            int                 iSelector;
     2216            KU32                fKind;
    22172217
    22182218            /* sanity */
     
    22312231                union _rel
    22322232                {
    2233                     const uint8_t *          pb;
    2234                     const struct r32_rlc    *prlc;
     2233                    const KU8 *             pb;
     2234                    const struct r32_rlc   *prlc;
    22352235                } u;
    22362236
     
    22482248                    case NRRINT:
    22492249                    {
    2250                         uint16_t iTrgObject;
    2251                         uint32_t offTrgObject;
     2250                        KU16 iTrgObject;
     2251                        KU32 offTrgObject;
    22522252
    22532253                        /* the object */
    22542254                        if (u.prlc->nr_flags & NR16OBJMOD)
    22552255                        {
    2256                             iTrgObject = *(const uint16_t *)pb;
     2256                            iTrgObject = *(const KU16 *)pb;
    22572257                            pb += 2;
    22582258                        }
     
    22682268                            if (u.prlc->nr_flags & NR32BITOFF)
    22692269                            {
    2270                                 offTrgObject = *(const uint32_t *)pb;
     2270                                offTrgObject = *(const KU32 *)pb;
    22712271                                pb += 4;
    22722272                            }
    22732273                            else
    22742274                            {
    2275                                 offTrgObject = *(const uint16_t *)pb;
     2275                                offTrgObject = *(const KU16 *)pb;
    22762276                                pb += 2;
    22772277                            }
     
    22962296                    case NRRORD:
    22972297                    {
    2298                         uint16_t iModule;
    2299                         uint32_t iSymbol;
     2298                        KU16 iModule;
     2299                        KU32 iSymbol;
    23002300
    23012301                        /* the module ordinal */
    23022302                        if (u.prlc->nr_flags & NR16OBJMOD)
    23032303                        {
    2304                             iModule = *(const uint16_t *)pb;
     2304                            iModule = *(const KU16 *)pb;
    23052305                            pb += 2;
    23062306                        }
     
    23182318                        if (u.prlc->nr_flags & NR32BITOFF)
    23192319                        {
    2320                             iSymbol = *(const uint32_t *)pb;
     2320                            iSymbol = *(const KU32 *)pb;
    23212321                            pb += 4;
    23222322                        }
    23232323                        else if (!(u.prlc->nr_flags & NR8BITORD))
    23242324                        {
    2325                             iSymbol = *(const uint16_t *)pb;
     2325                            iSymbol = *(const KU16 *)pb;
    23262326                            pb += 2;
    23272327                        }
     
    23422342                    case NRRNAM:
    23432343                    {
    2344                         uint32_t iModule;
    2345                         uint16_t offSymbol;
    2346                         const uint8_t *pbSymbol;
     2344                        KU32 iModule;
     2345                        KU16 offSymbol;
     2346                        const KU8 *pbSymbol;
    23472347
    23482348                        /* the module ordinal */
    23492349                        if (u.prlc->nr_flags & NR16OBJMOD)
    23502350                        {
    2351                             iModule = *(const uint16_t *)pb;
     2351                            iModule = *(const KU16 *)pb;
    23522352                            pb += 2;
    23532353                        }
     
    23652365                        if (u.prlc->nr_flags & NR32BITOFF)
    23662366                        {
    2367                             offSymbol = *(const uint32_t *)pb;
     2367                            offSymbol = *(const KU32 *)pb;
    23682368                            pb += 4;
    23692369                        }
    23702370                        else if (!(u.prlc->nr_flags & NR8BITORD))
    23712371                        {
    2372                             offSymbol = *(const uint16_t *)pb;
     2372                            offSymbol = *(const KU16 *)pb;
    23732373                            pb += 2;
    23742374                        }
     
    24002400                    if (u.prlc->nr_flags & NR32BITADD)
    24012401                    {
    2402                         uValue += *(const uint32_t *)pb;
     2402                        uValue += *(const KU32 *)pb;
    24032403                        pb += 4;
    24042404                    }
    24052405                    else
    24062406                    {
    2407                         uValue += *(const uint16_t *)pb;
     2407                        uValue += *(const KU16 *)pb;
    24082408                        pb += 2;
    24092409                    }
     
    24222422                        &&  off >= 0
    24232423                        &&  off <= OBJPAGELEN - 4)
    2424                         *(uint32_t *)&pbPage[off] = uValue;
     2424                        *(KU32 *)&pbPage[off] = uValue;
    24252425                    else if (    (u.prlc->nr_stype & NRSRCMASK) == NRSOFF32
    24262426                            &&  off >= 0
    24272427                            &&  off <= OBJPAGELEN - 4)
    2428                         *(uint32_t *)&pbPage[off] = uValue - (PageAddress + off + 4);
     2428                        *(KU32 *)&pbPage[off] = uValue - (PageAddress + off + 4);
    24292429                    else
    24302430                    {
     
    24372437                else if (!(u.prlc->nr_flags & NRICHAIN))
    24382438                {
    2439                     const int16_t *poffSrc = (const int16_t *)pb;
    2440                     uint8_t c = u.pb[2];
     2439                    const KI16 *poffSrc = (const KI16 *)pb;
     2440                    KU8 c = u.pb[2];
    24412441
    24422442                    /* common / simple */
     
    24472447                            int off = *poffSrc++;
    24482448                            if (off >= 0 && off <= OBJPAGELEN - 4)
    2449                                 *(uint32_t *)&pbPage[off] = uValue;
     2449                                *(KU32 *)&pbPage[off] = uValue;
    24502450                            else
    24512451                            {
     
    24622462                            int off = *poffSrc++;
    24632463                            if (off >= 0 && off <= OBJPAGELEN - 4)
    2464                                 *(uint32_t *)&pbPage[off] = uValue - (PageAddress + off + 4);
     2464                                *(KU32 *)&pbPage[off] = uValue - (PageAddress + off + 4);
    24652465                            else
    24662466                            {
     
    24802480                        }
    24812481                    }
    2482                     pb = (const uint8_t *)poffSrc;
     2482                    pb = (const KU8 *)poffSrc;
    24832483                }
    24842484                else
     
    25082508 * @param   fKind       The target kind.
    25092509 */
    2510 static int kldrModLXDoReloc(uint8_t *pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc,
    2511                             int iSelector, KLDRADDR uValue, uint32_t fKind)
     2510static int kldrModLXDoReloc(KU8 *pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc,
     2511                            int iSelector, KLDRADDR uValue, KU32 fKind)
    25122512{
    25132513#pragma pack(1) /* just to be sure */
    25142514    union
    25152515    {
    2516         uint8_t     ab[6];
    2517         uint32_t    off32;
    2518         uint16_t    off16;
    2519         uint8_t     off8;
     2516        KU8         ab[6];
     2517        KU32        off32;
     2518        KU16        off16;
     2519        KU8         off8;
    25202520        struct
    25212521        {
    2522             uint16_t off;
    2523             uint16_t Sel;
     2522            KU16    off;
     2523            KU16    Sel;
    25242524        }           Far16;
    25252525        struct
    25262526        {
    2527             uint32_t off;
    2528             uint16_t Sel;
     2527            KU32    off;
     2528            KU16    Sel;
    25292529        }           Far32;
    25302530    }               uData;
    25312531#pragma pack()
    2532     const uint8_t  *pbSrc;
    2533     uint8_t        *pbDst;
    2534     uint8_t         cb;
     2532    const KU8      *pbSrc;
     2533    KU8            *pbDst;
     2534    KU8             cb;
    25352535
    25362536    /*
     
    25402540    {
    25412541        case NRSBYT:
    2542             uData.off8 = (uint8_t)uValue;
     2542            uData.off8 = (KU8)uValue;
    25432543            cb = 1;
    25442544            break;
     
    25562556                /* fixme */
    25572557            }
    2558             uData.Far16.off = (uint16_t)uValue;
     2558            uData.Far16.off = (KU16)uValue;
    25592559            uData.Far16.Sel = iSelector;
    25602560            cb = 4;
    25612561            break;
    25622562        case NRSOFF:
    2563             uData.off16 = (uint16_t)uValue;
     2563            uData.off16 = (KU16)uValue;
    25642564            cb = 2;
    25652565            break;
     
    25692569                /* fixme */
    25702570            }
    2571             uData.Far32.off = (uint32_t)uValue;
     2571            uData.Far32.off = (KU32)uValue;
    25722572            uData.Far32.Sel = iSelector;
    25732573            cb = 6;
    25742574            break;
    25752575        case NROFF32:
    2576             uData.off32 = (uint32_t)uValue;
     2576            uData.off32 = (KU32)uValue;
    25772577            cb = 4;
    25782578            break;
    25792579        case NRSOFF32:
    2580             uData.off32 = (uint32_t)uValue - (PageAddress + off + 4);
     2580            uData.off32 = (KU32)uValue - (PageAddress + off + 4);
    25812581            cb = 4;
    25822582            break;
Note: See TracChangeset for help on using the changeset viewer.