public void Setup() { eventListener = new FakeDecompilerEventListener(); this.services = new ServiceContainer(); var tlSvc = new TypeLibraryLoaderServiceImpl(services); var configSvc = new Mock <IConfigurationService>(); var win32env = new PlatformDefinition { TypeLibraries = { new TypeLibraryDefinition { Name = "msvcrt.xml" }, new TypeLibraryDefinition { Name = "windows32.xml" }, } }; configSvc.Setup(c => c.GetEnvironment("win32")).Returns(win32env); configSvc.Setup(c => c.GetInstallationRelativePath(It.IsAny <string>())) .Returns((string[] s) => RekoConfigurationService.MakeInstallationRelativePath(s)); services.AddService(typeof(ITypeLibraryLoaderService), tlSvc); services.AddService(typeof(IConfigurationService), configSvc.Object); services.AddService(typeof(DecompilerEventListener), eventListener); services.AddService(typeof(CancellationTokenSource), new CancellationTokenSource()); services.AddService(typeof(IFileSystemService), new FileSystemServiceImpl()); services.AddService(typeof(IDiagnosticsService), new FakeDiagnosticsService()); arch = new X86ArchitectureFlat32("x86-protected-32"); win32 = new Reko.Environments.Windows.Win32Platform(services, arch); }
public void Setup() { mr = new MockRepository(); eventListener = new FakeDecompilerEventListener(); this.services = mr.Stub <IServiceProvider>(); var tlSvc = new TypeLibraryLoaderServiceImpl(services); var configSvc = mr.StrictMock <IConfigurationService>(); var win32env = new OperatingEnvironmentElement { TypeLibraries = { new TypeLibraryElement { Name = "msvcrt.xml" }, new TypeLibraryElement { Name = "windows32.xml" }, } }; configSvc.Stub(c => c.GetEnvironment("win32")).Return(win32env); configSvc.Stub(c => c.GetInstallationRelativePath(null)).IgnoreArguments() .Do(new Func <string[], string>(s => RekoConfigurationService.MakeInstallationRelativePath(s))); services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc); services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(configSvc); services.Stub(s => s.GetService(typeof(DecompilerEventListener))).Return(eventListener); services.Stub(s => s.GetService(typeof(CancellationTokenSource))).Return(null); services.Stub(s => s.GetService(typeof(IFileSystemService))).Return(new FileSystemServiceImpl()); services.Stub(s => s.GetService(typeof(IDiagnosticsService))).Return(new FakeDiagnosticsService()); services.Replay(); configSvc.Replay(); arch = new X86ArchitectureFlat32("x86-protected-32"); win32 = new Reko.Environments.Windows.Win32Platform(services, arch); }
public async Task Zot() { var sc = new ServiceContainer(); var plSvc = new PluginLoaderService(); sc.AddService <IPluginLoaderService>(plSvc); var fsSvc = new FileSystemServiceImpl(); sc.AddService <IFileSystemService>(fsSvc); var cfgSvc = RekoConfigurationService.Load(sc, @"D:\dev\uxmal\reko\extras\parallel\UnitTests\bin\Debug\net5.0\reko\reko.config"); sc.AddService <IConfigurationService>(cfgSvc); var listener = new NullDecompilerEventListener(); sc.AddService <DecompilerEventListener>(listener); var dechost = new Reko.DecompiledFileService(sc, fsSvc, listener); sc.AddService <IDecompiledFileService>(dechost); var tlSvc = new TypeLibraryLoaderServiceImpl(sc); sc.AddService <ITypeLibraryLoaderService>(tlSvc); var loader = new Reko.Loading.Loader(sc); var program = (Program)loader.Load(ImageLocation.FromUri(@"D:\dev\uxmal\reko\users\smx-zoo\RELEASE_MIPS\RELEASE")); var project = Project.FromSingleProgram(program); var reko = new Reko.Decompiler(project, sc); TryFindSegment(program, ".text", out var seg); var scanner = new Scanner(seg.MemoryArea); var result = await scanner.ScanAsync(program.EntryPoints.Values); Console.Write(result.B.Count); }