readprocessmemory wrong outcome menu

User Tag List

Results 1 to 5 of 5
  1. #1
    meleea's Avatar Banned
    Reputation
    1
    Join Date
    Jun 2016
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    readprocessmemory wrong outcome

    Hi,

    can anyone tell me what I did wrong, please?
    The outcome is every time false...

    Code:
    private void button1_Click(object sender, EventArgs e)
            {
                ProcessMemory Mem = new ProcessMemory("Wow");
               
                if(!Mem.CheckProcess())
                {
                    MessageBox.Show("Make sure your application is running...");
                }
                else
                {
                    Mem.StartProcess();
                    int a = Mem.ReadInt(Convert.ToInt32(0xBC0A64));
                    richTextBox1.Text += test.ToString() + "\n";
                }
            }
    Code:
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System;
    using System.Windows.Forms;
    using System.Media;
    using System.Text;
    using System.Threading;
    
    namespace ReadWriteMemory
    {
        internal class ProcessMemory
        {
            // Fields
            protected int BaseAddress;
            protected Process[] MyProcess;
            protected ProcessModule myProcessModule;
            private const uint PAGE_EXECUTE = 16;
            private const uint PAGE_EXECUTE_READ = 32;
            private const uint PAGE_EXECUTE_READWRITE = 64;
            private const uint PAGE_EXECUTE_WRITECOPY = 128;
            private const uint PAGE_GUARD = 256;
            private const uint PAGE_NOACCESS = 1;
            private const uint PAGE_NOCACHE = 512;
            private const uint PAGE_READONLY = 2;
            private const uint PAGE_READWRITE = 4;
            private const uint PAGE_WRITECOPY = 8;
            private const uint PROCESS_ALL_ACCESS = 2035711;
            protected int processHandle;
            protected string ProcessName;
    
            // Methods
            public ProcessMemory(string pProcessName)
            {
                this.ProcessName = pProcessName;
            }
    
            public bool CheckProcess()
            {
                return (Process.GetProcessesByName(this.ProcessName).Length > 0);
            }
    
            [DllImport("kernel32.dll")]
            public static extern bool CloseHandle(int hObject);
            public string CutString(string mystring)
            {
                char[] chArray = mystring.ToCharArray();
                string str = "";
                for (int i = 0; i < mystring.Length; i++)
                {
                    if ((chArray[i] == ' ') && (chArray[i + 1] == ' '))
                    {
                        return str;
                    }
                    if (chArray[i] == '\0')
                    {
                        return str;
                    }
                    str = str + chArray[i].ToString();
                }
                return mystring.TrimEnd(new char[] { '0' });
            }
    
            public int DllImageAddress(string dllname)
            {
                ProcessModuleCollection modules = this.MyProcess[0].Modules;
    
                foreach (ProcessModule procmodule in modules)
                {
                    if (dllname == procmodule.ModuleName)
                    {
                        return (int)procmodule.BaseAddress;
                    }
                }
                return -1;
    
            }
            [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
            public static extern int FindWindowByCaption(int ZeroOnly, string lpWindowName);
            public int ImageAddress()
            {
                this.BaseAddress = 0;
                this.myProcessModule = this.MyProcess[0].MainModule;
                this.BaseAddress = (int)this.myProcessModule.BaseAddress;
                return this.BaseAddress;
    
    
            }
    
            public int ImageAddress(int pOffset)
            {
                this.BaseAddress = 0;
                this.myProcessModule = this.MyProcess[0].MainModule;
                this.BaseAddress = (int)this.myProcessModule.BaseAddress;
                return (pOffset + this.BaseAddress);
            }
            public string MyProcessName()
            {
                return this.ProcessName;
            }
    
            [DllImport("kernel32.dll")]
            public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
            public int Pointer(bool AddToImageAddress, int pOffset)
            {
                return this.ReadInt(this.ImageAddress(pOffset));
            }
    
            public int Pointer(string Module, int pOffset)
            {
                return this.ReadInt(this.DllImageAddress(Module) + pOffset);
            }
    
            public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2)
            {
                //look at this shit, it doesnt even have a if statement
                if (AddToImageAddress)
                    return (this.ReadInt(this.ImageAddress() + pOffset) + pOffset2);
                else
                    return (this.ReadInt(pOffset) + pOffset2);
            }
    
            public int Pointer(string Module, int pOffset, int pOffset2)
            {
                return (this.ReadInt(this.DllImageAddress(Module) + pOffset) + pOffset2);
            }
    
            public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2, int pOffset3)
            {
                return (this.ReadInt(this.ReadInt(this.ImageAddress(pOffset)) + pOffset2) + pOffset3);
            }
    
            public int Pointer(string Module, int pOffset, int pOffset2, int pOffset3)
            {
                return (this.ReadInt(this.ReadInt(this.DllImageAddress(Module) + pOffset) + pOffset2) + pOffset3);
            }
    
            public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2, int pOffset3, int pOffset4)
            {
                return (this.ReadInt(this.ReadInt(this.ReadInt(this.ImageAddress(pOffset)) + pOffset2) + pOffset3) + pOffset4);
            }
    
            public int Pointer(string Module, int pOffset, int pOffset2, int pOffset3, int pOffset4)
            {
                return (this.ReadInt(this.ReadInt(this.ReadInt(this.DllImageAddress(Module) + pOffset) + pOffset2) + pOffset3) + pOffset4);
            }
    
            public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2, int pOffset3, int pOffset4, int pOffset5)
            {
                return (this.ReadInt(this.ReadInt(this.ReadInt(this.ReadInt(this.ImageAddress(pOffset)) + pOffset2) + pOffset3) + pOffset4) + pOffset5);
            }
    
            public int Pointer(string Module, int pOffset, int pOffset2, int pOffset3, int pOffset4, int pOffset5)
            {
                return (this.ReadInt(this.ReadInt(this.ReadInt(this.ReadInt(this.DllImageAddress(Module) + pOffset) + pOffset2) + pOffset3) + pOffset4) + pOffset5);
            }
    
            public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2, int pOffset3, int pOffset4, int pOffset5, int pOffset6)
            {
                return (this.ReadInt(this.ReadInt(this.ReadInt(this.ReadInt(this.ReadInt(this.ImageAddress(pOffset)) + pOffset2) + pOffset3) + pOffset4) + pOffset5) + pOffset6);
            }
    
            public int Pointer(string Module, int pOffset, int pOffset2, int pOffset3, int pOffset4, int pOffset5, int pOffset6)
            {
                return (this.ReadInt(this.ReadInt(this.ReadInt(this.ReadInt(this.ReadInt(this.DllImageAddress(Module) + pOffset) + pOffset2) + pOffset3) + pOffset4) + pOffset5) + pOffset6);
            }
    
            public byte ReadByte(int pOffset)
            {
                byte[] buffer = new byte[1];
                ReadProcessMemory(this.processHandle, pOffset, buffer, 1, 0);
                return buffer[0];
            }
    
            public byte ReadByte(bool AddToImageAddress, int pOffset)
            {
                byte[] buffer = new byte[1];
                int lpBaseAddress = AddToImageAddress ? this.ImageAddress(pOffset) : pOffset;
                ReadProcessMemory(this.processHandle, lpBaseAddress, buffer, 1, 0);
                return buffer[0];
            }
    
            public byte ReadByte(string Module, int pOffset)
            {
                byte[] buffer = new byte[1];
                ReadProcessMemory(this.processHandle, this.DllImageAddress(Module) + pOffset, buffer, 1, 0);
                return buffer[0];
            }
    
            public float ReadFloat(int pOffset)
            {
                return BitConverter.ToSingle(this.ReadMem(pOffset, 4), 0);
            }
    
            public float ReadFloat(bool AddToImageAddress, int pOffset)
            {
                return BitConverter.ToSingle(this.ReadMem(pOffset, 4, AddToImageAddress), 0);
            }
    
            public float ReadFloat(string Module, int pOffset)
            {
                return BitConverter.ToSingle(this.ReadMem(this.DllImageAddress(Module) + pOffset, 4), 0);
            }
    
            public int ReadInt(int pOffset)
            {
                return BitConverter.ToInt32(this.ReadMem(pOffset, 4), 0);
            }
    
            public int ReadInt(bool AddToImageAddress, int pOffset)
            {
                return BitConverter.ToInt32(this.ReadMem(pOffset, 4, AddToImageAddress), 0);
            }
    
            public int ReadInt(string Module, int pOffset)
            {
                return BitConverter.ToInt32(this.ReadMem(this.DllImageAddress(Module) + pOffset, 4), 0);
            }
    
            public byte[] ReadMem(int pOffset, int pSize)
            {
                byte[] buffer = new byte[pSize];
                ReadProcessMemory(this.processHandle, pOffset, buffer, pSize, 0);
                return buffer;
            }
    
            public byte[] ReadMem(int pOffset, int pSize, bool AddToImageAddress)
            {
                byte[] buffer = new byte[pSize];
                int lpBaseAddress = AddToImageAddress ? this.ImageAddress(pOffset) : pOffset;
                ReadProcessMemory(this.processHandle, lpBaseAddress, buffer, pSize, 0);
                return buffer;
            }
    
            [DllImport("kernel32.dll")]
            public static extern bool ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);
            public short ReadShort(int pOffset)
            {
                return BitConverter.ToInt16(this.ReadMem(pOffset, 2), 0);
            }
    
            public short ReadShort(bool AddToImageAddress, int pOffset)
            {
                return BitConverter.ToInt16(this.ReadMem(pOffset, 2, AddToImageAddress), 0);
            }
    
            public short ReadShort(string Module, int pOffset)
            {
                return BitConverter.ToInt16(this.ReadMem(this.DllImageAddress(Module) + pOffset, 2), 0);
            }
    
            public string ReadStringAscii(int pOffset, int pSize)
            {
                return this.CutString(Encoding.ASCII.GetString(this.ReadMem(pOffset, pSize)));
            }
    
            public string ReadStringAscii(bool AddToImageAddress, int pOffset, int pSize)
            {
                return this.CutString(Encoding.ASCII.GetString(this.ReadMem(pOffset, pSize, AddToImageAddress)));
            }
    
            public string ReadStringAscii(string Module, int pOffset, int pSize)
            {
                return this.CutString(Encoding.ASCII.GetString(this.ReadMem(this.DllImageAddress(Module) + pOffset, pSize)));
            }
    
            public string ReadStringUnicode(int pOffset, int pSize)
            {
                return this.CutString(Encoding.Unicode.GetString(this.ReadMem(pOffset, pSize)));
            }
    
            public string ReadStringUnicode(bool AddToImageAddress, int pOffset, int pSize)
            {
                return this.CutString(Encoding.Unicode.GetString(this.ReadMem(pOffset, pSize, AddToImageAddress)));
            }
    
            public string ReadStringUnicode(string Module, int pOffset, int pSize)
            {
                return this.CutString(Encoding.Unicode.GetString(this.ReadMem(this.DllImageAddress(Module) + pOffset, pSize)));
            }
    
            public uint ReadUInt(int pOffset)
            {
                return BitConverter.ToUInt32(this.ReadMem(pOffset, 4), 0);
            }
    
            public uint ReadUInt(bool AddToImageAddress, int pOffset)
            {
                return BitConverter.ToUInt32(this.ReadMem(pOffset, 4, AddToImageAddress), 0);
            }
    
            public uint ReadUInt(string Module, int pOffset)
            {
                return BitConverter.ToUInt32(this.ReadMem(this.DllImageAddress(Module) + pOffset, 4), 0);
            }
    
            public bool StartProcess()
            {
                if (this.ProcessName != "")
                {
                    this.MyProcess = Process.GetProcessesByName(this.ProcessName);
                    if (this.MyProcess.Length == 0)
                    {
                        MessageBox.Show(this.ProcessName + " is not running or has not been found. Please check and try again", "Process Not Found", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return false;
                    }
                    this.processHandle = OpenProcess(2035711, false, this.MyProcess[0].Id);
                    if (this.processHandle == 0)
                    {
                        MessageBox.Show(this.ProcessName + " is not running or has not been found. Please check and try again", "Process Not Found", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return false;
                    }
                    return true;
                }
                MessageBox.Show("Define process name first!");
                return false;
            }
    
            [DllImport("kernel32.dll")]
            public static extern bool VirtualProtectEx(int hProcess, int lpAddress, int dwSize, uint flNewProtect, out uint lpflOldProtect);
            public void WriteByte(int pOffset, byte pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes((short)pBytes));
            }
    
            public void WriteByte(bool AddToImageAddress, int pOffset, byte pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes((short)pBytes), AddToImageAddress);
            }
    
            public void WriteByte(string Module, int pOffset, byte pBytes)
            {
                this.WriteMem(this.DllImageAddress(Module) + pOffset, BitConverter.GetBytes((short)pBytes));
            }
    
            public void WriteDouble(int pOffset, double pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteDouble(bool AddToImageAddress, int pOffset, double pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes), AddToImageAddress);
            }
    
            public void WriteDouble(string Module, int pOffset, double pBytes)
            {
                this.WriteMem(this.DllImageAddress(Module) + pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteFloat(int pOffset, float pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteFloat(bool AddToImageAddress, int pOffset, float pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes), AddToImageAddress);
            }
    
            public void WriteFloat(string Module, int pOffset, float pBytes)
            {
                this.WriteMem(this.DllImageAddress(Module) + pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteInt(int pOffset, int pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteInt(bool AddToImageAddress, int pOffset, int pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes), AddToImageAddress);
            }
    
            public void WriteInt(string Module, int pOffset, int pBytes)
            {
                this.WriteMem(this.DllImageAddress(Module) + pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteMem(int pOffset, byte[] pBytes)
            {
                WriteProcessMemory(this.processHandle, pOffset, pBytes, pBytes.Length, 0);
            }
    
            public void WriteMem(int pOffset, byte[] pBytes, bool AddToImageAddress)
            {
                int lpBaseAddress = AddToImageAddress ? this.ImageAddress(pOffset) : pOffset;
                WriteProcessMemory(this.processHandle, lpBaseAddress, pBytes, pBytes.Length, 0);
            }
    
            [DllImport("kernel32.dll")]
            public static extern bool WriteProcessMemory(int hProcess, int lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesWritten);
            public void WriteShort(int pOffset, short pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteShort(bool AddToImageAddress, int pOffset, short pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes), AddToImageAddress);
            }
    
            public void WriteShort(string Module, int pOffset, short pBytes)
            {
                this.WriteMem(this.DllImageAddress(Module) + pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteStringAscii(int pOffset, string pBytes)
            {
                this.WriteMem(pOffset, Encoding.ASCII.GetBytes(pBytes + "\0"));
            }
    
            public void WriteStringAscii(bool AddToImageAddress, int pOffset, string pBytes)
            {
                this.WriteMem(pOffset, Encoding.ASCII.GetBytes(pBytes + "\0"), AddToImageAddress);
            }
    
            public void WriteStringAscii(string Module, int pOffset, string pBytes)
            {
                this.WriteMem(this.DllImageAddress(Module) + pOffset, Encoding.ASCII.GetBytes(pBytes + "\0"));
            }
    
            public void WriteStringUnicode(int pOffset, string pBytes)
            {
                this.WriteMem(pOffset, Encoding.Unicode.GetBytes(pBytes + "\0"));
            }
    
            public void WriteStringUnicode(bool AddToImageAddress, int pOffset, string pBytes)
            {
                this.WriteMem(pOffset, Encoding.Unicode.GetBytes(pBytes + "\0"), AddToImageAddress);
            }
    
            public void WriteStringUnicode(string Module, int pOffset, string pBytes)
            {
                this.WriteMem(this.DllImageAddress(Module) + pOffset, Encoding.Unicode.GetBytes(pBytes + "\0"));
            }
    
            public void WriteUInt(int pOffset, uint pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes));
            }
    
            public void WriteUInt(bool AddToImageAddress, int pOffset, uint pBytes)
            {
                this.WriteMem(pOffset, BitConverter.GetBytes(pBytes), AddToImageAddress);
            }
    
            public void WriteUInt(string Module, int pOffset, uint pBytes)
            {
                this.WriteMem(this.DllImageAddress(Module) + pOffset, BitConverter.GetBytes(pBytes));
            }
    
            // Nested Types
            [Flags]
            public enum ProcessAccessFlags : uint
            {
                All = 2035711,
                CreateThread = 2,
                DupHandle = 64,
                QueryInformation = 1024,
                SetInformation = 512,
                Synchronize = 1048576,
                Terminate = 1,
                VMOperation = 8,
                VMRead = 16,
                VMWrite = 32
            }
        }
    }
    Sorry but im still new to this:/

    Thanks Meleea

    readprocessmemory wrong outcome
  2. #2
    dragonbane24's Avatar Contributor
    Reputation
    103
    Join Date
    Jan 2012
    Posts
    53
    Thanks G/R
    8/36
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure what you mean by "false"

    You have this code:
    Mem.StartProcess();
    int a = Mem.ReadInt(Convert.ToInt32(0xBC0A64));
    richTextBox1.Text += test.ToString() + "\n";

    And you are reading the value at some random memory location and saving it in the variable "a".

    Then you do some string append with a different string altogether. So "a" never gets used.

    Were you expecting to do something with the value at "a"?

  3. #3
    meleea's Avatar Banned
    Reputation
    1
    Join Date
    Jun 2016
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im trying to read something like coordinates or playername to get started with memory reading in wow. I can handle cheat engine, olly and ida, but have some troubles with reading the variables via code...

  4. #4
    Vandra's Avatar Contributor
    Reputation
    288
    Join Date
    Mar 2008
    Posts
    471
    Thanks G/R
    26/26
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to add process's baseaddress to the address you're tring to read.

    Like in cheat engine wow.exe + 0x00000

    Also you're talking about player name or coordinate, you're trying to read an int, playername is a string and coordinates are floats.
    "If it compiles, it works."

  5. #5
    meleea's Avatar Banned
    Reputation
    1
    Join Date
    Jun 2016
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see... Thanks.
    I got it to work with Blackmagic, but i dont want to use blackmagic.

    Code:
    Memory.wow.OpenProcessAndThread(SProcess.GetProcessFromWindowTitle(ProcMgr.cbSelectedIndex[i]));
    Memory.baseWow = Memory.wow.MainModule.BaseAddress;
    Player.playername = wow.ReadASCIIString((uint)baseWow + (uint)Memory.offsets.playername, 256);
    Can you please give me an example with readprocessmemory or a link with something useful and working:P?

    Thanks, got it. I can now read the memory
    Last edited by meleea; 06-06-2016 at 05:04 PM.

Similar Threads

  1. Blizzard's Policy and whats wrong with it PART ONE
    By WoWLegend in forum World of Warcraft General
    Replies: 12
    Last Post: 11-26-2006, 07:59 AM
  2. So you clicked the wrong Flight path
    By Nolixz in forum World of Warcraft Exploits
    Replies: 6
    Last Post: 11-25-2006, 10:56 PM
  3. Whats wrong with my video card?
    By Matt in forum Community Chat
    Replies: 2
    Last Post: 07-20-2006, 03:17 AM
  4. When buying an Account goes wrong
    By karokekid in forum Community Chat
    Replies: 5
    Last Post: 07-12-2006, 05:54 PM
All times are GMT -5. The time now is 12:54 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search