public void MultipleItemsNoAlignment()
        {
            var segment1 = new DataSegment(new byte[] { 1, 2, 3, 4 });
            var segment2 = new DataSegment(new byte[] { 1, 2, 3 });
            var segment3 = new DataSegment(new byte[] { 1, 2, 3, 4, 5 });

            var collection = new SegmentBuilder {
                segment1, segment2, segment3
            };

            collection.UpdateOffsets(0x400, 0x1000);

            Assert.Equal(0x400u, segment1.FileOffset);
            Assert.Equal(0x1000u, segment1.Rva);
            Assert.Equal(0x404u, segment2.FileOffset);
            Assert.Equal(0x1004u, segment2.Rva);
            Assert.Equal(0x407u, segment3.FileOffset);
            Assert.Equal(0x1007u, segment3.Rva);

            Assert.Equal(12u, collection.GetPhysicalSize());
            Assert.Equal(12u, collection.GetVirtualSize());

            Assert.Equal(new byte[]
            {
                1, 2, 3, 4,
                1, 2, 3,
                1, 2, 3, 4, 5
            }, ToBytes(collection));
        }
        public void MultipleItemsAlignment()
        {
            var segment1 = new DataSegment(new byte[] { 1, 2, 3, 4 });
            var segment2 = new DataSegment(new byte[] { 1, 2, 3 });
            var segment3 = new DataSegment(new byte[] { 1, 2, 3, 4, 5 });

            var builder = new SegmentBuilder
            {
                { segment1, 8 },
                { segment2, 8 },
                { segment3, 8 }
            };

            builder.UpdateOffsets(0x400, 0x1000);

            Assert.Equal(0x400u, segment1.FileOffset);
            Assert.Equal(0x1000u, segment1.Rva);
            Assert.Equal(0x408u, segment2.FileOffset);
            Assert.Equal(0x1008u, segment2.Rva);
            Assert.Equal(0x410u, segment3.FileOffset);
            Assert.Equal(0x1010u, segment3.Rva);

            Assert.Equal(0x15u, builder.GetPhysicalSize());
            Assert.Equal(0x15u, builder.GetVirtualSize());

            Assert.Equal(new byte[]
            {
                1, 2, 3, 4, 0, 0, 0, 0,
                1, 2, 3, 0, 0, 0, 0, 0,
                1, 2, 3, 4, 5
            }, ToBytes(builder));
        }
        public void EmptyNoAlignment()
        {
            var collection = new SegmentBuilder();

            collection.UpdateOffsets(0x400, 0x1000);

            Assert.Equal(0x400u, collection.FileOffset);
            Assert.Equal(0x1000u, collection.Rva);
            Assert.Equal(0u, collection.GetPhysicalSize());
            Assert.Equal(0u, collection.GetVirtualSize());

            Assert.Empty(ToBytes(collection));
        }
        public void SingleItemAlignment()
        {
            var segment = new DataSegment(new byte[] { 1, 2, 3, 4 });

            var builder = new SegmentBuilder {
                segment
            };

            builder.UpdateOffsets(0x400, 0x1000);

            Assert.Equal(0x400u, segment.FileOffset);

            Assert.Equal(4u, builder.GetPhysicalSize());
            Assert.Equal(4u, builder.GetVirtualSize());

            Assert.Equal(new byte[]
            {
                1, 2, 3, 4
            }, ToBytes(builder));
        }
        public void SingleItemNoAlignment()
        {
            var segment = new DataSegment(new byte[] { 1, 2, 3, 4 });

            var collection = new SegmentBuilder {
                segment
            };

            collection.UpdateOffsets(0x400, 0x1000);

            Assert.Equal(0x400u, segment.FileOffset);
            Assert.Equal(0x1000u, segment.Rva);
            Assert.Equal(4u, collection.GetPhysicalSize());
            Assert.Equal(4u, collection.GetVirtualSize());

            Assert.Equal(new byte[]
            {
                1, 2, 3, 4
            }, ToBytes(collection));
        }
Exemplo n.º 6
0
 /// <inheritdoc />
 public override uint GetPhysicalSize() => ExportDirectoryHeaderSize + _contentsBuilder.GetPhysicalSize();
Exemplo n.º 7
0
 /// <inheritdoc />
 public uint GetPhysicalSize() => _segments.GetPhysicalSize();
Exemplo n.º 8
0
        /// <inheritdoc />
        public uint GetPhysicalSize()
        {
            uint physicalSize = _segments.GetPhysicalSize();

            return(physicalSize);
        }
Exemplo n.º 9
0
 /// <inheritdoc />
 public uint GetPhysicalSize() => _headers.GetPhysicalSize();