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
コード例 #1
0
        }          /*
                    * private string CreateAddress(byte[] pBytes)
                    * {
                    * string sAddress = "";
                    *
                    * for (int i = 0; i < pBytes.Length; i++)
                    * {
                    * Console.WriteLine(String.Format("pBytes[{0}] = {1}, sAddress = {2}", i, pBytes[i], sAddress));
                    * sAddress = (pBytes[i] < 17) ? (String.Format("0{0}{1}", pBytes[i].ToString("X"), sAddress)) : (pBytes[i].ToString("X") + sAddress);
                    * }
                    * return sAddress;
                    * } */

        //Calculate Pointer
        private int CalculatePointer(int iMemoryAddress, int[] iOffsets)
        {
            int iPointerCount = iOffsets.Length - 1; IntPtr ptrBytesRead; byte[] bBuffer = new byte[4]; int iTemporaryAddress = 0;

            if (iPointerCount == 0)
            {
                iTemporaryAddress = iMemoryAddress;
            }

            for (int i = 0; i <= iPointerCount; i++)
            {
                if (i == iPointerCount)
                {
                    MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iTemporaryAddress, bBuffer, 4, out ptrBytesRead);
                    iTemporaryAddress = Dec(CreateAddress(bBuffer)) + iOffsets[i];
                    return(iTemporaryAddress);
                }
                else if (i == 0)
                {
                    MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 4, out ptrBytesRead);
                    iTemporaryAddress = Dec(CreateAddress(bBuffer)) + iOffsets[0];
                }
                else
                {
                    MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iTemporaryAddress, bBuffer, 4, out ptrBytesRead);
                    iTemporaryAddress = Dec(CreateAddress(bBuffer)) + iOffsets[i];
                }
            }
            return(0);
        }
コード例 #2
0
        public string ReadText(int iMemoryAddress, int[] iOffsets, uint iStringLength, bool Unicode, int iMode = 0)
        {
            int iFinalAddress = CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[iStringLength];
            IntPtr ptrBytesRead;

            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iFinalAddress, bBuffer, iStringLength, out ptrBytesRead);

            if (Unicode)
            {
                return(Encoding.Unicode.GetString(bBuffer));
            }
            if (iMode == 0)
            {
                return(Encoding.UTF8.GetString(bBuffer));
            }
            else if (iMode == 1)
            {
                return(BitConverter.ToString(bBuffer).Replace("-", ""));
            }
            else
            {
                return("");
            }
        }
コード例 #3
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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);
        }
コード例 #4
0
        public byte[] ReadAOB(int iMemoryAddress, uint iBytesToRead)
        {
            byte[] bBuffer = new byte[iBytesToRead]; IntPtr ptrBytesRead;
            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iMemoryAddress, bBuffer, iBytesToRead, out ptrBytesRead);

            return(bBuffer);
        }
コード例 #5
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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]);
        }
コード例 #6
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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));
        }
コード例 #7
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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));
        }
コード例 #8
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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));
        }
コード例 #9
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        public byte[] ReadAOB(int iMemoryAddress, int[] iOffsets, uint iBytesToRead)
        {
            IntPtr ptr;
            int    num = this.CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[1];
            MAPI.ReadProcessMemory(this.hReadProcess, (IntPtr)num, bBuffer, iBytesToRead, out ptr);
            return(bBuffer);
        }
コード例 #10
0
        public byte[] ReadAOB(int iMemoryAddress, int[] iOffsets, uint iBytesToRead)
        {
            int iFinalAddress = CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[1];
            IntPtr ptrBytesRead;

            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iFinalAddress, bBuffer, iBytesToRead, out ptrBytesRead);
            return(bBuffer);
        }
コード例 #11
0
        public double ReadDouble(int iMemoryAddress, int[] iOffsets)
        {
            int iFinalAddress = CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[8];
            IntPtr ptrBytesRead;

            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iFinalAddress, bBuffer, 8, out ptrBytesRead);
            return(BitConverter.ToDouble(bBuffer, 0));
        }
