public FieldOptionsVM(FieldDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType) { this.ownerModule = ownerModule; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = false, OwnerType = ownerType, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) typeSigCreatorOptions.CanAddGenericTypeVar = false; this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged; this.customAttributesVM = new CustomAttributesVM(ownerModule, language); this.origOptions = options; this.constantVM = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, "Default value for this field"); ConstantVM.PropertyChanged += constantVM_PropertyChanged; this.marshalTypeVM = new MarshalTypeVM(ownerModule, language, ownerType, null); MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged; this.fieldOffset = new NullableUInt32VM(a => HasErrorUpdated()); this.initialValue = new HexStringVM(a => HasErrorUpdated()); this.rva = new UInt32VM(a => HasErrorUpdated()); this.implMapVM = new ImplMapVM(ownerModule); ImplMapVM.PropertyChanged += implMapVM_PropertyChanged; this.typeSigCreator.CanAddFnPtr = false; ConstantVM.IsEnabled = HasDefault; MarshalTypeVM.IsEnabled = HasFieldMarshal; ImplMapVM.IsEnabled = PinvokeImpl; Reinitialize(); }
public PropertyOptionsVM(PropertyDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType) { this.ownerModule = ownerModule; this.origOptions = options; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = true, OwnerType = ownerType, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) typeSigCreatorOptions.CanAddGenericTypeVar = false; var methodSigCreatorOptions = new MethodSigCreatorOptions(typeSigCreatorOptions); methodSigCreatorOptions.IsPropertySig = true; this.methodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions); this.methodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged; this.methodSigCreator.ParametersCreateTypeSigArray.PropertyChanged += methodSigCreator_PropertyChanged; this.methodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr = false; this.getMethodsVM = new MethodDefsVM(ownerModule, language); this.setMethodsVM = new MethodDefsVM(ownerModule, language); this.otherMethodsVM = new MethodDefsVM(ownerModule, language); this.customAttributesVM = new CustomAttributesVM(ownerModule, language); this.constantVM = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, "Default value for this property"); this.constantVM.PropertyChanged += constantVM_PropertyChanged; ConstantVM.IsEnabled = HasDefault; Reinitialize(); }
public override void Decompile(Language language, ITextOutput output) { base.Decompile(language, output); var so = output as ISmartTextOutput; if (so != null) { so.AddButton(null, "Save", (s, e) => Save()); so.WriteLine(); so.WriteLine(); } }
public override void Decompile(ICSharpCode.ILSpy.Language language, ITextOutput output, ICSharpCode.ILSpy.DecompilationOptions options) { //Switches on the token switch (_tokenProvider.MetadataToken.TokenType) { case TokenType.Module: language.DecompileModule((ModuleDefinition)_tokenProvider, output, options); break; case TokenType.Assembly: language.WriteCommentLine(output, ((AssemblyNameReference)_tokenProvider).FullName); break; case TokenType.TypeDef: language.DecompileType((TypeDefinition)_tokenProvider, output, options); break; case TokenType.Field: language.DecompileField((FieldDefinition)_tokenProvider, output, options); break; case TokenType.Method: language.DecompileMethod((MethodDefinition)_tokenProvider, output, options); break; case TokenType.Event: language.DecompileEvent((EventDefinition)_tokenProvider, output, options); break; case TokenType.Property: language.DecompileProperty((PropertyDefinition)_tokenProvider, output, options); break; case TokenType.MemberRef: var memberRef = (MemberReference)_tokenProvider; if (memberRef.DeclaringType != null && memberRef.DeclaringType is GenericInstanceType) { var giType = (GenericInstanceType)memberRef.DeclaringType; var type = giType.ElementType.Resolve(); var memberDef = type.Fields.Cast <IMemberDefinition>() .Concat(type.Methods) .Concat(type.Properties) .Concat(type.Events) .FirstOrDefault(m => m.Name == memberRef.Name); if (memberDef != null) { new ILEditTreeNode(memberDef, true).Decompile(language, output, options); } } break; default: language.WriteCommentLine(output, (string)this.Text); break; } }
public ParamDefVM(ParamDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod) { this.ownerModule = ownerModule; this.origOptions = options; this.sequence = new UInt16VM(a => { OnPropertyChanged("FullName"); HasErrorUpdated(); }); this.customAttributesVM = new CustomAttributesVM(ownerModule, language); this.constantVM = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, "Default value for this parameter"); ConstantVM.PropertyChanged += constantVM_PropertyChanged; this.marshalTypeVM = new MarshalTypeVM(ownerModule, language, ownerType != null ? ownerType : ownerMethod == null ? null : ownerMethod.DeclaringType, ownerMethod); MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged; ConstantVM.IsEnabled = HasDefault; MarshalTypeVM.IsEnabled = HasFieldMarshal; Reinitialize(); }
public TypeDefOrRefAndCAVM(TypeDefOrRefAndCAOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod) { this.origOptions = options; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = false, OwnerType = ownerType, OwnerMethod = ownerMethod, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) typeSigCreatorOptions.CanAddGenericTypeVar = false; if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0) typeSigCreatorOptions.CanAddGenericMethodVar = true; this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); TypeSigCreator.PropertyChanged += TypeSigCreator_PropertyChanged; this.customAttributesVM = new CustomAttributesVM(ownerModule, language); Reinitialize(); }
public GenericParamVM(GenericParamOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod) { this.ownerModule = ownerModule; this.origOptions = options; this.number = new UInt16VM(a => { OnPropertyChanged("FullName"); HasErrorUpdated(); }); this.typeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM<GenericParamConstraint>("Edit Generic Parameter Constraint", "Create Generic Parameter Constraint", ownerModule, language, ownerType, ownerMethod); this.customAttributesVM = new CustomAttributesVM(ownerModule, language); this.gpVarianceVM = new EnumListVM(EnumVM.Create(typeof(GPVariance))); var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = false, OwnerType = ownerType, OwnerMethod = ownerMethod, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) typeSigCreatorOptions.CanAddGenericTypeVar = false; if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0) typeSigCreatorOptions.CanAddGenericMethodVar = true; this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); Reinitialize(); }
private void DecompileAssembly(AssemblyDefinition adef, string outputDir, string location) { Utils.WriteToConsole("Decompiling assembly: " + adef.FullName); //Each visitor is responsible of changing the file if necessary (from here it is ipmossible to know the file names) ICSharpCode.Decompiler.ITextOutput textOutput = new ICSharpCode.Decompiler.FileTextOutput(outputDir); FileWritterManager.WorkingPath = outputDir; ICSharpCode.ILSpy.Language lang = null; //CONFIGURE OUTPUT LANGUAGE if (Config.ToCSharp) { lang = OutputLanguage("C#"); } else { lang = OutputLanguage("CXX"); } if (Config.RecursiveDependencies) { var resolver = new DefaultAssemblyResolver(); Utils.WriteToConsole("Adding " + location + " to resolver search directories"); resolver.AddSearchDirectory(location); foreach (AssemblyNameReference anref in adef.MainModule.AssemblyReferences) { if (!Config.IgnoreReferences.Contains(anref.Name)) { AssemblyDefinition assembly = resolver.Resolve(anref); //TODO: Change directory ? DecompileAssembly(assembly, outputDir, location); if (assembly == null) { Utils.WriteToConsole("alternative: "); Utils.WriteToConsole("ERROR - could not resolve assembly " + anref.FullName + " ."); } } } } //DECOMPILE FIRST TIME AND FILL THE TABLES foreach (TypeDefinition tdef in adef.MainModule.Types) { if (!tdef.Name.Contains("<")) { lang.DecompileType(tdef, textOutput, new ICSharpCode.ILSpy.DecompilationOptions() { FullDecompilation = false }); } } //DECOMPILE foreach (TypeDefinition tdef in adef.MainModule.Types) { if (!tdef.Name.Contains("<")) { lang.DecompileType(tdef, textOutput, new ICSharpCode.ILSpy.DecompilationOptions() { FullDecompilation = false }); Utils.WriteToConsole("Decompiled: " + tdef.FullName); } } }
public MethodOptionsVM(MethodDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod) { this.ownerModule = ownerModule; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = ownerMethod == null || ownerMethod.GenericParameters.Count > 0, OwnerType = ownerType, OwnerMethod = ownerMethod, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) typeSigCreatorOptions.CanAddGenericTypeVar = false; var methodSigCreatorOptions = new MethodSigCreatorOptions(typeSigCreatorOptions); methodSigCreatorOptions.IsPropertySig = false; this.methodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions); this.methodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged; this.methodSigCreator.ParametersCreateTypeSigArray.PropertyChanged += methodSigCreator_PropertyChanged; this.methodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.ShowTypeFullName = true; this.methodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr = false; this.customAttributesVM = new CustomAttributesVM(ownerModule, language, ownerType, ownerMethod); this.declSecuritiesVM = new DeclSecuritiesVM(ownerModule, language, ownerType, ownerMethod); this.paramDefsVM = new ParamDefsVM(ownerModule, language, ownerType, ownerMethod); this.genericParamsVM = new GenericParamsVM(ownerModule, language, ownerType, ownerMethod); this.methodOverridesVM = new MethodOverridesVM(ownerModule, language, ownerType, ownerMethod); this.origOptions = options; this.implMapVM = new ImplMapVM(ownerModule); ImplMapVM.PropertyChanged += implMapVM_PropertyChanged; ImplMapVM.IsEnabled = PinvokeImpl; Reinitialize(); }
public bool Equals(ILSpyTreeNode[] nodes, Language language) { if (Language != language) return false; if (DecompiledNodes.Length != nodes.Length) return false; for (int i = 0; i < DecompiledNodes.Length; i++) { if (DecompiledNodes[i] != nodes[i]) return false; } return true; }
public DecompileTabState(Language language) { var view = TextView; view.Tag = this; this.language = language; ContextMenuProvider.Add(view); view.DragOver += view_DragOver; view.OnThemeUpdated(); InstallMouseWheelZoomHandler(TextView.TextEditor.TextArea); }
internal void SetDecompileProps(Language language, ILSpyTreeNode[] nodes) { this.language = language; UnhookEvents(); this.decompiledNodes = nodes ?? new ILSpyTreeNode[0]; HookEvents(); this.title = null; UpdateHeader(); }
protected override sealed void Write(ITextOutput output, Language language) { Write(output); }
public override sealed void Decompile(Language language, ITextOutput output, DecompilationOptions options) { language.WriteCommentLine(output, string.Format("{0:X8} - {1:X8} {2}", StartOffset, EndOffset, this.ToString())); foreach (var vm in HexVMs) { language.WriteCommentLine(output, string.Empty); language.WriteCommentLine(output, string.Format("{0}:", vm.Name)); foreach (var field in vm.HexFields) language.WriteCommentLine(output, string.Format("{0:X8} - {1:X8} {2} = {3}", field.StartOffset, field.EndOffset, field.FormattedValue, field.Name)); } var smartOutput = output as ISmartTextOutput; if (smartOutput != null) smartOutput.MarkAsNonCached(); }
public DeclSecurityVM(DeclSecurityOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod) { this.ownerModule = ownerModule; this.language = language; this.ownerType = ownerType; this.ownerMethod = ownerMethod; this.origOptions = options; this.customAttributesVM = new CustomAttributesVM(ownerModule, language); CustomAttributesVM.PropertyChanged += CustomAttributesVM_PropertyChanged; this.declSecVerEnumListVM = new EnumListVM(declSecVerList, (a, b) => OnDeclSecVerChanged()); this.securityActionEnumListVM = new EnumListVM(secActList, (a, b) => OnSecurityActionChanged()); this.securityAttributesVM = new SecurityAttributesVM(ownerModule, language, ownerType, ownerMethod); this.SecurityAttributesVM.Collection.CollectionChanged += SecurityAttributesVM_CollectionChanged; Reinitialize(); }