public LoadCommand(byte[] buffer, int offset) { m_commandType = (LoadCommandType)LittleEndianConverter.ToUInt32(buffer, offset + 0); m_commandSize = LittleEndianConverter.ToUInt32(buffer, offset + 4); if (this.GetType() == typeof(LoadCommand)) // We check if the current class is LoadCommand and not a class that inherits from LoadCommand { Data = ByteReader.ReadBytes(buffer, offset + 8, (int)(CommandSize - 8)); } }
public LoadCommand GetLoadCommand(LoadCommandType commandType) { foreach (LoadCommand command in LoadCommands) { if (command.CommandType == commandType) { return(command); } } return(null); }
private MachSegment[] ReadSegments() { List <MachSegment> segs = new List <MachSegment>(); foreach (Tuple <MachLoadCommand, ulong> cmdAndPos in _loadCommands.Value) { LoadCommandType segType = Is64Bit ? LoadCommandType.Segment64 : LoadCommandType.Segment; if (cmdAndPos.Item1.Command != segType) { continue; } MachSegment seg = new MachSegment(DataSourceReader, cmdAndPos.Item2, _dataSourceIsVirtualAddressSpace); segs.Add(seg); } return(segs.ToArray()); }
public static LoadCommand ReadCommand(byte[] buffer, int offset) { LoadCommandType commandType = (LoadCommandType)LittleEndianConverter.ToUInt32(buffer, offset + 0); switch (commandType) { case LoadCommandType.Segment: return(new SegmentCommand32(buffer, offset + 0)); case LoadCommandType.Segment64: return(new SegmentCommand64(buffer, offset + 0)); case LoadCommandType.CodeSignature: return(new CodeSignatureCommand(buffer, offset + 0)); default: return(new LoadCommand(buffer, offset + 0)); } }
public byte[] Data; // LoadCommand data, only used for unrecognized LoadCommand structures public LoadCommand(LoadCommandType commandType, uint commandSize) { }
public string SegmentName; // segname, 16 bytes public SegmentCommand(LoadCommandType commandType, uint commandSize) : base(commandType, commandSize) { }