Changeset 3546
- Timestamp:
- Aug 25, 2007, 7:28:50 PM (18 years ago)
- Location:
- trunk/kStuff
- Files:
-
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/include/k/kHlpString.h
r3545 r3546 28 28 #define ___k_kHlpString_h___ 29 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 30 #if 0 /* optimize / fix this later */ 34 31 #ifdef __GNUC__ 35 32 /** memchr */ … … 65 62 # error "Port Me" 66 63 #endif 64 #endif /* disabled */ 67 65 68 66 #ifdef __cplusplus … … 77 75 #endif 78 76 #ifndef kHlpMemCopy 79 void *kHlpMem Mopy(void *pv1, const void *pv2, KSIZE cb);77 void *kHlpMemCopy(void *pv1, const void *pv2, KSIZE cb); 80 78 #endif 81 79 #ifndef kHlpMemMove -
trunk/kStuff/include/k/kRdr.h
r3543 r3546 31 31 #include <k/kTypes.h> 32 32 33 #ifdef __cplusplus34 extern "C" {35 #endif36 37 38 33 /** @defgroup grp_kRdr kRdr - The File Provider 39 34 * @{ */ … … 43 38 /** Pointer to a file provider instance pointer. */ 44 39 typedef struct KRDR **PPKRDR; 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 45 44 46 45 int kRdrOpen(PPKRDR ppRdr, const char *pszFilename); … … 56 55 KSIZE kRdrPageSize(PKRDR pRdr); 57 56 #ifndef ___k_kLdr___ 58 int kRdrMap( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsignedfFixed);57 int kRdrMap( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed); 59 58 int kRdrRefresh( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 60 int kRdrProtect( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsignedfUnprotectOrProtect);59 int kRdrProtect( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect); 61 60 int kRdrUnmap( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 62 61 #endif /* !___k_kLdr___ */ 63 62 void kRdrDone( PKRDR pRdr); 64 65 /** @} */66 63 67 64 #ifdef __cplusplus … … 69 66 #endif 70 67 68 /** @} */ 69 71 70 #endif 72 71 -
trunk/kStuff/include/k/kRdrAll.h
r3543 r3546 67 67 int (* pfnDestroy)( PKRDR pRdr); 68 68 /** @copydoc kRdrRead */ 69 int (* pfnRead)( PKRDR pRdr, void *pvBuf, size_tcb, KFOFF off);69 int (* pfnRead)( PKRDR pRdr, void *pvBuf, KSIZE cb, KFOFF off); 70 70 /** @copydoc kRdrAllMap */ 71 71 int (* pfnAllMap)( PKRDR pRdr, const void **ppvBits); … … 83 83 KSIZE (* pfnPageSize)(PKRDR pRdr); 84 84 /** @copydoc kRdrMap */ 85 int (* pfnMap)( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsignedfFixed);85 int (* pfnMap)( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed); 86 86 /** @copydoc kRdrRefresh */ 87 87 int (* pfnRefresh)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 88 88 /** @copydoc kRdrProtect */ 89 int (* pfnProtect)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsignedfUnprotectOrProtect);89 int (* pfnProtect)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect); 90 90 /** @copydoc kRdrUnmap */ 91 91 int (* pfnUnmap)( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); -
trunk/kStuff/kRdr/Makefile.kmk
r3543 r3546 36 36 kRdrStatic_INCS = ../kLdr 37 37 kRdrStatic_SOURCES = \ 38 kRdr.c \39 kRdrFile.c 38 kRdr.cpp \ 39 kRdrFile.cpp 40 40 41 41 # Generate the rules -
trunk/kStuff/kRdr/kRdrFile.cpp
r3545 r3546 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #include <k/kDefs.h> 31 #include "kRdrInternal.h" 32 #include <k/kHlpAlloc.h> 33 #include <k/kHlpString.h> 32 34 33 35 #if K_OS == K_OS_OS2 … … 154 156 #endif 155 157 156 #include "kRdrInternal.h"157 #include <k/kHlpAlloc.h>158 #include <k/kHlpString.h>159 160 158 161 159 /******************************************************************************* … … 215 213 static int krdrFileUnmap(PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 216 214 static int krdrFileGenericUnmap(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments); 217 static int krdrFileProtect(PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsignedfUnprotectOrProtect);218 static int krdrFileGenericProtect(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, unsignedfUnprotectOrProtect);215 static int krdrFileProtect(PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect); 216 static int krdrFileGenericProtect(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect); 219 217 static int krdrFileRefresh(PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments); 220 218 static int krdrFileGenericRefresh(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments); 221 static int krdrFileMap(PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsignedfFixed);222 static int krdrFileGenericMap(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, unsignedfFixed);219 static int krdrFileMap(PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed); 220 static int krdrFileGenericMap(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed); 223 221 static KSIZE krdrFilePageSize(PKRDR pRdr); 224 222 static const char *krdrFileName(PKRDR pRdr); … … 370 368 371 369 /** @copydoc KRDROPS::pfnProtect */ 372 static int krdrFileProtect(PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, unsignedfUnprotectOrProtect)370 static int krdrFileProtect(PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect) 373 371 { 374 372 PKRDRFILE pRdrFile = (PKRDRFILE)pRdr; … … 390 388 391 389 /** Generic implementation of krdrFileProtect. */ 392 static int krdrFileGenericProtect(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, unsignedfUnprotectOrProtect)390 static int krdrFileGenericProtect(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect) 393 391 { 394 392 KU32 i; … … 401 399 int rc; 402 400 void *pv; 403 K LDRPROT enmProt;401 KPROT enmProt; 404 402 405 403 if (paSegments[i].RVA == NIL_KLDRADDR) … … 407 405 408 406 /* calc new protection. */ 409 enmProt = paSegments[i].enmProt;407 enmProt = (KPROT)paSegments[i].enmProt; /** @todo drop cast */ 410 408 if (fUnprotectOrProtect) 411 409 { 412 410 switch (enmProt) 413 411 { 414 case K LDRPROT_NOACCESS:415 case K LDRPROT_READONLY:416 case K LDRPROT_READWRITE:417 case K LDRPROT_WRITECOPY:418 enmProt = K LDRPROT_READWRITE;412 case KPROT_NOACCESS: 413 case KPROT_READONLY: 414 case KPROT_READWRITE: 415 case KPROT_WRITECOPY: 416 enmProt = KPROT_READWRITE; 419 417 break; 420 case K LDRPROT_EXECUTE:421 case K LDRPROT_EXECUTE_READ:422 case K LDRPROT_EXECUTE_READWRITE:423 case K LDRPROT_EXECUTE_WRITECOPY:424 enmProt = K LDRPROT_EXECUTE_READWRITE;418 case KPROT_EXECUTE: 419 case KPROT_EXECUTE_READ: 420 case KPROT_EXECUTE_READWRITE: 421 case KPROT_EXECUTE_WRITECOPY: 422 enmProt = KPROT_EXECUTE_READWRITE; 425 423 break; 426 424 default: … … 432 430 { 433 431 /* copy on write -> normal write. */ 434 if (enmProt == K LDRPROT_EXECUTE_WRITECOPY)435 enmProt = K LDRPROT_EXECUTE_READWRITE;436 else if (enmProt == K LDRPROT_WRITECOPY)437 enmProt = K LDRPROT_READWRITE;432 if (enmProt == KPROT_EXECUTE_WRITECOPY) 433 enmProt = KPROT_EXECUTE_READWRITE; 434 else if (enmProt == KPROT_WRITECOPY) 435 enmProt = KPROT_READWRITE; 438 436 } 439 437 … … 523 521 524 522 /** @copydoc KRDROPS::pfnMap */ 525 static int krdrFileMap(PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, unsignedfFixed)523 static int krdrFileMap(PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed) 526 524 { 527 525 PKRDRFILE pRdrFile = (PKRDRFILE)pRdr; … … 751 749 752 750 /** Generic implementation of krdrFileMap. */ 753 static int krdrFileGenericMap(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, unsignedfFixed)751 static int krdrFileGenericMap(PKRDR pRdr, PKRDRFILEPREP pPrep, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed) 754 752 { 755 753 int rc; … … 759 757 * Generic mapping code using kHlpPageAlloc(), kHlpPageFree() and kHlpPageProtect(). 760 758 */ 761 rc = kHlpPageAlloc(&pPrep->pv, pPrep->cb, K LDRPROT_EXECUTE_READWRITE, fFixed);759 rc = kHlpPageAlloc(&pPrep->pv, pPrep->cb, KPROT_EXECUTE_READWRITE, fFixed); 762 760 if (rc) 763 761 return rc; … … 914 912 { 915 913 int rc; 916 KFOFF cb = pRdrFile->Core.pOps->pfnSize(pRdr); 914 KFOFF cbFile = pRdrFile->Core.pOps->pfnSize(pRdr); 915 KSIZE cb = (KSIZE)cbFile; 916 if (cb != cbFile) 917 return ERROR_NOT_ENOUGH_MEMORY; 917 918 918 919 pRdrFile->pvMapping = kHlpAlloc(cb); … … 964 965 LONG offLow; 965 966 966 offHigh = sizeof(KFOFF) == 4 ? 0 :(off >> 32);967 offHigh = (LONG)(off >> 32); 967 968 offLow = SetFilePointer(pRdrFile->File, (LONG)off, &offHigh, FILE_BEGIN); 968 969 if ( offLow != (LONG)off 969 || offHigh != (LONG)( sizeof(KFOFF) == 4 ? 0 : (off >> 32)))970 || offHigh != (LONG)(off >> 32)) 970 971 { 971 972 int rc = GetLastError(); … … 1133 1134 return rc; 1134 1135 } 1135 if (sizeof(KFOFF) == 4) 1136 cb = High ? 0x7fffffff : Low; 1137 else 1138 cb = ((KFOFF)High << 32) | Low; 1136 cb = ((KFOFF)High << 32) | Low; 1139 1137 1140 1138 #else
Note:
See TracChangeset
for help on using the changeset viewer.