-
Notifications
You must be signed in to change notification settings - Fork 609
Open
Description
dnlib/src/DotNet/Writer/Metadata.cs
Lines 3695 to 3736 in 71946df
| public void SetOffset(FileOffset offset, RVA rva) { | |
| // This method can be called twice by NativeModuleWriter. It needs to know the size | |
| // of the final metadata. If it fits in the old location, the new MD will be written | |
| // there (smaller file size). If the new MD doesn't fit in the old location, this | |
| // method gets called a second time with the updated offset + rva. | |
| bool initAll = this.offset == 0; | |
| this.offset = offset; | |
| this.rva = rva; | |
| if (initAll) { | |
| // #Strings heap is initialized in OnBeforeSetOffset() | |
| blobHeap.SetReadOnly(); | |
| guidHeap.SetReadOnly(); | |
| tablesHeap.SetReadOnly(); | |
| pdbHeap.SetReadOnly(); | |
| tablesHeap.BigStrings = stringsHeap.IsBig; | |
| tablesHeap.BigBlob = blobHeap.IsBig; | |
| tablesHeap.BigGuid = guidHeap.IsBig; | |
| metadataHeader.Heaps = GetHeaps(); | |
| } | |
| metadataHeader.SetOffset(offset, rva); | |
| uint len = metadataHeader.GetFileLength(); | |
| offset += len; | |
| rva += len; | |
| foreach (var heap in metadataHeader.Heaps) { | |
| offset = offset.AlignUp(HEAP_ALIGNMENT); | |
| rva = rva.AlignUp(HEAP_ALIGNMENT); | |
| heap.SetOffset(offset, rva); | |
| len = heap.GetFileLength(); | |
| offset += len; | |
| rva += len; | |
| } | |
| Debug.Assert(initAll || length == rva - this.rva); | |
| if (!(initAll || length == rva - this.rva)) | |
| throw new InvalidOperationException(); | |
| length = rva - this.rva; | |
| if (!isStandaloneDebugMetadata && initAll) | |
| UpdateMethodAndFieldRvas(); | |
| } |
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;
...
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels