public static GraphProvider Create(MethodDef method) { var methodName = IdentifierEscaper.Escape(method.Name); switch (method.MethodBody) { case CilBody _: { var arch = new CilArchitecture(method); var stateResolver = new CilStateTransitionResolver(arch); var cflowBuilder = new SymbolicFlowGraphBuilder <Instruction>(arch, method.Body.Instructions, stateResolver); var cflow = cflowBuilder.ConstructFlowGraph(0); return(new ControlFlowGraphProvider <Instruction>(methodName, cflow)); } case NativeMethodBody _: { var cflow = IcedHelpers.ReadNativeMethodBody(method); return(new ControlFlowGraphProvider <Iced.Intel.Instruction>(methodName, cflow)); } default: throw new Exception("Tried to create graph for method that has neither managed nor native body"); } }
public static GraphProvider Create(MethodDef method) { var methodName = IdentifierEscaper.Escape(method.Name); switch (method.MethodBody) { case CilBody cilBody: { var cflow = method.ConstructStaticFlowGraph(); return(new ControlFlowGraphProvider <Instruction>(methodName, cflow)); } case NativeMethodBody _: { var cflow = IcedHelpers.ReadNativeMethodBody(method); return(new ControlFlowGraphProvider <Iced.Intel.Instruction>(methodName, cflow)); } default: throw new Exception("Tried to create graph for method that has neither managed nor native body"); } }