Changeset 46048 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- May 14, 2013 7:44:30 AM (12 years ago)
- Location:
- trunk/src/VBox/Runtime/common
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
r45994 r46048 277 277 if (RT_SUCCESS(rc)) 278 278 rc = rtDbgModDebugInterpreterRegister(&g_rtDbgModVtDbgDwarf); 279 #ifdef RT_OS_WINDOWS 280 if (RT_SUCCESS(rc)) 281 rc = rtDbgModDebugInterpreterRegister(&g_rtDbgModVtDbgDbgHelp); 282 #endif 279 283 if (RT_SUCCESS(rc)) 280 284 rc = rtDbgModImageInterpreterRegister(&g_rtDbgModVtImgLdr); -
trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp
r44529 r46048 383 383 VERR_DBG_INVALID_SEGMENT_INDEX); 384 384 AssertMsgReturn( iSeg >= RTDBGSEGIDX_SPECIAL_FIRST 385 || off + cb<= pThis->paSegs[iSeg].cb,385 || off <= pThis->paSegs[iSeg].cb, 386 386 ("off=%RTptr cb=%RTptr cbSeg=%RTptr\n", off, cb, pThis->paSegs[iSeg].cb), 387 387 VERR_DBG_INVALID_SEGMENT_OFFSET); 388 389 /* Be a little relaxed wrt to the symbol size. */ 390 int rc = VINF_SUCCESS; 391 if (off + cb > pThis->paSegs[iSeg].cb) 392 { 393 cb = pThis->paSegs[iSeg].cb - off; 394 rc = VINF_DBG_ADJUSTED_SYM_SIZE; 395 } 388 396 389 397 /* … … 401 409 pSymbol->fFlags = fFlags; 402 410 pSymbol->NameCore.pszString = RTStrCacheEnterN(g_hDbgModStrCache, pszSymbol, cchSymbol); 403 int rc;404 411 if (pSymbol->NameCore.pszString) 405 412 { … … 416 423 *piOrdinal = pThis->iNextSymbolOrdinal; 417 424 pThis->iNextSymbolOrdinal++; 418 return VINF_SUCCESS;425 return rc; 419 426 } 420 427 -
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r46023 r46048 929 929 static DECLCALLBACK(int) rtldrPE_EnumSegments(PRTLDRMODINTERNAL pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser) 930 930 { 931 NOREF(pMod); NOREF(pfnCallback); NOREF(pvUser); 932 return VINF_NOT_SUPPORTED; 931 PRTLDRMODPE pModPe = (PRTLDRMODPE)pMod; 932 RTLDRSEG SegInfo; 933 934 /* 935 * The first section is a fake one covering the headers. 936 */ 937 SegInfo.pchName = "NtHdrs"; 938 SegInfo.cchName = 6; 939 SegInfo.SelFlat = 0; 940 SegInfo.Sel16bit = 0; 941 SegInfo.fFlags = 0; 942 SegInfo.fProt = RTMEM_PROT_READ; 943 SegInfo.Alignment = 1; 944 SegInfo.LinkAddress = 0; 945 SegInfo.RVA = SegInfo.LinkAddress; 946 SegInfo.offFile = 0; 947 SegInfo.cb = pModPe->cbHeaders; 948 SegInfo.cbFile = pModPe->cbHeaders; 949 SegInfo.cbMapped = pModPe->cbHeaders; 950 if ((pModPe->paSections[0].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) 951 SegInfo.cbMapped = pModPe->paSections[0].VirtualAddress; 952 int rc = pfnCallback(pMod, &SegInfo, pvUser); 953 954 /* 955 * Then all the normal sections. 956 */ 957 PCIMAGE_SECTION_HEADER pSh = pModPe->paSections; 958 for (uint32_t i = 0; i < pModPe->cSections && rc == VINF_SUCCESS; i++, pSh++) 959 { 960 SegInfo.pchName = (const char *)&pSh->Name[0]; 961 SegInfo.cchName = (uint32_t)RTStrNLen(SegInfo.pchName, sizeof(pSh->Name)); 962 SegInfo.SelFlat = 0; 963 SegInfo.Sel16bit = 0; 964 SegInfo.fFlags = 0; 965 SegInfo.fProt = RTMEM_PROT_NONE; 966 if (pSh->Characteristics & IMAGE_SCN_MEM_READ) 967 SegInfo.fProt |= RTMEM_PROT_READ; 968 if (pSh->Characteristics & IMAGE_SCN_MEM_WRITE) 969 SegInfo.fProt |= RTMEM_PROT_WRITE; 970 if (pSh->Characteristics & IMAGE_SCN_MEM_EXECUTE) 971 SegInfo.fProt |= RTMEM_PROT_EXEC; 972 SegInfo.Alignment = (pSh->Characteristics & IMAGE_SCN_ALIGN_MASK) >> IMAGE_SCN_ALIGN_SHIFT; 973 if (SegInfo.Alignment > 0) 974 SegInfo.Alignment = RT_BIT_64(SegInfo.Alignment - 1); 975 if (pSh->Characteristics & IMAGE_SCN_TYPE_NOLOAD) 976 { 977 SegInfo.LinkAddress = NIL_RTLDRADDR; 978 SegInfo.RVA = NIL_RTLDRADDR; 979 SegInfo.cbMapped = pSh->Misc.VirtualSize; 980 } 981 else 982 { 983 SegInfo.LinkAddress = pSh->VirtualAddress; 984 SegInfo.RVA = SegInfo.LinkAddress; 985 SegInfo.cbMapped = RT_ALIGN(SegInfo.cb, SegInfo.Alignment); 986 if (i + 1 < pModPe->cSections && !(pSh[1].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) 987 SegInfo.cbMapped = pSh[1].VirtualAddress - pSh->VirtualAddress; 988 } 989 SegInfo.cb = pSh->Misc.VirtualSize; 990 if (pSh->PointerToRawData == 0 || pSh->SizeOfRawData == 0) 991 { 992 SegInfo.offFile = -1; 993 SegInfo.cbFile = 0; 994 } 995 else 996 { 997 SegInfo.offFile = pSh->PointerToRawData; 998 SegInfo.cbFile = pSh->SizeOfRawData; 999 } 1000 1001 rc = pfnCallback(pMod, &SegInfo, pvUser); 1002 } 1003 1004 return rc; 933 1005 } 934 1006 … … 938 1010 uint32_t *piSeg, PRTLDRADDR poffSeg) 939 1011 { 940 NOREF(pMod); NOREF(LinkAddress); NOREF(piSeg); NOREF(poffSeg); 941 return VERR_NOT_IMPLEMENTED; 1012 PRTLDRMODPE pModPe = (PRTLDRMODPE)pMod; 1013 1014 /* Note! LinkAddress == RVA */ 1015 1016 /* Special header segment. */ 1017 if (LinkAddress < pModPe->paSections[0].VirtualAddress) 1018 { 1019 *piSeg = 0; 1020 *poffSeg = LinkAddress; 1021 return VINF_SUCCESS; 1022 } 1023 1024 /* 1025 * Search the normal sections. (Could do this in binary fashion, they're 1026 * sorted, but too much bother right now.) 1027 */ 1028 if (LinkAddress > pModPe->cbImage) 1029 return VERR_LDR_INVALID_LINK_ADDRESS; 1030 uint32_t i = pModPe->cSections; 1031 PCIMAGE_SECTION_HEADER paShs = pModPe->paSections; 1032 while (i-- > 0) 1033 if (!(paShs[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) 1034 { 1035 uint32_t uAddr = paShs[i].VirtualAddress; 1036 if (LinkAddress >= uAddr) 1037 { 1038 *poffSeg = LinkAddress - uAddr; 1039 *piSeg = i + 1; 1040 return VINF_SUCCESS; 1041 } 1042 } 1043 1044 return VERR_LDR_INVALID_LINK_ADDRESS; 942 1045 } 943 1046 … … 946 1049 static DECLCALLBACK(int) rtldrPE_LinkAddressToRva(PRTLDRMODINTERNAL pMod, RTLDRADDR LinkAddress, PRTLDRADDR pRva) 947 1050 { 948 NOREF(pMod); NOREF(LinkAddress); NOREF(pRva); 949 return VERR_NOT_IMPLEMENTED; 1051 PRTLDRMODPE pModPe = (PRTLDRMODPE)pMod; 1052 1053 if (LinkAddress > pModPe->cbImage) 1054 return VERR_LDR_INVALID_LINK_ADDRESS; 1055 *pRva = LinkAddress; 1056 return VINF_SUCCESS; 950 1057 } 951 1058 … … 955 1062 PRTLDRADDR pRva) 956 1063 { 957 NOREF(pMod); NOREF(iSeg); NOREF(offSeg); NOREF(pRva); 958 return VERR_NOT_IMPLEMENTED; 1064 PRTLDRMODPE pModPe = (PRTLDRMODPE)pMod; 1065 1066 if (iSeg > pModPe->cSections) 1067 return VERR_LDR_INVALID_SEG_OFFSET; 1068 1069 /** @todo should validate offSeg here... too lazy right now. */ 1070 if (iSeg == 0) 1071 *pRva = offSeg; 1072 else if (pModPe->paSections[iSeg].Characteristics & IMAGE_SCN_TYPE_NOLOAD) 1073 return VERR_LDR_INVALID_SEG_OFFSET; 1074 else 1075 *pRva = offSeg + pModPe->paSections[iSeg].VirtualAddress; 1076 return VINF_SUCCESS; 959 1077 } 960 1078 … … 964 1082 uint32_t *piSeg, PRTLDRADDR poffSeg) 965 1083 { 966 NOREF(pMod); NOREF(Rva); NOREF(piSeg); NOREF(poffSeg); 967 return VERR_NOT_IMPLEMENTED; 1084 int rc = rtldrPE_LinkAddressToSegOffset(pMod, Rva, piSeg, poffSeg); 1085 if (RT_FAILURE(rc)) 1086 rc = VERR_LDR_INVALID_RVA; 1087 return rc; 968 1088 } 969 1089
Note:
See TracChangeset
for help on using the changeset viewer.