AnalyzeProgram() публичный Метод

public AnalyzeProgram ( ) : void
Результат void
Пример #1
0
		protected Program RewriteFile(string relativePath, Address addrBase)
		{
            var sc = new ServiceContainer();
            var config = new FakeDecompilerConfiguration();
            sc.AddService<IConfigurationService>(config);
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener());
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            ILoader ldr = new Loader(sc);
            var program = ldr.AssembleExecutable(
                FileUnitTester.MapTestPath(relativePath),
                new X86TextAssembler(sc, new IntelArchitecture(ProcessorMode.Real)),
                addrBase);
            program.Platform = new DefaultPlatform(sc, program.Architecture);
            var ep = new EntryPoint(program.Image.BaseAddress, program.Architecture.CreateProcessorState());
            var project = new Project { Programs = { program } };
            var scan = new Scanner(
                program,
                new Dictionary<Address, ProcedureSignature>(),
                new ImportResolver(project),
                sc);
			scan.EnqueueEntryPoint(ep);
			scan.ScanImage();

			var dfa = new DataFlowAnalysis(program, new FakeDecompilerEventListener());
			dfa.AnalyzeProgram();
            return program;
		}
Пример #2
0
		protected Program RewriteFile(string relativePath, Address addrBase)
		{
            sc = new ServiceContainer();
            var config = new FakeDecompilerConfiguration();
            var eventListener = new FakeDecompilerEventListener();
            sc.AddService<IConfigurationService>(config);
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<DecompilerEventListener>(eventListener);
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            ILoader ldr = new Loader(sc);
            var program = ldr.AssembleExecutable(
                FileUnitTester.MapTestPath(relativePath),
                new X86TextAssembler(sc, new X86ArchitectureReal()),
                addrBase);
            program.Platform = new DefaultPlatform(sc, program.Architecture);
            var ep = new ImageSymbol(program.SegmentMap.BaseAddress);
            var project = new Project { Programs = { program } };
            var scan = new Scanner(
                program,
                new ImportResolver(project, program, eventListener),
                sc);
			scan.EnqueueImageSymbol(ep, true);
			scan.ScanImage();

            var importResolver = new ImportResolver(project, program, eventListener);
            var dfa = new DataFlowAnalysis(program, importResolver, eventListener);
			dfa.AnalyzeProgram();
            return program;
		}
Пример #3
0
        protected void RunHexTest(string hexFile, string outputFile)
        {
            var svc = new ServiceContainer();
            var cfg = new FakeDecompilerConfiguration();
            var eventListener = new FakeDecompilerEventListener();
            svc.AddService<IConfigurationService>(cfg);
            svc.AddService<DecompilerEventListener>(eventListener);
            svc.AddService<DecompilerHost>(new FakeDecompilerHost());
            ILoader ldr = new Loader(svc);
            var imgLoader = new DchexLoader(FileUnitTester.MapTestPath( hexFile), svc, null);
            var program = imgLoader.Load(null);
            var project = new Project { Programs = { program } };
            var ep = new ImageSymbol(program.ImageMap.BaseAddress);
            var importResolver = new ImportResolver(project, program, eventListener);
            var scan = new Scanner(program, importResolver, svc);
            scan.EnqueueImageSymbol(ep, true);
            scan.ScanImage();

            var dfa = new DataFlowAnalysis(program, null, eventListener);
            dfa.AnalyzeProgram();
            RunTest(program, outputFile);
        }
Пример #4
0
        private Program RewriteProgram()
        {
            var eventListener = new FakeDecompilerEventListener();
            var importResolver = MockRepository.GenerateStub<IImportResolver>();
            importResolver.Replay();
            var scan = new Scanner(
                program,
                importResolver,
                sc);
            foreach (ImageSymbol ep in program.EntryPoints.Values)
            {
                scan.EnqueueImageSymbol(ep, true);
            }
            scan.ScanImage();

            var dfa = new DataFlowAnalysis(program, importResolver, eventListener);
            dfa.AnalyzeProgram();

            return program;
        }
