Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rvaConverter"><see cref="RVA"/>/<see cref="FileOffset"/> converter</param>
 /// <param name="dataReader">Data reader (it's used after converting an <see cref="RVA"/>
 /// to a <see cref="FileOffset"/>). This instance owns the reader.</param>
 /// <param name="rsrcReader">Reader for the whole Win32 resources section (usually
 /// the .rsrc section). It's used to read <see cref="ResourceDirectory"/>'s and
 /// <see cref="ResourceData"/>'s but not the actual data blob. This instance owns the
 /// reader.</param>
 public Win32ResourcesPE(IRvaFileOffsetConverter rvaConverter, IImageStream dataReader, IBinaryReader rsrcReader)
 {
     if (dataReader == rsrcReader)
     {
         rsrcReader = dataReader.Clone();                        // Must not be the same readers
     }
     this.rvaConverter = rvaConverter;
     this.dataReader   = dataReader;
     this.rsrcReader   = rsrcReader;
     Initialize();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="peImage">The PE image</param>
 /// <param name="rsrcReader">Reader for the whole Win32 resources section (usually
 /// the .rsrc section) or <c>null</c> if we should create one from the resource data
 /// directory in the optional header. This instance owns the reader.</param>
 public Win32ResourcesPE(IPEImage peImage, IBinaryReader rsrcReader)
 {
     this.rvaConverter = peImage;
     this.dataReader   = peImage.CreateFullStream();
     if (rsrcReader != null)
     {
         this.rsrcReader = rsrcReader;
     }
     else
     {
         var dataDir = peImage.ImageNTHeaders.OptionalHeader.DataDirectories[2];
         if (dataDir.VirtualAddress != 0 && dataDir.Size != 0)
         {
             this.rsrcReader = peImage.CreateStream(dataDir.VirtualAddress, dataDir.Size);
         }
         else
         {
             this.rsrcReader = MemoryImageStream.CreateEmpty();
         }
     }
     Initialize();
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="peImage">The PE image</param>
		/// <param name="rsrcReader">Reader for the whole Win32 resources section (usually
		/// the .rsrc section) or <c>null</c> if we should create one from the resource data
		/// directory in the optional header. This instance owns the reader.</param>
		public Win32ResourcesPE(IPEImage peImage, IBinaryReader rsrcReader) {
			this.rvaConverter = peImage;
			this.dataReader = peImage.CreateFullStream();
			if (rsrcReader != null)
				this.rsrcReader = rsrcReader;
			else {
				var dataDir = peImage.ImageNTHeaders.OptionalHeader.DataDirectories[2];
				if (dataDir.VirtualAddress != 0 && dataDir.Size != 0)
					this.rsrcReader = peImage.CreateStream(dataDir.VirtualAddress, dataDir.Size);
				else
					this.rsrcReader = MemoryImageStream.CreateEmpty();
			}
			Initialize();
		}
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="rvaConverter"><see cref="RVA"/>/<see cref="FileOffset"/> converter</param>
		/// <param name="dataReader">Data reader (it's used after converting an <see cref="RVA"/>
		/// to a <see cref="FileOffset"/>). This instance owns the reader.</param>
		/// <param name="rsrcReader">Reader for the whole Win32 resources section (usually
		/// the .rsrc section). It's used to read <see cref="ResourceDirectory"/>'s and
		/// <see cref="ResourceData"/>'s but not the actual data blob. This instance owns the
		/// reader.</param>
		public Win32ResourcesPE(IRvaFileOffsetConverter rvaConverter, IImageStream dataReader, IBinaryReader rsrcReader) {
			if (dataReader == rsrcReader)
				rsrcReader = dataReader.Clone();	// Must not be the same readers
			this.rvaConverter = rvaConverter;
			this.dataReader = dataReader;
			this.rsrcReader = rsrcReader;
			Initialize();
		}