コード例 #12
0
        public float ReadFloat(int iMemoryAddress, int[] iOffsets)
        {
            int iFinalAddress = CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[4];
            IntPtr ptrBytesRead;

            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iFinalAddress, bBuffer, 4, out ptrBytesRead);
            return(BitConverter.ToSingle(bBuffer, 0));
        }
コード例 #13
0
        public ushort ReadShort(int iMemoryAddress, int[] iOffsets)
        {
            int iFinalAddress = CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[2];
            IntPtr ptrBytesRead;

            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iFinalAddress, bBuffer, 2, out ptrBytesRead);
            return(BitConverter.ToUInt16(bBuffer, 0));
        }
コード例 #14
0
        //Read from Pointer
        public byte ReadByte(int iMemoryAddress, int[] iOffsets)
        {
            int iFinalAddress = CalculatePointer(iMemoryAddress, iOffsets);

            byte[] bBuffer = new byte[1];
            IntPtr ptrBytesRead;

            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iFinalAddress, bBuffer, 1, out ptrBytesRead);
            return(bBuffer[0]);
        }
コード例 #15
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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]);
        }
コード例 #16
0
ファイル: Memory.cs プロジェクト: Project-Jc/Penumbra
        public uint ReadInt(int iMemoryAddress, int[] iOffsets)
        {
            int iFinalAddress = CalculatePointer(iMemoryAddress, iOffsets);

            //return (uint)iFinalAddress;
            byte[] bBuffer = new byte[4];
            IntPtr ptrBytesRead;

            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iFinalAddress, bBuffer, 4, out ptrBytesRead);
            return(BitConverter.ToUInt32(bBuffer, 0));
        }
コード例 #17
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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));
        }
コード例 #18
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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));
        }
コード例 #19
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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));
        }
コード例 #20
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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));
        }
コード例 #21
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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));
        }
コード例 #22
0
        public ushort ReadShort(int iMemoryAddress)
        {
            byte[] bBuffer = new byte[2]; IntPtr ptrBytesRead;
            int    iReturn = MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 2, out ptrBytesRead);

            if (iReturn == 0)
            {
                return(0);
            }
            else
            {
                return(BitConverter.ToUInt16(bBuffer, 0));
            }
        }
コード例 #23
0
        public float ReadFloat(int iMemoryAddress)
        {
            byte[] bBuffer = new byte[4]; IntPtr ptrBytesRead;
            int    iReturn = MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 4, out ptrBytesRead);

            if (iReturn == 0)
            {
                return(0);
            }
            else
            {
                return(BitConverter.ToSingle(bBuffer, 0));
            }
        }
コード例 #24
0
        public double ReadDouble(int iMemoryAddress)
        {
            byte[] bBuffer = new byte[8]; IntPtr ptrBytesRead;
            int    iReturn = MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 8, out ptrBytesRead);

            if (iReturn == 0)
            {
                return(0);
            }
            else
            {
                return(BitConverter.ToDouble(bBuffer, 0));
            }
        }
コード例 #25
0
        //Read from Address
        public byte ReadByte(int iMemoryAddress)
        {
            byte[] bBuffer = new byte[1]; IntPtr ptrBytesRead;
            int    iReturn = MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iMemoryAddress, bBuffer, 1, out ptrBytesRead);

            if (iReturn == 0)
            {
                return(0);
            }
            else
            {
                return(bBuffer[0]);
            }
        }
コード例 #26
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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("");
        }
コード例 #27
0
        public string ReadString(int iMemoryAddress, uint iTextLength, bool Unicode)
        {
            byte[] bBuffer = new byte[iTextLength];
            IntPtr ptrBytesRead;

            MAPI.ReadProcessMemory(hReadProcess, (IntPtr)iMemoryAddress, bBuffer, iTextLength, out ptrBytesRead);

            if (Unicode)
            {
                return(Encoding.Unicode.GetString(bBuffer));
            }
            else
            {
                return("");
            }
        }
コード例 #28
0
ファイル: Memory.cs プロジェクト: tecnojp/SF4ComboTrainer
        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("");
        }