diff --git a/.gitignore b/.gitignore index ab11a70..52ff7de 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bin/ obj/ *.userprefs test-results/ +/packages/*/ diff --git a/ELFSharp.sln b/ELFSharp.sln index 6a7fcdb..7162b68 100644 --- a/ELFSharp.sln +++ b/ELFSharp.sln @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ELFSharp", "ELFSharp\ELFSharp.csproj", "{CF944E09-7C14-433C-A185-161848E989B3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ELFSharp.LinqBridge", "ELFSharp\ELFSharp.LinqBridge.csproj", "{6169D4ED-92C8-469C-ABF4-FF0FA29D557C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -13,6 +15,10 @@ Global {CF944E09-7C14-433C-A185-161848E989B3}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF944E09-7C14-433C-A185-161848E989B3}.Release|Any CPU.ActiveCfg = Release|Any CPU {CF944E09-7C14-433C-A185-161848E989B3}.Release|Any CPU.Build.0 = Release|Any CPU + {6169D4ED-92C8-469C-ABF4-FF0FA29D557C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6169D4ED-92C8-469C-ABF4-FF0FA29D557C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6169D4ED-92C8-469C-ABF4-FF0FA29D557C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6169D4ED-92C8-469C-ABF4-FF0FA29D557C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = ELFSharp\ELFSharp.csproj diff --git a/ELFSharp/ELF/ELF.cs b/ELFSharp/ELF/ELF.cs index 193ccaa..1ab73d1 100644 --- a/ELFSharp/ELF/ELF.cs +++ b/ELFSharp/ELF/ELF.cs @@ -60,7 +60,7 @@ public IEnumerable> Segments IEnumerable IELF.Segments { - get { return Segments; } + get { return Segments.Cast(); } } public IStringTable SectionsStringTable { get; private set; } @@ -87,7 +87,7 @@ IEnumerable IELF.Sections { get { - return Sections; + return Sections.Cast(); } } diff --git a/ELFSharp/ELF/Sections/SymbolTable.cs b/ELFSharp/ELF/Sections/SymbolTable.cs index dcf45cb..8f6a804 100644 --- a/ELFSharp/ELF/Sections/SymbolTable.cs +++ b/ELFSharp/ELF/Sections/SymbolTable.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using MiscUtil.IO; using System.Collections.ObjectModel; @@ -21,7 +22,7 @@ public IEnumerable> Entries IEnumerable ISymbolTable.Entries { - get { return Entries; } + get { return Entries.Cast(); } } private void ReadSymbols() diff --git a/ELFSharp/ELFSharp.LinqBridge.csproj b/ELFSharp/ELFSharp.LinqBridge.csproj new file mode 100644 index 0000000..933ae62 --- /dev/null +++ b/ELFSharp/ELFSharp.LinqBridge.csproj @@ -0,0 +1,109 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {6169D4ED-92C8-469C-ABF4-FF0FA29D557C} + Library + Properties + ELFSharp + ELFSharp + 512 + v2.0 + obj\LinqBridge\ + + + true + full + false + bin\LinqBridge\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\LinqBridge\Release\ + TRACE + prompt + 4 + + + + False + ..\packages\LinqBridge.1.3.0\lib\net20\LinqBridge.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ELFSharp/MiscUtil/Streams.cs b/ELFSharp/MiscUtil/Streams.cs new file mode 100644 index 0000000..6d5b435 --- /dev/null +++ b/ELFSharp/MiscUtil/Streams.cs @@ -0,0 +1,51 @@ +using System; +using System.IO; + +namespace MiscUtil.IO +{ + public static class Streams + { + /// + /// Copies the content of one stream to another in buffer-sized steps. + /// + /// The source stream to copy from. + /// The destination stream to copy to. + /// The size of the buffer to use for copying in bytes. + /// Will try to to the start of . + public static void CopyTo(this Stream source, Stream destination, long bufferSize) + { + #region Sanity checks + if (source == null) throw new ArgumentNullException("source"); + if (destination == null) throw new ArgumentNullException("destination"); + #endregion + + var buffer = new byte[bufferSize]; + int read; + + if (source.CanSeek) source.Position = 0; + + do + { + read = source.Read(buffer, 0, buffer.Length); + destination.Write(buffer, 0, read); + } while (read != 0); + + if (destination.CanSeek) destination.Position = 0; + } + + /// + /// Copies the content of one stream to another in one go. + /// + /// The source stream to copy from. + /// The destination stream to copy to. + public static void CopyTo(this Stream source, Stream destination) + { + #region Sanity checks + if (source == null) throw new ArgumentNullException("source"); + if (destination == null) throw new ArgumentNullException("destination"); + #endregion + + source.CopyTo(destination, 4096); + } + } +} diff --git a/ELFSharp/UImage/UImage.cs b/ELFSharp/UImage/UImage.cs index 53ce0e3..a11771b 100644 --- a/ELFSharp/UImage/UImage.cs +++ b/ELFSharp/UImage/UImage.cs @@ -3,6 +3,7 @@ using System.Text; using System.Linq; using System.IO.Compression; +using MiscUtil.IO; namespace ELFSharp.UImage { diff --git a/ELFSharp/packages.config b/ELFSharp/packages.config new file mode 100644 index 0000000..6003a80 --- /dev/null +++ b/ELFSharp/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/packages/repositories.config b/packages/repositories.config new file mode 100644 index 0000000..d99f32f --- /dev/null +++ b/packages/repositories.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file