Hooking


Hooking

:"For the slang term meaning female prostitution, see prostitution. For the ice hockey penalty, see hooking (ice hockey)."

Hooking in programming is a technique employing so-called "hooks" to make a chain of procedures as an event handler. Thus, after the handled event occurs, control flow follows the chain in specific order. The new hook registers its own address as handler for the event and is expected to call the original handler at some point, usually at the end. Each hook is required to pass execution to the previous handler, eventually arriving to the default one, otherwise the chain is broken. Unregistering the hook means setting the original procedure as the event handler.

Hooking can be used for many purposes, including debugging and extending original functionality. It can also be misused to inject (potentially malicious) code to the event handler - for example, rootkits try to make themselves invisible by faking the output of API calls that would otherwise reveal their existence.

A special form of hooking employs intercepting the library functions calls made by a process. Function hooking is implemented by changing the very first few code instructions of the target function to jump to an injected code. Alternatively on systems using the shared library concept , the interrupt vector table or the import descriptor table can be modified in memory

Examples

Hooking is an extremely complex process on most systems, and the programs trying to hook usually have to be run with administrator privileges.There are very few practical applications using hooks whose source is open:However there is one library once provided by Microsoft in a sample, which can be used to hook function calls into Dynamic-link library files:The original sample is hard to acquire, but key files are still available on some SVN repositories, for example on Sourceforge: [http://oo-open.svn.sourceforge.net/viewvc/oo-open/trunk/OblivionOnline/HookImportedFunctionByName.cpp?revision=404&view=markup Link on the SVN repository by SF.net] The sample is commented and should explain itself. Another example can be found in the source code of the Psotnic IRC bot.

Libraries

* [http://research.microsoft.com/sn/detours Detours] is a general purpose function hooking library created by Microsoft Research which works in C / C++.
* [http://www.nektra.com/products/deviare/ Deviare API Hook Library] is implemented as a group of COM objects and can be used in VB, .NET, Delphi, C / C++ and Python.

Hook API

* [http://www.internals.com/ APISpy32] is an application used to hook win32 API.
* [http://www.nektra.com/products/spystudio/ Spy Studio API Spy] lets you hook windows API and watch and modify the parameters of the calls.

ee also

* Delegation (programming)
* Rootkit
* Callback (computer science)


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Hooking Up — is a collection of essays and short stories by American author Tom Wolfe, a number of which were published in earlier form in popular magazines. The essays cover a number of diverse topics dating from as early as 1965, including both non fiction… …   Wikipedia

  • Hooking — Hook Hook, v. t. [imp. & p. p. {Hooked}; p. pr. & vb. n. {Hooking}.] 1. To catch or fasten with a hook or hooks; to seize, capture, or hold, as with a hook, esp. with a disguised or baited hook; hence, to secure by allurement or artifice; to… …   The Collaborative International Dictionary of English

  • hooking — noun a golf shot that curves to the left for a right handed golfer he took lessons to cure his hooking • Syn: ↑hook, ↑draw • Derivationally related forms: ↑hook, ↑hook (for: ↑hook) …   Useful english dictionary

  • hooking — fishing for cod with hand lines …   Dictionary of ichthyology

  • hooking — hÊŠk n. curved piece of metal or other material by which things are hung or attached; fishhook; curve, angle, sharp bend; short punch (Boxing) v. secure, fasten, hang, attach; bend; capture; ensnare, addict; catch a fish; be caught; be attached;… …   English contemporary dictionary

  • Hooking (ice hockey) — Hooking in ice hockey is a penalty called when an offending player uses their hockey stick to prevent another player from moving freely. This results in a two minute penalty being assessed to the offending player. It is the most common penalty in …   Wikipedia

  • hooking-boat — a small, single masted, fishing vessel (Newfoundland) …   Dictionary of ichthyology

  • Hooking Search —    Bison use their horns to stab each other in the side …   Hunting glossary

  • hooking iron — noun : a hand tool with a pointed metal blade for removing caulking from seams (as of a boat) …   Useful english dictionary

  • Traditional rug hooking — is a craft where rugs are made by pulling loops of yarn or fabric through a stiff woven base such as burlap, linen, or rug warp. The loops are pulled through the backing material by using a crochet type hook mounted in a handle (usually wood) for …   Wikipedia


Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”

We are using cookies for the best presentation of our site. Continuing to use this site, you agree with this.