本文整理汇总了C#中ICSharpCode.ILSpy.DecompilationOptions类的典型用法代码示例。如果您正苦于以下问题:C# DecompilationOptions类的具体用法?C# DecompilationOptions怎么用?C# DecompilationOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DecompilationOptions类属于ICSharpCode.ILSpy命名空间,在下文中一共展示了DecompilationOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DecompileMethod
public override void DecompileMethod(ilspy::Mono.Cecil.MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
var xMethod = GetXMethodDefinition(method);
var ilMethod = xMethod as XBuilder.ILMethodDefinition;
CompiledMethod cmethod;
if (ilMethod == null || !ilMethod.OriginalMethod.HasBody)
{
output.Write("");
output.WriteLine("// not an il method or method without body.");
return;
}
var methodSource = new MethodSource(xMethod, ilMethod.OriginalMethod);
var target = (DexTargetPackage) AssemblyCompiler.TargetPackage;
var dMethod = (MethodDefinition)xMethod.GetReference(target);
DexMethodBodyCompiler.TranslateToRL(AssemblyCompiler, target, methodSource, dMethod, GenerateSetNextInstructionCode, out cmethod);
var rlBody = cmethod.RLBody;
// Optimize RL code
string lastApplied = RLTransformations.Transform(target.DexFile, rlBody, StopOptimizationAfter == -1?int.MaxValue:StopOptimizationAfter);
if(lastApplied != null)
output.WriteLine("// Stop after " + lastApplied);
PrintMethod(cmethod, output, options);
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:28,代码来源:RLLanguage.cs
示例2: DecompileMethod
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
if (!method.HasBody) {
return;
}
ILAstBuilder astBuilder = new ILAstBuilder();
ILBlock ilMethod = new ILBlock();
ilMethod.Body = astBuilder.Build(method, inlineVariables);
if (abortBeforeStep != null) {
DecompilerContext context = new DecompilerContext(method.Module) { CurrentType = method.DeclaringType, CurrentMethod = method };
new ILAstOptimizer().Optimize(context, ilMethod, abortBeforeStep.Value);
}
var allVariables = ilMethod.GetSelfAndChildrenRecursive<ILExpression>().Select(e => e.Operand as ILVariable)
.Where(v => v != null && !v.IsParameter).Distinct();
foreach (ILVariable v in allVariables) {
output.WriteDefinition(v.Name, v);
if (v.Type != null) {
output.Write(" : ");
if (v.IsPinned)
output.Write("pinned ");
v.Type.WriteTo(output, ILNameSyntax.ShortTypeName);
}
output.WriteLine();
}
output.WriteLine();
foreach (ILNode node in ilMethod.Body) {
node.WriteTo(output);
output.WriteLine();
}
}
开发者ID:rmattuschka,项目名称:ILSpy,代码行数:34,代码来源:ILAstLanguage.cs
示例3: WriteResourceToFile
public string WriteResourceToFile(LoadedAssembly assembly, string fileName, Stream stream, DecompilationOptions options)
{
var document = BamlResourceEntryNode.LoadIntoDocument(assembly.GetAssemblyResolver(), assembly.AssemblyDefinition, stream);
fileName = Path.ChangeExtension(fileName, ".xaml");
document.Save(Path.Combine(options.SaveAsProjectDirectory, fileName));
return fileName;
}
开发者ID:FaceHunter,项目名称:ILSpy,代码行数:7,代码来源:BamlResourceNodeFactory.cs
示例4: DecompileMethod
public override void DecompileMethod(ilspy::Mono.Cecil.MethodDefinition method, ICSharpCode.Decompiler.ITextOutput output, DecompilationOptions options)
{
var cmethod = GetCompiledMethod(method);
if ((cmethod != null) && (cmethod.DexMethod != null))
{
try
{
var f = new MethodBodyDisassemblyFormatter(cmethod.DexMethod, MapFile);
var formatOptions = FormatOptions.EmbedSourceCode | FormatOptions.ShowJumpTargets;
if(ShowFullNames) formatOptions |= FormatOptions.FullTypeNames;
if(DebugOperandTypes) formatOptions |= FormatOptions.DebugOperandTypes;
var s = f.Format(formatOptions);
output.Write(s);
}
catch (Exception)
{
output.Write("\n\n// Formatting error. Using Fallback.\n\n");
FallbackFormatting(output, cmethod);
}
}
else
{
output.Write("Method not found in dex");
output.WriteLine();
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:29,代码来源:DexLanguage.cs
示例5: Execute
public override void Execute(object parameter)
{
MainWindow.Instance.TextView.RunWithCancellation(ct => Task<AvalonEditTextOutput>.Factory.StartNew(() => {
AvalonEditTextOutput output = new AvalonEditTextOutput();
Parallel.ForEach(MainWindow.Instance.CurrentAssemblyList.GetAssemblies(), new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount, CancellationToken = ct }, delegate(LoadedAssembly asm) {
if (!asm.HasLoadError) {
Stopwatch w = Stopwatch.StartNew();
Exception exception = null;
using (var writer = new System.IO.StreamWriter("c:\\temp\\decompiled\\" + asm.ShortName + ".cs")) {
try {
var options = new DecompilationOptions { FullDecompilation = true, CancellationToken = ct };
var textOutput = new Decompiler.PlainTextOutput(writer);
textOutput.SetIndentationString(options.DecompilerSettings.IndentString);
new CSharpLanguage().DecompileAssembly(asm, textOutput, options);
}
catch (Exception ex) {
writer.WriteLine(ex.ToString());
exception = ex;
}
}
lock (output) {
output.Write(asm.ShortName + " - " + w.Elapsed);
if (exception != null) {
output.Write(" - ");
output.Write(exception.GetType().Name);
}
output.WriteLine();
}
}
});
return output;
}, ct), task => MainWindow.Instance.TextView.ShowText(task.Result));
}
开发者ID:x-strong,项目名称:ILSpy,代码行数:33,代码来源:DecompileAllCommand.cs
示例6: DecompileAssembly
public override void DecompileAssembly(AssemblyDefinition assembly, string fileName, ITextOutput output, DecompilationOptions options)
{
output.WriteLine("// " + fileName);
output.WriteLine();
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).WriteAssemblyHeader(assembly);
}
开发者ID:richardschneider,项目名称:ILSpy,代码行数:7,代码来源:ILLanguage.cs
示例7: DecompileMethod
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
WriteCommentLine(output, TypeToString(method.DeclaringType, includeNamespace: true));
AstBuilder codeDomBuilder = CreateAstBuilder(options, method.DeclaringType);
codeDomBuilder.AddMethod(method);
codeDomBuilder.GenerateCode(output, transformAbortCondition);
}
开发者ID:tanujmathur,项目名称:ILSpy,代码行数:7,代码来源:CSharpLanguage.cs
示例8: DecompileMethod
public override void DecompileMethod(MethodDef method, ITextOutput output, DecompilationOptions options)
{
WriteComment(output, "Method: ");
output.WriteDefinition(IdentifierEscaper.Escape(method.FullName), method, TextTokenType.Comment, false);
output.WriteLine();
if (!method.HasBody) {
return;
}
StartKeywordBlock(output, ".body", method);
ILAstBuilder astBuilder = new ILAstBuilder();
ILBlock ilMethod = new ILBlock();
DecompilerContext context = new DecompilerContext(method.Module) { CurrentType = method.DeclaringType, CurrentMethod = method };
ilMethod.Body = astBuilder.Build(method, inlineVariables, context);
if (abortBeforeStep != null) {
new ILAstOptimizer().Optimize(context, ilMethod, abortBeforeStep.Value);
}
if (context.CurrentMethodIsAsync) {
output.Write("async", TextTokenType.Keyword);
output.Write('/', TextTokenType.Operator);
output.WriteLine("await", TextTokenType.Keyword);
}
var allVariables = ilMethod.GetSelfAndChildrenRecursive<ILExpression>().Select(e => e.Operand as ILVariable)
.Where(v => v != null && !v.IsParameter).Distinct();
foreach (ILVariable v in allVariables) {
output.WriteDefinition(IdentifierEscaper.Escape(v.Name), v, v.IsParameter ? TextTokenType.Parameter : TextTokenType.Local);
if (v.Type != null) {
output.WriteSpace();
output.Write(':', TextTokenType.Operator);
output.WriteSpace();
if (v.IsPinned) {
output.Write("pinned", TextTokenType.Keyword);
output.WriteSpace();
}
v.Type.WriteTo(output, ILNameSyntax.ShortTypeName);
}
if (v.IsGenerated) {
output.WriteSpace();
output.Write('[', TextTokenType.Operator);
output.Write("generated", TextTokenType.Keyword);
output.Write(']', TextTokenType.Operator);
}
output.WriteLine();
}
var memberMapping = new MemberMapping(method);
foreach (ILNode node in ilMethod.Body) {
node.WriteTo(output, memberMapping);
if (!node.WritesNewLine)
output.WriteLine();
}
output.AddDebugSymbols(memberMapping);
EndKeywordBlock(output);
}
开发者ID:nakijun,项目名称:dnSpy,代码行数:59,代码来源:ILAstLanguage.cs
示例9: PrintMethod
private void PrintMethod(CompiledMethod cmethod, ITextOutput output, DecompilationOptions options)
{
if ((cmethod != null) && (cmethod.RLBody != null))
{
var body = cmethod.RLBody;
var basicBlocks = BasicBlock.Find(body);
foreach (var block in basicBlocks)
{
output.Write(string.Format("D_{0:X4}:", block.Entry.Index));
output.WriteLine();
output.Indent();
foreach (var ins in block.Instructions)
{
if (ShowHasSeqPoint)
{
if (ins.SequencePoint != null)
output.Write(ins.SequencePoint.IsSpecial ? "!" : "~");
}
output.Write(ins.ToString());
output.WriteLine();
}
output.Unindent();
}
if (body.Exceptions.Any())
{
output.WriteLine();
output.Write("Exception handlers:");
output.WriteLine();
output.Indent();
foreach (var handler in body.Exceptions)
{
output.Write(string.Format("{0:x4}-{1:x4}", handler.TryStart.Index, handler.TryEnd.Index));
output.WriteLine();
output.Indent();
foreach (var c in handler.Catches)
{
output.Write(string.Format("{0} => {1:x4}", c.Type, c.Instruction.Index));
output.WriteLine();
}
if (handler.CatchAll != null)
{
output.Write(string.Format("{0} => {1:x4}", "<any>", handler.CatchAll.Index));
output.WriteLine();
}
output.Unindent();
}
output.Unindent();
}
}
else
{
output.Write("Method not found in dex");
output.WriteLine();
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:58,代码来源:RLLanguage.cs
示例10: Decompile
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(EnsureChildrenFiltered));
language.WriteCommentLine(output, "PE");
language.WriteCommentLine(output, "All tree nodes below use the hex editor to modify the PE file");
foreach (HexTreeNode node in Children) {
language.WriteCommentLine(output, string.Empty);
node.Decompile(language, output, options);
}
}
开发者ID:johnjohnsp1,项目名称:dnSpy,代码行数:10,代码来源:PETreeNode.cs
示例11: CreateReflectionDisassembler
ReflectionDisassembler CreateReflectionDisassembler(ITextOutput output, DecompilationOptions options, ModuleDef ownerModule) {
var disOpts = new DisassemblerOptions(options.CancellationToken, ownerModule);
if (options.DecompilerSettings.ShowILComments)
disOpts.GetOpCodeDocumentation = GetOpCodeDocumentation;
if (options.DecompilerSettings.ShowXmlDocumentation)
disOpts.GetXmlDocComments = GetXmlDocComments;
disOpts.CreateInstructionBytesReader = InstructionBytesReader.Create;
disOpts.ShowTokenAndRvaComments = options.DecompilerSettings.ShowTokenAndRvaComments;
disOpts.ShowILBytes = options.DecompilerSettings.ShowILBytes;
disOpts.SortMembers = options.DecompilerSettings.SortMembers;
return new ReflectionDisassembler(output, detectControlStructure, disOpts);
}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:12,代码来源:ILLanguage.cs
示例12: DecompileMethod
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
WriteCommentLine(output, TypeToString(method.DeclaringType, includeNamespace: true));
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: method.DeclaringType, isSingleMember: true);
if (method.IsConstructor && !method.IsStatic && !method.DeclaringType.IsValueType) {
// also fields and other ctors so that the field initializers can be shown as such
AddFieldsAndCtors(codeDomBuilder, method.DeclaringType, method.IsStatic);
RunTransformsAndGenerateCode(codeDomBuilder, output, options, new SelectCtorTransform(method));
} else {
codeDomBuilder.AddMethod(method);
RunTransformsAndGenerateCode(codeDomBuilder, output, options);
}
}
开发者ID:x-strong,项目名称:ILSpy,代码行数:13,代码来源:CSharpLanguage.cs
示例13: DecompileAssembly
public virtual void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
WriteCommentLine(output, assembly.FileName);
if (assembly.AssemblyDefinition != null) {
if (assembly.AssemblyDefinition.IsContentTypeWindowsRuntime) {
WriteCommentLine(output, assembly.AssemblyDefinition.Name + " [WinRT]");
} else {
WriteCommentLine(output, assembly.AssemblyDefinition.FullName);
}
} else {
WriteCommentLine(output, assembly.ModuleDefinition.Name);
}
}
开发者ID:jorik041,项目名称:dnSpy-retired,代码行数:13,代码来源:Language.cs
示例14: DecompileAssembly
public AssemblyCompiler AssemblyCompiler { get { return compiler.AssemblyCompiler; } }
public MapFileLookup MapFile { get { return compiler.MapFile; } }
public static bool GenerateSetNextInstructionCode
{
get { return compiler.GenerateSetNextInstructionCode; }
set { compiler.GenerateSetNextInstructionCode = value; }
}
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
compiler.CompileIfRequired(assembly.AssemblyDefinition);
开发者ID:Xtremrules,项目名称:dot42,代码行数:14,代码来源:CompiledLanguage.cs
示例15: DecompileEvent
public override void DecompileEvent(EventDefinition ev, ITextOutput output, DecompilationOptions options)
{
ReflectionDisassembler rd = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken);
rd.DisassembleEvent(ev);
if (ev.AddMethod != null) {
output.WriteLine();
rd.DisassembleMethod(ev.AddMethod);
}
if (ev.RemoveMethod != null) {
output.WriteLine();
rd.DisassembleMethod(ev.RemoveMethod);
}
foreach (var m in ev.OtherMethods) {
output.WriteLine();
rd.DisassembleMethod(m);
}
}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:17,代码来源:ILLanguage.cs
示例16: DecompileProperty
public override void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options)
{
ReflectionDisassembler rd = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken);
rd.DisassembleProperty(property);
if (property.GetMethod != null) {
output.WriteLine();
rd.DisassembleMethod(property.GetMethod);
}
if (property.SetMethod != null) {
output.WriteLine();
rd.DisassembleMethod(property.SetMethod);
}
foreach (var m in property.OtherMethods) {
output.WriteLine();
rd.DisassembleMethod(m);
}
}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:17,代码来源:ILLanguage.cs
示例17: DecompileType
public override void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options)
{
var xType = GetXTypeDefinition(type);
output.WriteLine("class " + type.Name);
output.WriteLine("{");
foreach (var field in xType.Fields)
{
if (!field.IsReachable)
continue;
output.WriteLine("\t{0} {1};", field.FieldType.Name, field.Name);
}
output.WriteLine();
foreach (var method in xType.Methods)
{
var ilMethod = method as XBuilder.ILMethodDefinition;
if (ilMethod != null && !ilMethod.OriginalMethod.IsReachable)
continue;
output.Write("\t{0} {1}(", method.ReturnType.Name, method.Name);
List<string> parms = method.Parameters.Select(p => string.Format("{0}{1} {2}",
KindToStringAndSpace(p.Kind),
p.ParameterType.Name,
p.Name))
.ToList();
if (method.NeedsGenericInstanceTypeParameter)
parms.Add("Type[] git");
if (method.NeedsGenericInstanceMethodParameter)
parms.Add("Type[] gim");
output.Write(string.Join(", ", parms));
output.WriteLine(")");
output.WriteLine("\t{");
DecompileMethod(method, output, 2);
output.WriteLine("\t}");
output.WriteLine();
}
output.WriteLine("}");
}
开发者ID:jakesays,项目名称:dot42,代码行数:46,代码来源:DexInputLanguage.cs
示例18: DecompileAssembly
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
output.WriteLine("// " + assembly.FileName);
output.WriteLine();
ReflectionDisassembler rd = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken);
//if (options.FullDecompilation)
// rd.WriteAssemblyReferences(assembly.ModuleDefinition);
if (assembly.AssemblyDefinition != null)
rd.WriteAssemblyHeader(assembly.AssemblyDefinition);
output.WriteLine();
rd.WriteModuleHeader(assembly.ModuleDefinition);
if (options.FullDecompilation) {
output.WriteLine();
output.WriteLine();
rd.WriteModuleContents(assembly.ModuleDefinition);
}
}
开发者ID:jorik041,项目名称:dnSpy-retired,代码行数:18,代码来源:ILLanguage.cs
示例19: Decompile
public string Decompile(string language, object o)
{
if (o == null) return String.Empty;
Language l = CreateLanguage(language);
if (l == null) return String.Format("Can't create language: {0}", language);
ITextOutput output = new RtfTextOutput();
DecompilationOptions options = new DecompilationOptions();
if (o is AssemblyDefinition)
l.DecompileAssembly((AssemblyDefinition)o, output, options);
else if (o is TypeDefinition)
l.DecompileType((TypeDefinition)o, output, options);
else if (o is MethodDefinition)
l.DecompileMethod((MethodDefinition)o, output, options);
else if (o is FieldDefinition)
l.DecompileField((FieldDefinition)o, output, options);
else if (o is PropertyDefinition)
l.DecompileProperty((PropertyDefinition)o, output, options);
else if (o is EventDefinition)
l.DecompileEvent((EventDefinition)o, output, options);
else if (o is AssemblyNameReference)
{
output.Write("// Assembly Reference ");
output.WriteDefinition(o.ToString(), null);
output.WriteLine();
}
else if(o is ModuleReference)
{
output.Write("// Module Reference ");
output.WriteDefinition(o.ToString(), null);
output.WriteLine();
}
else
{
output.Write(String.Format("// {0} ", o.GetType().Name));
output.WriteDefinition(o.ToString(), null);
output.WriteLine();
}
return output.ToString();
}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:42,代码来源:SimpleILSpy.cs
示例20: Decompile
public string Decompile(object @object)
{
if (@object == null) return String.Empty;
Language l = new CSharpLanguage();
ITextOutput output = new RtfTextOutput();
var options = new DecompilationOptions();
if (@object is AssemblyDefinition)
l.DecompileAssembly((AssemblyDefinition)@object, output, options);
else if (@object is TypeDefinition)
l.DecompileType((TypeDefinition)@object, output, options);
else if (@object is MethodDefinition)
l.DecompileMethod((MethodDefinition)@object, output, options);
else if (@object is FieldDefinition)
l.DecompileField((FieldDefinition)@object, output, options);
else if (@object is PropertyDefinition)
l.DecompileProperty((PropertyDefinition)@object, output, options);
else if (@object is EventDefinition)
l.DecompileEvent((EventDefinition)@object, output, options);
else if (@object is AssemblyNameReference)
{
output.Write("// Assembly Reference ");
output.WriteDefinition(@object.ToString(), null);
output.WriteLine();
}
else if(@object is ModuleReference)
{
output.Write("// Module Reference ");
output.WriteDefinition(@object.ToString(), null);
output.WriteLine();
}
else
{
output.Write(String.Format("// {0} ", @object.GetType().Name));
output.WriteDefinition(@object.ToString(), null);
output.WriteLine();
}
return output.ToString();
}
开发者ID:AssassinUKG,项目名称:dnEditor,代码行数:41,代码来源:ILSpyDecompiler.cs
注:本文中的ICSharpCode.ILSpy.DecompilationOptions类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论