Helpc# any simple memory class 32/64 bit ?

Posts 15 of 5 · Page 1 of 1
c# any simple memory class 32/64 bit ?
Hi, i want to find some decent easy memory class for use in 1 mmo online game 32 bit.

I want some simple memory class to read data like

Code:
baseAdress = 0x00499FB8;
offsets[3] = [0x4, 0x24, 0x3c];

data = readMemory( targetProcess, baseAddress + offsets[] );

textBox.Text = data;
is something like this exists ?

I used 1 program that worked with this game long time ago but now won't work, i don't know if its because of windows10 64 bit or something else.

Try to run VS 2017 as admin too and still don't work :$

This is code i just changed pointer + offsets and don't work

c# code
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace test_memory
{
    
    public partial class Form1 : Form
    {
   
        public Form1()
        {
            InitializeComponent();

        }

        private void startbot_Click(object sender, EventArgs e)
        {
            test();
        }
        
        public void test()
        {
            Process[] processList = null;
            Process targetProcess = null;
            string processName = "alefclient";

            // get process by name
            processList = Process.GetProcessesByName(processName);
            try
            {
                // check if process is running
                if (processList == null)
                {
                    MessageBox.Show("Process not selected.");
                    return;
                }
                else
                {
                    byte[] buffer = new byte[4];
                    byte[] nameBuffer = new byte[30];
                    uint bytesRead = 0;
                    int address = Convert.ToInt32("00499FB8", 16); // base address 0x00499FB8

                    // offsets 0x4a4, 0x5c, 0x24, 0x4, 0x720
                    
                    address = BitConverter.ToInt32(buffer, 0) + 1172;   // 0x4a4
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 92; // 0x5c 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 36; // 0x24 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 4;  // 0x4 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    var targetHealth = BitConverter.ToInt32(buffer, 0) + 1824;  // 0x720
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    txtTargetID.Text = "Taget health " + targetHealth;
                        
                }
           }
           catch (Exception ex)
           {
                MessageBox.Show("Something went wrong, try again.");
           }
        }

        private void ReadProcessMemory(IntPtr handle, IntPtr address, byte[] buffer, int v, ref uint bytesRead)
        {
            throw new NotImplementedException();
        }
    }
}
visit.jpg180 KB · 14 downloads
Quote Originally Posted by mlukac89 View Post
[0x4, 0x24, 0x3c];
C# arrays aren't stored like that. They're stored with {}.


Quote Originally Posted by mlukac89 View Post
data = readMemory( targetProcess, baseAddress + offsets[] );
What type is data? What type are you reading from the function "readMemory"? You don't read arrays like that.


Quote Originally Posted by mlukac89 View Post
textBox.Text = data;
You're not going to cast the imaginary type?



Quote Originally Posted by mlukac89 View Post
private void ReadProcessMemory(IntPtr handle, IntPtr address, byte[] buffer, int v, ref uint bytesRead)
{
throw new NotImplementedException();
}
lol.


Quote Originally Posted by mlukac89 View Post
baseAdress = 0x00499FB8;
offsets[3] = [0x4, 0x24, 0x3c];

data = readMemory( targetProcess, baseAddress + offsets[] );

textBox.Text = data;
is something like this exists ?
Code:
IntPtr baseAdress = new IntPtr(0x00499FB8);
int offsets[3] = new int[] {0x4, 0x24, 0x3c};
IntPtr processedInPtr = 0;

for(int i = 0; i < offsets.Length; i++) {
     processedInPtr = ReadInteger(baseAddress + offsets[i] );
}

/* assuming you're reading a string. */
string data = ReadString(processedInPtr);

textBox.Text = data;
Quote Originally Posted by Silent View Post


C# arrays aren't stored like that. They're stored with {}.




What type is data? What type are you reading from the function "readMemory"? You don't read arrays like that.




You're not going to cast the imaginary type?





lol.




Code:
IntPtr baseAdress = new IntPtr(0x00499FB8);
int offsets[3] = new int[] {0x4, 0x24, 0x3c};
IntPtr processedInPtr = 0;

for(int i = 0; i < offsets.Length; i++) {
     processedInPtr = ReadInteger(baseAddress + offsets[i] );
}

/* assuming you're reading a string. */
string data = ReadString(processedInPtr);

textBox.Text = data;
Sorry but i am a new in c# so i don't know very much.

In first code i was giving a just and example, because i code in AutoIt and this its how its going but i can't paste that code here i'm not allowed :/.

I am trying to read 4 byte and string, but in this example only the 4 byte.

Sorry for the source code its a wrong, i give a wrong one

