Info on Hooks
-
Can somebody tell me what hooks are? Why are hooks used? When DisplatchMessage is called Does Window places a hook before passing to WndProc. Pls guide Tiger
-
Can somebody tell me what hooks are? Why are hooks used? When DisplatchMessage is called Does Window places a hook before passing to WndProc. Pls guide Tiger
-
Can somebody tell me what hooks are? Why are hooks used? When DisplatchMessage is called Does Window places a hook before passing to WndProc. Pls guide Tiger
Win32 Hooks Abstract This article describes hooks and their use in the Microsoft® Win32® application programming interface (API). It discusses hook functions, filter functions, and the following types of hooks: WH_CALLWNDPROC WH_CBT WH_DEBUG WH_FOREGROUNDIDLE WH_GETMESSAGE WH_JOURNALPLAYBACK WH_JOURNALRECORD WH_KEYBOARD WH_MOUSE WH_MSGFILTER WH_SHELL WH_SYSMSGFILTER Terminology In this article, the term Windows refers to the Windows family of operating systems, that is, 16-bit Windows, Windows NT®, and Windows for Workgroups. Likewise, Windows 3.1 refers to the 3.1 version of these operating systems. Introduction In the Microsoft® Windows® operating system, a hook is a mechanism by which a function can intercept events (messages, mouse actions, keystrokes) before they reach an application. The function can act on events and, in some cases, modify or discard them. Functions that receive events are called filter functions and are classified according to the type of event they intercept. For example, a filter function might want to receive all keyboard or mouse events. For Windows to call a filter function, the filter function must be installed—that is, attached—to a Windows hook (for example, to a keyboard hook). Attaching one or more filter functions to a hook is known as setting a hook. If a hook has more than one filter function attached, Windows maintains a chain of filter functions. The most recently installed function is at the beginning of the chain, and the least recently installed function is at the end. When a hook has one or more filter functions attached and an event occurs that triggers the hook, Windows calls the first filter function in the filter function chain. This action is known as calling the hook. For example, if a filter function is attached to the CBT hook and an event that triggers the hook occurs (for example, a window is about to be created), Windows calls the CBT hook by calling the first function in the filter function chain. To maintain and access filter functions, applications use the SetWindowsHookEx and the UnhookWindowsHookEx functions. Hooks provide powerful capabilities for Windows-based applications. These applications can use hooks to: Process or modify all messages meant for all the dialog boxes, message boxes, scroll bars, or menus for an application (WH_MSGFILTER). Process or modify all messages meant for all the dialog boxes, message boxes, scroll bars, or menus for the system (WH_SYSMSG