public List <EntryPoint> LoadEntryPoints(Dictionary <int, string> names) { var rdr = new LeImageReader(RawImage, this.lfaNew + this.offEntryTable); var entries = new List <EntryPoint>(); for (;;) { var cEntries = rdr.ReadByte(); if (cEntries == 0) { break; } var segNum = rdr.ReadByte(); var seg = this.segments[segNum - 1]; for (int i = 0; i < cEntries; ++i) { var flags = rdr.ReadByte(); var offset = rdr.ReadUInt16(); string name; var addr = seg.Address + offset; var state = arch.CreateProcessorState(); EntryPoint ep; if (names.TryGetValue(entries.Count, out name)) { ep = new EntryPoint(addr, name, state); } else { ep = new EntryPoint(addr, state); } entries.Add(ep); } } return(entries); }
public List <ImageSymbol> LoadEntryPoints(Dictionary <int, string> names) { var rdr = new LeImageReader(RawImage, this.lfaNew + this.offEntryTable); var entries = new List <ImageSymbol>(); for (;;) { var cEntries = rdr.ReadByte(); if (cEntries == 0) { break; } var segNum = rdr.ReadByte(); var seg = this.segments[segNum - 1]; for (int i = 0; i < cEntries; ++i) { var flags = rdr.ReadByte(); var offset = rdr.ReadUInt16(); string name; var addr = seg.Address + offset; var state = arch.CreateProcessorState(); ImageSymbol ep = new ImageSymbol(addr); if (names.TryGetValue(entries.Count, out name)) { ep.Name = name; } ep.Type = SymbolType.Procedure; ep.ProcessorState = state; imageSymbols[ep.Address] = ep; entries.Add(ep); } } return(entries); }
public ArchiveDirectoryEntry[] LoadDirectory() { var rdr = new LeImageReader(this.RawImage); rdr.Offset += 8; // Skip title var entries = new DFSEntry[31]; for (int i = 0; i < 31; ++i) { var bytes = rdr.ReadBytes(7); var fname = new string(bytes.Select(b => (char)b).ToArray()); var bDir = rdr.ReadByte(); var dir = (char)bDir & 0x7F; var locked = (bDir & 0x80) != 0; var de = new DFSEntry { Name = fname }; entries[i] = de; } // Sector 1 Debug.Assert(rdr.Offset == 0x0100); rdr.Offset += 4; // Skip last 4 bytes of title rdr.ReadByte(); // # of writes int cEntries = rdr.ReadByte() / 8; byte cSectHi = rdr.ReadByte(); byte cSectLo = rdr.ReadByte(); for (int i = 0; i < 31; ++i) { var uAddrLoad = rdr.ReadUInt16(); var uAddrExec = rdr.ReadUInt16(); var cbLength = rdr.ReadUInt16(); var sectHi = rdr.ReadByte(); var sectLo = rdr.ReadByte(); var de = entries[i]; de.LoadAddress = Address.Ptr16(uAddrLoad); de.ExecAddress = Address.Ptr16(uAddrLoad); de.Length = cbLength; } return(entries.Take(cEntries).ToArray()); }
private FileHeader LoadHeader() { var rdr = new LeImageReader(RawImage, 0); var magic = rdr.ReadLeUInt16(); switch (magic) { case 0x014C: arch = new IntelArchitecture(ProcessorMode.Protected32); break; default: throw new NotSupportedException(); } return(new FileHeader { f_magic = magic, f_nscns = rdr.ReadUInt16(), f_timdat = rdr.ReadUInt32(), f_symptr = rdr.ReadUInt32(), f_nsyms = rdr.ReadUInt32(), f_opthdr = rdr.ReadUInt16(), f_flags = rdr.ReadUInt16(), }); }
private FileHeader LoadHeader() { var rdr = new LeImageReader(RawImage, 0); var magic = rdr.ReadLeUInt16(); var cfgSvc = Services.RequireService <IConfigurationService>(); switch (magic) { case 0x014C: arch = cfgSvc.GetArchitecture("x86-real-16"); break; default: throw new NotSupportedException(); } return(new FileHeader { f_magic = magic, f_nscns = rdr.ReadUInt16(), f_timdat = rdr.ReadUInt32(), f_symptr = rdr.ReadUInt32(), f_nsyms = rdr.ReadUInt32(), f_opthdr = rdr.ReadUInt16(), f_flags = rdr.ReadUInt16(), }); }
private (byte, ushort) ReadFixedSegmentEntry(LeImageReader rdr, byte iSeg) { var offset = rdr.ReadUInt16(); return(iSeg, offset); }