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)); }
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 Write_Assembly_ExternalReferences_then_AssemblySection() { var disassembler = new Disassembler(_assemblyProcessorMock, _assemblyDefinitionResolver); disassembler.Execute(new CommandOptions(), new ItemFilter(string.Empty)); Received.InOrder(() => { _assemblyProcessorMock.WriteAssemblyExternalReferences(Arg.Any <AssemblyDefinition>()); _assemblyProcessorMock.WriteAssemblySection(Arg.Any <AssemblyDefinition>()); }); }