示例#1
0
        private static void GenSmogonSets(PKM rough)
        {
            SmogonSetList info;

            try
            {
                info = new SmogonSetList(rough);
            }
            catch (Exception ex)
            {
                WinFormsUtil.Error($"An error occured while trying to obtain the contents of the URL. This is most likely an issue with your Internet Connection. The exact error is as follows: {ex}");
                return;
            }

            if (!info.Valid || info.Sets.Count == 0)
            {
                WinFormsUtil.Error("No movesets available. Perhaps you could help out? Check the Contributions & Corrections forum.\n\nForum: https://www.smogon.com/forums/forums/contributions-corrections.388/");
                return;
            }

            ShowdownSetLoader.Import(info.Sets);
            WinFormsUtil.Alert(info.Summary);
        }
示例#2
0
        private void B_ReadOffset_Click(object sender, EventArgs e)
        {
            var txt    = TB_Offset.Text;
            var offset = Util.GetHexValue(txt);

            if (offset.ToString("X8") != txt.ToUpper().PadLeft(8, '0'))
            {
                WinFormsUtil.Alert("Specified offset is not a valid hex string.");
                return;
            }
            try
            {
                var result = Remote.ReadOffset(offset);
                if (!result)
                {
                    WinFormsUtil.Alert("No valid data is located at the specified offset.");
                }
            }
            catch (Exception ex)
            {
                WinFormsUtil.Error("Unable to load data from the specified offset.", ex.Message);
            }
        }
示例#3
0
        private void B_ReadPointer_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 size = Remote.Bot.SlotSize;
            var data = sb.ReadBytesAbsolute(address, size);
            var pkm  = SAV.SAV.GetDecryptedPKM(data);

            // Since data might not actually exist at the user-specified offset, double check that the pkm data is valid.
            if (pkm.ChecksumValid)
            {
                Remote.Editor.PopulateFields(pkm);
            }
        }
示例#4
0
        public ulong GetPointerAddress(SysBotMini sb)
        {
            var  ptr    = TB_Pointer.Text;
            uint finadd = 0;

            if (!ptr.EndsWith("]"))
            {
                finadd = Util.GetHexValue(ptr.Split('+').Last());
            }
            var jumps = ptr.Replace("main", "").Replace("[", "").Replace("]", "").Split(new[] { "+" }, StringSplitOptions.RemoveEmptyEntries);

            if (jumps.Length == 0)
            {
                WinFormsUtil.Alert("Invalid Pointer");
                return(0);
            }

            var   initaddress = Util.GetHexValue(jumps[0].Trim());
            ulong address     = BitConverter.ToUInt64(sb.ReadBytesMain(initaddress, 0x8), 0);

            foreach (var j in jumps)
            {
                var val = Util.GetHexValue(j.Trim());
                if (val == initaddress)
                {
                    continue;
                }
                if (val == finadd)
                {
                    address += val;
                    break;
                }
                address = BitConverter.ToUInt64(sb.ReadBytesAbsolute(address + val, 0x8), 0);
            }
            return(address);
        }
示例#5
0
        private void LegalizeActive()
        {
            var pk = PKMEditor.PreparePKM();
            var la = new LegalityAnalysis(pk);

            if (la.Valid)
            {
                return; // already valid, don't modify it
            }
            var sav    = SaveFileEditor.SAV;
            var result = sav.Legalize(pk);

            // let's double check

            la = new LegalityAnalysis(result);
            if (!la.Valid)
            {
                WinFormsUtil.Error("Unable to make the Active Pokemon legal!");
                return;
            }

            PKMEditor.PopulateFields(result);
            WinFormsUtil.Alert("Legalized Active Pokemon!");
        }
示例#6
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);
                }