Exemple #1
0
        public MethodBodyVM(MethodBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions = options;

            this.nativeMethodBodyVM = new MethodBody.NativeMethodBodyVM(options.NativeMethodBodyOptions);
            NativeMethodBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            this.cilBodyVM = new MethodBody.CilBodyVM(options.CilBodyOptions, ownerModule, language, ownerType, ownerMethod);
            CilBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            this.methodBodyTypeVM = new EnumListVM(methodBodyTypeList, (a, b) => OnMethodBodyTypeChanged());

            Reinitialize();
        }
Exemple #2
0
        public MethodBodyVM(MethodBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions = options;

            this.nativeMethodBodyVM             = new MethodBody.NativeMethodBodyVM(options.NativeMethodBodyOptions);
            NativeMethodBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            this.cilBodyVM             = new MethodBody.CilBodyVM(options.CilBodyOptions, ownerModule, language, ownerType, ownerMethod);
            CilBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            this.methodBodyTypeVM      = new EnumListVM(methodBodyTypeList, (a, b) => OnMethodBodyTypeChanged());

            Reinitialize();
        }
Exemple #3
0
        protected override void OnDataContextChangedInternal(object dataContext)
        {
            this.cilBodyVM             = ((MethodBodyVM)dataContext).CilBodyVM;
            this.cilBodyVM.SelectItems = this;
            this.coll = cilBodyVM.InstructionsListVM;
            this.coll.CollectionChanged += coll_CollectionChanged;
            InitializeInstructions(this.coll);

            Add(new ContextMenuHandler {
                Header           = "_NOP Instruction",
                HeaderPlural     = "_NOP Instructions",
                Command          = cilBodyVM.ReplaceInstructionWithNopCommand,
                Icon             = "NOP",
                InputGestureText = "N",
                Modifiers        = ModifierKeys.None,
                Key = Key.N,
            });
            Add(new ContextMenuHandler {
                Header           = "_Invert Branch",
                HeaderPlural     = "_Invert Branches",
                Command          = cilBodyVM.InvertBranchCommand,
                Icon             = "Branch",
                InputGestureText = "I",
                Modifiers        = ModifierKeys.None,
                Key = Key.I,
            });
            Add(new ContextMenuHandler {
                Header           = "Convert to Unconditional _Branch",
                HeaderPlural     = "Convert to Unconditional _Branches",
                Command          = cilBodyVM.ConvertBranchToUnconditionalBranchCommand,
                Icon             = "ToUncondBranch",
                InputGestureText = "B",
                Modifiers        = ModifierKeys.None,
                Key = Key.B,
            });
            Add(new ContextMenuHandler {
                Header           = "R_emove and Add Pops",
                Command          = cilBodyVM.RemoveInstructionAndAddPopsCommand,
                InputGestureText = "P",
                Modifiers        = ModifierKeys.None,
                Key = Key.P,
            });
            AddSeparator();
            Add(new ContextMenuHandler {
                Header           = "_Simplify All Instructions",
                Command          = cilBodyVM.SimplifyAllInstructionsCommand,
                InputGestureText = "S",
                Modifiers        = ModifierKeys.None,
                Key = Key.S,
            });
            Add(new ContextMenuHandler {
                Header           = "Optimi_ze All Instructions",
                Command          = cilBodyVM.OptimizeAllInstructionsCommand,
                InputGestureText = "O",
                Modifiers        = ModifierKeys.None,
                Key = Key.O,
            });
            AddSeparator();
            AddStandardMenuHandlers();
            Add(new ContextMenuHandler {
                Header           = "Copy _MD Token",
                HeaderPlural     = "Copy _MD Tokens",
                Command          = new RelayCommand(a => CopyOperandMDTokens((InstructionVM[])a), a => CopyOperandMDTokensCanExecute((InstructionVM[])a)),
                InputGestureText = "Ctrl+M",
                Modifiers        = ModifierKeys.Control,
                Key = Key.M,
            });
            Add(new ContextMenuHandler {
                Header           = "C_opy RVA",
                HeaderPlural     = "C_opy RVAs",
                Command          = new RelayCommand(a => CopyInstructionRVA((InstructionVM[])a), a => CopyInstructionRVACanExecute((InstructionVM[])a)),
                InputGestureText = "Ctrl+R",
                Modifiers        = ModifierKeys.Control,
                Key = Key.R,
            });
            Add(new ContextMenuHandler {
                Header           = "Copy File Offset",
                HeaderPlural     = "Copy File Offsets",
                Command          = new RelayCommand(a => CopyInstructionFileOffset((InstructionVM[])a), a => CopyInstructionFileOffsetCanExecute((InstructionVM[])a)),
                InputGestureText = "Ctrl+F",
                Modifiers        = ModifierKeys.Control,
                Key = Key.F,
            });
        }