Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Hooking Win32 API calls

Posted on 2009-02-21
5
Medium Priority
?
726 Views
Last Modified: 2013-12-03
Ah hello.

Simple question: I would like to learn how to hook a given Win32 call, so I can either deny the call, or replace the call with something else.  I don't want to do this for malicious purposes, I need this for my own application only.

For example, I want to hook the calls into ::MessageBox, for example.  This is so I can set up a another windows hook to watch for the window creation, then change, say, the text on the dialog, or the background colour of the dialog.  This is to prevent the need for a whole new class of dialog to be created, then replace every call to ::MessageBox with this new dialog, but also to catch message boxes displayed via MFC internally, eg those displayed during Serialization Fail ("Failed to load document").

(I asked a question similar to this a while ago, and was pointed at the Windows Theme API.  But I don't want to use that for many reasons that are not relevant here :) )

PS Any book titles that discuss this topic will also be welcomed.

TIA
0
Comment
Question by:mrwad99
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1200 total points
ID: 23701693
Take a look at http://www.codeproject.com/KB/system/hooksys.aspx ("API hooking revealed") - this article discusses that issue in-depth and comes with full source code.
0
 
LVL 5

Assisted Solution

by:migoEX
migoEX earned 400 total points
ID: 23703818
0
 
LVL 2

Assisted Solution

by:Castorix
Castorix earned 400 total points
ID: 23752622
Just use Detours or read J. Richter's book and see his sampleq codes
0
 
LVL 19

Author Comment

by:mrwad99
ID: 23754073
Greetings all.

I have not forgotten about this question, I have been reading the links provided, which currently seem to be useful.  Castorix, you mention Jeffrey Richter's book - which book exactly?

TIA
0
 
LVL 19

Author Comment

by:mrwad99
ID: 23757261
Thanks all.  By reading those articles I found a link to a sample project which does just this via the book "Programming Applications for Windows" by Jeffrey Richter; but I am having problems: if you could help at http:Q_24184290.html please do :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question