/// <summary>
 /// Reads a NULL terminated string
 /// </summary>
 /// <param name="offset"></param>
 /// <returns></returns>
 public string ReadCString(uint offset)
 {
     return(rdr.ReadAt(infoHeader.loaderStringsOffset + offset, (_) =>
     {
         return rdr.ReadCString(PrimitiveType.Char, Encoding.ASCII).ToString();
     }));
 }
Beispiel #2
0
        public IEnumerable <PefImageSegment> GetImageSegments(EndianByteImageReader rdr, Address addrLoad)
        {
            var addr = addrLoad;

            for (int i = 0; i < ContainerHeader.sectionCount; i++)
            {
                PEFSectionHeader sectionHeader = sectionHeaders[i];

                byte[] containerData = rdr.ReadAt(sectionHeader.containerOffset, rdr => rdr.ReadBytes(sectionHeader.packedSize));

                if (sectionHeader.IsCompressedSection())
                {
                    // replace PEF bytecode with decoded output from the interpreter
                    containerData = DecompressSection(containerData);
                }

                if (sectionHeader.defaultAddress != 0)
                {
                    addr = Address.Ptr32(sectionHeader.defaultAddress);
                }
                else
                {
                    addr = addrLoad;
                }
                var segment = new ImageSegment(
                    sectionNameTable[i] ?? $"seg{sectionHeader.defaultAddress:X8}",
                    new ByteMemoryArea(addr, containerData),
                    sectionHeader.GetAccessMode());

                yield return(new PefImageSegment(sectionHeader, segment));

                addrLoad = (segment.Address + containerData.Length).Align(0x1000);
            }
        }