当前位置: 首页>>代码示例>>C#>>正文


C# Address.ToLinear方法代码示例

本文整理汇总了C#中Address.ToLinear方法的典型用法代码示例。如果您正苦于以下问题:C# Address.ToLinear方法的具体用法?C# Address.ToLinear怎么用?C# Address.ToLinear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Address的用法示例。


在下文中一共展示了Address.ToLinear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplySignatureToProcedure

        public void ApplySignatureToProcedure(Address addr, ProcedureSignature sig, Procedure proc)
        {
            proc.Signature = sig;

            int i = 0;
            var stmts = proc.EntryBlock.Succ[0].Statements;
            var linAddr = addr.ToLinear();
            foreach (var param in sig.Parameters)
            {
                var starg = param.Storage as StackArgumentStorage;
                if (starg != null)
                {
                    proc.Frame.EnsureStackArgument(
                        starg.StackOffset + sig.ReturnAddressOnStack,
                        param.DataType,
                        param.Name);
                }
                else
                {
                    var paramId = proc.Frame.EnsureIdentifier(param.Storage);
                    paramId.DataType = param.DataType;

                    // Need to take an extra step with parameters being passed
                    // in a register. It's perfectly possible for a user to 
                    // create a variable which they want to call 'r2' but which
                    // the calling convention of the machine wants to call 'r1'.
                    // To avoid this, we create a temporary identifier for 
                    // the formal parameter, and inject an copy statement in the
                    // entry block that moves the parameter value into the 
                    // register.
                    stmts.Insert(i, linAddr, NewMethod(param, paramId));
                    ++i;
                }
            }
        }
开发者ID:gitter-badger,项目名称:reko,代码行数:35,代码来源:UserSignatureBuilder.cs

示例2: Overlaps

 /// <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;
     ulong linReloc;
     if (map.TryGetLowerBoundKey(linAddr, out 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;
 }
开发者ID:relaxar,项目名称:reko,代码行数:33,代码来源:RelocationDictionary.cs

示例3: IsInRange

 public bool IsInRange(Address addr)
 {
     return IsInRange(addr.ToLinear());
 }
开发者ID:relaxar,项目名称:reko,代码行数:4,代码来源:ImageSegment.cs

示例4: DumpData

 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());
     }
 }
开发者ID:nemerle,项目名称:reko,代码行数:39,代码来源:Dumper.cs

示例5: SplitBlock

        /// <summary>
        /// Splits the given block at the specified address, yielding two blocks. The first block is the original block,
        /// now truncated, with a single out edge to the new block. The second block receives the out edges of the first block.
        /// </summary>
        /// <param name="block"></param>
        /// <param name="addr"></param>
        /// <returns>The newly created, empty second block</returns>
        public Block SplitBlock(Block blockToSplit, Address addr)
        {
            var graph = blockToSplit.Procedure.ControlGraph;
            var blockNew = AddBlock(addr, blockToSplit.Procedure, GenerateBlockName(addr));
            foreach (var succ in graph.Successors(blockToSplit))
            {
                graph.AddEdge(blockNew, succ);
            }
            foreach (var succ in graph.Successors(blockNew))
            {
                graph.RemoveEdge(blockToSplit, succ);
            }

            var linAddr = addr.ToLinear();
            var stmsToMove = blockToSplit.Statements.FindAll(s => s.LinearAddress >= linAddr).ToArray();
            if (blockToSplit.Statements.Count > 0 && blockToSplit.Statements.Last.LinearAddress >= linAddr)
            {
                graph.AddEdge(blockToSplit, blockNew);
                blockToSplit.Statements.RemoveAll(s => s.LinearAddress >= linAddr);
            }
            blockNew.Statements.AddRange(stmsToMove);
            foreach (var stm in stmsToMove)
            {
                stm.Block = blockNew;
            }
            blocks[blockStarts[blockToSplit]].End = linAddr;
            return blockNew;
        }
开发者ID:killbug2004,项目名称:reko,代码行数:35,代码来源:Scanner.cs

