Ejemplo n.º 1
0
        public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize)
        {
            origOptions         = options;
            this.canDeserialize = canDeserialize;

            BooleanVM             = new BooleanVM(a => HasErrorUpdated());
            CharVM                = new CharVM(a => HasErrorUpdated());
            ByteVM                = new ByteVM(a => HasErrorUpdated());
            SByteVM               = new SByteVM(a => HasErrorUpdated());
            Int16VM               = new Int16VM(a => HasErrorUpdated());
            UInt16VM              = new UInt16VM(a => HasErrorUpdated());
            Int32VM               = new Int32VM(a => HasErrorUpdated());
            UInt32VM              = new UInt32VM(a => HasErrorUpdated());
            Int64VM               = new Int64VM(a => HasErrorUpdated());
            UInt64VM              = new UInt64VM(a => HasErrorUpdated());
            SingleVM              = new SingleVM(a => HasErrorUpdated());
            DoubleVM              = new DoubleVM(a => HasErrorUpdated());
            DecimalVM             = new DecimalVM(a => HasErrorUpdated());
            DateTimeVM            = new DateTimeVM(a => HasErrorUpdated());
            TimeSpanVM            = new TimeSpanVM(a => HasErrorUpdated());
            UserTypeVM            = new UserTypeVM(ownerModule, canDeserialize);
            ResourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged());

            UserTypeVM.PropertyChanged += (s, e) => {
                if (e.PropertyName == nameof(UserTypeVM.HasError))
                {
                    HasErrorUpdated();
                }
            };

            Reinitialize();
        }
Ejemplo n.º 2
0
		public NativeMethodBodyVM(NativeMethodBodyOptions options, bool initialize) {
			origOptions = options;
			RVA = new UInt32VM(a => HasErrorUpdated());

			if (initialize)
				Reinitialize();
		}
Ejemplo n.º 3
0
        public NativeMethodBodyVM(NativeMethodBodyOptions options)
        {
            this.origOptions = options;
            this.rva = new UInt32VM(a => HasErrorUpdated());

            Reinitialize();
        }
Ejemplo n.º 4
0
        public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize)
        {
            this.origOptions    = options;
            this.canDeserialize = canDeserialize;

            this.booleanVM             = new BooleanVM(a => HasErrorUpdated());
            this.charVM                = new CharVM(a => HasErrorUpdated());
            this.byteVM                = new ByteVM(a => HasErrorUpdated());
            this.sbyteVM               = new SByteVM(a => HasErrorUpdated());
            this.int16VM               = new Int16VM(a => HasErrorUpdated());
            this.uint16VM              = new UInt16VM(a => HasErrorUpdated());
            this.int32VM               = new Int32VM(a => HasErrorUpdated());
            this.uint32VM              = new UInt32VM(a => HasErrorUpdated());
            this.int64VM               = new Int64VM(a => HasErrorUpdated());
            this.uint64VM              = new UInt64VM(a => HasErrorUpdated());
            this.singleVM              = new SingleVM(a => HasErrorUpdated());
            this.doubleVM              = new DoubleVM(a => HasErrorUpdated());
            this.decimalVM             = new DecimalVM(a => HasErrorUpdated());
            this.dateTimeVM            = new DateTimeVM(a => HasErrorUpdated());
            this.timeSpanVM            = new TimeSpanVM(a => HasErrorUpdated());
            this.userTypeVM            = new UserTypeVM(ownerModule, canDeserialize);
            this.resourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged());

            this.UserTypeVM.PropertyChanged += (s, e) => {
                if (e.PropertyName == "HasError")
                {
                    HasErrorUpdated();
                }
            };

            Reinitialize();
        }
Ejemplo n.º 5
0
        public NativeMethodBodyVM(NativeMethodBodyOptions options)
        {
            this.origOptions = options;
            this.rva         = new UInt32VM(a => HasErrorUpdated());

            Reinitialize();
        }
