Changeset 54
- Timestamp:
- Oct 9, 2013, 9:52:48 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/k/kErrors.h
r29 r54 206 206 /** Unsupported CPU subtype found in a FAT entry. */ 207 207 #define KLDR_ERR_FAT_UNSUPPORTED_CPU_SUBTYPE (KLDR_ERR_BASE + 37) 208 /** The image has no UUID. */ 209 #define KLDR_ERR_NO_IMAGE_UUID (KLDR_ERR_BASE + 38) 208 210 /** @} */ 209 211 … … 212 214 */ 213 215 /** The base of the kLdrModPE specific status codes. */ 214 #define KLDR_ERR_PE_BASE (KLDR_ERR_BASE + 3 8)216 #define KLDR_ERR_PE_BASE (KLDR_ERR_BASE + 39) 215 217 /** The machine isn't supported by the interpreter. */ 216 218 #define KLDR_ERR_PE_UNSUPPORTED_MACHINE (KLDR_ERR_PE_BASE + 0) -
trunk/include/k/kLdr.h
r52 r54 614 614 int kLdrModGetStackInfo(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo); 615 615 int kLdrModQueryMainEntrypoint(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress); 616 int kLdrModQueryImageUuid(PKLDRMOD pMod, const void *pvBits, void *pvUuid, KSIZE cbUuid); 616 617 int kLdrModQueryResource(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 idType, const char *pszType, 617 618 KU32 idName, const char *pszName, KU32 idLang, PKLDRADDR pAddrRsrc, KSIZE *pcbRsrc); … … 699 700 /** @copydoc kLdrModQueryMainEntrypoint */ 700 701 int (* pfnQueryMainEntrypoint)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress); 702 /** @copydoc kLdrModQueryImageUuid */ 703 int (* pfnQueryImageUuid)(PKLDRMOD pMod, const void *pvBits, void *pvUuid, KSIZE pcbUuid); 701 704 /** @copydoc kLdrModQueryResource */ 702 705 int (* pfnQueryResource)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 idType, const char *pszType, -
trunk/kLdr/kLdrMod.c
r52 r54 511 511 * @param pvBits Optional pointer to bits returned by kLdrModGetBits(). 512 512 * This can be used by some module interpreters to reduce memory consumption. 513 * @param enmArch The CPU architecture. 514 * @param enmCpu The CPU series/model. 513 515 */ 514 516 int kLdrModCanExecuteOn(PKLDRMOD pMod, const void *pvBits, KCPUARCH enmArch, KCPU enmCpu) … … 560 562 *pMainEPAddress = 0; 561 563 return pMod->pOps->pfnQueryMainEntrypoint(pMod, pvBits, BaseAddress, pMainEPAddress); 564 } 565 566 567 /** 568 * Queries the image UUID, if the image has one. 569 * 570 * @returns 0 and *pvUuid. Non-zero status code on failure. 571 * @param pMod The module. 572 * @param pvBits Optional pointer to bits returned by kLdrModGetBits() currently located at BaseAddress. 573 * This can be used by some module interpreters to reduce memory consumption. 574 * @param pvUuid Where to store the UUID. 575 * @param cbUuid Size of the UUID buffer, must be at least 16 bytes. 576 */ 577 int kLdrModQueryImageUuid(PKLDRMOD pMod, const void *pvBits, void *pvUuid, KSIZE cbUuid) 578 { 579 KLDRMOD_VALIDATE(pMod); 580 if (cbUuid < 16) 581 return KERR_INVALID_SIZE; 582 if (pMod->pOps->pfnQueryImageUuid) 583 return pMod->pOps->pfnQueryImageUuid(pMod, pvBits, pvUuid, cbUuid); 584 return KLDR_ERR_NO_IMAGE_UUID; 562 585 } 563 586 -
trunk/kLdr/kLdrModLX.c
r29 r54 2640 2640 kldrModLXGetStackInfo, 2641 2641 kldrModLXQueryMainEntrypoint, 2642 NULL /* pfnQueryImageUuid */, 2642 2643 NULL /* fixme */, 2643 2644 NULL /* fixme */, -
trunk/kLdr/kLdrModMachO.c
r53 r54 164 164 /** Pointer to the loaded string table. */ 165 165 char *pchStrings; 166 167 /** The image UUID, all zeros if not found. */ 168 KU8 abImageUuid[16]; 166 169 167 170 /** The RVA of the Global Offset Table. */ … … 475 478 pModMachO->cchStrings = 0; 476 479 pModMachO->pchStrings = NULL; 480 kHlpMemSet(pModMachO->abImageUuid, 0, sizeof(pModMachO->abImageUuid)); 477 481 pModMachO->GotRVA = NIL_KLDRADDR; 478 482 pModMachO->JmpStubsRVA = NIL_KLDRADDR; … … 1117 1121 const segment_command_64_t *pSeg64; 1118 1122 const symtab_command_t *pSymTab; 1123 const uuid_command_t *pUuid; 1119 1124 } u; 1120 1125 const char *pchCurSegName = NULL; … … 1426 1431 break; 1427 1432 1433 case LC_UUID: 1434 kHlpMemCopy(pModMachO->abImageUuid, u.pUuid->uuid, sizeof(pModMachO->abImageUuid)); 1435 break; 1436 1428 1437 default: 1429 1438 break; … … 2404 2413 *pMainEPAddress = NIL_KLDRADDR; 2405 2414 #endif 2415 return 0; 2416 } 2417 2418 2419 /** @copydoc kLdrModQueryImageUuid */ 2420 static int kldrModMachOQueryImageUuid(PKLDRMOD pMod, const void *pvBits, void *pvUuid, KSIZE cbUuid) 2421 { 2422 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; 2423 kHlpMemSet(pvUuid, 0, cbUuid); 2424 if (kHlpMemComp(pvUuid, pModMachO->abImageUuid, sizeof(pModMachO->abImageUuid)) == 0) 2425 return KLDR_ERR_NO_IMAGE_UUID; 2426 kHlpMemCopy(pvUuid, pModMachO->abImageUuid, sizeof(pModMachO->abImageUuid)); 2406 2427 return 0; 2407 2428 } … … 3739 3760 kldrModMachOGetStackInfo, 3740 3761 kldrModMachOQueryMainEntrypoint, 3762 kldrModMachOQueryImageUuid, 3741 3763 NULL, 3742 3764 NULL, -
trunk/kLdr/kLdrModNative.c
r29 r54 1136 1136 kldrModNativeGetStackInfo, 1137 1137 kldrModNativeQueryMainEntrypoint, 1138 NULL /* pfnQueryImageUuid */, 1138 1139 NULL /* fixme */, 1139 1140 NULL /* fixme */, -
trunk/kLdr/kLdrModPE.c
r41 r54 1979 1979 kldrModPEGetStackInfo, 1980 1980 kldrModPEQueryMainEntrypoint, 1981 NULL /* pfnQueryImageUuid */, 1981 1982 NULL, /** @todo resources */ 1982 1983 NULL, /** @todo resources */
Note:
See TracChangeset
for help on using the changeset viewer.