示例6: ScanProcedure

        /// <summary>
        /// Performs a scan of the blocks that constitute a procedure named <paramref name="procedureName"/>
        /// </summary>
        /// <param name="addr">Address of the code from which we will start scanning.</param>
        /// <param name="procedureName"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public ProcedureBase ScanProcedure(Address addr, string procedureName, ProcessorState state)
        {
            TerminateAnyBlockAt(addr);
            var trampoline = GetTrampoline(addr);
            if (trampoline != null)
                return trampoline;
            var imp = GetImportedProcedure(addr, addr);
            if (imp != null)
                return imp;
            Procedure proc = EnsureProcedure(addr, procedureName);
            if (visitedProcs.Contains(proc))
                return proc;

            visitedProcs.Add(proc);
            Debug.WriteLineIf(trace.TraceInfo, string.Format("Scanning procedure at {0}", addr));

            //$REFACTOR: make the stack explicit?
            var oldQueue = queue;
            queue = new PriorityQueue<WorkItem>();
            var st = state.Clone();
            st.OnProcedureEntered();
            var sp = proc.Frame.EnsureRegister(program.Architecture.StackRegister);
            st.SetValue(sp, proc.Frame.FramePointer);
            var block = EnqueueJumpTarget(addr, addr, proc, st);
            proc.ControlGraph.AddEdge(proc.EntryBlock, block);
            ProcessQueue();
            queue = oldQueue;

            // Add <stackpointer> := fp explicitly to the starting block.
            proc.EntryBlock.Succ[0].Statements.Insert(0, addr.ToLinear(), new Assignment(sp, proc.Frame.FramePointer));
            return proc;
        }
开发者ID:killbug2004,项目名称:reko,代码行数:39,代码来源:Scanner.cs

示例7: AddBlock

        /// <summary>
        /// Adds a new basic block to the procedure <paramref name="proc"/>.
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="proc"></param>
        /// <param name="blockName"></param>
        /// <returns></returns>
        public Block AddBlock(Address addr, Procedure proc, string blockName)
        {
            Block b = new Block(proc, blockName) { Address = addr };
            blocks.Add(addr, new BlockRange(b, addr.ToLinear(), image.BaseAddress.ToLinear() + (uint)image.Bytes.Length));
            blockStarts.Add(b, addr);
            proc.ControlGraph.Blocks.Add(b);

            imageMap.AddItem(addr, new ImageMapBlock { Block = b }); 
            return b;
        }
开发者ID:killbug2004,项目名称:reko,代码行数:17,代码来源:Scanner.cs

示例8: BwiX86_SetCallSignatureAdAddress

 public void BwiX86_SetCallSignatureAdAddress(Address addrCallInstruction, FunctionType signature)
 {
     sigs.Add(addrCallInstruction.ToLinear(), signature);
 }
开发者ID:relaxar,项目名称:reko,代码行数:4,代码来源:BlockWorkitem.X86Tests.cs

示例9: IsValidAddress

 public bool IsValidAddress(Address addr)
 {
     if (addr == null)
         return false;
     return IsValidLinearAddress(addr.ToLinear());
 }
开发者ID:nemerle,项目名称:reko,代码行数:6,代码来源:LoadedImage.cs

示例10: CreateCallRetThunk

        /// <summary>
        /// Creates a small basic block, consisting solely of a 'call' followed by a 'return'
        /// instruction. 
        /// </summary>
        /// <param name="addrFrom"></param>
        /// <param name="procOld"></param>
        /// <param name="procNew"></param>
        /// <returns></returns>
        public Block CreateCallRetThunk(Address addrFrom, Procedure procOld, Procedure procNew)
        {
            //$BUG: ReturnAddressOnStack property needs to be properly set, the
            // EvenOdd sample shows how this doesn't work currently. 
            var blockName = string.Format(
                "{0}_thunk_{1}", 
                Block.GenerateName(addrFrom),
                procNew.Name);
            var callRetThunkBlock = procOld.AddBlock(blockName);
            callRetThunkBlock.IsSynthesized = true;

            var linFrom = addrFrom.ToLinear();
            callRetThunkBlock.Statements.Add(
                addrFrom.ToLinear(), 
                new CallInstruction(
                    new ProcedureConstant(program.Platform.PointerType, procNew),
                    new CallSite(
                        procNew.Signature.ReturnAddressOnStack,
                        0)));
            program.CallGraph.AddEdge(callRetThunkBlock.Statements.Last, procNew);

            callRetThunkBlock.Statements.Add(linFrom, new ReturnInstruction());
            procOld.ControlGraph.AddEdge(callRetThunkBlock, procOld.ExitBlock);
            SetProcedureReturnAddressBytes(procOld, procNew.Frame.ReturnAddressSize, addrFrom);
            return callRetThunkBlock;
        }
