Example #1
0
 public static string ReadAsString(this MemoryReader reader, MemoryChannel ch)
 {
     switch(ch.Type)
     {
         case MemoryChannelType.FLOAT:
             return reader.ReadFloat(ch.Address).ToString("0.0000");
             break;
         case MemoryChannelType.INT32:
             return reader.ReadInt32(ch.Address).ToString();
             break;
         case MemoryChannelType.DOUBLE:
             return reader.ReadDouble(ch.Address).ToString("0.0000");
             break;
         default:
             return "??";
     }
 }
Example #2
0
        public static string ReadAsString(this MemoryReader reader, MemoryChannel ch)
        {
            switch (ch.Type)
            {
            case MemoryChannelType.FLOAT:
                return(reader.ReadFloat(ch.Address).ToString("0.0000"));

                break;

            case MemoryChannelType.INT32:
                return(reader.ReadInt32(ch.Address).ToString());

                break;

            case MemoryChannelType.DOUBLE:
                return(reader.ReadDouble(ch.Address).ToString("0.0000"));

                break;

            default:
                return("??");
            }
        }
Example #3
0
        private void bt_load_table_Click(object sender, System.EventArgs e)
        {
            if (_mMemory != null)
            {
                _mMemory.CloseHandle();
            }
            string file = "Test.CT";

            _mMemoryList = new CheatEngineReader();
            _mMemoryList.Read(file);

            lbl_table.Text = "Table:" + file;

            // Update UI.
            _mTable.Items.Clear();

            // Search for the exe
            Process[] p = Process.GetProcessesByName(_mMemoryList.ProcessExe.Substring(0, _mMemoryList.ProcessExe.Length - 4));
            if (p.Length == 1)
            {
                _mProcess            = p[0];
                _mMemory             = new MemoryReader();
                _mMemory.ReadProcess = p[0];
                _mMemory.OpenProcess();

                lbl_exe.Text = "PID:" + p[0].Id + "\r\n[" + p[0].ProcessName + "]";
            }
            else if (p.Length == 0)
            {
                lbl_exe.Text = "Failed";
                MessageBox.Show("Please load only if the process is already running.");
                // TODO: Wait for process.
                return;
            }
            else
            {
                lbl_exe.Text = "Failed";
                MessageBox.Show("Found multiple exe's running! Cannot figure out what to-do.");
                //TODO: Add dialog.
                return;
            }

            IntPtr base_addr = p[0].MainModule.BaseAddress;

            for (int i = 0; i < _mMemoryList.Channels.Count; i++)
            {
                _mMemoryList.Channels[i].UI_ID   = i;
                _mMemoryList.Channels[i].Address = new IntPtr(_mMemoryList.Channels[i].Address.ToInt32() + base_addr.ToInt32());
                MemoryChannel ch = _mMemoryList.Channels[i];
                _mTable.Items.Add(new ListViewItem(new string[5]
                {
                    ch.ID.ToString(),
                    ch.Name,
                    "0x" + String.Format("{0,10:X}", ch.Address.ToInt32()),
                    ch.TypeToString(),
                    "0.000"
                }));
            }


            _mGrabber       = new Grabber(_mMemoryList, _mMemory);
            _mGrabber.Done += new Signal(_mGrabber_Done);
        }
Example #4
0
        public void Read(string file)
        {
            int j = 0, i = 0;

            MemoryChannel ch = new MemoryChannel();

            ch.ID = -1;

            if (File.Exists(file))
            {
                // For table version 12
                using (XmlReader xml = XmlReader.Create(file))
                {
                    while (xml.Read())
                    {
                        if (xml.IsStartElement())
                        {
                            switch (xml.Name)
                            {
                            case "CheatTable":
                                // YEP for version 12.
                                break;

                            case "CheatEntries":
                                // Yep.
                                break;

                            case "CheatEntry":
                                ch = new MemoryChannel();
                                break;

                            case "ID":
                                xml.Read();
                                //ch.ID = Convert.ToInt32(xml.Value);
                                ch.ID = j++;    //xml.ReadContentAsInt();
                                break;

                            case "Description":
                                xml.Read();
                                ch.Name = xml.ReadContentAsString();
                                ch.Name = ch.Name.Substring(1, ch.Name.Length - 2);
                                break;

                            case "VariableType":
                                xml.Read();
                                switch (xml.Value)
                                {
                                case "4 Bytes":
                                    ch.Type = MemoryChannelType.INT32;
                                    break;

                                case "Float":
                                    ch.Type = MemoryChannelType.FLOAT;
                                    break;

                                case "Double":
                                    ch.Type = MemoryChannelType.DOUBLE;
                                    break;
                                }
                                break;

                            case "Address":
                                xml.Read();
                                string s = xml.Value;
                                ProcessExe = s.Substring(0, s.IndexOf("+"));
                                s          = s.Substring(s.IndexOf("+") + 1);
                                int.TryParse(s, NumberStyles.HexNumber, new CultureInfo("EN-US"), out i);

                                ch.Address = new IntPtr(i);
                                break;
                            }
                        }
                        else
                        {
                            if (xml.Name == "CheatEntry")
                            {
                                // Store it.
                                Channels.Add(ch);
                            }
                        }
                    }
                }
            }
        }