Пример #1
0
        private void load_address_btn_Click(object sender, EventArgs e)
        {
            if (processManager == null)
            {
                return;
            }

            open_file_dialog.Filter           = "Cheat files (*.cht)|*.cht";
            open_file_dialog.FilterIndex      = 1;
            open_file_dialog.RestoreDirectory = true;

            if (open_file_dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            cheatList.LoadFile(open_file_dialog.FileName, (string)processes_comboBox.SelectedItem, processManager);
            cheat_list_view.Rows.Clear();

            for (int i = 0; i < cheatList.Count; ++i)
            {
                Cheat cheat = cheatList[i];
                if (cheat.CheatType == CheatType.DATA_TYPE)
                {
                    add_new_row_of_cheat_list_view((DataCheat)cheat, ((DataCheat)cheat).SectionID);
                }
                else if (cheat.CheatType == CheatType.HEX_TYPE)
                {
                    add_new_row_of_cheat_list_view((HexCheat)cheat, ((HexCheat)cheat).SectionID);
                }
            }
        }
Пример #2
0
        private void btnLoadCheat_Click(object sender, EventArgs e)
        {
            ofdOpenFile.Filter           = "Cheat files (*.cht)|*.cht";
            ofdOpenFile.FilterIndex      = 1;
            ofdOpenFile.RestoreDirectory = true;

            if (ofdOpenFile.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            lvCheatList.Rows.Clear();
            cheatList.LoadFile(ofdOpenFile.FileName, processManager, cmbProcesses);

            for (int i = 0; i < cheatList.Count; ++i)
            {
                Cheat cheat = cheatList[i];
                if (cheat.CheatType == CheatType.DATA_TYPE)
                {
                    add_new_row_to_cheat_list_view((DataCheat)cheat);
                }
                else if (cheat.CheatType == CheatType.SIMPLE_POINTER_TYPE)
                {
                    add_new_row_to_cheat_list_view((SimplePointerCheat)cheat);
                }
            }
        }
Пример #3
0
 public bool Exist(Cheat cheat)
 {
     for (int i = 0; i < Count; ++i)
     {
         if (cheat_list[i].Address == cheat.Address)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
        private void cheat_list_item_active_Click(object sender, EventArgs e)
        {
            if (cheat_list_view.SelectedRows == null)
                return;

            DataGridViewSelectedRowCollection items = cheat_list_view.SelectedRows;
            for (int i = 0; i < items.Count; ++i)
            {
                Cheat cheat = cheatList[items[i].Index];

                cheat.GetDestination().SetRuntime(cheat.GetSource());
            }
        }
Пример #5
0
        void add_new_row_to_cheat_list_view(Cheat cheat)
        {
            int index = this.lvCheatList.Rows.Add();

            DataGridViewRow cheat_list_view_item = lvCheatList.Rows[index];
            CheatOperator   destination          = cheat.GetDestination();
            CheatOperator   source = cheat.GetSource();

            cheat_list_view_item.Cells[CHEAT_LIST_ADDRESS].Value = destination.Display();
            cheat_list_view_item.Cells[CHEAT_LIST_TYPE].Value    = MemoryHelper.GetStringOfValueType(source.ValueType);
            cheat_list_view_item.Cells[CHEAT_LIST_VALUE].Value   = source.Display();
            cheat_list_view_item.Cells[CHEAT_LIST_SECTION].Value = processManager.MappedSectionList.GetSectionName(destination.GetSectionID());
            cheat_list_view_item.Cells[CHEAT_LIST_LOCK].Value    = cheat.Lock;
            cheat_list_view_item.Cells[CHEAT_LIST_DESC].Value    = cheat.Description;
        }
Пример #6
0
        void new_data_cheat(string address_str, string type, string value, string section, string flag, string description)
        {
            try
            {
                ulong address   = ulong.Parse(address_str, NumberStyles.HexNumber);
                int   sectionID = processManager.GetMappedSectionID(address);

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

                for (int i = 0; i < cheatList.Count; ++i)
                {
                    if (cheatList[i].Address == address_str)
                    {
                        return;
                    }
                }

                ulong flag_u = ulong.Parse(flag, NumberStyles.HexNumber);
                bool  lock_  = (flag_u & CONSTANT.SAVE_FLAG_LOCK) == CONSTANT.SAVE_FLAG_LOCK ? true : false;

                ValueType valueType = MemoryHelper.GetValueTypeByString(type);
                CheatType cheatType = Cheat.GetCheatTypeByValueType(valueType);
                if (cheatType == CheatType.DATA_TYPE)
                {
                    DataCheat dataCheat = new DataCheat(processManager, address_str, sectionID, value, lock_, valueType, description);
                    add_new_row_of_cheat_list_view(dataCheat, sectionID);
                    cheatList.Add(dataCheat);
                }
                else if (cheatType == CheatType.HEX_TYPE)
                {
                    HexCheat hexCheat = new HexCheat(processManager, address_str, sectionID, value, lock_, valueType, description);
                    add_new_row_of_cheat_list_view(hexCheat, sectionID);
                    cheatList.Add(hexCheat);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, exception.Source, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
Пример #7
0
        public bool LoadFile(string path, string processName, ProcessManager processManager)
        {
            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 == 1 && secondary_version <= 3)
            {
                string process_name = header_items[CHEAT_CODE_HEADER_PROCESS_NAME];
                if (process_name != processName)
                {
                    MessageBox.Show("Invalid process.");
                    return(false);
                }

                for (int i = 1; i < cheats.Length; ++i)
                {
                    string cheat_tuple = cheats[i];
                    try
                    {
                        string[] cheat_elements = cheat_tuple.Split('|');

                        if (cheat_elements.Length == 0)
                        {
                            continue;
                        }
                        Cheat cheat = null;
                        if (cheat_elements[CHEAT_CODE_TYPE] == "data")
                        {
                            cheat = new DataCheat(processManager);
                            if (cheat.Load(cheat_elements, processManager) && !Exist(cheat))
                            {
                                cheat_list.Add(cheat);
                            }
                        }
                        else if (cheat_elements[CHEAT_CODE_TYPE] == "hex")
                        {
                            cheat = new HexCheat(processManager);
                            if (cheat.Load(cheat_elements, processManager) && !Exist(cheat))
                            {
                                cheat_list.Add(cheat);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Invaid cheat file.");
                            continue;
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Invalid version.");
                return(false);
            }
            return(true);
        }
Пример #8
0
 public void Add(Cheat cheat)
 {
     cheat_list.Add(cheat);
 }
Пример #9
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 || (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);
                    }
                }
            }

            string resultMsg = "";

            for (int i = 1; i < cheats.Length; ++i)
            {
                string cheat_tuple = cheats[i];
                Cheat  cheat       = null;
                if (ParseCheatTuple(cheat_tuple, processManager, ref cheat) && cheat != null)
                {
                    cheat_list.Add(cheat);
                }
                else
                {
                    resultMsg += cheat_tuple + "\n";
                    continue;
                }
            }
            if (resultMsg != "")
            {
                MessageBox.Show("Invaid cheat code:\n" + resultMsg);
            }
            return(true);
        }
Пример #10
0
 public bool Exist(Cheat cheat)
 {
     return(false);
 }
Пример #11
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);
        }
Пример #12
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);
        }