- Timestamp:
- Aug 27, 2007, 9:54:05 PM (18 years ago)
- Location:
- trunk/kStuff/kLdr
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kLdr/Makefile.kmk
r3537 r3567 66 66 TEMPLATE_TST_LDFLAGS = 67 67 endif 68 TEMPLATE_TST_INCS = . 68 TEMPLATE_TST_INCS = . ../include 69 69 70 70 … … 112 112 kLdr_LDFLAGS = -nostdlib 113 113 endif 114 kLdr_INCS = . 114 kLdr_INCS = . ../include 115 115 kLdr_SOURCES = \ 116 116 kLdr.c \ … … 152 152 kLdrStatic_TEMPLATE = kStuffLIB 153 153 kLdrStatic_SDKS.win = WINPSDK W2K3DDK 154 kLdrStatic_INCS = . 154 kLdrStatic_INCS = . ../include 155 155 kLdrStatic_DEFS.win = __WIN__ 156 156 kLdrStatic_DEFS.os2 = __OS2__ … … 179 179 kLdrExeStub-win_SDKS.x86 = WIN32SDK 180 180 kLdrExeStub-win_SDKS.amd64 = WIN64SDK 181 kLdrExeStub-win_INCS = . 181 kLdrExeStub-win_INCS = . ../include 182 182 kLdrExeStub-win_DEFS = __WIN__ 183 183 kLdrExeStub-win_CFLAGS = -W3 -Zl -
trunk/kStuff/kLdr/kLdr.h
r3537 r3567 42 42 43 43 /** The kLdr address type. */ 44 typedef uint64_tKLDRADDR;44 typedef KU64 KLDRADDR; 45 45 /** Pointer to a kLdr address. */ 46 46 typedef KLDRADDR *PKLDRADDR; … … 49 49 50 50 /** NIL address. */ 51 #define NIL_KLDRADDR (~( uint64_t)0)51 #define NIL_KLDRADDR (~(KU64)0) 52 52 53 53 /** @def PRI_KLDRADDR … … 61 61 62 62 /** The kLdr size type. */ 63 typedef uint64_tKLDRSIZE;63 typedef KU64 KLDRSIZE; 64 64 /** Pointer to a kLdr size. */ 65 65 typedef KLDRSIZE *PKLDRSIZE; … … 93 93 typedef union KLDRU 94 94 { 95 int8_t i8; /**< int8_tview. */96 uint8_t u8; /**< uint8_tview. */97 int16_t i16; /**< int16_tview. */98 uint16_t u16; /**< uint16_tview. */99 int32_t i32; /**< int32_tview. */100 uint32_t u32; /**< uint32_tview. */101 int64_t i64; /**< int64_tview. */102 uint64_t u64; /**< uint64_tview. */103 104 int8_t ai8[8]; /**< int8_tarray view . */105 uint8_t au8[8]; /**< uint8_tarray view. */106 int16_t ai16[4];/**< int16_tarray view . */107 uint16_t au16[4];/**< uint16_tarray view. */108 int32_t ai32[2];/**< int32_tarray view . */109 uint32_t au32[2];/**< uint32_tarray view. */95 KI8 i8; /**< KI8 view. */ 96 KU8 u8; /**< KU8 view. */ 97 KI16 i16; /**< KI16 view. */ 98 KU16 u16; /**< KU16 view. */ 99 KI32 i32; /**< KI32 view. */ 100 KU32 u32; /**< KU32 view. */ 101 KI64 i64; /**< KI64 view. */ 102 KU64 u64; /**< KU64 view. */ 103 104 KI8 ai8[8]; /**< KI8 array view . */ 105 KU8 au8[8]; /**< KU8 array view. */ 106 KI16 ai16[4];/**< KI16 array view . */ 107 KU16 au16[4];/**< KU16 array view. */ 108 KI32 ai32[2];/**< KI32 array view . */ 109 KU32 au32[2];/**< KU32 array view. */ 110 110 111 111 signed char ch; /**< signed char view. */ … … 133 133 typedef union KLDRPU 134 134 { 135 int8_t *pi8; /**< int8_tview. */136 uint8_t *pu8; /**< uint8_tview. */137 int16_t *pi16; /**< int16_tview. */138 uint16_t *pu16; /**< uint16_tview. */139 int32_t *pi32; /**< int32_tview. */140 uint32_t *pu32; /**< uint32_tview. */141 int64_t *pi64; /**< int64_tview. */142 uint64_t *pu64; /**< uint64_tview. */135 KI8 *pi8; /**< KI8 view. */ 136 KU8 *pu8; /**< KU8 view. */ 137 KI16 *pi16; /**< KI16 view. */ 138 KU16 *pu16; /**< KU16 view. */ 139 KI32 *pi32; /**< KI32 view. */ 140 KU32 *pu32; /**< KU32 view. */ 141 KI64 *pi64; /**< KI64 view. */ 142 KU64 *pu64; /**< KU64 view. */ 143 143 144 144 signed char *pch; /**< signed char view. */ … … 232 232 int (* pfnDestroy)( PKLDRRDR pRdr); 233 233 /** @copydoc kLdrRdrRead */ 234 int (* pfnRead)( PKLDRRDR pRdr, void *pvBuf, size_tcb, KLDRFOFF off);234 int (* pfnRead)( PKLDRRDR pRdr, void *pvBuf, KSIZE cb, KLDRFOFF off); 235 235 /** @copydoc kLdrRdrAllMap */ 236 236 int (* pfnAllMap)( PKLDRRDR pRdr, const void **ppvBits); … … 244 244 const char * (* pfnName)(PKLDRRDR pRdr); 245 245 /** @copydoc kLdrRdrPageSize */ 246 size_t(* pfnPageSize)(PKLDRRDR pRdr);246 KSIZE (* pfnPageSize)(PKLDRRDR pRdr); 247 247 /** @copydoc kLdrRdrMap */ 248 int (* pfnMap)( PKLDRRDR pRdr, void **ppvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fFixed);248 int (* pfnMap)( PKLDRRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fFixed); 249 249 /** @copydoc kLdrRdrRefresh */ 250 int (* pfnRefresh)( PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments);250 int (* pfnRefresh)( PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 251 251 /** @copydoc kLdrRdrProtect */ 252 int (* pfnProtect)( PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect);252 int (* pfnProtect)( PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect); 253 253 /** @copydoc kLdrRdrUnmap */ 254 int (* pfnUnmap)( PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments);254 int (* pfnUnmap)( PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 255 255 /** @copydoc kLdrRdrDone */ 256 256 void (* pfnDone)( PKLDRRDR pRdr); 257 257 /** The usual non-zero dummy that makes sure we've initialized all members. */ 258 uint32_tu32Dummy;258 KU32 u32Dummy; 259 259 } KLDRRDROPS; 260 260 /** Pointer to file provider operations. */ … … 270 270 { 271 271 /** Magic number (KLDRRDR_MAGIC). */ 272 uint32_tu32Magic;272 KU32 u32Magic; 273 273 /** Pointer to the file provider operations. */ 274 274 PCKLDRRDROPS pOps; … … 282 282 int kLdrRdrOpen( PPKLDRRDR ppRdr, const char *pszFilename); 283 283 int kLdrRdrClose( PKLDRRDR pRdr); 284 int kLdrRdrRead( PKLDRRDR pRdr, void *pvBuf, size_tcb, KLDRFOFF off);284 int kLdrRdrRead( PKLDRRDR pRdr, void *pvBuf, KSIZE cb, KLDRFOFF off); 285 285 int kLdrRdrAllMap( PKLDRRDR pRdr, const void **ppvBits); 286 286 int kLdrRdrAllUnmap(PKLDRRDR pRdr, const void *pvBits); … … 288 288 KLDRFOFF kLdrRdrTell( PKLDRRDR pRdr); 289 289 const char *kLdrRdrName(PKLDRRDR pRdr); 290 size_tkLdrRdrPageSize(PKLDRRDR pRdr);291 int kLdrRdrMap( PKLDRRDR pRdr, void **ppvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fFixed);292 int kLdrRdrRefresh( PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments);293 int kLdrRdrProtect( PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect);294 int kLdrRdrUnmap( PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments);290 KSIZE kLdrRdrPageSize(PKLDRRDR pRdr); 291 int kLdrRdrMap( PKLDRRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fFixed); 292 int kLdrRdrRefresh( PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 293 int kLdrRdrProtect( PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect); 294 int kLdrRdrUnmap( PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 295 295 void kLdrRdrDone( PKLDRRDR pRdr); 296 296 … … 475 475 const char *pchName; 476 476 /** The length of the segment name. */ 477 uint32_tcchName;477 KU32 cchName; 478 478 /** The flat selector to use for the segment (i.e. data/code). 479 479 * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */ 480 uint16_tSelFlat;480 KU16 SelFlat; 481 481 /** The 16-bit selector to use for the segment. 482 482 * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */ 483 uint16_tSel16bit;483 KU16 Sel16bit; 484 484 /** Segment flags. */ 485 uint32_tfFlags;485 KU32 fFlags; 486 486 /** The segment protection. */ 487 487 KLDRPROT enmProt; … … 505 505 KLDRADDR RVA; 506 506 /** The size of the segment including the alignment gap up to the next segment when mapped. */ 507 size_tcbMapped;507 KSIZE cbMapped; 508 508 /** The address the segment was mapped at by kLdrModMap(). 509 509 * Set to 0 if not mapped. */ 510 uintptr_tMapAddress;510 KUPTR MapAddress; 511 511 } KLDRSEG; 512 512 … … 616 616 { 617 617 /** Magic number (KLDRMOD_MAGIC). */ 618 uint32_tu32Magic;618 KU32 u32Magic; 619 619 /** The format of this module. */ 620 620 KLDRFMT enmFmt; … … 629 629 KLDRENDIAN enmEndian; 630 630 /** The filename length (bytes). */ 631 uint32_tcchFilename;631 KU32 cchFilename; 632 632 /** The filename. */ 633 633 const char *pszFilename; … … 635 635 const char *pszName; 636 636 /** The module name length (bytes). */ 637 uint32_tcchName;637 KU32 cchName; 638 638 /** The number of segments in the module. */ 639 uint32_tcSegments;639 KU32 cSegments; 640 640 /** Pointer to the loader methods. 641 641 * Not meant for calling directly thru! */ … … 660 660 /** Special import module ordinal value used to indicate that there is no 661 661 * specific module associated with the requested symbol. */ 662 #define NIL_KLDRMOD_IMPORT (~( uint32_t)0)662 #define NIL_KLDRMOD_IMPORT (~(KU32)0) 663 663 664 664 /** Special symbol ordinal value used to indicate that the symbol 665 665 * only has a string name. */ 666 #define NIL_KLDRMOD_SYM_ORDINAL (~( uint32_t)0)666 #define NIL_KLDRMOD_SYM_ORDINAL (~(KU32)0) 667 667 668 668 … … 724 724 * @param pvUser The user parameter specified to the relocation function. 725 725 */ 726 typedef int FNKLDRMODGETIMPORT(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pchSymbol, size_tcchSymbol,727 const char *pszVersion, PKLDRADDR puValue, uint32_t*pfKind, void *pvUser);726 typedef int FNKLDRMODGETIMPORT(PKLDRMOD pMod, KU32 iImport, KU32 iSymbol, const char *pchSymbol, KSIZE cchSymbol, 727 const char *pszVersion, PKLDRADDR puValue, KU32 *pfKind, void *pvUser); 728 728 /** Pointer to a import callback. */ 729 729 typedef FNKLDRMODGETIMPORT *PFNKLDRMODGETIMPORT; … … 747 747 * @param pvUser The user parameter specified to kLdrModEnumSymbols(). 748 748 */ 749 typedef int FNKLDRMODENUMSYMS(PKLDRMOD pMod, uint32_t iSymbol, const char *pchSymbol, size_tcchSymbol, const char *pszVersion,750 KLDRADDR uValue, uint32_tfKind, void *pvUser);749 typedef int FNKLDRMODENUMSYMS(PKLDRMOD pMod, KU32 iSymbol, const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion, 750 KLDRADDR uValue, KU32 fKind, void *pvUser); 751 751 /** Pointer to a symbol enumerator callback. */ 752 752 typedef FNKLDRMODENUMSYMS *PFNKLDRMODENUMSYMS; … … 771 771 * @param pvUser The user parameter specified to kLdrModEnumDbgInfo. 772 772 */ 773 typedef int FNKLDRENUMDBG(PKLDRMOD pMod, uint32_t iDbgInfo, KLDRDBGINFOTYPE enmType, int16_t iMajorVer, int16_tiMinorVer,773 typedef int FNKLDRENUMDBG(PKLDRMOD pMod, KU32 iDbgInfo, KLDRDBGINFOTYPE enmType, KI16 iMajorVer, KI16 iMinorVer, 774 774 KLDRFOFF offFile, KLDRADDR LinkAddress, KLDRSIZE cb, const char *pszExtFile, void *pvUser); 775 775 /** Pointer to a debug info enumerator callback. */ … … 792 792 * @param pvUser The user parameter specified to kLdrModEnumDbgInfo. 793 793 */ 794 typedef int FNKLDRENUMRSRC(PKLDRMOD pMod, uint32_t idType, const char *pszType, uint32_tidName, const char *pszName,795 uint32_tidLang, KLDRADDR AddrRsrc, KLDRSIZE cbRsrc, void *pvUser);794 typedef int FNKLDRENUMRSRC(PKLDRMOD pMod, KU32 idType, const char *pszType, KU32 idName, const char *pszName, 795 KU32 idLang, KLDRADDR AddrRsrc, KLDRSIZE cbRsrc, void *pvUser); 796 796 /** Pointer to a resource enumerator callback. */ 797 797 typedef FNKLDRENUMRSRC *PFNKLDRENUMRSRC; 798 798 799 799 /** NIL resource name ID. */ 800 #define NIL_KLDRMOD_RSRC_NAME_ID ( ~( uint32_t)0 )800 #define NIL_KLDRMOD_RSRC_NAME_ID ( ~(KU32)0 ) 801 801 /** NIL resource type ID. */ 802 #define NIL_KLDRMOD_RSRC_TYPE_ID ( ~( uint32_t)0 )802 #define NIL_KLDRMOD_RSRC_TYPE_ID ( ~(KU32)0 ) 803 803 /** @name Language ID 804 804 * … … 808 808 * @{ */ 809 809 /** NIL language ID. */ 810 #define NIL_KLDR_LANG_ID ( ~( uint32_t)0 )810 #define NIL_KLDR_LANG_ID ( ~(KU32)0 ) 811 811 /** Special language id value for matching any language. */ 812 #define KLDR_LANG_ID_ANY ( ~( uint32_t)1 )812 #define KLDR_LANG_ID_ANY ( ~(KU32)1 ) 813 813 /** Special language id value indicating language neutral. */ 814 #define KLDR_LANG_ID_NEUTRAL ( ~( uint32_t)2 )814 #define KLDR_LANG_ID_NEUTRAL ( ~(KU32)2 ) 815 815 /** Special language id value indicating user default language. */ 816 #define KLDR_LANG_ID_USER_DEFAULT ( ~( uint32_t)3 )816 #define KLDR_LANG_ID_USER_DEFAULT ( ~(KU32)3 ) 817 817 /** Special language id value indicating system default language. */ 818 #define KLDR_LANG_ID_SYS_DEFAULT ( ~( uint32_t)4 )818 #define KLDR_LANG_ID_SYS_DEFAULT ( ~(KU32)4 ) 819 819 /** Special language id value indicating default custom locale. */ 820 #define KLDR_LANG_ID_CUSTOM_DEFAULT ( ~( uint32_t)5 )820 #define KLDR_LANG_ID_CUSTOM_DEFAULT ( ~(KU32)5 ) 821 821 /** Special language id value indicating unspecified custom locale. */ 822 #define KLDR_LANG_ID_CUSTOM_UNSPECIFIED ( ~( uint32_t)6 )822 #define KLDR_LANG_ID_CUSTOM_UNSPECIFIED ( ~(KU32)6 ) 823 823 /** Special language id value indicating default custom MUI locale. */ 824 #define KLDR_LANG_ID_UI_CUSTOM_DEFAULT ( ~( uint32_t)7 )824 #define KLDR_LANG_ID_UI_CUSTOM_DEFAULT ( ~(KU32)7 ) 825 825 /** @} */ 826 826 … … 829 829 int kLdrModOpenFromRdr(PKLDRRDR pRdr, PPKLDRMOD ppMod); 830 830 int kLdrModOpenNative(const char *pszFilename, PPKLDRMOD ppMod); 831 int kLdrModOpenNativeByHandle( uintptr_tuHandle, PPKLDRMOD ppMod);831 int kLdrModOpenNativeByHandle(KUPTR uHandle, PPKLDRMOD ppMod); 832 832 int kLdrModClose(PKLDRMOD pMod); 833 833 834 int kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tiSymbol,835 const char *pchSymbol, size_tcchSymbol, const char *pszVersion,836 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind);834 int kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol, 835 const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion, 836 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind); 837 837 int kLdrModEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, 838 uint32_tfFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);839 int kLdrModGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_tcchName);840 int32_tkLdrModNumberOfImports(PKLDRMOD pMod, const void *pvBits);838 KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser); 839 int kLdrModGetImport(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName); 840 KI32 kLdrModNumberOfImports(PKLDRMOD pMod, const void *pvBits); 841 841 int kLdrModCanExecuteOn(PKLDRMOD pMod, const void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu); 842 842 int kLdrModGetStackInfo(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo); 843 843 int kLdrModQueryMainEntrypoint(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress); 844 int kLdrModQueryResource(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tidType, const char *pszType,845 uint32_t idName, const char *pszName, uint32_t idLang, PKLDRADDR pAddrRsrc, size_t*pcbRsrc);846 int kLdrModEnumResources(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tidType, const char *pszType,847 uint32_t idName, const char *pszName, uint32_tidLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);844 int kLdrModQueryResource(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 idType, const char *pszType, 845 KU32 idName, const char *pszName, KU32 idLang, PKLDRADDR pAddrRsrc, KSIZE *pcbRsrc); 846 int kLdrModEnumResources(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 idType, const char *pszType, 847 KU32 idName, const char *pszName, KU32 idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser); 848 848 int kLdrModEnumDbgInfo(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser); 849 849 int kLdrModHasDbgInfo(PKLDRMOD pMod, const void *pvBits); … … 859 859 int kLdrModReload(PKLDRMOD pMod); 860 860 int kLdrModFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 861 int kLdrModCallInit(PKLDRMOD pMod, uintptr_tuHandle);862 int kLdrModCallTerm(PKLDRMOD pMod, uintptr_tuHandle);863 int kLdrModCallThread(PKLDRMOD pMod, uintptr_tuHandle, unsigned fAttachingOrDetaching);861 int kLdrModCallInit(PKLDRMOD pMod, KUPTR uHandle); 862 int kLdrModCallTerm(PKLDRMOD pMod, KUPTR uHandle); 863 int kLdrModCallThread(PKLDRMOD pMod, KUPTR uHandle, unsigned fAttachingOrDetaching); 864 864 /** @} */ 865 865 … … 907 907 908 908 /** @copydoc kLdrModQuerySymbol */ 909 int (* pfnQuerySymbol)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tiSymbol,910 const char *pchSymbol, size_tcchSymbol, const char *pszVersion,911 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind);909 int (* pfnQuerySymbol)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol, 910 const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion, 911 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind); 912 912 /** @copydoc kLdrModEnumSymbols */ 913 int (* pfnEnumSymbols)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tfFlags,913 int (* pfnEnumSymbols)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 fFlags, 914 914 PFNKLDRMODENUMSYMS pfnCallback, void *pvUser); 915 915 /** @copydoc kLdrModGetImport */ 916 int (* pfnGetImport)(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_tcchName);916 int (* pfnGetImport)(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName); 917 917 /** @copydoc kLdrModNumberOfImports */ 918 int32_t(* pfnNumberOfImports)(PKLDRMOD pMod, const void *pvBits);918 KI32 (* pfnNumberOfImports)(PKLDRMOD pMod, const void *pvBits); 919 919 /** @copydoc kLdrModCanExecuteOn */ 920 920 int (* pfnCanExecuteOn)(PKLDRMOD pMod, const void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu); … … 924 924 int (* pfnQueryMainEntrypoint)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress); 925 925 /** @copydoc kLdrModQueryResource */ 926 int (* pfnQueryResource)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tidType, const char *pszType,927 uint32_t idName, const char *pszName, uint32_t idLang, PKLDRADDR pAddrRsrc, size_t*pcbRsrc);926 int (* pfnQueryResource)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 idType, const char *pszType, 927 KU32 idName, const char *pszName, KU32 idLang, PKLDRADDR pAddrRsrc, KSIZE *pcbRsrc); 928 928 /** @copydoc kLdrModEnumResources */ 929 int (* pfnEnumResources)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tidType, const char *pszType,930 uint32_t idName, const char *pszName, uint32_tidLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);929 int (* pfnEnumResources)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 idType, const char *pszType, 930 KU32 idName, const char *pszName, KU32 idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser); 931 931 /** @copydoc kLdrModEnumDbgInfo */ 932 932 int (* pfnEnumDbgInfo)(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser); … … 946 946 int (* pfnFixupMapping)(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 947 947 /** @copydoc kLdrModCallInit */ 948 int (* pfnCallInit)(PKLDRMOD pMod, uintptr_tuHandle);948 int (* pfnCallInit)(PKLDRMOD pMod, KUPTR uHandle); 949 949 /** @copydoc kLdrModCallTerm */ 950 int (* pfnCallTerm)(PKLDRMOD pMod, uintptr_tuHandle);950 int (* pfnCallTerm)(PKLDRMOD pMod, KUPTR uHandle); 951 951 /** @copydoc kLdrModCallThread */ 952 int (* pfnCallThread)(PKLDRMOD pMod, uintptr_tuHandle, unsigned fAttachingOrDetaching);952 int (* pfnCallThread)(PKLDRMOD pMod, KUPTR uHandle, unsigned fAttachingOrDetaching); 953 953 /** @copydoc kLdrModSize */ 954 954 KLDRADDR (* pfnSize)(PKLDRMOD pMod); … … 961 961 int (* pfnMostlyDone)(PKLDRMOD pMod); 962 962 /** Dummy which should be assigned a non-zero value. */ 963 uint32_tuEndOfStructure;963 KU32 uEndOfStructure; 964 964 } KLDRMODOPS; 965 965 … … 1034 1034 1035 1035 int kLdrDyldLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, 1036 unsigned fFlags, PHKLDRMOD phMod, char *pszErr, size_tcchErr);1036 unsigned fFlags, PHKLDRMOD phMod, char *pszErr, KSIZE cchErr); 1037 1037 int kLdrDyldUnload(HKLDRMOD hMod); 1038 1038 int kLdrDyldFindByName(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, 1039 1039 unsigned fFlags, PHKLDRMOD phMod); 1040 int kLdrDyldFindByAddress( uintptr_t Address, PHKLDRMOD phMod, uint32_t *piSegment, uintptr_t*poffSegment);1041 int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, size_tcchName);1042 int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, size_tcchFilename);1043 int kLdrDyldQuerySymbol(HKLDRMOD hMod, uint32_tuSymbolOrdinal, const char *pszSymbolName,1044 const char *pszSymbolVersion, uintptr_t *pValue, uint32_t*pfKind);1045 int kLdrDyldQueryResource(HKLDRMOD hMod, uint32_t idType, const char *pszType, uint32_tidName,1046 const char *pszName, uint32_t idLang, void **pvRsrc, size_t*pcbRsrc);1047 int kLdrDyldEnumResources(HKLDRMOD hMod, uint32_t idType, const char *pszType, uint32_tidName,1048 const char *pszName, uint32_tidLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);1040 int kLdrDyldFindByAddress(KUPTR Address, PHKLDRMOD phMod, KU32 *piSegment, KUPTR *poffSegment); 1041 int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, KSIZE cchName); 1042 int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, KSIZE cchFilename); 1043 int kLdrDyldQuerySymbol(HKLDRMOD hMod, KU32 uSymbolOrdinal, const char *pszSymbolName, 1044 const char *pszSymbolVersion, KUPTR *pValue, KU32 *pfKind); 1045 int kLdrDyldQueryResource(HKLDRMOD hMod, KU32 idType, const char *pszType, KU32 idName, 1046 const char *pszName, KU32 idLang, void **pvRsrc, KSIZE *pcbRsrc); 1047 int kLdrDyldEnumResources(HKLDRMOD hMod, KU32 idType, const char *pszType, KU32 idName, 1048 const char *pszName, KU32 idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser); 1049 1049 1050 1050 /** @name OS/2 like API … … 1055 1055 # define KLDROS2API 1056 1056 #endif 1057 int kLdrDosLoadModule(char *pszObject, size_tcbObject, const char *pszModule, PHKLDRMOD phMod);1057 int kLdrDosLoadModule(char *pszObject, KSIZE cbObject, const char *pszModule, PHKLDRMOD phMod); 1058 1058 int kLdrDosFreeModule(HKLDRMOD hMod); 1059 1059 int kLdrDosQueryModuleHandle(const char *pszModname, PHKLDRMOD phMod); 1060 int kLdrDosQueryModuleName(HKLDRMOD hMod, size_tcchName, char *pszName);1061 int kLdrDosQueryProcAddr(HKLDRMOD hMod, uint32_tiOrdinal, const char *pszProcName, void **ppvProcAddr);1062 int kLdrDosQueryProcType(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, uint32_t*pfProcType);1063 int kLdrDosQueryModFromEIP(PHKLDRMOD phMod, uint32_t *piObject, size_t cbName, char *pszName, uintptr_t *poffObject, uintptr_tulEIP);1060 int kLdrDosQueryModuleName(HKLDRMOD hMod, KSIZE cchName, char *pszName); 1061 int kLdrDosQueryProcAddr(HKLDRMOD hMod, KU32 iOrdinal, const char *pszProcName, void **ppvProcAddr); 1062 int kLdrDosQueryProcType(HKLDRMOD hMod, KU32 iOrdinal, const char *pszProcName, KU32 *pfProcType); 1063 int kLdrDosQueryModFromEIP(PHKLDRMOD phMod, KU32 *piObject, KSIZE cbName, char *pszName, KUPTR *poffObject, KUPTR ulEIP); 1064 1064 int kLdrDosReplaceModule(const char *pszOldModule, const char *pszNewModule, const char *pszBackupModule); 1065 int kLdrDosGetResource(HKLDRMOD hMod, uint32_t idType, uint32_tidName, void **pvResAddr);1066 int kLdrDosQueryResourceSize(HKLDRMOD hMod, uint32_t idType, uint32_t idName, uint32_t*pcb);1065 int kLdrDosGetResource(HKLDRMOD hMod, KU32 idType, KU32 idName, void **pvResAddr); 1066 int kLdrDosQueryResourceSize(HKLDRMOD hMod, KU32 idType, KU32 idName, KU32 *pcb); 1067 1067 int kLdrDosFreeResource(void *pvResAddr); 1068 1068 /** @} */ … … 1085 1085 #endif 1086 1086 HKLDRMOD KLDRWINAPI kLdrWLoadLibrary(const char *pszFilename); 1087 HKLDRMOD KLDRWINAPI kLdrWLoadLibraryEx(const char *pszFilename, void *hFileReserved, uint32_tfFlags);1088 uint32_t KLDRWINAPI kLdrWGetModuleFileName(HKLDRMOD hMod, char *pszModName, size_tcchModName);1087 HKLDRMOD KLDRWINAPI kLdrWLoadLibraryEx(const char *pszFilename, void *hFileReserved, KU32 fFlags); 1088 KU32 KLDRWINAPI kLdrWGetModuleFileName(HKLDRMOD hMod, char *pszModName, KSIZE cchModName); 1089 1089 HKLDRMOD KLDRWINAPI kLdrWGetModuleHandle(const char *pszFilename); 1090 int KLDRWINAPI kLdrWGetModuleHandleEx( uint32_tfFlags, const char *pszFilename, HKLDRMOD hMod);1090 int KLDRWINAPI kLdrWGetModuleHandleEx(KU32 fFlags, const char *pszFilename, HKLDRMOD hMod); 1091 1091 void * KLDRWINAPI kLdrWGetProcAddress(HKLDRMOD hMod, const char *pszProcName); 1092 uint32_t KLDRWINAPI kLdrWGetDllDirectory(size_tcchDir, char *pszDir);1092 KU32 KLDRWINAPI kLdrWGetDllDirectory(KSIZE cchDir, char *pszDir); 1093 1093 int KLDRWINAPI kLdrWSetDllDirectory(const char *pszDir); 1094 1094 int KLDRWINAPI kLdrWFreeLibrary(HKLDRMOD hMod); … … 1100 1100 typedef struct KLDRWRSRCLOADED *HKLDRWRSRCLOADED; 1101 1101 HKLDRWRSRCFOUND KLDRWINAPI kLdrWFindResource(HKLDRMOD hMod, const char *pszType, const char *pszName); 1102 HKLDRWRSRCFOUND KLDRWINAPI kLdrWFindResourceEx(HKLDRMOD hMod, const char *pszType, const char *pszName, uint16_tidLang);1103 uint32_tKLDRWINAPI kLdrWSizeofResource(HKLDRMOD hMod, HKLDRWRSRCFOUND hFoundRsrc);1102 HKLDRWRSRCFOUND KLDRWINAPI kLdrWFindResourceEx(HKLDRMOD hMod, const char *pszType, const char *pszName, KU16 idLang); 1103 KU32 KLDRWINAPI kLdrWSizeofResource(HKLDRMOD hMod, HKLDRWRSRCFOUND hFoundRsrc); 1104 1104 HKLDRWRSRCLOADED KLDRWINAPI kLdrWLoadResource(HKLDRMOD hMod, HKLDRWRSRCFOUND hFoundRsrc); 1105 1105 void *KLDRWINAPI kLdrWLockResource(HKLDRMOD hMod, HKLDRWRSRCLOADED hLoadedRsrc); 1106 1106 int KLDRWINAPI kLdrWFreeResource(HKLDRMOD hMod, HKLDRWRSRCLOADED hLoadedRsrc); 1107 1107 1108 typedef int (KLDRWINAPI *PFNKLDRWENUMRESTYPE)(HKLDRMOD hMod, const char *pszType, uintptr_tuUser);1109 int KLDRWINAPI kLdrWEnumResourceTypes(HKLDRMOD hMod, PFNKLDRWENUMRESTYPE pfnEnum, uintptr_tuUser);1110 int KLDRWINAPI kLdrWEnumResourceTypesEx(HKLDRMOD hMod, PFNKLDRWENUMRESTYPE pfnEnum, uintptr_t uUser, uint32_t fFlags, uint16_tidLang);1111 1112 typedef int (KLDRWINAPI *PFNKLDRWENUMRESNAME)(HKLDRMOD hMod, const char *pszType, char *pszName, uintptr_tuUser);1113 int KLDRWINAPI kLdrWEnumResourceNames(HKLDRMOD hMod, const char *pszType, PFNKLDRWENUMRESNAME pfnEnum, uintptr_tuUser);1114 int KLDRWINAPI kLdrWEnumResourceNamesEx(HKLDRMOD hMod, const char *pszType, PFNKLDRWENUMRESNAME pfnEnum, uintptr_t uUser, uint32_t fFlags, uint16_tidLang);1115 1116 typedef int (KLDRWINAPI *PFNKLDRWENUMRESLANG)(HKLDRMOD hMod, const char *pszType, const char *pszName, uint16_t idLang, uintptr_tuUser);1117 int KLDRWINAPI kLdrWEnumResourceLanguages(HKLDRMOD hMod, const char *pszType, const char *pszName, PFNKLDRWENUMRESLANG pfnEnum, uintptr_tuUser);1108 typedef int (KLDRWINAPI *PFNKLDRWENUMRESTYPE)(HKLDRMOD hMod, const char *pszType, KUPTR uUser); 1109 int KLDRWINAPI kLdrWEnumResourceTypes(HKLDRMOD hMod, PFNKLDRWENUMRESTYPE pfnEnum, KUPTR uUser); 1110 int KLDRWINAPI kLdrWEnumResourceTypesEx(HKLDRMOD hMod, PFNKLDRWENUMRESTYPE pfnEnum, KUPTR uUser, KU32 fFlags, KU16 idLang); 1111 1112 typedef int (KLDRWINAPI *PFNKLDRWENUMRESNAME)(HKLDRMOD hMod, const char *pszType, char *pszName, KUPTR uUser); 1113 int KLDRWINAPI kLdrWEnumResourceNames(HKLDRMOD hMod, const char *pszType, PFNKLDRWENUMRESNAME pfnEnum, KUPTR uUser); 1114 int KLDRWINAPI kLdrWEnumResourceNamesEx(HKLDRMOD hMod, const char *pszType, PFNKLDRWENUMRESNAME pfnEnum, KUPTR uUser, KU32 fFlags, KU16 idLang); 1115 1116 typedef int (KLDRWINAPI *PFNKLDRWENUMRESLANG)(HKLDRMOD hMod, const char *pszType, const char *pszName, KU16 idLang, KUPTR uUser); 1117 int KLDRWINAPI kLdrWEnumResourceLanguages(HKLDRMOD hMod, const char *pszType, const char *pszName, PFNKLDRWENUMRESLANG pfnEnum, KUPTR uUser); 1118 1118 int KLDRWINAPI kLdrWEnumResourceLanguagesEx(HKLDRMOD hMod, const char *pszType, const char *pszName, 1119 PFNKLDRWENUMRESLANG pfnEnum, uintptr_t uUser, uint32_t fFlags, uint16_tidLang);1119 PFNKLDRWENUMRESLANG pfnEnum, KUPTR uUser, KU32 fFlags, KU16 idLang); 1120 1120 /** @} */ 1121 1121 … … 1130 1130 { 1131 1131 /** Load & search flags, some which will become defaults. */ 1132 uint32_tfFlags;1132 KU32 fFlags; 1133 1133 /** The default search method. */ 1134 1134 KLDRDYLDSEARCH enmSearch; … … 1140 1140 char szDefSuffix[16]; 1141 1141 /** The LD_LIBRARY_PATH prefix for the process.. */ 1142 char szLibPath[4096 - sizeof( uint32_t) - sizeof(KLDRDYLDSEARCH) - 16 - 16 - 260];1142 char szLibPath[4096 - sizeof(KU32) - sizeof(KLDRDYLDSEARCH) - 16 - 16 - 260]; 1143 1143 } KLDREXEARGS, *PKLDREXEARGS; 1144 1144 /** Pointer to a const argument package from the stub. */ -
trunk/kStuff/kLdr/kLdrBase.h
r3537 r3567 28 28 #define ___kLdrBase_h___ 29 29 30 #include <k/kDefs.h> 31 #include <k/kTypes.h> 32 30 33 31 34 /** @defgroup grp_kLdrBase kLdrBase - Base Definitions And Typedefs 32 35 * @{ */ 33 34 /*35 * kLdr depend on size_t, [u]intNN_t, [u]intptr_t and some related constants.36 * If KLDR_ALREADY_INCLUDED_STD_TYPES or KCOMMON_ALREADY_INCLUDED_STD_TYPES37 * is defined, these has already been defined.38 */39 #if !defined(KLDR_ALREADY_INCLUDED_STD_TYPES) && !defined(KCOMMON_ALREADY_INCLUDED_STD_TYPES)40 # define KCOMMON_ALREADY_INCLUDED_STD_TYPES 141 # include <sys/types.h>42 # include <stddef.h>43 # ifdef _MSC_VER44 typedef signed char int8_t;45 typedef unsigned char uint8_t;46 typedef signed short int16_t;47 typedef unsigned short uint16_t;48 typedef signed int int32_t;49 typedef unsigned int uint32_t;50 typedef signed __int64 int64_t;51 typedef unsigned __int64 uint64_t;52 typedef int64_t intmax_t;53 typedef uint64_t uintmax_t;54 # define UINT8_C(c) (c)55 # define UINT16_C(c) (c)56 # define UINT32_C(c) (c ## U)57 # define UINT64_C(c) (c ## ULL)58 # define INT8_C(c) (c)59 # define INT16_C(c) (c)60 # define INT32_C(c) (c)61 # define INT64_C(c) (c ## LL)62 # define INT8_MIN (INT8_C(-0x7f) - 1)63 # define INT16_MIN (INT16_C(-0x7fff) - 1)64 # define INT32_MIN (INT32_C(-0x7fffffff) - 1)65 # define INT64_MIN (INT64_C(-0x7fffffffffffffff) - 1)66 # define INT8_MAX INT8_C(0x7f)67 # define INT16_MAX INT16_C(0x7fff)68 # define INT32_MAX INT32_C(0x7fffffff)69 # define INT64_MAX INT64_C(0x7fffffffffffffff)70 # define UINT8_MAX UINT8_C(0xff)71 # define UINT16_MAX UINT16_C(0xffff)72 # define UINT32_MAX UINT32_C(0xffffffff)73 # define UINT64_MAX UINT64_C(0xffffffffffffffff)74 # else75 # include <stdint.h>76 # endif77 #endif /* !KLDR_ALREADY_INCLUDED_STD_TYPES && !KCOMMON_ALREADY_INCLUDED_STD_TYPES */78 36 79 37 /** Get the minimum of two values. */ … … 82 40 #define KLDR_MAX(a, b) ((a) >= (b) ? (a) : (b)) 83 41 /** Calculate the offset of a structure member. */ 84 #define KLDR_OFFSETOF(strct, memb) ( ( size_t)( &((strct *)0)->memb ) )85 /** Align a size_tvalue. */86 #define KLDR_ALIGN_Z(val, align) ( ((val) + ((align) - 1)) & ~( size_t)((align) - 1) )42 #define KLDR_OFFSETOF(strct, memb) ( (KSIZE)( &((strct *)0)->memb ) ) 43 /** Align a KSIZE value. */ 44 #define KLDR_ALIGN_Z(val, align) ( ((val) + ((align) - 1)) & ~(KSIZE)((align) - 1) ) 87 45 /** Align a void * value. */ 88 #define KLDR_ALIGN_P(pv, align) ( (void *)( (( uintptr_t)(pv) + ((align) - 1)) & ~(uintptr_t)((align) - 1) ) )89 /** Align a size_tvalue. */46 #define KLDR_ALIGN_P(pv, align) ( (void *)( ((KUPTR)(pv) + ((align) - 1)) & ~(KUPTR)((align) - 1) ) ) 47 /** Align a KSIZE value. */ 90 48 #define KLDR_ALIGN_ADDR(val, align) ( ((val) + ((align) - 1)) & ~(KLDRADDR)((align) - 1) ) 91 49 /** Number of elements in an array. */ … … 110 68 /** @def KLDR_E2E_U16 111 69 * Convert the endian of an unsigned 16-bit value. */ 112 # define KLDR_E2E_U16(u16) ( ( uint16_t) (((u16) >> 8) | ((u16) << 8)) )70 # define KLDR_E2E_U16(u16) ( (KU16) (((u16) >> 8) | ((u16) << 8)) ) 113 71 /** @def KLDR_E2E_U32 114 72 * Convert the endian of an unsigned 32-bit value. */ 115 # define KLDR_E2E_U32(u32) ( ( ((u32) & UINT32_C(0xff000000)) >> 24 ) \116 | ( ((u32) & UINT32_C(0x00ff0000)) >> 8 ) \117 | ( ((u32) & UINT32_C(0x0000ff00)) << 8 ) \118 | ( ((u32) & UINT32_C(0x000000ff)) << 24 ) \73 # define KLDR_E2E_U32(u32) ( ( ((u32) & KU32_C(0xff000000)) >> 24 ) \ 74 | ( ((u32) & KU32_C(0x00ff0000)) >> 8 ) \ 75 | ( ((u32) & KU32_C(0x0000ff00)) << 8 ) \ 76 | ( ((u32) & KU32_C(0x000000ff)) << 24 ) \ 119 77 ) 120 78 /** @def KLDR_E2E_U64 121 79 * Convert the endian of an unsigned 64-bit value. */ 122 # define KLDR_E2E_U64(u64) ( ( ((u64) & UINT64_C(0xff00000000000000)) >> 56 ) \123 | ( ((u64) & UINT64_C(0x00ff000000000000)) >> 40 ) \124 | ( ((u64) & UINT64_C(0x0000ff0000000000)) >> 24 ) \125 | ( ((u64) & UINT64_C(0x000000ff00000000)) >> 8 ) \126 | ( ((u64) & UINT64_C(0x00000000ff000000)) << 8 ) \127 | ( ((u64) & UINT64_C(0x0000000000ff0000)) << 24 ) \128 | ( ((u64) & UINT64_C(0x000000000000ff00)) << 40 ) \129 | ( ((u64) & UINT64_C(0x00000000000000ff)) << 56 ) \80 # define KLDR_E2E_U64(u64) ( ( ((u64) & KU64_C(0xff00000000000000)) >> 56 ) \ 81 | ( ((u64) & KU64_C(0x00ff000000000000)) >> 40 ) \ 82 | ( ((u64) & KU64_C(0x0000ff0000000000)) >> 24 ) \ 83 | ( ((u64) & KU64_C(0x000000ff00000000)) >> 8 ) \ 84 | ( ((u64) & KU64_C(0x00000000ff000000)) << 8 ) \ 85 | ( ((u64) & KU64_C(0x0000000000ff0000)) << 24 ) \ 86 | ( ((u64) & KU64_C(0x000000000000ff00)) << 40 ) \ 87 | ( ((u64) & KU64_C(0x00000000000000ff)) << 56 ) \ 130 88 ) 131 89 … … 143 101 * Unsigned 64-bit big-endian to host endian. */ 144 102 #ifdef KLDR_LITTLE_ENDIAN 145 # define KLDR_LE2H_U16(u16) (( uint16_t)(u16))146 # define KLDR_LE2H_U32(u32) (( uint32_t)(u32))147 # define KLDR_LE2H_U64(u64) (( uint32_t)(u32))103 # define KLDR_LE2H_U16(u16) ((KU16)(u16)) 104 # define KLDR_LE2H_U32(u32) ((KU32)(u32)) 105 # define KLDR_LE2H_U64(u64) ((KU32)(u32)) 148 106 # define KLDR_BE2H_U16(u16) KLDR_E2E_U16(u16) 149 107 # define KLDR_BE2H_U32(u32) KLDR_E2E_U32(u32) … … 153 111 # define KLDR_LE2H_U32(u32) KLDR_E2E_U32(u32) 154 112 # define KLDR_LE2H_U32(u64) KLDR_E2E_U64(u64) 155 # define KLDR_BE2H_U16(u16) (( uint16_t)(u16))156 # define KLDR_BE2H_U32(u32) (( uint32_t)(u32))157 # define KLDR_BE2H_U64(u64) (( uint32_t)(u32))113 # define KLDR_BE2H_U16(u16) ((KU16)(u16)) 114 # define KLDR_BE2H_U32(u32) ((KU32)(u32)) 115 # define KLDR_BE2H_U64(u64) ((KU32)(u32)) 158 116 #else 159 117 # error "KLDR_BIG_ENDIAN or KLDR_LITTLE_ENDIAN is supposed to be defined." -
trunk/kStuff/kLdr/kLdrDyld.c
r3537 r3567 96 96 97 97 /** The default flags. */ 98 uint32_tkLdrDyldFlags = 0;98 KU32 kLdrDyldFlags = 0; 99 99 /** The default search method. */ 100 100 KLDRDYLDSEARCH kLdrDyldSearch = KLDRDYLD_SEARCH_HOST; … … 110 110 void *g_pvkLdrDyldMainStack = NULL; 111 111 /** The size of the main stack object. */ 112 size_tg_cbkLdrDyldMainStack = 0;112 KSIZE g_cbkLdrDyldMainStack = 0; 113 113 /** @} */ 114 114 … … 123 123 static PPKLDRDYLDMOD g_papStackMods; 124 124 /** The number of used entries in the g_papStackMods array. */ 125 static uint32_tg_cStackMods;125 static KU32 g_cStackMods; 126 126 /** The number of entries allocated for the g_papStackMods array. */ 127 static uint32_tg_cStackModsAllocated;127 static KU32 g_cStackModsAllocated; 128 128 /** Number of active load calls. */ 129 static uint32_tg_cActiveLoadCalls;129 static KU32 g_cActiveLoadCalls; 130 130 /** Number of active unload calls. */ 131 static uint32_tg_cActiveUnloadCalls;131 static KU32 g_cActiveUnloadCalls; 132 132 /** Total number of load calls. */ 133 static uint32_tg_cTotalLoadCalls;133 static KU32 g_cTotalLoadCalls; 134 134 /** Total mumber of unload calls. */ 135 static uint32_tg_cTotalUnloadCalls;135 static KU32 g_cTotalUnloadCalls; 136 136 /** Boolean flag indicating that GC is active. */ 137 static uint32_tg_fActiveGC;137 static KU32 g_fActiveGC; 138 138 139 139 … … 145 145 * @internal 146 146 * @{ */ 147 void kldrDyldDoLoadExeStackSwitch(PKLDRDYLDMOD pExe, void *pvStack, size_tcbStack);147 void kldrDyldDoLoadExeStackSwitch(PKLDRDYLDMOD pExe, void *pvStack, KSIZE cbStack); 148 148 static int kldrDyldDoLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, 149 unsigned fFlags, PPKLDRDYLDMOD ppMod, char *pszErr, size_tcchErr);149 unsigned fFlags, PPKLDRDYLDMOD ppMod, char *pszErr, KSIZE cchErr); 150 150 static int kldrDyldDoLoad2(PKLDRDYLDMOD pLoadedMod, const char *pszPrefix, const char *pszSuffix, 151 151 KLDRDYLDSEARCH enmSearch, unsigned fFlags); … … 155 155 static int kldrDyldDoFindByName(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, 156 156 unsigned fFlags, PPKLDRDYLDMOD ppMod); 157 static int kldrDyldDoFindByAddress( uintptr_t Address, PPKLDRDYLDMOD ppMod, uint32_t *piSegment, uintptr_t*poffSegment);158 static int kldrDyldDoGetName(PKLDRDYLDMOD pMod, char *pszName, size_tcchName);159 static int kldrDyldDoGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, size_tcchFilename);160 static int kldrDyldDoQuerySymbol(PKLDRDYLDMOD pMod, uint32_t uSymbolOrdinal, const char *pszSymbolName, uintptr_t *pValue, uint32_t*pfKind);157 static int kldrDyldDoFindByAddress(KUPTR Address, PPKLDRDYLDMOD ppMod, KU32 *piSegment, KUPTR *poffSegment); 158 static int kldrDyldDoGetName(PKLDRDYLDMOD pMod, char *pszName, KSIZE cchName); 159 static int kldrDyldDoGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, KSIZE cchFilename); 160 static int kldrDyldDoQuerySymbol(PKLDRDYLDMOD pMod, KU32 uSymbolOrdinal, const char *pszSymbolName, KUPTR *pValue, KU32 *pfKind); 161 161 /** @} */ 162 162 … … 171 171 * @internal 172 172 * @{ */ 173 static uint32_tkldrDyldStackNewFrame(PKLDRDYLDMOD pMod);173 static KU32 kldrDyldStackNewFrame(PKLDRDYLDMOD pMod); 174 174 static int kldrDyldStackAddModule(PKLDRDYLDMOD pMod); 175 175 static int kldrDyldStackFrameCompleted(void); 176 176 static void kldrDyldStackCleanupOne(PKLDRDYLDMOD pMod, int rc); 177 static void kldrDyldStackDropFrame( uint32_t iLoad1st, uint32_tiLoadEnd, int rc);177 static void kldrDyldStackDropFrame(KU32 iLoad1st, KU32 iLoadEnd, int rc); 178 178 /** @} */ 179 179 180 static int kldrDyldCopyError(int rc, char *pszErr, size_tcchErr);180 static int kldrDyldCopyError(int rc, char *pszErr, KSIZE cchErr); 181 181 182 182 … … 235 235 { 236 236 void *pvStack; 237 size_tcbStack;237 KSIZE cbStack; 238 238 PKLDRDYLDMOD pExe; 239 239 int rc; … … 325 325 */ 326 326 int kLdrDyldLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, 327 unsigned fFlags, PHKLDRMOD phMod, char *pszErr, size_tcchErr)327 unsigned fFlags, PHKLDRMOD phMod, char *pszErr, KSIZE cchErr) 328 328 { 329 329 int rc; … … 434 434 * @param poffSegment Where to store the offset into the segment. (optional) 435 435 */ 436 int kLdrDyldFindByAddress( uintptr_t Address, PHKLDRMOD phMod, uint32_t *piSegment, uintptr_t*poffSegment)436 int kLdrDyldFindByAddress(KUPTR Address, PHKLDRMOD phMod, KU32 *piSegment, KUPTR *poffSegment) 437 437 { 438 438 int rc; … … 441 441 *phMod = NIL_HKLDRMOD; 442 442 if (piSegment) 443 *piSegment = ~( uint32_t)0;443 *piSegment = ~(KU32)0; 444 444 if (poffSegment) 445 *poffSegment = ~( uintptr_t)0;445 *poffSegment = ~(KUPTR)0; 446 446 447 447 /* get sem & do work */ … … 468 468 * @see kLdrDyldGetFilename 469 469 */ 470 int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, size_tcchName)470 int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, KSIZE cchName) 471 471 { 472 472 int rc; … … 499 499 * @see kLdrDyldGetName 500 500 */ 501 int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, size_tcchFilename)501 int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, KSIZE cchFilename) 502 502 { 503 503 int rc; … … 532 532 * @param pfKind Where to put the symbol kind flags. Optional if pValue is non-zero. 533 533 */ 534 int kLdrDyldQuerySymbol(HKLDRMOD hMod, uint32_tuSymbolOrdinal, const char *pszSymbolName,535 const char *pszSymbolVersion, uintptr_t *pValue, uint32_t*pfKind)534 int kLdrDyldQuerySymbol(HKLDRMOD hMod, KU32 uSymbolOrdinal, const char *pszSymbolName, 535 const char *pszSymbolVersion, KUPTR *pValue, KU32 *pfKind) 536 536 { 537 537 int rc; … … 592 592 */ 593 593 static int kldrDyldDoLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, 594 unsigned fFlags, PPKLDRDYLDMOD ppMod, char *pszErr, size_tcchErr)594 unsigned fFlags, PPKLDRDYLDMOD ppMod, char *pszErr, KSIZE cchErr) 595 595 { 596 596 int rc; … … 692 692 * Load prerequisites. 693 693 */ 694 uint32_ti;695 uint32_tiLoad1st = kldrDyldStackNewFrame(pLoadedMod);694 KU32 i; 695 KU32 iLoad1st = kldrDyldStackNewFrame(pLoadedMod); 696 696 int rc = kldrDyldDoLoadPrerequisites(pLoadedMod, pszPrefix, pszSuffix, enmSearch, fFlags); 697 uint32_tiLoadEnd = kldrDyldStackFrameCompleted();697 KU32 iLoadEnd = kldrDyldStackFrameCompleted(); 698 698 if (rc) 699 699 { … … 882 882 if (cEntries < sizeof(s_aEntries) / sizeof(s_aEntries[0])) 883 883 { 884 s_aEntries[cEntries].cLeft = ~( uint32_t)0;884 s_aEntries[cEntries].cLeft = ~(KU32)0; 885 885 s_aEntries[cEntries].pMod = pMod->papPrereqs[pMod->cPrereqs - s_aEntries[i].cLeft]; 886 886 s_aEntries[i].cLeft--; … … 1024 1024 * @param pLoadMod The module being loaded (only used for asserting). 1025 1025 */ 1026 static uint32_tkldrDyldStackNewFrame(PKLDRDYLDMOD pLoadMod)1026 static KU32 kldrDyldStackNewFrame(PKLDRDYLDMOD pLoadMod) 1027 1027 { 1028 1028 /* … … 1084 1084 if (g_cStackMods + 1 > g_cStackModsAllocated) 1085 1085 { 1086 uint32_tcNew = g_cStackModsAllocated ? g_cStackModsAllocated * 2 : 128;1086 KU32 cNew = g_cStackModsAllocated ? g_cStackModsAllocated * 2 : 128; 1087 1087 void *pvOld = g_papStackMods; 1088 1088 void *pvNew = kldrHlpAlloc(cNew * sizeof(g_papStackMods[0])); … … 1199 1199 * @param rc Used for state verification. 1200 1200 */ 1201 static void kldrDyldStackDropFrame( uint32_t iLoad1st, uint32_tiLoadEnd, int rc)1202 { 1203 uint32_ti;1201 static void kldrDyldStackDropFrame(KU32 iLoad1st, KU32 iLoadEnd, int rc) 1202 { 1203 KU32 i; 1204 1204 KLDRDYLD_ASSERT(iLoad1st <= g_cStackMods); 1205 1205 KLDRDYLD_ASSERT(iLoadEnd == g_cStackMods); … … 1318 1318 case KLDRSTATE_PENDING_TERMINATION: 1319 1319 { 1320 const uint32_tcTotalLoadCalls = g_cTotalLoadCalls;1321 const uint32_tcTotalUnloadCalls = g_cTotalUnloadCalls;1320 const KU32 cTotalLoadCalls = g_cTotalLoadCalls; 1321 const KU32 cTotalUnloadCalls = g_cTotalUnloadCalls; 1322 1322 kldrDyldModCallTerm(pMod); 1323 1323 fRestart = cTotalLoadCalls != g_cTotalLoadCalls … … 1401 1401 * @internal 1402 1402 */ 1403 static int kldrDyldDoFindByAddress( uintptr_t Address, PPKLDRDYLDMOD ppMod, uint32_t *piSegment, uintptr_t*poffSegment)1403 static int kldrDyldDoFindByAddress(KUPTR Address, PPKLDRDYLDMOD ppMod, KU32 *piSegment, KUPTR *poffSegment) 1404 1404 { 1405 1405 /* Scan the segments of each module in the load list. */ … … 1407 1407 while (pMod) 1408 1408 { 1409 uint32_tiSeg;1409 KU32 iSeg; 1410 1410 for (iSeg = 0; iSeg < pMod->pMod->cSegments; iSeg++) 1411 1411 { … … 1417 1417 *piSegment = iSeg; 1418 1418 if (poffSegment) 1419 *poffSegment = ( uintptr_t)off;1419 *poffSegment = (KUPTR)off; 1420 1420 return 0; 1421 1421 } … … 1434 1434 * @internal 1435 1435 */ 1436 static int kldrDyldDoGetName(PKLDRDYLDMOD pMod, char *pszName, size_tcchName)1436 static int kldrDyldDoGetName(PKLDRDYLDMOD pMod, char *pszName, KSIZE cchName) 1437 1437 { 1438 1438 return kldrDyldModGetName(pMod, pszName, cchName); … … 1444 1444 * @internal 1445 1445 */ 1446 static int kldrDyldDoGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, size_tcchFilename)1446 static int kldrDyldDoGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, KSIZE cchFilename) 1447 1447 { 1448 1448 return kldrDyldModGetFilename(pMod, pszFilename, cchFilename); … … 1454 1454 * @internal 1455 1455 */ 1456 static int kldrDyldDoQuerySymbol(PKLDRDYLDMOD pMod, uint32_t uSymbolOrdinal, const char *pszSymbolName, uintptr_t *pValue, uint32_t*pfKind)1456 static int kldrDyldDoQuerySymbol(PKLDRDYLDMOD pMod, KU32 uSymbolOrdinal, const char *pszSymbolName, KUPTR *pValue, KU32 *pfKind) 1457 1457 { 1458 1458 return kldrDyldModQuerySymbol(pMod, uSymbolOrdinal, pszSymbolName, pValue, pfKind); … … 1485 1485 * @param cchErr The size of the destination buffer. 1486 1486 */ 1487 static int kldrDyldCopyError(int rc, char *pszErr, size_tcchErr)1488 { 1489 size_tcchToCopy;1487 static int kldrDyldCopyError(int rc, char *pszErr, KSIZE cchErr) 1488 { 1489 KSIZE cchToCopy; 1490 1490 1491 1491 /* if no error string, format the rc into a string. */ -
trunk/kStuff/kLdr/kLdrDyldFind.c
r3537 r3567 82 82 { 83 83 const char *pszName; 84 size_tcchName;84 KSIZE cchName; 85 85 86 86 const char *pszPrefix; 87 size_tcchPrefix;87 KSIZE cchPrefix; 88 88 89 89 const char *pszSuffix; 90 size_tcchSuffix;91 92 size_tcchMaxLength;90 KSIZE cchSuffix; 91 92 KSIZE cchMaxLength; 93 93 94 94 KLDRDYLDSEARCH enmSearch; 95 uint32_tfFlags;95 KU32 fFlags; 96 96 PPKLDRRDR ppRdr; 97 97 } KLDRDYLDFINDARGS, *PKLDRDYLDFINDARGS; … … 205 205 KLDRDYLDSEARCH enmSearch, unsigned fFlags, PPKLDRRDR ppRdr); 206 206 static int kldrDyldFindTryOpen(const char *pszFilename, PPKLDRRDR ppRdr); 207 static int kldrDyldFindTryOpenPath(const char *pchPath, size_tcchPath, PCKLDRDYLDFINDARGS pArgs);207 static int kldrDyldFindTryOpenPath(const char *pchPath, KSIZE cchPath, PCKLDRDYLDFINDARGS pArgs); 208 208 static int kldrDyldFindEnumeratePath(const char *pszSearchPath, PCKLDRDYLDFINDARGS pArgs); 209 209 static int kldrDyldFindGetDefaults(KLDRDYLDSEARCH *penmSearch, const char **pszPrefix, 210 const char **pszSuffix, const char *pszName, uint32_tfFlags);210 const char **pszSuffix, const char *pszName, KU32 fFlags); 211 211 212 212 … … 218 218 int kldrDyldFindInit(void) 219 219 { 220 size_tcch;220 KSIZE cch; 221 221 int rc; 222 222 char szTmp[sizeof(kLdrDyldDefSuffix)]; … … 377 377 { 378 378 const char *pszFilename = kLdrRdrName(pRdr); 379 const size_tcchFilename = kLdrHlpStrLen(pszFilename);379 const KSIZE cchFilename = kLdrHlpStrLen(pszFilename); 380 380 PKLDRDYLDMOD pCur; 381 381 for (pCur = kLdrDyldHead; pCur; pCur = pCur->Load.pNext) … … 391 391 { 392 392 const char *pszFilename = kLdrRdrName(pRdr); 393 const size_tcchFilename = kLdrHlpStrLen(pszFilename);393 const KSIZE cchFilename = kLdrHlpStrLen(pszFilename); 394 394 PKLDRDYLDMOD pCur; 395 395 for (pCur = kLdrDyldHead; pCur; pCur = pCur->Load.pNext) … … 590 590 if (!kLdrDyldExePath[0]) 591 591 { 592 size_tcch;592 KSIZE cch; 593 593 kldrHlpGetEnv("KLDR_EXE_PATH", kLdrDyldExePath, sizeof(kLdrDyldExePath) - 10); 594 594 cch = kLdrHlpStrLen(kLdrDyldExePath); … … 637 637 * @returns See kldrDyldFindTryOpen 638 638 */ 639 static int kldrDyldFindTryOpenPath(const char *pchPath, size_tcchPath, PCKLDRDYLDFINDARGS pArgs)639 static int kldrDyldFindTryOpenPath(const char *pchPath, KSIZE cchPath, PCKLDRDYLDFINDARGS pArgs) 640 640 { 641 641 static char s_szFilename[1024]; … … 721 721 { 722 722 const char *pszEnd; 723 size_tcchPath;723 KSIZE cchPath; 724 724 725 725 /* … … 780 780 */ 781 781 static int kldrDyldFindGetDefaults(KLDRDYLDSEARCH *penmSearch, const char **ppszPrefix, const char **ppszSuffix, 782 const char *pszName, uint32_tfFlags)782 const char *pszName, KU32 fFlags) 783 783 { 784 784 unsigned fCaseSensitive; … … 836 836 if (*ppszSuffix) 837 837 { 838 const size_tcchName = kLdrHlpStrLen(pszName);839 const size_tcchSuffix = kLdrHlpStrLen(*ppszSuffix);838 const KSIZE cchName = kLdrHlpStrLen(pszName); 839 const KSIZE cchSuffix = kLdrHlpStrLen(*ppszSuffix); 840 840 if ( cchName > cchSuffix 841 841 && ( fCaseSensitive … … 908 908 /* do a filename based search. */ 909 909 const char *pszFilename = kLdrRdrName(pRdr); 910 const size_tcchFilename = kLdrHlpStrLen(pszFilename);910 const KSIZE cchFilename = kLdrHlpStrLen(pszFilename); 911 911 PKLDRDYLDMOD pCur; 912 912 rc = KLDR_ERR_MODULE_NOT_FOUND; … … 926 926 else 927 927 { 928 const size_tcchName = kLdrHlpStrLen(pszName);929 const size_tcchPrefix = pszPrefix ? kLdrHlpStrLen(pszPrefix) : 0;930 const size_tcchSuffix = pszSuffix ? kLdrHlpStrLen(pszSuffix) : 0;928 const KSIZE cchName = kLdrHlpStrLen(pszName); 929 const KSIZE cchPrefix = pszPrefix ? kLdrHlpStrLen(pszPrefix) : 0; 930 const KSIZE cchSuffix = pszSuffix ? kLdrHlpStrLen(pszSuffix) : 0; 931 931 const char *pszNameSuffix = kldrHlpGetSuff(pszName); 932 932 PKLDRDYLDMOD pCur = kLdrDyldHead; -
trunk/kStuff/kLdr/kLdrDyldMod.c
r3537 r3567 67 67 * @param ppMod Where to put the pointer to the new module on success. 68 68 */ 69 int kldrDyldModCreate(PKLDRRDR pRdr, uint32_tfFlags, PPKLDRDYLDMOD ppMod)69 int kldrDyldModCreate(PKLDRRDR pRdr, KU32 fFlags, PPKLDRDYLDMOD ppMod) 70 70 { 71 71 PKLDRDYLDMOD pMod; … … 198 198 * @remark This function ain't finalized yet. 199 199 */ 200 int kldrDyldModCreateNative( uintptr_thNativeModule)200 int kldrDyldModCreateNative(KUPTR hNativeModule) 201 201 { 202 202 #if 0 … … 275 275 if (pMod->papPrereqs) 276 276 { 277 uint32_ti = pMod->cPrereqs;277 KU32 i = pMod->cPrereqs; 278 278 while (i-- > 0) 279 279 { … … 609 609 * @param pMod The module in question. 610 610 */ 611 static uint32_tkldrDyldModUnloadPrerequisitesOne(PKLDRDYLDMOD pMod)611 static KU32 kldrDyldModUnloadPrerequisitesOne(PKLDRDYLDMOD pMod) 612 612 { 613 613 PKLDRDYLDMOD pMod2; 614 uint32_tcToUnload = 0;615 uint32_ti;614 KU32 cToUnload = 0; 615 KU32 i; 616 616 617 617 KLDRDYLDMOD_ASSERT(pMod->papPrereqs || !pMod->cPrereqs); … … 683 683 void kldrDyldModUnloadPrerequisites(PKLDRDYLDMOD pMod) 684 684 { 685 uint32_tcToUnload;685 KU32 cToUnload; 686 686 687 687 /* sanity */ … … 738 738 KLDRDYLDSEARCH enmSearch, unsigned fFlags) 739 739 { 740 int32_tcPrereqs;741 uint32_ti;742 int 740 KI32 cPrereqs; 741 KU32 i; 742 int rc = 0; 743 743 744 744 /* sanity */ … … 932 932 * pvUser points to the KLDRDYLDMOD. 933 933 */ 934 static int kldrDyldModFixupGetImportCallback(PKLDRMOD pMod, uint32_t iImport, uint32_tiSymbol,935 const char *pchSymbol, size_tcchSymbol, const char *pszVersion,936 PKLDRADDR puValue, uint32_t*pfKind, void *pvUser)934 static int kldrDyldModFixupGetImportCallback(PKLDRMOD pMod, KU32 iImport, KU32 iSymbol, 935 const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion, 936 PKLDRADDR puValue, KU32 *pfKind, void *pvUser) 937 937 { 938 938 static int s_cRecursiveCalls = 0; … … 979 979 while (pBindMod) 980 980 { 981 uint32_tfKind;981 KU32 fKind; 982 982 KLDRADDR uValue; 983 983 rc = kLdrModQuerySymbol(pBindMod->pMod, NULL, KLDRMOD_BASEADDRESS_MAP, … … 1058 1058 1059 1059 pMod->enmState = KLDRSTATE_INITIALIZING; 1060 rc = kLdrModCallInit(pMod->pMod, ( uintptr_t)pMod->hMod);1060 rc = kLdrModCallInit(pMod->pMod, (KUPTR)pMod->hMod); 1061 1061 if (!rc) 1062 1062 { … … 1090 1090 1091 1091 pMod->enmState = KLDRSTATE_TERMINATING; 1092 kLdrModCallTerm(pMod->pMod, ( uintptr_t)pMod->hMod);1092 kLdrModCallTerm(pMod->pMod, (KUPTR)pMod->hMod); 1093 1093 pMod->enmState = KLDRSTATE_PENDING_GC; 1094 1094 /* unlinking on destruction. */ … … 1106 1106 KLDRDYLDMOD_ASSERT(pMod->enmState == KLDRSTATE_GOOD); 1107 1107 1108 return kLdrModCallThread(pMod->pMod, ( uintptr_t)pMod->hMod, 1 /* attach */);1108 return kLdrModCallThread(pMod->pMod, (KUPTR)pMod->hMod, 1 /* attach */); 1109 1109 } 1110 1110 … … 1120 1120 KLDRDYLDMOD_ASSERT(pMod->enmState == KLDRSTATE_GOOD); 1121 1121 1122 kLdrModCallThread(pMod->pMod, ( uintptr_t)pMod->hMod, 0 /* detach */);1122 kLdrModCallThread(pMod->pMod, (KUPTR)pMod->hMod, 0 /* detach */); 1123 1123 } 1124 1124 … … 1132 1132 * @param pcbStack Where to store the size of the stack. 1133 1133 */ 1134 int kldrDyldModGetMainStack(PKLDRDYLDMOD pMod, void **ppvStack, size_t*pcbStack)1134 int kldrDyldModGetMainStack(PKLDRDYLDMOD pMod, void **ppvStack, KSIZE *pcbStack) 1135 1135 { 1136 1136 int rc = 0; … … 1148 1148 { 1149 1149 /* check if there is a stack size override/default. */ 1150 size_tcbDefOverride;1150 KSIZE cbDefOverride; 1151 1151 if (kldrHlpGetEnvUZ("KLDR_MAIN_STACK_SIZE", &cbDefOverride)) 1152 1152 cbDefOverride = 0; … … 1157 1157 || StackInfo.cbStack < cbDefOverride) 1158 1158 { 1159 size_t cbStack = (size_t)KLDR_MAX(StackInfo.cbStack, cbDefOverride);1159 KSIZE cbStack = (KSIZE)KLDR_MAX(StackInfo.cbStack, cbDefOverride); 1160 1160 1161 1161 g_pvkLdrDyldMainStack = kldrDyldOSAllocStack(cbStack); … … 1174 1174 1175 1175 g_fkLdrDyldMainStackAllocated = 0; 1176 g_pvkLdrDyldMainStack = (void *)( uintptr_t)StackInfo.Address;1177 KLDRDYLDMOD_ASSERT(( uintptr_t)g_pvkLdrDyldMainStack == StackInfo.Address);1178 1179 g_cbkLdrDyldMainStack = ( size_t)StackInfo.cbStack;1176 g_pvkLdrDyldMainStack = (void *)(KUPTR)StackInfo.Address; 1177 KLDRDYLDMOD_ASSERT((KUPTR)g_pvkLdrDyldMainStack == StackInfo.Address); 1178 1179 g_cbkLdrDyldMainStack = (KSIZE)StackInfo.cbStack; 1180 1180 KLDRDYLDMOD_ASSERT(StackInfo.cbStack == g_cbkLdrDyldMainStack); 1181 1181 } … … 1209 1209 KLDRADDR MainEPAddress; 1210 1210 void *pvStack; 1211 size_tcbStack;1211 KSIZE cbStack; 1212 1212 KLDRDYLDMOD_ASSERT(pMod->fExecutable); 1213 1213 … … 1218 1218 if (rc) 1219 1219 return rc; 1220 return kldrDyldOSStartExe(( uintptr_t)MainEPAddress, pvStack, cbStack);1220 return kldrDyldOSStartExe((KUPTR)MainEPAddress, pvStack, cbStack); 1221 1221 } 1222 1222 … … 1230 1230 * @param cchName The size of the name buffer. 1231 1231 */ 1232 int kldrDyldModGetName(PKLDRDYLDMOD pMod, char *pszName, size_tcchName)1233 { 1234 size_tcch = KLDR_MIN(cchName, pMod->pMod->cchName + 1);1232 int kldrDyldModGetName(PKLDRDYLDMOD pMod, char *pszName, KSIZE cchName) 1233 { 1234 KSIZE cch = KLDR_MIN(cchName, pMod->pMod->cchName + 1); 1235 1235 if (cch) 1236 1236 { … … 1250 1250 * @param cchFilename The size of the filename buffer. 1251 1251 */ 1252 int kldrDyldModGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, size_tcchFilename)1253 { 1254 size_tcch = KLDR_MIN(cchFilename, pMod->pMod->cchFilename + 1);1252 int kldrDyldModGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, KSIZE cchFilename) 1253 { 1254 KSIZE cch = KLDR_MIN(cchFilename, pMod->pMod->cchFilename + 1); 1255 1255 if (cch) 1256 1256 { … … 1272 1272 * @param pfKind Where to store the symbol kind. optional. 1273 1273 */ 1274 int kldrDyldModQuerySymbol(PKLDRDYLDMOD pMod, uint32_tuSymbolOrdinal, const char *pszSymbolName,1275 uintptr_t *puValue, uint32_t*pfKind)1274 int kldrDyldModQuerySymbol(PKLDRDYLDMOD pMod, KU32 uSymbolOrdinal, const char *pszSymbolName, 1275 KUPTR *puValue, KU32 *pfKind) 1276 1276 { 1277 1277 int rc; 1278 1278 KLDRADDR uValue = 0; 1279 uint32_tfKind = 0;1279 KU32 fKind = 0; 1280 1280 1281 1281 rc = kLdrModQuerySymbol(pMod->pMod, NULL, KLDRMOD_BASEADDRESS_MAP, … … 1287 1287 if (puValue) 1288 1288 { 1289 *puValue = ( uintptr_t)uValue;1289 *puValue = (KUPTR)uValue; 1290 1290 KLDRDYLDMOD_ASSERT(*puValue == uValue); 1291 1291 } -
trunk/kStuff/kLdr/kLdrDyldOS.c
r3537 r3567 51 51 * If 0, a OS specific default stack size will be employed. 52 52 */ 53 void *kldrDyldOSAllocStack( size_tcb)53 void *kldrDyldOSAllocStack(KSIZE cb) 54 54 { 55 55 #ifdef __OS2__ … … 87 87 * @param cbStack The size of the stack object. 88 88 */ 89 int kldrDyldOSStartExe( uintptr_t uMainEPAddress, void *pvStack, size_tcbStack)89 int kldrDyldOSStartExe(KUPTR uMainEPAddress, void *pvStack, KSIZE cbStack) 90 90 { 91 91 #if defined(__OS2__) … … 116 116 117 117 118 void kldrDyldDoLoadExeStackSwitch(PKLDRDYLDMOD pExe, void *pvStack, size_tcbStack)118 void kldrDyldDoLoadExeStackSwitch(PKLDRDYLDMOD pExe, void *pvStack, KSIZE cbStack) 119 119 { 120 120 /*kldrHlpAssert(!"not implemented");*/ -
trunk/kStuff/kLdr/kLdrHlp-gcc.c
r3537 r3567 34 34 35 35 36 void *memchr(const void *pv, int ch, size_tcb)36 void *memchr(const void *pv, int ch, KSIZE cb) 37 37 { 38 38 const char *pb = pv; … … 47 47 48 48 49 int memcmp(const void *pv1, const void *pv2, size_tcb)49 int memcmp(const void *pv1, const void *pv2, KSIZE cb) 50 50 { 51 51 /* … … 53 53 */ 54 54 if ( cb > 16 55 && !(( uintptr_t)pv1 & (sizeof(void *) - 1))56 && !(( uintptr_t)pv2 & (sizeof(void *) - 1)) )57 { 58 const uintptr_t*pu1 = pv1;59 const uintptr_t*pu2 = pv2;60 while (cb >= sizeof( uintptr_t))61 { 62 const uintptr_tu1 = *pu1++;63 const uintptr_tu2 = *pu2++;55 && !((KUPTR)pv1 & (sizeof(void *) - 1)) 56 && !((KUPTR)pv2 & (sizeof(void *) - 1)) ) 57 { 58 const KUPTR *pu1 = pv1; 59 const KUPTR *pu2 = pv2; 60 while (cb >= sizeof(KUPTR)) 61 { 62 const KUPTR u1 = *pu1++; 63 const KUPTR u2 = *pu2++; 64 64 if (u1 != u2) 65 65 return u1 > u2 ? 1 : -1; 66 cb -= sizeof( uintptr_t);66 cb -= sizeof(KUPTR); 67 67 } 68 68 if (!cb) … … 91 91 92 92 93 void *memcpy(void *pv1, const void *pv2, size_tcb)93 void *memcpy(void *pv1, const void *pv2, KSIZE cb) 94 94 { 95 95 void *pv1Start = pv1; … … 99 99 */ 100 100 if ( cb > 16 101 && !(( uintptr_t)pv1 & (sizeof(void *) - 1))102 && !(( uintptr_t)pv2 & (sizeof(void *) - 1)) )103 { 104 uintptr_t*pu1 = pv1;105 const uintptr_t*pu2 = pv2;106 while (cb >= sizeof( uintptr_t))107 { 108 cb -= sizeof( uintptr_t);101 && !((KUPTR)pv1 & (sizeof(void *) - 1)) 102 && !((KUPTR)pv2 & (sizeof(void *) - 1)) ) 103 { 104 KUPTR *pu1 = pv1; 105 const KUPTR *pu2 = pv2; 106 while (cb >= sizeof(KUPTR)) 107 { 108 cb -= sizeof(KUPTR); 109 109 *pu1++ = *pu2++; 110 110 } … … 129 129 } 130 130 131 void *memset(void *pv, int ch, size_tcb)131 void *memset(void *pv, int ch, KSIZE cb) 132 132 { 133 133 void *pvStart = pv; … … 137 137 */ 138 138 if ( cb > 16 139 && !(( uintptr_t)pv & (sizeof(void *) - 1)))140 { 141 uintptr_t*pu = pv;142 uintptr_tu = ch | (ch << 8);139 && !((KUPTR)pv & (sizeof(void *) - 1))) 140 { 141 KUPTR *pu = pv; 142 KUPTR u = ch | (ch << 8); 143 143 u |= u << 16; 144 144 #if defined(__AMD64__) … … 146 146 #endif 147 147 148 while (cb >= sizeof( uintptr_t))149 { 150 cb -= sizeof( uintptr_t);148 while (cb >= sizeof(KUPTR)) 149 { 150 cb -= sizeof(KUPTR); 151 151 *pu++ = u; 152 152 } … … 180 180 181 181 182 int strncmp(const char *psz1, const char *psz2, size_tcch)182 int strncmp(const char *psz1, const char *psz2, KSIZE cch) 183 183 { 184 184 while (cch-- > 0) … … 207 207 } 208 208 209 size_tstrlen(const char *psz)209 KSIZE strlen(const char *psz) 210 210 { 211 211 const char *pszStart = psz; -
trunk/kStuff/kLdr/kLdrHlp.c
r3537 r3567 54 54 * @param cchVal The size of the buffer pointed to by pszVal. 55 55 */ 56 int kldrHlpGetEnv(const char *pszVar, char *pszVal, size_tcchVal)56 int kldrHlpGetEnv(const char *pszVar, char *pszVal, KSIZE cchVal) 57 57 { 58 58 #ifdef __OS2__ … … 64 64 if (!rc) 65 65 { 66 size_tcch = kLdrHlpStrLen((const char *)pszValue);66 KSIZE cch = kLdrHlpStrLen((const char *)pszValue); 67 67 if (cchVal > cch) 68 68 kLdrHlpMemCopy(pszVal, pszValue, cch + 1); … … 96 96 97 97 /** 98 * Gets an environment variable and converts it to a size_t.98 * Gets an environment variable and converts it to a KSIZE. 99 99 * 100 100 * @returns 0 and *pcb on success. … … 103 103 * @param pcb Where to put the value. 104 104 */ 105 int kldrHlpGetEnvUZ(const char *pszVar, size_t*pcb)106 { 107 size_tcb;105 int kldrHlpGetEnvUZ(const char *pszVar, KSIZE *pcb) 106 { 107 KSIZE cb; 108 108 unsigned uBase; 109 109 char szVal[64]; 110 size_tcchVal = sizeof(szVal);110 KSIZE cchVal = sizeof(szVal); 111 111 const char *psz; 112 112 int rc; -
trunk/kStuff/kLdr/kLdrHlp.h
r3537 r3567 105 105 # endif 106 106 # ifdef kLdrHlpStrChr_needed 107 int kLdrHlpStrNComp(const char *psz1, const char *psz2, size_tcch);107 int kLdrHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch); 108 108 # endif 109 109 # ifdef kLdrHlpMemChr_needed 110 void *kLdrHlpMemChr(const void *pv, int ch, size_tcb);110 void *kLdrHlpMemChr(const void *pv, int ch, KSIZE cb); 111 111 # endif 112 112 # ifdef kLdrHlpMemMove_needed 113 void *kLdrHlpMemMove(void *pv1, const void *pv2, size_tcb);113 void *kLdrHlpMemMove(void *pv1, const void *pv2, KSIZE cb); 114 114 # endif 115 115 … … 169 169 #endif 170 170 171 size_t kLdrHlpStrNLen(const char *psz, size_tcchMax);172 int kLdrHlpMemIComp(const void *pv1, const void *pv2, size_tcb);171 KSIZE kLdrHlpStrNLen(const char *psz, KSIZE cchMax); 172 int kLdrHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb); 173 173 int kLdrHlpStrIComp(const char *pv1, const char *pv2); 174 174 … … 178 178 void kldrHlpSemRelease(void); 179 179 180 int kldrHlpPageAlloc(void **ppv, size_tcb, KLDRPROT enmProt, unsigned fFixed);181 int kldrHlpPageProtect(void *pv, size_tcb, KLDRPROT enmProt);182 int kldrHlpPageFree(void *pv, size_tcb);180 int kldrHlpPageAlloc(void **ppv, KSIZE cb, KLDRPROT enmProt, unsigned fFixed); 181 int kldrHlpPageProtect(void *pv, KSIZE cb, KLDRPROT enmProt); 182 int kldrHlpPageFree(void *pv, KSIZE cb); 183 183 184 184 int kldrHlpHeapInit(void); 185 185 void kldrHlpHeapTerm(void); 186 void kldrHlpHeapDonate(void *pv, size_tcb);187 void * kldrHlpAlloc( size_tcb);188 void * kldrHlpAllocZ( size_tcb);186 void kldrHlpHeapDonate(void *pv, KSIZE cb); 187 void * kldrHlpAlloc(KSIZE cb); 188 void * kldrHlpAllocZ(KSIZE cb); 189 189 void kldrHlpFree(void *pv); 190 190 191 int kldrHlpGetEnv(const char *pszVar, char *pszVal, size_tcchVal);192 int kldrHlpGetEnvUZ(const char *pszVar, size_t*pcb);191 int kldrHlpGetEnv(const char *pszVar, char *pszVal, KSIZE cchVal); 192 int kldrHlpGetEnvUZ(const char *pszVar, KSIZE *pcb); 193 193 char *kldrHlpGetFilename(const char *pszFilename); 194 194 char *kldrHlpGetSuff(const char *pszFilename); … … 197 197 void kldrHlpExit(int rc); 198 198 void kldrHlpSleep(unsigned cMillies); 199 char *kldrHlpInt2Ascii(char *psz, size_tcch, long lVal, unsigned iBase);199 char *kldrHlpInt2Ascii(char *psz, KSIZE cch, long lVal, unsigned iBase); 200 200 void kldrHlpAssertMsg(const char *pszExpr, const char *pszFile, unsigned iLine, const char *pszFunction); 201 201 … … 233 233 if ((cb)) \ 234 234 { \ 235 uint8_t__b; \236 uint8_t volatile * __pb = (uint8_tvolatile *)(buf); \237 size_t __cbPage1 = 0x1000 - ((uintptr_t)(__pb) & 0xfff); /* ASSUMES page size! */ \235 KU8 __b; \ 236 KU8 volatile * __pb = (KU8 volatile *)(buf); \ 237 KSIZE __cbPage1 = 0x1000 - ((KUPTR)(__pb) & 0xfff); /* ASSUMES page size! */ \ 238 238 __b = *__pb; *__pb = 0xff; *__pb = __b; \ 239 239 if ((cb) > __cbPage1) \ 240 240 { \ 241 size_t__cb = (cb) - __cbPage1; \241 KSIZE __cb = (cb) - __cbPage1; \ 242 242 __pb -= __cbPage1; \ 243 243 for (;;) \ -
trunk/kStuff/kLdr/kLdrHlpHeap.c
r3537 r3567 58 58 struct KLDRHEAPBLOCK *pPrev; 59 59 /** The size of this block including this header. */ 60 size_tcb;60 KSIZE cb; 61 61 /** The flags. */ 62 size_tfFlags;62 KSIZE fFlags; 63 63 } KLDRHEAPBLOCK, *PKLDRHEAPBLOCK; 64 64 65 65 /** Indicates whether the block is free (set) or allocated (clear). */ 66 #define KLDRHEAPBLOCK_FLAG_FREE (( size_t)1)66 #define KLDRHEAPBLOCK_FLAG_FREE ((KSIZE)1) 67 67 /** Valid flag mask. */ 68 #define KLDRHEAPBLOCK_FLAG_MASK (( size_t)1)68 #define KLDRHEAPBLOCK_FLAG_MASK ((KSIZE)1) 69 69 70 70 /** Checks if the block is freed. */ … … 75 75 * Assumes pB1 < pB2. */ 76 76 #define KLDRHEAPBLOCK_IS_ADJACENT(pB1, pB2) \ 77 ( (( uintptr_t)(pB1) + (pB1)->cb) == (uintptr_t)(pB2) )77 ( ((KUPTR)(pB1) + (pB1)->cb) == (KUPTR)(pB2) ) 78 78 79 79 /** The block alignment. */ … … 93 93 KLDRHEAP_ASSERT(!((pBlock)->fFlags & ~KLDRHEAPBLOCK_FLAG_MASK)); \ 94 94 KLDRHEAP_ASSERT(!((pBlock)->cb & (KLDRHEAPBLOCK_ALIGNMENT - 1))); \ 95 KLDRHEAP_ASSERT(( uintptr_t)(pBlock)->pPrev < (uintptr_t)(pBlock)); \96 KLDRHEAP_ASSERT(( uintptr_t)(pBlock)->pNext > (uintptr_t)(pBlock) || !(pBlock)->pNext); \95 KLDRHEAP_ASSERT((KUPTR)(pBlock)->pPrev < (KUPTR)(pBlock)); \ 96 KLDRHEAP_ASSERT((KUPTR)(pBlock)->pNext > (KUPTR)(pBlock) || !(pBlock)->pNext); \ 97 97 } while (0) 98 98 … … 100 100 do { \ 101 101 KLDRHEAP_ASSERT_BLOCK(pHeap, &(pFree)->Core); \ 102 KLDRHEAP_ASSERT(( uintptr_t)(pFree)->pPrev < (uintptr_t)(pFree)); \103 KLDRHEAP_ASSERT(( uintptr_t)(pFree)->pNext > (uintptr_t)(pFree) || !(pFree)->pNext); \102 KLDRHEAP_ASSERT((KUPTR)(pFree)->pPrev < (KUPTR)(pFree)); \ 103 KLDRHEAP_ASSERT((KUPTR)(pFree)->pNext > (KUPTR)(pFree) || !(pFree)->pNext); \ 104 104 } while (0) 105 105 … … 133 133 void *pvBase; 134 134 /** The length of the segment (in bytes). */ 135 size_tcb;135 KSIZE cb; 136 136 } KLDRHEAPSEG, *PKLDRHEAPSEG; 137 137 … … 144 144 struct KLDRHEAPSEGS *pNext; 145 145 /** The number of segments used. */ 146 uint32_tcSegs;146 KU32 cSegs; 147 147 /** Array of chunks. */ 148 148 KLDRHEAPSEG aSegs[64]; … … 181 181 static int kLdrHeapInit(PKLDRHEAPANCHOR pHeap); 182 182 static void kLdrHeapDelete(PKLDRHEAPANCHOR pHeap); 183 static void * kLdrHeapAlloc(PKLDRHEAPANCHOR pHeap, size_tcb);183 static void * kLdrHeapAlloc(PKLDRHEAPANCHOR pHeap, KSIZE cb); 184 184 static void kLdrHeapFree(PKLDRHEAPANCHOR pHeap, void *pv); 185 static void kLdrHeapDonate(PKLDRHEAPANCHOR pHeap, void *pv, size_tcb);186 static int kLdrHeapSegAlloc(PKLDRHEAPSEG pSeg, size_tcb);185 static void kLdrHeapDonate(PKLDRHEAPANCHOR pHeap, void *pv, KSIZE cb); 186 static int kLdrHeapSegAlloc(PKLDRHEAPSEG pSeg, KSIZE cb); 187 187 static void kLdrHeapSegFree(PKLDRHEAPSEG pSeg); 188 188 … … 214 214 * @param cb The requested heap block size. 215 215 */ 216 void *kldrHlpAlloc( size_tcb)216 void *kldrHlpAlloc(KSIZE cb) 217 217 { 218 218 return kLdrHeapAlloc(&g_Heap, cb); … … 226 226 * @param cb The requested heap block size. 227 227 */ 228 void *kldrHlpAllocZ( size_tcb)228 void *kldrHlpAllocZ(KSIZE cb) 229 229 { 230 230 void *pv = kLdrHeapAlloc(&g_Heap, cb); … … 252 252 * @param cb The amount of memory. 253 253 */ 254 void kldrHlpHeapDonate(void *pv, size_tcb)254 void kldrHlpHeapDonate(void *pv, KSIZE cb) 255 255 { 256 256 kLdrHeapDonate(&g_Heap, pv, cb); … … 293 293 { 294 294 /* find the tail. */ 295 uint32_tiSeg;295 KU32 iSeg; 296 296 PKLDRHEAPSEGS pSegs = pHeap->SegsHead.pNext; 297 297 if (!pSegs) … … 322 322 * Internal heap block allocator. 323 323 */ 324 static void * kldrHeapAllocSub(PKLDRHEAPANCHOR pHeap, size_tcb)324 static void * kldrHeapAllocSub(PKLDRHEAPANCHOR pHeap, KSIZE cb) 325 325 { 326 326 /* 327 327 * Find a fitting free block. 328 328 */ 329 const size_tcbReq = KLDR_ALIGN_Z(cb + sizeof(KLDRHEAPBLOCK), KLDRHEAPBLOCK_ALIGNMENT);329 const KSIZE cbReq = KLDR_ALIGN_Z(cb + sizeof(KLDRHEAPBLOCK), KLDRHEAPBLOCK_ALIGNMENT); 330 330 PKLDRHEAPFREE pCur = pHeap->pFreeHead; 331 331 while (pCur) … … 376 376 pCur->Core.cb -= cbReq; 377 377 378 pNew = (PKLDRHEAPBLOCK)(( uintptr_t)pCur + pCur->Core.cb);378 pNew = (PKLDRHEAPBLOCK)((KUPTR)pCur + pCur->Core.cb); 379 379 pNew->fFlags = 0; 380 380 pNew->cb = cbReq; … … 415 415 * @param cb The requested heap block size. 416 416 */ 417 static void * kLdrHeapAlloc(PKLDRHEAPANCHOR pHeap, size_tcb)417 static void * kLdrHeapAlloc(PKLDRHEAPANCHOR pHeap, KSIZE cb) 418 418 { 419 419 void *pv; … … 563 563 * @param cb Size of the donated memory. 564 564 */ 565 static void kLdrHeapDonate(PKLDRHEAPANCHOR pHeap, void *pv, size_tcb)565 static void kLdrHeapDonate(PKLDRHEAPANCHOR pHeap, void *pv, KSIZE cb) 566 566 { 567 567 PKLDRHEAPBLOCK pBlock; … … 576 576 * Align the donation on a heap block boundrary. 577 577 */ 578 if (( uintptr_t)pv & (KLDRHEAPBLOCK_ALIGNMENT - 1))579 { 580 cb -= ( uintptr_t)pv & 31;578 if ((KUPTR)pv & (KLDRHEAPBLOCK_ALIGNMENT - 1)) 579 { 580 cb -= (KUPTR)pv & 31; 581 581 pv = KLDR_ALIGN_P(pv, KLDRHEAPBLOCK_ALIGNMENT); 582 582 } 583 cb &= ~( size_t)(KLDRHEAPBLOCK_ALIGNMENT - 1);583 cb &= ~(KSIZE)(KLDRHEAPBLOCK_ALIGNMENT - 1); 584 584 585 585 /* … … 593 593 594 594 /* insert */ 595 if (( uintptr_t)pBlock < (uintptr_t)pHeap->pHead)595 if ((KUPTR)pBlock < (KUPTR)pHeap->pHead) 596 596 { 597 597 /* head */ … … 600 600 pHeap->pHead = pBlock; 601 601 } 602 else if (( uintptr_t)pBlock > (uintptr_t)pHeap->pTail)602 else if ((KUPTR)pBlock > (KUPTR)pHeap->pTail) 603 603 { 604 604 if (pHeap->pTail) … … 624 624 { 625 625 KLDRHEAP_ASSERT_BLOCK(pHeap, pCur); 626 if (( uintptr_t)pCur > (uintptr_t)pBlock)626 if ((KUPTR)pCur > (KUPTR)pBlock) 627 627 break; 628 628 pPrev = pCur; … … 650 650 * @param cbMin The minimum segment size. 651 651 */ 652 static int kLdrHeapSegAlloc(PKLDRHEAPSEG pSeg, size_tcbMin)652 static int kLdrHeapSegAlloc(PKLDRHEAPSEG pSeg, KSIZE cbMin) 653 653 { 654 654 #ifdef __OS2__ 655 655 APIRET rc; 656 656 657 pSeg->cb = (cbMin + 0xffff) & ~( size_t)0xffff;657 pSeg->cb = (cbMin + 0xffff) & ~(KSIZE)0xffff; 658 658 pSeg->pvBase = NULL; 659 659 rc = DosAllocMem(&pSeg->pvBase, pSeg->cb, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_ANY); … … 668 668 669 669 #elif defined(__WIN__) 670 pSeg->cb = (cbMin + 0xffff) & ~( size_t)0xffff;670 pSeg->cb = (cbMin + 0xffff) & ~(KSIZE)0xffff; 671 671 pSeg->pvBase = VirtualAlloc(NULL, pSeg->cb, MEM_COMMIT, PAGE_READWRITE); 672 672 if (!pSeg->pvBase) -
trunk/kStuff/kLdr/kLdrHlpMem.c
r3537 r3567 52 52 static void *g_pvStub = NULL; 53 53 /** The size of the stub object - 0 if no stub. */ 54 static size_tg_cbStub = 0;54 static KSIZE g_cbStub = 0; 55 55 56 56 #elif defined(__WIN__) … … 107 107 * @param enmProt The new protection. Copy-on-write is invalid. 108 108 */ 109 int kldrHlpPageAlloc(void **ppv, size_tcb, KLDRPROT enmProt, unsigned fFixed)109 int kldrHlpPageAlloc(void **ppv, KSIZE cb, KLDRPROT enmProt, unsigned fFixed) 110 110 { 111 111 #ifdef __OS2__ … … 162 162 * @param enmProt The new protection. Copy-on-write is invalid. 163 163 */ 164 int kldrHlpPageProtect(void *pv, size_tcb, KLDRPROT enmProt)164 int kldrHlpPageProtect(void *pv, KSIZE cb, KLDRPROT enmProt) 165 165 { 166 166 #ifdef __OS2__ … … 184 184 if (rc) 185 185 return rc; 186 pv = (void *)(( uintptr_t)pv + 0x1000);186 pv = (void *)((KUPTR)pv + 0x1000); 187 187 cb -= 0x1000; 188 188 } … … 215 215 * @param cb The byte count requested from kldrHlpPageAlloc(). 216 216 */ 217 int kldrHlpPageFree(void *pv, size_tcb)217 int kldrHlpPageFree(void *pv, KSIZE cb) 218 218 { 219 219 #ifdef __OS2__ … … 223 223 * Deal with any portion overlapping with the stub. 224 224 */ 225 uintptr_t offStub = (uintptr_t)pv - (uintptr_t)g_pvStub;225 KUPTR offStub = (KUPTR)pv - (KUPTR)g_pvStub; 226 226 if (offStub < g_cbStub) 227 227 { 228 228 /* decommit the pages in the stub. */ 229 size_tcbStub = KLDR_MIN(g_cbStub - offStub, cb);229 KSIZE cbStub = KLDR_MIN(g_cbStub - offStub, cb); 230 230 rc = DosSetMem(pv, cbStub, PAG_DECOMMIT); 231 231 if (rc) … … 236 236 if (!DosSetMem(pv, 0x1000, PAG_DECOMMIT)) 237 237 rc = 0; 238 pv = (void *)(( uintptr_t)pv + 0x1000);238 pv = (void *)((KUPTR)pv + 0x1000); 239 239 cbStub -= 0x1000; 240 240 cb -= 0x1000; … … 251 251 if (!cb) 252 252 return 0; 253 pv = (void *)(( uintptr_t)pv + cbStub);253 pv = (void *)((KUPTR)pv + cbStub); 254 254 } 255 255 } -
trunk/kStuff/kLdr/kLdrHlpStr.c
r3537 r3567 42 42 * @param iBase The base to format it. (2,8,10 or 16) 43 43 */ 44 char *kldrHlpInt2Ascii(char *psz, size_tcch, long lVal, unsigned iBase)44 char *kldrHlpInt2Ascii(char *psz, KSIZE cch, long lVal, unsigned iBase) 45 45 { 46 46 static const char s_szDigits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; … … 81 81 82 82 83 size_t kLdrHlpStrNLen(const char *psz, size_tcchMax)83 KSIZE kLdrHlpStrNLen(const char *psz, KSIZE cchMax) 84 84 { 85 85 const char * const pszStart = psz; … … 90 90 91 91 92 int kLdrHlpMemIComp(const void *pv1, const void *pv2, size_tcb)92 int kLdrHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb) 93 93 { 94 const uint8_t *pb1 = (const uint8_t*)pv1;95 const uint8_t *pb2 = (const uint8_t*)pv2;94 const KU8 *pb1 = (const KU8 *)pv1; 95 const KU8 *pb2 = (const KU8 *)pv2; 96 96 while (cb-- > 0) 97 97 { 98 98 if (*pb1 != *pb2) 99 99 { 100 const uint8_tu1 = *pb1 >= 'a' && *pb1 <= 'z' ? *pb1 - 'a' : *pb1;101 const uint8_tu2 = *pb2 >= 'a' && *pb2 <= 'z' ? *pb2 - 'a' : *pb2;100 const KU8 u1 = *pb1 >= 'a' && *pb1 <= 'z' ? *pb1 - 'a' : *pb1; 101 const KU8 u2 = *pb2 >= 'a' && *pb2 <= 'z' ? *pb2 - 'a' : *pb2; 102 102 if (u1 != u2) 103 103 return (int)*pb1 - (int)*pb2; … … 112 112 int kLdrHlpStrIComp(const char *pv1, const char *pv2) 113 113 { 114 const uint8_t *pb1 = (const uint8_t*)pv1;115 const uint8_t *pb2 = (const uint8_t*)pv2;114 const KU8 *pb1 = (const KU8 *)pv1; 115 const KU8 *pb2 = (const KU8 *)pv2; 116 116 for (;;) 117 117 { 118 118 if (*pb1 != *pb2) 119 119 { 120 const uint8_tu1 = *pb1 >= 'a' && *pb1 <= 'z' ? *pb1 - 'a' : *pb1;121 const uint8_tu2 = *pb2 >= 'a' && *pb2 <= 'z' ? *pb2 - 'a' : *pb2;120 const KU8 u1 = *pb1 >= 'a' && *pb1 <= 'z' ? *pb1 - 'a' : *pb1; 121 const KU8 u2 = *pb2 >= 'a' && *pb2 <= 'z' ? *pb2 - 'a' : *pb2; 122 122 if (u1 != u2) 123 123 return (int)*pb1 - (int)*pb2; … … 147 147 148 148 #ifdef kLdrHlpMemChr_needed 149 void *kLdrHlpMemChr(const void *pv, int ch, size_tcb)149 void *kLdrHlpMemChr(const void *pv, int ch, KSIZE cb) 150 150 { 151 const uint8_t *pb = (const uint8_t*)pv;152 const uint8_t b = (uint8_t)ch;151 const KU8 *pb = (const KU8 *)pv; 152 const KU8 b = (KU8)ch; 153 153 while (cb-- > 0) 154 154 { … … 163 163 164 164 #ifdef kLdrHlpMemMove_needed 165 void *kLdrHlpMemMove(void *pv1, const void *pv2, size_tcb)165 void *kLdrHlpMemMove(void *pv1, const void *pv2, KSIZE cb) 166 166 { 167 uint8_t *pbDst = (uint8_t*)pv1;168 const uint8_t *pbSrc = (const uint8_t*)pv2;167 KU8 *pbDst = (KU8 *)pv1; 168 const KU8 *pbSrc = (const KU8 *)pv2; 169 169 while (cb-- > 0) 170 170 { 171 const uint8_tb = *pbSrc++;171 const KU8 b = *pbSrc++; 172 172 *pbDst++ = b; 173 173 } … … 178 178 179 179 #ifdef kLdrHlpStrNComp_needed 180 int kLdrHlpStrNComp(const char *psz1, const char *psz2, size_tcch)180 int kLdrHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch) 181 181 { 182 182 while (cch-- > 0) … … 191 191 return 0; 192 192 } 193 #endif 193 #endif 194 194 -
trunk/kStuff/kLdr/kLdrInternal.h
r3537 r3567 50 50 * @{ */ 51 51 /** ELF signature ("\x7fELF"). */ 52 #define IMAGE_ELF_SIGNATURE KLDR_LE2H_U32(0x7f | ('E' << 8) | (( uint32_t)'L' << 16) | ((uint32_t)'F' << 24))52 #define IMAGE_ELF_SIGNATURE KLDR_LE2H_U32(0x7f | ('E' << 8) | ((KU32)'L' << 16) | ((KU32)'F' << 24)) 53 53 /** PE signature ("PE\0\0"). */ 54 54 #define IMAGE_NT_SIGNATURE KLDR_LE2H_U32('P' | ('E' << 8)) … … 62 62 #define IMAGE_DOS_SIGNATURE KLDR_LE2H_U16('M' | ('Z' << 8)) 63 63 /** The FAT signature (universal binaries). */ 64 #define IMAGE_FAT_SIGNATURE UINT32_C(0xcafebabe)64 #define IMAGE_FAT_SIGNATURE KU32_C(0xcafebabe) 65 65 /** The FAT signature (universal binaries), other endian. */ 66 #define IMAGE_FAT_SIGNATURE_OE UINT32_C(0xbebafeca)66 #define IMAGE_FAT_SIGNATURE_OE KU32_C(0xbebafeca) 67 67 /** The 32-bit Mach-O signature. */ 68 #define IMAGE_MACHO32_SIGNATURE UINT32_C(0xfeedface)68 #define IMAGE_MACHO32_SIGNATURE KU32_C(0xfeedface) 69 69 /** The 32-bit Mach-O signature, other endian. */ 70 #define IMAGE_MACHO32_SIGNATURE_OE UINT32_C(0xcefaedfe)70 #define IMAGE_MACHO32_SIGNATURE_OE KU32_C(0xcefaedfe) 71 71 /** The 64-bit Mach-O signature. */ 72 #define IMAGE_MACHO64_SIGNATURE UINT32_C(0xfeedfacf)72 #define IMAGE_MACHO64_SIGNATURE KU32_C(0xfeedfacf) 73 73 /** The 64-bit Mach-O signature, other endian. */ 74 #define IMAGE_MACHO64_SIGNATURE_OE UINT32_C(0xfefaedfe)74 #define IMAGE_MACHO64_SIGNATURE_OE KU32_C(0xfefaedfe) 75 75 /** @} */ 76 76 … … 245 245 { 246 246 /** Magic number. */ 247 uint32_tu32MagicHead;247 KU32 u32MagicHead; 248 248 /** The module state. */ 249 249 KLDRSTATE enmState; … … 253 253 HKLDRMOD hMod; 254 254 /** The total number of references. */ 255 uint32_tcRefs;255 KU32 cRefs; 256 256 /** The number of dependency references. */ 257 uint32_tcDepRefs;257 KU32 cDepRefs; 258 258 /** The number of dynamic load references. */ 259 uint32_tcDynRefs;259 KU32 cDynRefs; 260 260 /** Set if this is the executable module. 261 261 * When clear, the module is a shared object or relocatable object. */ 262 uint32_tfExecutable : 1;262 KU32 fExecutable : 1; 263 263 /** Global DLL (set) or specific DLL (clear). */ 264 uint32_tfGlobalOrSpecific : 1;264 KU32 fGlobalOrSpecific : 1; 265 265 /** Whether the module contains bindable symbols in the global unix namespace. */ 266 uint32_tfBindable : 1;266 KU32 fBindable : 1; 267 267 /** Set if linked into the global init list. */ 268 uint32_tfInitList : 1;268 KU32 fInitList : 1; 269 269 /** Already loaded or checked prerequisites. 270 270 * This flag is used when loading prerequisites, when set it means that 271 271 * this module is already seen and shouldn't be processed again. */ 272 uint32_tfAlreadySeen : 1;272 KU32 fAlreadySeen : 1; 273 273 /** Set if the module is currently mapped. 274 274 * This is used to avoid unnecessary calls to kLdrModUnmap during cleanup. */ 275 uint32_tfMapped : 1;275 KU32 fMapped : 1; 276 276 /** Set if TLS allocation has been done. (part of the mapping). */ 277 uint32_tfAllocatedTLS : 1;277 KU32 fAllocatedTLS : 1; 278 278 /** Reserved for future use. */ 279 uint32_tf25Reserved : 25;279 KU32 f25Reserved : 25; 280 280 /** The load list linkage. */ 281 281 struct … … 309 309 310 310 /** The number of prerequisite modules in the prereq array. */ 311 uint32_tcPrereqs;311 KU32 cPrereqs; 312 312 /** Pointer to an array of prerequisite module pointers. 313 313 * This array is only filled when in the states starting with … … 317 317 318 318 /** Magic number. */ 319 uint32_tu32MagicTail;319 KU32 u32MagicTail; 320 320 } KLDRDYLDMOD, *PKLDRDYLDMOD, **PPKLDRDYLDMOD; 321 321 … … 344 344 int kldrDyldFailure(int rc, const char *pszFormat, ...); 345 345 346 int kldrDyldOSStartExe( uintptr_t uMainEntrypoint, void *pvStack, size_tcbStack);347 void *kldrDyldOSAllocStack( size_tcb);346 int kldrDyldOSStartExe(KUPTR uMainEntrypoint, void *pvStack, KSIZE cbStack); 347 void *kldrDyldOSAllocStack(KSIZE cb); 348 348 349 349 int kldrDyldFindInit(void); … … 357 357 358 358 359 int kldrDyldModCreate(PKLDRRDR pRdr, uint32_tfFlags, PPKLDRDYLDMOD ppMod);359 int kldrDyldModCreate(PKLDRRDR pRdr, KU32 fFlags, PPKLDRDYLDMOD ppMod); 360 360 void kldrDyldModDestroy(PKLDRDYLDMOD pMod); 361 361 void kldrDyldModAddRef(PKLDRDYLDMOD pMod); … … 381 381 int kldrDyldModAttachThread(PKLDRDYLDMOD pMod); 382 382 void kldrDyldModDetachThread(PKLDRDYLDMOD pMod); 383 int kldrDyldModGetMainStack(PKLDRDYLDMOD pMod, void **ppvStack, size_t*pcbStack);383 int kldrDyldModGetMainStack(PKLDRDYLDMOD pMod, void **ppvStack, KSIZE *pcbStack); 384 384 int kldrDyldModStartExe(PKLDRDYLDMOD pMod); 385 385 386 int kldrDyldModGetName(PKLDRDYLDMOD pMod, char *pszName, size_tcchName);387 int kldrDyldModGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, size_tcchFilename);388 int kldrDyldModQuerySymbol(PKLDRDYLDMOD pMod, uint32_t uSymbolOrdinal, const char *pszSymbolName, uintptr_t *puValue, uint32_t*pfKind);386 int kldrDyldModGetName(PKLDRDYLDMOD pMod, char *pszName, KSIZE cchName); 387 int kldrDyldModGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, KSIZE cchFilename); 388 int kldrDyldModQuerySymbol(PKLDRDYLDMOD pMod, KU32 uSymbolOrdinal, const char *pszSymbolName, KUPTR *puValue, KU32 *pfKind); 389 389 390 390 … … 421 421 extern void *g_pvkLdrDyldMainStack; 422 422 /** The size of the main stack object. */ 423 extern size_tg_cbkLdrDyldMainStack;423 extern KSIZE g_cbkLdrDyldMainStack; 424 424 425 425 /** The global error buffer. */ -
trunk/kStuff/kLdr/kLdrMod.c
r3537 r3567 140 140 union 141 141 { 142 uint32_tu32;143 uint16_tu16;144 uint16_tau16[2];145 uint8_tau8[4];142 KU32 u32; 143 KU16 u16; 144 KU16 au16[2]; 145 KU8 au8[4]; 146 146 } u; 147 147 KLDRFOFF offHdr = 0; … … 258 258 * On output the symbol kind. (optional) 259 259 */ 260 int kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tiSymbol,261 const char *pchSymbol, size_tcchSymbol, const char *pszVersion,262 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind)260 int kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol, 261 const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion, 262 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind) 263 263 { 264 264 KLDRMOD_VALIDATE(pMod); … … 288 288 * @param pvUser The user argument to the callback function. 289 289 */ 290 int kLdrModEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tfFlags,290 int kLdrModEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 fFlags, 291 291 PFNKLDRMODENUMSYMS pfnCallback, void *pvUser) 292 292 { … … 310 310 * @param cchName The size of the name buffer. 311 311 */ 312 int kLdrModGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_tcchName)312 int kLdrModGetImport(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName) 313 313 { 314 314 KLDRMOD_VALIDATE(pMod); … … 325 325 * This can be used by some module interpreters to reduce memory consumption. 326 326 */ 327 int32_tkLdrModNumberOfImports(PKLDRMOD pMod, const void *pvBits)327 KI32 kLdrModNumberOfImports(PKLDRMOD pMod, const void *pvBits) 328 328 { 329 329 KLDRMOD_VALIDATE(pMod); … … 417 417 * @param pvUser The user argument for the callback. 418 418 */ 419 int kLdrModQueryResource(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tidType, const char *pszType,420 uint32_t idName, const char *pszName, uint32_t idLang, PKLDRADDR pAddrRsrc, size_t*pcbRsrc)419 int kLdrModQueryResource(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 idType, const char *pszType, 420 KU32 idName, const char *pszName, KU32 idLang, PKLDRADDR pAddrRsrc, KSIZE *pcbRsrc) 421 421 { 422 422 KLDRMOD_VALIDATE(pMod); … … 453 453 * @param pvUser The user argument for the callback. 454 454 */ 455 int kLdrModEnumResources(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tidType, const char *pszType,456 uint32_t idName, const char *pszName, uint32_tidLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser)455 int kLdrModEnumResources(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 idType, const char *pszType, 456 KU32 idName, const char *pszName, KU32 idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser) 457 457 { 458 458 KLDRMOD_VALIDATE(pMod); … … 615 615 * @param uHandle The module handle to use if any of the init functions requires the module handle. 616 616 */ 617 int kLdrModCallInit(PKLDRMOD pMod, uintptr_tuHandle)617 int kLdrModCallInit(PKLDRMOD pMod, KUPTR uHandle) 618 618 { 619 619 KLDRMOD_VALIDATE(pMod); … … 631 631 * @remark Termination function failure will be ignored by the module interpreter. 632 632 */ 633 int kLdrModCallTerm(PKLDRMOD pMod, uintptr_tuHandle)633 int kLdrModCallTerm(PKLDRMOD pMod, KUPTR uHandle) 634 634 { 635 635 KLDRMOD_VALIDATE(pMod); … … 650 650 * @remark Detach function failure will be ignored by the module interpreter. 651 651 */ 652 int kLdrModCallThread(PKLDRMOD pMod, uintptr_tuHandle, unsigned fAttachingOrDetaching)652 int kLdrModCallThread(PKLDRMOD pMod, KUPTR uHandle, unsigned fAttachingOrDetaching) 653 653 { 654 654 KLDRMOD_VALIDATE(pMod); -
trunk/kStuff/kLdr/kLdrModELF32.h
r3537 r3567 37 37 */ 38 38 39 typedef uint32_tElf32_Addr;40 typedef uint16_tElf32_Half;41 typedef uint32_tElf32_Off;42 typedef int32_tElf32_Sword;43 typedef uint32_tElf32_Word;44 typedef uint32_tElf32_Size;39 typedef KU32 Elf32_Addr; 40 typedef KU16 Elf32_Half; 41 typedef KU32 Elf32_Off; 42 typedef KI32 Elf32_Sword; 43 typedef KU32 Elf32_Word; 44 typedef KU32 Elf32_Size; 45 45 typedef Elf32_Off Elf32_Hashelt; 46 46 -
trunk/kStuff/kLdr/kLdrModELF64.h
r3537 r3567 37 37 */ 38 38 39 typedef uint64_tElf64_Addr;40 typedef uint32_tElf64_Half;41 typedef uint64_tElf64_Off;42 typedef int64_tElf64_Sword;43 typedef uint64_tElf64_Word;44 typedef uint64_tElf64_Size;45 typedef uint16_tElf64_Quarter;39 typedef KU64 Elf64_Addr; 40 typedef KU32 Elf64_Half; 41 typedef KU64 Elf64_Off; 42 typedef KI64 Elf64_Sword; 43 typedef KU64 Elf64_Word; 44 typedef KU64 Elf64_Size; 45 typedef KU16 Elf64_Quarter; 46 46 47 47 /* -
trunk/kStuff/kLdr/kLdrModELFCommon.h
r3537 r3567 44 44 45 45 typedef struct { 46 uint32_tn_namesz; /* Length of name. */47 uint32_tn_descsz; /* Length of descriptor. */48 uint32_tn_type; /* Type of this note. */46 KU32 n_namesz; /* Length of name. */ 47 KU32 n_descsz; /* Length of descriptor. */ 48 KU32 n_type; /* Type of this note. */ 49 49 } Elf_Note; 50 50 -
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; -
trunk/kStuff/kLdr/kLdrModLX.h
r3537 r3567 20 20 struct e32_exe 21 21 { 22 uint8_te32_magic[2];23 uint8_te32_border;24 uint8_te32_worder;25 uint32_te32_level;26 uint16_te32_cpu;27 uint16_te32_os;28 uint32_te32_ver;29 uint32_te32_mflags;30 uint32_te32_mpages;31 uint32_te32_startobj;32 uint32_te32_eip;33 uint32_te32_stackobj;34 uint32_te32_esp;35 uint32_te32_pagesize;36 uint32_te32_pageshift;22 KU8 e32_magic[2]; 23 KU8 e32_border; 24 KU8 e32_worder; 25 KU32 e32_level; 26 KU16 e32_cpu; 27 KU16 e32_os; 28 KU32 e32_ver; 29 KU32 e32_mflags; 30 KU32 e32_mpages; 31 KU32 e32_startobj; 32 KU32 e32_eip; 33 KU32 e32_stackobj; 34 KU32 e32_esp; 35 KU32 e32_pagesize; 36 KU32 e32_pageshift; 37 37 /** The size of the fixup section. 38 38 * The fixup section consists of the fixup page table, the fixup record table, 39 39 * the import module table, and the import procedure name table. 40 40 */ 41 uint32_te32_fixupsize;42 uint32_te32_fixupsum;41 KU32 e32_fixupsize; 42 KU32 e32_fixupsum; 43 43 /** The size of the resident loader section. 44 44 * This includes the object table, the object page map table, the resource table, the resident name table, 45 45 * the entry table, the module format directives table, and the page checksum table (?). */ 46 uint32_te32_ldrsize;46 KU32 e32_ldrsize; 47 47 /** The checksum of the loader section. 0 if not calculated. */ 48 uint32_te32_ldrsum;48 KU32 e32_ldrsum; 49 49 /** The offset of the object table relative to this structure. */ 50 uint32_te32_objtab;50 KU32 e32_objtab; 51 51 /** Count of objects. */ 52 uint32_te32_objcnt;52 KU32 e32_objcnt; 53 53 /** The offset of the object page map table relative to this structure. */ 54 uint32_te32_objmap;54 KU32 e32_objmap; 55 55 /** The offset of the object iterated pages (whatever this is used for) relative to the start of the file. */ 56 uint32_te32_itermap;56 KU32 e32_itermap; 57 57 /** The offset of the resource table relative to this structure. */ 58 uint32_te32_rsrctab;58 KU32 e32_rsrctab; 59 59 /** The number of entries in the resource table. */ 60 uint32_te32_rsrccnt;60 KU32 e32_rsrccnt; 61 61 /** The offset of the resident name table relative to this structure. */ 62 uint32_te32_restab;62 KU32 e32_restab; 63 63 /** The offset of the entry (export) table relative to this structure. */ 64 uint32_te32_enttab;64 KU32 e32_enttab; 65 65 /** The offset of the module format directives table relative to this structure. */ 66 uint32_te32_dirtab;66 KU32 e32_dirtab; 67 67 /** The number of entries in the module format directives table. */ 68 uint32_te32_dircnt;68 KU32 e32_dircnt; 69 69 /** The offset of the fixup page table relative to this structure. */ 70 uint32_te32_fpagetab;70 KU32 e32_fpagetab; 71 71 /** The offset of the fixup record table relative to this structure. */ 72 uint32_te32_frectab;72 KU32 e32_frectab; 73 73 /** The offset of the import module name table relative to this structure. */ 74 uint32_te32_impmod;74 KU32 e32_impmod; 75 75 /** The number of entries in the import module name table. */ 76 uint32_te32_impmodcnt;76 KU32 e32_impmodcnt; 77 77 /** The offset of the import procedure name table relative to this structure. */ 78 uint32_te32_impproc;78 KU32 e32_impproc; 79 79 /** The offset of the page checksum table relative to this structure. */ 80 uint32_te32_pagesum;80 KU32 e32_pagesum; 81 81 /** The offset of the data pages relative to the start of the file. */ 82 uint32_te32_datapage;82 KU32 e32_datapage; 83 83 /** The number of preload pages (ignored). */ 84 uint32_te32_preload;84 KU32 e32_preload; 85 85 /** The offset of the non-resident name table relative to the start of the file. */ 86 uint32_te32_nrestab;86 KU32 e32_nrestab; 87 87 /** The size of the non-resident name table. */ 88 uint32_te32_cbnrestab;89 uint32_te32_nressum;90 uint32_te32_autodata;91 uint32_te32_debuginfo;92 uint32_te32_debuglen;93 uint32_te32_instpreload;94 uint32_te32_instdemand;95 uint32_te32_heapsize;96 uint32_te32_stacksize;97 uint8_te32_res3[20];88 KU32 e32_cbnrestab; 89 KU32 e32_nressum; 90 KU32 e32_autodata; 91 KU32 e32_debuginfo; 92 KU32 e32_debuglen; 93 KU32 e32_instpreload; 94 KU32 e32_instdemand; 95 KU32 e32_heapsize; 96 KU32 e32_stacksize; 97 KU8 e32_res3[20]; 98 98 }; 99 99 … … 113 113 #define E32BEWO 1 114 114 /** e32_level */ 115 #define E32LEVEL UINT32_C(0)115 #define E32LEVEL KU32_C(0) 116 116 /** e32_cpu - 80286 */ 117 117 #define E32CPU286 1 … … 121 121 #define E32CPU486 3 122 122 /** e32_pagesize */ 123 #define OBJPAGELEN UINT32_C(0x1000)123 #define OBJPAGELEN KU32_C(0x1000) 124 124 125 125 … … 127 127 * @{ */ 128 128 /** App Type: Fullscreen only. */ 129 #define E32NOPMW UINT32_C(0x00000100)129 #define E32NOPMW KU32_C(0x00000100) 130 130 /** App Type: PM API. */ 131 #define E32PMAPI UINT32_C(0x00000300)131 #define E32PMAPI KU32_C(0x00000300) 132 132 /** App Type: PM VIO compatible. */ 133 #define E32PMW UINT32_C(0x00000200)133 #define E32PMW KU32_C(0x00000200) 134 134 /** Application type mask. */ 135 #define E32APPMASK UINT32_C(0x00000300)135 #define E32APPMASK KU32_C(0x00000300) 136 136 /** Executable module. */ 137 #define E32MODEXE UINT32_C(0x00000000)137 #define E32MODEXE KU32_C(0x00000000) 138 138 /** Dynamic link library (DLL / library) module. */ 139 #define E32MODDLL UINT32_C(0x00008000)139 #define E32MODDLL KU32_C(0x00008000) 140 140 /** Protected memory DLL. */ 141 #define E32PROTDLL UINT32_C(0x00010000)141 #define E32PROTDLL KU32_C(0x00010000) 142 142 /** Physical Device Driver. */ 143 #define E32MODPDEV UINT32_C(0x00020000)143 #define E32MODPDEV KU32_C(0x00020000) 144 144 /** Virtual Device Driver. */ 145 #define E32MODVDEV UINT32_C(0x00028000)145 #define E32MODVDEV KU32_C(0x00028000) 146 146 /** Device driver */ 147 147 #define E32DEVICE E32MODPDEV … … 151 151 #define E32MODPROTDLL (E32MODDLL | E32PROTDLL) 152 152 /** Module Type mask. */ 153 #define E32MODMASK UINT32_C(0x00038000)153 #define E32MODMASK KU32_C(0x00038000) 154 154 /** Not loadable (linker error). */ 155 #define E32NOLOAD UINT32_C(0x00002000)155 #define E32NOLOAD KU32_C(0x00002000) 156 156 /** No internal fixups. */ 157 #define E32NOINTFIX UINT32_C(0x00000010)157 #define E32NOINTFIX KU32_C(0x00000010) 158 158 /** No external fixups (i.e. imports). */ 159 #define E32NOEXTFIX UINT32_C(0x00000020)159 #define E32NOEXTFIX KU32_C(0x00000020) 160 160 /** System DLL, no internal fixups. */ 161 #define E32SYSDLL UINT32_C(0x00000008)161 #define E32SYSDLL KU32_C(0x00000008) 162 162 /** Global (set) or per instance (cleared) library initialization. */ 163 #define E32LIBINIT UINT32_C(0x00000004)163 #define E32LIBINIT KU32_C(0x00000004) 164 164 /** Global (set) or per instance (cleared) library termination. */ 165 #define E32LIBTERM UINT32_C(0x40000000)165 #define E32LIBTERM KU32_C(0x40000000) 166 166 /** Indicates when set in an executable that the process isn't SMP safe. */ 167 #define E32NOTMPSAFE UINT32_C(0x00080000)167 #define E32NOTMPSAFE KU32_C(0x00080000) 168 168 /** @} */ 169 169 … … 172 172 typedef union _offset 173 173 { 174 uint16_toffset16;175 uint32_toffset32;174 KU16 offset16; 175 KU32 offset32; 176 176 } offset; 177 177 … … 181 181 struct r32_rlc 182 182 { 183 uint8_tnr_stype;184 uint8_tnr_flags;185 int16_tr32_soff;186 uint16_tr32_objmod;183 KU8 nr_stype; 184 KU8 nr_flags; 185 KI16 r32_soff; 186 KU16 r32_objmod; 187 187 188 188 union targetid … … 192 192 { 193 193 offset proc; 194 uint32_tord;194 KU32 ord; 195 195 } extref; 196 196 struct addfixup 197 197 { 198 uint16_tentry;198 KU16 entry; 199 199 offset addval; 200 200 } addfix; 201 201 } r32_target; 202 uint16_tr32_srccount;203 uint16_tr32_chain;202 KU16 r32_srccount; 203 KU16 r32_chain; 204 204 }; 205 205 … … 256 256 { 257 257 /** The size of the object. */ 258 uint32_to32_size;258 KU32 o32_size; 259 259 /** The base address of the object. */ 260 uint32_to32_base;260 KU32 o32_base; 261 261 /** Object flags. */ 262 uint32_to32_flags;262 KU32 o32_flags; 263 263 /** Page map index. */ 264 uint32_to32_pagemap;264 KU32 o32_pagemap; 265 265 /** Page map size. (doesn't need to be o32_size >> page shift). */ 266 uint32_to32_mapsize;266 KU32 o32_mapsize; 267 267 /** Reserved */ 268 uint32_to32_reserved;268 KU32 o32_reserved; 269 269 }; 270 270 … … 272 272 * @{ */ 273 273 /** Read access. */ 274 #define OBJREAD UINT32_C(0x00000001)274 #define OBJREAD KU32_C(0x00000001) 275 275 /** Write access. */ 276 #define OBJWRITE UINT32_C(0x00000002)276 #define OBJWRITE KU32_C(0x00000002) 277 277 /** Execute access. */ 278 #define OBJEXEC UINT32_C(0x00000004)278 #define OBJEXEC KU32_C(0x00000004) 279 279 /** Resource object. */ 280 #define OBJRSRC UINT32_C(0x00000008)280 #define OBJRSRC KU32_C(0x00000008) 281 281 /** The object is discarable (i.e. don't swap, just load in pages from the executable). 282 282 * This overlaps a bit with object type. */ 283 #define OBJDISCARD UINT32_C(0x00000010)283 #define OBJDISCARD KU32_C(0x00000010) 284 284 /** The object is shared. */ 285 #define OBJSHARED UINT32_C(0x00000020)285 #define OBJSHARED KU32_C(0x00000020) 286 286 /** The object has preload pages. */ 287 #define OBJPRELOAD UINT32_C(0x00000040)287 #define OBJPRELOAD KU32_C(0x00000040) 288 288 /** The object has invalid pages. */ 289 #define OBJINVALID UINT32_C(0x00000080)289 #define OBJINVALID KU32_C(0x00000080) 290 290 /** Non-permanent, link386 bug. */ 291 #define LNKNONPERM UINT32_C(0x00000600)291 #define LNKNONPERM KU32_C(0x00000600) 292 292 /** Non-permanent, correct 'value'. */ 293 #define OBJNONPERM UINT32_C(0x00000000)293 #define OBJNONPERM KU32_C(0x00000000) 294 294 /** Obj Type: The object is permanent and swappable. */ 295 #define OBJPERM UINT32_C(0x00000100)295 #define OBJPERM KU32_C(0x00000100) 296 296 /** Obj Type: The object is permanent and resident (i.e. not swappable). */ 297 #define OBJRESIDENT UINT32_C(0x00000200)297 #define OBJRESIDENT KU32_C(0x00000200) 298 298 /** Obj Type: The object is resident and contigious. */ 299 #define OBJCONTIG UINT32_C(0x00000300)299 #define OBJCONTIG KU32_C(0x00000300) 300 300 /** Obj Type: The object is permanent and long locable. */ 301 #define OBJDYNAMIC UINT32_C(0x00000400)301 #define OBJDYNAMIC KU32_C(0x00000400) 302 302 /** Object type mask. */ 303 #define OBJTYPEMASK UINT32_C(0x00000700)303 #define OBJTYPEMASK KU32_C(0x00000700) 304 304 /** x86: The object require an 16:16 alias. */ 305 #define OBJALIAS16 UINT32_C(0x00001000)305 #define OBJALIAS16 KU32_C(0x00001000) 306 306 /** x86: Big/Default selector setting, i.e. toggle 32-bit or 16-bit. */ 307 #define OBJBIGDEF UINT32_C(0x00002000)307 #define OBJBIGDEF KU32_C(0x00002000) 308 308 /** x86: conforming selector setting (weird stuff). */ 309 #define OBJCONFORM UINT32_C(0x00004000)309 #define OBJCONFORM KU32_C(0x00004000) 310 310 /** x86: IOPL. */ 311 #define OBJIOPL UINT32_C(0x00008000)311 #define OBJIOPL KU32_C(0x00008000) 312 312 /** @} */ 313 313 … … 316 316 { 317 317 /** The file offset of the page. */ 318 uint32_to32_pagedataoffset;318 KU32 o32_pagedataoffset; 319 319 /** The number of bytes of raw page data. */ 320 uint16_to32_pagesize;320 KU16 o32_pagesize; 321 321 /** Per page flags describing how the page is encoded in the file. */ 322 uint16_to32_pageflags;322 KU16 o32_pageflags; 323 323 }; 324 324 … … 327 327 */ 328 328 /** Raw page (uncompressed) in the file. */ 329 #define VALID UINT16_C(0x0000)329 #define VALID KU16_C(0x0000) 330 330 /** RLE encoded page in file. */ 331 #define ITERDATA UINT16_C(0x0001)331 #define ITERDATA KU16_C(0x0001) 332 332 /** Invalid page, nothing in the file. */ 333 #define INVALID UINT16_C(0x0002)333 #define INVALID KU16_C(0x0002) 334 334 /** Zero page, nothing in file. */ 335 #define ZEROED UINT16_C(0x0003)335 #define ZEROED KU16_C(0x0003) 336 336 /** range of pages (what is this?) */ 337 #define RANGE UINT16_C(0x0004)337 #define RANGE KU16_C(0x0004) 338 338 /** Compressed page in file. */ 339 #define ITERDATA2 UINT16_C(0x0005)339 #define ITERDATA2 KU16_C(0x0005) 340 340 /** @} */ 341 341 … … 345 345 { 346 346 /** Number of iterations. */ 347 uint16_tLX_nIter;347 KU16 LX_nIter; 348 348 /** The number of bytes that's being iterated. */ 349 uint16_tLX_nBytes;349 KU16 LX_nBytes; 350 350 /** The bytes. */ 351 uint8_tLX_Iterdata;351 KU8 LX_Iterdata; 352 352 }; 353 353 … … 359 359 { 360 360 /** Resource Type. */ 361 uint16_ttype;361 KU16 type; 362 362 /** Resource ID. */ 363 uint16_tname;363 KU16 name; 364 364 /** Resource size in bytes. */ 365 uint32_tcb;365 KU32 cb; 366 366 /** The index of the object containing the resource. */ 367 uint16_tobj;367 KU16 obj; 368 368 /** Offset of the resource that within the object. */ 369 uint32_toffset;369 KU32 offset; 370 370 }; 371 371 … … 379 379 { 380 380 /** The number of entries. */ 381 uint8_tb32_cnt;381 KU8 b32_cnt; 382 382 /** The type of bundle. */ 383 uint8_tb32_type;383 KU8 b32_type; 384 384 /** The index of the object containing these entry points. */ 385 uint16_tb32_obj;385 KU16 b32_obj; 386 386 }; 387 387 … … 407 407 { 408 408 /** Entry point flags */ 409 uint8_te32_flags; /* Entry point flags */409 KU8 e32_flags; /* Entry point flags */ 410 410 union entrykind 411 411 { … … 416 416 { 417 417 /** Offset into segment. */ 418 uint16_toffset;418 KU16 offset; 419 419 /** The callgate selector */ 420 uint16_tcallgate;420 KU16 callgate; 421 421 } e32_callgate; 422 422 /** ENTRYFWD */ … … 424 424 { 425 425 /** Module ordinal number (i.e. into the import module table). */ 426 uint16_tmodord;426 KU16 modord; 427 427 /** Procedure name or ordinal number. */ 428 uint32_tvalue;428 KU32 value; 429 429 } e32_fwd; 430 430 } e32_variant; -
trunk/kStuff/kLdr/kLdrModMZ.h
r3537 r3567 10 10 typedef struct _IMAGE_DOS_HEADER 11 11 { 12 uint16_te_magic;13 uint16_te_cblp;14 uint16_te_cp;15 uint16_te_crlc;16 uint16_te_cparhdr;17 uint16_te_minalloc;18 uint16_te_maxalloc;19 uint16_te_ss;20 uint16_te_sp;21 uint16_te_csum;22 uint16_te_ip;23 uint16_te_cs;24 uint16_te_lfarlc;25 uint16_te_ovno;26 uint16_te_res[4];27 uint16_te_oemid;28 uint16_te_oeminfo;29 uint16_te_res2[10];30 uint32_te_lfanew;12 KU16 e_magic; 13 KU16 e_cblp; 14 KU16 e_cp; 15 KU16 e_crlc; 16 KU16 e_cparhdr; 17 KU16 e_minalloc; 18 KU16 e_maxalloc; 19 KU16 e_ss; 20 KU16 e_sp; 21 KU16 e_csum; 22 KU16 e_ip; 23 KU16 e_cs; 24 KU16 e_lfarlc; 25 KU16 e_ovno; 26 KU16 e_res[4]; 27 KU16 e_oemid; 28 KU16 e_oeminfo; 29 KU16 e_res2[10]; 30 KU32 e_lfanew; 31 31 } IMAGE_DOS_HEADER; 32 32 typedef IMAGE_DOS_HEADER *PIMAGE_DOS_HEADER; -
trunk/kStuff/kLdr/kLdrModMachO.c
r3537 r3567 70 70 KLDRFOFF offFile; 71 71 /** The number of fixups. */ 72 uint32_tcFixups;72 KU32 cFixups; 73 73 /** The array of fixups. (lazy loaded) */ 74 74 macho_relocation_info_t *paFixups; … … 77 77 KLDRFOFF offFixups; 78 78 /** Mach-O section flags. */ 79 uint32_tfFlags;79 KU32 fFlags; 80 80 /** kLdr segment index. */ 81 uint32_tiSegment;81 KU32 iSegment; 82 82 /** Pointer to the Mach-O section structure. */ 83 83 void *pvMachoSection; … … 92 92 { 93 93 /** The number of sections in the segment. */ 94 uint32_tcSections;94 KU32 cSections; 95 95 /** Pointer to the sections belonging to this segment. 96 96 * The array resides in the big memory chunk allocated for … … 122 122 123 123 /** Pointer to the load commands. (endian converted) */ 124 uint8_t*pbLoadCommands;124 KU8 *pbLoadCommands; 125 125 /** The Mach-O header. (endian converted) 126 126 * @remark The reserved field is only valid for real 64-bit headers. */ … … 130 130 KLDRFOFF offSymbols; 131 131 /** The number of symbols. */ 132 uint32_tcSymbols;132 KU32 cSymbols; 133 133 /** The pointer to the loaded symbol table. */ 134 134 void *pvaSymbols; … … 136 136 KLDRFOFF offStrings; 137 137 /** The size of the of the string table. */ 138 uint32_tcchStrings;138 KU32 cchStrings; 139 139 /** Pointer to the loaded string table. */ 140 140 char *pchStrings; 141 141 142 142 /** The number of sections. */ 143 uint32_tcSections;143 KU32 cSections; 144 144 /** Pointer to the section array running in parallel to the Mach-O one. */ 145 145 PKLDRMODMACHOSECT paSections; … … 155 155 *******************************************************************************/ 156 156 #if 0 157 static int32_tkldrModMachONumberOfImports(PKLDRMOD pMod, const void *pvBits);157 static KI32 kldrModMachONumberOfImports(PKLDRMOD pMod, const void *pvBits); 158 158 #endif 159 159 static int kldrModMachORelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress, … … 161 161 162 162 static int kldrModMachODoCreate(PKLDRRDR pRdr, PKLDRMODMACHO *ppMod); 163 static int kldrModMachOPreParseLoadCommands( uint8_t*pbLoadCommands, const mach_header_32_t *pHdr, PKLDRRDR pRdr,164 uint32_t *pcSegments, uint32_t *pcSections, uint32_t*pcbStringPool);165 static int kldrModMachOParseLoadCommands(PKLDRMODMACHO pModMachO, char *pbStringPool, uint32_tcbStringPool);163 static int kldrModMachOPreParseLoadCommands(KU8 *pbLoadCommands, const mach_header_32_t *pHdr, PKLDRRDR pRdr, 164 KU32 *pcSegments, KU32 *pcSections, KU32 *pcbStringPool); 165 static int kldrModMachOParseLoadCommands(PKLDRMODMACHO pModMachO, char *pbStringPool, KU32 cbStringPool); 166 166 static int kldrModMachOAdjustBaseAddress(PKLDRMODMACHO pModMachO, PKLDRADDR pBaseAddress); 167 167 168 168 /*static int kldrModMachOLoadLoadCommands(PKLDRMODMACHO pModMachO);*/ 169 169 static int kldrModMachOLoadObjSymTab(PKLDRMODMACHO pModMachO); 170 static int kldrModMachOLoadFixups(PKLDRMODMACHO pModMachO, KLDRFOFF offFixups, uint32_tcFixups, macho_relocation_info_t **ppaFixups);170 static int kldrModMachOLoadFixups(PKLDRMODMACHO pModMachO, KLDRFOFF offFixups, KU32 cFixups, macho_relocation_info_t **ppaFixups); 171 171 static int kldrModMachOMapVirginBits(PKLDRMODMACHO pModMachO); 172 172 173 static int kldrModMachODoQuerySymbol32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, uint32_tcSyms, const char *pchStrings,174 uint32_t cchStrings, KLDRADDR BaseAddress, uint32_tiSymbol, const char *pchSymbol,175 size_t cchSymbol, PKLDRADDR puValue, uint32_t*pfKind);176 static int kldrModMachODoEnumSymbols32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, uint32_tcSyms,177 const char *pchStrings, uint32_tcchStrings, KLDRADDR BaseAddress,178 uint32_tfFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);173 static int kldrModMachODoQuerySymbol32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, KU32 cSyms, const char *pchStrings, 174 KU32 cchStrings, KLDRADDR BaseAddress, KU32 iSymbol, const char *pchSymbol, 175 KSIZE cchSymbol, PKLDRADDR puValue, KU32 *pfKind); 176 static int kldrModMachODoEnumSymbols32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, KU32 cSyms, 177 const char *pchStrings, KU32 cchStrings, KLDRADDR BaseAddress, 178 KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser); 179 179 static int kldrModMachOObjDoImports(PKLDRMODMACHO pModMachO, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 180 180 static int kldrModMachOObjDoFixups(PKLDRMODMACHO pModMachO, void *pvMapping, KLDRADDR NewBaseAddress); 181 static int kldrModMachOFixupSectionGeneric32Bit(PKLDRMODMACHO pModMachO, uint8_t*pbSectBits, PKLDRMODMACHOSECT pFixupSect,182 macho_nlist_32_t *paSyms, uint32_tcSyms, KLDRADDR NewBaseAddress);181 static int kldrModMachOFixupSectionGeneric32Bit(PKLDRMODMACHO pModMachO, KU8 *pbSectBits, PKLDRMODMACHOSECT pFixupSect, 182 macho_nlist_32_t *paSyms, KU32 cSyms, KLDRADDR NewBaseAddress); 183 183 184 184 /*static int kldrModMachODoFixups(PKLDRMODMACHO pModMachO, void *pvMapping, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress); … … 235 235 PKLDRMODMACHO pModMachO; 236 236 PKLDRMOD pMod; 237 uint8_t*pbLoadCommands;238 uint32_tcSegments;239 uint32_tcSections;240 uint32_tcbStringPool;241 size_tcchFilename;242 size_tcb;237 KU8 *pbLoadCommands; 238 KU32 cSegments; 239 KU32 cSections; 240 KU32 cbStringPool; 241 KSIZE cchFilename; 242 KSIZE cb; 243 243 int rc; 244 244 *ppModMachO = NULL; … … 311 311 312 312 /* KLDRMOD */ 313 pMod = (PKLDRMOD)(( uint8_t*)pModMachO + KLDR_ALIGN_Z( KLDR_OFFSETOF(KLDRMODMACHO, aSegments[cSegments])314 313 pMod = (PKLDRMOD)((KU8 *)pModMachO + KLDR_ALIGN_Z( KLDR_OFFSETOF(KLDRMODMACHO, aSegments[cSegments]) 314 + sizeof(KLDRMODMACHOSECT) * cSections, 16)); 315 315 pMod->pvData = pModMachO; 316 316 pMod->pRdr = pRdr; … … 430 430 * @param pcbStringPool Where to store the string pool size. 431 431 */ 432 static int kldrModMachOPreParseLoadCommands( uint8_t*pbLoadCommands, const mach_header_32_t *pHdr, PKLDRRDR pRdr,433 uint32_t *pcSegments, uint32_t *pcSections, uint32_t*pcbStringPool)432 static int kldrModMachOPreParseLoadCommands(KU8 *pbLoadCommands, const mach_header_32_t *pHdr, PKLDRRDR pRdr, 433 KU32 *pcSegments, KU32 *pcSections, KU32 *pcbStringPool) 434 434 { 435 435 union 436 436 { 437 uint8_t*pb;437 KU8 *pb; 438 438 load_command_t *pLoadCmd; 439 439 segment_command_32_t *pSeg32; … … 443 443 uuid_command_t *pUuid; 444 444 } u; 445 const uint64_tcbFile = kLdrRdrSize(pRdr);446 uint32_tcSegments = 0;447 uint32_tcSections = 0;448 uint32_tcbStringPool = 0;449 uint32_tcLeft = pHdr->ncmds;450 uint32_tcbLeft = pHdr->sizeofcmds;451 uint8_t*pb = pbLoadCommands;445 const KU64 cbFile = kLdrRdrSize(pRdr); 446 KU32 cSegments = 0; 447 KU32 cSections = 0; 448 KU32 cbStringPool = 0; 449 KU32 cLeft = pHdr->ncmds; 450 KU32 cbLeft = pHdr->sizeofcmds; 451 KU8 *pb = pbLoadCommands; 452 452 int cSegmentCommands = 0; 453 453 int cSymbolTabs = 0; … … 487 487 section_32_t *pSect; 488 488 section_32_t *pFirstSect; 489 uint32_tcSectionsLeft;489 KU32 cSectionsLeft; 490 490 491 491 /* convert and verify*/ … … 509 509 if ( u.pSeg32->filesize 510 510 && ( u.pSeg32->fileoff > cbFile 511 || ( uint64_t)u.pSeg32->fileoff + u.pSeg32->filesize > cbFile))511 || (KU64)u.pSeg32->fileoff + u.pSeg32->filesize > cbFile)) 512 512 return KLDR_ERR_MACHO_BAD_LOAD_COMMAND; 513 513 if (!u.pSeg32->filesize && u.pSeg32->fileoff) … … 594 594 if ( fFileBits 595 595 && ( pSect->offset > cbFile 596 || ( uint64_t)pSect->offset + pSect->size > cbFile))596 || (KU64)pSect->offset + pSect->size > cbFile)) 597 597 return KLDR_ERR_MACHO_BAD_SECTION; 598 598 if (!fFileBits && pSect->offset) … … 602 602 if ( pSect->nreloc 603 603 && ( pSect->reloff > cbFile 604 || ( uint64_t)pSect->reloff + (KLDRFOFF)pSect->nreloc * sizeof(macho_relocation_info_t)) > cbFile)604 || (KU64)pSect->reloff + (KLDRFOFF)pSect->nreloc * sizeof(macho_relocation_info_t)) > cbFile) 605 605 return KLDR_ERR_MACHO_BAD_SECTION; 606 606 … … 624 624 /* verify that the linker/assembler has ordered sections correctly. */ 625 625 section_32_t *pCur = (pSect - 2); 626 while (( uintptr_t)pCur >= (uintptr_t)pFirstSect)626 while ((KUPTR)pCur >= (KUPTR)pFirstSect) 627 627 { 628 628 if (!kLdrHlpStrNComp(pCur->segname, pSect->segname, sizeof(pSect->segname))) … … 656 656 case LC_SYMTAB: 657 657 { 658 size_tcbSym;658 KSIZE cbSym; 659 659 if (fConvertEndian) 660 660 { … … 671 671 : sizeof(macho_nlist_64_t); 672 672 if ( u.pSymTab->symoff >= cbFile 673 || ( uint64_t)u.pSymTab->symoff + u.pSymTab->nsyms * cbSym > kLdrRdrSize(pRdr))673 || (KU64)u.pSymTab->symoff + u.pSymTab->nsyms * cbSym > kLdrRdrSize(pRdr)) 674 674 return KLDR_ERR_MACHO_BAD_LOAD_COMMAND; 675 675 if ( u.pSymTab->stroff >= cbFile 676 || ( uint64_t)u.pSymTab->stroff + u.pSymTab->strsize > cbFile)676 || (KU64)u.pSymTab->stroff + u.pSymTab->strsize > cbFile) 677 677 return KLDR_ERR_MACHO_BAD_LOAD_COMMAND; 678 678 … … 692 692 case LC_UNIXTHREAD: 693 693 { 694 uint32_t *pu32 = (uint32_t*)(u.pb + sizeof(load_command_t));695 uint32_t cItemsLeft = (u.pThread->cmdsize - sizeof(load_command_t)) / sizeof(uint32_t);694 KU32 *pu32 = (KU32 *)(u.pb + sizeof(load_command_t)); 695 KU32 cItemsLeft = (u.pThread->cmdsize - sizeof(load_command_t)) / sizeof(KU32); 696 696 while (cItemsLeft) 697 697 { 698 /* convert & verify header items ([0] == flavor, [1] == uint32_tcount). */698 /* convert & verify header items ([0] == flavor, [1] == KU32 count). */ 699 699 if (cItemsLeft < 2) 700 700 return KLDR_ERR_MACHO_BAD_LOAD_COMMAND; … … 787 787 * @param cbStringPool The size of the string pool. 788 788 */ 789 static int kldrModMachOParseLoadCommands(PKLDRMODMACHO pModMachO, char *pbStringPool, uint32_tcbStringPool)789 static int kldrModMachOParseLoadCommands(PKLDRMODMACHO pModMachO, char *pbStringPool, KU32 cbStringPool) 790 790 { 791 791 union 792 792 { 793 const uint8_t*pb;793 const KU8 *pb; 794 794 const load_command_t *pLoadCmd; 795 795 const segment_command_32_t *pSeg32; … … 797 797 const symtab_command_t *pSymTab; 798 798 } u; 799 uint32_tcLeft = pModMachO->Hdr.ncmds;800 uint32_tcbLeft = pModMachO->Hdr.sizeofcmds;801 const uint8_t*pb = pModMachO->pbLoadCommands;799 KU32 cLeft = pModMachO->Hdr.ncmds; 800 KU32 cbLeft = pModMachO->Hdr.sizeofcmds; 801 const KU8 *pb = pModMachO->pbLoadCommands; 802 802 int fFirstSegment = 1; 803 803 PKLDRSEG pSeg = &pModMachO->pMod->aSegments[0]; 804 804 PKLDRMODMACHOSEG pSegExtra = &pModMachO->aSegments[0]; 805 805 PKLDRMODMACHOSECT pSectExtra = pModMachO->paSections; 806 const uint32_tcSegments = pModMachO->pMod->cSegments;807 uint32_ti;806 const KU32 cSegments = pModMachO->pMod->cSegments; 807 KU32 i; 808 808 809 809 while (cLeft-- > 0) … … 822 822 section_32_t *pSect; 823 823 section_32_t *pFirstSect; 824 uint32_tcSectionsLeft;824 KU32 cSectionsLeft; 825 825 826 826 pModMachO->LinkAddress = u.pSeg32->vmaddr; … … 867 867 pSeg->pvUser = NULL; 868 868 pSeg->pchName = pbStringPool; 869 pSeg->cchName = ( uint32_t)kLdrHlpStrNLen(&pSect->segname[0], sizeof(pSect->sectname));869 pSeg->cchName = (KU32)kLdrHlpStrNLen(&pSect->segname[0], sizeof(pSect->sectname)); 870 870 kLdrHlpMemCopy(pbStringPool, &pSect->segname[0], pSeg->cchName); 871 871 pbStringPool += pSeg->cchName; … … 967 967 { 968 968 KLDRADDR cb1; 969 size_tcb2;969 KSIZE cb2; 970 970 971 971 for (i = 0; i < cSegments - 1; i++) 972 972 { 973 973 cb1 = pSeg[i + 1].LinkAddress - pSeg[i].LinkAddress; 974 cb2 = ( size_t)cb1;975 pSeg[i].cbMapped = cb2 == cb1 ? cb2 : ~( size_t)0;974 cb2 = (KSIZE)cb1; 975 pSeg[i].cbMapped = cb2 == cb1 ? cb2 : ~(KSIZE)0; 976 976 } 977 977 cb1 = KLDR_ALIGN_ADDR(pSeg[i].cb, pSeg[i].Alignment); 978 cb2 = ( size_t)cb1;979 pSeg[i].cbMapped = cb2 == cb1 ? cb2 : ~( size_t)0;978 cb2 = (KSIZE)cb1; 979 pSeg[i].cbMapped = cb2 == cb1 ? cb2 : ~(KSIZE)0; 980 980 981 981 pModMachO->cbImage = pSeg[i].RVA + cb1; … … 993 993 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; 994 994 int rc = 0; 995 uint32_ti, j;995 KU32 i, j; 996 996 KLDRMODMACHO_ASSERT(!pModMachO->pvMapping); 997 997 … … 1049 1049 1050 1050 /** @copydoc kLdrModQuerySymbol */ 1051 static int kldrModMachOQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tiSymbol,1052 const char *pchSymbol, size_tcchSymbol, const char *pszVersion,1053 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind)1051 static int kldrModMachOQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol, 1052 const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion, 1053 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind) 1054 1054 { 1055 1055 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; … … 1115 1115 * @param pfKind See kLdrModQuerySymbol. 1116 1116 */ 1117 static int kldrModMachODoQuerySymbol32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, uint32_tcSyms, const char *pchStrings,1118 uint32_t cchStrings, KLDRADDR BaseAddress, uint32_t iSymbol, const char *pchSymbol, size_tcchSymbol,1119 PKLDRADDR puValue, uint32_t*pfKind)1117 static int kldrModMachODoQuerySymbol32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, KU32 cSyms, const char *pchStrings, 1118 KU32 cchStrings, KLDRADDR BaseAddress, KU32 iSymbol, const char *pchSymbol, KSIZE cchSymbol, 1119 PKLDRADDR puValue, KU32 *pfKind) 1120 1120 { 1121 1121 /* … … 1130 1130 1131 1131 /* external symbols are usually at the end, so search the other way. */ 1132 for (iSymbol = cSyms - 1; iSymbol != UINT32_MAX; iSymbol--)1132 for (iSymbol = cSyms - 1; iSymbol != KU32_MAX; iSymbol--) 1133 1133 { 1134 1134 const char *psz; … … 1147 1147 if (!paSyms[iSymbol].n_un.n_strx) 1148 1148 continue; 1149 if (( uint32_t)paSyms[iSymbol].n_un.n_strx >= cchStrings)1149 if ((KU32)paSyms[iSymbol].n_un.n_strx >= cchStrings) 1150 1150 continue; 1151 1151 psz = &pchStrings[paSyms[iSymbol].n_un.n_strx]; … … 1158 1158 break; 1159 1159 } 1160 if (iSymbol == UINT32_MAX)1160 if (iSymbol == KU32_MAX) 1161 1161 return KLDR_ERR_SYMBOL_NOT_FOUND; 1162 1162 } … … 1191 1191 PKLDRMODMACHOSECT pSect; 1192 1192 KLDRADDR RVA; 1193 if (( uint32_t)(paSyms[iSymbol].n_sect - 1) >= pModMachO->cSections)1193 if ((KU32)(paSyms[iSymbol].n_sect - 1) >= pModMachO->cSections) 1194 1194 return KLDR_ERR_MACHO_BAD_SYMBOL; 1195 1195 pSect = &pModMachO->paSections[paSyms[iSymbol].n_sect - 1]; … … 1228 1228 /** @copydoc kLdrModEnumSymbols */ 1229 1229 static int kldrModMachOEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, 1230 uint32_tfFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)1230 KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser) 1231 1231 { 1232 1232 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; … … 1280 1280 * @param pvUser See kLdrModEnumSymbols. 1281 1281 */ 1282 static int kldrModMachODoEnumSymbols32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, uint32_tcSyms,1283 const char *pchStrings, uint32_tcchStrings, KLDRADDR BaseAddress,1284 uint32_tfFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)1285 { 1286 const uint32_tfKindBase = pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE1282 static int kldrModMachODoEnumSymbols32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, KU32 cSyms, 1283 const char *pchStrings, KU32 cchStrings, KLDRADDR BaseAddress, 1284 KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser) 1285 { 1286 const KU32 fKindBase = pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE 1287 1287 || pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE 1288 1288 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT; 1289 uint32_tiSym;1289 KU32 iSym; 1290 1290 int rc; 1291 1291 … … 1295 1295 for (iSym = 0; iSym < cSyms; iSym++) 1296 1296 { 1297 uint32_tfKind;1297 KU32 fKind; 1298 1298 KLDRADDR uValue; 1299 1299 const char *psz; 1300 size_tcch;1300 KSIZE cch; 1301 1301 1302 1302 /* Skip debug symbols and undefined symbols. */ … … 1322 1322 1323 1323 /* name */ 1324 if (( uint32_t)paSyms[iSym].n_un.n_strx >= cchStrings)1324 if ((KU32)paSyms[iSym].n_un.n_strx >= cchStrings) 1325 1325 return KLDR_ERR_MACHO_BAD_SYMBOL; 1326 1326 psz = &pchStrings[paSyms[iSym].n_un.n_strx]; … … 1338 1338 { 1339 1339 PKLDRMODMACHOSECT pSect; 1340 if (( uint32_t)(paSyms[iSym].n_sect - 1) >= pModMachO->cSections)1340 if ((KU32)(paSyms[iSym].n_sect - 1) >= pModMachO->cSections) 1341 1341 return KLDR_ERR_MACHO_BAD_SYMBOL; 1342 1342 pSect = &pModMachO->paSections[paSyms[iSym].n_sect - 1]; … … 1379 1379 1380 1380 /** @copydoc kLdrModGetImport */ 1381 static int kldrModMachOGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_tcchName)1381 static int kldrModMachOGetImport(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName) 1382 1382 { 1383 1383 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; … … 1391 1391 1392 1392 /** @copydoc kLdrModNumberOfImports */ 1393 static int32_tkldrModMachONumberOfImports(PKLDRMOD pMod, const void *pvBits)1393 static KI32 kldrModMachONumberOfImports(PKLDRMOD pMod, const void *pvBits) 1394 1394 { 1395 1395 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; … … 1449 1449 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; 1450 1450 const IMAGE_DEBUG_DIRECTORY *pDbgDir; 1451 uint32_tiDbgInfo;1452 uint32_tcb;1451 KU32 iDbgInfo; 1452 KU32 cb; 1453 1453 int rc; 1454 1454 … … 1543 1543 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; 1544 1544 unsigned fFixed; 1545 uint32_ti;1545 KU32 i; 1546 1546 void *pvBase; 1547 1547 int rc; … … 1563 1563 else 1564 1564 { 1565 pvBase = (void *)( uintptr_t)pMod->aSegments[0].LinkAddress;1566 if (( uintptr_t)pvBase != pMod->aSegments[0].LinkAddress)1565 pvBase = (void *)(KUPTR)pMod->aSegments[0].LinkAddress; 1566 if ((KUPTR)pvBase != pMod->aSegments[0].LinkAddress) 1567 1567 return KLDR_ERR_ADDRESS_OVERFLOW; 1568 1568 } … … 1584 1584 { 1585 1585 if (pMod->aSegments[i].RVA != NIL_KLDRADDR) 1586 pMod->aSegments[i].MapAddress = ( uintptr_t)pvBase + (uintptr_t)pMod->aSegments[i].RVA;1586 pMod->aSegments[i].MapAddress = (KUPTR)pvBase + (KUPTR)pMod->aSegments[i].RVA; 1587 1587 } 1588 1588 pModMachO->pvMapping = pvBase; … … 1596 1596 { 1597 1597 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; 1598 uint32_ti;1598 KU32 i; 1599 1599 int rc; 1600 1600 … … 1691 1691 * Resolve imports and apply base relocations. 1692 1692 */ 1693 rc = kldrModMachORelocateBits(pMod, pModMachO->pvMapping, ( uintptr_t)pModMachO->pvMapping, pModMachO->LinkAddress,1693 rc = kldrModMachORelocateBits(pMod, pModMachO->pvMapping, (KUPTR)pModMachO->pvMapping, pModMachO->LinkAddress, 1694 1694 pfnGetImport, pvUser); 1695 1695 … … 1717 1717 static int kldrModMachOObjDoImports(PKLDRMODMACHO pModMachO, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser) 1718 1718 { 1719 const uint32_tcSyms = pModMachO->cSymbols;1720 uint32_tiSym;1719 const KU32 cSyms = pModMachO->cSymbols; 1720 KU32 iSym; 1721 1721 int rc; 1722 1722 … … 1745 1745 { 1746 1746 const char *pszSymbol; 1747 size_tcchSymbol;1748 uint32_tfKind = KLDRSYMKIND_REQ_FLAT;1747 KSIZE cchSymbol; 1748 KU32 fKind = KLDRSYMKIND_REQ_FLAT; 1749 1749 KLDRADDR Value; 1750 1750 … … 1754 1754 1755 1755 /* Get the symbol name and try resolve it. */ 1756 if (( uint32_t)paSyms[iSym].n_un.n_strx >= pModMachO->cchStrings)1756 if ((KU32)paSyms[iSym].n_un.n_strx >= pModMachO->cchStrings) 1757 1757 return KLDR_ERR_MACHO_BAD_SYMBOL; 1758 1758 pszSymbol = &pModMachO->pchStrings[paSyms[iSym].n_un.n_strx]; … … 1769 1769 1770 1770 /* Update the symbol. */ 1771 paSyms[iSym].n_value = ( uint32_t)Value;1771 paSyms[iSym].n_value = (KU32)Value; 1772 1772 if (paSyms[iSym].n_value != Value) 1773 1773 { … … 1796 1796 { 1797 1797 const char *pszSymbol; 1798 size_tcchSymbol;1799 uint32_tfKind = KLDRSYMKIND_REQ_FLAT;1798 KSIZE cchSymbol; 1799 KU32 fKind = KLDRSYMKIND_REQ_FLAT; 1800 1800 KLDRADDR Value; 1801 1801 … … 1850 1850 static int kldrModMachOObjDoFixups(PKLDRMODMACHO pModMachO, void *pvMapping, KLDRADDR NewBaseAddress) 1851 1851 { 1852 uint32_tiSeg;1852 KU32 iSeg; 1853 1853 int rc; 1854 1854 … … 1867 1867 { 1868 1868 PKLDRMODMACHOSEG pSeg = &pModMachO->aSegments[iSeg]; 1869 uint32_tiSect;1869 KU32 iSect; 1870 1870 1871 1871 for (iSect = 0; iSect < pSeg->cSections; iSect++) 1872 1872 { 1873 1873 PKLDRMODMACHOSECT pSect = &pSeg->paSections[iSect]; 1874 uint8_t*pbSectBits;1874 KU8 *pbSectBits; 1875 1875 1876 1876 /* skip sections without fixups. */ … … 1889 1889 * Apply the fixups. 1890 1890 */ 1891 pbSectBits = ( uint8_t *)pvMapping + (uintptr_t)pSect->RVA;1891 pbSectBits = (KU8 *)pvMapping + (KUPTR)pSect->RVA; 1892 1892 if (pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE) /** @todo this aint right. */ 1893 1893 rc = kldrModMachOFixupSectionGeneric32Bit(pModMachO, pbSectBits, pSect, … … 1915 1915 * @param NewBaseAddress The new base image address. 1916 1916 */ 1917 static int kldrModMachOFixupSectionGeneric32Bit(PKLDRMODMACHO pModMachO, uint8_t*pbSectBits, PKLDRMODMACHOSECT pFixupSect,1918 macho_nlist_32_t *paSyms, uint32_tcSyms, KLDRADDR NewBaseAddress)1917 static int kldrModMachOFixupSectionGeneric32Bit(PKLDRMODMACHO pModMachO, KU8 *pbSectBits, PKLDRMODMACHOSECT pFixupSect, 1918 macho_nlist_32_t *paSyms, KU32 cSyms, KLDRADDR NewBaseAddress) 1919 1919 { 1920 1920 const macho_relocation_info_t *paFixups = pFixupSect->paFixups; 1921 const uint32_tcFixups = pFixupSect->cFixups;1922 size_t cbSectBits = (size_t)pFixupSect->cb;1923 const uint8_t*pbSectVirginBits;1924 uint32_tiFixup;1921 const KU32 cFixups = pFixupSect->cFixups; 1922 KSIZE cbSectBits = (KSIZE)pFixupSect->cb; 1923 const KU8 *pbSectVirginBits; 1924 KU32 iFixup; 1925 1925 KLDRPU uFixVirgin; 1926 1926 KLDRPU uFix; … … 1936 1936 if (rc) 1937 1937 return rc; 1938 pbSectVirginBits = (const uint8_t*)pModMachO->pvBits + pFixupSect->offFile;1938 pbSectVirginBits = (const KU8 *)pModMachO->pvBits + pFixupSect->offFile; 1939 1939 } 1940 1940 else … … 1956 1956 { 1957 1957 /* sanity */ 1958 if (( uint32_t)Fixup.r.r_address >= cbSectBits)1958 if ((KU32)Fixup.r.r_address >= cbSectBits) 1959 1959 return KLDR_ERR_BAD_FIXUP; 1960 1960 1961 1961 /* calc fixup addresses. */ 1962 1962 uFix.pv = pbSectBits + Fixup.r.r_address; 1963 uFixVirgin.pv = pbSectVirginBits ? ( uint8_t*)pbSectVirginBits + Fixup.r.r_address : 0;1963 uFixVirgin.pv = pbSectVirginBits ? (KU8 *)pbSectVirginBits + Fixup.r.r_address : 0; 1964 1964 1965 1965 /* … … 1994 1994 { 1995 1995 PKLDRMODMACHOSECT pSymSect; 1996 if (( uint32_t)pSym->n_sect - 1 > pModMachO->cSections)1996 if ((KU32)pSym->n_sect - 1 > pModMachO->cSections) 1997 1997 return KLDR_ERR_MACHO_BAD_SYMBOL; 1998 1998 pSymSect = &pModMachO->paSections[pSym->n_sect - 1]; … … 2032 2032 { 2033 2033 PKLDRMODMACHOSECT pSymSect; 2034 uint32_tiSymSect;2034 KU32 iSymSect; 2035 2035 KLDRADDR Value; 2036 2036 2037 2037 /* sanity */ 2038 2038 KLDRMODMACHO_ASSERT(Fixup.s.r_scattered); 2039 if (( uint32_t)Fixup.s.r_address >= cbSectBits)2039 if ((KU32)Fixup.s.r_address >= cbSectBits) 2040 2040 return KLDR_ERR_BAD_FIXUP; 2041 2041 2042 2042 /* calc fixup addresses. */ 2043 2043 uFix.pv = pbSectBits + Fixup.s.r_address; 2044 uFixVirgin.pv = pbSectVirginBits ? ( uint8_t*)pbSectVirginBits + Fixup.s.r_address : 0;2044 uFixVirgin.pv = pbSectVirginBits ? (KU8 *)pbSectVirginBits + Fixup.s.r_address : 0; 2045 2045 2046 2046 /* … … 2092 2092 switch (Fixup.r.r_length) 2093 2093 { 2094 case 0: *uFix.pu8 = ( uint8_t)SymAddr; break;2095 case 1: *uFix.pu16 = ( uint16_t)SymAddr; break;2096 case 2: *uFix.pu32 = ( uint32_t)SymAddr; break;2097 case 3: *uFix.pu64 = ( uint64_t)SymAddr; break;2094 case 0: *uFix.pu8 = (KU8)SymAddr; break; 2095 case 1: *uFix.pu16 = (KU16)SymAddr; break; 2096 case 2: *uFix.pu32 = (KU32)SymAddr; break; 2097 case 3: *uFix.pu64 = (KU64)SymAddr; break; 2098 2098 } 2099 2099 } … … 2123 2123 && pModMachO->cSymbols) 2124 2124 { 2125 size_tcbSyms;2126 size_tcbSym;2125 KSIZE cbSyms; 2126 KSIZE cbSym; 2127 2127 void *pvSyms; 2128 2128 void *pvStrings; … … 2163 2163 if (pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE) 2164 2164 { 2165 uint32_tcLeft = pModMachO->cSymbols;2165 KU32 cLeft = pModMachO->cSymbols; 2166 2166 macho_nlist_32_t *pSym = (macho_nlist_32_t *)pvSyms; 2167 2167 while (cLeft-- > 0) 2168 2168 { 2169 2169 pSym->n_un.n_strx = KLDR_E2E_U32(pSym->n_un.n_strx); 2170 pSym->n_desc = ( int16_t)KLDR_E2E_U16(pSym->n_desc);2170 pSym->n_desc = (KI16)KLDR_E2E_U16(pSym->n_desc); 2171 2171 pSym->n_value = KLDR_E2E_U32(pSym->n_value); 2172 2172 pSym++; … … 2175 2175 else if (pModMachO->Hdr.magic == IMAGE_MACHO64_SIGNATURE_OE) 2176 2176 { 2177 uint32_tcLeft = pModMachO->cSymbols;2177 KU32 cLeft = pModMachO->cSymbols; 2178 2178 macho_nlist_64_t *pSym = (macho_nlist_64_t *)pvSyms; 2179 2179 while (cLeft-- > 0) 2180 2180 { 2181 2181 pSym->n_un.n_strx = KLDR_E2E_U32(pSym->n_un.n_strx); 2182 pSym->n_desc = ( int16_t)KLDR_E2E_U16(pSym->n_desc);2182 pSym->n_desc = (KI16)KLDR_E2E_U16(pSym->n_desc); 2183 2183 pSym->n_value = KLDR_E2E_U64(pSym->n_value); 2184 2184 pSym++; … … 2210 2210 * @param ppaFixups Where to put the pointer to the allocated fixup array. 2211 2211 */ 2212 static int kldrModMachOLoadFixups(PKLDRMODMACHO pModMachO, KLDRFOFF offFixups, uint32_tcFixups, macho_relocation_info_t **ppaFixups)2212 static int kldrModMachOLoadFixups(PKLDRMODMACHO pModMachO, KLDRFOFF offFixups, KU32 cFixups, macho_relocation_info_t **ppaFixups) 2213 2213 { 2214 2214 macho_relocation_info_t *paFixups; 2215 size_tcbFixups;2215 KSIZE cbFixups; 2216 2216 int rc; 2217 2217 … … 2234 2234 || pModMachO->Hdr.magic == IMAGE_MACHO64_SIGNATURE_OE) 2235 2235 { 2236 uint32_tiFixup;2236 KU32 iFixup; 2237 2237 for (iFixup = 0; iFixup < cFixups; iFixup++) 2238 2238 { 2239 uint32_t *pu32 = (uint32_t*)&paFixups[iFixup];2239 KU32 *pu32 = (KU32 *)&paFixups[iFixup]; 2240 2240 pu32[0] = KLDR_E2E_U32(pu32[0]); 2241 2241 pu32[1] = KLDR_E2E_U32(pu32[1]); … … 2265 2265 2266 2266 /** @copydoc kLdrModCallInit */ 2267 static int kldrModMachOCallInit(PKLDRMOD pMod, uintptr_tuHandle)2267 static int kldrModMachOCallInit(PKLDRMOD pMod, KUPTR uHandle) 2268 2268 { 2269 2269 /* later */ … … 2273 2273 2274 2274 /** @copydoc kLdrModCallTerm */ 2275 static int kldrModMachOCallTerm(PKLDRMOD pMod, uintptr_tuHandle)2275 static int kldrModMachOCallTerm(PKLDRMOD pMod, KUPTR uHandle) 2276 2276 { 2277 2277 /* later */ … … 2281 2281 2282 2282 /** @copydoc kLdrModCallThread */ 2283 static int kldrModMachOCallThread(PKLDRMOD pMod, uintptr_tuHandle, unsigned fAttachingOrDetaching)2283 static int kldrModMachOCallThread(PKLDRMOD pMod, KUPTR uHandle, unsigned fAttachingOrDetaching) 2284 2284 { 2285 2285 /* Relevant for Mach-O? */ … … 2300 2300 { 2301 2301 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; 2302 uint32_ti;2302 KU32 i; 2303 2303 int rc; 2304 2304 … … 2306 2306 * Zero the entire buffer first to simplify things. 2307 2307 */ 2308 kLdrHlpMemSet(pvBits, 0, ( size_t)pModMachO->cbImage);2308 kLdrHlpMemSet(pvBits, 0, (KSIZE)pModMachO->cbImage); 2309 2309 2310 2310 /* … … 2325 2325 continue; 2326 2326 rc = kLdrRdrRead(pMod->pRdr, 2327 ( uint8_t*)pvBits + (pMod->aSegments[i].LinkAddress - pModMachO->LinkAddress),2327 (KU8 *)pvBits + (pMod->aSegments[i].LinkAddress - pModMachO->LinkAddress), 2328 2328 pMod->aSegments[i].cbFile, 2329 2329 pMod->aSegments[i].offFile); -
trunk/kStuff/kLdr/kLdrModMachO.h
r3537 r3567 16 16 #ifndef IMAGE_FAT_SIGNATURE 17 17 /** The FAT signature (universal binaries). */ 18 # define IMAGE_FAT_SIGNATURE UINT32_C(0xcafebabe)18 # define IMAGE_FAT_SIGNATURE KU32_C(0xcafebabe) 19 19 #endif 20 20 #ifndef IMAGE_FAT_SIGNATURE_OE 21 21 /** The FAT signature (universal binaries), other endian. */ 22 # define IMAGE_FAT_SIGNATURE_OE UINT32_C(0xbebafeca)22 # define IMAGE_FAT_SIGNATURE_OE KU32_C(0xbebafeca) 23 23 #endif 24 24 … … 29 29 typedef struct fat_header 30 30 { 31 uint32_tmagic;32 uint32_tnfat_arch;31 KU32 magic; 32 KU32 nfat_arch; 33 33 } fat_header_t; 34 34 … … 38 38 typedef struct fat_arch 39 39 { 40 int32_tcputype;41 int32_tcpusubtype;42 uint32_toffset;43 uint32_tsize;44 uint32_talign; /**< Power of 2. */40 KI32 cputype; 41 KI32 cpusubtype; 42 KU32 offset; 43 KU32 size; 44 KU32 align; /**< Power of 2. */ 45 45 } fat_arch_t; 46 46 … … 49 49 #ifndef IMAGE_MACHO32_SIGNATURE 50 50 /** The 32-bit Mach-O signature. */ 51 # define IMAGE_MACHO32_SIGNATURE UINT32_C(0xfeedface)51 # define IMAGE_MACHO32_SIGNATURE KU32_C(0xfeedface) 52 52 #endif 53 53 #ifndef IMAGE_MACHO32_SIGNATURE_OE 54 54 /** The 32-bit Mach-O signature, other endian. */ 55 # define IMAGE_MACHO32_SIGNATURE_OE UINT32_C(0xcefaedfe)55 # define IMAGE_MACHO32_SIGNATURE_OE KU32_C(0xcefaedfe) 56 56 #endif 57 57 #define MH_MAGIC IMAGE_MACHO32_SIGNATURE … … 65 65 typedef struct mach_header_32 66 66 { 67 uint32_tmagic;68 int32_tcputype;69 int32_tcpusubtype;70 uint32_tfiletype;71 uint32_tncmds;72 uint32_tsizeofcmds;73 uint32_tflags;67 KU32 magic; 68 KI32 cputype; 69 KI32 cpusubtype; 70 KU32 filetype; 71 KU32 ncmds; 72 KU32 sizeofcmds; 73 KU32 flags; 74 74 } mach_header_32_t; 75 75 … … 78 78 #ifndef IMAGE_MACHO64_SIGNATURE 79 79 /** The 64-bit Mach-O signature. */ 80 # define IMAGE_MACHO64_SIGNATURE UINT32_C(0xfeedfacf)80 # define IMAGE_MACHO64_SIGNATURE KU32_C(0xfeedfacf) 81 81 #endif 82 82 #ifndef IMAGE_MACHO64_SIGNATURE_OE 83 83 /** The 64-bit Mach-O signature, other endian. */ 84 # define IMAGE_MACHO64_SIGNATURE_OE UINT32_C(0xfefaedfe)84 # define IMAGE_MACHO64_SIGNATURE_OE KU32_C(0xfefaedfe) 85 85 #endif 86 86 #define MH_MAGIC_64 IMAGE_MACHO64_SIGNATURE … … 94 94 typedef struct mach_header_64 95 95 { 96 uint32_tmagic;97 int32_tcputype;98 int32_tcpusubtype;99 uint32_tfiletype;100 uint32_tncmds;101 uint32_tsizeofcmds;102 uint32_tflags;103 uint32_treserved; /**< (for proper struct and command alignment I guess) */96 KU32 magic; 97 KI32 cputype; 98 KI32 cpusubtype; 99 KU32 filetype; 100 KU32 ncmds; 101 KU32 sizeofcmds; 102 KU32 flags; 103 KU32 reserved; /**< (for proper struct and command alignment I guess) */ 104 104 } mach_header_64_t; 105 105 … … 108 108 * @{ 109 109 */ 110 #define MH_OBJECT UINT32_C(1) /**< Object (relocatable). */111 #define MH_EXECUTE UINT32_C(2) /**< Executable (demand paged). */112 #define MH_FVMLIB UINT32_C(3) /**< Fixed VM shared library. */113 #define MH_CORE UINT32_C(4) /**< Core file. */114 #define MH_PRELOAD UINT32_C(5) /**< Preloaded executable. */115 #define MH_DYLIB UINT32_C(6) /**< Dynamically bound shared library. */116 #define MH_DYLINKER UINT32_C(7) /**< Dynamic linker. */117 #define MH_BUNDLE UINT32_C(8) /**< Dymamically bound bundle. */118 #define MH_DYLIB_STUB UINT32_C(9) /**< Shared library stub for static linking. */119 #define MH_DSYM UINT32_C(10)/**< Debug symbols. */110 #define MH_OBJECT KU32_C(1) /**< Object (relocatable). */ 111 #define MH_EXECUTE KU32_C(2) /**< Executable (demand paged). */ 112 #define MH_FVMLIB KU32_C(3) /**< Fixed VM shared library. */ 113 #define MH_CORE KU32_C(4) /**< Core file. */ 114 #define MH_PRELOAD KU32_C(5) /**< Preloaded executable. */ 115 #define MH_DYLIB KU32_C(6) /**< Dynamically bound shared library. */ 116 #define MH_DYLINKER KU32_C(7) /**< Dynamic linker. */ 117 #define MH_BUNDLE KU32_C(8) /**< Dymamically bound bundle. */ 118 #define MH_DYLIB_STUB KU32_C(9) /**< Shared library stub for static linking. */ 119 #define MH_DSYM KU32_C(10)/**< Debug symbols. */ 120 120 121 121 /** @} */ … … 125 125 * @{ 126 126 */ 127 #define MH_NOUNDEFS UINT32_C(0x00000001) /**< No undefined symbols. */128 #define MH_INCRLINK UINT32_C(0x00000002) /**< Partial increment link output. */129 #define MH_DYLDLINK UINT32_C(0x00000004) /**< Food for the dynamic linker, not for ld. */130 #define MH_BINDATLOAD UINT32_C(0x00000008) /**< Bind all undefined symbols at load time. */131 #define MH_PREBOUND UINT32_C(0x00000010) /**< Contains prebound undefined symbols. */132 #define MH_SPLIT_SEGS UINT32_C(0x00000020) /**< Read-only and read-write segments are split. */133 #define MH_LAZY_INIT UINT32_C(0x00000040) /**< Obsolete flag for doing lazy init when data is written. */134 #define MH_TWOLEVEL UINT32_C(0x00000080) /**< Uses two-level name space bindings. */135 #define MH_FORCE_FLAT UINT32_C(0x00000100) /**< Task: The executable forces all images to use flat name space bindings. */136 #define MH_NOMULTIDEFS UINT32_C(0x00000200) /**< No multiple symbol definitions, safe to use two-level namespace hints. */137 #define MH_NOFIXPREBINDING UINT32_C(0x00000400) /**< The dynamic linker should not notify the prebinding agent about this executable. */138 #define MH_PREBINDABLE UINT32_C(0x00000800) /**< Not prebound, but it can be. Invalid if MH_PREBOUND is set. */139 #define MH_ALLMODSBOUND UINT32_C(0x00001000) /**< Binds to all two-level namespace modules of preqs. Requires MH_PREBINDABLE and MH_TWOLEVEL to be set. */140 #define MH_SUBSECTIONS_VIA_SYMBOLS UINT32_C(0x00002000) /**< Safe to divide sections into sub-sections via symbols for dead code stripping. */141 #define MH_CANONICAL UINT32_C(0x00004000) /**< Canonicalized via unprebind. */142 #define MH_WEAK_DEFINES UINT32_C(0x00008000) /**< The (finally) linked image has weak symbols. */143 #define MH_BINDS_TO_WEAK UINT32_C(0x00010000) /**< The (finally) linked image uses weak symbols. */144 #define MH_ALLOW_STACK_EXECUTION UINT32_C(0x00020000) /**< Task: allow stack execution. (MH_EXECUTE only) */145 #define MH_VALID_FLAGS UINT32_C(0x0003ffff) /**< Mask containing the defined flags. */127 #define MH_NOUNDEFS KU32_C(0x00000001) /**< No undefined symbols. */ 128 #define MH_INCRLINK KU32_C(0x00000002) /**< Partial increment link output. */ 129 #define MH_DYLDLINK KU32_C(0x00000004) /**< Food for the dynamic linker, not for ld. */ 130 #define MH_BINDATLOAD KU32_C(0x00000008) /**< Bind all undefined symbols at load time. */ 131 #define MH_PREBOUND KU32_C(0x00000010) /**< Contains prebound undefined symbols. */ 132 #define MH_SPLIT_SEGS KU32_C(0x00000020) /**< Read-only and read-write segments are split. */ 133 #define MH_LAZY_INIT KU32_C(0x00000040) /**< Obsolete flag for doing lazy init when data is written. */ 134 #define MH_TWOLEVEL KU32_C(0x00000080) /**< Uses two-level name space bindings. */ 135 #define MH_FORCE_FLAT KU32_C(0x00000100) /**< Task: The executable forces all images to use flat name space bindings. */ 136 #define MH_NOMULTIDEFS KU32_C(0x00000200) /**< No multiple symbol definitions, safe to use two-level namespace hints. */ 137 #define MH_NOFIXPREBINDING KU32_C(0x00000400) /**< The dynamic linker should not notify the prebinding agent about this executable. */ 138 #define MH_PREBINDABLE KU32_C(0x00000800) /**< Not prebound, but it can be. Invalid if MH_PREBOUND is set. */ 139 #define MH_ALLMODSBOUND KU32_C(0x00001000) /**< Binds to all two-level namespace modules of preqs. Requires MH_PREBINDABLE and MH_TWOLEVEL to be set. */ 140 #define MH_SUBSECTIONS_VIA_SYMBOLS KU32_C(0x00002000) /**< Safe to divide sections into sub-sections via symbols for dead code stripping. */ 141 #define MH_CANONICAL KU32_C(0x00004000) /**< Canonicalized via unprebind. */ 142 #define MH_WEAK_DEFINES KU32_C(0x00008000) /**< The (finally) linked image has weak symbols. */ 143 #define MH_BINDS_TO_WEAK KU32_C(0x00010000) /**< The (finally) linked image uses weak symbols. */ 144 #define MH_ALLOW_STACK_EXECUTION KU32_C(0x00020000) /**< Task: allow stack execution. (MH_EXECUTE only) */ 145 #define MH_VALID_FLAGS KU32_C(0x0003ffff) /**< Mask containing the defined flags. */ 146 146 /** @} */ 147 147 … … 150 150 * @{ 151 151 */ 152 #define CPU_ARCH_MASK INT32_C(0xff000000)153 #define CPU_ARCH_ABI64 INT32_C(0x01000000)154 #define CPU_TYPE_ANY INT32_C(-1)155 #define CPU_TYPE_VAX INT32_C(1)156 #define CPU_TYPE_MC680x0 INT32_C(6)157 #define CPU_TYPE_X86 INT32_C(7)152 #define CPU_ARCH_MASK KI32_C(0xff000000) 153 #define CPU_ARCH_ABI64 KI32_C(0x01000000) 154 #define CPU_TYPE_ANY KI32_C(-1) 155 #define CPU_TYPE_VAX KI32_C(1) 156 #define CPU_TYPE_MC680x0 KI32_C(6) 157 #define CPU_TYPE_X86 KI32_C(7) 158 158 #define CPU_TYPE_I386 CPU_TYPE_X86 159 159 #define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64) 160 #define CPU_TYPE_MC98000 INT32_C(10)161 #define CPU_TYPE_HPPA INT32_C(11)162 #define CPU_TYPE_MC88000 INT32_C(13)163 #define CPU_TYPE_SPARC INT32_C(14)164 #define CPU_TYPE_I860 INT32_C(15)165 #define CPU_TYPE_POWERPC INT32_C(18)160 #define CPU_TYPE_MC98000 KI32_C(10) 161 #define CPU_TYPE_HPPA KI32_C(11) 162 #define CPU_TYPE_MC88000 KI32_C(13) 163 #define CPU_TYPE_SPARC KI32_C(14) 164 #define CPU_TYPE_I860 KI32_C(15) 165 #define CPU_TYPE_POWERPC KI32_C(18) 166 166 #define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64) 167 167 /** @} */ … … 170 170 /** @name CPU subtypes (mach_header_64::cpusubtype, mach_header_32::cpusubtype, fat_arch::cpusubtype) 171 171 * @{ */ 172 #define CPU_SUBTYPE_MULTIPLE INT32_C(-1)173 #define CPU_SUBTYPE_LITTLE_ENDIAN INT32_C(0) /**< figure this one out. */174 #define CPU_SUBTYPE_BIG_ENDIAN INT32_C(1) /**< ditto */172 #define CPU_SUBTYPE_MULTIPLE KI32_C(-1) 173 #define CPU_SUBTYPE_LITTLE_ENDIAN KI32_C(0) /**< figure this one out. */ 174 #define CPU_SUBTYPE_BIG_ENDIAN KI32_C(1) /**< ditto */ 175 175 176 176 /* VAX */ 177 #define CPU_SUBTYPE_VAX_ALL INT32_C(0)178 #define CPU_SUBTYPE_VAX780 INT32_C(1)179 #define CPU_SUBTYPE_VAX785 INT32_C(2)180 #define CPU_SUBTYPE_VAX750 INT32_C(3)181 #define CPU_SUBTYPE_VAX730 INT32_C(4)182 #define CPU_SUBTYPE_UVAXI INT32_C(5)183 #define CPU_SUBTYPE_UVAXII INT32_C(6)184 #define CPU_SUBTYPE_VAX8200 INT32_C(7)185 #define CPU_SUBTYPE_VAX8500 INT32_C(8)186 #define CPU_SUBTYPE_VAX8600 INT32_C(9)187 #define CPU_SUBTYPE_VAX8650 INT32_C(10)188 #define CPU_SUBTYPE_VAX8800 INT32_C(11)189 #define CPU_SUBTYPE_UVAXIII INT32_C(12)177 #define CPU_SUBTYPE_VAX_ALL KI32_C(0) 178 #define CPU_SUBTYPE_VAX780 KI32_C(1) 179 #define CPU_SUBTYPE_VAX785 KI32_C(2) 180 #define CPU_SUBTYPE_VAX750 KI32_C(3) 181 #define CPU_SUBTYPE_VAX730 KI32_C(4) 182 #define CPU_SUBTYPE_UVAXI KI32_C(5) 183 #define CPU_SUBTYPE_UVAXII KI32_C(6) 184 #define CPU_SUBTYPE_VAX8200 KI32_C(7) 185 #define CPU_SUBTYPE_VAX8500 KI32_C(8) 186 #define CPU_SUBTYPE_VAX8600 KI32_C(9) 187 #define CPU_SUBTYPE_VAX8650 KI32_C(10) 188 #define CPU_SUBTYPE_VAX8800 KI32_C(11) 189 #define CPU_SUBTYPE_UVAXIII KI32_C(12) 190 190 191 191 /* MC680xx */ 192 #define CPU_SUBTYPE_MC680x0_ALL INT32_C(1)193 #define CPU_SUBTYPE_MC68030 INT32_C(1)194 #define CPU_SUBTYPE_MC68040 INT32_C(2)195 #define CPU_SUBTYPE_MC68030_ONLY INT32_C(3)192 #define CPU_SUBTYPE_MC680x0_ALL KI32_C(1) 193 #define CPU_SUBTYPE_MC68030 KI32_C(1) 194 #define CPU_SUBTYPE_MC68040 KI32_C(2) 195 #define CPU_SUBTYPE_MC68030_ONLY KI32_C(3) 196 196 197 197 /* I386 */ 198 #define CPU_SUBTYPE_INTEL(fam, model) ( ( int32_t)(((model) << 4) | (fam)) )198 #define CPU_SUBTYPE_INTEL(fam, model) ( (KI32)(((model) << 4) | (fam)) ) 199 199 #define CPU_SUBTYPE_INTEL_FAMILY(subtype) ( (subtype) & 0xf ) 200 200 #define CPU_SUBTYPE_INTEL_MODEL(subtype) ( (subtype) >> 4 ) … … 225 225 226 226 /* X86 */ 227 #define CPU_SUBTYPE_X86_ALL INT32_C(3) /* CPU_SUBTYPE_I386_ALL */228 #define CPU_SUBTYPE_X86_64_ALL INT32_C(3) /* CPU_SUBTYPE_I386_ALL */229 #define CPU_SUBTYPE_X86_ARCH1 INT32_C(4) /* CPU_SUBTYPE_I486_ALL */227 #define CPU_SUBTYPE_X86_ALL KI32_C(3) /* CPU_SUBTYPE_I386_ALL */ 228 #define CPU_SUBTYPE_X86_64_ALL KI32_C(3) /* CPU_SUBTYPE_I386_ALL */ 229 #define CPU_SUBTYPE_X86_ARCH1 KI32_C(4) /* CPU_SUBTYPE_I486_ALL */ 230 230 231 231 /* MIPS */ 232 #define CPU_SUBTYPE_MIPS_ALL INT32_C(0)233 #define CPU_SUBTYPE_MIPS_R2300 INT32_C(1)234 #define CPU_SUBTYPE_MIPS_R2600 INT32_C(2)235 #define CPU_SUBTYPE_MIPS_R2800 INT32_C(3)236 #define CPU_SUBTYPE_MIPS_R2000a INT32_C(4)237 #define CPU_SUBTYPE_MIPS_R2000 INT32_C(5)238 #define CPU_SUBTYPE_MIPS_R3000a INT32_C(6)239 #define CPU_SUBTYPE_MIPS_R3000 INT32_C(7)232 #define CPU_SUBTYPE_MIPS_ALL KI32_C(0) 233 #define CPU_SUBTYPE_MIPS_R2300 KI32_C(1) 234 #define CPU_SUBTYPE_MIPS_R2600 KI32_C(2) 235 #define CPU_SUBTYPE_MIPS_R2800 KI32_C(3) 236 #define CPU_SUBTYPE_MIPS_R2000a KI32_C(4) 237 #define CPU_SUBTYPE_MIPS_R2000 KI32_C(5) 238 #define CPU_SUBTYPE_MIPS_R3000a KI32_C(6) 239 #define CPU_SUBTYPE_MIPS_R3000 KI32_C(7) 240 240 241 241 /* MC98000 (PowerPC) */ 242 #define CPU_SUBTYPE_MC98000_ALL INT32_C(0)243 #define CPU_SUBTYPE_MC98601 INT32_C(1)242 #define CPU_SUBTYPE_MC98000_ALL KI32_C(0) 243 #define CPU_SUBTYPE_MC98601 KI32_C(1) 244 244 245 245 /* HP-PA */ 246 #define CPU_SUBTYPE_HPPA_ALL INT32_C(0)247 #define CPU_SUBTYPE_HPPA_7100 INT32_C(0)248 #define CPU_SUBTYPE_HPPA_7100LC INT32_C(1)246 #define CPU_SUBTYPE_HPPA_ALL KI32_C(0) 247 #define CPU_SUBTYPE_HPPA_7100 KI32_C(0) 248 #define CPU_SUBTYPE_HPPA_7100LC KI32_C(1) 249 249 250 250 /* MC88000 */ 251 #define CPU_SUBTYPE_MC88000_ALL INT32_C(0)252 #define CPU_SUBTYPE_MC88100 INT32_C(1)253 #define CPU_SUBTYPE_MC88110 INT32_C(2)251 #define CPU_SUBTYPE_MC88000_ALL KI32_C(0) 252 #define CPU_SUBTYPE_MC88100 KI32_C(1) 253 #define CPU_SUBTYPE_MC88110 KI32_C(2) 254 254 255 255 /* SPARC */ 256 #define CPU_SUBTYPE_SPARC_ALL INT32_C(0)256 #define CPU_SUBTYPE_SPARC_ALL KI32_C(0) 257 257 258 258 /* I860 */ 259 #define CPU_SUBTYPE_I860_ALL INT32_C(0)260 #define CPU_SUBTYPE_I860_860 INT32_C(1)259 #define CPU_SUBTYPE_I860_ALL KI32_C(0) 260 #define CPU_SUBTYPE_I860_860 KI32_C(1) 261 261 262 262 /* PowerPC */ 263 #define CPU_SUBTYPE_POWERPC_ALL INT32_C(0)264 #define CPU_SUBTYPE_POWERPC_601 INT32_C(1)265 #define CPU_SUBTYPE_POWERPC_602 INT32_C(2)266 #define CPU_SUBTYPE_POWERPC_603 INT32_C(3)267 #define CPU_SUBTYPE_POWERPC_603e INT32_C(4)268 #define CPU_SUBTYPE_POWERPC_603ev INT32_C(5)269 #define CPU_SUBTYPE_POWERPC_604 INT32_C(6)270 #define CPU_SUBTYPE_POWERPC_604e INT32_C(7)271 #define CPU_SUBTYPE_POWERPC_620 INT32_C(8)272 #define CPU_SUBTYPE_POWERPC_750 INT32_C(9)273 #define CPU_SUBTYPE_POWERPC_7400 INT32_C(10)274 #define CPU_SUBTYPE_POWERPC_7450 INT32_C(11)275 #define CPU_SUBTYPE_POWERPC_Max INT32_C(10)276 #define CPU_SUBTYPE_POWERPC_SCVger INT32_C(11)277 #define CPU_SUBTYPE_POWERPC_970 INT32_C(100)263 #define CPU_SUBTYPE_POWERPC_ALL KI32_C(0) 264 #define CPU_SUBTYPE_POWERPC_601 KI32_C(1) 265 #define CPU_SUBTYPE_POWERPC_602 KI32_C(2) 266 #define CPU_SUBTYPE_POWERPC_603 KI32_C(3) 267 #define CPU_SUBTYPE_POWERPC_603e KI32_C(4) 268 #define CPU_SUBTYPE_POWERPC_603ev KI32_C(5) 269 #define CPU_SUBTYPE_POWERPC_604 KI32_C(6) 270 #define CPU_SUBTYPE_POWERPC_604e KI32_C(7) 271 #define CPU_SUBTYPE_POWERPC_620 KI32_C(8) 272 #define CPU_SUBTYPE_POWERPC_750 KI32_C(9) 273 #define CPU_SUBTYPE_POWERPC_7400 KI32_C(10) 274 #define CPU_SUBTYPE_POWERPC_7450 KI32_C(11) 275 #define CPU_SUBTYPE_POWERPC_Max KI32_C(10) 276 #define CPU_SUBTYPE_POWERPC_SCVger KI32_C(11) 277 #define CPU_SUBTYPE_POWERPC_970 KI32_C(100) 278 278 279 279 /** @} */ … … 292 292 typedef struct load_command 293 293 { 294 uint32_tcmd; /**< The load command id. */295 uint32_tcmdsize; /**< The size of the command (including this header). */294 KU32 cmd; /**< The load command id. */ 295 KU32 cmdsize; /**< The size of the command (including this header). */ 296 296 } load_command_t; 297 297 … … 302 302 * grok the command. The dynamic linker will otherwise ignore commands it 303 303 * doesn't understand. Introduced with Mac OS X 10.1. */ 304 #define LC_REQ_DYLD UINT32_C(0x80000000)305 306 #define LC_SEGMENT_32 UINT32_C(0x01) /**< Segment to be mapped (32-bit). See segment_command_32. */307 #define LC_SYMTAB UINT32_C(0x02) /**< 'stab' symbol table. See symtab_command. */308 #define LC_SYMSEG UINT32_C(0x03) /**< Obsoleted gdb symbol table. */309 #define LC_THREAD UINT32_C(0x04) /**< Thread. See thread_command. */310 #define LC_UNIXTHREAD UINT32_C(0x05) /**< Unix thread (includes stack and stuff). See thread_command. */311 #define LC_LOADFVMLIB UINT32_C(0x06) /**< Load a specified fixed VM shared library (obsolete?). See fvmlib_command. */312 #define LC_IDFVMLIB UINT32_C(0x07) /**< Fixed VM shared library id (obsolete?). See fvmlib_command. */313 #define LC_IDENT UINT32_C(0x08) /**< Identification info (obsolete). See ident_command. */314 #define LC_FVMFILE UINT32_C(0x09) /**< Fixed VM file inclusion (internal). See fvmfile_command. */315 #define LC_PREPAGE UINT32_C(0x0a) /**< Prepage command (internal). See ?? */316 #define LC_DYSYMTAB UINT32_C(0x0b) /**< Symbol table for dynamic linking. See dysymtab_command. */317 #define LC_LOAD_DYLIB UINT32_C(0x0c) /**< Load a dynamically linked shared library. See dylib_command. */318 #define LC_ID_DYLIB UINT32_C(0x0d) /**< Dynamically linked share library ident. See dylib_command. */319 #define LC_LOAD_DYLINKER UINT32_C(0x0e) /**< Load a dynamical link editor. See dylinker_command. */320 #define LC_ID_DYLINKER UINT32_C(0x0f) /**< Dynamic link editor ident. See dylinker_command. */321 #define LC_PREBOUND_DYLIB UINT32_C(0x10) /**< Prebound modules for dynamically linking of a shared lib. See prebound_dylib_command. */322 #define LC_ROUTINES UINT32_C(0x11) /**< Image routines. See routines_command_32. */323 #define LC_SUB_FRAMEWORK UINT32_C(0x12) /**< Sub framework. See sub_framework_command. */324 #define LC_SUB_UMBRELLA UINT32_C(0x13) /**< Sub umbrella. See sub_umbrella_command. */325 #define LC_SUB_CLIENT UINT32_C(0x14) /**< Sub client. See sub_client_command. */326 #define LC_SUB_LIBRARY UINT32_C(0x15) /**< Sub library. See sub_library_command. */327 #define LC_TWOLEVEL_HINTS UINT32_C(0x16) /**< Two-level namespace lookup hints. See twolevel_hints_command. */328 #define LC_PREBIND_CKSUM UINT32_C(0x17) /**< Prebind checksum. See prebind_cksum_command. */329 #define LC_LOAD_WEAK_DYLIB ( UINT32_C(0x18) | LC_REQ_DYLD) /**< Dylib that can be missing, all symbols weak. See dylib_command. */330 #define LC_SEGMENT_64 UINT32_C(0x19) /**< segment to be mapped (64-bit). See segment_command_32. */331 #define LC_ROUTINES_64 UINT32_C(0x1a) /**< Image routines (64-bit). See routines_command_32. */332 #define LC_UUID UINT32_C(0x1b) /**< The UUID of the object module. See uuid_command. */304 #define LC_REQ_DYLD KU32_C(0x80000000) 305 306 #define LC_SEGMENT_32 KU32_C(0x01) /**< Segment to be mapped (32-bit). See segment_command_32. */ 307 #define LC_SYMTAB KU32_C(0x02) /**< 'stab' symbol table. See symtab_command. */ 308 #define LC_SYMSEG KU32_C(0x03) /**< Obsoleted gdb symbol table. */ 309 #define LC_THREAD KU32_C(0x04) /**< Thread. See thread_command. */ 310 #define LC_UNIXTHREAD KU32_C(0x05) /**< Unix thread (includes stack and stuff). See thread_command. */ 311 #define LC_LOADFVMLIB KU32_C(0x06) /**< Load a specified fixed VM shared library (obsolete?). See fvmlib_command. */ 312 #define LC_IDFVMLIB KU32_C(0x07) /**< Fixed VM shared library id (obsolete?). See fvmlib_command. */ 313 #define LC_IDENT KU32_C(0x08) /**< Identification info (obsolete). See ident_command. */ 314 #define LC_FVMFILE KU32_C(0x09) /**< Fixed VM file inclusion (internal). See fvmfile_command. */ 315 #define LC_PREPAGE KU32_C(0x0a) /**< Prepage command (internal). See ?? */ 316 #define LC_DYSYMTAB KU32_C(0x0b) /**< Symbol table for dynamic linking. See dysymtab_command. */ 317 #define LC_LOAD_DYLIB KU32_C(0x0c) /**< Load a dynamically linked shared library. See dylib_command. */ 318 #define LC_ID_DYLIB KU32_C(0x0d) /**< Dynamically linked share library ident. See dylib_command. */ 319 #define LC_LOAD_DYLINKER KU32_C(0x0e) /**< Load a dynamical link editor. See dylinker_command. */ 320 #define LC_ID_DYLINKER KU32_C(0x0f) /**< Dynamic link editor ident. See dylinker_command. */ 321 #define LC_PREBOUND_DYLIB KU32_C(0x10) /**< Prebound modules for dynamically linking of a shared lib. See prebound_dylib_command. */ 322 #define LC_ROUTINES KU32_C(0x11) /**< Image routines. See routines_command_32. */ 323 #define LC_SUB_FRAMEWORK KU32_C(0x12) /**< Sub framework. See sub_framework_command. */ 324 #define LC_SUB_UMBRELLA KU32_C(0x13) /**< Sub umbrella. See sub_umbrella_command. */ 325 #define LC_SUB_CLIENT KU32_C(0x14) /**< Sub client. See sub_client_command. */ 326 #define LC_SUB_LIBRARY KU32_C(0x15) /**< Sub library. See sub_library_command. */ 327 #define LC_TWOLEVEL_HINTS KU32_C(0x16) /**< Two-level namespace lookup hints. See twolevel_hints_command. */ 328 #define LC_PREBIND_CKSUM KU32_C(0x17) /**< Prebind checksum. See prebind_cksum_command. */ 329 #define LC_LOAD_WEAK_DYLIB (KU32_C(0x18) | LC_REQ_DYLD) /**< Dylib that can be missing, all symbols weak. See dylib_command. */ 330 #define LC_SEGMENT_64 KU32_C(0x19) /**< segment to be mapped (64-bit). See segment_command_32. */ 331 #define LC_ROUTINES_64 KU32_C(0x1a) /**< Image routines (64-bit). See routines_command_32. */ 332 #define LC_UUID KU32_C(0x1b) /**< The UUID of the object module. See uuid_command. */ 333 333 /** @} */ 334 334 … … 342 342 * The string is zero-terminated. the size of the load command 343 343 * is zero padded up to a multiple of 4 bytes. */ 344 uint32_toffset;344 KU32 offset; 345 345 } lc_str_t; 346 346 … … 351 351 typedef struct segment_command_32 352 352 { 353 uint32_tcmd; /**< LC_SEGMENT */354 uint32_tcmdsize; /**< sizeof(self) + sections. */353 KU32 cmd; /**< LC_SEGMENT */ 354 KU32 cmdsize; /**< sizeof(self) + sections. */ 355 355 char segname[16]; /**< The segment name. */ 356 uint32_tvmaddr; /**< Memory address of this segment. */357 uint32_tvmsize; /**< Size of this segment. */358 uint32_tfileoff; /**< The file location of the segment. */359 uint32_tfilesize; /**< The file size of the segment. */360 uint32_tmaxprot; /**< Maximum VM protection. */361 uint32_tinitprot; /**< Initial VM protection. */362 uint32_tnsects; /**< Number of section desciptors following this structure. */363 uint32_tflags; /**< Flags (SG_*). */356 KU32 vmaddr; /**< Memory address of this segment. */ 357 KU32 vmsize; /**< Size of this segment. */ 358 KU32 fileoff; /**< The file location of the segment. */ 359 KU32 filesize; /**< The file size of the segment. */ 360 KU32 maxprot; /**< Maximum VM protection. */ 361 KU32 initprot; /**< Initial VM protection. */ 362 KU32 nsects; /**< Number of section desciptors following this structure. */ 363 KU32 flags; /**< Flags (SG_*). */ 364 364 } segment_command_32_t; 365 365 … … 371 371 typedef struct segment_command_64 372 372 { 373 uint32_tcmd; /**< LC_SEGMENT */374 uint32_tcmdsize; /**< sizeof(self) + sections. */373 KU32 cmd; /**< LC_SEGMENT */ 374 KU32 cmdsize; /**< sizeof(self) + sections. */ 375 375 char segname[16]; /**< The segment name. */ 376 uint64_tvmaddr; /**< Memory address of this segment. */377 uint64_tvmsize; /**< Size of this segment. */378 uint64_tfileoff; /**< The file location of the segment. */379 uint64_tfilesize; /**< The file size of the segment. */380 uint32_tmaxprot; /**< Maximum VM protection. */381 uint32_tinitprot; /**< Initial VM protection. */382 uint32_tnsects; /**< Number of section desciptors following this structure. */383 uint32_tflags; /**< Flags (SG_*). */376 KU64 vmaddr; /**< Memory address of this segment. */ 377 KU64 vmsize; /**< Size of this segment. */ 378 KU64 fileoff; /**< The file location of the segment. */ 379 KU64 filesize; /**< The file size of the segment. */ 380 KU32 maxprot; /**< Maximum VM protection. */ 381 KU32 initprot; /**< Initial VM protection. */ 382 KU32 nsects; /**< Number of section desciptors following this structure. */ 383 KU32 flags; /**< Flags (SG_*). */ 384 384 } segment_command_64_t; 385 385 … … 389 389 * instead of the low end. Intended for stacks in core dumps. 390 390 * The part of the segment memory not covered by file bits will be zeroed. */ 391 #define SG_HIGHVM UINT32_C(0x00000001)391 #define SG_HIGHVM KU32_C(0x00000001) 392 392 /** This segment is the virtual memory allocated by a fixed VM library. 393 393 * (Used for overlap checking in the linker.) */ 394 #define SG_FVMLIB UINT32_C(0x00000002)394 #define SG_FVMLIB KU32_C(0x00000002) 395 395 /** No relocations for or symbols that's relocated to in this segment. 396 396 * The segment can therefore safely be replaced. */ 397 #define SG_NORELOC UINT32_C(0x00000004)397 #define SG_NORELOC KU32_C(0x00000004) 398 398 /** The segment is protected. 399 399 * The first page isn't protected if it starts at file offset 0 400 400 * (so that the mach header and this load command can be easily mapped). */ 401 #define SG_PROTECTED_VERSION_1 UINT32_C(0x00000008)401 #define SG_PROTECTED_VERSION_1 KU32_C(0x00000008) 402 402 /** @} */ 403 403 … … 410 410 char sectname[16]; /**< The section name. */ 411 411 char segname[16]; /**< The name of the segment this section goes into. */ 412 uint32_taddr; /**< The memory address of this section. */413 uint32_tsize; /**< The size of this section. */414 uint32_toffset; /**< The file offset of this section. */415 uint32_talign; /**< The section alignment (**2). */416 uint32_treloff; /**< The file offset of the relocations. */417 uint32_tnreloc; /**< The number of relocations. */418 uint32_tflags; /**< The section flags; section type and attribs */419 uint32_treserved1; /**< Reserved / offset / index. */420 uint32_treserved2; /**< Reserved / count / sizeof. */412 KU32 addr; /**< The memory address of this section. */ 413 KU32 size; /**< The size of this section. */ 414 KU32 offset; /**< The file offset of this section. */ 415 KU32 align; /**< The section alignment (**2). */ 416 KU32 reloff; /**< The file offset of the relocations. */ 417 KU32 nreloc; /**< The number of relocations. */ 418 KU32 flags; /**< The section flags; section type and attribs */ 419 KU32 reserved1; /**< Reserved / offset / index. */ 420 KU32 reserved2; /**< Reserved / count / sizeof. */ 421 421 } section_32_t; 422 422 … … 428 428 char sectname[16]; /**< The section name. */ 429 429 char segname[16]; /**< The name of the segment this section goes into. */ 430 uint64_taddr; /**< The memory address of this section. */431 uint64_tsize; /**< The size of this section. */432 uint32_toffset; /**< The file offset of this section. */433 uint32_talign; /**< The section alignment (**2). */434 uint32_treloff; /**< The file offset of the relocations. */435 uint32_tnreloc; /**< The number of relocations. */436 uint32_tflags; /**< The section flags; section type and attribs */437 uint32_treserved1; /**< Reserved / offset / index. */438 uint32_treserved2; /**< Reserved / count / sizeof. */439 uint32_treserved3; /**< (Just) Reserved. */430 KU64 addr; /**< The memory address of this section. */ 431 KU64 size; /**< The size of this section. */ 432 KU32 offset; /**< The file offset of this section. */ 433 KU32 align; /**< The section alignment (**2). */ 434 KU32 reloff; /**< The file offset of the relocations. */ 435 KU32 nreloc; /**< The number of relocations. */ 436 KU32 flags; /**< The section flags; section type and attribs */ 437 KU32 reserved1; /**< Reserved / offset / index. */ 438 KU32 reserved2; /**< Reserved / count / sizeof. */ 439 KU32 reserved3; /**< (Just) Reserved. */ 440 440 } section_64_t; 441 441 … … 444 444 */ 445 445 /** Section type mask. */ 446 #define SECTION_TYPE UINT32_C(0x000000ff)446 #define SECTION_TYPE KU32_C(0x000000ff) 447 447 /** Regular section. */ 448 448 #define S_REGULAR 0x0 … … 480 480 481 481 /** Section attribute mask. */ 482 #define SECTION_ATTRIBUTES UINT32_C(0xffffff00)482 #define SECTION_ATTRIBUTES KU32_C(0xffffff00) 483 483 484 484 /** User settable attribute mask. */ 485 #define SECTION_ATTRIBUTES_USR UINT32_C(0xff000000)485 #define SECTION_ATTRIBUTES_USR KU32_C(0xff000000) 486 486 /** Pure instruction (code). */ 487 #define S_ATTR_PURE_INSTRUCTIONS UINT32_C(0x80000000)487 #define S_ATTR_PURE_INSTRUCTIONS KU32_C(0x80000000) 488 488 /** ranlib, ignore my symbols... */ 489 #define S_ATTR_NO_TOC UINT32_C(0x40000000)489 #define S_ATTR_NO_TOC KU32_C(0x40000000) 490 490 /** May strip static symbols when linking int a MH_DYLDLINK file. */ 491 #define S_ATTR_STRIP_STATIC_SYMS UINT32_C(0x20000000)491 #define S_ATTR_STRIP_STATIC_SYMS KU32_C(0x20000000) 492 492 /** No dead stripping. */ 493 #define S_ATTR_NO_DEAD_STRIP UINT32_C(0x10000000)493 #define S_ATTR_NO_DEAD_STRIP KU32_C(0x10000000) 494 494 /** Live support. */ 495 #define S_ATTR_LIVE_SUPPORT UINT32_C(0x08000000)495 #define S_ATTR_LIVE_SUPPORT KU32_C(0x08000000) 496 496 /** Contains self modifying code (generally i386 code stub for dyld). */ 497 #define S_ATTR_SELF_MODIFYING_CODE UINT32_C(0x04000000)497 #define S_ATTR_SELF_MODIFYING_CODE KU32_C(0x04000000) 498 498 /** Debug info (DWARF usually). */ 499 #define S_ATTR_DEBUG UINT32_C(0x02000000)499 #define S_ATTR_DEBUG KU32_C(0x02000000) 500 500 501 501 /** System settable attribute mask. */ 502 #define SECTION_ATTRIBUTES_SYS UINT32_C(0x00ffff00)502 #define SECTION_ATTRIBUTES_SYS KU32_C(0x00ffff00) 503 503 /** Contains some instructions (code). */ 504 #define S_ATTR_SOME_INSTRUCTIONS UINT32_C(0x00000400)504 #define S_ATTR_SOME_INSTRUCTIONS KU32_C(0x00000400) 505 505 /** Has external relocations. */ 506 #define S_ATTR_EXT_RELOC UINT32_C(0x00000200)506 #define S_ATTR_EXT_RELOC KU32_C(0x00000200) 507 507 /** Has internal (local) relocations. */ 508 #define S_ATTR_LOC_RELOC UINT32_C(0x00000100)508 #define S_ATTR_LOC_RELOC KU32_C(0x00000100) 509 509 /** @} */ 510 510 … … 577 577 * is made up of a number of state structures preceded by a 32-bit flavor 578 578 * and 32-bit count field stating the kind of stat structure and it's size 579 * in uint32_titems respecitvly.579 * in KU32 items respecitvly. 580 580 * 581 581 * LC_UNIXTHREAD differs from LC_THREAD in that it implies stack creation … … 585 585 typedef struct thread_command 586 586 { 587 uint32_tcmd; /**< LC_UNIXTHREAD or LC_THREAD. */588 uint32_tcmdsize; /**< The size of the command (including this header). */587 KU32 cmd; /**< LC_UNIXTHREAD or LC_THREAD. */ 588 KU32 cmdsize; /**< The size of the command (including this header). */ 589 589 } thread_command_t; 590 590 … … 600 600 typedef struct symtab_command 601 601 { 602 uint32_tcmd; /**< LC_SYMTAB */603 uint32_tcmdsize; /** sizeof(symtab_command_t) */604 uint32_tsymoff; /** The file offset of the symbol table. */605 uint32_tnsyms; /** The number of symbols in the symbol table. */606 uint32_tstroff; /** The file offset of the string table. */607 uint32_tstrsize; /** The size of the string table. */602 KU32 cmd; /**< LC_SYMTAB */ 603 KU32 cmdsize; /** sizeof(symtab_command_t) */ 604 KU32 symoff; /** The file offset of the symbol table. */ 605 KU32 nsyms; /** The number of symbols in the symbol table. */ 606 KU32 stroff; /** The file offset of the string table. */ 607 KU32 strsize; /** The size of the string table. */ 608 608 } symtab_command_t; 609 609 … … 624 624 typedef struct uuid_command 625 625 { 626 uint32_tcmd; /**< LC_UUID */627 uint32_tcmdsize; /**< sizeof(uuid_command_t) */628 uint8_tuuid[16]; /** The UUID bytes. */626 KU32 cmd; /**< LC_UUID */ 627 KU32 cmdsize; /**< sizeof(uuid_command_t) */ 628 KU8 uuid[16]; /** The UUID bytes. */ 629 629 } uuid_command_t; 630 630 … … 652 652 union 653 653 { 654 int32_tn_strx; /**< Offset (index) into the string table. 0 means "". */654 KI32 n_strx; /**< Offset (index) into the string table. 0 means "". */ 655 655 } n_un; 656 uint8_tn_type; /**< Symbol type. */657 uint8_tn_sect; /**< Section number of NO_SECT. */658 int16_tn_desc; /**< Type specific, debug info details mostly.*/659 uint32_tn_value; /**< The symbol value or stab offset. */656 KU8 n_type; /**< Symbol type. */ 657 KU8 n_sect; /**< Section number of NO_SECT. */ 658 KI16 n_desc; /**< Type specific, debug info details mostly.*/ 659 KU32 n_value; /**< The symbol value or stab offset. */ 660 660 } macho_nlist_32_t; 661 661 … … 669 669 union 670 670 { 671 uint32_t n_strx;/**< Offset (index) into the string table. 0 means "". */671 KU32 n_strx; /**< Offset (index) into the string table. 0 means "". */ 672 672 } n_un; 673 uint8_tn_type; /**< Symbol type. */674 uint8_tn_sect; /**< Section number of NO_SECT. */675 int16_tn_desc; /**< Type specific, debug info details mostly.*/676 uint64_tn_value; /**< The symbol value or stab offset. */673 KU8 n_type; /**< Symbol type. */ 674 KU8 n_sect; /**< Section number of NO_SECT. */ 675 KI16 n_desc; /**< Type specific, debug info details mostly.*/ 676 KU64 n_value; /**< The symbol value or stab offset. */ 677 677 } macho_nlist_64_t; 678 678 … … 709 709 710 710 /* Base masks. */ 711 #define MACHO_N_EXT UINT8_C(0x01) /**< External symbol (when set) (N_EXT). */712 #define MACHO_N_TYPE UINT8_C(0x0e) /**< Symbol type (N_TYPE without the 8th bit). */713 #define MACHO_N_PEXT UINT8_C(0x10) /**< Private extern symbol (when set). (M) */714 #define MACHO_N_STAB UINT8_C(0xe0) /**< Debug symbol mask (N_STAB). */711 #define MACHO_N_EXT KU8_C(0x01) /**< External symbol (when set) (N_EXT). */ 712 #define MACHO_N_TYPE KU8_C(0x0e) /**< Symbol type (N_TYPE without the 8th bit). */ 713 #define MACHO_N_PEXT KU8_C(0x10) /**< Private extern symbol (when set). (M) */ 714 #define MACHO_N_STAB KU8_C(0xe0) /**< Debug symbol mask (N_STAB). */ 715 715 716 716 /* MACHO_N_TYPE values. */ 717 #define MACHO_N_UNDF UINT8_C(0x00) /**< MACHO_N_TYPE: Undefined symbol (N_UNDF). n_sect = NO_SECT. */718 #define MACHO_N_ABS UINT8_C(0x02) /**< MACHO_N_TYPE: Absolute symbol (N_UNDF). n_sect = NO_SECT. */719 #define MACHO_N_INDR UINT8_C(0x0a) /**< MACHO_N_TYPE: Indirect symbol, n_value is the index of the symbol. (M) */720 #define MACHO_N_PBUD UINT8_C(0x0c) /**< MACHO_N_TYPE: Prebound undefined symbo (defined in a dylib). (M) */721 #define MACHO_N_SECT UINT8_C(0x0e) /**< MACHO_N_TYPE: Defined in the section given by n_sects. (M) */717 #define MACHO_N_UNDF KU8_C(0x00) /**< MACHO_N_TYPE: Undefined symbol (N_UNDF). n_sect = NO_SECT. */ 718 #define MACHO_N_ABS KU8_C(0x02) /**< MACHO_N_TYPE: Absolute symbol (N_UNDF). n_sect = NO_SECT. */ 719 #define MACHO_N_INDR KU8_C(0x0a) /**< MACHO_N_TYPE: Indirect symbol, n_value is the index of the symbol. (M) */ 720 #define MACHO_N_PBUD KU8_C(0x0c) /**< MACHO_N_TYPE: Prebound undefined symbo (defined in a dylib). (M) */ 721 #define MACHO_N_SECT KU8_C(0x0e) /**< MACHO_N_TYPE: Defined in the section given by n_sects. (M) */ 722 722 723 723 /* Debug symbols. */ 724 #define MACHO_N_GSYM UINT8_C(0x20) /**< Global variable. "name",, NO_SECT, type, 0 (2) */725 #define MACHO_N_FNAME UINT8_C(0x22) /**< Function name (F77). "name",, NO_SECT, 0, 0 */726 #define MACHO_N_FUN UINT8_C(0x24) /**< Function / text var. "name",, section, line, address (1) */727 #define MACHO_N_STSYM UINT8_C(0x26) /**< Static data symbol. "name",, section, type, address (2) */728 #define MACHO_N_LCSYM UINT8_C(0x28) /**< static bss symbol. "name",, section, type, address (2) */724 #define MACHO_N_GSYM KU8_C(0x20) /**< Global variable. "name",, NO_SECT, type, 0 (2) */ 725 #define MACHO_N_FNAME KU8_C(0x22) /**< Function name (F77). "name",, NO_SECT, 0, 0 */ 726 #define MACHO_N_FUN KU8_C(0x24) /**< Function / text var. "name",, section, line, address (1) */ 727 #define MACHO_N_STSYM KU8_C(0x26) /**< Static data symbol. "name",, section, type, address (2) */ 728 #define MACHO_N_LCSYM KU8_C(0x28) /**< static bss symbol. "name",, section, type, address (2) */ 729 729 /* omits N_MAIN and N_ROSYM. */ 730 #define MACHO_N_BNSYM UINT8_C(0x2e) /**< Begin nsect symbol. 0,, section, 0, address (M) */731 #define MACHO_N_PC UINT8_C(0x30) /**< Global pascal symbol. "name",, NO_SECT, subtype?, line (3) */730 #define MACHO_N_BNSYM KU8_C(0x2e) /**< Begin nsect symbol. 0,, section, 0, address (M) */ 731 #define MACHO_N_PC KU8_C(0x30) /**< Global pascal symbol. "name",, NO_SECT, subtype?, line (3) */ 732 732 /* omits N_NSYMS, N_NOMAP and N_OBJ. */ 733 #define MACHO_N_OPT UINT8_C(0x3c) /**< Options for the debugger related to the language of the733 #define MACHO_N_OPT KU8_C(0x3c) /**< Options for the debugger related to the language of the 734 734 source file. "options?",,,, */ 735 #define MACHO_N_RSYM UINT8_C(0x40) /**< Register variable. "name",, NO_SECT, type, register */735 #define MACHO_N_RSYM KU8_C(0x40) /**< Register variable. "name",, NO_SECT, type, register */ 736 736 /* omits N_M2C */ 737 #define MACHO_N_SLINE UINT8_C(0x44) /**< Source line. 0,, section, line, address */737 #define MACHO_N_SLINE KU8_C(0x44) /**< Source line. 0,, section, line, address */ 738 738 /* omits N_DSLINE, N_BSLINE / N_BROWS, N_DEFD and N_FLINE. */ 739 #define MACHO_N_ENSYM UINT8_C(0x4e) /**< End nsect symbol. 0,, section, 0, address (M) */739 #define MACHO_N_ENSYM KU8_C(0x4e) /**< End nsect symbol. 0,, section, 0, address (M) */ 740 740 /* omits N_EHDECL / N_MOD2 and N_CATCH. */ 741 #define MACHO_N_SSYM UINT8_C(0x60) /**< Struct/union element. "name",, NO_SECT, type, offset */741 #define MACHO_N_SSYM KU8_C(0x60) /**< Struct/union element. "name",, NO_SECT, type, offset */ 742 742 /* omits N_ENDM */ 743 #define MACHO_N_SO UINT8_C(0x64) /**< Source file name. "fname",, section, 0, address */744 #define MACHO_N_OSO UINT8_C(0x66) /**< Object file name. "fname",, 0, 0, st_mtime (M?) */743 #define MACHO_N_SO KU8_C(0x64) /**< Source file name. "fname",, section, 0, address */ 744 #define MACHO_N_OSO KU8_C(0x66) /**< Object file name. "fname",, 0, 0, st_mtime (M?) */ 745 745 /* omits N_ALIAS */ 746 #define MACHO_N_LSYM UINT8_C(0x80) /**< Stack variable. "name",, NO_SECT, type, frame_offset */747 #define MACHO_N_BINCL UINT8_C(0x82) /**< Begin #include. "fname",, NO_SECT, 0, sum? */748 #define MACHO_N_SOL UINT8_C(0x84) /**< #included file. "fname",, section, 0, start_address (S) */749 #define MACHO_N_PARAMS UINT8_C(0x86) /**< Compiler params. "params",, NO_SECT, 0, 0 */750 #define MACHO_N_VERSION UINT8_C(0x88) /**< Compiler version. "version",, NO_SECT, 0, 0 */751 #define MACHO_N_OLEVEL UINT8_C(0x8A) /**< Compiler -O level. "level",, NO_SECT, 0, 0 */752 #define MACHO_N_PSYM UINT8_C(0xa0) /**< Parameter variable. "name",, NO_SECT, type, frame_offset */753 #define MACHO_N_EINCL UINT8_C(0xa2) /**< End #include. "fname",, NO_SECT, 0, 0 (S) */754 #define MACHO_N_ENTRY UINT8_C(0xa4) /**< Alternate entry point. "name",, section, line, address */755 #define MACHO_N_LBRAC UINT8_C(0xc0) /**< Left bracket. 0,, NO_SECT, nesting_level, address */756 #define MACHO_N_EXCL UINT8_C(0xc2) /**< Deleted include file. "fname",, NO_SECT, 0, sum? (S) */746 #define MACHO_N_LSYM KU8_C(0x80) /**< Stack variable. "name",, NO_SECT, type, frame_offset */ 747 #define MACHO_N_BINCL KU8_C(0x82) /**< Begin #include. "fname",, NO_SECT, 0, sum? */ 748 #define MACHO_N_SOL KU8_C(0x84) /**< #included file. "fname",, section, 0, start_address (S) */ 749 #define MACHO_N_PARAMS KU8_C(0x86) /**< Compiler params. "params",, NO_SECT, 0, 0 */ 750 #define MACHO_N_VERSION KU8_C(0x88) /**< Compiler version. "version",, NO_SECT, 0, 0 */ 751 #define MACHO_N_OLEVEL KU8_C(0x8A) /**< Compiler -O level. "level",, NO_SECT, 0, 0 */ 752 #define MACHO_N_PSYM KU8_C(0xa0) /**< Parameter variable. "name",, NO_SECT, type, frame_offset */ 753 #define MACHO_N_EINCL KU8_C(0xa2) /**< End #include. "fname",, NO_SECT, 0, 0 (S) */ 754 #define MACHO_N_ENTRY KU8_C(0xa4) /**< Alternate entry point. "name",, section, line, address */ 755 #define MACHO_N_LBRAC KU8_C(0xc0) /**< Left bracket. 0,, NO_SECT, nesting_level, address */ 756 #define MACHO_N_EXCL KU8_C(0xc2) /**< Deleted include file. "fname",, NO_SECT, 0, sum? (S) */ 757 757 /* omits N_SCOPE */ 758 #define MACHO_N_RBRAC UINT8_C(0xe0) /**< Right bracket. 0,, NO_SECT, nesting_level, address */759 #define MACHO_N_BCOMM UINT8_C(0xe2) /**< Begin common. "name",, NO_SECT?, 0, 0 */760 #define MACHO_N_ECOMM UINT8_C(0xe4) /**< End common. "name",, section, 0, 0 */761 #define MACHO_N_ECOML UINT8_C(0xe8) /**< End local common. 0,, section, 0, address */762 #define MACHO_N_LENG UINT8_C(0xfe) /**< Length-value of the preceding entry.758 #define MACHO_N_RBRAC KU8_C(0xe0) /**< Right bracket. 0,, NO_SECT, nesting_level, address */ 759 #define MACHO_N_BCOMM KU8_C(0xe2) /**< Begin common. "name",, NO_SECT?, 0, 0 */ 760 #define MACHO_N_ECOMM KU8_C(0xe4) /**< End common. "name",, section, 0, 0 */ 761 #define MACHO_N_ECOML KU8_C(0xe8) /**< End local common. 0,, section, 0, address */ 762 #define MACHO_N_LENG KU8_C(0xfe) /**< Length-value of the preceding entry. 763 763 "name",, NO_SECT, 0, length */ 764 764 … … 775 775 */ 776 776 777 #define REFERENCE_TYPE UINT16_C(0x000f) /**< The reference type mask. */777 #define REFERENCE_TYPE KU16_C(0x000f) /**< The reference type mask. */ 778 778 #define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0 /**< Normal undefined symbol. */ 779 779 #define REFERENCE_FLAG_UNDEFINED_LAZY 1 /**< Lazy undefined symbol. */ … … 783 783 #define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5 /**< Lazy undefined private symbol. */ 784 784 785 #define REFERENCED_DYNAMICALLY UINT16_C(0x0010) /**< Don't strip. */785 #define REFERENCED_DYNAMICALLY KU16_C(0x0010) /**< Don't strip. */ 786 786 787 787 … … 799 799 800 800 /** Only MH_OBJECT: Never dead strip me! */ 801 #define N_NO_DEAD_STRIP UINT16_C(0x0020)801 #define N_NO_DEAD_STRIP KU16_C(0x0020) 802 802 /** Not MH_OBJECT: Discarded symbol. */ 803 #define N_DESC_DISCARDED UINT16_C(0x0020)803 #define N_DESC_DISCARDED KU16_C(0x0020) 804 804 /** Weak external symbol. Symbol can be missing, in which case it's will have the value 0. */ 805 #define N_WEAK_REF UINT16_C(0x0040)805 #define N_WEAK_REF KU16_C(0x0040) 806 806 /** Weak symbol definition. The symbol can be overridden by another weak 807 807 * symbol already present or by a non-weak (strong) symbol definition. … … 809 809 * @remark This bit means something differently for undefined symbols, see N_REF_TO_WEAK. 810 810 */ 811 #define N_WEAK_DEF UINT16_C(0x0080)811 #define N_WEAK_DEF KU16_C(0x0080) 812 812 /** Reference to a weak symbol, resolve using flat namespace searching. 813 813 * @remark This bit means something differently for defined symbols, see N_WEAK_DEF. */ 814 #define N_REF_TO_WEAK UINT16_C(0x0080)814 #define N_REF_TO_WEAK KU16_C(0x0080) 815 815 816 816 /** @} */ … … 833 833 typedef struct macho_relocation_info 834 834 { 835 int32_tr_address; /**< Section relative address of the fixup.835 KI32 r_address; /**< Section relative address of the fixup. 836 836 The top bit (signed) indicates that this is a scattered 837 837 relocation if set, see scattered_relocation_info_t. */ 838 uint32_tr_symbolnum : 24, /**< r_extern=1: Symbol table index, relocate with the address of this symbol.838 KU32 r_symbolnum : 24, /**< r_extern=1: Symbol table index, relocate with the address of this symbol. 839 839 r_extern=0: Section ordinal, relocate with the address of this section. */ 840 840 r_pcrel : 1, /**< PC (program counter) relative fixup; subtract the fixup address. */ 841 r_length : 2, /**< Fixup length: 0= uint8_t, 1=uint16_t, 2=uint32_t, 3=uint64_t. */841 r_length : 2, /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. */ 842 842 r_extern : 1, /**< External or internal fixup, decides the r_symbolnum interpretation.. */ 843 843 r_type : 4; /**< Relocation type; 0 is standard, non-zero are machine specific. */ … … 849 849 /** Flag in r_address indicating that the relocation is of the 850 850 * scattered_relocation_info_t kind and not macho_relocation_info_t. */ 851 #define R_SCATTERED UINT32_C(0x80000000)851 #define R_SCATTERED KU32_C(0x80000000) 852 852 853 853 /** … … 864 864 { 865 865 #ifdef KLDR_LITTLE_ENDIAN 866 uint32_tr_address : 24, /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */866 KU32 r_address : 24, /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */ 867 867 r_type : 4, /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */ 868 r_length : 2, /**< Fixup length: 0= uint8_t, 1=uint16_t, 2=uint32_t, 3=uint64_t. (macho_relocation_info_t::r_length) */868 r_length : 2, /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. (macho_relocation_info_t::r_length) */ 869 869 r_pcrel : 1, /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */ 870 870 r_scattered : 1; /**< Set if scattered relocation, clear if normal relocation. */ 871 871 #elif defined(KLDR_BIG_ENDIAN) 872 uint32_tr_scattered : 1, /**< Set if scattered relocation, clear if normal relocation. */872 KU32 r_scattered : 1, /**< Set if scattered relocation, clear if normal relocation. */ 873 873 r_pcrel : 1, /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */ 874 r_length : 2, /**< Fixup length: 0= uint8_t, 1=uint16_t, 2=uint32_t, 3=uint64_t. (macho_relocation_info_t::r_length) */874 r_length : 2, /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. (macho_relocation_info_t::r_length) */ 875 875 r_type : 4, /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */ 876 876 r_address : 24; /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */ … … 878 878 # error "Neither KLDR_LITTLE_ENDIAN nor KLDR_BIG_ENDIAN is defined!" 879 879 #endif 880 int32_tr_value; /**< The value the fixup is refering to (without offset added). */880 KI32 r_value; /**< The value the fixup is refering to (without offset added). */ 881 881 } scattered_relocation_info_t; 882 882 -
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; -
trunk/kStuff/kLdr/kLdrModPE.c
r3537 r3567 58 58 */ 59 59 #define KLDRMODPE_RVA2TYPE(pvBits, uRVA, type) \ 60 ( (type) (( uintptr_t)(pvBits) + (uintptr_t)(uRVA)) )60 ( (type) ((KUPTR)(pvBits) + (KUPTR)(uRVA)) ) 61 61 62 62 /** @def KLDRMODPE_VALID_RVA … … 86 86 const void *pvMapping; 87 87 /** Reserved flags. */ 88 uint32_tf32Reserved;88 KU32 f32Reserved; 89 89 /** The number of imported modules. 90 * If ~( uint32_t)0 this hasn't been determined yet. */91 uint32_tcImportModules;90 * If ~(KU32)0 this hasn't been determined yet. */ 91 KU32 cImportModules; 92 92 /** The offset of the NT headers. */ 93 93 KLDRFOFF offHdrs; … … 102 102 * Internal Functions * 103 103 *******************************************************************************/ 104 static int32_tkldrModPENumberOfImports(PKLDRMOD pMod, const void *pvBits);104 static KI32 kldrModPENumberOfImports(PKLDRMOD pMod, const void *pvBits); 105 105 static int kldrModPERelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress, 106 106 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); … … 112 112 static void kldrModPEDoOptionalHeaderConversion(PIMAGE_OPTIONAL_HEADER64 pOptionalHeader); 113 113 static int kldrModPEDoForwarderQuery(PKLDRMODPE pModPE, const void *pvBits, const char *pszForwarder, 114 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind);114 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser, PKLDRADDR puValue, KU32 *pfKind); 115 115 static int kldrModPEDoFixups(PKLDRMODPE pModPE, void *pvMapping, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress); 116 116 static int kldrModPEDoImports32Bit(PKLDRMODPE pModPE, void *pvMapping, const IMAGE_IMPORT_DESCRIPTOR *pImpDesc, … … 119 119 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 120 120 static int kldrModPEDoImports(PKLDRMODPE pModPE, void *pvMapping, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); 121 static int kldrModPEDoCallDLL(PKLDRMODPE pModPE, unsigned uOp, uintptr_tuHandle);122 static int kldrModPEDoCallTLS(PKLDRMODPE pModPE, unsigned uOp, uintptr_tuHandle);123 static int32_t kldrModPEDoCall(uintptr_t uEntrypoint, uintptr_t uHandle, uint32_tuOp, void *pvReserved);121 static int kldrModPEDoCallDLL(PKLDRMODPE pModPE, unsigned uOp, KUPTR uHandle); 122 static int kldrModPEDoCallTLS(PKLDRMODPE pModPE, unsigned uOp, KUPTR uHandle); 123 static KI32 kldrModPEDoCall(KUPTR uEntrypoint, KUPTR uHandle, KU32 uOp, void *pvReserved); 124 124 125 125 … … 164 164 struct 165 165 { 166 uint32_tSignature;166 KU32 Signature; 167 167 IMAGE_FILE_HEADER FileHdr; 168 168 } s; 169 169 PKLDRMODPE pModPE; 170 170 PKLDRMOD pMod; 171 size_tcb;172 size_tcchFilename;171 KSIZE cb; 172 KSIZE cchFilename; 173 173 KLDRFOFF off; 174 uint32_ti;174 KU32 i; 175 175 int rc; 176 176 *ppModPE = NULL; … … 210 210 211 211 /* KLDRMOD */ 212 pMod = (PKLDRMOD)(( uint8_t*)pModPE + KLDR_ALIGN_Z(KLDR_OFFSETOF(KLDRMODPE, aShdrs[s.FileHdr.NumberOfSections]), 16));212 pMod = (PKLDRMOD)((KU8 *)pModPE + KLDR_ALIGN_Z(KLDR_OFFSETOF(KLDRMODPE, aShdrs[s.FileHdr.NumberOfSections]), 16)); 213 213 pMod->pvData = pModPE; 214 214 pMod->pRdr = pRdr; … … 253 253 pModPE->pvMapping = NULL; 254 254 pModPE->f32Reserved = 0; 255 pModPE->cImportModules = ~( uint32_t)0;255 pModPE->cImportModules = ~(KU32)0; 256 256 pModPE->offHdrs = offNewHdr >= 0 ? offNewHdr : 0; 257 257 pModPE->Hdrs.Signature = s.Signature; … … 432 432 IMAGE_OPTIONAL_HEADER32 volatile *pOptHdr32 = (IMAGE_OPTIONAL_HEADER32 volatile *)pOptHdr; 433 433 IMAGE_OPTIONAL_HEADER64 volatile *pOptHdr64 = pOptHdr; 434 uint32_t volatile*pu32Dst;435 uint32_t volatile*pu32Src;436 uint32_t volatile*pu32SrcLast;437 uint32_tu32;434 KU32 volatile *pu32Dst; 435 KU32 volatile *pu32Src; 436 KU32 volatile *pu32SrcLast; 437 KU32 u32; 438 438 439 439 /* From LoaderFlags and out the difference is 4 * 32-bits. */ 440 pu32Dst = ( uint32_t*)&pOptHdr64->DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] - 1;441 pu32Src = ( uint32_t*)&pOptHdr32->DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] - 1;442 pu32SrcLast = ( uint32_t*)&pOptHdr32->LoaderFlags;440 pu32Dst = (KU32 *)&pOptHdr64->DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] - 1; 441 pu32Src = (KU32 *)&pOptHdr32->DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] - 1; 442 pu32SrcLast = (KU32 *)&pOptHdr32->LoaderFlags; 443 443 while (pu32Src >= pu32SrcLast) 444 444 *pu32Dst-- = *pu32Src--; … … 472 472 IMAGE_LOAD_CONFIG_DIRECTORY32 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32 volatile *)pLoadCfg; 473 473 IMAGE_LOAD_CONFIG_DIRECTORY64 volatile *pLoadCfg64 = pLoadCfg; 474 uint32_tu32;474 KU32 u32; 475 475 476 476 pLoadCfg64->SEHandlerCount = pLoadCfg32->SEHandlerCount; … … 557 557 void *pvBase; 558 558 int rc; 559 uint32_ti;559 KU32 i; 560 560 561 561 /* … … 570 570 else 571 571 { 572 pvBase = (void *)( uintptr_t)pMod->aSegments[0].LinkAddress;573 if (( uintptr_t)pvBase != pMod->aSegments[0].LinkAddress)572 pvBase = (void *)(KUPTR)pMod->aSegments[0].LinkAddress; 573 if ((KUPTR)pvBase != pMod->aSegments[0].LinkAddress) 574 574 return KLDR_ERR_ADDRESS_OVERFLOW; 575 575 } … … 588 588 { 589 589 if (pMod->aSegments[i].RVA != NIL_KLDRADDR) 590 pMod->aSegments[i].MapAddress = ( uintptr_t)pvBase + (uintptr_t)pMod->aSegments[i].RVA;590 pMod->aSegments[i].MapAddress = (KUPTR)pvBase + (KUPTR)pMod->aSegments[i].RVA; 591 591 } 592 592 pModPE->pvMapping = pvBase; … … 612 612 PKLDRMOD pMod = pModPE->pMod; 613 613 int rc; 614 uint32_ti;614 KU32 i; 615 615 616 616 /* … … 690 690 691 691 /** @copydoc kLdrModQuerySymbol */ 692 static int kldrModPEQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_tiSymbol,693 const char *pchSymbol, size_tcchSymbol, const char *pszVersion,694 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind)692 static int kldrModPEQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol, 693 const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion, 694 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind) 695 695 696 696 { 697 697 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; 698 const uint32_t*paExportRVAs;698 const KU32 *paExportRVAs; 699 699 const IMAGE_EXPORT_DIRECTORY *pExpDir; 700 uint32_tiExpOrd;701 uint32_tuRVA;700 KU32 iExpOrd; 701 KU32 uRVA; 702 702 int rc; 703 703 … … 732 732 * (The name table is sorted in ascending ordered by the linker.) 733 733 */ 734 const uint32_t *paRVANames = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfNames, const uint32_t*);735 const uint16_t *paOrdinals = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfNameOrdinals, const uint16_t*);736 int32_tiStart = 1; /* one based binary searching is simpler. */737 int32_tiEnd = pExpDir->NumberOfNames;734 const KU32 *paRVANames = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfNames, const KU32 *); 735 const KU16 *paOrdinals = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfNameOrdinals, const KU16 *); 736 KI32 iStart = 1; /* one based binary searching is simpler. */ 737 KI32 iEnd = pExpDir->NumberOfNames; 738 738 739 739 for (;;) 740 740 { 741 int32_ti;741 KI32 i; 742 742 int diff; 743 743 const char *pszName; … … 747 747 { 748 748 #ifdef KLDRMODPE_STRICT /* Make sure the linker and we both did our job right. */ 749 for (i = 0; i < ( int32_t)pExpDir->NumberOfNames; i++)749 for (i = 0; i < (KI32)pExpDir->NumberOfNames; i++) 750 750 751 751 { … … 778 778 * Lookup the address in the 'symbol' table. 779 779 */ 780 paExportRVAs = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfFunctions, const uint32_t*);780 paExportRVAs = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfFunctions, const KU32 *); 781 781 uRVA = paExportRVAs[iExpOrd]; 782 782 if ( uRVA - pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress … … 815 815 */ 816 816 static int kldrModPEDoForwarderQuery(PKLDRMODPE pModPE, const void *pvBits, const char *pszForwarder, 817 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t*pfKind)817 PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind) 818 818 { 819 819 const IMAGE_IMPORT_DESCRIPTOR *paImpDir; 820 uint32_tiImpModule;821 uint32_tcchImpModule;820 KU32 iImpModule; 821 KU32 cchImpModule; 822 822 const char *pszSymbol; 823 uint32_tiSymbol;823 KU32 iSymbol; 824 824 int rc; 825 825 … … 903 903 { 904 904 const char *pszName = KLDRMODPE_RVA2TYPE(pvBits, paImpDir[iImpModule].Name, const char *); 905 size_tcchName = kLdrHlpStrLen(pszName);905 KSIZE cchName = kLdrHlpStrLen(pszName); 906 906 if ( ( cchName == cchImpModule 907 907 || ( cchName > cchImpModule … … 930 930 /** @copydoc kLdrModEnumSymbols */ 931 931 static int kldrModPEEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, 932 uint32_tfFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)932 KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser) 933 933 { 934 934 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; 935 const uint32_t*paFunctions;935 const KU32 *paFunctions; 936 936 const IMAGE_EXPORT_DIRECTORY *pExpDir; 937 const uint32_t*paRVANames;938 const uint16_t*paOrdinals;939 uint32_tiFunction;940 uint32_tcFunctions;941 uint32_tcNames;937 const KU32 *paRVANames; 938 const KU16 *paOrdinals; 939 KU32 iFunction; 940 KU32 cFunctions; 941 KU32 cNames; 942 942 int rc; 943 943 … … 960 960 * Enumerate the ordinal exports. 961 961 */ 962 paRVANames = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfNames, const uint32_t*);963 paOrdinals = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfNameOrdinals, const uint16_t*);964 paFunctions = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfFunctions, const uint32_t*);962 paRVANames = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfNames, const KU32 *); 963 paOrdinals = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfNameOrdinals, const KU16 *); 964 paFunctions = KLDRMODPE_RVA2TYPE(pvBits, pExpDir->AddressOfFunctions, const KU32 *); 965 965 cFunctions = pExpDir->NumberOfFunctions; 966 966 cNames = pExpDir->NumberOfNames; … … 968 968 { 969 969 unsigned fFoundName; 970 uint32_tiName;971 const uint32_tuRVA = paFunctions[iFunction];970 KU32 iName; 971 const KU32 uRVA = paFunctions[iFunction]; 972 972 const KLDRADDR uValue = BaseAddress + uRVA; 973 uint32_tfKind = (pModPE->Hdrs.FileHeader.SizeOfOptionalHeader == sizeof(IMAGE_OPTIONAL_HEADER32)973 KU32 fKind = (pModPE->Hdrs.FileHeader.SizeOfOptionalHeader == sizeof(IMAGE_OPTIONAL_HEADER32) 974 974 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT) 975 975 | KLDRSYMKIND_NO_TYPE; … … 1011 1011 1012 1012 /** @copydoc kLdrModGetImport */ 1013 static int kldrModPEGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_tcchName)1013 static int kldrModPEGetImport(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName) 1014 1014 { 1015 1015 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; 1016 1016 const IMAGE_IMPORT_DESCRIPTOR *pImpDesc; 1017 1017 const char *pszImportName; 1018 size_tcchImportName;1018 KSIZE cchImportName; 1019 1019 int rc; 1020 1020 … … 1029 1029 * Simple bounds check. 1030 1030 */ 1031 if (iImport >= ( uint32_t)kldrModPENumberOfImports(pMod, pvBits))1031 if (iImport >= (KU32)kldrModPENumberOfImports(pMod, pvBits)) 1032 1032 return KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS; 1033 1033 … … 1059 1059 1060 1060 /** @copydoc kLdrModNumberOfImports */ 1061 static int32_tkldrModPENumberOfImports(PKLDRMOD pMod, const void *pvBits)1061 static KI32 kldrModPENumberOfImports(PKLDRMOD pMod, const void *pvBits) 1062 1062 { 1063 1063 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; 1064 if (pModPE->cImportModules == ~( uint32_t)0)1064 if (pModPE->cImportModules == ~(KU32)0) 1065 1065 { 1066 1066 /* … … 1131 1131 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; 1132 1132 const IMAGE_DEBUG_DIRECTORY *pDbgDir; 1133 uint32_tiDbgInfo;1134 uint32_tcb;1133 KU32 iDbgInfo; 1134 KU32 cb; 1135 1135 int rc; 1136 1136 … … 1342 1342 * Apply base relocations. 1343 1343 */ 1344 rc = kldrModPEDoFixups(pModPE, (void *)pModPE->pvMapping, ( uintptr_t)pModPE->pvMapping,1344 rc = kldrModPEDoFixups(pModPE, (void *)pModPE->pvMapping, (KUPTR)pModPE->pvMapping, 1345 1345 pModPE->Hdrs.OptionalHeader.ImageBase); 1346 1346 … … 1373 1373 { 1374 1374 const KLDRADDR Delta = NewBaseAddress - OldBaseAddress; 1375 uint32_tcbLeft = pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;1375 KU32 cbLeft = pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].Size; 1376 1376 const IMAGE_BASE_RELOCATION *pBR, *pFirstBR; 1377 1377 … … 1396 1396 union 1397 1397 { 1398 uint8_t*pu8;1399 uint16_t*pu16;1400 uint32_t*pu32;1401 uint64_t*pu64;1398 KU8 *pu8; 1399 KU16 *pu16; 1400 KU32 *pu32; 1401 KU64 *pu64; 1402 1402 } uChunk, 1403 1403 u; 1404 const uint16_t *poffFixup = (const uint16_t*)(pBR + 1);1405 const uint32_tcbBlock = KLDR_MIN(cbLeft, pBR->SizeOfBlock) - sizeof(IMAGE_BASE_RELOCATION); /* more caution... */1406 uint32_tcFixups = cbBlock / sizeof(poffFixup[0]);1407 uChunk.pu8 = KLDRMODPE_RVA2TYPE(pvMapping, pBR->VirtualAddress, uint8_t*);1404 const KU16 *poffFixup = (const KU16 *)(pBR + 1); 1405 const KU32 cbBlock = KLDR_MIN(cbLeft, pBR->SizeOfBlock) - sizeof(IMAGE_BASE_RELOCATION); /* more caution... */ 1406 KU32 cFixups = cbBlock / sizeof(poffFixup[0]); 1407 uChunk.pu8 = KLDRMODPE_RVA2TYPE(pvMapping, pBR->VirtualAddress, KU8 *); 1408 1408 1409 1409 /* … … 1421 1421 /* 1 - 16-bit, add 2nd 16-bit part of the delta. (rare) */ 1422 1422 case IMAGE_REL_BASED_HIGH: 1423 *u.pu16 += ( uint16_t)(Delta >> 16);1423 *u.pu16 += (KU16)(Delta >> 16); 1424 1424 break; 1425 1425 1426 1426 /* 2 - 16-bit, add 1st 16-bit part of the delta. (rare) */ 1427 1427 case IMAGE_REL_BASED_LOW: 1428 *u.pu16 += ( uint16_t)Delta;1428 *u.pu16 += (KU16)Delta; 1429 1429 break; 1430 1430 1431 1431 /* 3 - 32-bit, add delta. (frequent in 32-bit images) */ 1432 1432 case IMAGE_REL_BASED_HIGHLOW: 1433 *u.pu32 += ( uint32_t)Delta;1433 *u.pu32 += (KU32)Delta; 1434 1434 break; 1435 1435 … … 1437 1437 case IMAGE_REL_BASED_HIGHADJ: 1438 1438 { 1439 int32_ti32;1439 KI32 i32; 1440 1440 if (cFixups <= 1) 1441 1441 return KLDR_ERR_PE_BAD_FIXUP; 1442 1442 1443 i32 = ( uint32_t)*u.pu16 << 16;1443 i32 = (KU32)*u.pu16 << 16; 1444 1444 i32 |= *++poffFixup; cFixups--; /* the addend argument */ 1445 i32 += ( uint32_t)Delta;1445 i32 += (KU32)Delta; 1446 1446 i32 += 0x8000; 1447 *u.pu16 = ( uint16_t)(i32 >> 16);1447 *u.pu16 = (KU16)(i32 >> 16); 1448 1448 break; 1449 1449 } … … 1452 1452 case IMAGE_REL_BASED_MIPS_JMPADDR: 1453 1453 *u.pu32 = (*u.pu32 & 0xc0000000) 1454 | (( uint32_t)((*u.pu32 << 2) + (uint32_t)Delta) >> 2);1454 | ((KU32)((*u.pu32 << 2) + (KU32)Delta) >> 2); 1455 1455 break; 1456 1456 … … 1478 1478 /* 10 - 64-bit, add delta. (frequently in 64-bit images) */ 1479 1479 case IMAGE_REL_BASED_DIR64: 1480 *u.pu64 += ( uint64_t)Delta;1480 *u.pu64 += (KU64)Delta; 1481 1481 break; 1482 1482 … … 1484 1484 case IMAGE_REL_BASED_HIGH3ADJ: 1485 1485 { 1486 int64_ti64;1486 KI64 i64; 1487 1487 if (cFixups <= 2) 1488 1488 return KLDR_ERR_PE_BAD_FIXUP; 1489 1489 1490 i64 = ( uint64_t)*u.pu16 << 321491 | (( uint32_t)poffFixup[2] << 16)1490 i64 = (KU64)*u.pu16 << 32 1491 | ((KU32)poffFixup[2] << 16) 1492 1492 | poffFixup[1]; 1493 1493 i64 += Delta; 1494 1494 i64 += 0x80008000UL; 1495 *u.pu16 = ( uint16_t)(i64 >> 32);1495 *u.pu16 = (KU16)(i64 >> 32); 1496 1496 /* skip the addends arguments */ 1497 1497 poffFixup += 2; … … 1517 1517 */ 1518 1518 cbLeft -= pBR->SizeOfBlock; 1519 pBR = (PIMAGE_BASE_RELOCATION)(( uintptr_t)pBR + pBR->SizeOfBlock);1519 pBR = (PIMAGE_BASE_RELOCATION)((KUPTR)pBR + pBR->SizeOfBlock); 1520 1520 } 1521 1521 … … 1568 1568 { 1569 1569 PKLDRMOD pMod = pModPE->pMod; 1570 uint32_tiImp;1570 KU32 iImp; 1571 1571 1572 1572 /* … … 1584 1584 { 1585 1585 KLDRADDR Value; 1586 uint32_tfKind = KLDRSYMKIND_REQ_FLAT;1586 KU32 fKind = KLDRSYMKIND_REQ_FLAT; 1587 1587 int rc; 1588 1588 … … 1605 1605 1606 1606 /* Apply it. */ 1607 pFirstThunk->u1.Function = ( uint32_t)Value;1607 pFirstThunk->u1.Function = (KU32)Value; 1608 1608 if (pFirstThunk->u1.Function != Value) 1609 1609 { … … 1636 1636 { 1637 1637 PKLDRMOD pMod = pModPE->pMod; 1638 uint32_tiImp;1638 KU32 iImp; 1639 1639 1640 1640 /* … … 1652 1652 { 1653 1653 KLDRADDR Value; 1654 uint32_tfKind = KLDRSYMKIND_REQ_FLAT;1654 KU32 fKind = KLDRSYMKIND_REQ_FLAT; 1655 1655 int rc; 1656 1656 1657 1657 /* Ordinal or name import? */ 1658 1658 if (IMAGE_SNAP_BY_ORDINAL64(pThunk->u1.Ordinal)) 1659 rc = pfnGetImport(pMod, iImp, ( uint32_t)IMAGE_ORDINAL64(pThunk->u1.Ordinal), NULL, 0, NULL, &Value, &fKind, pvUser);1659 rc = pfnGetImport(pMod, iImp, (KU32)IMAGE_ORDINAL64(pThunk->u1.Ordinal), NULL, 0, NULL, &Value, &fKind, pvUser); 1660 1660 else if (KLDRMODPE_VALID_RVA(pModPE, pThunk->u1.Ordinal)) 1661 1661 { … … 1687 1687 1688 1688 /** @copydoc kLdrModCallInit */ 1689 static int kldrModPECallInit(PKLDRMOD pMod, uintptr_tuHandle)1689 static int kldrModPECallInit(PKLDRMOD pMod, KUPTR uHandle) 1690 1690 { 1691 1691 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; … … 1723 1723 * @param uHandle The module handle to present. 1724 1724 */ 1725 static int kldrModPEDoCallDLL(PKLDRMODPE pModPE, unsigned uOp, uintptr_tuHandle)1725 static int kldrModPEDoCallDLL(PKLDRMODPE pModPE, unsigned uOp, KUPTR uHandle) 1726 1726 { 1727 1727 int rc; … … 1736 1736 * Invoke the entrypoint and convert the boolean result to a kLdr status code. 1737 1737 */ 1738 rc = kldrModPEDoCall(( uintptr_t)pModPE->pvMapping + pModPE->Hdrs.OptionalHeader.AddressOfEntryPoint,1738 rc = kldrModPEDoCall((KUPTR)pModPE->pvMapping + pModPE->Hdrs.OptionalHeader.AddressOfEntryPoint, 1739 1739 uHandle, uOp, NULL); 1740 1740 if (rc) … … 1759 1759 * @param uHandle The module handle to present. 1760 1760 */ 1761 static int kldrModPEDoCallTLS(PKLDRMODPE pModPE, unsigned uOp, uintptr_tuHandle)1761 static int kldrModPEDoCallTLS(PKLDRMODPE pModPE, unsigned uOp, KUPTR uHandle) 1762 1762 { 1763 1763 /** @todo implement TLS support. */ … … 1775 1775 * @param pvReserved The third argument, reserved argument. (figure this one out) 1776 1776 */ 1777 static int32_t kldrModPEDoCall(uintptr_t uEntrypoint, uintptr_t uHandle, uint32_tuOp, void *pvReserved)1778 { 1779 int32_trc;1777 static KI32 kldrModPEDoCall(KUPTR uEntrypoint, KUPTR uHandle, KU32 uOp, void *pvReserved) 1778 { 1779 KI32 rc; 1780 1780 1781 1781 /** @todo try/except */ … … 1823 1823 */ 1824 1824 /** @todo Deal with GCC / MSC differences in some sensible way. */ 1825 int (*pfn)( uintptr_t uHandle, uint32_tuOp, void *pvReserved);1826 pfn = (int (*)( uintptr_t uHandle, uint32_tuOp, void *pvReserved))uEntrypoint;1825 int (*pfn)(KUPTR uHandle, KU32 uOp, void *pvReserved); 1826 pfn = (int (*)(KUPTR uHandle, KU32 uOp, void *pvReserved))uEntrypoint; 1827 1827 rc = pfn(uHandle, uOp, NULL); 1828 1828 … … 1836 1836 1837 1837 /** @copydoc kLdrModCallTerm */ 1838 static int kldrModPECallTerm(PKLDRMOD pMod, uintptr_tuHandle)1838 static int kldrModPECallTerm(PKLDRMOD pMod, KUPTR uHandle) 1839 1839 { 1840 1840 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; … … 1858 1858 1859 1859 /** @copydoc kLdrModCallThread */ 1860 static int kldrModPECallThread(PKLDRMOD pMod, uintptr_tuHandle, unsigned fAttachingOrDetaching)1860 static int kldrModPECallThread(PKLDRMOD pMod, KUPTR uHandle, unsigned fAttachingOrDetaching) 1861 1861 { 1862 1862 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; … … 1896 1896 { 1897 1897 PKLDRMODPE pModPE = (PKLDRMODPE)pMod->pvData; 1898 uint32_ti;1898 KU32 i; 1899 1899 int rc; 1900 1900 … … 1916 1916 continue; 1917 1917 rc = kLdrRdrRead(pMod->pRdr, 1918 ( uint8_t*)pvBits + (pMod->aSegments[i].LinkAddress - pModPE->Hdrs.OptionalHeader.ImageBase),1918 (KU8 *)pvBits + (pMod->aSegments[i].LinkAddress - pModPE->Hdrs.OptionalHeader.ImageBase), 1919 1919 pMod->aSegments[i].cbFile, 1920 1920 pMod->aSegments[i].offFile); -
trunk/kStuff/kLdr/kLdrModPE.h
r3537 r3567 176 176 typedef struct _IMAGE_FILE_HEADER 177 177 { 178 uint16_tMachine;179 uint16_tNumberOfSections;180 uint32_tTimeDateStamp;181 uint32_tPointerToSymbolTable;182 uint32_tNumberOfSymbols;183 uint16_tSizeOfOptionalHeader;184 uint16_tCharacteristics;178 KU16 Machine; 179 KU16 NumberOfSections; 180 KU32 TimeDateStamp; 181 KU32 PointerToSymbolTable; 182 KU32 NumberOfSymbols; 183 KU16 SizeOfOptionalHeader; 184 KU16 Characteristics; 185 185 } IMAGE_FILE_HEADER; 186 186 typedef IMAGE_FILE_HEADER *PIMAGE_FILE_HEADER; … … 189 189 typedef struct _IMAGE_DATA_DIRECTORY 190 190 { 191 uint32_tVirtualAddress;192 uint32_tSize;191 KU32 VirtualAddress; 192 KU32 Size; 193 193 } IMAGE_DATA_DIRECTORY; 194 194 typedef IMAGE_DATA_DIRECTORY *PIMAGE_DATA_DIRECTORY; … … 197 197 typedef struct _IMAGE_OPTIONAL_HEADER32 198 198 { 199 uint16_tMagic;200 uint8_tMajorLinkerVersion;201 uint8_tMinorLinkerVersion;202 uint32_tSizeOfCode;203 uint32_tSizeOfInitializedData;204 uint32_tSizeOfUninitializedData;205 uint32_tAddressOfEntryPoint;206 uint32_tBaseOfCode;207 uint32_tBaseOfData;208 uint32_tImageBase;209 uint32_tSectionAlignment;210 uint32_tFileAlignment;211 uint16_tMajorOperatingSystemVersion;212 uint16_tMinorOperatingSystemVersion;213 uint16_tMajorImageVersion;214 uint16_tMinorImageVersion;215 uint16_tMajorSubsystemVersion;216 uint16_tMinorSubsystemVersion;217 uint32_tWin32VersionValue;218 uint32_tSizeOfImage;219 uint32_tSizeOfHeaders;220 uint32_tCheckSum;221 uint16_tSubsystem;222 uint16_tDllCharacteristics;223 uint32_tSizeOfStackReserve;224 uint32_tSizeOfStackCommit;225 uint32_tSizeOfHeapReserve;226 uint32_tSizeOfHeapCommit;227 uint32_tLoaderFlags;228 uint32_tNumberOfRvaAndSizes;199 KU16 Magic; 200 KU8 MajorLinkerVersion; 201 KU8 MinorLinkerVersion; 202 KU32 SizeOfCode; 203 KU32 SizeOfInitializedData; 204 KU32 SizeOfUninitializedData; 205 KU32 AddressOfEntryPoint; 206 KU32 BaseOfCode; 207 KU32 BaseOfData; 208 KU32 ImageBase; 209 KU32 SectionAlignment; 210 KU32 FileAlignment; 211 KU16 MajorOperatingSystemVersion; 212 KU16 MinorOperatingSystemVersion; 213 KU16 MajorImageVersion; 214 KU16 MinorImageVersion; 215 KU16 MajorSubsystemVersion; 216 KU16 MinorSubsystemVersion; 217 KU32 Win32VersionValue; 218 KU32 SizeOfImage; 219 KU32 SizeOfHeaders; 220 KU32 CheckSum; 221 KU16 Subsystem; 222 KU16 DllCharacteristics; 223 KU32 SizeOfStackReserve; 224 KU32 SizeOfStackCommit; 225 KU32 SizeOfHeapReserve; 226 KU32 SizeOfHeapCommit; 227 KU32 LoaderFlags; 228 KU32 NumberOfRvaAndSizes; 229 229 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; 230 230 } IMAGE_OPTIONAL_HEADER32; … … 233 233 typedef struct _IMAGE_OPTIONAL_HEADER64 234 234 { 235 uint16_tMagic;236 uint8_tMajorLinkerVersion;237 uint8_tMinorLinkerVersion;238 uint32_tSizeOfCode;239 uint32_tSizeOfInitializedData;240 uint32_tSizeOfUninitializedData;241 uint32_tAddressOfEntryPoint;242 uint32_tBaseOfCode;243 uint64_tImageBase;244 uint32_tSectionAlignment;245 uint32_tFileAlignment;246 uint16_tMajorOperatingSystemVersion;247 uint16_tMinorOperatingSystemVersion;248 uint16_tMajorImageVersion;249 uint16_tMinorImageVersion;250 uint16_tMajorSubsystemVersion;251 uint16_tMinorSubsystemVersion;252 uint32_tWin32VersionValue;253 uint32_tSizeOfImage;254 uint32_tSizeOfHeaders;255 uint32_tCheckSum;256 uint16_tSubsystem;257 uint16_tDllCharacteristics;258 uint64_tSizeOfStackReserve;259 uint64_tSizeOfStackCommit;260 uint64_tSizeOfHeapReserve;261 uint64_tSizeOfHeapCommit;262 uint32_tLoaderFlags;263 uint32_tNumberOfRvaAndSizes;235 KU16 Magic; 236 KU8 MajorLinkerVersion; 237 KU8 MinorLinkerVersion; 238 KU32 SizeOfCode; 239 KU32 SizeOfInitializedData; 240 KU32 SizeOfUninitializedData; 241 KU32 AddressOfEntryPoint; 242 KU32 BaseOfCode; 243 KU64 ImageBase; 244 KU32 SectionAlignment; 245 KU32 FileAlignment; 246 KU16 MajorOperatingSystemVersion; 247 KU16 MinorOperatingSystemVersion; 248 KU16 MajorImageVersion; 249 KU16 MinorImageVersion; 250 KU16 MajorSubsystemVersion; 251 KU16 MinorSubsystemVersion; 252 KU32 Win32VersionValue; 253 KU32 SizeOfImage; 254 KU32 SizeOfHeaders; 255 KU32 CheckSum; 256 KU16 Subsystem; 257 KU16 DllCharacteristics; 258 KU64 SizeOfStackReserve; 259 KU64 SizeOfStackCommit; 260 KU64 SizeOfHeapReserve; 261 KU64 SizeOfHeapCommit; 262 KU32 LoaderFlags; 263 KU32 NumberOfRvaAndSizes; 264 264 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; 265 265 } IMAGE_OPTIONAL_HEADER64; … … 269 269 typedef struct _IMAGE_NT_HEADERS 270 270 { 271 uint32_tSignature;271 KU32 Signature; 272 272 IMAGE_FILE_HEADER FileHeader; 273 273 IMAGE_OPTIONAL_HEADER32 OptionalHeader; … … 277 277 typedef struct _IMAGE_NT_HEADERS64 278 278 { 279 uint32_tSignature;279 KU32 Signature; 280 280 IMAGE_FILE_HEADER FileHeader; 281 281 IMAGE_OPTIONAL_HEADER64 OptionalHeader; … … 286 286 typedef struct _IMAGE_SECTION_HEADER 287 287 { 288 uint8_tName[IMAGE_SIZEOF_SHORT_NAME];288 KU8 Name[IMAGE_SIZEOF_SHORT_NAME]; 289 289 union 290 290 { 291 uint32_tPhysicalAddress;292 uint32_tVirtualSize;291 KU32 PhysicalAddress; 292 KU32 VirtualSize; 293 293 } Misc; 294 uint32_tVirtualAddress;295 uint32_tSizeOfRawData;296 uint32_tPointerToRawData;297 uint32_tPointerToRelocations;298 uint32_tPointerToLinenumbers;299 uint16_tNumberOfRelocations;300 uint16_tNumberOfLinenumbers;301 uint32_tCharacteristics;294 KU32 VirtualAddress; 295 KU32 SizeOfRawData; 296 KU32 PointerToRawData; 297 KU32 PointerToRelocations; 298 KU32 PointerToLinenumbers; 299 KU16 NumberOfRelocations; 300 KU16 NumberOfLinenumbers; 301 KU32 Characteristics; 302 302 } IMAGE_SECTION_HEADER; 303 303 typedef IMAGE_SECTION_HEADER *PIMAGE_SECTION_HEADER; … … 306 306 typedef struct _IMAGE_BASE_RELOCATION 307 307 { 308 uint32_tVirtualAddress;309 uint32_tSizeOfBlock;308 KU32 VirtualAddress; 309 KU32 SizeOfBlock; 310 310 } IMAGE_BASE_RELOCATION; 311 311 typedef IMAGE_BASE_RELOCATION *PIMAGE_BASE_RELOCATION; … … 314 314 typedef struct _IMAGE_EXPORT_DIRECTORY 315 315 { 316 uint32_tCharacteristics;317 uint32_tTimeDateStamp;318 uint16_tMajorVersion;319 uint16_tMinorVersion;320 uint32_tName;321 uint32_tBase;322 uint32_tNumberOfFunctions;323 uint32_tNumberOfNames;324 uint32_tAddressOfFunctions;325 uint32_tAddressOfNames;326 uint32_tAddressOfNameOrdinals;316 KU32 Characteristics; 317 KU32 TimeDateStamp; 318 KU16 MajorVersion; 319 KU16 MinorVersion; 320 KU32 Name; 321 KU32 Base; 322 KU32 NumberOfFunctions; 323 KU32 NumberOfNames; 324 KU32 AddressOfFunctions; 325 KU32 AddressOfNames; 326 KU32 AddressOfNameOrdinals; 327 327 } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; 328 328 … … 332 332 union 333 333 { 334 uint32_tCharacteristics;335 uint32_tOriginalFirstThunk;334 KU32 Characteristics; 335 KU32 OriginalFirstThunk; 336 336 } u; 337 uint32_tTimeDateStamp;338 uint32_tForwarderChain;339 uint32_tName;340 uint32_tFirstThunk;337 KU32 TimeDateStamp; 338 KU32 ForwarderChain; 339 KU32 Name; 340 KU32 FirstThunk; 341 341 } IMAGE_IMPORT_DESCRIPTOR; 342 342 typedef IMAGE_IMPORT_DESCRIPTOR *PIMAGE_IMPORT_DESCRIPTOR; … … 345 345 typedef struct _IMAGE_IMPORT_BY_NAME 346 346 { 347 uint16_tHint;348 uint8_tName[1];347 KU16 Hint; 348 KU8 Name[1]; 349 349 } IMAGE_IMPORT_BY_NAME; 350 350 typedef IMAGE_IMPORT_BY_NAME *PIMAGE_IMPORT_BY_NAME; … … 356 356 union 357 357 { 358 uint64_tForwarderString;359 uint64_tFunction;360 uint64_tOrdinal;361 uint64_tAddressOfData;358 KU64 ForwarderString; 359 KU64 Function; 360 KU64 Ordinal; 361 KU64 AddressOfData; 362 362 } u1; 363 363 } IMAGE_THUNK_DATA64; … … 368 368 union 369 369 { 370 uint32_tForwarderString;371 uint32_tFunction;372 uint32_tOrdinal;373 uint32_tAddressOfData;370 KU32 ForwarderString; 371 KU32 Function; 372 KU32 Ordinal; 373 KU32 AddressOfData; 374 374 } u1; 375 375 } IMAGE_THUNK_DATA32; … … 379 379 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32 380 380 { 381 uint32_tSize;382 uint32_tTimeDateStamp;383 uint16_tMajorVersion;384 uint16_tMinorVersion;385 uint32_tGlobalFlagsClear;386 uint32_tGlobalFlagsSet;387 uint32_tCriticalSectionDefaultTimeout;388 uint32_tDeCommitFreeBlockThreshold;389 uint32_tDeCommitTotalFreeThreshold;390 uint32_tLockPrefixTable;391 uint32_tMaximumAllocationSize;392 uint32_tVirtualMemoryThreshold;393 uint32_tProcessHeapFlags;394 uint32_tProcessAffinityMask;395 uint16_tCSDVersion;396 uint16_tReserved1;397 uint32_tEditList;398 uint32_tSecurityCookie;399 uint32_tSEHandlerTable;400 uint32_tSEHandlerCount;381 KU32 Size; 382 KU32 TimeDateStamp; 383 KU16 MajorVersion; 384 KU16 MinorVersion; 385 KU32 GlobalFlagsClear; 386 KU32 GlobalFlagsSet; 387 KU32 CriticalSectionDefaultTimeout; 388 KU32 DeCommitFreeBlockThreshold; 389 KU32 DeCommitTotalFreeThreshold; 390 KU32 LockPrefixTable; 391 KU32 MaximumAllocationSize; 392 KU32 VirtualMemoryThreshold; 393 KU32 ProcessHeapFlags; 394 KU32 ProcessAffinityMask; 395 KU16 CSDVersion; 396 KU16 Reserved1; 397 KU32 EditList; 398 KU32 SecurityCookie; 399 KU32 SEHandlerTable; 400 KU32 SEHandlerCount; 401 401 } IMAGE_LOAD_CONFIG_DIRECTORY32; 402 402 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY32; … … 404 404 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64 405 405 { 406 uint32_tSize;407 uint32_tTimeDateStamp;408 uint16_tMajorVersion;409 uint16_tMinorVersion;410 uint32_tGlobalFlagsClear;411 uint32_tGlobalFlagsSet;412 uint32_tCriticalSectionDefaultTimeout;413 uint64_tDeCommitFreeBlockThreshold;414 uint64_tDeCommitTotalFreeThreshold;415 uint64_tLockPrefixTable;416 uint64_tMaximumAllocationSize;417 uint64_tVirtualMemoryThreshold;418 uint64_tProcessAffinityMask;419 uint32_tProcessHeapFlags;420 uint16_tCSDVersion;421 uint16_tReserved1;422 uint64_tEditList;423 uint64_tSecurityCookie;424 uint64_tSEHandlerTable;425 uint64_tSEHandlerCount;406 KU32 Size; 407 KU32 TimeDateStamp; 408 KU16 MajorVersion; 409 KU16 MinorVersion; 410 KU32 GlobalFlagsClear; 411 KU32 GlobalFlagsSet; 412 KU32 CriticalSectionDefaultTimeout; 413 KU64 DeCommitFreeBlockThreshold; 414 KU64 DeCommitTotalFreeThreshold; 415 KU64 LockPrefixTable; 416 KU64 MaximumAllocationSize; 417 KU64 VirtualMemoryThreshold; 418 KU64 ProcessAffinityMask; 419 KU32 ProcessHeapFlags; 420 KU16 CSDVersion; 421 KU16 Reserved1; 422 KU64 EditList; 423 KU64 SecurityCookie; 424 KU64 SEHandlerTable; 425 KU64 SEHandlerCount; 426 426 } IMAGE_LOAD_CONFIG_DIRECTORY64; 427 427 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 *PIMAGE_LOAD_CONFIG_DIRECTORY64; … … 429 429 typedef struct _IMAGE_DEBUG_DIRECTORY 430 430 { 431 uint32_tCharacteristics;432 uint32_tTimeDateStamp;433 uint16_tMajorVersion;434 uint16_tMinorVersion;435 uint32_tType;436 uint32_tSizeOfData;437 uint32_tAddressOfRawData;438 uint32_tPointerToRawData;431 KU32 Characteristics; 432 KU32 TimeDateStamp; 433 KU16 MajorVersion; 434 KU16 MinorVersion; 435 KU32 Type; 436 KU32 SizeOfData; 437 KU32 AddressOfRawData; 438 KU32 PointerToRawData; 439 439 } IMAGE_DEBUG_DIRECTORY; 440 440 typedef IMAGE_DEBUG_DIRECTORY *PIMAGE_DEBUG_DIRECTORY; … … 451 451 typedef struct _IMAGE_TLS_DIRECTORY32 452 452 { 453 uint32_tStartAddressOfRawData;454 uint32_tEndAddressOfRawData;455 uint32_tAddressOfIndex;456 uint32_tAddressOfCallBacks;457 uint32_tSizeOfZeroFill;458 uint32_tCharacteristics;453 KU32 StartAddressOfRawData; 454 KU32 EndAddressOfRawData; 455 KU32 AddressOfIndex; 456 KU32 AddressOfCallBacks; 457 KU32 SizeOfZeroFill; 458 KU32 Characteristics; 459 459 } IMAGE_TLS_DIRECTORY32; 460 460 typedef IMAGE_TLS_DIRECTORY32 *PIMAGE_TLS_DIRECTORY32; … … 462 462 typedef struct _IMAGE_TLS_DIRECTORY64 463 463 { 464 uint64_tStartAddressOfRawData;465 uint64_tEndAddressOfRawData;466 uint64_tAddressOfIndex;467 uint64_tAddressOfCallBacks;468 uint32_tSizeOfZeroFill;469 uint32_tCharacteristics;464 KU64 StartAddressOfRawData; 465 KU64 EndAddressOfRawData; 466 KU64 AddressOfIndex; 467 KU64 AddressOfCallBacks; 468 KU32 SizeOfZeroFill; 469 KU32 Characteristics; 470 470 } IMAGE_TLS_DIRECTORY64; 471 471 typedef IMAGE_TLS_DIRECTORY64 *PIMAGE_TLS_DIRECTORY64; -
trunk/kStuff/kLdr/kLdrRdr.c
r3549 r3567 139 139 * @param off Where to start reading. 140 140 */ 141 int kLdrRdrRead(PKLDRRDR pRdr, void *pvBuf, size_tcb, KLDRFOFF off)141 int kLdrRdrRead(PKLDRRDR pRdr, void *pvBuf, KSIZE cb, KLDRFOFF off) 142 142 { 143 143 KLDRRDR_VALIDATE(pRdr); … … 215 215 * @param pRdr The file provider instance. 216 216 */ 217 size_tkLdrRdrPageSize(PKLDRRDR pRdr)217 KSIZE kLdrRdrPageSize(PKLDRRDR pRdr) 218 218 { 219 219 KLDRRDR_VALIDATE_EX(pRdr, 0x10000); … … 236 236 * @param fFixed If set, the address at *ppvBase should be the base address of the mapping. 237 237 */ 238 int kLdrRdrMap(PKLDRRDR pRdr, void **ppvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fFixed)238 int kLdrRdrMap(PKLDRRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fFixed) 239 239 { 240 240 KLDRRDR_VALIDATE(pRdr); … … 252 252 * @param paSegments The segments thats going to be mapped. 253 253 */ 254 int kLdrRdrRefresh(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments)254 int kLdrRdrRefresh(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments) 255 255 { 256 256 KLDRRDR_VALIDATE(pRdr); … … 273 273 * When clean the segment protection is restored. 274 274 */ 275 int kLdrRdrProtect(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect)275 int kLdrRdrProtect(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect) 276 276 { 277 277 KLDRRDR_VALIDATE(pRdr); … … 289 289 * @param paSegments The segments thats going to be mapped. 290 290 */ 291 int kLdrRdrUnmap(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments)291 int kLdrRdrUnmap(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments) 292 292 { 293 293 KLDRRDR_VALIDATE(pRdr); -
trunk/kStuff/kLdr/kLdrRdrFile.c
r3537 r3567 184 184 void *pv; 185 185 /** The size of the prepared region. */ 186 size_tcb;186 KSIZE cb; 187 187 #if defined(__WIN__) || defined(__NT__) 188 188 /** Handle to the section created to map the file. */ … … 213 213 KLDRRDRFILEPREP aPreps[4]; 214 214 /** The number of current preps. */ 215 uint32_tcPreps;215 KU32 cPreps; 216 216 /** Number of mapping references. */ 217 int32_tcMappings;217 KI32 cMappings; 218 218 /** The memory mapping. */ 219 219 void *pvMapping; … … 227 227 *******************************************************************************/ 228 228 static void kldrRdrFileDone(PKLDRRDR pRdr); 229 static int kldrRdrFileUnmap(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments);230 static int kldrRdrFileGenericUnmap(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, uint32_tcSegments, PCKLDRSEG paSegments);231 static int kldrRdrFileProtect(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect);232 static int kldrRdrFileGenericProtect(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect);233 static int kldrRdrFileRefresh(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments);234 static int kldrRdrFileGenericRefresh(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, uint32_tcSegments, PCKLDRSEG paSegments);235 static int kldrRdrFileMap(PKLDRRDR pRdr, void **ppvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fFixed);236 static int kldrRdrFileGenericMap(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fFixed);237 static size_tkldrRdrFilePageSize(PKLDRRDR pRdr);229 static int kldrRdrFileUnmap(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 230 static int kldrRdrFileGenericUnmap(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments); 231 static int kldrRdrFileProtect(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect); 232 static int kldrRdrFileGenericProtect(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect); 233 static int kldrRdrFileRefresh(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 234 static int kldrRdrFileGenericRefresh(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments); 235 static int kldrRdrFileMap(PKLDRRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fFixed); 236 static int kldrRdrFileGenericMap(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, unsigned fFixed); 237 static KSIZE kldrRdrFilePageSize(PKLDRRDR pRdr); 238 238 static const char *kldrRdrFileName(PKLDRRDR pRdr); 239 239 static KLDRFOFF kldrRdrFileTell(PKLDRRDR pRdr); … … 241 241 static int kldrRdrFileAllUnmap(PKLDRRDR pRdr, const void *pvBits); 242 242 static int kldrRdrFileAllMap(PKLDRRDR pRdr, const void **ppvBits); 243 static int kldrRdrFileRead(PKLDRRDR pRdr, void *pvBuf, size_tcb, KLDRFOFF off);243 static int kldrRdrFileRead(PKLDRRDR pRdr, void *pvBuf, KSIZE cb, KLDRFOFF off); 244 244 static int kldrRdrFileDestroy(PKLDRRDR pRdr); 245 245 static int kldrRdrFileCreate(PPKLDRRDR ppRdr, const char *pszFilename); … … 335 335 static PKLDRRDRFILEPREP kldrRdrFileFindPrepExact(PKLDRRDRFILE pFile, void *pv) 336 336 { 337 int32_ti = pFile->cPreps;337 KI32 i = pFile->cPreps; 338 338 while (i-- > 0) 339 339 if (pFile->aPreps[i].pv == pv) … … 344 344 345 345 /** @copydoc KLDRRDR::pfnUnmap */ 346 static int kldrRdrFileUnmap(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments)346 static int kldrRdrFileUnmap(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments) 347 347 { 348 348 PKLDRRDRFILE pRdrFile = (PKLDRRDRFILE)pRdr; … … 374 374 375 375 /** Generic implementation of kldrRdrFileUnmap. */ 376 static int kldrRdrFileGenericUnmap(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, uint32_tcSegments, PCKLDRSEG paSegments)376 static int kldrRdrFileGenericUnmap(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments) 377 377 { 378 378 kldrRdrFileGenericProtect(pRdr, pPrep, cSegments, paSegments, 1 /* unprotect */); … … 382 382 383 383 /** @copydoc KLDRRDR::pfnProtect */ 384 static int kldrRdrFileProtect(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect)384 static int kldrRdrFileProtect(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect) 385 385 { 386 386 PKLDRRDRFILE pRdrFile = (PKLDRRDRFILE)pRdr; … … 402 402 403 403 /** Generic implementation of kldrRdrFileProtect. */ 404 static int kldrRdrFileGenericProtect(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect)405 { 406 uint32_ti;404 static int kldrRdrFileGenericProtect(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect) 405 { 406 KU32 i; 407 407 408 408 /* … … 450 450 } 451 451 452 pv = ( uint8_t*)pPrep->pv + paSegments[i].RVA;452 pv = (KU8 *)pPrep->pv + paSegments[i].RVA; 453 453 454 454 rc = kldrHlpPageProtect(pv, paSegments[i].cbMapped, enmProt); … … 462 462 463 463 /** @copydoc KLDRRDR::pfnRefresh */ 464 static int kldrRdrFileRefresh(PKLDRRDR pRdr, void *pvBase, uint32_tcSegments, PCKLDRSEG paSegments)464 static int kldrRdrFileRefresh(PKLDRRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments) 465 465 { 466 466 PKLDRRDRFILE pRdrFile = (PKLDRRDRFILE)pRdr; … … 482 482 483 483 /** Generic implementation of kldrRdrFileRefresh. */ 484 static int kldrRdrFileGenericRefresh(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, uint32_tcSegments, PCKLDRSEG paSegments)484 static int kldrRdrFileGenericRefresh(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments) 485 485 { 486 486 int rc; 487 487 int rc2; 488 uint32_ti;488 KU32 i; 489 489 490 490 /* … … 517 517 continue; 518 518 519 pv = ( uint8_t*)pPrep->pv + paSegments[i].RVA;519 pv = (KU8 *)pPrep->pv + paSegments[i].RVA; 520 520 rc = pRdr->pOps->pfnRead(pRdr, pv, paSegments[i].cbFile, paSegments[i].offFile); 521 521 if (rc) … … 535 535 536 536 /** @copydoc KLDRRDR::pfnMap */ 537 static int kldrRdrFileMap(PKLDRRDR pRdr, void **ppvBase, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fFixed)537 static int kldrRdrFileMap(PKLDRRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsigned fFixed) 538 538 { 539 539 PKLDRRDRFILE pRdrFile = (PKLDRRDRFILE)pRdr; 540 540 PKLDRRDRFILEPREP pPrep = &pRdrFile->aPreps[pRdrFile->cPreps]; 541 541 KLDRSIZE cbTotal; 542 const size_tcbPage = pRdr->pOps->pfnPageSize(pRdr);542 const KSIZE cbPage = pRdr->pOps->pfnPageSize(pRdr); 543 543 int rc; 544 uint32_ti;544 KU32 i; 545 545 546 546 if (pRdrFile->cPreps >= KLDR_ELEMENTS(pRdrFile->aPreps)) … … 560 560 cbTotal = uRVASegmentEnd; 561 561 } 562 pPrep->cb = ( size_t)cbTotal;562 pPrep->cb = (KSIZE)cbTotal; 563 563 if (pPrep->cb != cbTotal) 564 564 return KLDR_ERR_ADDRESS_OVERFLOW; … … 646 646 { 647 647 pv = NULL; 648 ViewSize = ( size_t)cbTotal;648 ViewSize = (KSIZE)cbTotal; 649 649 650 650 Status = NtAllocateVirtualMemory(NtCurrentProcess(), … … 677 677 continue; 678 678 679 pv = ( uint8_t*)pPrep->pv + paSegments[i].RVA;679 pv = (KU8 *)pPrep->pv + paSegments[i].RVA; 680 680 if (paSegments[i].cbFile > 0) 681 681 { … … 735 735 continue; 736 736 737 pv = ( uint8_t*)pPrep->pv + paSegments[i].RVA;737 pv = (KU8 *)pPrep->pv + paSegments[i].RVA; 738 738 if (paSegments[i].cbFile > 0) 739 739 NtUnmapViewOfSection(NtCurrentProcess(), pv); … … 763 763 764 764 /** Generic implementation of kldrRdrFileMap. */ 765 static int kldrRdrFileGenericMap(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, uint32_tcSegments, PCKLDRSEG paSegments, unsigned fFixed)765 static int kldrRdrFileGenericMap(PKLDRRDR pRdr, PKLDRRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, unsigned fFixed) 766 766 { 767 767 int rc; 768 uint32_ti;768 KU32 i; 769 769 770 770 /* … … 786 786 continue; 787 787 788 pv = ( uint8_t*)pPrep->pv + paSegments[i].RVA;788 pv = (KU8 *)pPrep->pv + paSegments[i].RVA; 789 789 rc = pRdr->pOps->pfnRead(pRdr, pv, paSegments[i].cbFile, paSegments[i].offFile); 790 790 if (rc) … … 810 810 811 811 /** @copydoc KLDRRDR::pfnPageSize */ 812 static size_tkldrRdrFilePageSize(PKLDRRDR pRdr)812 static KSIZE kldrRdrFilePageSize(PKLDRRDR pRdr) 813 813 { 814 814 #ifdef __OS2__ … … 941 941 942 942 /** @copydoc KLDRRDR::pfnRead */ 943 static int kldrRdrFileRead(PKLDRRDR pRdr, void *pvBuf, size_tcb, KLDRFOFF off)943 static int kldrRdrFileRead(PKLDRRDR pRdr, void *pvBuf, KSIZE cb, KLDRFOFF off) 944 944 { 945 945 PKLDRRDRFILE pRdrFile = (PKLDRRDRFILE)pRdr; … … 1059 1059 static int kldrRdrFileCreate(PPKLDRRDR ppRdr, const char *pszFilename) 1060 1060 { 1061 size_tcchFilename;1061 KSIZE cchFilename; 1062 1062 PKLDRRDRFILE pRdrFile; 1063 1063 … … 1073 1073 char szFilename[CCHMAXPATH]; 1074 1074 1075 if (( uintptr_t)pszFilename >= 0x20000000)1075 if ((KUPTR)pszFilename >= 0x20000000) 1076 1076 { 1077 1077 char *psz; -
trunk/kStuff/kLdr/tstkLdrMod.c
r3537 r3567 70 70 71 71 /** Dummy import resolver callback. */ 72 static int BasicTestsGetImport(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pchSymbol, size_tcchSymbol,73 const char *pszVersion, PKLDRADDR puValue, uint32_t*pfKind, void *pvUser)72 static int BasicTestsGetImport(PKLDRMOD pMod, KU32 iImport, KU32 iSymbol, const char *pchSymbol, KSIZE cchSymbol, 73 const char *pszVersion, PKLDRADDR puValue, KU32 *pfKind, void *pvUser) 74 74 { 75 75 *puValue = 0xdeadface; … … 82 82 * Verbose memcmp(). 83 83 */ 84 static int TestMemComp(const void *pv1, const void *pv2, size_tcb)85 { 86 size_toff;87 const uint8_t *pb1 = (const uint8_t*)pv1;88 const uint8_t *pb2 = (const uint8_t*)pv2;84 static int TestMemComp(const void *pv1, const void *pv2, KSIZE cb) 85 { 86 KSIZE off; 87 const KU8 *pb1 = (const KU8 *)pv1; 88 const KU8 *pb2 = (const KU8 *)pv2; 89 89 if (!memcmp(pb1, pb2, cb)) 90 90 return 0; … … 105 105 static int BasicTestsRelocate(PKLDRMOD pMod, void *pvBits, void *pvBits2) 106 106 { 107 const size_t cbImage = (size_t)kLdrModSize(pMod);107 const KSIZE cbImage = (KSIZE)kLdrModSize(pMod); 108 108 int rc; 109 109 … … 114 114 */ 115 115 memset(pvBits2, 0xfe, cbImage); 116 rc = kLdrModGetBits(pMod, pvBits2, ( uintptr_t)pvBits, BasicTestsGetImport, NULL);116 rc = kLdrModGetBits(pMod, pvBits2, (KUPTR)pvBits, BasicTestsGetImport, NULL); 117 117 if (rc) 118 118 return Failure("failed to get image bits, rc=%d (%s) (a)", rc, kLdrErrStr(rc)); … … 123 123 * Short relocation round trip. 124 124 */ 125 rc = kLdrModRelocateBits(pMod, pvBits2, 0x1000, ( uintptr_t)pvBits, BasicTestsGetImport, NULL);125 rc = kLdrModRelocateBits(pMod, pvBits2, 0x1000, (KUPTR)pvBits, BasicTestsGetImport, NULL); 126 126 if (rc) 127 127 return Failure("failed to relocate, rc=%d (%s) (b1)", rc, kLdrErrStr(rc)); 128 rc = kLdrModRelocateBits(pMod, pvBits2, ( uintptr_t)pvBits, 0x1000, BasicTestsGetImport, NULL);128 rc = kLdrModRelocateBits(pMod, pvBits2, (KUPTR)pvBits, 0x1000, BasicTestsGetImport, NULL); 129 129 if (rc) 130 130 return Failure("failed to relocate, rc=%d (%s) (b2)", rc, kLdrErrStr(rc)); … … 136 136 */ 137 137 /* stage one */ 138 rc = kLdrModRelocateBits(pMod, pvBits, 0x1000000, ( uintptr_t)pvBits, BasicTestsGetImport, NULL);138 rc = kLdrModRelocateBits(pMod, pvBits, 0x1000000, (KUPTR)pvBits, BasicTestsGetImport, NULL); 139 139 if (rc) 140 140 return Failure("failed to relocate, rc=%d (%s) (c1)", rc, kLdrErrStr(rc)); … … 147 147 148 148 /* stage two */ 149 rc = kLdrModRelocateBits(pMod, pvBits, ~( uintptr_t)0x1010000, 0x1000000, BasicTestsGetImport, NULL);149 rc = kLdrModRelocateBits(pMod, pvBits, ~(KUPTR)0x1010000, 0x1000000, BasicTestsGetImport, NULL); 150 150 if (rc) 151 151 return Failure("failed to relocate, rc=%d (%s) (c2)", rc, kLdrErrStr(rc)); 152 152 memset(pvBits2, 0xef, cbImage); 153 rc = kLdrModGetBits(pMod, pvBits2, ~( uintptr_t)0x1010000, BasicTestsGetImport, NULL);153 rc = kLdrModGetBits(pMod, pvBits2, ~(KUPTR)0x1010000, BasicTestsGetImport, NULL); 154 154 if (rc) 155 155 return Failure("failed to get image bits, rc=%d (%s) (c2)", rc, kLdrErrStr(rc)); … … 158 158 159 159 /* stage three */ 160 rc = kLdrModRelocateBits(pMod, pvBits, MY_BASEADDRESS, ~( uintptr_t)0x1010000, BasicTestsGetImport, NULL);160 rc = kLdrModRelocateBits(pMod, pvBits, MY_BASEADDRESS, ~(KUPTR)0x1010000, BasicTestsGetImport, NULL); 161 161 if (rc) 162 162 return Failure("failed to relocate, rc=%d (%s) (c3)", rc, kLdrErrStr(rc)); … … 169 169 170 170 /* stage four */ 171 rc = kLdrModRelocateBits(pMod, pvBits, ~( uintptr_t)0 / 2 - 0x10000, MY_BASEADDRESS, BasicTestsGetImport, NULL);171 rc = kLdrModRelocateBits(pMod, pvBits, ~(KUPTR)0 / 2 - 0x10000, MY_BASEADDRESS, BasicTestsGetImport, NULL); 172 172 if (rc) 173 173 return Failure("failed to relocate, rc=%d %(s) (c4)", rc, kLdrErrStr(rc)); 174 174 memset(pvBits2, 0xdc, cbImage); 175 rc = kLdrModGetBits(pMod, pvBits2, ~( uintptr_t)0 / 2 - 0x10000, BasicTestsGetImport, NULL);175 rc = kLdrModGetBits(pMod, pvBits2, ~(KUPTR)0 / 2 - 0x10000, BasicTestsGetImport, NULL); 176 176 if (rc) 177 177 return Failure("failed to get image bits, rc=%d (%s) (c4)", rc, kLdrErrStr(rc)); … … 180 180 181 181 /* return */ 182 rc = kLdrModRelocateBits(pMod, pvBits, ( uintptr_t)pvBits, ~(uintptr_t)0 / 2 - 0x10000, BasicTestsGetImport, NULL);182 rc = kLdrModRelocateBits(pMod, pvBits, (KUPTR)pvBits, ~(KUPTR)0 / 2 - 0x10000, BasicTestsGetImport, NULL); 183 183 if (rc) 184 184 return Failure("failed to relocate, rc=%d (%s) (c5)", rc, kLdrErrStr(rc)); 185 185 memset(pvBits2, 0xcd, cbImage); 186 rc = kLdrModGetBits(pMod, pvBits2, ( uintptr_t)pvBits, BasicTestsGetImport, NULL);186 rc = kLdrModGetBits(pMod, pvBits2, (KUPTR)pvBits, BasicTestsGetImport, NULL); 187 187 if (rc) 188 188 return Failure("failed to get image bits, rc=%d (%s) (c5)", rc, kLdrErrStr(rc)); … … 197 197 * Dump symbols and check that we can query each of them recursivly. 198 198 */ 199 static int BasicTestsEnumSymCallback(PKLDRMOD pMod, uint32_t iSymbol, const char *pchSymbol, size_tcchSymbol,200 const char *pszVersion, KLDRADDR uValue, uint32_tfKind, void *pvUser)199 static int BasicTestsEnumSymCallback(PKLDRMOD pMod, KU32 iSymbol, const char *pchSymbol, KSIZE cchSymbol, 200 const char *pszVersion, KLDRADDR uValue, KU32 fKind, void *pvUser) 201 201 { 202 202 KLDRADDR uValue2; 203 uint32_tfKind2;203 KU32 fKind2; 204 204 int rc; 205 205 … … 249 249 * Dump debugger information and check it for correctness. 250 250 */ 251 static int BasicTestEnumDbgInfoCallback(PKLDRMOD pMod, uint32_tiDbgInfo, KLDRDBGINFOTYPE enmType,252 int16_t iMajorVer, int16_tiMinorVer, KLDRFOFF offFile, KLDRADDR LinkAddress,251 static int BasicTestEnumDbgInfoCallback(PKLDRMOD pMod, KU32 iDbgInfo, KLDRDBGINFOTYPE enmType, 252 KI16 iMajorVer, KI16 iMinorVer, KLDRFOFF offFile, KLDRADDR LinkAddress, 253 253 KLDRSIZE cb, const char *pszExtFile, void *pvUser) 254 254 { … … 272 272 static int BasicTestsSub2(PKLDRMOD pMod, void *pvBits) 273 273 { 274 int32_tcImports;275 int32_ti;274 KI32 cImports; 275 KI32 i; 276 276 int rc; 277 uint32_tfKind;277 KU32 fKind; 278 278 KLDRADDR Value; 279 279 KLDRADDR MainEPAddress; … … 395 395 { 396 396 int rc; 397 uint32_ti;397 KU32 i; 398 398 void *pvBits; 399 size_tcbImage;399 KSIZE cbImage; 400 400 401 401 /* … … 479 479 printf("* Testing user mapping...\n"); 480 480 481 cbImage = ( size_t)kLdrModSize(pMod);481 cbImage = (KSIZE)kLdrModSize(pMod); 482 482 if (cbImage != kLdrModSize(pMod)) 483 483 return Failure("aborting test because the image is too huge!"); 484 pvBits = malloc(( size_t)cbImage);484 pvBits = malloc((KSIZE)cbImage); 485 485 if (!pvBits) 486 486 return Failure("failed to allocate %d bytes for the image", cbImage); 487 487 488 rc = kLdrModGetBits(pMod, pvBits, ( uintptr_t)pvBits, BasicTestsGetImport, NULL);488 rc = kLdrModGetBits(pMod, pvBits, (KUPTR)pvBits, BasicTestsGetImport, NULL); 489 489 if (rc) 490 490 return Failure("failed to get image bits, rc=%d (%s)", rc, kLdrErrStr(rc)); … … 499 499 * Test relocating the bits in a few different ways before we're done with them. 500 500 */ 501 void *pvBits2 = malloc(( size_t)cbImage);501 void *pvBits2 = malloc((KSIZE)cbImage); 502 502 if (pvBits2) 503 503 {
Note:
See TracChangeset
for help on using the changeset viewer.