Ejemplo n.º 6
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            this.ownerMethod = ownerMethod;
            this.origOptions = options;

            typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language)
            {
                CanAddGenericTypeVar   = ownerType.HasGenericParameters,
                CanAddGenericMethodVar = ownerMethod.MethodSig.GetGenParamCount() > 0,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            this.localsListVM                                  = new IndexObservableCollection <LocalVM>(() => new LocalVM(typeSigCreatorOptions, new LocalOptions(new Local(ownerModule.CorLibTypes.Int32))));
            this.instructionsListVM                            = new IndexObservableCollection <InstructionVM>(() => CreateInstructionVM());
            this.exceptionHandlersListVM                       = new IndexObservableCollection <ExceptionHandlerVM>(() => new ExceptionHandlerVM(typeSigCreatorOptions, new ExceptionHandlerOptions()));
            this.LocalsListVM.UpdateIndexesDelegate            = LocalsUpdateIndexes;
            this.InstructionsListVM.UpdateIndexesDelegate      = InstructionsUpdateIndexes;
            this.ExceptionHandlersListVM.UpdateIndexesDelegate = ExceptionHandlersUpdateIndexes;
            this.InstructionsListVM.CollectionChanged         += InstructionsListVM_CollectionChanged;
            this.LocalsListVM.CollectionChanged               += LocalsListVM_CollectionChanged;
            this.ExceptionHandlersListVM.CollectionChanged    += ExceptionHandlersListVM_CollectionChanged;
            this.maxStack         = new UInt16VM(a => CallHasErrorUpdated());
            this.localVarSigTok   = new UInt32VM(a => CallHasErrorUpdated());
            this.headerSize       = new ByteVM(a => CallHasErrorUpdated());
            this.headerRVA        = new UInt32VM(a => CallHasErrorUpdated());
            this.headerFileOffset = new UInt64VM(a => CallHasErrorUpdated());
            this.rva        = new UInt32VM(a => CallHasErrorUpdated());
            this.fileOffset = new UInt64VM(a => CallHasErrorUpdated());

            Reinitialize();
        }
Ejemplo n.º 7
0
        public NativeMethodBodyVM(NativeMethodBodyOptions options, bool initialize)
        {
            origOptions = options;
            RVA         = new UInt32VM(a => HasErrorUpdated());

            if (initialize)
            {
                Reinitialize();
            }
        }
Ejemplo n.º 8
0
        public UInt32HexField(HexDocument doc, string parentName, string name, ulong start, bool useDecimal = false)
            : base(doc, parentName, name, start, 4)
        {
            var val = doc.ReadUInt32(start);

            this.data = new UInt32VM(val, a => UpdateValue())
            {
                UseDecimal = useDecimal
            };
            if (useDecimal)
            {
                this.data.Value = val;
            }
        }
Ejemplo n.º 9
0
        public TypeSigCreatorVM(TypeSigCreatorOptions options, TypeSig defaultTypeSig = null)
        {
            this.options = options.Clone();
            this.defaultTypeSig = defaultTypeSig;
            this.arrayRank = new UInt32VM(2, a => { });
            this.arraySizes = new UInt32ListDataFieldVM(a => { }) {
                Min = ModelUtils.COMPRESSED_UINT32_MIN,
                Max = ModelUtils.COMPRESSED_UINT32_MAX,
            };
            this.arrayLowerBounds = new Int32ListDataFieldVM(a => { }) {
                Min = ModelUtils.COMPRESSED_INT32_MIN,
                Max = ModelUtils.COMPRESSED_INT32_MAX,
            };
            this.genericVariableNumber = new UInt32VM(0, a => { });

            Reinitialize();
        }
