473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How can I trap an API call by windows

Hi everyone,
I just wanted to know how my program can trap a particular API
call by windows. (The idea is that I want to hook all the open text
boxes and keep hooking new ones as and when they are created).

So for this i want to trap the CreateWindow or CreateWindowEx API
as that I can keep track of the handles etc. I have an idea that
this can be done by mapping the entry points of kernel32.dll,
gdi32.dll etc, just like how SoftIce does, but Im not very sure about
this.

Any suggestions or help would be greatly appreciated.

Thanks in advance,
Ali.
Nov 14 '05 #1
6 4194
Ali Akbar wrote:
Hi everyone,
I just wanted to know how my program can trap a particular API
call by windows.


Then you probably wanted a Windows programming group. This group is for
discussion of the C language as defined by the international C standard,
which has nothing to say about Windows or trapping APIs (whatever that
means).

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Nov 14 '05 #2
"Ali Akbar" <al******@yahoo.com> wrote in message
news:bd**************************@posting.google.c om...
Hi everyone,
I just wanted to know how my program can trap a particular API
call by windows. (The idea is that I want to hook all the open text
boxes and keep hooking new ones as and when they are created).

So for this i want to trap the CreateWindow or CreateWindowEx API
as that I can keep track of the handles etc. I have an idea that
this can be done by mapping the entry points of kernel32.dll,
gdi32.dll etc, just like how SoftIce does, but Im not very sure about
this.

Any suggestions or help would be greatly appreciated.

Thanks in advance,
Ali.


Hello,

Although this is not a "C" question, you can still search for "Detours" by
Microsoft or "API Hooking" on google.

--
Elias
Nov 14 '05 #3
Ali Akbar wrote:
Hi everyone,
I just wanted to know how my program can trap a particular API
call by windows. (The idea is that I want to hook all the open text
boxes and keep hooking new ones as and when they are created). So for this i want to trap the CreateWindow or CreateWindowEx API
as that I can keep track of the handles etc. I have an idea that
this can be done by mapping the entry points of kernel32.dll,
gdi32.dll etc, just like how SoftIce does, but Im not very sure about
this.


The only way that I can think of that is on topic here is to do
something like:

#define CreateWindow myCreateWindow

in the program you want to trap, and then separately write a
myCreateWindow function that does whatever you want to do
before or after calling the real CreateWindow function.

That may or may not satisfy your question.

Another way, though getting off of standard C, is to go through
the system library with a binary editor and change all
strings that say CreateWindow into something like XCreatWindow
(It must be the same length to edit in the compiled form.)

Then you can write a function called CreateWindow that will
then call XCreatWindow.

hope this helps,

-- glen

Nov 14 '05 #4
glen herrmannsfeldt <ga*@ugcs.caltech.edu> writes:
[...]
Another way, though getting off of standard C, is to go through
the system library with a binary editor and change all
strings that say CreateWindow into something like XCreatWindow
(It must be the same length to edit in the compiled form.)

Then you can write a function called CreateWindow that will
then call XCreatWindow.


Of course, this may not work if the system library format includes
some kind of index or hash table.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
Nov 14 '05 #5
Kevin Goodsell <us*********************@neverbox.com> wrote in
news:r2****************@newsread2.news.pas.earthli nk.net on Wed 17 Dec
2003 01:00:23a:
Ali Akbar wrote:
Hi everyone,
I just wanted to know how my program can trap a particular API
call by windows.


Then you probably wanted a Windows programming group. This group is for
discussion of the C language as defined by the international C standard,
which has nothing to say about Windows or trapping APIs (whatever that
means).

-Kevin


<OT>
From what I understand, it means catching a call to an API (the hooks an
OS provides to application programs) so you can execute your code in
response to that call before the OS has a chance to do anything.

It is, of course, offtopic here.
</OT>

Nov 14 '05 #6
al******@yahoo.com (Ali Akbar) writes:
I just wanted to know how my program can trap a particular API
call by windows. (The idea is that I want to hook all the open text
boxes and keep hooking new ones as and when they are created).


Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to
explore if you have questions about these topics. Please do
observe proper netiquette before posting to any of these
newsgroups. In particular, you should read the group's charter
and FAQ, if any. If those fail to answer your question then you
should browse through at least two weeks of recent articles to
make sure that your question has not already been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.
--
"When I have to rely on inadequacy, I prefer it to be my own."
--Richard Heathfield
Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: GrelEns | last post by:
hello, i would like if this behaviour can be obtained from python : trap an attributeError from inside a subclassing dict class... (here is a silly examples to explain my question) class...
1
by: gregory_may | last post by:
This code seems to "work" but I get the following errors: An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll then this one: An unhandled...
2
by: aj | last post by:
DB2 WSE LUW 8.1 Fixpak 5 Red Hat AS 2.1 Has anyone ever seen a db2diag.log indicate that a trap file was written, but it is *not* written? For the 3rd time in 18 months, I had a production...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
4
by: Chris Botha | last post by:
If one wants to assure that there is only one instance of an app running, then the popular solution is to use a Mutex and a message box, telling the user there is already one running. I decided to...
2
by: Rich | last post by:
Hello, I need to trap/detect when a textbox is entered via the tabkey. If the textbox is not empty when entered via the tabkey then set focus to next textbox. To enter that textbox would then...
8
by: =?Utf-8?B?RyBIdXN0aXM=?= | last post by:
This is the 2nd time posting so sorry for duplications. I am using VB.NT 2005 & a standard Combobox. I've been wracking my brain over this problem for a over a month & cannot seem to find a way to...
6
by: John | last post by:
In a form how I can I trap for the action that a user opens the built in 'find dialog'? I would like to trap for it and before the dialog shows up, I would like to execute some code, and after that...
3
by: Johnny | last post by:
Hi there, Does anyone know how I can trap F1 to activate help when a menu item is active, preferably without creating a "ToolStripMenuItem" derivative (so I can quickly wire this up using the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.