コード例 #1
0
        /// <summary>
        /// Returns true if the specified address + length partially overlaps
        /// a relocation.
        /// </summary>
        /// <returns></returns>
        public bool Overlaps(Address addr, uint length)
        {
            ulong linAddr    = addr.ToLinear();
            ulong linAddrEnd = linAddr + length;

            if (map.TryGetLowerBoundKey(linAddr, out ulong linReloc))
            {
                // |-reloc----|
                //      |-addr----|
                var linRelocEnd = linReloc + (uint)map[linReloc].DataType.Size;
                if (linReloc < linAddr && linAddr < linRelocEnd)
                {
                    return(true);
                }
            }
            if (map.TryGetUpperBoundKey(linAddr, out linReloc))
            {
                //     |-reloc----|
                // |-addr----|
                var linRelocEnd = linReloc + (uint)map[linReloc].DataType.Size;
                if (linReloc < linAddrEnd)
                {
                    if (linAddrEnd < linRelocEnd)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: MemoryArea.cs プロジェクト: yuejianli/reko
 public bool IsValidAddress(Address addr)
 {
     if (addr == null)
     {
         return(false);
     }
     return(IsValidLinearAddress(addr.ToLinear()));
 }
コード例 #3
0
ファイル: RelocationDictionary.cs プロジェクト: zan00789/reko
        public void Dump(Address addrBase)
        {
            var lin = addrBase.ToLinear();

            foreach (var de in map)
            {
                Debug.Print("{0:X8} - {1}", de.Key - lin, de.Value);
            }
        }
コード例 #4
0
ファイル: SegmentMap.cs プロジェクト: Eng-RSMY/reko
 /// <summary>
 /// Returns the segment that contains the specified address.
 /// </summary>
 /// <param name="addr"></param>
 /// <returns></returns>
 public bool TryFindSegment(Address addr, out ImageSegment segment)
 {
     if (!segments.TryGetLowerBound(addr, out segment))
     {
         return(false);
     }
     if (segment.Address.ToLinear() == addr.ToLinear())
     {
         return(true);
     }
     return(segment.IsInRange(addr));
 }
コード例 #5
0
        public void DumpData(SegmentMap map, Address address, long cbBytes, TextWriter stm)
        {
            ulong        cSkip = address.ToLinear() & 0x0F;
            ImageSegment segment;

            if (!map.TryFindSegment(address, out segment) || segment.MemoryArea == null)
            {
                return;
            }
            ImageReader rdr = arch.CreateImageReader(segment.MemoryArea, address);

            while (cbBytes > 0)
            {
                StringBuilder sb = new StringBuilder(0x12);
                try
                {
                    stm.Write("{0} ", rdr.Address);
                    for (int i = 0; i < 16; ++i)
                    {
                        if (cbBytes > 0 && cSkip == 0)
                        {
                            byte b = rdr.ReadByte();
                            stm.Write("{0:X2} ", b);
                            sb.Append(0x20 <= b && b < 0x7F
                                                                ? (char)b
                                                                : '.');
                            --cbBytes;
                        }
                        else
                        {
                            stm.Write("   ");
                            if (cSkip > 0)
                            {
                                sb.Append(' ');
                            }
                            --cSkip;
                        }
                    }
                }
                catch
                {
                    stm.WriteLine();
                    stm.WriteLine("...end of image");
                    return;
                }
                stm.WriteLine(sb.ToString());
            }
        }
コード例 #6
0
ファイル: Dumper.cs プロジェクト: mmyydd/reko
        public void DumpData(LoadedImage image, Address address, long cbBytes, TextWriter stm)
        {
            ulong       cSkip = address.ToLinear() & 0x0F;
            ImageReader rdr   = arch.CreateImageReader(image, address);

            while (cbBytes > 0)
            {
                StringBuilder sb = new StringBuilder(0x12);
                try
                {
                    stm.Write("{0} ", rdr.Address);
                    for (int i = 0; i < 16; ++i)
                    {
                        if (cbBytes > 0 && cSkip == 0)
                        {
                            byte b = rdr.ReadByte();
                            stm.Write("{0:X2} ", b);
                            sb.Append(0x20 <= b && b < 0x7F
                                                                ? (char)b
                                                                : '.');
                            --cbBytes;
                        }
                        else
                        {
                            stm.Write("   ");
                            if (cSkip > 0)
                            {
                                sb.Append(' ');
                            }
                            --cSkip;
                        }
                    }
                }
                catch
                {
                    stm.WriteLine();
                    stm.WriteLine("...end of image");
                    return;
                }
                stm.WriteLine(sb.ToString());
            }
        }
コード例 #7
0
        bool ExpressionVisitor <bool> .VisitAddress(Reko.Core.Address addr)
        {
            var anyC = p as WildConstant;

            if (anyC != null)
            {
                if (!string.IsNullOrEmpty(anyC.Label))
                {
                    capturedExpressions[anyC.Label] = addr;
                }
                return(true);
            }
            var cP = p as Address;

            if (cP == null)
            {
                return(false);
            }
            return(addr.ToLinear() == cP.ToLinear());
        }
コード例 #8
0
        public void DumpData(SegmentMap map, Address address, long cbBytes, Formatter stm)
        {
            const int    BytesPerLine = 16;
            var          linAddr      = address.ToLinear();
            ulong        cSkip        = linAddr - BytesPerLine * (linAddr / BytesPerLine);
            ImageSegment segment;

            if (!map.TryFindSegment(address, out segment) || segment.MemoryArea == null)
            {
                return;
            }
            byte[]            prevLine     = null;
            bool              showEllipsis = true;
            EndianImageReader rdr          = arch.CreateImageReader(segment.MemoryArea, address);

            while (cbBytes > 0)
            {
                StringBuilder sb      = new StringBuilder(0x12);
                var           bytes   = new List <byte>();
                var           sbBytes = new StringBuilder();
                try
                {
                    sbBytes.AppendFormat("{0} ", rdr.Address);
                    for (int i = 0; i < BytesPerLine; ++i)
                    {
                        if (cbBytes > 0 && cSkip == 0)
                        {
                            byte b = rdr.ReadByte();
                            bytes.Add(b);
                            sbBytes.AppendFormat("{0:X2} ", b);
                            sb.Append(0x20 <= b && b < 0x7F
                                                                ? (char)b
                                                                : '.');
                            --cbBytes;
                        }
                        else
                        {
                            sbBytes.Append("   ");
                            if (cSkip > 0)
                            {
                                sb.Append(' ');
                            }
                            --cSkip;
                        }
                    }
                    var ab = bytes.ToArray();
                    if (!HaveSameZeroBytes(prevLine, ab))
                    {
                        stm.Write(sbBytes.ToString());
                        stm.WriteLine(sb.ToString());
                        showEllipsis = true;
                    }
                    else
                    {
                        if (showEllipsis)
                        {
                            stm.WriteLine("; ...");
                            showEllipsis = false;
                        }
                    }
                    prevLine = ab;
                }
                catch
                {
                    stm.WriteLine();
                    stm.WriteLine(";;; ...end of image");
                    return;
                }
            }
        }
コード例 #9
0
 public bool IsInRange(Address addr)
 {
     return(IsInRange(addr.ToLinear()));
 }
コード例 #10
0
ファイル: UserGlobal.cs プロジェクト: fengjixuchui/reko
 public static string GenerateDefaultName(Address address) => string.Format("g_{0:X}", address.ToLinear());
コード例 #11
0
ファイル: MemoryArea.cs プロジェクト: yuejianli/reko
 private long ToOffset(Address addr)
 {
     return((long)addr.ToLinear() - (long)this.BaseAddress.ToLinear());
 }
コード例 #12
0
ファイル: MemoryArea.cs プロジェクト: xxtxiaofeng/reko
 public bool IsValidAddress(Address addr)
 {
     return(IsValidLinearAddress(addr.ToLinear()));
 }
コード例 #13
0
ファイル: Dumper.cs プロジェクト: nemerle/reko
        public void DumpData(
            IProcessorArchitecture arch,
            MemoryArea mem,
            Address address,
            long cbBytes,
            Formatter stm)
        {
            const int BytesPerLine = 16;
            var       linAddr      = address.ToLinear();
            ulong     cSkip        = linAddr - BytesPerLine * (linAddr / BytesPerLine);

            byte[]? prevLine = null;
            bool showEllipsis = true;

            cbBytes = Math.Min(cbBytes, mem.Length - (address - mem.BaseAddress));
            if (cbBytes <= 0)
            {
                return;
            }
            var rdr = arch.CreateImageReader(mem, address);

            while (cbBytes > 0)
            {
                StringBuilder sb      = new StringBuilder(0x12);
                var           bytes   = new List <byte>();
                var           sbBytes = new StringBuilder();
                try
                {
                    sbBytes.AppendFormat("{0} ", rdr.Address);
                    for (int i = 0; i < BytesPerLine; ++i)
                    {
                        if (cbBytes > 0 && cSkip == 0)
                        {
                            byte b = rdr.ReadByte();
                            bytes.Add(b);
                            sbBytes.AppendFormat("{0:X2} ", b);
                            sb.Append(0x20 <= b && b < 0x7F
                                                                ? (char)b
                                                                : '.');
                            --cbBytes;
                        }
                        else
                        {
                            sbBytes.Append("   ");
                            if (cSkip > 0)
                            {
                                sb.Append(' ');
                            }
                            --cSkip;
                        }
                    }
                    var ab = bytes.ToArray();
                    if (!HaveSameZeroBytes(prevLine, ab))
                    {
                        stm.Write(sbBytes.ToString());
                        stm.WriteLine(sb.ToString());
                        showEllipsis = true;
                    }
                    else
                    {
                        if (showEllipsis)
                        {
                            stm.WriteLine("; ...");
                            showEllipsis = false;
                        }
                    }
                    prevLine = ab;
                }
                catch
                {
                    stm.WriteLine();
                    stm.WriteLine(";;; ...end of image");
                    return;
                }
            }
        }
コード例 #14
0
ファイル: LoadedImage.cs プロジェクト: feelworld/reko
 private ulong ToOffset(Address addr)
 {
     return(addr.ToLinear() - this.BaseAddress.ToLinear());
 }