Ejemplo n.º 10
0
 public MethodSigCreatorVM(MethodSigCreatorOptions options)
 {
     this.options = options.Clone();
     this.title   = options.TypeSigCreatorOptions.Title;
     this.parametersCreateTypeSigArray = new CreateTypeSigArrayVM(options.TypeSigCreatorOptions.Clone(null), null);
     this.ParametersCreateTypeSigArray.TypeSigCollection.CollectionChanged += (s, e) => OnPropertyChanged("SignatureFullName");
     this.sentinelCreateTypeSigArray = new CreateTypeSigArrayVM(options.TypeSigCreatorOptions.Clone(null), null);
     this.SentinelCreateTypeSigArray.TypeSigCollection.CollectionChanged += (s, e) => OnPropertyChanged("SignatureFullName");
     this.sentinelCreateTypeSigArray.IsEnabled = CanHaveSentinel;
     this.genericParameterCount = new UInt32VM(0, a => {
         HasErrorUpdated();
         OnPropertyChanged("SignatureFullName");
         if (GenericParameterCount != null && !GenericParameterCount.HasError)
         {
             IsGeneric = GenericParameterCount.Value != 0;
         }
     })
     {
         Min = ModelUtils.COMPRESSED_UINT32_MIN,
         Max = ModelUtils.COMPRESSED_UINT32_MAX,
     };
     this.methodCallingConvVM = new EnumListVM(methodCallingConvList, (a, b) => {
         if (!IsMethodSig)
         {
             throw new InvalidOperationException();
         }
         CallingConvention = (CallingConvention & ~dnlib.DotNet.CallingConvention.Mask) |
                             (dnlib.DotNet.CallingConvention)(MethodCallingConv) MethodCallingConv.SelectedItem;
     });
     if (!CanHaveSentinel)
     {
         MethodCallingConv.Items.RemoveAt(MethodCallingConv.GetIndex(DnlibDialogs.MethodCallingConv.VarArg));
         MethodCallingConv.Items.RemoveAt(MethodCallingConv.GetIndex(DnlibDialogs.MethodCallingConv.NativeVarArg));
     }
     if (IsMethodSig)
     {
         MethodCallingConv.SelectedItem = DnlibDialogs.MethodCallingConv.Default;
     }
     else
     {
         CallingConvention = (CallingConvention & ~dnlib.DotNet.CallingConvention.Mask) | dnlib.DotNet.CallingConvention.Property;
     }
     ReturnType = options.TypeSigCreatorOptions.OwnerModule.CorLibTypes.Void;
 }
Ejemplo n.º 11
0
        public TypeSigCreatorVM(TypeSigCreatorOptions options, TypeSig defaultTypeSig = null)
        {
            this.options        = options.Clone();
            this.defaultTypeSig = defaultTypeSig;
            this.ArrayRank      = new UInt32VM(2, a => { });
            this.ArraySizes     = new UInt32ListDataFieldVM(a => { })
            {
                Min = ModelUtils.COMPRESSED_UINT32_MIN,
                Max = ModelUtils.COMPRESSED_UINT32_MAX,
            };
            this.ArrayLowerBounds = new Int32ListDataFieldVM(a => { })
            {
                Min = ModelUtils.COMPRESSED_INT32_MIN,
                Max = ModelUtils.COMPRESSED_INT32_MAX,
            };
            this.GenericVariableNumber = new UInt32VM(0, a => { });

            Reinitialize();
        }
Ejemplo n.º 12
0
        public TypeSigCreatorVM(TypeSigCreatorOptions options, TypeSig defaultTypeSig = null)
        {
            this.options        = options.Clone();
            this.defaultTypeSig = defaultTypeSig;
            ArrayRank           = new UInt32VM(2, a => { });
            ArraySizes          = new UInt32ListDataFieldVM(a => { })
            {
                Min = ModelUtils.COMPRESSED_UINT32_MIN,
                Max = ModelUtils.COMPRESSED_UINT32_MAX,
            };
            ArrayLowerBounds = new Int32ListDataFieldVM(a => { })
            {
                Min = ModelUtils.COMPRESSED_INT32_MIN,
                Max = ModelUtils.COMPRESSED_INT32_MAX,
            };
            GenericVariableNumber = new UInt32VM(0, a => { });

            allDecompilers = new ObservableCollection <DecompilerVM>(options.DecompilerService.AllDecompilers.Select(a => new DecompilerVM(a)));

            Reinitialize();
        }
