public DotNetHeadersImpl(PeHeaders peHeaders, DotNetCor20Data cor20, DotNetMetadataHeaders metadataHeaders, VirtualArrayData <ByteData> strongNameSignature, DotNetMethodProvider methodProvider, DotNetResourceProvider resourceProvider) { if (peHeaders == null) { throw new ArgumentNullException(nameof(peHeaders)); } if (cor20 == null) { throw new ArgumentNullException(nameof(cor20)); } if (methodProvider == null) { throw new ArgumentNullException(nameof(methodProvider)); } if (resourceProvider == null) { throw new ArgumentNullException(nameof(resourceProvider)); } PeHeaders = peHeaders; Cor20 = cor20; MetadataHeaders = metadataHeaders; StrongNameSignature = strongNameSignature; MethodProvider = methodProvider; ResourceProvider = resourceProvider; }
public DotNetEmbeddedResourceImpl(DotNetResourceProvider resourceProvider, HexBufferSpan span, uint token) : base(resourceProvider, span, token) { if (span.Length < 4) { throw new ArgumentOutOfRangeException(nameof(span)); } Size = new StructField <UInt32Data>("Size", new UInt32Data(span.Buffer, span.Start.Position)); Content = new StructField <VirtualArrayData <ByteData> >("Content", ArrayData.CreateVirtualByteArray(HexBufferSpan.FromBounds(span.Start + 4, span.End))); Fields = new BufferField[] { Size, Content, }; }
public override bool Initialize() { HexSpan?resourcesSpan = null; var peHeaders = file.GetHeaders <PeHeaders>(); if (peHeaders != null) { if (peHeaders.OptionalHeader.DataDirectory.Data.FieldCount < 15) { return(false); } var cor20Span = Read(peHeaders, peHeaders.OptionalHeader.DataDirectory.Data[14].Data); if (cor20Span == null) { return(false); } cor20 = DotNetCor20DataImpl.TryCreate(file, cor20Span.Value.Start); if (cor20 == null) { return(false); } var mdSpan = Read(peHeaders, cor20.MetaData.Data); resourcesSpan = Read(peHeaders, cor20.Resources.Data); var snSpan = Read(peHeaders, cor20.StrongNameSignature.Data); ReadDotNetMetadataHeader(peHeaders, mdSpan); ReadStrongNameSignature(peHeaders, snSpan); } else { // Could be a portable PDB file (or a metadata only file) ReadDotNetMetadataHeader(file.Span); } if (mdHeader != null && dotNetHeaps != null) { dotNetMetadataHeaders = new DotNetMetadataHeadersImpl(metadataSpan, mdHeader, dotNetHeaps); } if (peHeaders != null && cor20 != null) { dotNetMethodProvider = new DotNetMethodProviderImpl(file, peHeaders, dotNetMetadataHeaders?.TablesStream); dotNetResourceProvider = new DotNetResourceProviderImpl(file, peHeaders, dotNetMetadataHeaders, resourcesSpan); dotNetHeaders = new DotNetHeadersImpl(peHeaders, cor20, dotNetMetadataHeaders, strongNameSignature, dotNetMethodProvider, dotNetResourceProvider); } return(cor20 != null || !metadataSpan.IsEmpty); }