Esempio n. 1
0
        public ExecutionResult Execute(CommandOptions options, ItemFilter itemFilter)
        {
            var assembly = _assemblyResolver.Resolve(options.FilePath);

            if (assembly == null)
            {
                return(new ExecutionResult(false, "Assembly could not be loaded, please check the path and try again."));
            }

            if (!itemFilter.HasFilter)
            {
                _assemblyDataProcessor.WriteAssemblyExternalReferences(assembly);
                _assemblyDataProcessor.WriteAssemblySection(assembly);
            }

            foreach (var module in assembly.Modules)
            {
                if (!itemFilter.HasFilter)
                {
                    _assemblyDataProcessor.WriteModuleSection(module);
                }

                _assemblyDataProcessor.WriteModuleTypes(module.Types, itemFilter);
            }

            if (!options.IsTextOutput)
            {
                return(new ExecutionResult(true, $"Assembly IL exported to {options.OutputPath}"));
            }

            return(new ExecutionResult(true));
        }
Esempio n. 2
0
        public virtual ExecutionResult Execute(CommandArgument argument, ItemFilter itemFilter)
        {
            var assembly = _assemblyResolver.Resolve(argument.Assembly);

            if (assembly == null)
            {
                return(new ExecutionResult(false, "Error: Assembly could not be loaded, please check the path and try again."));
            }

            if (!itemFilter.HasFilter)
            {
                _assemblyDecompiler.WriteAssemblyExternalReferences(assembly);
                _assemblyDecompiler.WriteAssemblySection(assembly);
            }

            foreach (var module in assembly.Modules)
            {
                if (!itemFilter.HasFilter)
                {
                    _assemblyDecompiler.WriteModuleSection(module);
                }

                _assemblyDecompiler.WriteModuleTypes(module.Types, itemFilter);
            }

            return(new ExecutionResult(true));
        }
        public void Not_Execute_If_Assembly_File_Does_Not_Exist()
        {
            var disassembler = new Disassembler(_assemblyProcessorMock, _assemblyDefinitionResolver);

            _assemblyDefinitionResolver.Resolve(Arg.Any <string>()).Returns((AssemblyDefinition)null);

            ExecutionResult executionResult = disassembler.Execute(new CommandOptions(), new ItemFilter(string.Empty));

            Assert.False(executionResult.Succeeded);
            Assert.Equal("Assembly could not be loaded, please check the path and try again.", executionResult.Message);
        }
        public DisassemblerShould()
        {
            _assemblyDefinitionResolver = Substitute.For <IAssemblyDefinitionResolver>();
            _assemblyProcessorMock      = Substitute.For <IAssemblyDecompiler>();

            var assemblyDefinition = Mono.Cecil.AssemblyDefinition.CreateAssembly(
                new AssemblyNameDefinition("test", Version.Parse("1.0.0")),
                "Module1", ModuleKind.Dll);

            _assemblyDefinitionResolver.Resolve(Arg.Any <string>()).Returns(assemblyDefinition);
        }