public string GetProcessName(int idx)
        {
            ProcessList processList = MemoryHelper.GetProcessList();

            return(processList.processes[idx].name);
        }
Esempio n. 2
0
        public GameInfo()
        {
            string process_name   = "";
            string section_name   = "";
            ulong  id_offset      = 0;
            ulong  version_offset = 0;
            int    section_prot   = 0;

            switch (Util.Version)
            {
            case 702:
                process_name   = GAME_INFO_7_02_PROCESS_NAME;
                section_name   = GAME_INFO_7_02_SECTION_NAME;
                id_offset      = GAME_INFO_7_02_ID_OFFSET;
                version_offset = GAME_INFO_7_02_VERSION_OFFSET;
                section_prot   = GAME_INFO_7_02_SECTION_PROT;
                break;

            case 672:
                process_name   = GAME_INFO_6_72_PROCESS_NAME;
                section_name   = GAME_INFO_6_72_SECTION_NAME;
                id_offset      = GAME_INFO_6_72_ID_OFFSET;
                version_offset = GAME_INFO_6_72_VERSION_OFFSET;
                section_prot   = GAME_INFO_6_72_SECTION_PROT;
                break;

            case 505:
                process_name   = GAME_INFO_5_05_PROCESS_NAME;
                section_name   = GAME_INFO_5_05_SECTION_NAME;
                id_offset      = GAME_INFO_5_05_ID_OFFSET;
                version_offset = GAME_INFO_5_05_VERSION_OFFSET;
                section_prot   = GAME_INFO_5_05_SECTION_PROT;
                break;

            default:
                break;
            }

            try
            {
                ProcessManager processManager   = new ProcessManager();
                ProcessInfo?   maybeProcessInfo = processManager.GetProcessInfo(process_name);
                if (maybeProcessInfo is null)
                {
                    return;
                }
                ProcessInfo processInfo = (ProcessInfo)maybeProcessInfo;

                MemoryHelper      memoryHelper      = new MemoryHelper(false, processInfo.pid);
                MappedSectionList mappedSectionList = processManager.MappedSectionList;
                ProcessMap        processMap        = MemoryHelper.GetProcessMaps(processInfo.pid);
                if (processMap is null)
                {
                    return;
                }

                mappedSectionList.InitMemorySectionList(processMap);
                List <MappedSection> sectionList = mappedSectionList.GetMappedSectionList(section_name, section_prot);

                if (sectionList.Count != 1)
                {
                    return;
                }

                GameID  = System.Text.Encoding.Default.GetString(memoryHelper.ReadMemory(sectionList[0].Start + id_offset, 16));
                GameID  = GameID.Trim(new char[] { '\0' });
                Version = System.Text.Encoding.Default.GetString(memoryHelper.ReadMemory(sectionList[0].Start + version_offset, 16));
                Version = Version.Trim(new char[] { '\0' });
            }
            catch
            {
            }
        }
        public void UpdateResultList(ProcessManager processManager, MemoryHelper memoryHelper,
                                     string default_value_0_str, string default_value_1_str, bool is_hex, bool newScan, int thread_id)
        {
            if (!Check)
            {
                ResultList = null;
                return;
            }

            ResultList new_result_list = new ResultList(memoryHelper.Length, memoryHelper.Alignment);

            ulong address      = this.Start;
            uint  base_address = 0;
            int   length       = this.Length;

            const int buffer_length = 1024 * 1024 * 128;

            while (length != 0)
            {
                int cur_length = buffer_length;

                if (cur_length > length)
                {
                    cur_length = length;
                    length     = 0;
                }
                else
                {
                    length -= cur_length;
                }

                byte[] buffer = memoryHelper.ReadMemory(address, (int)cur_length, thread_id);

                byte[] default_value_0 = null;
                if (memoryHelper.ParseFirstValue)
                {
                    if (is_hex)
                    {
                        default_value_0 = memoryHelper.HexStringToBytes(default_value_0_str);
                    }
                    else
                    {
                        default_value_0 = memoryHelper.StringToBytes(default_value_0_str);
                    }
                }

                byte[] default_value_1 = null;
                if (memoryHelper.ParseSecondValue)
                {
                    if (is_hex)
                    {
                        default_value_1 = memoryHelper.HexStringToBytes(default_value_1_str);
                    }
                    else
                    {
                        default_value_1 = memoryHelper.StringToBytes(default_value_1_str);
                    }
                }

                if (newScan)
                {
                    memoryHelper.CompareWithMemoryBufferNewScanner(default_value_0, default_value_1, buffer, new_result_list, base_address);
                }
                else
                {
                    memoryHelper.CompareWithMemoryBufferNextScanner(default_value_0, default_value_1, buffer, ResultList, new_result_list);
                }

                address      += (ulong)cur_length;
                base_address += (uint)cur_length;
            }
            ResultList = new_result_list;
        }
