Changeset 3546 for trunk/kStuff/kRdr/kRdrFile.cpp
- Timestamp:
- Aug 25, 2007, 7:28:50 PM (18 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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.