Ejemplo n.º 13
0
 public ModuleOptionsVM(ModuleDef module, ModuleOptions options, ILanguageManager languageManager)
 {
     this.module      = module;
     this.options     = new ModuleOptions();
     this.origOptions = options;
     moduleKindVM     = new EnumListVM(SaveModule.SaveModuleOptionsVM.moduleKindList, (a, b) => {
         Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
     });
     this.machineVM = new EnumListVM(SaveModule.PEHeadersOptionsVM.machineList, (a, b) => {
         Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.PE.Machine)Machine.SelectedItem);
     });
     mvid         = new NullableGuidVM(a => HasErrorUpdated());
     encId        = new NullableGuidVM(a => HasErrorUpdated());
     encBaseId    = new NullableGuidVM(a => HasErrorUpdated());
     clrVersionVM = new EnumListVM(NetModuleOptionsVM.clrVersionList, (a, b) => OnClrVersionChanged());
     clrVersionVM.Items.Add(new EnumVM(Module.ClrVersion.Unknown, dnSpy_AsmEditor_Resources.Unknown));
     clrVersionVM.SelectedItem = Module.ClrVersion.Unknown;
     cor20HeaderRuntimeVersion = new NullableUInt32VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
     tablesHeaderVersion       = new NullableUInt16VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
     nativeEntryPointRva       = new UInt32VM(a => HasErrorUpdated());
     customAttributesVM        = new CustomAttributesVM(module, languageManager);
     Reinitialize();
 }
Ejemplo n.º 14
0
        public FieldOptionsVM(FieldDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService);
            origOptions        = options;

            ConstantVM = new ConstantVM(ownerModule, options.Constant?.Value, dnSpy_AsmEditor_Resources.Field_DefaultValueInfo);
            ConstantVM.PropertyChanged += constantVM_PropertyChanged;
            MarshalTypeVM = new MarshalTypeVM(ownerModule, decompilerService, ownerType, null);
            MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged;
            FieldOffset  = new NullableUInt32VM(a => HasErrorUpdated());
            InitialValue = new HexStringVM(a => HasErrorUpdated());
            RVA          = new UInt32VM(a => HasErrorUpdated());
            ImplMapVM    = new ImplMapVM(ownerModule);
            ImplMapVM.PropertyChanged += implMapVM_PropertyChanged;

            TypeSigCreator.CanAddFnPtr = false;
            ConstantVM.IsEnabled       = HasDefault;
            MarshalTypeVM.IsEnabled    = HasFieldMarshal;
            ImplMapVM.IsEnabled        = PinvokeImpl;
            Reinitialize();
        }
Ejemplo n.º 15
0
        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();
        }
Ejemplo n.º 16
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod, bool initialize)
        {
            OwnerModule      = ownerModule;
            this.ownerMethod = ownerMethod;
            origOptions      = options;

            TypeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                CanAddGenericTypeVar   = ownerType.HasGenericParameters,
                CanAddGenericMethodVar = ownerMethod.MethodSig.GetGenParamCount() > 0,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            LocalsListVM                                  = new LocalsIndexObservableCollection(this, () => new LocalVM(TypeSigCreatorOptions, new LocalOptions(new Local(ownerModule.CorLibTypes.Int32))));
            InstructionsListVM                            = new IndexObservableCollection <InstructionVM>(() => CreateInstructionVM());
            ExceptionHandlersListVM                       = new IndexObservableCollection <ExceptionHandlerVM>(() => new ExceptionHandlerVM(TypeSigCreatorOptions, new ExceptionHandlerOptions()));
            LocalsListVM.UpdateIndexesDelegate            = LocalsUpdateIndexes;
            InstructionsListVM.UpdateIndexesDelegate      = InstructionsUpdateIndexes;
            ExceptionHandlersListVM.UpdateIndexesDelegate = ExceptionHandlersUpdateIndexes;
            InstructionsListVM.CollectionChanged         += InstructionsListVM_CollectionChanged;
            LocalsListVM.CollectionChanged               += LocalsListVM_CollectionChanged;
            ExceptionHandlersListVM.CollectionChanged    += ExceptionHandlersListVM_CollectionChanged;
            MaxStack         = new UInt16VM(a => CallHasErrorUpdated());
            LocalVarSigTok   = new UInt32VM(a => CallHasErrorUpdated());
            HeaderSize       = new ByteVM(a => CallHasErrorUpdated());
            HeaderRVA        = new UInt32VM(a => CallHasErrorUpdated());
            HeaderFileOffset = new UInt64VM(a => CallHasErrorUpdated());
            RVA        = new UInt32VM(a => CallHasErrorUpdated());
            FileOffset = new UInt64VM(a => CallHasErrorUpdated());

            if (initialize)
            {
                Reinitialize();
            }
        }
