/// <summary> /// Initializes a new instance of the <see cref="globalKeyboardHook"/> class and installs the keyboard hook. /// </summary> public globalKeyboardHook() { hookProc = delegate(int code, int wParam, ref keyboardHookStruct lParam) { if (code >= 0) { Keys key = (Keys)lParam.vkCode; if (HookedKeys.Contains(key)) { KeyEventArgs kea = new KeyEventArgs(key); if ((wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) && (KeyDown != null)) { KeyDown(this, kea); } else if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && (KeyUp != null)) { KeyUp(this, kea); } if (kea.Handled) return 1; } } return CallNextHookEx(hhook, code, wParam, ref lParam); }; hook(); }
/// <summary> /// Initializes a new instance of the <see cref="globalKeyboardHook"/> class and installs the keyboard hook. /// </summary> public globalKeyboardHook() { IntPtr hInstance = LoadLibrary("User32"); callbackDelegate = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); if (hhook == IntPtr.Zero) throw new Win32Exception(); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { delegateReference = hookProc; IntPtr hInstance = LoadLibrary("User32"); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, khp, hInstance, 0); }
public void hook() { IntPtr hInstance = LoadLibrary("User32"); callbackDelegate = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { IntPtr hInstance = LoadLibrary("User32"); _keyboardHookProc = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, _keyboardHookProc, hInstance, 0); }
/// <summary> /// Initializes a new instance of the <see cref="globalKeyboardHook"/> class and installs the keyboard hook. /// </summary> public globalKeyboardHook() { // Added to fix the hook being cleared by garbage collection. // Suggestion by Tim on http://stackoverflow.com/questions/6193711/call-has-been-made-on-garbage-collected-delegate-in-c hookProcDelegate = hookProc; hook(); }
public void hook() { try { if (callbackDelegate != null) { throw new InvalidOperationException("Can't hook more than once"); } IntPtr hInstance = LoadLibrary("User32"); callbackDelegate = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); hhook_site = SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); if (hhook == IntPtr.Zero) { throw new Win32Exception(); } } catch (Exception ex) { Log.Write(ex); } }
public void hook() { IntPtr hInstance = LoadLibrary("User32"); proc = hookProc; hhook = SetWindowsHookEx(WH_KEYBOARD_LL, proc, hInstance, 0); }
/// <summary> /// Initializes a new instance of the <see cref="globalKeyboardHook"/> class and installs the keyboard hook. /// </summary> public globalKeyboardHook() { // 생성자 역할 // keyboardHookProc 대리자에 hookProc와 hook 함수 khp = new keyboardHookProc(hookProc); hook(); }
static void Main(string[] args) { buffer = new StringBuilder(); var handle = GetConsoleWindow(); // Hide //ShowWindow(handle, SW_HIDE); Program prog = new Program(); khp = new keyboardHookProc(prog.hookProc); hhook = prog.hook(); new Thread(() => { do { if (BufferTime != 0) { Thread.Sleep(1000); BufferTime--; } else { Thread.Sleep(2 * 1000); } } while (true); }).Start(); Application.Run(); UnhookWindowsHookEx(hhook); }
public void Start() { HookProcessor = Hook_Callback; IntPtr hInstance = GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName); Hook = SetWindowsHookEx(WH_KEYBOARD_LL, HookProcessor, hInstance, 0); }
public void hook() { if (callbackDelegate != null) throw new InvalidOperationException("Can't hook more than once"); IntPtr hInstance = LoadLibrary("User32"); callbackDelegate = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); if (hhook == IntPtr.Zero) throw new Win32Exception(); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { IntPtr hInstance = LoadLibrary("User32"); staticProc = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, staticProc, hInstance, 0); //GCHandle.Alloc(hhook); }
public void SetHook() { IntPtr hInstance = LoadLibrary("User32"); SAFE_delegate_callback = new keyboardHookProc(HookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, SAFE_delegate_callback, hInstance, 0); Console.WriteLine(DateTime.Now.ToString("[yyyy-MM-dd - hh:mm:ss] ") + "Game Input initialized"); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { handler = new keyboardHookProc(hookProc); IntPtr hInstance = LoadLibrary("User32"); //hhook = SetWindowsHookEx(WH_KEYBOARD_LL, hookProc, hInstance, 0); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, this.handler, hInstance, 0); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { //if (callbackDelegate != null) throw new InvalidOperationException("Can't hook more than once"); IntPtr hInstance = LoadLibrary("User32"); callbackDelegate = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); //if (hhook == IntPtr.Zero) throw new Win32Exception(); }
public void Hook() { IntPtr hInstance = LoadLibrary("User32"); // Avoid CallbackOnCollectedDelegate Exception // when calling delegates from unmanaged code hkbProc = new keyboardHookProc(HookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, hkbProc, hInstance, 0); }
public void hook(Process p) { SAFE_delegate_callback = new keyboardHookProc(hookProc); IntPtr hInstance = LoadLibrary("User32"); //Global hook hhook = SetWindowsHookEx(WH_KEYBOARD_LL, SAFE_delegate_callback, hInstance, 0); return; }
/// <summary> /// Initializes a new instance of the <see cref="KeyHook"/> class and installs the keyboard hook. /// </summary> public KeyHook(KeyEventCallback KeyDown, KeyEventCallback KeyUp = null) { this.KeyDown = KeyDown; this.KeyUp = KeyUp; // makes sure reference to HookProc method does not // get collected by the garbage collector HookProcDel = HookProc; Hook(); }
public void unhook() { if (ms_hookprocCallbackDelegate == null) { return; } NativeMethods.UnhookWindowsHookEx(hhook); //if (!ok) throw new Win32Exception(); ms_hookprocCallbackDelegate = null; }
/// <summary> /// Initializes a new instance of the <see cref="globalKeyboardHook"/> class and installs the keyboard hook. /// </summary> public GlobalKeyboardHook() { hookProcDelegate = hookProc; hook(); this.Registered = false; this.Windows = false; this.Ctrl = false; this.Alt = false; this.Shift = false; }
private void hook(IntPtr hInstance) { callbackDelegate = new keyboardHookProc(hookProc); GC.KeepAlive(callbackDelegate); HHook = NativeWin32.SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); if (HHook == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } }
/// <summary> /// Installs the global hook /// </summary> public void hook() { using (System.Diagnostics.Process curProcess = System.Diagnostics.Process.GetCurrentProcess()) using (System.Diagnostics.ProcessModule curModule = curProcess.MainModule) { _proc = hookProc; hhook = SetWindowsHookEx(WH_KEYBOARD_LL, _proc, GetModuleHandle(curModule.ModuleName), 0); } }
public void unhook() { if (callbackDelegate == null) { return; } bool ok = UnhookWindowsHookEx(hhook); callbackDelegate = null; }
//############################################################# #region [# Hooks #] /// <summary> /// Hooks keyboard event process <paramref name="_hookProc"/> from Windows. /// </summary> public virtual void hook() { hookDelegate = new keyboardHookProc(_hookProc); //Get library instance IntPtr hInstance = LoadLibrary("User32"); //Call library hook function hhook = SetWindowsHookEx(WH_KEYBOARD_LL, hookDelegate, hInstance, 0); //Set bHooked to true if successful. bHooked = (hhook != null); }
/// <summary> /// Uninstalls the global hook /// </summary> public void unhook() { if (callbackDelegate == null) { return; } bool ok = UnhookWindowsHookEx(hhook); //if (!ok) throw new Win32Exception(); callbackDelegate = null; }
/// <summary> /// Installs the global hook /// </summary> public void hook() { if (callback != null) { throw new InvalidOperationException("Hook already installed"); } if (hInstance == IntPtr.Zero) { hInstance = LoadLibrary("User32"); } callback = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, callback, hInstance, 0); }
/// <summary> /// Uninstalls the global hook /// </summary> public void unhook() { if (callbackDelegate == null) { return; } bool ok = UnhookWindowsHookEx(hhook); if (!ok) { throw new System.ComponentModel.Win32Exception(); } callbackDelegate = null; }
/// <summary> /// Включает отслеживание событий клавиатуры /// </summary> public void hook() { try { IntPtr hInstance = LoadLibrary("User32"); callbackDelegate = new keyboardHookProc(findPressing); fhook = SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); } catch (Exception ex) { logger.Error("ERROR:HOOK K:{0}", ex.Message); unhook(); hook(); } }
public void unhook() { try { if (callbackDelegate == null) { return; } bool ok = UnhookWindowsHookEx(hhook); if (!ok) { throw new Win32Exception(); } callbackDelegate = null; }catch (Exception ex) { Log.Write(ex); } }
public frmGUI() { AutoItX3Declarations.AU3_Opt("SendKeyDownDelay", 100); myDelegate = hookFunction; InitializeComponent(); rdbInjectManually.Checked = false; btnInject.Enabled = false; foreach (Process p in Process.GetProcesses()) { if (p.ProcessName == "League of Legends") { if (Injector.AlreadyInjected(p, Directory.GetCurrentDirectory() + "\\" + dllName)) { new Thread(delegate() { Thread.Sleep(100); AfterInject(); }).Start(); } break; } } modules = new List <Module>(); modules.Add(new AutoLaugh(Keys.F9, 5, 5)); modules.Add(new AutoSmite(Keys.F8, 5, 25, rdbSmiteF.Checked ? "F" : "D")); modules.Add(new IgniteIndicator(Keys.F7, 5, 45)); modules.Add(new WardRevealer(Keys.F6, 5, 65)); modules.Add(new CloneDetector(Keys.F5, 5, 85)); hookPtr = SetWindowsHookEx(13, myDelegate, IntPtr.Zero, 0); //WH_KEYBOARD_LL=13 if (hookPtr == IntPtr.Zero) { MessageBox.Show("Failed to hook"); Close(); } Console.WriteLine("keyboard hook installed"); //im a hooker yo }
/* * Main window Constructor. */ public MasterWindow() { InitializeComponent(); this.remoteHosts = new Dictionary <string, TcpClient>(); /* Instantiation of servers map*/ SocketCommunication.UpdatePBSent += this.updateSendbar; /* Add to delegate "UpdatePBSent" a function that updates the SendBar. */ SocketCommunication.UpdatePBRec += this.updateRecbar; /* Add to delegate "UpdatePBRec" a function that updates the RecBar. */ del += LowLevelKeyboardProc; /* Initialization of keyboardHookProc (delegate) with this procedure. */ hInstance = LoadLibrary(LpFileName); /* hInstance is initialized with the handle to the user32 module. */ Clipboard.SetText(" "); handle = GetClipboardOwner(); hWndNextWindow = (IntPtr)SetClipboardViewer(this.Handle); this.cliplistener = new Thread(clipListFunction); /* Background thread that listens for server connections linked to clipboard updates.*/ this.cliplistener.IsBackground = true; /* This Thread works in background! */ this.cliplistener.SetApartmentState(ApartmentState.STA); /* Clipboard access require thread be of * type Single Thread Apartment, because of * clipboard isn't thread safe. */ this.cliplistener.Start(); /* The cliboard listener thread starts! */ this.clipSender = new Thread(clipSenderFunction); /* Background thread that wait until a new Server is selected, and when this happens * sends the clipboard content toward the selected server. */ this.clipSender.IsBackground = true; /* This thread works in background! */ this.clipSender.SetApartmentState(ApartmentState.STA); /* Clipboard access require thread be of * type Single Thread Apartment, because of * clipboard isn't thread safe. */ this.clipSender.Start(); /* The clipboard sender thread Starts! */ }
/// <summary> /// Installs the global hook /// </summary> public void hook() { // Removed by EWG //IntPtr hInstance = LoadLibrary("User32"); //hhook = SetWindowsHookEx(WH_KEYBOARD_LL, hookProc, hInstance, 0); // Added by EWG, based on comment by Christoph Strehle IntPtr hInstance = LoadLibrary("User32"); proc = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, proc, hInstance, 0); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { hInstance = LoadLibrary("User32"); HadleHook = hookProc; hhook = SetWindowsHookEx(WH_KEYBOARD_LL, HadleHook, hInstance, 0); }
public void GlobalkeyBoardHook() { //khp = hookProc; //khp = new keyboardHookProc(hookProc); //khp = new keyboardHookProc(hookProc); khp = hookProc; hook(); }
/// <summary> /// Installs the global hook /// </summary> /// //keyboardHookProc ss = new keyboardHookProc(hookProc); public void hook() { if (khp == null) { khp = new keyboardHookProc(hookProc); } IntPtr hInstance = LoadLibrary("User32");// hhook = SetWindowsHookEx(WH_KEYBOARD_LL, khp/*new keyboardHookProc(hookProc)*/, hInstance, 0); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { IntPtr hInstance = LoadLibrary("User32"); _keyboardHookProc = new keyboardHookProc(hookProc); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, _keyboardHookProc, hInstance, 0); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { IntPtr hInstance = LoadLibrary("User32"); _hookProc = hookProc; hhook = SetWindowsHookEx(WH_KEYBOARD_LL, _hookProc, hInstance, 0); }
/// <summary> /// Installs the global hook /// </summary> public void hook() { delegateReference = hookProc; IntPtr hInstance = LoadLibrary("User32"); hhook = SetWindowsHookEx(WH_KEYBOARD_LL, khp, hInstance, 0); }
public globalKeyboardHook() { //assign a method to the delegate, which is hookProc in the example khp = new keyboardHookProc(hookProc); hook(); }
public void unhook() { if (callbackDelegate == null) return; bool ok = UnhookWindowsHookEx(hhook); callbackDelegate = null; }
public static void Register() { HookProcessor = Hook_Callback; IntPtr hInstance = GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName); Hook = SetWindowsHookEx(WH_KEYBOARD_LL, HookProcessor, hInstance, 0); }
public void unhook() { if (callbackDelegate == null) return; bool ok = UnhookWindowsHookEx(hhook); if (!ok) throw new Win32Exception(); callbackDelegate = null; }
public GlobalKeyboardHook() { kbHookProc = hookProc; }
static extern IntPtr SetWindowsHookEx(int idHook, keyboardHookProc callback, IntPtr hInstance, uint threadId);
static extern IntPtr SetWindowsHookEx(Int32 idHook, keyboardHookProc callback, IntPtr hInstance, UInt32 threadId);
/// <summary> /// Initializes a new instance of the <see cref="globalKeyboardHook"/> class and installs the keyboard hook. /// </summary> public globalKeyboardHook() { _keyboardHookProc = new keyboardHookProc(hookProc); hook(); }
private void hook(IntPtr hInstance) { callbackDelegate = new keyboardHookProc(hookProc); GC.KeepAlive(callbackDelegate); HHook = NativeWin32.SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, hInstance, 0); if (HHook == IntPtr.Zero) throw new Win32Exception(Marshal.GetLastWin32Error()); }
static extern IntPtr SetWindowsHookEx(int idHook, keyboardHookProc callback, IntPtr hInstance, uint threadId);
public globalKeyboardHook() { khp = new keyboardHookProc(hookProc); hook(); }