Changeset 3567 for trunk/kStuff/kLdr/kLdrModLX.c
- Timestamp:
- Aug 27, 2007, 9:54:05 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kLdr/kLdrModLX.c
r3537 r3567 65 65 const void *pvMapping; 66 66 /** The size of the mapped LX image. */ 67 size_tcbMapped;67 KSIZE cbMapped; 68 68 /** Reserved flags. */ 69 uint32_tf32Reserved;69 KU32 f32Reserved; 70 70 71 71 /** The offset of the LX header. */ … … 76 76 /** Pointer to the loader section. 77 77 * Allocated together with this strcture. */ 78 const uint8_t*pbLoaderSection;78 const KU8 *pbLoaderSection; 79 79 /** Pointer to the last byte in the loader section. */ 80 const uint8_t*pbLoaderSectionLast;80 const KU8 *pbLoaderSectionLast; 81 81 /** Pointer to the object table in the loader section. */ 82 82 const struct o32_obj *paObjs; … … 86 86 const struct rsrc32 *paRsrcs; 87 87 /** Pointer to the resident name table in the loader section. */ 88 const uint8_t*pbResNameTab;88 const KU8 *pbResNameTab; 89 89 /** Pointer to the entry table in the loader section. */ 90 const uint8_t*pbEntryTab;90 const KU8 *pbEntryTab; 91 91 92 92 /** Pointer to the non-resident name table. */ 93 uint8_t*pbNonResNameTab;93 KU8 *pbNonResNameTab; 94 94 /** Pointer to the last byte in the non-resident name table. */ 95 const uint8_t*pbNonResNameTabLast;95 const KU8 *pbNonResNameTabLast; 96 96 97 97 /** Pointer to the fixup section. */ 98 uint8_t*pbFixupSection;98 KU8 *pbFixupSection; 99 99 /** Pointer to the last byte in the fixup section. */ 100 const uint8_t*pbFixupSectionLast;100 const KU8 *pbFixupSectionLast; 101 101 /** Pointer to the fixup page table within pvFixupSection. */ 102 const uint32_t*paoffPageFixups;102 const KU32 *paoffPageFixups; 103 103 /** Pointer to the fixup record table within pvFixupSection. */ 104 const uint8_t*pbFixupRecs;104 const KU8 *pbFixupRecs; 105 105 /** Pointer to the import module name table within pvFixupSection. */ 106 const uint8_t*pbImportMods;106 const KU8 *pbImportMods; 107 107 /** Pointer to the import module name table within pvFixupSection. */ 108 const uint8_t*pbImportProcs;108 const KU8 *pbImportProcs; 109 109 } KLDRMODLX, *PKLDRMODLX; 110 110 … … 117 117 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 118 118 static int kldrModLXDoCreate(PKLDRRDR pRdr, KLDRFOFF offNewHdr, PKLDRMODLX *ppModLX); 119 static const uint8_t *kldrModLXDoNameTableLookupByOrdinal(const uint8_t *pbNameTable, int32_t cbNameTable, uint32_tiOrdinal);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_tcbNameTable,122 const char *pchSymbol, size_tcchSymbol);119 static const KU8 *kldrModLXDoNameTableLookupByOrdinal(const KU8 *pbNameTable, KI32 cbNameTable, KU32 iOrdinal); 120 static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, KU32 cchSymbol, KU32 *piSymbol); 121 static const KU8 *kldrModLXDoNameTableLookupByName(const KU8 *pbNameTable, KI32 cbNameTable, 122 const char *pchSymbol, KSIZE cchSymbol); 123 123 static 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);124 static int kldrModLXDoIterDataUnpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc); 125 static int kldrModLXDoIterData2Unpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc); 126 static void kLdrModLXMemCopyW(KU8 *pbDst, const KU8 *pbSrc, int cb); 127 127 static int kldrModLXDoProtect(PKLDRMODLX pModLX, void *pvBits, unsigned fUnprotectOrProtect); 128 static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, unsigned uOp, uintptr_tuHandle);128 static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, unsigned uOp, KUPTR uHandle); 129 129 static 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); 131 131 static int kldrModLXDoLoadFixupSection(PKLDRMODLX pModLX); 132 static int32_t kldrModLXDoCall(uintptr_t uEntrypoint, uintptr_t uHandle, uint32_tuOp, void *pvReserved);133 static int kldrModLXDoReloc( uint8_t*pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc,134 int iSelector, KLDRADDR uValue, uint32_tfKind);132 static KI32 kldrModLXDoCall(KUPTR uEntrypoint, KUPTR uHandle, KU32 uOp, void *pvReserved); 133 static int kldrModLXDoReloc(KU8 *pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc, 134 int iSelector, KLDRADDR uValue, KU32 fKind); 135 135 136 136 … … 176 176 PKLDRMODLX pModLX; 177 177 PKLDRMOD pMod; 178 size_tcb;179 size_tcchFilename;180 uint32_toff, offEnd;181 uint32_ti;178 KSIZE cb; 179 KSIZE cchFilename; 180 KU32 off, offEnd; 181 KU32 i; 182 182 int rc; 183 183 int fCanOptimizeMapping; 184 uint32_tNextRVA;184 KU32 NextRVA; 185 185 *ppModLX = NULL; 186 186 … … 206 206 207 207 /* 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); 209 209 if ( Hdr.e32_itermap > offEnd 210 210 || Hdr.e32_datapage > offEnd … … 278 278 279 279 /* KLDRMOD */ 280 pMod = (PKLDRMOD)(( uint8_t*)pModLX + KLDR_ALIGN_Z(sizeof(KLDRMODLX), 8));280 pMod = (PKLDRMOD)((KU8 *)pModLX + KLDR_ALIGN_Z(sizeof(KLDRMODLX), 8)); 281 281 pMod->pvData = pModLX; 282 282 pMod->pRdr = pRdr; … … 361 361 if (rc) 362 362 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; 365 365 if (pModLX->Hdr.e32_objcnt) 366 366 pModLX->paObjs = (const struct o32_obj *)pModLX->pbLoaderSection; … … 386 386 if (!pMod->pszName) 387 387 return KLDR_ERR_LX_NO_SONAME; 388 pMod->cchName = *(const uint8_t*)pMod->pszName++;388 pMod->cchName = *(const KU8 *)pMod->pszName++; 389 389 if (pMod->cchName != kLdrHlpStrLen(pMod->pszName)) 390 390 return KLDR_ERR_LX_BAD_SONAME; … … 403 403 return KLDR_ERR_LX_BAD_OBJECT_TABLE; 404 404 if ( pModLX->paObjs[i].o32_mapsize 405 && ( ( uint8_t*)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap] > pModLX->pbLoaderSectionLast406 || ( 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] 407 407 > pModLX->pbLoaderSectionLast)) 408 408 return KLDR_ERR_LX_BAD_OBJECT_TABLE; … … 564 564 565 565 /** @copydoc kLdrModQuerySymbol */ 566 static int kldrModLXQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tiSymbol,567 const char *pchSymbol, size_tcchSymbol, const char *pszVersion,568 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind)566 static 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) 569 569 { 570 570 PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData; 571 uint32_tiOrdinal;571 KU32 iOrdinal; 572 572 int rc; 573 573 const struct b32_bundle *pBundle; … … 598 598 while (pBundle->b32_cnt && iOrdinal <= iSymbol) 599 599 { 600 static const size_ts_cbEntry[] = { 0, 3, 5, 5, 7 };600 static const KSIZE s_cbEntry[] = { 0, 3, 5, 5, 7 }; 601 601 602 602 /* … … 606 606 if (iSymbol < iOrdinal) 607 607 { 608 uint32_toffObject;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) 610 610 + (iSymbol - (iOrdinal - pBundle->b32_cnt)) 611 611 * s_cbEntry[pBundle->b32_type]); … … 674 674 } 675 675 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); 677 677 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); 679 679 } 680 680 … … 692 692 * @param piSymbol Where to store the symbol ordinal. 693 693 */ 694 static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, uint32_t cchSymbol, uint32_t*piSymbol)694 static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, KU32 cchSymbol, KU32 *piSymbol) 695 695 { 696 696 … … 703 703 * Search the name tables. 704 704 */ 705 const uint8_t*pbName = kldrModLXDoNameTableLookupByName(pModLX->pbResNameTab,706 707 705 const KU8 *pbName = kldrModLXDoNameTableLookupByName(pModLX->pbResNameTab, 706 pModLX->pbLoaderSectionLast - pModLX->pbResNameTab + 1, 707 pchSymbol, cchSymbol); 708 708 if (!pbName) 709 709 { … … 721 721 return KLDR_ERR_SYMBOL_NOT_FOUND; 722 722 723 *piSymbol = *(const uint16_t*)(pbName + 1 + *pbName);723 *piSymbol = *(const KU16 *)(pbName + 1 + *pbName); 724 724 return 0; 725 725 } … … 743 743 * elsewhere. 744 744 */ 745 static uint32_t kldrModLXDoHash(const char *pchSymbol, uint8_tcchSymbol)746 { 747 uint32_thash = 0;745 static KU32 kldrModLXDoHash(const char *pchSymbol, KU8 cchSymbol) 746 { 747 KU32 hash = 0; 748 748 int ch; 749 749 … … 767 767 * @param cchSymbol The length of the symbol name. 768 768 */ 769 static const uint8_t *kldrModLXDoNameTableLookupByName(const uint8_t *pbNameTable, int32_tcbNameTable,770 const char *pchSymbol, size_tcchSymbol)769 static const KU8 *kldrModLXDoNameTableLookupByName(const KU8 *pbNameTable, KI32 cbNameTable, 770 const char *pchSymbol, KSIZE cchSymbol) 771 771 { 772 772 /* 773 773 * Determin the namelength up front so we can skip anything which doesn't matches the length. 774 774 */ 775 uint8_t cbSymbol8Bit = (uint8_t)cchSymbol;775 KU8 cbSymbol8Bit = (KU8)cchSymbol; 776 776 if (cbSymbol8Bit != cchSymbol) 777 777 return NULL; /* too long. */ … … 782 782 while (*pbNameTable != 0 && cbNameTable > 0) 783 783 { 784 const uint8_tcbName = *pbNameTable;784 const KU8 cbName = *pbNameTable; 785 785 786 786 cbNameTable -= cbName + 1 + 2; … … 812 812 */ 813 813 static 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) 815 815 { 816 816 int rc; 817 uint32_tiSymbol;817 KU32 iSymbol; 818 818 const char *pchSymbol; 819 uint8_tcchSymbol;819 KU8 cchSymbol; 820 820 821 821 if (!pfnGetForwarder) … … 840 840 else 841 841 { 842 const uint8_t*pbName;842 const KU8 *pbName; 843 843 844 844 /* load the fixup section if necessary. */ … … 861 861 if (pbName[1] == '#') 862 862 { 863 uint8_tcbLeft = *pbName;864 const uint8_t*pb = pbName + 1;865 unsigned 863 KU8 cbLeft = *pbName; 864 const KU8 *pb = pbName + 1; 865 unsigned uBase; 866 866 867 867 /* base detection */ … … 934 934 { 935 935 int rc; 936 uint32_toff;936 KU32 off; 937 937 void *pv; 938 938 … … 950 950 KLDRMODLX_ASSERT(!pModLX->paoffPageFixups); 951 951 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); 953 953 KLDRMODLX_ASSERT(!pModLX->pbFixupRecs); 954 954 if (pModLX->Hdr.e32_frectab) … … 969 969 /** @copydoc kLdrModEnumSymbols */ 970 970 static int kldrModLXEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, 971 uint32_tfFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)971 KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser) 972 972 { 973 973 PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData; 974 974 const struct b32_bundle *pBundle; 975 uint32_tiOrdinal;975 KU32 iOrdinal; 976 976 int rc = 0; 977 977 … … 986 986 while (pBundle->b32_cnt && iOrdinal) 987 987 { 988 static const size_ts_cbEntry[] = { 0, 3, 5, 5, 7 };988 static const KSIZE s_cbEntry[] = { 0, 3, 5, 5, 7 }; 989 989 990 990 /* … … 994 994 { 995 995 const struct e32_entry *pEntry; 996 size_tcbEntry;996 KSIZE cbEntry; 997 997 KLDRADDR BundleRVA; 998 998 unsigned cLeft; … … 1028 1028 { 1029 1029 KLDRADDR uValue; 1030 uint32_tfKind;1030 KU32 fKind; 1031 1031 int fFoundName; 1032 const uint8_t*pbName;1032 const KU8 *pbName; 1033 1033 1034 1034 /* … … 1118 1118 /* next */ 1119 1119 iOrdinal++; 1120 pEntry = (const struct e32_entry *)(( uintptr_t)pEntry + cbEntry);1120 pEntry = (const struct e32_entry *)((KUPTR)pEntry + cbEntry); 1121 1121 } 1122 1122 } … … 1131 1131 } 1132 1132 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); 1134 1134 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); 1136 1136 } 1137 1137 … … 1149 1149 * @param iOrdinal The ordinal to search for. 1150 1150 */ 1151 static const uint8_t *kldrModLXDoNameTableLookupByOrdinal(const uint8_t *pbNameTable, int32_t cbNameTable, uint32_tiOrdinal)1151 static const KU8 *kldrModLXDoNameTableLookupByOrdinal(const KU8 *pbNameTable, KI32 cbNameTable, KU32 iOrdinal) 1152 1152 { 1153 1153 while (*pbNameTable != 0 && cbNameTable > 0) 1154 1154 { 1155 const uint8_tcbName = *pbNameTable;1156 uint32_tiName;1155 const KU8 cbName = *pbNameTable; 1156 KU32 iName; 1157 1157 1158 1158 cbNameTable -= cbName + 1 + 2; … … 1174 1174 1175 1175 /** @copydoc kLdrModGetImport */ 1176 static int kldrModLXGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_tcchName)1177 { 1178 PKLDRMODLX 1179 const uint8_t *pb;1180 int 1176 static 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; 1181 1181 1182 1182 /* … … 1225 1225 1226 1226 /** @copydoc kLdrModNumberOfImports */ 1227 static int32_tkldrModLXNumberOfImports(PKLDRMOD pMod, const void *pvBits)1227 static KI32 kldrModLXNumberOfImports(PKLDRMOD pMod, const void *pvBits) 1228 1228 { 1229 1229 PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData; … … 1236 1236 { 1237 1237 PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData; 1238 const uint32_ti = pModLX->Hdr.e32_stackobj;1238 const KU32 i = pModLX->Hdr.e32_stackobj; 1239 1239 1240 1240 if ( i … … 1341 1341 else 1342 1342 { 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) 1345 1345 return KLDR_ERR_ADDRESS_OVERFLOW; 1346 1346 } … … 1357 1357 if (!rc) 1358 1358 { 1359 uint32_ti;1359 KU32 i; 1360 1360 for (i = 0; i < pMod->cSegments; i++) 1361 1361 { 1362 1362 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; 1364 1364 } 1365 1365 pModLX->pvMapping = pvBase; … … 1383 1383 { 1384 1384 const PKLDRRDR pRdr = pModLX->pMod->pRdr; 1385 uint8_t*pbTmpPage = NULL;1385 KU8 *pbTmpPage = NULL; 1386 1386 int rc = 0; 1387 uint32_ti;1387 KU32 i; 1388 1388 1389 1389 /* … … 1393 1393 { 1394 1394 const struct o32_obj * const pObj = &pModLX->paObjs[i]; 1395 const uint32_tcPages = pModLX->pMod->aSegments[i].cbMapped / OBJPAGELEN;1396 uint32_tiPage;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; 1398 1398 1399 1399 /* … … 1486 1486 * contains 4 additional zero bytes. 1487 1487 */ 1488 static int kldrModLXDoIterDataUnpacking( uint8_t *pbDst, const uint8_t*pbSrc, int cbSrc)1488 static int kldrModLXDoIterDataUnpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc) 1489 1489 { 1490 1490 const struct LX_Iter *pIter = (const struct LX_Iter *)pbSrc; … … 1557 1557 * contains 4 additional zero bytes. 1558 1558 */ 1559 static int kldrModLXDoIterData2Unpacking( uint8_t *pbDst, const uint8_t*pbSrc, int cbSrc)1559 static int kldrModLXDoIterData2Unpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc) 1560 1560 { 1561 1561 int cbDst = OBJPAGELEN; … … 1774 1774 * @remark This assumes that unaligned word and dword access is fine. 1775 1775 */ 1776 static void kLdrModLXMemCopyW( uint8_t *pbDst, const uint8_t*pbSrc, int cb)1776 static void kLdrModLXMemCopyW(KU8 *pbDst, const KU8 *pbSrc, int cb) 1777 1777 { 1778 1778 switch (pbDst - pbSrc) … … 1786 1786 *pbDst++ = *pbSrc++; 1787 1787 for (cb >>= 1; cb > 0; cb--, pbDst += 2, pbSrc += 2) 1788 *( uint16_t *)pbDst = *(const uint16_t*)pbSrc;1788 *(KU16 *)pbDst = *(const KU16 *)pbSrc; 1789 1789 break; 1790 1790 … … 1795 1795 if (cb & 2) 1796 1796 { 1797 *( uint16_t *)pbDst = *(const uint16_t*)pbSrc;1797 *(KU16 *)pbDst = *(const KU16 *)pbSrc; 1798 1798 pbDst += 2; 1799 1799 pbSrc += 2; 1800 1800 } 1801 1801 for (cb >>= 2; cb > 0; cb--, pbDst += 4, pbSrc += 4) 1802 *( uint32_t *)pbDst = *(const uint32_t*)pbSrc;1802 *(KU32 *)pbDst = *(const KU32 *)pbSrc; 1803 1803 break; 1804 1804 } … … 1819 1819 static int kldrModLXDoProtect(PKLDRMODLX pModLX, void *pvBits, unsigned fUnprotectOrProtect) 1820 1820 { 1821 uint32_ti;1821 KU32 i; 1822 1822 PKLDRMOD pMod = pModLX->pMod; 1823 1823 … … 1865 1865 1866 1866 /* calc the address and set page protection. */ 1867 pv = ( uint8_t*)pvBits + pMod->aSegments[i].RVA;1867 pv = (KU8 *)pvBits + pMod->aSegments[i].RVA; 1868 1868 1869 1869 rc = kldrHlpPageProtect(pv, pMod->aSegments[i].cbMapped, enmProt); … … 1882 1882 { 1883 1883 PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData; 1884 uint32_ti;1884 KU32 i; 1885 1885 int rc; 1886 1886 … … 1980 1980 * Apply fixups and resolve imports. 1981 1981 */ 1982 rc = kldrModLXRelocateBits(pMod, (void *)pModLX->pvMapping, ( uintptr_t)pModLX->pvMapping,1982 rc = kldrModLXRelocateBits(pMod, (void *)pModLX->pvMapping, (KUPTR)pModLX->pvMapping, 1983 1983 pMod->aSegments[0].LinkAddress, pfnGetImport, pvUser); 1984 1984 … … 1994 1994 1995 1995 /** @copydoc kLdrModCallInit */ 1996 static int kldrModLXCallInit(PKLDRMOD pMod, uintptr_tuHandle)1996 static int kldrModLXCallInit(PKLDRMOD pMod, KUPTR uHandle) 1997 1997 { 1998 1998 PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData; … … 2025 2025 * @param uHandle The module handle to present. 2026 2026 */ 2027 static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, unsigned uOp, uintptr_tuHandle)2027 static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, unsigned uOp, KUPTR uHandle) 2028 2028 { 2029 2029 int rc; … … 2039 2039 * Invoke the entrypoint and convert the boolean result to a kLdr status code. 2040 2040 */ 2041 rc = kldrModLXDoCall(( uintptr_t)pModLX->pvMapping2042 + ( uintptr_t)pModLX->pMod->aSegments[pModLX->Hdr.e32_startobj - 1].RVA2041 rc = kldrModLXDoCall((KUPTR)pModLX->pvMapping 2042 + (KUPTR)pModLX->pMod->aSegments[pModLX->Hdr.e32_startobj - 1].RVA 2043 2043 + pModLX->Hdr.e32_eip, 2044 2044 uHandle, uOp, NULL); … … 2062 2062 * @param pvReserved The third argument, reserved argument. (figure this one out) 2063 2063 */ 2064 static int32_t kldrModLXDoCall(uintptr_t uEntrypoint, uintptr_t uHandle, uint32_tuOp, void *pvReserved)2064 static KI32 kldrModLXDoCall(KUPTR uEntrypoint, KUPTR uHandle, KU32 uOp, void *pvReserved) 2065 2065 { 2066 2066 #if defined(__X86__) || defined(__i386__) || defined(_M_IX86) 2067 int32_trc;2067 KI32 rc; 2068 2068 /** @todo try/except */ 2069 2069 … … 2112 2112 2113 2113 /** @copydoc kLdrModCallTerm */ 2114 static int kldrModLXCallTerm(PKLDRMOD pMod, uintptr_tuHandle)2114 static int kldrModLXCallTerm(PKLDRMOD pMod, KUPTR uHandle) 2115 2115 { 2116 2116 PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData; … … 2133 2133 2134 2134 /** @copydoc kLdrModCallThread */ 2135 static int kldrModLXCallThread(PKLDRMOD pMod, uintptr_tuHandle, unsigned fAttachingOrDetaching)2135 static int kldrModLXCallThread(PKLDRMOD pMod, KUPTR uHandle, unsigned fAttachingOrDetaching) 2136 2136 { 2137 2137 /* no thread attach/detach callout. */ … … 2174 2174 { 2175 2175 PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData; 2176 uint32_tiSeg;2176 KU32 iSeg; 2177 2177 int rc; 2178 2178 … … 2202 2202 const struct o32_obj * const pObj = &pModLX->paObjs[iSeg]; 2203 2203 KLDRADDR PageAddress = NewBaseAddress + pModLX->pMod->aSegments[iSeg].RVA; 2204 uint32_tiPage;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; 2206 2206 2207 2207 /* … … 2210 2210 for (iPage = 0, rc = 0; !rc && iPage < pObj->o32_mapsize; iPage++, pbPage += OBJPAGELEN, PageAddress += OBJPAGELEN) 2211 2211 { 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 2215 int 2216 uint32_tfKind;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; 2217 2217 2218 2218 /* sanity */ … … 2231 2231 union _rel 2232 2232 { 2233 const uint8_t *pb;2234 const struct r32_rlc 2233 const KU8 * pb; 2234 const struct r32_rlc *prlc; 2235 2235 } u; 2236 2236 … … 2248 2248 case NRRINT: 2249 2249 { 2250 uint16_tiTrgObject;2251 uint32_toffTrgObject;2250 KU16 iTrgObject; 2251 KU32 offTrgObject; 2252 2252 2253 2253 /* the object */ 2254 2254 if (u.prlc->nr_flags & NR16OBJMOD) 2255 2255 { 2256 iTrgObject = *(const uint16_t*)pb;2256 iTrgObject = *(const KU16 *)pb; 2257 2257 pb += 2; 2258 2258 } … … 2268 2268 if (u.prlc->nr_flags & NR32BITOFF) 2269 2269 { 2270 offTrgObject = *(const uint32_t*)pb;2270 offTrgObject = *(const KU32 *)pb; 2271 2271 pb += 4; 2272 2272 } 2273 2273 else 2274 2274 { 2275 offTrgObject = *(const uint16_t*)pb;2275 offTrgObject = *(const KU16 *)pb; 2276 2276 pb += 2; 2277 2277 } … … 2296 2296 case NRRORD: 2297 2297 { 2298 uint16_tiModule;2299 uint32_tiSymbol;2298 KU16 iModule; 2299 KU32 iSymbol; 2300 2300 2301 2301 /* the module ordinal */ 2302 2302 if (u.prlc->nr_flags & NR16OBJMOD) 2303 2303 { 2304 iModule = *(const uint16_t*)pb;2304 iModule = *(const KU16 *)pb; 2305 2305 pb += 2; 2306 2306 } … … 2318 2318 if (u.prlc->nr_flags & NR32BITOFF) 2319 2319 { 2320 iSymbol = *(const uint32_t*)pb;2320 iSymbol = *(const KU32 *)pb; 2321 2321 pb += 4; 2322 2322 } 2323 2323 else if (!(u.prlc->nr_flags & NR8BITORD)) 2324 2324 { 2325 iSymbol = *(const uint16_t*)pb;2325 iSymbol = *(const KU16 *)pb; 2326 2326 pb += 2; 2327 2327 } … … 2342 2342 case NRRNAM: 2343 2343 { 2344 uint32_tiModule;2345 uint16_toffSymbol;2346 const uint8_t*pbSymbol;2344 KU32 iModule; 2345 KU16 offSymbol; 2346 const KU8 *pbSymbol; 2347 2347 2348 2348 /* the module ordinal */ 2349 2349 if (u.prlc->nr_flags & NR16OBJMOD) 2350 2350 { 2351 iModule = *(const uint16_t*)pb;2351 iModule = *(const KU16 *)pb; 2352 2352 pb += 2; 2353 2353 } … … 2365 2365 if (u.prlc->nr_flags & NR32BITOFF) 2366 2366 { 2367 offSymbol = *(const uint32_t*)pb;2367 offSymbol = *(const KU32 *)pb; 2368 2368 pb += 4; 2369 2369 } 2370 2370 else if (!(u.prlc->nr_flags & NR8BITORD)) 2371 2371 { 2372 offSymbol = *(const uint16_t*)pb;2372 offSymbol = *(const KU16 *)pb; 2373 2373 pb += 2; 2374 2374 } … … 2400 2400 if (u.prlc->nr_flags & NR32BITADD) 2401 2401 { 2402 uValue += *(const uint32_t*)pb;2402 uValue += *(const KU32 *)pb; 2403 2403 pb += 4; 2404 2404 } 2405 2405 else 2406 2406 { 2407 uValue += *(const uint16_t*)pb;2407 uValue += *(const KU16 *)pb; 2408 2408 pb += 2; 2409 2409 } … … 2422 2422 && off >= 0 2423 2423 && off <= OBJPAGELEN - 4) 2424 *( uint32_t*)&pbPage[off] = uValue;2424 *(KU32 *)&pbPage[off] = uValue; 2425 2425 else if ( (u.prlc->nr_stype & NRSRCMASK) == NRSOFF32 2426 2426 && off >= 0 2427 2427 && off <= OBJPAGELEN - 4) 2428 *( uint32_t*)&pbPage[off] = uValue - (PageAddress + off + 4);2428 *(KU32 *)&pbPage[off] = uValue - (PageAddress + off + 4); 2429 2429 else 2430 2430 { … … 2437 2437 else if (!(u.prlc->nr_flags & NRICHAIN)) 2438 2438 { 2439 const int16_t *poffSrc = (const int16_t*)pb;2440 uint8_tc = u.pb[2];2439 const KI16 *poffSrc = (const KI16 *)pb; 2440 KU8 c = u.pb[2]; 2441 2441 2442 2442 /* common / simple */ … … 2447 2447 int off = *poffSrc++; 2448 2448 if (off >= 0 && off <= OBJPAGELEN - 4) 2449 *( uint32_t*)&pbPage[off] = uValue;2449 *(KU32 *)&pbPage[off] = uValue; 2450 2450 else 2451 2451 { … … 2462 2462 int off = *poffSrc++; 2463 2463 if (off >= 0 && off <= OBJPAGELEN - 4) 2464 *( uint32_t*)&pbPage[off] = uValue - (PageAddress + off + 4);2464 *(KU32 *)&pbPage[off] = uValue - (PageAddress + off + 4); 2465 2465 else 2466 2466 { … … 2480 2480 } 2481 2481 } 2482 pb = (const uint8_t*)poffSrc;2482 pb = (const KU8 *)poffSrc; 2483 2483 } 2484 2484 else … … 2508 2508 * @param fKind The target kind. 2509 2509 */ 2510 static int kldrModLXDoReloc( uint8_t*pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc,2511 int iSelector, KLDRADDR uValue, uint32_tfKind)2510 static int kldrModLXDoReloc(KU8 *pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc, 2511 int iSelector, KLDRADDR uValue, KU32 fKind) 2512 2512 { 2513 2513 #pragma pack(1) /* just to be sure */ 2514 2514 union 2515 2515 { 2516 uint8_tab[6];2517 uint32_toff32;2518 uint16_toff16;2519 uint8_toff8;2516 KU8 ab[6]; 2517 KU32 off32; 2518 KU16 off16; 2519 KU8 off8; 2520 2520 struct 2521 2521 { 2522 uint16_toff;2523 uint16_tSel;2522 KU16 off; 2523 KU16 Sel; 2524 2524 } Far16; 2525 2525 struct 2526 2526 { 2527 uint32_toff;2528 uint16_tSel;2527 KU32 off; 2528 KU16 Sel; 2529 2529 } Far32; 2530 2530 } uData; 2531 2531 #pragma pack() 2532 const uint8_t*pbSrc;2533 uint8_t*pbDst;2534 uint8_tcb;2532 const KU8 *pbSrc; 2533 KU8 *pbDst; 2534 KU8 cb; 2535 2535 2536 2536 /* … … 2540 2540 { 2541 2541 case NRSBYT: 2542 uData.off8 = ( uint8_t)uValue;2542 uData.off8 = (KU8)uValue; 2543 2543 cb = 1; 2544 2544 break; … … 2556 2556 /* fixme */ 2557 2557 } 2558 uData.Far16.off = ( uint16_t)uValue;2558 uData.Far16.off = (KU16)uValue; 2559 2559 uData.Far16.Sel = iSelector; 2560 2560 cb = 4; 2561 2561 break; 2562 2562 case NRSOFF: 2563 uData.off16 = ( uint16_t)uValue;2563 uData.off16 = (KU16)uValue; 2564 2564 cb = 2; 2565 2565 break; … … 2569 2569 /* fixme */ 2570 2570 } 2571 uData.Far32.off = ( uint32_t)uValue;2571 uData.Far32.off = (KU32)uValue; 2572 2572 uData.Far32.Sel = iSelector; 2573 2573 cb = 6; 2574 2574 break; 2575 2575 case NROFF32: 2576 uData.off32 = ( uint32_t)uValue;2576 uData.off32 = (KU32)uValue; 2577 2577 cb = 4; 2578 2578 break; 2579 2579 case NRSOFF32: 2580 uData.off32 = ( uint32_t)uValue - (PageAddress + off + 4);2580 uData.off32 = (KU32)uValue - (PageAddress + off + 4); 2581 2581 cb = 4; 2582 2582 break;
Note:
See TracChangeset
for help on using the changeset viewer.