This is a source code :
Code:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace FindMemory
{
    public partial class Form1 : Form
    {
        Process[] processList = null;
        Process targetProcess = null;

        public Form1()
        {
            InitializeComponent();
        }

        //[DllImport("kernel32.dll", SetLastError = true)]
        //static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);


        [DllImport("Kernel32.dll")]
        public static extern bool ReadProcessMemory
        (
            IntPtr hProcess,
            IntPtr lpBaseAddress,
            byte[] lpBuffer,
            UInt32 nSize,
            ref UInt32 lpNumberOfBytesRead
        );


        private void button1_Click(object sender, EventArgs e)
        {
            test();
        }

        public void test()
        {
            

            // get process by name
            processList = Process.GetProcessesByName("alefclient");
            try
            {
                // check if process is running
                if (processList == null || processList.Length == 0)
                {
                    MessageBox.Show("Process not selected.");
                    //return;
                }
                else
                {
                    targetProcess = processList[0];
                    byte[] buffer = new byte[4];
                    uint bytesRead = 0;
                    int address = Convert.ToInt32("00499FB8", 16); // base address 0x00499FB8

                    // offsets 0x4a4, 0x5c, 0x24, 0x4, 0x720
                    
                    address = BitConverter.ToInt32(buffer, 0) + 1172;   // 0x4a4
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 92; // 0x5c 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 36; // 0x24 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 4;  // 0x4 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 1824;  // 0x720
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    int total = BitConverter.ToInt32(buffer, 0);

                    targetHpBOX.Text = " " + total;
                        
                }
           }
           catch (Exception ex)
           {
                MessageBox.Show("Something went wrong, try again." + ex);
           }
        }
    }
}
Quote Originally Posted by mlukac89 View Post
Sorry but i am a new in c# so i don't know very much.

In first code i was giving a just and example, because i code in AutoIt and this its how its going but i can't paste that code here i'm not allowed :/.

I am trying to read 4 byte and string, but in this example only the 4 byte.

Sorry for the source code its a wrong, i give a wrong one

This is a source code :
Code:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace FindMemory
{
    public partial class Form1 : Form
    {
        Process[] processList = null;
        Process targetProcess = null;

        public Form1()
        {
            InitializeComponent();
        }

        //[DllImport("kernel32.dll", SetLastError = true)]
        //static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);


        [DllImport("Kernel32.dll")]
        public static extern bool ReadProcessMemory
        (
            IntPtr hProcess,
            IntPtr lpBaseAddress,
            byte[] lpBuffer,
            UInt32 nSize,
            ref UInt32 lpNumberOfBytesRead
        );


        private void button1_Click(object sender, EventArgs e)
        {
            test();
        }

        public void test()
        {
            

            // get process by name
            processList = Process.GetProcessesByName("alefclient");
            try
            {
                // check if process is running
                if (processList == null || processList.Length == 0)
                {
                    MessageBox.Show("Process not selected.");
                    //return;
                }
                else
                {
                    targetProcess = processList[0];
                    byte[] buffer = new byte[4];
                    uint bytesRead = 0;
                    int address = Convert.ToInt32("00499FB8", 16); // base address 0x00499FB8

                    // offsets 0x4a4, 0x5c, 0x24, 0x4, 0x720
                    
                    address = BitConverter.ToInt32(buffer, 0) + 1172;   // 0x4a4
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 92; // 0x5c 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 36; // 0x24 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 4;  // 0x4 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 1824;  // 0x720
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    int total = BitConverter.ToInt32(buffer, 0);

                    targetHpBOX.Text = " " + total;
                        
                }
           }
           catch (Exception ex)
           {
                MessageBox.Show("Something went wrong, try again." + ex);
           }
        }
    }
}
Well I don't see anything wrong wit that code. apart from when you cast an integer to a string. But if you want to read the actual string in opposed to just the offset of the string, do something like this:

Code:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace FindMemory
{
    public partial class Form1 : Form
    {
        Process[] processList = null;
        Process targetProcess = null;

        public Form1()
        {
            InitializeComponent();
        }

        //[DllImport("kernel32.dll", SetLastError = true)]
        //static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);


        [DllImport("Kernel32.dll")]
        public static extern bool ReadProcessMemory
        (
            IntPtr hProcess,
            IntPtr lpBaseAddress,
            byte[] lpBuffer,
            UInt32 nSize,
            ref UInt32 lpNumberOfBytesRead
        );


        private void button1_Click(object sender, EventArgs e)
        {
            test();
        }

        public void test()
        {
            

            // get process by name
            processList = Process.GetProcessesByName("alefclient");
            try
            {
                // check if process is running
                if (processList == null || processList.Length == 0)
                {
                    MessageBox.Show("Process not selected.");
                    //return;
                }
                else
                {
                    targetProcess = processList[0];
                    byte[] buffer = new byte[4];
                    uint bytesRead = 0;
                    int address = Convert.ToInt32("00499FB8", 16); // base address 0x00499FB8

                    // offsets 0x4a4, 0x5c, 0x24, 0x4, 0x720
                    
                    address = BitConverter.ToInt32(buffer, 0) + 1172;   // 0x4a4
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 92; // 0x5c 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 36; // 0x24 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 4;  // 0x4 
                    ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);

                    address = BitConverter.ToInt32(buffer, 0) + 1824;  // 0x720

                    ReadProcessMemory(
                         targetProcess.Handle,
                         (IntPtr)address,
                         buffer,
                         1024,/*Length of string*/
                         ref bytesRead);

                    /*Can't remember if it's .ToString or .GetString*/
                    targetHpBOX.Text = " " + Encoding.ASCII.ToString(buffer);
                        
                }
           }
           catch (Exception ex)
           {
                MessageBox.Show("Something went wrong, try again." + ex);
           }
        }
    }
}
I see, but with this too i still can't read memory it don't give any error or any result even if i run as admin.

Game is 32 bit and i'm running windows 64 bit, maybe is problem in something else ?

Using VS 2017
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?