Ejemplo n.º 1
0
        void InitializeFrom(ModuleOptions options)
        {
            Mvid.Value                      = options.Mvid;
            EncId.Value                     = options.EncId;
            EncBaseId.Value                 = options.EncBaseId;
            Name                            = options.Name;
            ModuleKind.SelectedItem         = options.Kind;
            DllCharacteristics              = options.DllCharacteristics;
            RuntimeVersion                  = options.RuntimeVersion;
            Machine.SelectedItem            = options.Machine;
            Cor20HeaderFlags                = options.Cor20HeaderFlags;
            Cor20HeaderRuntimeVersion.Value = options.Cor20HeaderRuntimeVersion;
            TablesHeaderVersion.Value       = options.TablesHeaderVersion;

            ManagedEntryPoint         = options.ManagedEntryPoint;
            NativeEntryPointRva.Value = (uint)options.NativeEntryPoint;
            if (options.ManagedEntryPoint != null)
            {
                EntryPointEnum = EntryPointType.Managed;
            }
            else if (options.NativeEntryPoint != 0)
            {
                EntryPointEnum = EntryPointType.Native;
            }
            else
            {
                EntryPointEnum = EntryPointType.None;
            }

            // Writing to Machine and ModuleKind triggers code that updates Characteristics so write
            // this property last.
            Characteristics = options.Characteristics;

            CustomAttributesVM.InitializeFrom(options.CustomAttributes);
        }
Ejemplo n.º 2
0
        ModuleOptions CopyTo(ModuleOptions options)
        {
            options.Mvid                      = Mvid.Value;
            options.EncId                     = EncId.Value;
            options.EncBaseId                 = EncBaseId.Value;
            options.Name                      = Name;
            options.Kind                      = (ModuleKind)ModuleKind.SelectedItem;
            options.Characteristics           = Characteristics;
            options.DllCharacteristics        = DllCharacteristics;
            options.RuntimeVersion            = RuntimeVersion;
            options.Machine                   = (dnlib.PE.Machine)Machine.SelectedItem;
            options.Cor20HeaderFlags          = Cor20HeaderFlags;
            options.Cor20HeaderRuntimeVersion = Cor20HeaderRuntimeVersion.Value;
            options.TablesHeaderVersion       = TablesHeaderVersion.Value;

            if (EntryPointEnum == EntryPointType.None)
            {
                options.ManagedEntryPoint = null;
                options.NativeEntryPoint  = 0;
            }
            else if (EntryPointEnum == EntryPointType.Managed)
            {
                options.ManagedEntryPoint = ManagedEntryPoint;
                options.NativeEntryPoint  = 0;
            }
            else if (EntryPointEnum == EntryPointType.Native)
            {
                options.ManagedEntryPoint = null;
                options.NativeEntryPoint  = (RVA)NativeEntryPointRva.Value;
            }
            else
            {
                throw new InvalidOperationException();
            }

            options.CustomAttributes.Clear();
            options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create()));

            return(options);
        }
Ejemplo n.º 3
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.º 4
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.º 5
0
        void InitializeFrom(ModuleOptions options)
        {
            Mvid.Value = options.Mvid;
            EncId.Value = options.EncId;
            EncBaseId.Value = options.EncBaseId;
            Name = options.Name;
            ModuleKind.SelectedItem = options.Kind;
            DllCharacteristics = options.DllCharacteristics;
            RuntimeVersion = options.RuntimeVersion;
            Machine.SelectedItem = options.Machine;
            Cor20HeaderFlags = options.Cor20HeaderFlags;
            Cor20HeaderRuntimeVersion.Value = options.Cor20HeaderRuntimeVersion;
            TablesHeaderVersion.Value = options.TablesHeaderVersion;

            ManagedEntryPoint = options.ManagedEntryPoint;
            NativeEntryPointRva.Value = (uint)options.NativeEntryPoint;
            if (options.ManagedEntryPoint != null)
                EntryPointEnum = EntryPointType.Managed;
            else if (options.NativeEntryPoint != 0)
                EntryPointEnum = EntryPointType.Native;
            else
                EntryPointEnum = EntryPointType.None;

            // Writing to Machine and ModuleKind triggers code that updates Characteristics so write
            // this property last.
            Characteristics = options.Characteristics;

            CustomAttributesVM.InitializeFrom(options.CustomAttributes);
        }
Ejemplo n.º 6
0
        ModuleOptions CopyTo(ModuleOptions options)
        {
            options.Mvid = Mvid.Value;
            options.EncId = EncId.Value;
            options.EncBaseId = EncBaseId.Value;
            options.Name = Name;
            options.Kind = (ModuleKind)ModuleKind.SelectedItem;
            options.Characteristics = Characteristics;
            options.DllCharacteristics = DllCharacteristics;
            options.RuntimeVersion = RuntimeVersion;
            options.Machine = (dnlib.PE.Machine)Machine.SelectedItem;
            options.Cor20HeaderFlags = Cor20HeaderFlags;
            options.Cor20HeaderRuntimeVersion = Cor20HeaderRuntimeVersion.Value;
            options.TablesHeaderVersion = TablesHeaderVersion.Value;

            if (EntryPointEnum == EntryPointType.None) {
                options.ManagedEntryPoint = null;
                options.NativeEntryPoint = 0;
            }
            else if (EntryPointEnum == EntryPointType.Managed) {
                options.ManagedEntryPoint = ManagedEntryPoint;
                options.NativeEntryPoint = 0;
            }
            else if (EntryPointEnum == EntryPointType.Native) {
                options.ManagedEntryPoint = null;
                options.NativeEntryPoint = (RVA)NativeEntryPointRva.Value;
            }
            else
                throw new InvalidOperationException();

            options.CustomAttributes.Clear();
            options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create()));

            return options;
        }
Ejemplo n.º 7
0
 void WriteModuleOptions(ModuleOptions theOptions)
 {
     theOptions.CopyTo(modNode.LoadedAssembly.ModuleDefinition);
     modNode.RaiseUIPropsChanged();
 }
Ejemplo n.º 8
0
 ModuleSettingsCommand(AssemblyTreeNode modNode, ModuleOptions newOptions)
 {
     this.modNode     = modNode;
     this.newOptions  = newOptions;
     this.origOptions = new ModuleOptions(modNode.LoadedAssembly.ModuleDefinition);
 }