konrad-kruczynski / elfsharp

Pure managed C# library for reading ELF, UImage, Mach-O binaries.
https://elfsharp.it
Other
150 stars 56 forks source link

Add support for loading from a Stream #56

Closed Anteru closed 4 years ago

Anteru commented 4 years ago

I'm running an application which only has the ELFs in memory, but not on disk, and I cannot guarantee that I can write to disk at all. It would be super helpful if there was an ELFReader.Load variant which accepts a Stream instead of the filename of the string.

Additionally, this would also simplify the unit tests in this library itself instead of having to write temporary files.

konrad-kruczynski commented 4 years ago

Hi @Anteru and thanks for the feedback. I'll probably be able to look at the case this weekend.

Anteru commented 4 years ago

Perfect, thanks a lot :)

konrad-kruczynski commented 4 years ago

After initial research it seems that it won't be problem, assuming the stream can seek. On the other hand, if it is not able to, one can copy the whole stream to a new memory stream which is seekable. I'll let you know once some code is there.

konrad-kruczynski commented 4 years ago

It's there and should soon be available from nuget, version 2.4.0.

Anteru commented 4 years ago

Perfect, thanks a lot! Seekable streams are totally fine for my use, and indeed, it's trivial to copy in memory if needed.