Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The precise method for calculating 'RVA' #539

Open
SoheilMV opened this issue Jan 23, 2024 · 0 comments
Open

The precise method for calculating 'RVA' #539

SoheilMV opened this issue Jan 23, 2024 · 0 comments

Comments

@SoheilMV
Copy link

SoheilMV commented Jan 23, 2024

In the research I conducted, I realized that the RVA value depends on "DataDirectories.Length" which can be observed in the path "moduleDefMD.Metadata.PEImage.ImageNTHeaders.OptionalHeader".

example :

ModuleContext _modCtx = ModuleDef.CreateModuleContext();
ModuleDefMD _moduleDefMD = ModuleDefMD.Load("path", _modCtx);
...
IImageOptionalHeader _optionalHeader = _moduleDefMD.Metadata.PEImage.ImageNTHeaders.OptionalHeader;
uint _numberOfRvaAndSizes = (uint)_optionalHeader.DataDirectories.Length;
var _options = new ModuleWriterOptions(_moduleDefMD)
{
    MetadataOptions = { Flags = MetadataFlags.PreserveAll },
    PEHeadersOptions = { NumberOfRvaAndSizes = _numberOfRvaAndSizes },
    Logger = DummyLogger.NoThrowInstance,
    WritePdb = true
};
_moduleDefMD.Write("path", _options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant