Exemple #1
0
        public bool ParseCheatTuple(string cheatTuple, ProcessManager processManager, ref Cheat cheat)
        {
            string[] cheatElements = cheatTuple.Split(new string[] { "|" }, StringSplitOptions.None);

            if (cheatElements.Length == 0)
            {
                return(false);
            }

            if (cheatElements[CHEAT_CODE_TYPE] == "data")
            {
                cheat = new DataCheat(processManager);
            }
            else if (cheatElements[CHEAT_CODE_TYPE] == "simple pointer")
            {
                cheat = new SimplePointerCheat(processManager);
            }
            else
            {
                return(false);
            }
            if (!cheat.Parse(cheatElements))
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public void new_pointer_cheat(ulong address, List <long> offset_list, string type, string data, bool lock_, string description)
        {
            try
            {
                int sectionID = processManager.MappedSectionList.GetMappedSectionID(address);

                if (sectionID == -1)
                {
                    MessageBox.Show("Address is out of range!");
                    return;
                }

                if (cheatList.Exist(address))
                {
                    return;
                }

                ValueType valueType = MemoryHelper.GetValueTypeByString(type);

                DataCheatOperator          sourceOperator       = new DataCheatOperator(data, valueType, processManager);
                AddressCheatOperator       addressCheatOperator = new AddressCheatOperator(address, processManager);
                List <OffsetCheatOperator> offsetOperators      = new List <OffsetCheatOperator>();

                for (int i = 0; i < offset_list.Count; ++i)
                {
                    OffsetCheatOperator offsetOperator = new OffsetCheatOperator(offset_list[i],
                                                                                 ValueType.ULONG_TYPE, processManager);
                    offsetOperators.Add(offsetOperator);
                }

                SimplePointerCheatOperator destOperator = new SimplePointerCheatOperator(addressCheatOperator, offsetOperators, valueType, processManager);

                SimplePointerCheat simplePointerCheat = new SimplePointerCheat(sourceOperator, destOperator,
                                                                               lock_, description, processManager);

                add_new_row_to_cheat_list_view(simplePointerCheat);
                cheatList.Add(simplePointerCheat);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, exception.Source, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
Exemple #3
0
        public bool LoadFile(string path, ProcessManager processManager, ComboBox comboBox)
        {
            string[] cheats = File.ReadAllLines(path);

            if (cheats.Length < 2)
            {
                return(false);
            }

            string header = cheats[0];

            string[] header_items = header.Split('|');

            if (header_items.Length < CHEAT_CODE_HEADER_ELEMENT_COUNT)
            {
                return(false);
            }

            string[] version = (header_items[CHEAT_CODE_HEADER_VERSION]).Split('.');

            ulong major_version     = 0;
            ulong secondary_version = 0;

            ulong.TryParse(version[0], out major_version);
            if (version.Length > 1)
            {
                ulong.TryParse(version[1], out secondary_version);
            }

            if (major_version > CONSTANT.MAJOR_VERSION || secondary_version > CONSTANT.SECONDARY_VERSION)
            {
                return(false);
            }

            string process_name = header_items[CHEAT_CODE_HEADER_PROCESS_NAME];

            if (process_name != (string)comboBox.SelectedItem)
            {
                comboBox.SelectedItem = process_name;
            }

            if (process_name != (string)comboBox.SelectedItem)
            {
                MessageBox.Show("Invalid process or refresh processes first.");
                return(false);
            }

            string game_id  = "";
            string game_ver = "";

            if (header_items.Length > CHEAT_CODE_HEADER_PROCESS_ID)
            {
                game_id = header_items[CHEAT_CODE_HEADER_PROCESS_ID];
                game_id = game_id.Substring(3);
            }

            if (header_items.Length > CHEAT_CODE_HEADER_PROCESS_VER)
            {
                game_ver = header_items[CHEAT_CODE_HEADER_PROCESS_VER];
                game_ver = game_ver.Substring(4);
            }

            if (game_id != "" && game_ver != "")
            {
                GameInfo gameInfo = new GameInfo();
                if (gameInfo.GameID != game_id)
                {
                    if (MessageBox.Show("Your Game ID(" + gameInfo.GameID + ") is different with cheat file(" + game_id + "), still load?",
                                        "Invalid game ID", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return(false);
                    }
                }

                if (gameInfo.Version != game_ver)
                {
                    if (MessageBox.Show("Your game version(" + gameInfo.Version + ") is different with cheat file(" + game_ver + "), still load?",
                                        "Invalid game version", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return(false);
                    }
                }
            }

            for (int i = 1; i < cheats.Length; ++i)
            {
                string   cheat_tuple    = cheats[i];
                string[] cheat_elements = cheat_tuple.Split(new string[] { "|" }, StringSplitOptions.None);

                if (cheat_elements.Length == 0)
                {
                    continue;
                }

                if (cheat_elements[CHEAT_CODE_TYPE] == "data")
                {
                    DataCheat cheat = new DataCheat(processManager);
                    if (!cheat.Parse(cheat_elements))
                    {
                        MessageBox.Show("Invaid cheat code:" + cheat_tuple);
                        continue;
                    }

                    cheat_list.Add(cheat);
                }
                else if (cheat_elements[CHEAT_CODE_TYPE] == "simple pointer")
                {
                    SimplePointerCheat cheat = new SimplePointerCheat(processManager);
                    if (!cheat.Parse(cheat_elements))
                    {
                        continue;
                    }
                    cheat_list.Add(cheat);
                }
                else
                {
                    MessageBox.Show("Invaid cheat code:" + cheat_tuple);
                    continue;
                }
            }
            return(true);
        }
Exemple #4
0
        public bool LoadFile(string path, ProcessManager processManager, ComboBox comboBox, ICheatPlugin cheatPlugin)
        {
            string[] cheats = File.ReadAllLines(path);

            string process_name = "";
            string game_id      = "";
            string game_ver     = "";

            if (cheatPlugin != null)
            {
                bool ret = cheatPlugin.ParseGameInfo(cheats);
                process_name = cheatPlugin.process_name;

                game_id  = cheatPlugin.game_id;
                game_ver = cheatPlugin.game_ver;
            }
            else
            {
                if (cheats.Length < 2)
                {
                    return(false);
                }

                string   header       = cheats[0];
                string[] header_items = header.Split('|');

                if (header_items.Length < CHEAT_CODE_HEADER_ELEMENT_COUNT)
                {
                    return(false);
                }

                string[] version = (header_items[CHEAT_CODE_HEADER_VERSION]).Split('.');

                ulong major_version     = 0;
                ulong secondary_version = 0;

                ulong.TryParse(version[0], out major_version);
                if (version.Length > 1)
                {
                    ulong.TryParse(version[1], out secondary_version);
                }

                if (major_version > CONSTANT.MAJOR_VERSION || (major_version == CONSTANT.MAJOR_VERSION && secondary_version > CONSTANT.SECONDARY_VERSION))
                {
                    return(false);
                }

                process_name = header_items[CHEAT_CODE_HEADER_PROCESS_NAME];

                if (header_items.Length > CHEAT_CODE_HEADER_PROCESS_ID)
                {
                    game_id = header_items[CHEAT_CODE_HEADER_PROCESS_ID];
                    game_id = game_id.Substring(3);
                }

                if (header_items.Length > CHEAT_CODE_HEADER_PROCESS_VER)
                {
                    game_ver = header_items[CHEAT_CODE_HEADER_PROCESS_VER];
                    game_ver = game_ver.Substring(4);
                }
            }

            if (process_name != (string)comboBox.SelectedItem)
            {
                comboBox.SelectedItem = process_name;
            }

            if (process_name != (string)comboBox.SelectedItem && !IS_DEV)
            {
                MessageBox.Show("Invalid process or refresh processes first.");
                return(false);
            }

            if (game_id != "" && game_ver != "")
            {
                GameInfo gameInfo = new GameInfo();
                if (gameInfo.GameID != game_id && !IS_DEV)
                {
                    if (MessageBox.Show("Your Game ID(" + gameInfo.GameID + ") is different with cheat file(" + game_id + "), still load?",
                                        "Invalid game ID", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return(false);
                    }
                }

                if (gameInfo.Version != game_ver && !IS_DEV)
                {
                    if (MessageBox.Show("Your game version(" + gameInfo.Version + ") is different with cheat file(" + game_ver + "), still load?",
                                        "Invalid game version", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return(false);
                    }
                }
            }

            if (cheatPlugin != null)
            {
                bool ret = cheatPlugin.ParseCheats(processManager, cheats);
                return(ret);
            }

            for (int i = 1; i < cheats.Length; ++i)
            {
                string   cheat_tuple    = cheats[i];
                string[] cheat_elements = cheat_tuple.Split(new string[] { "|" }, StringSplitOptions.None);

                if (cheat_elements.Length == 0)
                {
                    continue;
                }

                Cheat cheat = null;
                switch (cheat_elements[CHEAT_CODE_TYPE])
                {
                case "data":
                    cheat = new DataCheat(processManager);
                    if (!cheat.Parse(cheat_elements))
                    {
                        MessageBox.Show("Invaid cheat code:" + cheat_tuple);
                        continue;
                    }
                    break;

                case "simple pointer":
                    cheat = new SimplePointerCheat(processManager);
                    if (!cheat.Parse(cheat_elements))
                    {
                        continue;
                    }
                    break;

                case "@batchcode":
                    cheat = new BatchCodeCheat(processManager);
                    if (!cheat.Parse(cheat_elements))
                    {
                        MessageBox.Show("Invaid @batchcode:" + cheat_tuple);
                        continue;
                    }
                    break;

                case "@cheatcode":
                    //cheat = new CheatCodeCheat(processManager);
                    //if (!cheat.Parse(cheat_elements))
                    //{
                    //    MessageBox.Show("Invaid @cheatcode:" + cheat_tuple);
                    //    continue;
                    //}
                    break;

                default:
                    MessageBox.Show("Invaid cheat code:" + cheat_tuple);
                    continue;
                }
                cheat_list.Add(cheat);

                /*if (cheat_elements[CHEAT_CODE_TYPE] == "data")
                 * {
                 *  DataCheat cheat = new DataCheat(processManager);
                 *  if (!cheat.Parse(cheat_elements))
                 *  {
                 *      MessageBox.Show("Invaid cheat code:" + cheat_tuple);
                 *      continue;
                 *  }
                 *
                 *  cheat_list.Add(cheat);
                 * }
                 * else if (cheat_elements[CHEAT_CODE_TYPE] == "simple pointer")
                 * {
                 *
                 *  SimplePointerCheat cheat = new SimplePointerCheat(processManager);
                 *  if (!cheat.Parse(cheat_elements))
                 *      continue;
                 *  cheat_list.Add(cheat);
                 * }
                 * else
                 * {
                 *  MessageBox.Show("Invaid cheat code:" + cheat_tuple);
                 *  continue;
                 * }*/
            }
            return(true);
        }