/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System;
using System.IO;
namespace dnSpy.Contracts.Hex {
///
/// Creates s
///
public abstract class HexBufferStreamFactoryService {
///
/// Constructor
///
protected HexBufferStreamFactoryService() { }
///
/// Creates a
///
/// Filename
///
public HexBufferStream Create(string filename) {
if (filename is null)
throw new ArgumentNullException(nameof(filename));
return Create(File.ReadAllBytes(filename), filename);
}
///
/// Creates a
///
/// Data
/// Name, can be anything and is usually the filename
///
public abstract HexBufferStream Create(byte[] data, string name);
///
/// Creates a
///
/// Underlying stream
/// true if the returned stream owns and
/// disposes it when the returned stream gets disposed
///
public abstract HexCachedBufferStream CreateCached(HexSimpleBufferStream simpleStream, bool disposeStream);
///
/// Creates a process stream
///
/// Process handle
/// Name or null to use the default name
/// true if it's read only
/// true if the memory can be changed by other code
///
public HexCachedBufferStream CreateCachedProcessStream(IntPtr hProcess, string? name = null, bool isReadOnly = false, bool isVolatile = true) {
var simpleStream = CreateSimpleProcessStream(hProcess, name, isReadOnly, isVolatile);
return CreateCached(simpleStream, disposeStream: true);
}
///
/// Creates a process stream
///
/// Process handle
/// Name or null to use the default name
/// true if it's read only
/// true if the memory can be changed by other code
///
public abstract HexSimpleBufferStream CreateSimpleProcessStream(IntPtr hProcess, string? name = null, bool isReadOnly = false, bool isVolatile = true);
}
}