private void Load(object n)
        {
            string file = (string)n;

            CheatEngineReader channels = new CheatEngineReader();

            channels.Read(file + ".ct"); // Channel File

            _mWaveform.Data     = new Dictionary <int, List <byte[]> >();
            _mWaveform.File     = file;
            _mWaveform.Channels = new List <MemoryChannel>(channels.Channels);

            // Read all channel ID's
            foreach (MemoryChannel mc in _mWaveform.Channels)
            {
                byte[] data = this.GetData(file + ".ch" + mc.ID.ToString());
                _mWaveform.Data.Add(mc.ID, new List <byte[]>());

                int sample = 0;
                for (long b = 0; b < data.Length; b += mc.DataSize)
                {
                    // Memcpy() from data to sampleData
                    byte[] sampleData = new byte[mc.DataSize];
                    for (int i = 0; i < mc.DataSize; i++)
                    {
                        sampleData[i] = data[b + i];
                    }

                    // Store
                    _mWaveform.Data[mc.ID].Add(sampleData);
                    sample++;
                }
            }

            //DONE
            if (Done != null)
            {
                Done(_mWaveform);
            }
        }
示例#2
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);
        }