Ejemplo n.º 1
0
 public HexBufferImpl(HexBufferStream stream, HexTags tags, bool disposeStream)
     : base(tags)
 {
     this.stream        = stream ?? throw new ArgumentNullException(nameof(stream));
     this.disposeStream = disposeStream;
     currentHexVersion  = new HexVersionImpl(this, 0, 0);
 }
Ejemplo n.º 2
0
 protected override void DisposeCore()
 {
     if (disposeStream)
     {
         stream?.Dispose();
     }
     stream = null;
 }
Ejemplo n.º 3
0
 public void SetUnderlyingStream(HexBufferStream stream, DbgProcess process)
 {
     if (Process == process && DebuggerHexBufferStream.UnderlyingStream == stream)
     {
         return;
     }
     Process = process;
     DebuggerHexBufferStream.UnderlyingStream = stream;
     UnderlyingStreamChanged?.Invoke(this, EventArgs.Empty);
     UnderlyingProcessChanged?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 4
0
 void SetUnderlyingStreamCore(HexBufferStream newStream)
 {
     if (stream == newStream)
     {
         return;
     }
     UnregisterEvents();
     // Don't dispose the old stream. The caller disposes it (it's a process stream)
     stream = newStream;
     RegisterEvents();
     InvalidateAll();
 }
Ejemplo n.º 5
0
 void SetUnderlyingStreamCore(HexBufferStream newStream)
 {
     if (stream == newStream)
     {
         return;
     }
     UnregisterEvents();
     stream?.Dispose();
     stream = newStream;
     RegisterEvents();
     InvalidateAll();
     UnderlyingStreamChanged?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 6
0
        public override HexBuffer Create(HexBufferStream stream, HexTags tags, bool disposeStream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (tags == null)
            {
                throw new ArgumentNullException(nameof(tags));
            }
            var buffer = new HexBufferImpl(stream, tags, disposeStream);

            HexBufferCreated?.Invoke(this, new HexBufferCreatedEventArgs(buffer));
            return(buffer);
        }
Ejemplo n.º 7
0
        public override void Read(IntPtr hProcess, HexPosition position, byte[] destination, long destinationIndex, long length)
        {
            if (hProcess == IntPtr.Zero)
            {
                throw new ArgumentException();
            }
            if (position >= HexPosition.MaxEndPosition)
            {
                throw new ArgumentOutOfRangeException(nameof(position));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }
            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(destinationIndex));
            }
            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }
            if (new HexPosition(destinationIndex) + length > destination.LongLength)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }
            HexSimpleBufferStream processStream = null;
            HexBufferStream       cachedStream  = null;

            try {
                processStream = hexBufferStreamFactoryService.CreateSimpleProcessStream(hProcess);
                cachedStream  = hexBufferStreamFactoryService.CreateCached(processStream, disposeStream: false);
                cachedStream.ReadBytes(position, destination, destinationIndex, length);
            }
            finally {
                processStream?.Dispose();
                cachedStream?.Dispose();
            }
        }
Ejemplo n.º 8
0
 public void SetUnderlyingStream(HexBufferStream newStream)
 {
     CheckDisposed();
     SetUnderlyingStreamCore(newStream);
 }