Exemplo n.º 1
0
            public byte[] AddSection(byte[] input, SectionHeader sec)
            {
                // make space
                byte[] data = new byte[sec.RawAddr + sec.RawSize];
                Buffer.BlockCopy(input, 0, data, 0, (int)sec.RawAddr);

                // number of sections
                ushort sectionCount = (ushort)(this.NumberOfSections + 1);

                BitConverter.GetBytes(sectionCount).CopyTo(data, offset + 0x06);

                // size of image
                uint imageSize = sec.VirtAddr + GetMultiples(sec.VirtSize, sectionAlignment);

                BitConverter.GetBytes(imageSize).CopyTo(data, offset + 0x50);

                sec.Write(data, offset + 0xF8 + SectionHeader.HeaderSize * this.NumberOfSections);

                return(data);
            }