Ejemplo n.º 17
0
		public ModuleOptionsVM(ModuleDef module, ModuleOptions options, IDecompilerService decompilerService) {
			this.module = module;
			this.options = new ModuleOptions();
			origOptions = options;
			ModuleKind = new EnumListVM(SaveModule.SaveModuleOptionsVM.moduleKindList, (a, b) => {
				Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
			});
			Machine = new EnumListVM(SaveModule.PEHeadersOptionsVM.machineList, (a, b) => {
				Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.PE.Machine)Machine.SelectedItem);
			});
			Mvid = new NullableGuidVM(a => HasErrorUpdated());
			EncId = new NullableGuidVM(a => HasErrorUpdated());
			EncBaseId = new NullableGuidVM(a => HasErrorUpdated());
			ClrVersion = new EnumListVM(NetModuleOptionsVM.clrVersionList, (a, b) => OnClrVersionChanged());
			ClrVersion.Items.Add(new EnumVM(Module.ClrVersion.Unknown, dnSpy_AsmEditor_Resources.Unknown));
			ClrVersion.SelectedItem = Module.ClrVersion.Unknown;
			Cor20HeaderRuntimeVersion = new NullableUInt32VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
			TablesHeaderVersion = new NullableUInt16VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
			NativeEntryPointRva = new UInt32VM(a => HasErrorUpdated());
			CustomAttributesVM = new CustomAttributesVM(module, decompilerService);
			Reinitialize();
		}
Ejemplo n.º 18
0
 public UInt32HexField(HexDocument doc, string parentName, string name, ulong start, bool useDecimal = false)
     : base(doc, parentName, name, start, 4)
 {
     this.data = new UInt32VM(doc.ReadUInt32(start), a => UpdateValue(), useDecimal);
 }
Ejemplo n.º 19
0
 public UInt32HexField(HexBuffer buffer, string parentName, string name, HexPosition start, bool useDecimal = false)
     : base(buffer, parentName, name, start, 4)
 {
     data = new UInt32VM(buffer.ReadUInt32(start), a => UpdateValue(), useDecimal);
 }
Ejemplo n.º 20
0
 public UInt32FlagsHexField(HexDocument doc, string parentName, string name, ulong start)
     : base(doc, parentName, name, start, 4)
 {
     this.data = new UInt32VM(doc.ReadUInt32(start), a => UpdateValue(), false);
 }
Ejemplo n.º 21
0
        public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize)
        {
            this.origOptions = options;
            this.canDeserialize = canDeserialize;

            this.booleanVM = new BooleanVM(a => HasErrorUpdated());
            this.charVM = new CharVM(a => HasErrorUpdated());
            this.byteVM = new ByteVM(a => HasErrorUpdated());
            this.sbyteVM = new SByteVM(a => HasErrorUpdated());
            this.int16VM = new Int16VM(a => HasErrorUpdated());
            this.uint16VM = new UInt16VM(a => HasErrorUpdated());
            this.int32VM = new Int32VM(a => HasErrorUpdated());
            this.uint32VM = new UInt32VM(a => HasErrorUpdated());
            this.int64VM = new Int64VM(a => HasErrorUpdated());
            this.uint64VM = new UInt64VM(a => HasErrorUpdated());
            this.singleVM = new SingleVM(a => HasErrorUpdated());
            this.doubleVM = new DoubleVM(a => HasErrorUpdated());
            this.decimalVM = new DecimalVM(a => HasErrorUpdated());
            this.dateTimeVM = new DateTimeVM(a => HasErrorUpdated());
            this.timeSpanVM = new TimeSpanVM(a => HasErrorUpdated());
            this.userTypeVM = new UserTypeVM(ownerModule, canDeserialize);
            this.resourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged());

            this.UserTypeVM.PropertyChanged += (s, e) => {
                if (e.PropertyName == "HasError")
                    HasErrorUpdated();
            };

            Reinitialize();
        }
