Esempio n. 1
0
 public byte[] Read(IntPtr MemoryAddress, uint bytesToRead, out int bytesRead)
 {
     byte[] buffer = new byte[bytesToRead];
     IntPtr ptrBytesRead;
     MemoryAPI.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesRead);
     bytesRead = ptrBytesRead.ToInt32();
     return buffer;
 }
Esempio n. 2
0
    public byte[] PointerRead(IntPtr MemoryAddress, uint bytesToRead, int[] Offset, out int bytesRead)
    {
        int    iPointerCount = Offset.Length - 1;
        IntPtr ptrBytesRead;

        bytesRead = 0;
        byte[] buffer      = new byte[4]; //DWORD to hold an Address
        int    tempAddress = 0;

        if (iPointerCount == 0)
        {
            MemoryAPI.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, 4, out ptrBytesRead);
            tempAddress = Addr.ToDec(Addr.Make(buffer)) + Offset[0]; //Final Address

            buffer = new byte[bytesToRead];
            MemoryAPI.ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, bytesToRead, out ptrBytesRead);

            bytesRead = ptrBytesRead.ToInt32();
            return(buffer);
        }

        for (int i = 0; i <= iPointerCount; i++)
        {
            if (i == iPointerCount)
            {
                MemoryAPI.ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out ptrBytesRead);
                tempAddress = Addr.ToDec(Addr.Make(buffer)) + Offset[i]; //Final Address

                buffer = new byte[bytesToRead];
                MemoryAPI.ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, bytesToRead, out ptrBytesRead);

                bytesRead = ptrBytesRead.ToInt32();
                return(buffer);
            }
            else if (i == 0)
            {
                MemoryAPI.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, 4, out ptrBytesRead);
                tempAddress = Addr.ToDec(Addr.Make(buffer)) + Offset[1];
            }
            else
            {
                MemoryAPI.ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out ptrBytesRead);
                tempAddress = Addr.ToDec(Addr.Make(buffer)) + Offset[i];
            }
        }

        return(buffer);
    }
Esempio n. 3
0
    public string PointerWrite(IntPtr MemoryAddress, byte[] bytesToWrite, int[] Offset, out int bytesWritten)
    {
        int    iPointerCount = Offset.Length - 1;
        IntPtr ptrBytesWritten;

        bytesWritten = 0;
        byte[] buffer      = new byte[4]; //DWORD to hold an Address
        int    tempAddress = 0;

        if (iPointerCount == 0)
        {
            MemoryAPI.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, 4, out ptrBytesWritten);
            tempAddress = Addr.ToDec(Addr.Make(buffer)) + Offset[0]; //Final Address
            MemoryAPI.WriteProcessMemory(m_hProcess, (IntPtr)tempAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);

            bytesWritten = ptrBytesWritten.ToInt32();
            return(Addr.ToHex(tempAddress));
        }

        for (int i = 0; i <= iPointerCount; i++)
        {
            if (i == iPointerCount)
            {
                MemoryAPI.ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out ptrBytesWritten);
                tempAddress = Addr.ToDec(Addr.Make(buffer)) + Offset[i]; //Final Address
                MemoryAPI.WriteProcessMemory(m_hProcess, (IntPtr)tempAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);

                bytesWritten = ptrBytesWritten.ToInt32();
                return(Addr.ToHex(tempAddress));
            }
            else if (i == 0)
            {
                MemoryAPI.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, 4, out ptrBytesWritten);
                tempAddress = Addr.ToDec(Addr.Make(buffer)) + Offset[i];
            }
            else
            {
                MemoryAPI.ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out ptrBytesWritten);
                tempAddress = Addr.ToDec(Addr.Make(buffer)) + Offset[i];
            }
        }

        return(Addr.ToHex(tempAddress));
    }