secana / PeNet

Portable Executable (PE) library written in .Net
Apache License 2.0
594 stars 113 forks source link

Expose methods to aid in converting address types #173

Open Dewera opened 4 years ago

Dewera commented 4 years ago

I think most people working with this library are likely to need to convert between file offsets, relative virtual address and virtual addresses. Whilst these can be computed manually using the information present in the headers, due to how often these conversions are needed I think it would a good idea to expose methods to do this for consumers of the library.

Proposed methods


public uint RvaToFileOffset(uint rva);

public uint VaToRva(uint va);

public uint VaToRva(ulong va);

Would be happy to do this as a pull request should you agree.

secana commented 4 years ago

Sure, contributions are always welcome. Did you check if the methods in ExtensionsMethods.cs are already what you need? If not, feel free to create a PR!

Dewera commented 4 years ago

I actually didn't realise these existed - They're exactly what I was describing!

ZehMatt commented 3 weeks ago

Sorry for posting on this old issue I was also looking for exactly that, I think it would be a lot better if the extension methods were moved into PeFile so its PeFile.VaToOffset rather than ulong.VaToOffset, its just a lot easier to discover as having ulong.VaToOffset seems very unusual to me. I wouldn't mind doing the PR for it.

secana commented 2 weeks ago

Hi! A PR is welcome :)