Ejemplo n.º 22
0
		public UInt32FlagsHexField(HexBuffer buffer, string parentName, string name, HexPosition start)
			: base(buffer, parentName, name, start, 4) {
			data = new UInt32VM(buffer.ReadUInt32(start), a => UpdateValue(), false);
		}
Ejemplo n.º 23
0
 public UInt32HexField(HexDocument doc, string parentName, string name, ulong start, bool useDecimal = false)
     : base(doc, parentName, name, start, 4)
 {
     var val = doc.ReadUInt32(start);
     this.data = new UInt32VM(val, a => UpdateValue()) { UseDecimal = useDecimal };
     if (useDecimal)
         this.data.Value = val;
 }
Ejemplo n.º 24
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            this.ownerMethod = ownerMethod;
            this.origOptions = options;

            typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                CanAddGenericTypeVar = ownerType.HasGenericParameters,
                CanAddGenericMethodVar = ownerMethod.MethodSig.GetGenParamCount() > 0,
                OwnerType = ownerType,
                OwnerMethod = ownerMethod,
            };

            this.localsListVM = new IndexObservableCollection<LocalVM>(() => new LocalVM(typeSigCreatorOptions, new LocalOptions(new Local(ownerModule.CorLibTypes.Int32))));
            this.instructionsListVM = new IndexObservableCollection<InstructionVM>(() => CreateInstructionVM());
            this.exceptionHandlersListVM = new IndexObservableCollection<ExceptionHandlerVM>(() => new ExceptionHandlerVM(typeSigCreatorOptions, new ExceptionHandlerOptions()));
            this.LocalsListVM.UpdateIndexesDelegate = LocalsUpdateIndexes;
            this.InstructionsListVM.UpdateIndexesDelegate = InstructionsUpdateIndexes;
            this.ExceptionHandlersListVM.UpdateIndexesDelegate = ExceptionHandlersUpdateIndexes;
            this.InstructionsListVM.CollectionChanged += InstructionsListVM_CollectionChanged;
            this.LocalsListVM.CollectionChanged += LocalsListVM_CollectionChanged;
            this.ExceptionHandlersListVM.CollectionChanged += ExceptionHandlersListVM_CollectionChanged;
            this.maxStack = new UInt16VM(a => CallHasErrorUpdated());
            this.localVarSigTok = new UInt32VM(a => CallHasErrorUpdated());
            this.headerSize = new ByteVM(a => CallHasErrorUpdated());
            this.headerRVA = new UInt32VM(a => CallHasErrorUpdated());
            this.headerFileOffset = new UInt64VM(a => CallHasErrorUpdated());
            this.rva = new UInt32VM(a => CallHasErrorUpdated());
            this.fileOffset = new UInt64VM(a => CallHasErrorUpdated());

            Reinitialize();
        }
Ejemplo n.º 25
0
 public UInt32HexField(UInt32Data data, string fieldName, bool useDecimal = false)
     : base(data, fieldName)
 {
     this.data = new UInt32VM(buffer.ReadUInt32(Span.Start), a => UpdateValue(), useDecimal);
 }
Ejemplo n.º 26
0
 public UInt32FlagsHexField(HexBuffer buffer, string parentName, string name, HexPosition start)
     : base(buffer, parentName, name, start, 4)
 {
     data = new UInt32VM(buffer.ReadUInt32(start), a => UpdateValue(), false);
 }
Ejemplo n.º 27
0
 public UInt32FlagsHexField(StructField <UInt32FlagsData> field)
     : base(field)
 {
     data = new UInt32VM(buffer.ReadUInt32(Span.Start), a => UpdateValue(), false);
 }
Ejemplo n.º 28
0
		public UInt32HexField(HexBuffer buffer, string parentName, string name, HexPosition start, bool useDecimal = false)
			: base(buffer, parentName, name, start, 4) {
			data = new UInt32VM(buffer.ReadUInt32(start), a => UpdateValue(), useDecimal);
		}
