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(); }
public void Close() { if (MemoryAPI.CloseHandle(m_hProcess) == 0) { throw new Exception("Failed to close process"); } }
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); }
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"); } }
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); }
public void SendMessage(MessageType message, int wParam, int lParam) { MemoryAPI.SendMessage(m_ReadProcess.MainWindowHandle, (int)message, wParam, lParam); }
public void BringToFront() { MemoryAPI.SetForegroundWindow(m_ReadProcess.MainWindowHandle); }