diff options
author | Juan Hoyos <juan.hoyos@microsoft.com> | 2021-05-17 23:40:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-17 23:40:01 +0300 |
commit | 6f5ab2b939ccadef92341affdd089b0f7c003280 (patch) | |
tree | d52bf0fbd65b93d896a11ea090c9c6d81a6f44fe /src/coreclr/utilcode | |
parent | 64f5f0b31d9af2df199229e6e4ef3f4a876a05a5 (diff) |
SingleFile diagnostic support - Add export table and DotNetRuntimeInfo to dumps (#52731)
* DACize PEDecoder::GetExport
* Ensure export table and runtimeinfo export are always present in a minidump
Diffstat (limited to 'src/coreclr/utilcode')
-rw-r--r-- | src/coreclr/utilcode/pedecoder.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index 5ec34fa0700..3b46c56a415 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -1769,7 +1769,7 @@ void PEDecoder::LayoutILOnly(void *base, bool enableExecution) const PAGE_READONLY, &oldProtection)) ThrowLastError(); - // Finally, apply proper protection to copied sections + // Finally, apply proper protection to copied sections for (section = sectionStart; section < sectionEnd; section++) { // Add appropriate page protection. @@ -2346,8 +2346,7 @@ READYTORUN_HEADER * PEDecoder::FindReadyToRunHeader() const return NULL; } -#ifndef DACCESS_COMPILE -void *PEDecoder::GetExport(LPCSTR exportName) const +PTR_VOID PEDecoder::GetExport(LPCSTR exportName) const { // Get the export directory entry PIMAGE_DATA_DIRECTORY pExportDirectoryEntry = GetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_EXPORT); @@ -2356,30 +2355,30 @@ void *PEDecoder::GetExport(LPCSTR exportName) const return NULL; } - uint8_t *imageBase = (uint8_t *)GetBase(); - const IMAGE_EXPORT_DIRECTORY *pExportDir = (const IMAGE_EXPORT_DIRECTORY *)GetDirectoryData(pExportDirectoryEntry); + PTR_IMAGE_EXPORT_DIRECTORY pExportDir = dac_cast<PTR_IMAGE_EXPORT_DIRECTORY>(GetDirectoryData(pExportDirectoryEntry)); uint32_t namePointerCount = VAL32(pExportDir->NumberOfNames); uint32_t addressTableRVA = VAL32(pExportDir->AddressOfFunctions); - uint32_t namePointersRVA = VAL32(pExportDir->AddressOfNames); + uint32_t ordinalTableRVA = VAL32(pExportDir->AddressOfNameOrdinals); + uint32_t nameTableRVA = VAL32(pExportDir->AddressOfNames); for (uint32_t nameIndex = 0; nameIndex < namePointerCount; nameIndex++) { - uint32_t namePointerRVA = VAL32(*(const uint32_t *)&imageBase[namePointersRVA + sizeof(uint32_t) * nameIndex]); + uint32_t namePointerRVA = *dac_cast<PTR_UINT32>(GetRvaData(nameTableRVA + sizeof(uint32_t) * nameIndex)); if (namePointerRVA != 0) { - const char *namePointer = (const char *)&imageBase[namePointerRVA]; + const char *namePointer = dac_cast<PTR_CSTR>(GetRvaData(namePointerRVA)); if (!strcmp(namePointer, exportName)) { - uint32_t exportRVA = VAL32(*(const uint32_t *)&imageBase[addressTableRVA + sizeof(uint32_t) * nameIndex]); - return &imageBase[exportRVA]; + uint16_t ordinalForNamedExport = *dac_cast<PTR_UINT16>(GetRvaData(ordinalTableRVA + sizeof(uint16_t) * nameIndex)); + uint32_t exportRVA = *dac_cast<PTR_UINT32>(GetRvaData(addressTableRVA + sizeof(uint32_t) * ordinalForNamedExport)); + return dac_cast<PTR_VOID>(GetRvaData(exportRVA)); } } } return NULL; } -#endif // // code:PEDecoder::CheckILMethod and code:PEDecoder::ComputeILMethodSize really belong to |