dnlib
dnlib copied to clipboard
InvalidOperationException when md rva isn't alignment
https://github.com/0xd4d/dnlib/blob/71946df40541d1d97f62e249f3f39036e04e60da/src/DotNet/Writer/Metadata.cs#L3695-L3736
this?
public void SetOffset(FileOffset offset, RVA rva) {
uint rem = (uint)rva % HEAP_ALIGNMENT;
......
foreach (var heap in metadataHeader.Heaps) {
offset = (offset - rem).AlignUp(HEAP_ALIGNMENT) + rem;
rva = (rva - rem).AlignUp(HEAP_ALIGNMENT) + rem;
...
}
Why isn't it aligned?
var module = ModuleDefMD.Load(@"test.exe");
module.NativeWrite("output.exe"); // InvalidOperationException
What's wrong?
I haven't looked at this yet, but if you know how to fix this, you can send a PR.
No idea if alignment is requirement and how the alignment should be.