GetNextRVA() public method

public GetNextRVA ( TextSegment segment ) : UInt32
segment TextSegment
return System.UInt32
Beispiel #1
0
        private void BuildTextMap()
        {
            TextMap textMap = text_map;

            textMap.AddMap(TextSegment.Code, metadata.code.length, (!pe64) ? 4 : 16);
            textMap.AddMap(TextSegment.Resources, metadata.resources.length, 8);
            textMap.AddMap(TextSegment.Data, metadata.data.length, 4);
            if (metadata.data.length > 0)
            {
                metadata.table_heap.FixupData(textMap.GetRVA(TextSegment.Data));
            }
            textMap.AddMap(TextSegment.StrongNameSignature, GetStrongNameLength(), 4);
            BuildMetadataTextMap();
            int length = 0;

            if (debug_header != null && debug_header.HasEntries)
            {
                int num  = debug_header.Entries.Length * 28;
                int num2 = (int)textMap.GetNextRVA(TextSegment.BlobHeap) + num;
                int num3 = 0;
                for (int i = 0; i < debug_header.Entries.Length; i++)
                {
                    ImageDebugHeaderEntry imageDebugHeaderEntry = debug_header.Entries[i];
                    ImageDebugDirectory   directory             = imageDebugHeaderEntry.Directory;
                    directory.AddressOfRawData      = ((imageDebugHeaderEntry.Data.Length != 0) ? num2 : 0);
                    imageDebugHeaderEntry.Directory = directory;
                    num3 += imageDebugHeaderEntry.Data.Length;
                    num2 += num3;
                }
                length = num + num3;
            }
            textMap.AddMap(TextSegment.DebugDirectory, length, 4);
            if (!has_reloc)
            {
                uint nextRVA = textMap.GetNextRVA(TextSegment.DebugDirectory);
                textMap.AddMap(TextSegment.ImportDirectory, new Range(nextRVA, 0u));
                textMap.AddMap(TextSegment.ImportHintNameTable, new Range(nextRVA, 0u));
                textMap.AddMap(TextSegment.StartupStub, new Range(nextRVA, 0u));
            }
            else
            {
                uint nextRVA2 = textMap.GetNextRVA(TextSegment.DebugDirectory);
                uint num4     = nextRVA2 + 48;
                num4 = (uint)((int)(num4 + 15) & -16);
                uint num5 = num4 - nextRVA2 + 27;
                uint num6 = nextRVA2 + num5;
                num6 = (uint)((module.Architecture == TargetArchitecture.IA64) ? ((int)(num6 + 15) & -16) : (2 + ((int)(num6 + 3) & -4)));
                textMap.AddMap(TextSegment.ImportDirectory, new Range(nextRVA2, num5));
                textMap.AddMap(TextSegment.ImportHintNameTable, new Range(num4, 0u));
                textMap.AddMap(TextSegment.StartupStub, new Range(num6, GetStartupStubLength()));
            }
        }
        private TextMap BuildTextMap()
        {
            TextMap textMap = this.metadata.text_map;

            textMap.AddMap(TextSegment.Code, this.metadata.code.length, (!this.pe64 ? 4 : 16));
            textMap.AddMap(TextSegment.Resources, this.metadata.resources.length, 8);
            textMap.AddMap(TextSegment.Data, this.metadata.data.length, 4);
            if (this.metadata.data.length > 0)
            {
                this.metadata.table_heap.FixupData(textMap.GetRVA(TextSegment.Data));
            }
            textMap.AddMap(TextSegment.StrongNameSignature, this.GetStrongNameLength(), 4);
            textMap.AddMap(TextSegment.MetadataHeader, this.GetMetadataHeaderLength());
            textMap.AddMap(TextSegment.TableHeap, this.metadata.table_heap.length, 4);
            textMap.AddMap(TextSegment.StringHeap, this.metadata.string_heap.length, 4);
            textMap.AddMap(TextSegment.UserStringHeap, (this.metadata.user_string_heap.IsEmpty ? 0 : this.metadata.user_string_heap.length), 4);
            textMap.AddMap(TextSegment.GuidHeap, 16);
            textMap.AddMap(TextSegment.BlobHeap, (this.metadata.blob_heap.IsEmpty ? 0 : this.metadata.blob_heap.length), 4);
            int length = 0;

            if (!this.debug_data.IsNullOrEmpty <byte>())
            {
                this.debug_directory.AddressOfRawData = (int)(textMap.GetNextRVA(TextSegment.BlobHeap) + 28);
                length = (int)this.debug_data.Length + 28;
            }
            textMap.AddMap(TextSegment.DebugDirectory, length, 4);
            if (!this.has_reloc)
            {
                uint nextRVA = textMap.GetNextRVA(TextSegment.DebugDirectory);
                textMap.AddMap(TextSegment.ImportDirectory, new Range(nextRVA, 0));
                textMap.AddMap(TextSegment.ImportHintNameTable, new Range(nextRVA, 0));
                textMap.AddMap(TextSegment.StartupStub, new Range(nextRVA, 0));
                return(textMap);
            }
            uint num  = textMap.GetNextRVA(TextSegment.DebugDirectory);
            uint num1 = num + 48;

            num1 = num1 + 15 & -16;
            uint num2 = num1 - num + 27;
            uint num3 = num + num2;

            num3 = (this.module.Architecture == TargetArchitecture.IA64 ? num3 + 15 & -16 : 2 + (num3 + 3 & -4));
            textMap.AddMap(TextSegment.ImportDirectory, new Range(num, num2));
            textMap.AddMap(TextSegment.ImportHintNameTable, new Range(num1, 0));
            textMap.AddMap(TextSegment.StartupStub, new Range(num3, this.GetStartupStubLength()));
            return(textMap);
        }