Esempio n. 4
0
 public override void SetRuntime(CheatOperator SourceCheatOperator, int idx = 0)
 {
     MemoryHelper.WriteMemory(Address, SourceCheatOperator.GetRuntime());
 }
Esempio n. 5
0
 public override byte[] GetRuntime()
 {
     return(MemoryHelper.ReadMemory(GetAddress(), MemoryHelper.Length));
 }
Esempio n. 6
0
 public override string ToString(bool simple)
 {
     return(MemoryHelper.BytesToString(data));
 }
Esempio n. 7
0
 public override string Display()
 {
     return(MemoryHelper.BytesToString(data));
 }
Esempio n. 8
0
 public DataCheatOperator(string data, ValueType valueType, ProcessManager processManager)
     : base(valueType, processManager)
 {
     this.data         = MemoryHelper.StringToBytes(data);
     CheatOperatorType = CheatOperatorType.DATA_TYPE;
 }
Esempio n. 9
0
 public void Set(string data)
 {
     this.data = MemoryHelper.StringToBytes(data);
 }
Esempio n. 10
0
        private void update_result_list_view(BackgroundWorker worker, bool refresh, int start, float percent)
        {
            worker.ReportProgress(start);

            List <ListViewItem> listViewItems = new List <ListViewItem>();

            bool[] mappedSectionCheckeSet = new bool[processManager.MappedSectionList.Count];

            ulong  totalResultCount = processManager.MappedSectionList.TotalResultCount();
            ulong  curResultCount   = 0;
            string value_type       = MemoryHelper.GetStringOfValueType(memoryHelper.ValueType);

            const int MAX_RESULTS_NUM = 0x1000;

            for (int idx = 0; idx < processManager.MappedSectionList.Count; ++idx)
            {
                MappedSection mapped_section = processManager.MappedSectionList[idx];
                ResultList    result_list    = mapped_section.ResultList;
                if (result_list == null)
                {
                    continue;
                }
                if (!mapped_section.Check)
                {
                    continue;
                }

                mappedSectionCheckeSet[idx] = result_list.Count > 0;

                for (result_list.Begin(); !result_list.End(); result_list.Next())
                {
                    if (curResultCount >= MAX_RESULTS_NUM)
                    {
                        break;
                    }

                    uint   memory_address_offset = 0;
                    byte[] memory_value          = null;

                    result_list.Get(ref memory_address_offset, ref memory_value);

                    curResultCount++;
                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = String.Format("{0:X}", memory_address_offset + mapped_section.Start);

                    if (refresh && !worker.CancellationPending)
                    {
                        memory_value = memoryHelper.GetBytesByType(memory_address_offset + mapped_section.Start);
                        result_list.Set(memory_value);
                        worker.ReportProgress(start + (int)(100.0f * curResultCount / MAX_RESULTS_NUM));
                    }

                    lvi.SubItems.Add(value_type);
                    lvi.SubItems.Add(memoryHelper.BytesToString(memory_value));
                    lvi.SubItems.Add(memoryHelper.BytesToHexString(memory_value));
                    lvi.SubItems.Add(processManager.MappedSectionList.GetSectionName(idx));

                    listViewItems.Add(lvi);
                }
            }

            WorkerReturn workerReturn = new WorkerReturn();

            workerReturn.ListViewItems          = listViewItems;
            workerReturn.MappedSectionCheckeSet = mappedSectionCheckeSet;
            workerReturn.Results = totalResultCount;

            worker.ReportProgress(start + (int)(100 * percent), workerReturn);
        }
Esempio n. 11
0
 private void HexEdit_Load(object sender, EventArgs e)
 {
     this.hexBox.LineInfoOffset = (uint)section.Start;
     this.buffer = MemoryHelper.ReadMemory(section.Start, (int)section.Length);
     update_ui(page);
 }