开发者ID:uxmal,项目名称:reko,代码行数:34,代码来源:Scanner.cs

示例11: AddBlock

        /// <summary>
        /// Adds a new basic block to the procedure <paramref name="proc"/>.
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="proc"></param>
        /// <param name="blockName"></param>
        /// <returns></returns>
        public Block AddBlock(Address addr, Procedure proc, string blockName)
        {
            Block b = new Block(proc, blockName) { Address = addr };
            var lastMem = segmentMap.Segments.Values.Last().MemoryArea;
            blocks.Add(addr, new BlockRange(b, addr.ToLinear(), lastMem.BaseAddress.ToLinear() + (uint)lastMem.Length));
            blockStarts.Add(b, addr);
            proc.ControlGraph.Blocks.Add(b);

            imageMap.AddItem(addr, new ImageMapBlock { Block = b }); 
            return b;
        }
开发者ID:uxmal,项目名称:reko,代码行数:18,代码来源:Scanner.cs

示例12: RoundToNearestRow

		private Address RoundToNearestRow(Address addr)
		{
			ulong rows = addr.ToLinear() / cbRow;
			return imageMap.MapLinearAddressToAddress(rows * cbRow);
		}
开发者ID:melbcat,项目名称:reko,代码行数:5,代码来源:MemoryControl.cs

示例13: IsAddressInSelection

 private bool IsAddressInSelection(Address addr)
 {
     if (addr == null || addrAnchor == null || addrSelected == null)
         return false;
     var linAddr = addr.ToLinear();
     var linAnch = addrAnchor.ToLinear();
     var linSel = addrSelected.ToLinear();
     if (linAnch <= linSel)
     {
         return linAnch <= linAddr && linAddr <= linSel;
     }
     else 
     {
         return linSel <= linAddr && linAddr <= linAnch;
     }
 }
开发者ID:melbcat,项目名称:reko,代码行数:16,代码来源:MemoryControl.cs

示例14: ApplySignatureToProcedure

        private void ApplySignatureToProcedure(Address addr, ProcedureSignature sig, Procedure proc)
        {
            proc.Signature = sig;

            int i = 0;
            var stmts = proc.EntryBlock.Succ[0].Statements;
            var linAddr = addr.ToLinear();
            foreach (var param in sig.Parameters)
            {
                Identifier dst;
                var starg = param.Storage as StackArgumentStorage;
                if (starg != null)
                {
                    dst = proc.Frame.EnsureStackArgument(
                        starg.StackOffset + sig.ReturnAddressOnStack,
                        param.DataType);
                }
                else
                {
                    dst = proc.Frame.EnsureIdentifier(param.Storage);
                }
                stmts.Insert(i, linAddr, new Assignment(dst, param));
                ++i;
            }
        }
开发者ID:nemerle,项目名称:reko,代码行数:25,代码来源:UserSignatureBuilder.cs

示例15: InjectProcedureEntryStatements

 public override void InjectProcedureEntryStatements(Procedure proc, Address addr, CodeEmitter m)
 {
     switch (Architecture.Name)
     {
     case "mips-be-32":
         // MIPS ELF ABI: r25 is _always_ set to the address of a procedure on entry.
         m.Assign(proc.Frame.EnsureRegister(Architecture.GetRegister(25)), Constant.Word32((uint)addr.ToLinear()));
         break;
     }
 }
开发者ID:uxmal,项目名称:reko,代码行数:10,代码来源:SysVPlatform.cs


注:本文中的Address.ToLinear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。