Open SoheilMV opened 10 months ago
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);
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 :