public static Matrix ReadMatrix(Int64 _lpBaseAddress) { Matrix tmp = new Matrix(); byte[] Buffer = new byte[64]; IntPtr ByteRead; Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, 64, out ByteRead); tmp.M11 = BitConverter.ToSingle(Buffer, (0 * 4)); tmp.M12 = BitConverter.ToSingle(Buffer, (1 * 4)); tmp.M13 = BitConverter.ToSingle(Buffer, (2 * 4)); tmp.M14 = BitConverter.ToSingle(Buffer, (3 * 4)); tmp.M21 = BitConverter.ToSingle(Buffer, (4 * 4)); tmp.M22 = BitConverter.ToSingle(Buffer, (5 * 4)); tmp.M23 = BitConverter.ToSingle(Buffer, (6 * 4)); tmp.M24 = BitConverter.ToSingle(Buffer, (7 * 4)); tmp.M31 = BitConverter.ToSingle(Buffer, (8 * 4)); tmp.M32 = BitConverter.ToSingle(Buffer, (9 * 4)); tmp.M33 = BitConverter.ToSingle(Buffer, (10 * 4)); tmp.M34 = BitConverter.ToSingle(Buffer, (11 * 4)); tmp.M41 = BitConverter.ToSingle(Buffer, (12 * 4)); tmp.M42 = BitConverter.ToSingle(Buffer, (13 * 4)); tmp.M43 = BitConverter.ToSingle(Buffer, (14 * 4)); tmp.M44 = BitConverter.ToSingle(Buffer, (15 * 4)); return(tmp); }
// Update Thread private void Update(object sender) { while (true) { if (keys.Count > 0) { List <Key> keysData = new List <Key>(keys.Values); if (keysData != null && keysData.Count > 0) { foreach (Key key in keysData) { if (Convert.ToBoolean(Managed.GetKeyState(key.Id) & Managed.KEY_PRESSED)) { if (!key.IsKeyDown) { key.IsKeyDown = true; OnKeyDown(key.Id, key.Name); } } else { if (key.IsKeyDown) { key.IsKeyDown = false; OnKeyUp(key.Id, key.Name); } } } } } Thread.Sleep(interval); } }
private void Update(object sender) { while (true) { if (this.keys.Count > 0) { List <Key> list = new List <Key>(this.keys.Values); if ((list != null) && (list.Count > 0)) { foreach (Key key in list) { if (Convert.ToBoolean((int)(Managed.GetKeyState(key.Id) & 0x8000))) { if (!key.IsKeyDown) { key.IsKeyDown = true; this.OnKeyDown(key.Id, key.Name); } } else if (key.IsKeyDown) { key.IsKeyDown = false; this.OnKeyUp(key.Id, key.Name); } } } } Thread.Sleep(this.interval); } }
protected override void OnResize(EventArgs e) { int[] numArray1 = new int[4]; numArray1[2] = this.rect.Width; numArray1[3] = this.rect.Height; int[] pMargins = numArray1; Managed.DwmExtendFrameIntoClientArea(base.Handle, ref pMargins); }
public static byte ReadByte(Int64 _lpBaseAddress) { byte[] Buffer = new byte[sizeof(byte)]; IntPtr ByteRead; Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, sizeof(byte), out ByteRead); return(Buffer[0]); }
public static float ReadFloat(Int64 _lpBaseAddress) { byte[] Buffer = new byte[sizeof(float)]; IntPtr ByteRead; Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, sizeof(float), out ByteRead); return(BitConverter.ToSingle(Buffer, 0)); }
public static Int32 ReadInt32(Int64 _lpBaseAddress) { byte[] Buffer = new byte[4]; IntPtr ByteRead; Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, 4, out ByteRead); return(BitConverter.ToInt32(Buffer, 0)); }
public static string ReadString2(Int64 _lpBaseAddress, UInt64 _Size) { byte[] buffer = new byte[_Size]; IntPtr BytesRead; Managed.ReadProcessMemory(pHandle, _lpBaseAddress, buffer, _Size, out BytesRead); return(Encoding.ASCII.GetString(buffer)); }
public static bool WriteMemory(Int64 MemoryAddress, byte[] Buffer) { uint oldProtect; Managed.VirtualProtectEx(pHandle, (IntPtr)MemoryAddress, (uint)Buffer.Length, Managed.PAGE_READWRITE, out oldProtect); IntPtr ptrBytesWritten; return(Managed.WriteProcessMemory(pHandle, MemoryAddress, Buffer, (uint)Buffer.Length, out ptrBytesWritten)); }
public static Vector2 ReadVector2(Int64 _lpBaseAddress) { Vector2 tmp = new Vector2(); byte[] Buffer = new byte[8]; IntPtr ByteRead; Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, 8, out ByteRead); tmp.X = BitConverter.ToSingle(Buffer, (0 * 4)); tmp.Y = BitConverter.ToSingle(Buffer, (1 * 4)); return(tmp); }
public Overlay(Process process) { this.process = process; this.handle = base.Handle; int windowLong = Managed.GetWindowLong(base.Handle, -20); Managed.SetWindowLong(base.Handle, -20, (windowLong | 0x80000) | 0x20); IntPtr hWndInsertAfter = new IntPtr(-1); Managed.SetWindowPos(base.Handle, hWndInsertAfter, 0, 0, 0, 0, 3); this.OnResize(null); this.InitializeComponent(); }
public static AxisAlignedBox ReadAABB(Int64 _lpBaseAddress) { AxisAlignedBox tmp = new AxisAlignedBox(); byte[] Buffer = new byte[32]; IntPtr ByteRead; Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, 32, out ByteRead); tmp.Min.X = BitConverter.ToSingle(Buffer, (0 * 4)); tmp.Min.Y = BitConverter.ToSingle(Buffer, (1 * 4)); tmp.Min.Z = BitConverter.ToSingle(Buffer, (2 * 4)); tmp.Max.X = BitConverter.ToSingle(Buffer, (4 * 4)); tmp.Max.Y = BitConverter.ToSingle(Buffer, (5 * 4)); tmp.Max.Z = BitConverter.ToSingle(Buffer, (6 * 4)); return(tmp); }
public static string ReadString(Int64 _lpBaseAddress, UInt64 _Size) { byte[] buffer = new byte[_Size]; IntPtr BytesRead; Managed.ReadProcessMemory(pHandle, _lpBaseAddress, buffer, _Size, out BytesRead); for (int i = 0; i < buffer.Length; i++) { if (buffer[i] == 0) { byte[] _buffer = new byte[i]; Buffer.BlockCopy(buffer, 0, _buffer, 0, i); return(Encoding.ASCII.GetString(_buffer)); } } return(Encoding.ASCII.GetString(buffer)); }
private void SetWindow(object sender) { IntPtr ptr; Label_0000: ptr = IntPtr.Zero; ptr = Managed.FindWindow(null, "Rust"); if (ptr != IntPtr.Zero) { External_ESP_Base.RECT lpRect = new External_ESP_Base.RECT(); Managed.GetWindowRect(ptr, out lpRect); if (((lpRect.Left < 0) && (lpRect.Top < 0)) && ((lpRect.Right < 0) && (lpRect.Bottom < 0))) { this.IsMinimized = true; goto Label_0000; } this.IsMinimized = false; External_ESP_Base.RECT rect2 = new External_ESP_Base.RECT(); Managed.GetClientRect(ptr, out rect2); if ((this.rect.Width != (lpRect.Bottom - lpRect.Top)) && (this.rect.Width != (rect2.Right - rect2.Left))) { this.IsResize = true; } this.rect.Width = lpRect.Right - lpRect.Left; this.rect.Height = lpRect.Bottom - lpRect.Top; if ((Managed.GetWindowLong(ptr, Managed.GWL_STYLE) & Managed.WS_BORDER) != 0) { int num = lpRect.Bottom - lpRect.Top; this.rect.Height = rect2.Bottom - rect2.Top; this.rect.Width = rect2.Right - rect2.Left; int num2 = num - rect2.Bottom; int num3 = ((lpRect.Right - lpRect.Left) - rect2.Right) / 2; num2 -= num3; lpRect.Left += num3; lpRect.Top += num2; this.rect.Left = lpRect.Left; this.rect.Top = lpRect.Top; } Managed.MoveWindow(this.handle, lpRect.Left, lpRect.Top, this.rect.Width, this.rect.Height, true); } Thread.Sleep(300); goto Label_0000; }
// Init public Overlay(Process process) { this.process = process; this.handle = Handle; int initialStyle = Managed.GetWindowLong(this.Handle, -20); Managed.SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20); IntPtr HWND_TOPMOST = new IntPtr(-1); const UInt32 SWP_NOSIZE = 0x0001; const UInt32 SWP_NOMOVE = 0x0002; const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE; Managed.SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); OnResize(null); InitializeComponent(); }
public static IntPtr OpenProcess(int pId) { pHandle = Managed.OpenProcess(Managed.PROCESS_VM_READ | Managed.PROCESS_VM_WRITE | Managed.PROCESS_VM_OPERATION, false, pId); return(pHandle); }
// Set window style protected override void OnResize(EventArgs e) { int[] margins = new int[] { 0, 0, rect.Width, rect.Height }; Managed.DwmExtendFrameIntoClientArea(this.Handle, ref margins); }
public static void CloseProcess() { Managed.CloseHandle(pHandle); }
// Get Window Rect private void SetWindow(object sender) { while (true) { IntPtr targetWnd = IntPtr.Zero; targetWnd = Managed.FindWindow(null, "Battlefield™ 1"); if (targetWnd != IntPtr.Zero) { RECT targetSize = new RECT(); Managed.GetWindowRect(targetWnd, out targetSize); // Game is Minimized if (targetSize.Left < 0 && targetSize.Top < 0 && targetSize.Right < 0 && targetSize.Bottom < 0) { IsMinimized = true; continue; } // Reset IsMinimized = false; RECT borderSize = new RECT(); Managed.GetClientRect(targetWnd, out borderSize); int dwStyle = Managed.GetWindowLong(targetWnd, Managed.GWL_STYLE); int windowheight; int windowwidth; int borderheight; int borderwidth; if (rect.Width != (targetSize.Bottom - targetSize.Top) && rect.Width != (borderSize.Right - borderSize.Left)) { IsResize = true; } rect.Width = targetSize.Right - targetSize.Left; rect.Height = targetSize.Bottom - targetSize.Top; if ((dwStyle & Managed.WS_BORDER) != 0) { windowheight = targetSize.Bottom - targetSize.Top; windowwidth = targetSize.Right - targetSize.Left; rect.Height = borderSize.Bottom - borderSize.Top; rect.Width = borderSize.Right - borderSize.Left; borderheight = (windowheight - borderSize.Bottom); borderwidth = (windowwidth - borderSize.Right) / 2; //only want one side borderheight -= borderwidth; //remove bottom targetSize.Left += borderwidth; targetSize.Top += borderheight; rect.Left = targetSize.Left; rect.Top = targetSize.Top; } Managed.MoveWindow(handle, targetSize.Left, targetSize.Top, rect.Width, rect.Height, true); } Thread.Sleep(300); } }