Esempio n. 12
0
        private void update_result_list_view(BackgroundWorker worker, string value_type, bool refresh, int start, float percent)
        {
            worker.ReportProgress(start, 0);

            List <ListViewItem> listViewItems          = new List <ListViewItem>();
            HashSet <int>       mappedSectionCheckeSet = new HashSet <int>();

            ulong totalAddressCount = processManager.TotalAddressCount();
            ulong curAddressCount   = 0;

            for (int idx = 0; idx < processManager.MappedSectionList.Count; ++idx)
            {
                MappedSection mapped_section = processManager.MappedSectionList[idx];
                AddressList   address_list   = mapped_section.AddressList;
                if (address_list.Count > 0)
                {
                    mappedSectionCheckeSet.Add(idx);
                }
                for (int i = 0; i < address_list.Count; i++)
                {
                    if (curAddressCount >= 0x10000)
                    {
                        break;
                    }

                    curAddressCount++;
                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = String.Format("{0:X}", address_list[i].AddressOffset + mapped_section.Start);

                    byte[] match_bytes = BitConverter.GetBytes(address_list[i].MemoryValue);

                    if (refresh)
                    {
                        match_bytes = memoryHelper.GetBytesByType(address_list[i].AddressOffset + mapped_section.Start);
                        Address address_tmp = new Address();
                        address_tmp.AddressOffset = address_list[i].AddressOffset;
                        address_tmp.MemoryValue   = memoryHelper.BytesToUlong(match_bytes);
                        address_list[i]           = address_tmp;
                    }

                    string value_output = memoryHelper.BytesToString(match_bytes);

                    lvi.SubItems.Add(value_type);
                    lvi.SubItems.Add(value_output);
                    lvi.SubItems.Add(MemoryHelper.bytes_to_hex_string(match_bytes));
                    lvi.SubItems.Add(processManager.GetSectionName(idx));

                    listViewItems.Add(lvi);

                    if (i % 500 == 0)
                    {
                        worker.ReportProgress(start + (int)(i / (float)curAddressCount * 100 * percent));
                    }
                }
            }

            WorkerReturn workerReturn = new WorkerReturn();

            workerReturn.ListViewItems          = listViewItems;
            workerReturn.MappedSectionCheckeSet = mappedSectionCheckeSet;
            workerReturn.Results = totalAddressCount;

            worker.ReportProgress(start + (int)(100 * percent), workerReturn);
        }
Esempio n. 13
0
        public ProcessMap GetProcessMaps(int pid)
        {
            ProcessMap processMap = MemoryHelper.GetProcessMaps(pid);

            return(processMap);
        }
Esempio n. 14
0
        private byte[] GetData(int index, bool reset)
        {
            ulong     address = this.getAddress();
            BatchCode code    = Codes[index];

            byte[] data  = null;
            string value = code.value;

            if (reset)
            {
                value = code.reset;
            }
            ValueType vtype   = code.vtype;
            int       size    = code.size;
            int       psize   = size + code.skip;
            decimal   baseVal = 0;

            byte[] stepData = null;
            if (code.step != 0)
            {
                string hexStr = String.Format("{0:X}", code.step);
                stepData = NumberBytesHelper.HexToBytes(hexStr);
            }
            if (value.StartsWith("0x"))
            {
                string str = value.Substring(2);
                data = MemoryHelper.string_to_hex_bytes(str);
                if (size < 9)
                {
                    string[] strs = new string[str.Length / 2];
                    for (int i = 0; i < strs.Length; i++)
                    {
                        strs[i] = str.Substring(i * 2, 2);
                    }
                    Array.Reverse(strs);
                    str     = String.Join("", strs);
                    baseVal = ulong.Parse(str, NumberStyles.HexNumber);
                }
            }
            else
            {
                baseVal = Convert.ToDecimal(value);
                data    = this.convertValue(baseVal, vtype);
            }

            if (BatchType.VALUE.Equals(code.batchType))
            {
                return(data);
            }

            int dataSize = code.GetDataSize();
            int offset   = code.offset;

            address = address + (ulong)offset;
            byte[] buff = null;
            if (CheatList.IS_DEV)
            {
                buff = new byte[dataSize];
            }
            else
            {
                buff = MemoryHelper.ReadMemory(address, dataSize);
            }
            decimal        val      = baseVal;
            int            pos      = 0;
            NumberExcluder excluder = code.excluder;
            bool           ignore   = false;
            int            begin    = code.begin + 1;
            int            end      = code.target + 1;

            switch (code.batchType)
            {
            case BatchType.FOR:
                for (int i = begin; i < end; i++)
                {
                    if (excluder != null)
                    {
                        ignore = excluder.Match(i);
                    }
                    if (!ignore)
                    {
                        if (size < 9 && val != baseVal)
                        {
                            data = this.convertValue(val, vtype);
                        }
                        Buffer.BlockCopy(data, 0, buff, pos, code.size);
                        pos += psize;
                    }
                    if (!reset)
                    {
                        if (size < 9)
                        {
                            val += code.step;
                        }
                        else if (stepData != null)
                        {
                            data = NumberBytesHelper.Add(data, stepData);
                        }
                    }
                }
                break;
            }
            return(buff);
        }