Changeset 82 for trunk/kLdr/kLdrModNative.c
- Timestamp:
- Aug 22, 2016, 11:01:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/kLdrModNative.c
r81 r82 239 239 { 240 240 KSIZE cb; 241 K SIZEcchFilename;241 KU32 cchFilename; 242 242 KU32 cSegments; 243 243 PKLDRMOD pMod; … … 309 309 * Calc the instance size, allocate and initialize it. 310 310 */ 311 cchFilename = kHlpStrLen(szFilename);311 cchFilename = (KU32)kHlpStrLen(szFilename); 312 312 cb = K_ALIGN_Z(sizeof(KLDRMODNATIVE), 16) 313 313 + K_OFFSETOF(KLDRMOD, aSegments[cSegments]) … … 327 327 kHlpMemCopy((char *)pMod->pszFilename, szFilename, cchFilename + 1); 328 328 pMod->pszName = kHlpGetFilename(pMod->pszFilename); /** @todo get soname */ 329 pMod->cchName = cchFilename - ( pMod->pszName - pMod->pszFilename);329 pMod->cchName = cchFilename - (KU32)(pMod->pszName - pMod->pszFilename); 330 330 pMod->fFlags = 0; 331 331 #if defined(__i386__) || defined(__X86__) || defined(_M_IX86) … … 398 398 else 399 399 pMod->aSegments[0].cbMapped = pNtHdrs->OptionalHeader.SizeOfHeaders; 400 pMod->aSegments[0].MapAddress = 0;400 pMod->aSegments[0].MapAddress = uHandle; 401 401 402 402 /* The section headers. */ … … 404 404 { 405 405 const char *pch; 406 KU32 cchSegName; 406 407 407 408 /* unused */ 408 409 pMod->aSegments[i + 1].pvUser = NULL; 409 pMod->aSegments[i + 1].MapAddress = 0;410 410 411 411 /* name */ 412 412 pMod->aSegments[i + 1].pchName = pch = &paShdrs[i].Name[0]; 413 c b= IMAGE_SIZEOF_SHORT_NAME;414 while ( cb> 0415 && (pch[cb - 1] == ' ' || pch[cb- 1] == '\0'))416 c b--;417 pMod->aSegments[i + 1].cchName = c b;413 cchSegName = IMAGE_SIZEOF_SHORT_NAME; 414 while ( cchSegName > 0 415 && (pch[cchSegName - 1] == ' ' || pch[cchSegName - 1] == '\0')) 416 cchSegName--; 417 pMod->aSegments[i + 1].cchName = cchSegName; 418 418 419 419 /* size and addresses */ … … 421 421 { 422 422 pMod->aSegments[i + 1].cb = paShdrs[i].Misc.VirtualSize; 423 pMod->aSegments[i + 1].LinkAddress = paShdrs[i].VirtualAddress424 + pNtHdrs->OptionalHeader.ImageBase;425 423 pMod->aSegments[i + 1].RVA = paShdrs[i].VirtualAddress; 424 pMod->aSegments[i + 1].LinkAddress = paShdrs[i].VirtualAddress + pNtHdrs->OptionalHeader.ImageBase; 425 pMod->aSegments[i + 1].MapAddress = paShdrs[i].VirtualAddress + uHandle; 426 426 pMod->aSegments[i + 1].cbMapped = paShdrs[i].Misc.VirtualSize; 427 427 if (i + 2 < pMod->cSegments) 428 pMod->aSegments[i + 1].cbMapped = paShdrs[i + 1].VirtualAddress429 - paShdrs[i].VirtualAddress;428 pMod->aSegments[i + 1].cbMapped = paShdrs[i + 1].VirtualAddress 429 - paShdrs[i].VirtualAddress; 430 430 } 431 431 else … … 435 435 pMod->aSegments[i + 1].LinkAddress = NIL_KLDRADDR; 436 436 pMod->aSegments[i + 1].RVA = 0; 437 pMod->aSegments[i + 1].MapAddress = 0; 437 438 } 438 439 439 440 /* file location */ 440 441 pMod->aSegments[i + 1].offFile = paShdrs[i].PointerToRawData; 441 pMod->aSegments[i + 1].cbFile = paShdrs[i].SizeOfRawData;442 pMod->aSegments[i + 1].cbFile = paShdrs[i].SizeOfRawData; 442 443 if ( pMod->aSegments[i + 1].cbMapped > 0 /* if mapped */ 443 444 && (KLDRSIZE)pMod->aSegments[i + 1].cbFile > pMod->aSegments[i + 1].cbMapped) 444 pMod->aSegments[i + 1].cbFile = pMod->aSegments[i + 1].cbMapped;445 pMod->aSegments[i + 1].cbFile = (KLDRFOFF)pMod->aSegments[i + 1].cbMapped; 445 446 446 447 /* protection */
Note:
See TracChangeset
for help on using the changeset viewer.