示例#1
0
        void add_new_row_of_cheat_list_view(HexCheat cheat, int sectionID)
        {
            int index = this.cheat_list_view.Rows.Add();

            DataGridViewRow cheat_list_view_item = cheat_list_view.Rows[index];

            cheat_list_view_item.Cells[CHEAT_LIST_ADDRESS].Value = cheat.Address;
            cheat_list_view_item.Cells[CHEAT_LIST_TYPE].Value    = MemoryHelper.GetStringOfValueType(cheat.Type);
            cheat_list_view_item.Cells[CHEAT_LIST_VALUE].Value   = cheat.Value;
            cheat_list_view_item.Cells[CHEAT_LIST_SECTION].Value = processManager.GetSectionName(sectionID);
            cheat_list_view_item.Cells[CHEAT_LIST_DESC].Value    = cheat.Description;
        }
示例#2
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);
            }
        }
示例#3
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);
        }