コード例 #1
0
        private void B_ReadRAM_Click(object sender, EventArgs e)
        {
            var txt    = RamOffset.Text;
            var offset = Util.GetHexValue(txt);
            var valid  = int.TryParse(RamSize.Text, out int size);

            if (offset.ToString("X8") != txt.ToUpper().PadLeft(8, '0') || !valid)
            {
                WinFormsUtil.Alert("Make sure that the RAM offset is a hex string and the size is a valid integer");
                return;
            }

            try
            {
                var result = Remote.ReadRAM(offset, size);
                using (var form = new SimpleHexEditor(result))
                {
                    var res = form.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        var modifiedRAM = form.Bytes;
                        Remote.WriteRAM(offset, modifiedRAM);
                    }
                }
                Debug.WriteLine("RAM Modified");
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception ex)
            {
                WinFormsUtil.Error("Unable to load data from the specified offset.", ex.Message);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }
コード例 #2
0
        private void B_EditPointerData_Click(object sender, EventArgs e)
        {
            if (Remote.Bot.com is not SysBotMini sb)
            {
                return;
            }

            ulong address = GetPointerAddress(sb);

            if (address == 0)
            {
                WinFormsUtil.Alert("No pointer address.");
            }

            var valid = int.TryParse(RamSize.Text, out int size);

            if (!valid)
            {
                WinFormsUtil.Alert("Make sure that the size is a valid integer");
                return;
            }

            try
            {
                var result = sb.ReadBytesAbsolute(address, size);
                using (var form = new SimpleHexEditor(result))
                {
                    var res = form.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        var modifiedRAM = form.Bytes;
                        sb.WriteBytesAbsolute(modifiedRAM, address);
                    }
                }
                Debug.WriteLine("RAM Modified");
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception ex)
            {
                WinFormsUtil.Error("Unable to load data from the specified offset.", ex.Message);
            }
        }
コード例 #3
0
        private void B_ReadRAM_Click(object sender, EventArgs e)
        {
            var txt    = RamOffset.Text;
            var offset = Util.GetHexValue64(txt);
            var valid  = int.TryParse(RamSize.Text, out int size);

            if (offset.ToString("X16") != txt.ToUpper().PadLeft(16, '0') || !valid)
            {
                WinFormsUtil.Alert("Make sure that the RAM offset is a hex string and the size is a valid integer");
                return;
            }

            try
            {
                byte[] result;
                if (Remote.Bot.com is not ICommunicatorNX cnx)
                {
                    result = Remote.ReadRAM(offset, size);
                }
                else if (RB_Main.Checked)
                {
                    result = cnx.ReadBytesMain(offset, size);
                }
                else if (RB_Absolute.Checked)
                {
                    result = cnx.ReadBytesAbsolute(offset, size);
                }
                else
                {
                    result = Remote.ReadRAM(offset, size);
                }

                bool blockview = (ModifierKeys & Keys.Control) == Keys.Control;
                PKM? pkm       = null;
                if (blockview)
                {
                    pkm = SAV.SAV.GetDecryptedPKM(result);
                    if (!pkm.ChecksumValid)
                    {
                        blockview = false;
                    }
                }

                using var form = new SimpleHexEditor(result, Remote.Bot, offset, GetRWMethod());
                var loadgrid = blockview && ReflectUtil.GetPropertiesCanWritePublicDeclared(pkm !.GetType()).Count() > 1;
                if (loadgrid)
                {
                    form.PG_BlockView.Visible        = true;
                    form.PG_BlockView.SelectedObject = pkm;
                }
                var res = form.ShowDialog();
                if (res != DialogResult.OK)
                {
                    return;
                }

                if (loadgrid)
                {
                    PKM pk       = pkm !;
                    var pkmbytes = RamOffsets.WriteBoxData(Remote.Bot.Version) ? pk.EncryptedBoxData : pk.EncryptedPartyData;
                    if (pkmbytes.Length == Remote.Bot.SlotSize)
                    {
                        form.Bytes = pkmbytes;
                    }
                    else
                    {
                        form.Bytes = result;
                        WinFormsUtil.Error("Size mismatch. Please report this issue on the discord server.");
                    }
                }

                var modifiedRAM = form.Bytes;
                if (Remote.Bot.com is not ICommunicatorNX nx)
                {
                    Remote.WriteRAM(offset, modifiedRAM);
                }