private void DiffR2RMethodsForHeader(ReadyToRunCoreHeader leftHeader, ReadyToRunCoreHeader rightHeader) { if (!leftHeader.Sections.TryGetValue(ReadyToRunSectionType.MethodDefEntryPoints, out ReadyToRunSection leftSection)) { leftSection = new ReadyToRunSection(); } if (!rightHeader.Sections.TryGetValue(ReadyToRunSectionType.MethodDefEntryPoints, out ReadyToRunSection rightSection)) { rightSection = new ReadyToRunSection(); } ShowDiff(GetR2RMethodMap(_leftDumper.Reader, leftSection), GetR2RMethodMap(_rightDumper.Reader, rightSection), "R2R methods"); if (_leftDumper.Reader.Composite && _rightDumper.Reader.Composite) { HashSet <string> allComponentAssemblies = new HashSet <string>(_leftDumper.Reader.ManifestReferenceAssemblies.Keys); allComponentAssemblies.UnionWith(_rightDumper.Reader.ManifestReferenceAssemblies.Keys); foreach (string assemblyName in allComponentAssemblies.OrderBy(name => name)) { int leftIndex = _leftDumper.Reader.ManifestReferenceAssemblies[assemblyName]; int rightIndex = _rightDumper.Reader.ManifestReferenceAssemblies[assemblyName]; if (leftIndex < 0 || !_leftDumper.Reader.ReadyToRunAssemblyHeaders[leftIndex].Sections.TryGetValue(ReadyToRunSectionType.MethodDefEntryPoints, out leftSection)) { leftSection = new ReadyToRunSection(); } if (rightIndex < 0 || !_rightDumper.Reader.ReadyToRunAssemblyHeaders[rightIndex].Sections.TryGetValue(ReadyToRunSectionType.MethodDefEntryPoints, out rightSection)) { rightSection = new ReadyToRunSection(); } ShowDiff(GetR2RMethodMap(_leftDumper.Reader, leftSection), GetR2RMethodMap(_rightDumper.Reader, rightSection), $"{assemblyName}: component R2R methods"); } } }
public IEnumerable<ReadyToRunSection> NormalizedSections(ReadyToRunCoreHeader header) { IEnumerable<ReadyToRunSection> sections = header.Sections.Values; if (_options.Normalize) { sections = sections.OrderBy((s) => s.Type); } return sections; }
/// <summary> /// Dumps the R2RHeader and all the sections in the header /// </summary> internal override void DumpHeader(bool dumpSections) { _writer.WriteLine(_r2r.ReadyToRunHeader.ToString()); if (_options.Raw) { DumpBytes(_r2r.ReadyToRunHeader.RelativeVirtualAddress, (uint)_r2r.ReadyToRunHeader.Size); } SkipLine(); if (dumpSections) { WriteDivider("R2R Sections"); _writer.WriteLine($"{_r2r.ReadyToRunHeader.Sections.Count} sections"); SkipLine(); foreach (ReadyToRunSection section in NormalizedSections(_r2r.ReadyToRunHeader)) { DumpSection(section); } if (_r2r.Composite) { WriteDivider("Component Assembly Sections"); int assemblyIndex = 0; foreach (string assemblyName in _r2r.ManifestReferenceAssemblies.OrderBy(kvp => kvp.Value).Select(kvp => kvp.Key)) { string dividerName = $@"Component Assembly [{assemblyIndex}]: {assemblyName}"; if (_r2r.ReadyToRunHeader.Sections.TryGetValue(ReadyToRunSectionType.ManifestAssemblyMvids, out ReadyToRunSection mvidSection)) { int mvidOffset = _r2r.GetOffset(mvidSection.RelativeVirtualAddress) + GuidByteSize * assemblyIndex; Guid mvid = new Guid(new ReadOnlySpan <byte>(_r2r.Image, mvidOffset, GuidByteSize)); dividerName += $@" - MVID {mvid:b}"; } WriteDivider(dividerName); ReadyToRunCoreHeader assemblyHeader = _r2r.ReadyToRunAssemblyHeaders[assemblyIndex]; foreach (ReadyToRunSection section in NormalizedSections(assemblyHeader)) { DumpSection(section); } assemblyIndex++; } } } SkipLine(); }
/// <summary> /// Dumps the R2RHeader and all the sections in the header /// </summary> internal override void DumpHeader(bool dumpSections) { _writer.WriteLine(_r2r.ReadyToRunHeader.ToString()); if (_options.Raw) { DumpBytes(_r2r.ReadyToRunHeader.RelativeVirtualAddress, (uint)_r2r.ReadyToRunHeader.Size); } SkipLine(); if (dumpSections) { WriteDivider("R2R Sections"); _writer.WriteLine($"{_r2r.ReadyToRunHeader.Sections.Count} sections"); SkipLine(); foreach (ReadyToRunSection section in NormalizedSections(_r2r.ReadyToRunHeader)) { DumpSection(section); } if (_r2r.Composite) { WriteDivider("Component Assembly Sections"); int assemblyIndex = 0; foreach (string assemblyName in _r2r.ManifestReferenceAssemblies.OrderBy(kvp => kvp.Value).Select(kvp => kvp.Key)) { Guid mvid = _r2r.GetAssemblyMvid(assemblyIndex); WriteDivider($@"Component Assembly [{assemblyIndex}]: {assemblyName} - MVID {mvid:b}"); ReadyToRunCoreHeader assemblyHeader = _r2r.ReadyToRunAssemblyHeaders[assemblyIndex]; foreach (ReadyToRunSection section in NormalizedSections(assemblyHeader)) { DumpSection(section); } assemblyIndex++; } } } SkipLine(); }