Пример #5
0
		public void TrcoTreeFind()
		{
			ProgramBuilder m = new ProgramBuilder();
			m.Add(new TreeFindMock());
			Program prog = m.BuildProgram();
			DataFlowAnalysis dfa = new DataFlowAnalysis(prog, new FakeDecompilerEventListener());
			dfa.AnalyzeProgram();
			RunTest(prog, "Typing/TrcoTreeFind.txt");
		}
Пример #6
0
		public void TrcoIntelIndexedAddressingMode()
		{
			ProgramBuilder m = new ProgramBuilder();
			m.Add(new IntelIndexedAddressingMode());
			Program prog = m.BuildProgram();
			DataFlowAnalysis dfa = new DataFlowAnalysis(prog, new FakeDecompilerEventListener());
			dfa.AnalyzeProgram();
			RunTest(prog, "Typing/TrcoIntelIndexedAddressingMode.txt");
		}
Пример #7
0
        protected void RunHexTest(string hexFile, string outputFile)
        {
            var svc = new ServiceContainer();
            var cfg = new FakeDecompilerConfiguration();
            svc.AddService<IConfigurationService>(cfg);
            svc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener());
            svc.AddService<DecompilerHost>(new FakeDecompilerHost());
            ILoader ldr = new Loader(svc);
            var imgLoader = new DchexLoader(FileUnitTester.MapTestPath( hexFile), svc, null);
            var img = imgLoader.Load(null);
            var program = new Program(img.Image, img.Image.CreateImageMap(), img.Architecture, img.Platform);
            var project = new Project { Programs = { program } };
            var ep = new EntryPoint(program.Image.BaseAddress, program.Architecture.CreateProcessorState());
            var scan = new Scanner(program, new Dictionary<Address, ProcedureSignature>(), new ImportResolver(project), svc);
            scan.EnqueueEntryPoint(ep);
            scan.ScanImage();

            var dfa = new DataFlowAnalysis(program, new FakeDecompilerEventListener());
            dfa.AnalyzeProgram();
            RunTest(program, outputFile);
        }
Пример #8
0
        private Program RewriteProgram()
        {
            var project = new Project { Programs = { program } };
            var scan = new Scanner(
                program,
                new Dictionary<Address, ProcedureSignature>(),
                new ImportResolver(project),
                sc);
            foreach (EntryPoint ep in program.EntryPoints)
            {
                scan.EnqueueEntryPoint(ep);
            }
            scan.ScanImage();

            DecompilerEventListener eventListener = new FakeDecompilerEventListener();
            DataFlowAnalysis da = new DataFlowAnalysis(program, eventListener);
            da.AnalyzeProgram();

            return program;
        }
Пример #9
0
		protected override void RunTest(Program prog, TextWriter writer)
		{
			dfa = new DataFlowAnalysis(prog, new FakeDecompilerEventListener());
			dfa.AnalyzeProgram();
			foreach (Procedure proc in prog.Procedures.Values)
			{
				ProcedureFlow flow = dfa.ProgramDataFlow[proc];
				writer.Write("// ");
				flow.Signature.Emit(proc.Name, ProcedureSignature.EmitFlags.ArgumentKind|ProcedureSignature.EmitFlags.LowLevelInfo, writer);
				flow.Emit(prog.Architecture, writer);
				proc.Write(false, writer);
				writer.WriteLine();
			}
		}	
Пример #10
0
        protected override void RunTest(Program prog, TextWriter writer)
		{
            SetCSignatures(prog);
            IImportResolver importResolver = mr.Stub<IImportResolver>();
            importResolver.Replay();
			dfa = new DataFlowAnalysis(prog, importResolver, new FakeDecompilerEventListener());
			dfa.AnalyzeProgram();
			foreach (Procedure proc in prog.Procedures.Values)
			{
				ProcedureFlow flow = dfa.ProgramDataFlow[proc];
				writer.Write("// ");
                var sig = flow.Signature ?? proc.Signature;
                sig.Emit(proc.Name, FunctionType.EmitFlags.ArgumentKind|FunctionType.EmitFlags.LowLevelInfo, writer);
				flow.Emit(prog.Architecture, writer);
				proc.Write(false, writer);
				writer.WriteLine();
			}
		}