Click here to Skip to main content
15,891,809 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello!

I want to read data from my ram. But there are some Problems.
The MemoryScanner says that in the adress: 0x2604090 is the value: 1794.

But when i read that adress then i get a 0 back :(

I hope you can help me
PS: Sorry for my bad english :)

Here is my code:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
namespace ReadMemory
{
    public partial class Form1 : Form
    {
        MemoryScanner.ProcessMemoryReader reader = new MemoryScanner.ProcessMemoryReader();
        int[] ProcessIDs;
        public Form1()
        {
            InitializeComponent();
            Process[] Temp;
            Temp = Process.GetProcesses();
            ProcessIDs = new int[Temp.Length];
            for (int i = 0; i < Temp.Length; i++)
            {
                listBox1.Items.Add(Temp[i].ProcessName.ToString());
                ProcessIDs[i] = Temp[i].Id;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            reader.OpenProcess();
            int results = 0;
            uint bytesToRead = 20480;
            int bytesRead = 0;
            byte[] result = reader.ReadProcessMemory((IntPtr)0x2604090, bytesToRead, out bytesRead);
            if (bytesRead <= 0)
            {
                MessageBox.Show("No Bytes are readed!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                for (int i = 0; i < result.Length; i++)
                    results += result[i];
                richTextBox1.Text += results + Environment.NewLine;
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            byte[] WriteBytes = {255};
            int WrittenBytes = 0;
            reader.WriteProcessMemory((IntPtr)0x2604090, WriteBytes, out WrittenBytes);
            if(WrittenBytes <=0)
                MessageBox.Show("No Bytes are written!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
                MessageBox.Show("Successfully written!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            reader.ReadProcess = Process.GetProcessById(ProcessIDs[listBox1.SelectedIndex]);
        }
    }
}


I took the MemoryScanner.cs from the MemoryScanner ;)
Posted
Comments
Richard MacCutchan 20-Jul-10 8:37am    
You are not allowed to access memory locations that are not part of your application's address space. Your code above has the potential to crash the system, not a good thing to do.

1 solution

You'd better ask some hackers how to do this!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900