Ejemplo n.º 29
0
		public FieldOptionsVM(FieldDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType) {
			this.ownerModule = ownerModule;
			var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService) {
				IsLocal = false,
				CanAddGenericTypeVar = true,
				CanAddGenericMethodVar = false,
				OwnerType = ownerType,
			};
			if (ownerType != null && ownerType.GenericParameters.Count == 0)
				typeSigCreatorOptions.CanAddGenericTypeVar = false;
			TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
			TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

			CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService);
			origOptions = options;

			ConstantVM = new ConstantVM(ownerModule, options.Constant?.Value, dnSpy_AsmEditor_Resources.Field_DefaultValueInfo);
			ConstantVM.PropertyChanged += constantVM_PropertyChanged;
			MarshalTypeVM = new MarshalTypeVM(ownerModule, decompilerService, ownerType, null);
			MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged;
			FieldOffset = new NullableUInt32VM(a => HasErrorUpdated());
			InitialValue = new HexStringVM(a => HasErrorUpdated());
			RVA = new UInt32VM(a => HasErrorUpdated());
			ImplMapVM = new ImplMapVM(ownerModule);
			ImplMapVM.PropertyChanged += implMapVM_PropertyChanged;

			TypeSigCreator.CanAddFnPtr = false;
			ConstantVM.IsEnabled = HasDefault;
			MarshalTypeVM.IsEnabled = HasFieldMarshal;
			ImplMapVM.IsEnabled = PinvokeImpl;
			Reinitialize();
		}
Ejemplo n.º 30
0
 public ModuleOptionsVM(ModuleDef module, ModuleOptions options, Language language)
 {
     this.module = module;
     this.options = new ModuleOptions();
     this.origOptions = options;
     moduleKindVM = new EnumListVM(SaveModule.SaveModuleOptionsVM.moduleKindList, (a, b) => {
         Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
     });
     this.machineVM = new EnumListVM(SaveModule.PEHeadersOptionsVM.machineList, (a, b) => {
         Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.PE.Machine)Machine.SelectedItem);
     });
     mvid = new NullableGuidVM(a => HasErrorUpdated());
     encId = new NullableGuidVM(a => HasErrorUpdated());
     encBaseId = new NullableGuidVM(a => HasErrorUpdated());
     clrVersionVM = new EnumListVM(NetModuleOptionsVM.clrVersionList, (a, b) => OnClrVersionChanged());
     clrVersionVM.Items.Add(new EnumVM(Module.ClrVersion.Unknown, "Unknown"));
     clrVersionVM.SelectedItem = Module.ClrVersion.Unknown;
     cor20HeaderRuntimeVersion = new NullableUInt32VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
     tablesHeaderVersion = new NullableUInt16VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
     nativeEntryPointRva = new UInt32VM(a => HasErrorUpdated());
     customAttributesVM = new CustomAttributesVM(module, language);
     Reinitialize();
 }
Ejemplo n.º 31
0
		public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize) {
			origOptions = options;
			this.canDeserialize = canDeserialize;

			BooleanVM = new BooleanVM(a => HasErrorUpdated());
			CharVM = new CharVM(a => HasErrorUpdated());
			ByteVM = new ByteVM(a => HasErrorUpdated());
			SByteVM = new SByteVM(a => HasErrorUpdated());
			Int16VM = new Int16VM(a => HasErrorUpdated());
			UInt16VM = new UInt16VM(a => HasErrorUpdated());
			Int32VM = new Int32VM(a => HasErrorUpdated());
			UInt32VM = new UInt32VM(a => HasErrorUpdated());
			Int64VM = new Int64VM(a => HasErrorUpdated());
			UInt64VM = new UInt64VM(a => HasErrorUpdated());
			SingleVM = new SingleVM(a => HasErrorUpdated());
			DoubleVM = new DoubleVM(a => HasErrorUpdated());
			DecimalVM = new DecimalVM(a => HasErrorUpdated());
			DateTimeVM = new DateTimeVM(a => HasErrorUpdated());
			TimeSpanVM = new TimeSpanVM(a => HasErrorUpdated());
			UserTypeVM = new UserTypeVM(ownerModule, canDeserialize);
			ResourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged());

			UserTypeVM.PropertyChanged += (s, e) => {
				if (e.PropertyName == nameof(UserTypeVM.HasError))
					HasErrorUpdated();
			};

			Reinitialize();
		}
