예제 #1
0
파일: Module.cs 프로젝트: 7shi/LLPML
        public SectionHeader AddSection(SectionBase sb)
        {
            if (Sections.Count == 16)
            {
                throw new Exception("Maximum sections.");
            }

            SectionHeader ret = new SectionHeader();
            ret.Name = sb.Name;
            ret.VirtualSize = CreateBlock(sb).Length;
            ret.VirtualAddress = GetNextVirtualAddress();
            ret.SizeOfRawData = Align(ret.VirtualSize, Specific.FileAlignment);
            ret.PointerToRawData = GetNextPointerToRawData();
            switch (ret.Name)
            {
                case ".text":
                    ret.Characteristics =
                        IMAGE_SCN.CNT_CODE | IMAGE_SCN.CNT_INITIALIZED_DATA |
                        IMAGE_SCN.MEM_EXECUTE | IMAGE_SCN.MEM_READ;
                    break;
                case ".rdata":
                    ret.Characteristics =
                        IMAGE_SCN.CNT_INITIALIZED_DATA |
                        IMAGE_SCN.MEM_READ;
                    break;
                case ".bss":
                    ret.Characteristics =
                        IMAGE_SCN.CNT_UNINITIALIZED_DATA |
                        IMAGE_SCN.MEM_READ | IMAGE_SCN.MEM_WRITE;
                    break;
                default:
                    ret.Characteristics =
                        IMAGE_SCN.CNT_INITIALIZED_DATA |
                        IMAGE_SCN.MEM_READ | IMAGE_SCN.MEM_WRITE;
                    break;
            }
            sb.Header = ret;
            Sections.Add(sb);
            return ret;
        }
예제 #2
0
파일: Module.cs 프로젝트: 7shi/LLPML
 public Block32 CreateBlock(SectionBase sb)
 {
     if (sb.Header != null)
         return sb.ToBlock(sb.Header.VirtualAddress);
     else
         return sb.ToBlock(GetNextVirtualAddress());
 }