Note that there are some explanatory texts on larger screens.

plurals
  1. POGlobal Hook Keylogger problem
    primarykey
    data
    text
    <p>It logs the keys to textbox currently so its safe.</p> <p>PROBLEM The problem is when i run this at virtual machine, or my friends laptop, it hangs after pressing certain amount of keys(random).It runs perfectly fine in mine.</p> <p><a href="http://i34.tinypic.com/29o1im8.jpg" rel="noreferrer">http://i34.tinypic.com/29o1im8.jpg</a></p> <pre><code>class GlobalKeyboardHook { #region Definition of Structures, Constants and Delegates public delegate int KeyboardHookProc(int nCode, int wParam, ref GlobalKeyboardHookStruct lParam); public struct GlobalKeyboardHookStruct { public int vkCode; public int scanCode; public int flags; public int time; public int dwExtraInfo; } const int WM_KEYDOWN = 0x100; const int WM_KEYUP = 0x101; const int WM_SYSKEYDOWN = 0x104; const int WM_SYSKEYUP = 0x105; const int WH_KEYBOARD_LL = 13; #endregion #region Events public event KeyEventHandler KeyDown; public event KeyEventHandler KeyUp; #endregion #region Instance Variables public List&lt;Keys&gt; HookedKeys = new List&lt;Keys&gt;(); IntPtr hookHandle = IntPtr.Zero; #endregion #region DLL Imports [DllImport("kernel32.dll")] static extern IntPtr LoadLibrary(string lpFileName); [DllImport("user32.dll", CharSet = CharSet.Auto,CallingConvention = CallingConvention.StdCall, SetLastError = true)] static extern IntPtr SetWindowsHookEx(int hookID, KeyboardHookProc callback, IntPtr hInstance, uint threadID); [DllImport("user32.dll", CharSet = CharSet.Auto,CallingConvention = CallingConvention.StdCall, SetLastError = true)] static extern bool UnhookWindowsHookEx(IntPtr hookHandle); [DllImport("user32.dll", CharSet = CharSet.Auto,CallingConvention = CallingConvention.StdCall)] static extern int CallNextHookEx(IntPtr hookHandle, int nCode, int wParam, ref GlobalKeyboardHookStruct lParam); #endregion #region Public Methods public int hookProc(int nCode, int wParam, ref GlobalKeyboardHookStruct lParam) { if (nCode &gt;= 0) { Keys key = (Keys)lParam.vkCode; if (HookedKeys.Contains(key) == true) { KeyEventArgs kea = new KeyEventArgs(key); if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) &amp;&amp; KeyUp != null) { KeyUp(this, kea); } else if ((wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) &amp;&amp; KeyDown != null) { KeyDown(this, kea); } if (kea.Handled) return 1; } } return CallNextHookEx(hookHandle, nCode, wParam, ref lParam); } public void hook() { IntPtr hInstance = LoadLibrary("user32"); hookHandle = SetWindowsHookEx(WH_KEYBOARD_LL, hookProc, hInstance, 0); } public void unhook() { UnhookWindowsHookEx(hookHandle); } #endregion #region Constructors and Destructors public GlobalKeyboardHook() { hook(); } ~GlobalKeyboardHook() { unhook(); } #endregion </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload