Questions tagged [setwindowshookex]

Use this tag to better reference questions related to SetWindowsHookEx. This function installs an application-defined hook procedure into a hook chain.

Installs an application-defined hook procedure into a hook chain. You would install a hook procedure to monitor the system for certain types of events. These events are associated either with a specific thread or with all threads in the same desktop as the calling thread.

C# Syntax

HHOOK WINAPI SetWindowsHookEx(
  _In_ int       idHook,
  _In_ HOOKPROC  lpfn,
  _In_ HINSTANCE hMod,
  _In_ DWORD     dwThreadId
);

To find more informatoin :

241 questions
7
votes
1 answer

How to Modify Import Address Table for Run time Loaded DLL

I want to hook functions that are called from a loaded DLL on Run time, i used the class CAPIHook from the book "Windows Via C/C++" (the DLL Injecting done by Install System Wide hook and The hooking by Modify IAT) but this code work only if the DLL…
Wajdy Essam
  • 4,280
  • 3
  • 28
  • 33
6
votes
1 answer

C# low level mouse hook and form event handling

I'm using a simple form generated by VS 2010 which contains 2 buttons, start and stop. Start triggers WH_MOUSE_LL using SetWindowsHookEx, and stop stops the hook. The hook works fine and I mange to "replace" middle mouse button click with double…
Alex
  • 61
  • 2
6
votes
2 answers

Window hooks in c#

Im trying to hook up to other windows from csharp. Im using SetWindowsHookEx, but no luck with converting it fom c++ t c#. I found this thread here but it wasnt solved. The problem is that SetWindowsHookEx returns 0. It includes best code samle i…
b0xer
  • 153
  • 1
  • 2
  • 4
6
votes
1 answer

Windows Global Keyboard Hook - Delphi

I've created a GLOBAL keyboard hook DLL, using source code found on the internet. For the best part it works brilliant, except when it comes to browsers. It picks up every key in the browser except, it seems, when the browser gets focus, it looses…
Paul
  • 157
  • 1
  • 2
  • 14
6
votes
3 answers

C++ SetWindowsHookEx WH_KEYBOARD_LL Correct Setup

I'm creating a console application in which I'd like to record key presses (like the UP ARROW). I've created a Low Level Keyboard Hook that is supposed to capture all Key Presses in any thread and invoke my callback function, but it isn't working.…
Mahir
  • 63
  • 1
  • 1
  • 4
5
votes
1 answer

Low level keyboard hook set with SetWindowsHookEx stops calling function in C#

I am creating a program that monitors key presses for controlling iTunes globally. It also has a few WinForms (for displaying track information and editing options). The low-level keyboard hook works great for awhile. If I just start up the program,…
5
votes
2 answers

Low level keyboard hook not being called in .NET application

I am writing a keylogger in C# but am having some trouble getting my hook method called from the keyboard events. My code appears correct but for some reason the callback is not happening. Here is the relevant code: [DllImport("user32.dll", CharSet…
5
votes
0 answers

Capturing touch events with LowLevelMouseProc does not work for all applications

tldr: i am using LowLevelMouseProc to capture all touch events from a touch screen. This works for my application and some other applications, but unfortunately not for all apps. Can someone explain me why? Complete story: I have a C# application…
piet
  • 51
  • 4
5
votes
3 answers

Module not found

I've been working on this one quite a bit and haven't gotten any closer to a solution. I juut dug up my old copy of the WindowsHookLib again - It's available with source at http://www.codeproject.com/KB/DLL/WindowsHookLib.aspx. This library allows…
TMP
  • 51
  • 1
  • 3
5
votes
2 answers

Unloading an Injected DLL

I have a DLL I inject into other processes using SetWindowsHookEx. Inside the DLL I increment the module's reference counter by calling GetModuleHandleEx so I can control when the module is unloaded. At this point the module reference count "should…
tdemay
  • 649
  • 8
  • 23
5
votes
0 answers

SetWindowsHookEx fails with error 1428

I try to hook into the start button by the following code. // Create an instance of HookProc. StartHookProcedure = new CallBack(StartHookProc); IntPtr desktop = FindWindowEx( IntPtr.Zero, IntPtr.Zero, "Progman", null); uint procId…
Marco Klein
  • 683
  • 5
  • 19
5
votes
1 answer

Error when using SetWindowsHookEx in Windows XP, but not in Windows 7

I have develop a application that use a global keybord/mouse hook. It works perfect in Windows 7, but not in Windows XP. When I call SetWindowsHookEx in Windows XP, I get error code 1428 int MouseLowLevel = 14 int code =…
magol
  • 6,135
  • 17
  • 65
  • 120
4
votes
1 answer

Questions about SetWindowsHookEx() and hooking

Here is a little background information. I'm working on replacing a dll that has been used in a dll injection technique via the AppInit_DLLs registry entry. Its purpose was to be present in every process and set hooks into the GDI32.dll to gather…
Ultratrunks
  • 2,464
  • 5
  • 28
  • 48
4
votes
1 answer

Get HMENU from HWND within a Hook

I'm installing a hook within my application to get the standard EDIT context menu (with undo/copy/edit/paste/etc.). I need to insert a new menu item for my application. I've set a windows hook, but I can't seem to get the HMENU for the context menu.…
jubican
  • 43
  • 1
  • 3
4
votes
0 answers

How to check if SetWindowsHookEx hook is still working? (Win7 bug workaround)

I am writing a program in MS VisualC++. I set a keyboard hook by hHook = SetWindowsHookEx(13,MyProc,GetModuleHandle(NULL),0);. There is a bug in Win7, which I can reproduce, that disables my hook. When this bug happens, hHook is still TRUE, but…
1
2
3
16 17