Solved

API Hooking, codecave, inputvalidation

Posted on 2006-11-16
2
389 Views
Last Modified: 2008-01-09
A rather uncommon question, or rather series of questions im sure

First a case

I have this application
Very annoying application
This annoying application does not support any form of validation on textfields, so once you press the "save" button, these fields a written to a database, and from there it pollutes a whole new magnitude of.. stuff.
So I want to add validation to this application! (its ok with the vendor)
Now i can iterate through the handles of the application and get the different hwnd's of controls, including the save button, so one solution would be use 'another' save button wich in turn validated data (either get handles of textfields, or readproccessmemory) and on success pressed the true save button.
I dont like that one very much, as the 'save button' would most likely reside outside of the original application.
I'd much rather 'hook' the true save button, do some inspection upon activation and from there either allow or deny the actual 'pressing' messages to the constrol.

So here goes; how would you go about 'hooking' a button like that?
API hook on SendMessage to that thread? how is that done (pointer to litterature) ?
Implement a codecave in the executable around the particular control(button) ? (i have a handle to the button, anyway to reveal an interresting address from that ? )

Other ideas welcome too:) Thanks!!
0
Comment
Question by:CyTG
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 300 total points
ID: 17956902
Basically you can accomplish this task via both API hookin and a Windows hook, where the latterwould be the IMO preferred solution. See e.g.

http://www.codeproject.com/system/hooksys.asp ("API hooking revealed")
http://www.codeproject.com/dll/hooks.asp ("Hooks and DLLs")

and

http://www.codeproject.com/threads/winspy.asp ("Three Ways to Inject Your Code into Another Process")

for a broader view. MSDN also has an interesting article about that:

http://msdn.microsoft.com/library/en-us/dnwui/html/msdn_hooks32.asp ("Win32 Hooks")
0
 
LVL 1

Author Comment

by:CyTG
ID: 18001541
thanks .. good reads!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now