Beispiel #1
0
        /// <summary>
        /// Constructs a control flow graph and a data flow graph from a CIL method body.
        /// </summary>
        /// <param name="self">The method body.</param>
        /// <param name="dataFlowGraph">The constructed data flow graph.</param>
        /// <returns>The control flow graph.</returns>
        public static ControlFlowGraph <Instruction> ConstructSymbolicFlowGraph(
            this MethodDef self,
            out DataFlowGraph <Instruction> dataFlowGraph)
        {
            var body = self.Body;

            var architecture = new CilArchitecture(self);
            var dfgBuilder   = new CilStateTransitionResolver(architecture);
            var cfgBuilder   = new SymbolicFlowGraphBuilder <Instruction>(
                architecture,
                body.Instructions,
                dfgBuilder);

            var ehRanges = body
                           .GetExceptionHandlerRanges()
                           .ToArray();

            var cfg = cfgBuilder.ConstructFlowGraph(0, ehRanges);

            if (ehRanges.Length > 0)
            {
                cfg.DetectExceptionHandlerRegions(ehRanges);
            }

            dataFlowGraph = dfgBuilder.DataFlowGraph;
            return(cfg);
        }
Beispiel #2
0
        /// <summary>
        /// Constructs a control flow graph from a CIL method body.
        /// </summary>
        /// <param name="self">The method body.</param>
        /// <returns>The control flow graph.</returns>
        public static ControlFlowGraph <Instruction> ConstructStaticFlowGraph(this MethodDef self)
        {
            var body = self.Body;

            var architecture = new CilArchitecture(self);
            var cfgBuilder   = new StaticFlowGraphBuilder <Instruction>(
                architecture,
                body.Instructions,
                architecture.SuccessorResolver);

            var ehRanges = body
                           .GetExceptionHandlerRanges()
                           .ToArray();

            var cfg = cfgBuilder.ConstructFlowGraph(0, ehRanges);

            if (ehRanges.Length > 0)
            {
                cfg.DetectExceptionHandlerRegions(ehRanges);
            }
            return(cfg);
        }
 /// <summary>
 /// Creates a new instance of the <see cref="CilStateTransitionResolver"/> class.
 /// </summary>
 /// <param name="architecture">The CIL architecture variant to compute state transitions for.</param>
 public CilStateTransitionResolver(CilArchitecture architecture) : base(architecture)
 {
     _architecture = architecture;
 }