Changeset 3567 for trunk/kStuff/kLdr/kLdrModNative.c
- Timestamp:
- Aug 27, 2007, 9:54:05 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kLdr/kLdrModNative.c
r3537 r3567 94 94 */ 95 95 # define KLDRMODNATIVE_RVA2TYPE(pvBits, uRVA, type) \ 96 ( (type) (( uintptr_t)(pvBits) + (uRVA)) )96 ( (type) ((KUPTR)(pvBits) + (uRVA)) ) 97 97 98 98 #endif /* PE OSes */ … … 111 111 PKLDRMOD pMod; 112 112 /** Reserved flags. */ 113 uint32_tf32Reserved;113 KU32 f32Reserved; 114 114 /** The number of imported modules. 115 * If ~( uint32_t)0 this hasn't been determined yet. */116 uint32_tcImportModules;115 * If ~(KU32)0 this hasn't been determined yet. */ 116 KU32 cImportModules; 117 117 #ifdef __OS2__ 118 118 /** The module handle. */ … … 140 140 * Internal Functions * 141 141 *******************************************************************************/ 142 static int32_tkldrModNativeNumberOfImports(PKLDRMOD pMod, const void *pvBits);142 static KI32 kldrModNativeNumberOfImports(PKLDRMOD pMod, const void *pvBits); 143 143 144 144 … … 186 186 if (rc) 187 187 return rc; 188 rc = kLdrModOpenNativeByHandle(( uintptr_t)hmod, ppMod);188 rc = kLdrModOpenNativeByHandle((KUPTR)hmod, ppMod); 189 189 if (rc) 190 190 DosFreeModule(hmod); … … 196 196 if (!hmod) 197 197 return GetLastError(); 198 rc = kLdrModOpenNativeByHandle(( uintptr_t)hmod, ppMod);198 rc = kLdrModOpenNativeByHandle((KUPTR)hmod, ppMod); 199 199 if (rc) 200 200 FreeLibrary(hmod); … … 206 206 if (!pvMod) 207 207 return ENOENT; 208 rc = kLdrModOpenNativeByHandle(( uintptr_t)pvMod, ppMod);208 rc = kLdrModOpenNativeByHandle((KUPTR)pvMod, ppMod); 209 209 if (rc) 210 210 dlclose(pvMod); … … 227 227 * @remark This will not make the native loader increment the load count. 228 228 */ 229 int kLdrModOpenNativeByHandle( uintptr_tuHandle, PPKLDRMOD ppMod)230 { 231 size_tcb;232 size_tcchFilename;233 uint32_tcSegments;229 int kLdrModOpenNativeByHandle(KUPTR uHandle, PPKLDRMOD ppMod) 230 { 231 KSIZE cb; 232 KSIZE cchFilename; 233 KU32 cSegments; 234 234 PKLDRMOD pMod; 235 235 PKLDRMODNATIVE pModNative; … … 273 273 /* get the segment count. */ 274 274 if (pDosHdr->e_magic == IMAGE_DOS_SIGNATURE) 275 pNtHdrs = (const IMAGE_NT_HEADERS *)(( uintptr_t)pDosHdr + pDosHdr->e_lfanew);275 pNtHdrs = (const IMAGE_NT_HEADERS *)((KUPTR)pDosHdr + pDosHdr->e_lfanew); 276 276 else 277 277 pNtHdrs = (const IMAGE_NT_HEADERS *)pDosHdr; … … 309 309 310 310 /* KLDRMOD */ 311 pMod = (PKLDRMOD)(( uint8_t*)pModNative + KLDR_ALIGN_Z(sizeof(KLDRMODNATIVE), 16));311 pMod = (PKLDRMOD)((KU8 *)pModNative + KLDR_ALIGN_Z(sizeof(KLDRMODNATIVE), 16)); 312 312 pMod->pvData = pModNative; 313 313 pMod->pRdr = NULL; … … 337 337 pModNative->pMod = pMod; 338 338 pModNative->f32Reserved = 0; 339 pModNative->cImportModules = ~( uint32_t)0;339 pModNative->cImportModules = ~(KU32)0; 340 340 341 341 /* … … 541 541 542 542 /** @copydoc kLdrModQuerySymbol */ 543 static int kldrModNativeQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tiSymbol,544 const char *pchSymbol, size_tcchSymbol, const char *pszVersion,545 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind)543 static int kldrModNativeQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol, 544 const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion, 545 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind) 546 546 { 547 547 PKLDRMODNATIVE pModNative = (PKLDRMODNATIVE)pMod->pvData; … … 579 579 if (rc) 580 580 return rc == ERROR_PROC_NOT_FOUND ? KLDR_ERR_SYMBOL_NOT_FOUND : rc; 581 *puValue = ( uintptr_t)pfn;581 *puValue = (KUPTR)pfn; 582 582 } 583 583 if (pfKind) … … 602 602 return KLDR_ERR_SYMBOL_NOT_FOUND; 603 603 604 pfn = GetProcAddress(pModNative->hmod, pszSymbol ? pszSymbol : (const char *)( uintptr_t)iSymbol);604 pfn = GetProcAddress(pModNative->hmod, pszSymbol ? pszSymbol : (const char *)(KUPTR)iSymbol); 605 605 if (puValue) 606 *puValue = ( uintptr_t)pfn;606 *puValue = (KUPTR)pfn; 607 607 if (pfKind) 608 608 *pfKind = (pModNative->pNtHdrs->FileHeader.SizeOfOptionalHeader == sizeof(IMAGE_OPTIONAL_HEADER32) … … 618 618 return KLDR_ERR_SYMBOL_NOT_FOUND; 619 619 if (puValue) 620 *puValue = ( uintptr_t)pfn;620 *puValue = (KUPTR)pfn; 621 621 if (pfKind) 622 *pfKind = (sizeof( uintptr_t) == 4 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT)622 *pfKind = (sizeof(KUPTR) == 4 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT) 623 623 | KLDRSYMKIND_NO_TYPE; 624 624 … … 633 633 /** @copydoc kLdrModEnumSymbols */ 634 634 static int kldrModNativeEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, 635 uint32_tfFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)635 KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser) 636 636 { 637 637 PKLDRMODNATIVE pModNative = (PKLDRMODNATIVE)pMod->pvData; … … 643 643 644 644 #elif defined(__WIN__) || defined(__NT__) 645 const uint32_t*paFunctions;645 const KU32 *paFunctions; 646 646 const IMAGE_EXPORT_DIRECTORY *pExpDir; 647 const uint32_t*paRVANames;648 const uint16_t*paOrdinals;649 uint32_tiFunction;650 uint32_tcFunctions;651 uint32_tcNames;647 const KU32 *paRVANames; 648 const KU16 *paOrdinals; 649 KU32 iFunction; 650 KU32 cFunctions; 651 KU32 cNames; 652 652 int rc; 653 653 … … 666 666 * Enumerate the ordinal exports. 667 667 */ 668 paRVANames = KLDRMODNATIVE_RVA2TYPE(pModNative->hmod, pExpDir->AddressOfNames, const uint32_t*);669 paOrdinals = KLDRMODNATIVE_RVA2TYPE(pModNative->hmod, pExpDir->AddressOfNameOrdinals, const uint16_t*);670 paFunctions = KLDRMODNATIVE_RVA2TYPE(pModNative->hmod, pExpDir->AddressOfFunctions, const uint32_t*);668 paRVANames = KLDRMODNATIVE_RVA2TYPE(pModNative->hmod, pExpDir->AddressOfNames, const KU32 *); 669 paOrdinals = KLDRMODNATIVE_RVA2TYPE(pModNative->hmod, pExpDir->AddressOfNameOrdinals, const KU16 *); 670 paFunctions = KLDRMODNATIVE_RVA2TYPE(pModNative->hmod, pExpDir->AddressOfFunctions, const KU32 *); 671 671 cFunctions = pExpDir->NumberOfFunctions; 672 672 cNames = pExpDir->NumberOfNames; … … 674 674 { 675 675 unsigned fFoundName; 676 uint32_tiName;677 const uint32_tuRVA = paFunctions[iFunction];676 KU32 iName; 677 const KU32 uRVA = paFunctions[iFunction]; 678 678 const KLDRADDR uValue = BaseAddress + uRVA; 679 uint32_tfKind = (pModNative->pNtHdrs->FileHeader.SizeOfOptionalHeader == sizeof(IMAGE_OPTIONAL_HEADER32)679 KU32 fKind = (pModNative->pNtHdrs->FileHeader.SizeOfOptionalHeader == sizeof(IMAGE_OPTIONAL_HEADER32) 680 680 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT) 681 681 | KLDRSYMKIND_NO_TYPE; … … 727 727 728 728 /** @copydoc kLdrModGetImport */ 729 static int kldrModNativeGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_tcchName)729 static int kldrModNativeGetImport(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName) 730 730 { 731 731 PKLDRMODNATIVE pModNative = (PKLDRMODNATIVE)pMod->pvData; … … 739 739 const IMAGE_IMPORT_DESCRIPTOR *pImpDesc; 740 740 const char *pszImportName; 741 size_tcchImportName;741 KSIZE cchImportName; 742 742 int rc; 743 743 … … 745 745 * Simple bounds check. 746 746 */ 747 if (iImport >= ( uint32_t)kldrModNativeNumberOfImports(pMod, pvBits))747 if (iImport >= (KU32)kldrModNativeNumberOfImports(pMod, pvBits)) 748 748 return KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS; 749 749 … … 784 784 785 785 /** @copydoc kLdrModNumberOfImports */ 786 static int32_tkldrModNativeNumberOfImports(PKLDRMOD pMod, const void *pvBits)786 static KI32 kldrModNativeNumberOfImports(PKLDRMOD pMod, const void *pvBits) 787 787 { 788 788 PKLDRMODNATIVE pModNative = (PKLDRMODNATIVE)pMod->pvData; … … 794 794 795 795 #elif defined(__WIN__) || defined(__NT__) 796 if (pModNative->cImportModules == ~( uint32_t)0)796 if (pModNative->cImportModules == ~(KU32)0) 797 797 { 798 798 /* … … 898 898 #elif defined(__WIN__) || defined(__NT__) 899 899 const IMAGE_DEBUG_DIRECTORY *pDbgDir; 900 uint32_tiDbgInfo;901 uint32_tcb;900 KU32 iDbgInfo; 901 KU32 cb; 902 902 int rc; 903 903 … … 1039 1039 1040 1040 /** @copydoc kLdrModCallInit */ 1041 static int kldrModNativeCallInit(PKLDRMOD pMod, uintptr_tuHandle)1041 static int kldrModNativeCallInit(PKLDRMOD pMod, KUPTR uHandle) 1042 1042 { 1043 1043 return 0; … … 1046 1046 1047 1047 /** @copydoc kLdrModCallTerm */ 1048 static int kldrModNativeCallTerm(PKLDRMOD pMod, uintptr_tuHandle)1048 static int kldrModNativeCallTerm(PKLDRMOD pMod, KUPTR uHandle) 1049 1049 { 1050 1050 return 0; … … 1053 1053 1054 1054 /** @copydoc kLdrModCallThread */ 1055 static int kldrModNativeCallThread(PKLDRMOD pMod, uintptr_tuHandle, unsigned fAttachingOrDetaching)1055 static int kldrModNativeCallThread(PKLDRMOD pMod, KUPTR uHandle, unsigned fAttachingOrDetaching) 1056 1056 { 1057 1057 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.