PeNet icon indicating copy to clipboard operation
PeNet copied to clipboard

Expose methods to aid in converting address types

Open ghost opened this issue 5 years ago • 4 comments

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.

ghost avatar Oct 27 '20 01:10 ghost

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!

secana avatar Oct 27 '20 07:10 secana

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

ghost avatar Oct 27 '20 08:10 ghost

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.

ZehMatt avatar Oct 22 '24 20:10 ZehMatt

Hi! A PR is welcome :)

secana avatar Oct 25 '24 13:10 secana