/// <summary> /// Create symbols for the driver routines. /// </summary> private void AddDriverMethods(SortedList <Address, ImageSymbol> symbols, ByteMemoryArea memSeg) { void MakeSymbol(ByteMemoryArea mem, string prefix, string routineName, uint offset) { var name = $"{prefix}_{routineName}"; var sym = ImageSymbol.Procedure(this.arch, mem.BaseAddress + offset + 4, name); symbols.Add(sym.Address, sym); } var rdr = memSeg.CreateBeReader(4 + 8); var offsetOpen = rdr.ReadBeUInt16(); var offsetPrime = rdr.ReadBeUInt16(); var offsetCtl = rdr.ReadBeUInt16(); var offsetStatus = rdr.ReadBeUInt16(); var offsetClose = rdr.ReadBeUInt16(); var cbName = rdr.ReadByte(); var abName = rdr.ReadBytes(cbName); var driverName = Encoding.UTF8.GetString(abName); var driverPrefix = NamingPolicy.SanitizeIdentifierName(driverName); MakeSymbol(memSeg, driverPrefix, "Open", offsetOpen); MakeSymbol(memSeg, driverPrefix, "Prime", offsetPrime); MakeSymbol(memSeg, driverPrefix, "Ctl", offsetCtl); MakeSymbol(memSeg, driverPrefix, "Status", offsetStatus); MakeSymbol(memSeg, driverPrefix, "Close", offsetClose); }
private string FilenameBasedOnSegment(Address addr, ImageSegment seg, string fileExtension) { if (!segmentFilenames.TryGetValue(seg, out var filename)) { var sanitizedSegName = NamingPolicy.SanitizeIdentifierName(seg.Name); filename = $"{progname}_{sanitizedSegName}"; segmentFilenames.Add(seg, filename); } // If the segment is large, we need to subdivide it. if (seg.Size > MaxChunkSize) { var offset = addr - seg.Address; var chunk = offset / MaxChunkSize; filename = $"{filename}_{chunk:X4}"; } return(Path.ChangeExtension(filename, fileExtension)); }