Пример #1
0
 /// <summary>
 ///     Reads all bytes from the PE image. This may fail if the PE image has been loaded
 ///     by the OS loader since there may be memory holes.
 /// </summary>
 /// <param name="self">this</param>
 /// <returns>All bytes of the PE image</returns>
 public static byte[] GetImageAsByteArray(this IPEImage self)
 {
     using (var reader = self.CreateFullStream())
     {
         return(reader.ReadAllBytes());
     }
 }
Пример #2
0
        public AsmEdHexDocument GetOrCreate(IPEImage peImage)
        {
            var filename = GetFullPath(peImage.FileName);

            lock (lockObj) {
                var doc = TryGet_NoLock(filename);
                if (doc != null)
                {
                    return(doc);
                }

                using (var stream = peImage.CreateFullStream()) {
                    var data = stream.ReadAllBytes();
                    doc = new AsmEdHexDocument(undoCommandService, data, filename);
                    filenameToDoc[filename] = new WeakReference(doc);
                    return(doc);
                }
            }
        }
Пример #3
0
        public AsmEdHexDocument GetOrCreate(IPEImage peImage)
        {
            var filename = GetFullPath(peImage.FileName);

            lock (lockObj) {
                AsmEdHexDocument doc;
                if (filenameToDoc.TryGetValue(filename, out doc))
                {
                    return(doc);
                }

                using (var stream = peImage.CreateFullStream()) {
                    var data = stream.ReadAllBytes();
                    doc = new AsmEdHexDocument(data, filename);
                    filenameToDoc.Add(filename, doc);
                    return(doc);
                }
            }
        }
Пример #4
0
        HexBuffer GetOrCreate(IPEImage peImage)
        {
            var filename = GetFullPath(peImage.FileName);

            HexBuffer buffer;

            lock (lockObj) {
                buffer = TryGet_NoLock(filename);
                if (buffer != null)
                {
                    return(buffer);
                }

                using (var stream = peImage.CreateFullStream()) {
                    var data = stream.ReadAllBytes();
                    buffer = hexBufferFactoryService.Create(data, filename, hexBufferFactoryService.DefaultFileTags);
                    filenameToBuffer[filename] = new WeakReference(buffer);
                }
            }
            return(NotifyBufferCreated(buffer));
        }
Пример #5
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();
		}
Пример #7
0
		void Initialize(IPEImage peImage) {
			this.peImage = peImage;
			this.peStream = peImage.CreateFullStream();
		}
Пример #8
0
		public AsmEdHexDocument GetOrCreate(IPEImage peImage) {
			var filename = GetFullPath(peImage.FileName);

			lock (lockObj) {
				var doc = TryGet_NoLock(filename);
				if (doc != null)
					return doc;

				using (var stream = peImage.CreateFullStream()) {
					var data = stream.ReadAllBytes();
					doc = new AsmEdHexDocument(data, filename);
					filenameToDoc[filename] = new WeakReference(doc);
					return doc;
				}
			}
		}
Пример #9
0
 void Initialize(IPEImage peImage)
 {
     this.peImage  = peImage;
     this.peStream = peImage.CreateFullStream();
 }
Пример #10
0
        public AsmEdHexDocument GetOrCreate(IPEImage peImage)
        {
            var filename = GetFullPath(peImage.FileName);

            lock (lockObj) {
                AsmEdHexDocument doc;
                if (filenameToDoc.TryGetValue(filename, out doc))
                    return doc;

                using (var stream = peImage.CreateFullStream()) {
                    var data = stream.ReadAllBytes();
                    doc = new AsmEdHexDocument(data, filename);
                    filenameToDoc.Add(filename, doc);
                    return doc;
                }
            }
        }
Пример #11
0
		HexBuffer GetOrCreate(IPEImage peImage) {
			var filename = GetFullPath(peImage.FileName);

			HexBuffer buffer;
			lock (lockObj) {
				buffer = TryGet_NoLock(filename);
				if (buffer != null)
					return buffer;

				using (var stream = peImage.CreateFullStream()) {
					var data = stream.ReadAllBytes();
					buffer = hexBufferFactoryService.Create(data, filename, hexBufferFactoryService.DefaultFileTags);
					filenameToBuffer[filename] = new WeakReference(buffer);
				}
			}
			return NotifyBufferCreated(buffer);
		}