コード例 #1
0
        private void Apply(DebuggerProcess OwningProcess, Patch PatchItem)
        {
            int Size = PatchTypeLength(PatchItem.DisplayAs);

            // Repatch
            if (PatchItem.Original?.Length == Size && PatchItem.Patched?.Length == Size)
            {
                OwningProcess.WriteMemoryBlock(new IntPtr(PatchItem.Offset), PatchItem.Patched);
            }
        }
コード例 #2
0
        private void btnRevert_Click(object sender, EventArgs e)
        {
            if (lvCEMemory.SelectedIndices.Count != 1)
            {
                return;
            }

            string Value = txNewValue.Text;

            if (Value.Length != 0)
            {
                Patch DataPatch = patchMan.DataPatches.ElementAt(lvCEMemory.SelectedIndices[0]);

                IntPtr PatchAddr = new IntPtr(DataPatch.Offset);
                if (MainProcess.WriteMemoryBlock(PatchAddr, DataPatch.Original))
                {
                    UpdatePatches();
                }
            }
        }
コード例 #3
0
        public bool Write(DebuggerProcess OwningProcess, Patch PatchItem, string NewValue)
        {
            IntPtr PatchAddr = new IntPtr(PatchItem.Offset);

            switch (PatchItem.DisplayAs)
            {
            case PatchType.Byte:
            {
                byte Value = 0;
                if (Common.ReadByte(NewValue, ref Value))
                {
                    OwningProcess.WriteMemory(PatchAddr, Value);
                    return(true);
                }
                break;
            }

            case PatchType.Short:
            {
                short Value;
                if (short.TryParse(NewValue, out Value))
                {
                    OwningProcess.WriteMemory(PatchAddr, Value);
                    return(true);
                }
                break;
            }

            case PatchType.UShort:
            {
                ushort Value;
                if (ushort.TryParse(NewValue, out Value))
                {
                    OwningProcess.WriteMemory(PatchAddr, Value);
                    return(true);
                }
                break;
            }

            case PatchType.Int:
            {
                int Value;
                if (int.TryParse(NewValue, out Value))
                {
                    OwningProcess.WriteMemory(PatchAddr, Value);
                    return(true);
                }
                break;
            }

            case PatchType.UInt:
            {
                uint Value;
                if (uint.TryParse(NewValue, out Value))
                {
                    OwningProcess.WriteMemory(PatchAddr, Value);
                    return(true);
                }
                break;
            }

            case PatchType.Float:
            {
                float Value;
                if (float.TryParse(NewValue, out Value))
                {
                    OwningProcess.WriteMemory(PatchAddr, Value);
                    return(true);
                }
                break;
            }

            case PatchType.Array:
            {
                List <byte> ParsedBytes = new List <byte>();

                string[] Items = NewValue.Split(new char[] { ' ' });
                foreach (string Item in Items)
                {
                    byte Value = 0;
                    if (Common.ReadByte(Item, ref Value))
                    {
                        ParsedBytes.Add(Value);
                    }
                }
                if (ParsedBytes.Count == PatchItem.Patched.Length)
                {
                    OwningProcess.WriteMemoryBlock(PatchAddr, ParsedBytes.ToArray());
                    return(true);
                }

                break;
            }
            }

            return(false);
        }