Exemple #1
0
 public ModifyForm(Modify hook, MethodDefinition method, Modify.InstructionData inst) : this(hook, method)
 {
     Instruction = inst;
     InsertBeforeButton.Visible = false;
     InsertAfterButton.Visible  = false;
     SaveButton.Visible         = true;
 }
Exemple #2
0
 private void InsertAfterButton_Click(object sender, EventArgs e)
 {
     Instruction = new Modify.InstructionData();
     if (!UpdateInstruction())
     {
         return;
     }
     Index        = 1;
     DialogResult = DialogResult.OK;
 }
Exemple #3
0
        public ModifyForm(Field field, string type) : this(hook : null, method : null)
        {
            Instruction = new Modify.InstructionData {
                Operand = type, OpType = Modify.OpType.Type
            };

            opcodelabel.Visible = false;
            opcodes.Visible     = false;

            optypes.Items.Clear();
            optypes.Items.Add(Modify.OpType.Type);

            tablepanel.RowStyles[0].Height = 0;

            InsertBeforeButton.Visible = false;
            InsertAfterButton.Visible  = false;
            SaveButton.Visible         = true;
        }
        private void EditToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Modify.InstructionData inst = (Modify.InstructionData)illist.SelectedItem;
            if (inst == null)
            {
                return;
            }

            using (ModifyForm form = new ModifyForm((Modify)Hook, method, inst))
            {
                if (form.ShowDialog(PatcherForm.MainForm) != DialogResult.OK)
                {
                    return;
                }
                ((BindingSource)illist.DataSource).ResetBindings(false);
                NotifyChanges();
            }
        }
Exemple #5
0
        private void optypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            Control control = null;

            Modify.OpType optype = (Modify.OpType)optypes.SelectedItem;
            switch (optype)
            {
            case Modify.OpType.None:
                break;

            case Modify.OpType.Byte:
            case Modify.OpType.SByte:
            case Modify.OpType.Int32:
            case Modify.OpType.Int64:
            case Modify.OpType.Single:
            case Modify.OpType.Double:
            case Modify.OpType.String:
            case Modify.OpType.VerbatimString:
            case Modify.OpType.Field:
            case Modify.OpType.Method:
            case Modify.OpType.Generic:
            case Modify.OpType.Type:
                textBox.Text = Instruction?.Operand?.ToString() ?? string.Empty;
                control      = textBox;
                break;

            case Modify.OpType.Instruction:
                List <ListData>     instructions   = new List <ListData>();
                IList <Instruction> instructionset = method.Body.Instructions;
                if (hook.BaseHook != null)
                {
                    MethodDefinition methoddef = PatcherForm.MainForm.GetMethod(hook.AssemblyName, hook.TypeName, hook.Signature);
                    ILWeaver         weaver    = new ILWeaver(methoddef.Body)
                    {
                        Module = methoddef.Module
                    };
                    hook.BaseHook.ApplyPatch(methoddef, weaver, PatcherForm.MainForm.OxideAssembly);
                    instructionset = weaver.Instructions;
                }
                for (int i = 0; i < instructionset.Count; i++)
                {
                    Instruction instruction = instructionset[i];
                    instructions.Add(new ListData {
                        Text = $"({i}) {instruction.OpCode} {instruction.Operand}", Value = i
                    });
                }
                for (int i = 0; i < hook.Instructions.Count; i++)
                {
                    Modify.InstructionData instructionData = hook.Instructions[i];
                    instructions.Add(new ListData {
                        Text = $"({i + 1024}) {instructionData.OpCode} {instructionData.Operand}", Value = i + 1024
                    });
                }
                comboBox.DataSource = instructions;
                control             = comboBox;
                break;

            case Modify.OpType.Variable:
                List <ListData> variables = new List <ListData>();
                foreach (VariableDefinition variable in method.Body.Variables)
                {
                    variables.Add(new ListData {
                        Text = $"({variable.Index}) ({variable.VariableType.FullName})", Value = variable.Index
                    });
                }

                comboBox.DataSource = variables;
                control             = comboBox;
                break;

            case Modify.OpType.Parameter:
                List <ListData> parameters = new List <ListData>();
                foreach (ParameterDefinition parameter in method.Parameters)
                {
                    parameters.Add(new ListData {
                        Text = $"({parameter.Index}) {parameter.Name} ({parameter.ParameterType.FullName})", Value = parameter.Index
                    });
                }

                comboBox.DataSource = parameters;
                control             = comboBox;
                break;
            }
            Control current = tablepanel.GetControlFromPosition(1, 2);

            if (current != control)
            {
                if (current != null)
                {
                    tablepanel.Controls.Remove(current);
                }

                if (control != null)
                {
                    tablepanel.Controls.Add(control, 1, 2);
                }

                operandlabel.Visible = control != null;
            }
            if (control is ComboBox && Instruction?.Operand != null)
            {
                comboBox.SelectedItem = ((List <ListData>)comboBox.DataSource).FirstOrDefault(i => Convert.ToInt32(i.Value) == Convert.ToInt32(Instruction.Operand));
            }
        }