Changeset 3567 for trunk/kStuff/kLdr/kLdrRdrFile.c
- Timestamp:
- Aug 27, 2007, 9:54:05 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.