private ImmutableArray <byte> GetMetaDataFromAssembly(ClrModule module) { Debug.Assert(module.ImageBase != 0); var metadata = ImmutableArray <byte> .Empty; bool isVirtual = module.Layout != ModuleLayout.Flat; try { ulong size = module.Size; if (size == 0) { size = 4096; } Stream stream = _memoryService.CreateMemoryStream(module.ImageBase, size); var peImage = new PEImage(stream, leaveOpen: false, isVirtual); if (peImage.IsValid) { metadata = SymbolService.GetMetadata(module.Name, (uint)peImage.IndexTimeStamp, (uint)peImage.IndexFileSize); } else { Trace.TraceError($"GetMetaData: {module.ImageBase:X16} not valid PE"); } } catch (Exception ex) when(ex is BadImageFormatException || ex is EndOfStreamException || ex is IOException) { Trace.TraceError($"GetMetaData: loaded {module.ImageBase:X16} exception {ex.Message}"); } return(metadata); }
private ImmutableArray <byte> GetMetaDataFromAssembly(ClrModule module) { Debug.Assert(module.ImageBase != 0); var metadata = ImmutableArray <byte> .Empty; bool isVirtual = module.Layout != ModuleLayout.Flat; try { Stream stream = _memoryService.CreateMemoryStream(module.ImageBase, module.Size > 0 ? module.Size : 4096); PEFile peFile = new(new StreamAddressSpace(stream), isVirtual); if (peFile.IsValid()) { metadata = SymbolService.GetMetadata(module.Name, peFile.Timestamp, peFile.SizeOfImage); } else { Trace.TraceError($"GetMetaData: {module.ImageBase:X16} not valid PE"); } } catch (Exception ex) when(ex is InvalidVirtualAddressException || ex is BadInputFormatException) { Trace.TraceError($"GetMetaData: loaded {module.ImageBase:X16} exception {ex.Message}"); } return(metadata); }