Results 1 to 5 of 5
  1. #1
    Eithan1231's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    Australia
    Posts
    1,583
    Reputation
    429
    Thanks
    4,272
    My Mood
    Angelic

    Smile Memory class - Updated Jorndels.

    This was originally created by jorndel. I fixed it up a little added a few new features that some people may find useful.


    Jorndel's original thread: Click me!


    Features(There are functions for both 64x and 32x):
    Attach Process

    Read int
    Read Byte(s)
    Read Double
    Read String
    Read Float

    Write int
    Write Byte(s)
    Write Double
    Write String
    Write Float

    ReadString_Advanced < Will read till the end of the string(There's a 10k char limit tho xD)
    Pattern Scanner(32 bit only) < Scan memory


    Virus Scans to mine:
    Virus Total
    Virus Jotti


     

    Code:
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    class MemoryClass_Eithan_Jorndel
    {
        //Credits:
        //Jorndel < Created original class
        //Me < Edited it a lot. Added new fetures
        //SamTheDope < Being dope
    
        #region -----Main-----
        //Dll Inports
        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, UInt32 dwSize, uint flNewProtect, out uint lpflOldProtect);
    
        [DllImport("kernel32.dll")]
        private static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
    
        [DllImport("kernel32.dll")]
        private static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
    
        //Storing ProcessName
        IntPtr pHandel;
        Process attachedProcess = null;
    
        //Attching process
        public bool Process_Handle(string ProcessName)
        {
            try
            {
                Process[] ProcList = Process.GetProcessesByName(ProcessName);
                if (ProcList.Length == 0)
                    return false;
                else
                {
                    attachedProcess = ProcList[0];
                    pHandel = ProcList[0].Handle;
                    return true;
                }
            }
            catch (Exception ex) { SetLastError(ex); return false; }
        }
    
        #endregion
        #region 32 bit
        #region Basic Stuff
        private byte[] Read32(int Address, int Length)
        {
            byte[] Buffer = new byte[Length];
            IntPtr Zero = IntPtr.Zero;
            ReadProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
            return Buffer;
        }
    
        private void Write32(int Address, int Value)
        {
            byte[] Buffer = BitConverter.GetBytes(Value);
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        #endregion
        #region Write Functions
        public void WriteDouble32(int Address, double value)
        {
            byte[] Buffer = BitConverter.GetBytes(value);
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        public void WriteInteger(int Address, int Value)
        {
            Write32(Address, Value);
        }
    
        public void WriteString32(int Address, string Text)
        {
            byte[] Buffer = new ASCIIEncoding().GetBytes(Text);
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        public void WriteBytes32(int Address, byte[] Bytes)
        {
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Bytes, (uint)Bytes.Length, out Zero);
        }
    
        public void WriteNOP32(int Address, int nopLength)
        {
            byte[] Buffer = new byte[nopLength];
            for (int i = 0; i < nopLength; i++)
                Buffer[i] = (byte)0x90;
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        private void WriteFloat32(int Address, float Value)
        {
            byte[] Buffer = BitConverter.GetBytes(Value);
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        public void WriteFloat_Protected32(int Address, float Value)
        {
            uint OldProtection;
            VirtualProtectEx(pHandel, (IntPtr)Address, (uint)sizeof(float), 0x40, out OldProtection);
            WriteFloat32(Address, Value);
            VirtualProtectEx(pHandel, (IntPtr)Address, (uint)sizeof(float), OldProtection, out OldProtection);
        }
        #endregion
        #region Read Functions
        public int ReadInteger32(int Address, int Length = 4)
        {
            return BitConverter.ToInt32(Read32(Address, Length), 0);
        }
    
        public float ReadFloat32(int address)
        {
            return BitConverter.ToSingle(ReadBytes32(address, 8), 0);
        }
    
        public string ReadString32(int Address, int Length = 4)
        {
            return new ASCIIEncoding().GetString(Read32(Address, Length));
        }
    
        public byte[] ReadBytes32(int Address, int Length)
        {
            return Read32(Address, Length);
        }
    
        public double ReadDouble32(int address)
        {
            byte[] buffer = new byte[sizeof(double)];
            IntPtr Zero = IntPtr.Zero;
            ReadProcessMemory(pHandel, (IntPtr)address, buffer, (UInt32)buffer.Length, out Zero);
            return BitConverter.ToDouble(buffer, 0);
        }
        #endregion
        #region Advance
        //Don't use hex
        //Example: PatternScanXX("0 255 212 53 ?? 53 74 ?? 86 ?? ?? 12 ??")
        public int PatternScan32(string pattern, bool mainModule = true)
        {
            string[] splitPattern = pattern.Split(' ');
            bool[] indexValid = new bool[splitPattern.Length];
            byte[] indexValue = new byte[splitPattern.Length];
    
            byte tempByte = (byte)0x00;
    
            for (int i = 0; i < splitPattern.Length; i++)
            {
                indexValid[i] = !(splitPattern[i] == "??" || splitPattern[i] == "?");
                if (Byte.TryParse(splitPattern[i], out tempByte))
                    indexValue[i] = tempByte;
                else
                    indexValid[i] = false;
            }
    
    
            //searching memory part
            int startOfMemory = 0;
            int endOfMemory = 0;
    
            if(mainModule)
            {
                startOfMemory = attachedProcess.MainModule.BaseAddress.ToInt32();
                endOfMemory = attachedProcess.MainModule.ModuleMemorySize;
            }
            else
            {
                for (int i = 0; i < attachedProcess.Modules.Count; i++)
                    endOfMemory += attachedProcess.Modules[i].ModuleMemorySize;
            }
    
            for (int currentMemAddy = startOfMemory; currentMemAddy < endOfMemory; currentMemAddy++)
            {
                bool complete = false;
                for (int i = 0; i < splitPattern.Length; i++)
                {
                    if (!indexValid[i])
                        continue;
    
                    tempByte = ReadBytes32(currentMemAddy + i, 1)[0];
    
                    if (tempByte != indexValue[i])
                        break;
    
                    if (i == splitPattern.Length - 1)
                        complete = true;
    
                    if (complete)
                        break;
                }
    
                if (complete)
                    return currentMemAddy;
            }
    
            throw new Exception("Pattern not found!");
            return 0;
        }
        #endregion
        #endregion
        #region 64 Bit
        #region Basic Stuff
        private byte[] Read64(long Address, int Length)
        {
            byte[] Buffer = new byte[Length];
            IntPtr Zero = IntPtr.Zero;
            ReadProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
            return Buffer;
        }
    
        private void Write64(long Address, int Value)
        {
            byte[] Buffer = BitConverter.GetBytes(Value);
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        #endregion
        #region Write Function
        public void WriteInteger64(long Address, int Value)
        {
            Write64(Address, Value);
        }
    
        public void WriteString64(long Address, string Text)
        {
            byte[] Buffer = new ASCIIEncoding().GetBytes(Text);
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        public void WriteBytes64(long Address, byte[] Bytes)
        {
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Bytes, (uint)Bytes.Length, out Zero);
        }
    
        public void WriteNOP64(long Address)
        {
            byte[] Buffer = new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90 };
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        public void WriteFloat64(long Address, float Float)
        {
            byte[] Buffer = BitConverter.GetBytes(Float);
            IntPtr Zero = IntPtr.Zero;
            WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
        }
    
        #endregion
        #region Read Functions
        public int ReadInteger64(long Address, int Length = 4)
        {
            return BitConverter.ToInt32(Read64(Address, Length), 0);
        }
    
        public string ReadString64(long Address, int Length = 4)
        {
            return new ASCIIEncoding().GetString(Read64(Address, Length));
        }
    
        public byte[] ReadBytes64(long Address, int Length)
        {
            return Read64(Address, Length);
        }
    
        #endregion
        #endregion
        #region Advanced
        /// <summary>
        /// This will read the hole string until it's ended.
        /// Notes:
        /// This isn't the fastest method
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        public string ReadString_Advanced32(int offset)
        {
            string output = null;
    
            int i = 0;
            while (true)
            {
                byte[] currentByteRead = ReadBytes32(offset + i, 1);
                char currentCharRead = Encoding.ASCII.GetChars(currentByteRead)[0];
    
                //Check is valid char
                if (IsValidChar(currentCharRead))
                    output += currentCharRead.ToString();
                else
                    break;
    
                i++;
    
                if (i > 10000)//You need some sort of limit
                    break;
            }
    
            return output;
        }
    
        /// <summary>
        /// This will read the hole string until it's ended.
        /// Notes:
        /// This isn't the fastest method
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        public string ReadString_Advanced64(long offset)
        {
            string output = null;
    
            int i = 0;
            while (true)
            {
                byte[] currentByteRead = ReadBytes64(offset + i, 1);
                char currentCharRead = Encoding.ASCII.GetChars(currentByteRead)[0];
    
                //Check is valid char
                if (IsValidChar(currentCharRead))
                    output += currentCharRead.ToString();
                else
                    break;
    
                i++;
    
                if (i > 10000)
                    break;
            }
    
            return output;
        }
        #endregion
    
    
        #region Misc
        #region Error Handling
        private string lastError = null;
    
        public string GetLastError()
        {
            return lastError;
        }
    
        private void SetLastError(string error)
        {
            lastError = error;
        }
    
        private void SetLastError(Exception error)
        {
            lastError = error.ToString();
        }
        #endregion
        #region Char Checks - Used for "ReadString_Advanced"
        char[] validCharList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()_+-=` ".ToArray();//All the valid ascii chars I could think of
    
        private bool IsValidChar(char toCheckVar)
        {
            toCheckVar = ((toCheckVar.ToString()).ToLower()).ToCharArray()[0];
            for (int i = 0; i < validCharList.Length; i++)
                if (toCheckVar == validCharList[i])
                    return true;
            return false;
        }
        #endregion
        #endregion
    }
    Just under 320 lines


    And again, Big credits to Jorndel

    Download is below
    Click me to download!
    <b>Downloadable Files</b> Downloadable Files
    Last edited by Eithan1231; 4 Days Ago at 08:29 PM. Reason: Adding pattern scanner



     
    https://www.youtube.com/watch?v=-GcAc0kovUs

  2. The Following User Says Thank You to Eithan1231 For This Useful Post:

    Fymh (1 Week Ago)

  3. #2
    niko1921's Avatar
    Join Date
    Apr 2014
    Gender
    male
    Posts
    32
    Reputation
    10
    Thanks
    1
    for this i love C++

  4. #3
    Eithan1231's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    Australia
    Posts
    1,583
    Reputation
    429
    Thanks
    4,272
    My Mood
    Angelic
    Quote Originally Posted by niko1921 View Post
    for this i love C++
    You don't need a memory class for C++ internal...



     
    https://www.youtube.com/watch?v=-GcAc0kovUs

  5. The Following User Says Thank You to Eithan1231 For This Useful Post:

    JokerKing9903 (2 Weeks Ago)

  6. #4
    niko1921's Avatar
    Join Date
    Apr 2014
    Gender
    male
    Posts
    32
    Reputation
    10
    Thanks
    1
    Quote Originally Posted by Hunter's Sheep View Post


    You don't need a memory class for C++ internal...
    That's why i say.

  7. The Following User Says Thank You to niko1921 For This Useful Post:

    [MPGH]Eithan1231 (2 Weeks Ago)

  8. #5
    JokerKing9903's Avatar
    Join Date
    Sep 2014
    Gender
    male
    Location
    Visual Studio 2015 Enterprise
    Posts
    185
    Reputation
    10
    Thanks
    2,489
    My Mood
    Bitchy
    Eithan my one and only love thank yoooouu!
    SUPER Legit Coder


    When you use my Stuff and realize it's AWESOME!




    My Stuff be like! <3 #EnemyPounding

Similar Threads

  1. VB.Net Memory Class (Writen by Jorndel)
    By Jorndel in forum Call of Duty Modern Warfare 3 Coding, Programming & Source Code
    Replies: 22
    Last Post: 03-25-2015, 12:34 PM
  2. C# Memory Class (Writen by Jorndel)
    By Jorndel in forum Call of Duty Modern Warfare 3 Coding, Programming & Source Code
    Replies: 10
    Last Post: 03-22-2015, 06:43 AM
  3. [Patched] Killstreak Hack/Tool [All 15 Classes] updated
    By Jorndel in forum Call of Duty - Modern Warfare 3 (MW3) Hacks & Cheats
    Replies: 44
    Last Post: 01-25-2012, 07:06 PM
  4. Classes Updated?
    By Flengo in forum Combat Arms Coding Help & Discussion
    Replies: 0
    Last Post: 10-30-2011, 06:21 PM
  5. GameClientShell class update :(
    By Ch40zz-C0d3r in forum Combat Arms Coding Help & Discussion
    Replies: 0
    Last Post: 04-30-2011, 04:30 AM