Ejemplo n.º 32
0
        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();
        }
Ejemplo n.º 33
0
 public UInt32HexField(HexDocument doc, string parentName, string name, ulong start, bool useDecimal = false)
     : base(doc, parentName, name, start, 4)
 {
     this.data = new UInt32VM(doc.ReadUInt32(start), a => UpdateValue(), useDecimal);
 }
Ejemplo n.º 34
0
 public UInt32FlagsHexField(HexDocument doc, string parentName, string name, ulong start)
     : base(doc, parentName, name, start, 4)
 {
     this.data = new UInt32VM(doc.ReadUInt32(start), a => UpdateValue(), false);
 }
Ejemplo n.º 35
0
		public ConstantTypeVM(ModuleDef ownerModule, object value, ConstantType[] validConstants, bool allowNullString, bool arraysCanBeNull, TypeSigCreatorOptions options = null) {
			if (options == null) {
				IList<ConstantType> clist = validConstants;
				if (clist.IndexOf(ConstantType.Type) >= 0 ||
					clist.IndexOf(ConstantType.TypeArray) >= 0 ||
					clist.IndexOf(ConstantType.ObjectArray) >= 0) {
					throw new ArgumentNullException();
				}
			}
			this.arraysCanBeNull = arraysCanBeNull;
			var list = validConstants.Select(a => typeToEnumVM[a]);
			this.constantTypeEnumListVM = new EnumListVM(list, (a, b) => OnConstantChanged());
			this.boolean = new BooleanVM(a => FieldUpdated());
			this.@char = new CharVM(a => FieldUpdated());
			this.@sbyte = new SByteVM(a => FieldUpdated());
			this.@byte = new ByteVM(a => FieldUpdated());
			this.int16 = new Int16VM(a => FieldUpdated());
			this.uint16 = new UInt16VM(a => FieldUpdated());
			this.int32 = new Int32VM(a => FieldUpdated());
			this.uint32 = new UInt32VM(a => FieldUpdated());
			this.int64 = new Int64VM(a => FieldUpdated());
			this.uint64 = new UInt64VM(a => FieldUpdated());
			this.single = new SingleVM(a => FieldUpdated());
			this.@double = new DoubleVM(a => FieldUpdated());
			this.@string = new StringVM(a => FieldUpdated(), allowNullString);
			this.@enum = new EnumDataFieldVM(ownerModule, a => FieldUpdated());
			this.type = new TypeSigVM(a => FieldUpdated(), options);
			this.objectArray = new ObjectListDataFieldVM(ownerModule, a => FieldUpdated(), options);
			this.booleanArray = new BooleanListDataFieldVM(a => FieldUpdated());
			this.charArray = new CharListDataFieldVM(a => FieldUpdated());
			this.sbyteArray = new SByteListDataFieldVM(a => FieldUpdated());
			this.byteArray = new ByteListDataFieldVM(a => FieldUpdated());
			this.int16Array = new Int16ListDataFieldVM(a => FieldUpdated());
			this.uint16Array = new UInt16ListDataFieldVM(a => FieldUpdated());
			this.int32Array = new Int32ListDataFieldVM(a => FieldUpdated());
			this.uint32Array = new UInt32ListDataFieldVM(a => FieldUpdated());
			this.int64Array = new Int64ListDataFieldVM(a => FieldUpdated());
			this.uint64Array = new UInt64ListDataFieldVM(a => FieldUpdated());
			this.singleArray = new SingleListDataFieldVM(a => FieldUpdated());
			this.doubleArray = new DoubleListDataFieldVM(a => FieldUpdated());
			this.stringArray = new StringListDataFieldVM(a => FieldUpdated());
			this.enumArray = new EnumListDataFieldVM(ownerModule, a => FieldUpdated());
			this.typeArray = new TypeSigListDataFieldVM(a => FieldUpdated(), options);
			this.Value = value;
		}
Ejemplo n.º 36
0
 public UInt32HexField(StructField <FileOffsetData> field, bool useDecimal = false)
     : base(field)
 {
     data = new UInt32VM(buffer.ReadUInt32(Span.Start), a => UpdateValue(), useDecimal);
 }