コード例 #1
0
        public void Write(IntPtr address, byte[] buffer, out int bytesWritten)
        {
            IntPtr lpBytesWritten;

            MemoryAPI.WriteProcessMemory(m_hProcess, address, buffer, (uint)buffer.Length, out lpBytesWritten);
            bytesWritten = lpBytesWritten.ToInt32();
        }
コード例 #2
0
 public void Close()
 {
     if (MemoryAPI.CloseHandle(m_hProcess) == 0)
     {
         throw new Exception("Failed to close process");
     }
 }
コード例 #3
0
        public byte[] Read(IntPtr address, uint count, out int bytesRead)
        {
            byte[] buffer = new byte[count];
            IntPtr lpBytesRead;

            MemoryAPI.ReadProcessMemory(m_hProcess, address, buffer, count, out lpBytesRead);
            bytesRead = lpBytesRead.ToInt32();
            return(buffer);
        }
コード例 #4
0
 public void Open()
 {
     MemoryAPI.ProcessAccessType access = MemoryAPI.ProcessAccessType.PROCESS_VM_READ | MemoryAPI.ProcessAccessType.PROCESS_VM_WRITE | MemoryAPI.ProcessAccessType.PROCESS_VM_OPERATION;
     m_hProcess = MemoryAPI.OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id);
     if (m_hProcess == IntPtr.Zero)
     {
         throw new Exception("Failed to open process");
     }
 }
コード例 #5
0
        public int PointerWrite(IntPtr address, byte[] writeBuffer, int[] offset, out int bytesWritten)
        {
            int    pointerCount = offset.Length - 1;
            IntPtr lpBytesWritten;

            bytesWritten = 0;
            byte[] buffer      = new byte[4];
            int    tempAddress = 0;

            if (pointerCount == 0)
            {
                MemoryAPI.ReadProcessMemory(m_hProcess, address, buffer, 4, out lpBytesWritten);
                tempAddress = Address.ToDecimal(Address.Make(buffer)) + offset[0];
                MemoryAPI.WriteProcessMemory(m_hProcess, (IntPtr)tempAddress, writeBuffer, (uint)writeBuffer.Length, out lpBytesWritten);

                bytesWritten = lpBytesWritten.ToInt32();
                return(tempAddress);
            }

            for (int i = 0; i <= pointerCount; i++)
            {
                if (i == pointerCount)
                {
                    MemoryAPI.ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out lpBytesWritten);
                    tempAddress = Address.ToDecimal(Address.Make(buffer)) + offset[i];
                    MemoryAPI.WriteProcessMemory(m_hProcess, (IntPtr)tempAddress, writeBuffer, (uint)writeBuffer.Length, out lpBytesWritten);

                    bytesWritten = lpBytesWritten.ToInt32();
                    return(tempAddress);
                }
                else if (i == 0)
                {
                    MemoryAPI.ReadProcessMemory(m_hProcess, address, buffer, 4, out lpBytesWritten);
                    tempAddress = Address.ToDecimal(Address.Make(buffer)) + offset[i];
                }
                else
                {
                    MemoryAPI.ReadProcessMemory(m_hProcess, (IntPtr)address, buffer, 4, out lpBytesWritten);
                    tempAddress = Address.ToDecimal(Address.Make(buffer)) + offset[i];
                }
            }
            return(tempAddress);
        }
コード例 #6
0
 public void SendMessage(MessageType message, int wParam, int lParam)
 {
     MemoryAPI.SendMessage(m_ReadProcess.MainWindowHandle, (int)message, wParam, lParam);
 }
コード例 #7
0
 public void BringToFront()
 {
     MemoryAPI.SetForegroundWindow(m_ReadProcess.MainWindowHandle);
 }