ReadProcessMemory() private method

private ReadProcessMemory ( IntPtr hProcess, IntPtr lpBaseAddress, [ bBuffer, uint size, IntPtr &lpNumberOfBytesRead ) : int
hProcess System.IntPtr
lpBaseAddress System.IntPtr
bBuffer [
size uint
lpNumberOfBytesRead System.IntPtr
return int
Exemplo n.º 1
0
        private int CalculatePointer(int iMemoryAddress, int[] iOffsets)
        {
            int num = iOffsets.Length - 1;

            byte[] bBuffer = new byte[4];
            int    num2    = 0;

            if (num == 0)
            {
                num2 = iMemoryAddress;
            }
            for (int i = 0; i <= num; i++)
            {
                IntPtr ptr;
                if (i == num)
                {
                    MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num2, bBuffer, 4, out ptr);
                    return(this.Dec(this.CreateAddress(bBuffer)) + iOffsets[i]);
                }
                if (i == 0)
                {
                    MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 4, out ptr);
                    num2 = this.Dec(this.CreateAddress(bBuffer)) + iOffsets[0];
                }
                else
                {
                    MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num2, bBuffer, 4, out ptr);
                    num2 = this.Dec(this.CreateAddress(bBuffer)) + iOffsets[i];
                }
            }
            return(0);
        }
Exemplo n.º 2
0
        public byte[] ReadAOB(int iMemoryAddress, uint iBytesToRead)
        {
            IntPtr ptr;

            byte[] bBuffer = new byte[iBytesToRead];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, iBytesToRead, out ptr);
            return(bBuffer);
        }
Exemplo n.º 3
0
        public ushort ReadShort(int iMemoryAddress, int[] iOffsets)
        {
            IntPtr ptr;
            int    num = this.CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[2];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num, bBuffer, 2, out ptr);
            return(BitConverter.ToUInt16(bBuffer, 0));
        }
Exemplo n.º 4
0
        public long ReadLong(int iMemoryAddress, int[] iOffsets)
        {
            IntPtr ptr;
            int    num = this.CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[8];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num, bBuffer, 8, out ptr);
            return(BitConverter.ToInt64(bBuffer, 0));
        }
Exemplo n.º 5
0
        public float ReadFloat(int iMemoryAddress, int[] iOffsets)
        {
            IntPtr ptr;
            int    num = this.CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[4];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num, bBuffer, 4, out ptr);
            return(BitConverter.ToSingle(bBuffer, 0));
        }
Exemplo n.º 6
0
        public byte ReadByte(int iMemoryAddress, int[] iOffsets)
        {
            IntPtr ptr;
            int    num = this.CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[1];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num, bBuffer, 1, out ptr);
            return(bBuffer[0]);
        }
Exemplo n.º 7
0
        public byte[] ReadAOB(int iMemoryAddress, int[] iOffsets, uint iBytesToRead)
        {
            IntPtr ptr;
            int    num = this.CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[iBytesToRead];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num, bBuffer, iBytesToRead, out ptr);
            return(bBuffer);
        }
Exemplo n.º 8
0
        public ushort ReadShort(int iMemoryAddress)
        {
            IntPtr ptr;

            byte[] bBuffer = new byte[2];
            if (MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 2, out ptr) == 0)
            {
                return(0);
            }
            return(BitConverter.ToUInt16(bBuffer, 0));
        }
Exemplo n.º 9
0
        public long ReadLong(int iMemoryAddress)
        {
            IntPtr ptr;

            byte[] bBuffer = new byte[8];
            if (MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 8, out ptr) == 0)
            {
                return(0L);
            }
            return(BitConverter.ToInt64(bBuffer, 0));
        }
Exemplo n.º 10
0
        public uint ReadInt(int iMemoryAddress)
        {
            IntPtr ptr;

            byte[] bBuffer = new byte[4];
            if (MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 4, out ptr) == 0)
            {
                return(0);
            }
            return(BitConverter.ToUInt32(bBuffer, 0));
        }
Exemplo n.º 11
0
        public float ReadFloat(int iMemoryAddress)
        {
            IntPtr ptr;

            byte[] bBuffer = new byte[4];
            if (MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 4, out ptr) == 0)
            {
                return(0f);
            }
            return(BitConverter.ToSingle(bBuffer, 0));
        }
Exemplo n.º 12
0
        public double ReadDouble(int iMemoryAddress)
        {
            IntPtr ptr;

            byte[] bBuffer = new byte[8];
            if (MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 8, out ptr) == 0)
            {
                return(0.0);
            }
            return(BitConverter.ToDouble(bBuffer, 0));
        }
Exemplo n.º 13
0
        public byte ReadByte(int iMemoryAddress)
        {
            IntPtr ptr;

            byte[] bBuffer = new byte[1];
            if (MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 1, out ptr) == 0)
            {
                return(0);
            }
            return(bBuffer[0]);
        }
Exemplo n.º 14
0
        public string ReadString(int iMemoryAddress, uint iTextLength, int iMode = 0)
        {
            IntPtr ptr;

            byte[] bBuffer = new byte[iTextLength];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)iMemoryAddress, bBuffer, iTextLength, out ptr);
            if (iMode == 0)
            {
                return(Encoding.UTF8.GetString(bBuffer));
            }
            if (iMode == 1)
            {
                return(BitConverter.ToString(bBuffer).Replace("-", ""));
            }
            return("");
        }
Exemplo n.º 15
0
        public string ReadText(int iMemoryAddress, int[] iOffsets, uint iStringLength, int iMode = 0)
        {
            IntPtr ptr;
            int    num = this.CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[1];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num, bBuffer, iStringLength, out ptr);
            if (iMode == 0)
            {
                return(Encoding.UTF8.GetString(bBuffer));
            }
            if (iMode == 1)
            {
                return(BitConverter.ToString(bBuffer).Replace("-", ""));
            }
            return("");
        }