Beispiel #3
0
        private TextMap BuildTextMap()
        {
            TextMap map = this.metadata.text_map;

            map.AddMap(TextSegment.Code, this.metadata.code.length, !this.pe64 ? 4 : 0x10);
            map.AddMap(TextSegment.Resources, this.metadata.resources.length, 8);
            map.AddMap(TextSegment.Data, this.metadata.data.length, 4);
            if (this.metadata.data.length > 0)
            {
                this.metadata.table_heap.FixupData(map.GetRVA(TextSegment.Data));
            }
            map.AddMap(TextSegment.StrongNameSignature, this.GetStrongNameLength(), 4);
            map.AddMap(TextSegment.MetadataHeader, this.GetMetadataHeaderLength());
            map.AddMap(TextSegment.TableHeap, this.metadata.table_heap.length, 4);
            map.AddMap(TextSegment.StringHeap, this.metadata.string_heap.length, 4);
            map.AddMap(TextSegment.UserStringHeap, this.metadata.user_string_heap.IsEmpty ? 0 : this.metadata.user_string_heap.length, 4);
            map.AddMap(TextSegment.GuidHeap, 0x10);
            map.AddMap(TextSegment.BlobHeap, this.metadata.blob_heap.IsEmpty ? 0 : this.metadata.blob_heap.length, 4);
            int length = 0;

            if (!this.debug_data.IsNullOrEmpty <byte>())
            {
                this.debug_directory.AddressOfRawData = (int)(map.GetNextRVA(TextSegment.BlobHeap) + 0x1c);
                length = this.debug_data.Length + 0x1c;
            }
            map.AddMap(TextSegment.DebugDirectory, length, 4);
            if (!this.has_reloc)
            {
                uint num2 = map.GetNextRVA(TextSegment.DebugDirectory);
                map.AddMap(TextSegment.ImportDirectory, new Range(num2, 0));
                map.AddMap(TextSegment.ImportHintNameTable, new Range(num2, 0));
                map.AddMap(TextSegment.StartupStub, new Range(num2, 0));
                return(map);
            }
            uint nextRVA = map.GetNextRVA(TextSegment.DebugDirectory);
            uint index   = (uint)(((nextRVA + 0x30) + 15) & -16);
            uint num5    = (index - nextRVA) + ((uint)0x1b);
            uint num6    = nextRVA + num5;

            map.AddMap(TextSegment.ImportDirectory, new Range(nextRVA, num5));
            map.AddMap(TextSegment.ImportHintNameTable, new Range(index, 0));
            map.AddMap(TextSegment.StartupStub, new Range((this.module.Architecture == TargetArchitecture.IA64) ? ((uint)((num6 + 15) & -16)) : ((uint)(2 + ((num6 + 3) & -4))), this.GetStartupStubLength()));
            return(map);
        }