public static void Click(IntPtr handle, PredefinedTypes.MouseButtons btn, params Point[] position) { foreach (var t in position) { switch (btn) { case PredefinedTypes.MouseButtons.MouseLeft: Interop.SendMessage(handle, (uint)Interop.WMessages.Lbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); Interop.SendMessage(handle, (uint)Interop.WMessages.Lbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseRight: Interop.SendMessage(handle, (uint)Interop.WMessages.Rbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); Interop.SendMessage(handle, (uint)Interop.WMessages.Rbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseMiddle: Interop.SendMessage(handle, (uint)Interop.WMessages.Mbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); Interop.SendMessage(handle, (uint)Interop.WMessages.Mbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseLeftDown: Interop.SendMessage(handle, (uint)Interop.WMessages.Lbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseLeftUp: Interop.SendMessage(handle, (uint)Interop.WMessages.Lbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseRightDown: Interop.SendMessage(handle, (uint)Interop.WMessages.Rbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseRightUp: Interop.SendMessage(handle, (uint)Interop.WMessages.Rbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseMiddleDown: Interop.SendMessage(handle, (uint)Interop.WMessages.Mbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseMiddleUp: Interop.SendMessage(handle, (uint)Interop.WMessages.Mbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; } } }
/// <summary> /// Read an Byte out of memory (byte without -/+) /// </summary> /// <param name="address">The target address</param> /// <returns>The data you want (1 byte)</returns> public Byte ReadByte <T>(T address) { var adr = CastToIntPtr(address); var data = Interop.ReadProcessMemoryHelper(Handle, adr, 1)[0]; return(data); }
public static void PressKey(IntPtr handle, Interop.WMessages msg, params Keys[] keys) { foreach (var k in keys) { Interop.SendMessage(handle, (uint)msg, (IntPtr)k, IntPtr.Zero); } }
/// <summary> /// Read an unsigned long (UInt64) out of memory (with -/+) /// </summary> /// <param name="address">The target address</param> /// <returns>The data you want (8 bytes)</returns> public UInt64 ReadUInt64 <T>(T address) { var adr = CastToIntPtr(address); var data = BitConverter.ToUInt64(Interop.ReadProcessMemoryHelper(Handle, adr, 8), 0); return(data); }
/// <summary> /// Writes an UInt64 at a specific address into memory. /// </summary> /// <typeparam name="T">Type of address</typeparam> /// <param name="address">The actual address to write at</param> /// <param name="input">The data you want to put into memory</param> /// <returns>True/ False if the writing was successful or not</returns> public Boolean WriteUInt64 <T>(T address, UInt64 input) { var adr = CastToIntPtr(address); var byteBuffer = BitConverter.GetBytes(input); return(Interop.WriteProcessMemoryHelper(Handle, adr, byteBuffer)); }
/// <summary> /// Writes a String at a specific address into memory. /// </summary> /// <typeparam name="T">Type of address</typeparam> /// <param name="address">The actual address to write at</param> /// <param name="input">The data you want to put into memory</param> /// <param name="enc">The kind of encoding used to convert the string into a bytebuffer</param> /// <returns>True/ False if the writing was successful or not</returns> public Boolean WriteString <T>(T address, string input, Encoding enc) { var adr = CastToIntPtr(address); var byteBuffer = enc.GetBytes(input); return(Interop.WriteProcessMemoryHelper(Handle, adr, byteBuffer)); }
/// <summary> /// This will press an undefined amount of keys. /// The first key gets pressed and released, then the next key. /// </summary> /// <param name="handle">The target handle</param> /// <param name="key">The key you wish to use</param> public static void PressKeysOneByOne(IntPtr handle, params Keys[] key) { foreach (var t in key) { Interop.SendMessage(handle, (uint)Interop.WMessages.Keydown, (IntPtr)t, (IntPtr)Interop.WMessages.Keyup); } }
/// <summary> /// Read an int (Int32) out of memory (with -/+) /// </summary> /// <param name="address">The target address</param> /// <returns>The data you want (4 bytes)</returns> public Int32 ReadInt32 <T>(T address) { var adr = CastToIntPtr(address); var data = BitConverter.ToInt32(Interop.ReadProcessMemoryHelper(Handle, adr, 4), 0); return(data); }
/// <summary> /// Unlocks the process' handle to make it possible to read from that process! /// </summary> /// <param name="process">The process you want to crack</param> /// <param name="desiredAccess">The required Access (like VM_READ)</param> public void UnlockProcess(int desiredAccess, Process process = null) { if (process == null) { process = Process; } Handle = Interop.OpenProcess(desiredAccess, true, process.Id); }
/// <summary> /// Reads a chunk out of memory which has to be manipulated afterwards. /// </summary> /// <param name="address">The target address</param> /// <param name="size">The size (length) of data you want to read</param> /// <returns>The chunk you want out of memory</returns> public Byte[] ReadMemory <T>(T address, int size) { var adr = CastToIntPtr(address); var data = new byte[size]; data = Interop.ReadProcessMemoryHelper(Handle, adr, size); return(data); }
public static void Keyboard_SimulateKey(IntPtr handle, Keys key, Int32 times) { for (var i = 0; i < times; i++) { /* Key Down */ Interop.SendMessage(handle, (uint)Interop.WMessages.Keydown, (IntPtr)key, IntPtr.Zero); /* Key Up */ Interop.SendMessage(handle, (uint)Interop.WMessages.Keyup, (IntPtr)key, IntPtr.Zero); Thread.Sleep(1); } }
/// <summary> /// This will press (and hold) an undefined amount of keys. /// The keypress will begin with the first item and end with the last item. /// The keydown will begin with the last item and end with the first item. /// </summary> /// <param name="handle">The target handle</param> /// <param name="key">The key you wish to use</param> public static void PressKeysDownAndUpAsync(IntPtr handle, params Keys[] key) { foreach (var t in key) { Interop.SendMessage(handle, (uint)Interop.WMessages.Keydown, (IntPtr)t, IntPtr.Zero); } for (var i = key.Length - 1; i >= 0; i--) { Interop.SendMessage(handle, (uint)Interop.WMessages.Keyup, (IntPtr)key[i], IntPtr.Zero); } }
public void SelectGroup(GroupSelection group) { if (_myMethod.Equals(AutomationMethods.SendMessage)) { Interop.SendMessage(_myHandle, (uint)Interop.WMessages.Keydown, (IntPtr)group, IntPtr.Zero); Interop.SendMessage(_myHandle, (uint)Interop.WMessages.Keyup, (IntPtr)group, IntPtr.Zero); } else if (_myMethod.Equals(AutomationMethods.PostMessage)) { Interop.PostMessage(_myHandle, (uint)Interop.WMessages.Keydown, (IntPtr)group, IntPtr.Zero); Interop.PostMessage(_myHandle, (uint)Interop.WMessages.Keyup, (IntPtr)group, IntPtr.Zero); } }
/// <summary> /// This will press (and hold) an undefined amount of keys. /// The keypress will begin with the first item and end with the last item. /// The keydown will begin with the first item and end with the last item. /// </summary> /// <param name="handle">The target handle</param> /// <param name="key">The key you wish to use</param> public static void PressKeysDownAndUpSync(IntPtr handle, params Keys[] key) { foreach (var t in key) { Interop.SendMessage(handle, (uint)Interop.WMessages.Keydown, (IntPtr)t, IntPtr.Zero); } foreach (var t in key) { Interop.SendMessage(handle, (uint)Interop.WMessages.Keyup, (IntPtr)t, IntPtr.Zero); } }
public static void Keyboard_SimulateKeys(IntPtr handle, List <Keys> keys) { /* Key Down */ foreach (var t in keys) { Interop.SendMessage(handle, (uint)Interop.WMessages.Keydown, (IntPtr)t, IntPtr.Zero); } /* Key Up */ foreach (var t in keys) { Interop.SendMessage(handle, (uint)Interop.WMessages.Keyup, (IntPtr)t, IntPtr.Zero); } }
public void PerformCompleteKeypress(Keys key) { if (_myMethod.Equals(AutomationMethods.SendMessage)) { Interop.SendMessage(_myHandle, (uint)Interop.WMessages.Keydown, (IntPtr)key, IntPtr.Zero); Interop.SendMessage(_myHandle, (uint)Interop.WMessages.Keyup, (IntPtr)key, IntPtr.Zero); } else if (_myMethod.Equals(AutomationMethods.PostMessage)) { Interop.PostMessage(_myHandle, (uint)Interop.WMessages.Keydown, (IntPtr)key, IntPtr.Zero); Interop.PostMessage(_myHandle, (uint)Interop.WMessages.Keyup, (IntPtr)key, IntPtr.Zero); } }
/// <summary> /// Reunlocks the Handle. Surely closes the first handle and opens it with a neat new access- level (to write memory) /// </summary> /// <param name="desiredAccess">The level of access you want to give the process</param> /// <param name="process">The process you want to crack</param> public void ReUnlockProcess(int desiredAccess = 0, Process process = null) { if (desiredAccess == 0) { desiredAccess = DesiredAccess; } if (process == null) { process = Process; } if (process == null) { return; } if (Handle != null) { Interop.CloseHandle(Handle); } Handle = Interop.OpenProcess(desiredAccess, true, process.Id); }
public static void Keyboard_SimulateKey(IntPtr handle, Keys key) { Interop.SendMessage(handle, (uint)Interop.WMessages.Keydown, (IntPtr)key, (IntPtr)Interop.WMessages.Keyup); }
/// <summary> /// Writes a chunk of data at a specific address into memory. /// </summary> /// <typeparam name="T">Type of address</typeparam> /// <param name="address">The actual address to write at</param> /// <param name="input">The data you want to put into memory</param> /// <returns>True/ False if the writing was successful or not</returns> public Boolean WriteMemory <T>(T address, Byte[] input) { var adr = CastToIntPtr(address); return(Interop.WriteProcessMemoryHelper(Handle, adr, input)); }