private ElfSymbol GetSymbol(IMemoryManager memory, long address, long strTblAddr) { int nameIndex = memory.ReadInt32(address + 0); int info = memory.ReadByte(address + 4); int other = memory.ReadByte(address + 5); int shIdx = memory.ReadInt16(address + 6); long value = memory.ReadInt64(address + 8); long size = memory.ReadInt64(address + 16); string name = string.Empty; for (int chr; (chr = memory.ReadByte(strTblAddr + nameIndex++)) != 0;) { name += (char)chr; } return(new ElfSymbol(name, info, other, shIdx, value, size)); }
public static string ReadAsciiString(IMemoryManager memory, long position, long maxSize = -1) { using (MemoryStream ms = new MemoryStream()) { for (long offs = 0; offs < maxSize || maxSize == -1; offs++) { byte value = (byte)memory.ReadByte(position + offs); if (value == 0) { break; } ms.WriteByte(value); } return(Encoding.ASCII.GetString(ms.ToArray())); } }