GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Feb-2005, 16:52
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

yet another winapi problem


I am trying to make a program that adds customizable animations when a window is minimized. but since this is a standalone program that has to affect every open window (and therefore almost every running program) it needs to have a global (that is, systemwide) hook. now, MSDN mentions that the hook procedure for such a hook must be in an external DLL. but i don't know how to do this. can i just stick the function in the DLL?
  #2  
Old 16-Mar-2005, 16:45
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough
come on, i know someone out there is just DYING to help with this problem...
  #3  
Old 20-Mar-2005, 18:01
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough
all right, answered my own question through experimentation. I ended up putting the function in the DLL, and including declspec(dllexport) in the declaration/definition. and I enclosed the prototype in extern "C" { } so that the name would not be mangled and I would be able to access the function from outside the DLL.
  #4  
Old 20-Mar-2005, 18:32
Max Payne's Avatar
Max Payne Max Payne is offline
Regular Member
 
Join Date: Apr 2004
Location: 3° 08 North 101° 42 East
Posts: 332
Max Payne is a jewel in the roughMax Payne is a jewel in the roughMax Payne is a jewel in the rough
when i rad th question, i thout your asking how to use the hook procedurs, but actually your anser sems to be different than i expected, your asking how to use a dll function..

i used hook before for InternetExplorer(not all running app), to catch the contents and event of the IE window, but i used it in the exe app not in a dll, not sure why it must be in dll for your case..
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds
  #5  
Old 20-Mar-2005, 18:39
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough
yeah, i just didn't understand the concept of a DLL. the reason I need a DLL instead of just having my hook procedure in my program, is because I need a global (all threads) hook. You only needed to put a hook on one thread--Internet Explorer. but I need to monitor all threads, and Windows annoyingly requires that my hook procedure must be in a DLL. now, I set the hook from within min_anim.exe, of course, but the ShellHookProc is in min_anim.dll. i have one last question related to this topic: since I am only using the ShellHookProc in min_anim.dll, do I still need a DllMain()?
  #6  
Old 20-Mar-2005, 19:07
Max Payne's Avatar
Max Payne Max Payne is offline
Regular Member
 
Join Date: Apr 2004
Location: 3° 08 North 101° 42 East
Posts: 332
Max Payne is a jewel in the roughMax Payne is a jewel in the roughMax Payne is a jewel in the rough
i think youll need your dllMain but you wont hav to altr any code in the dll main.. just export your hook function..
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds
  #7  
Old 20-Mar-2005, 19:30
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough
thanks.


btw
I learned a lesson when I finally got the hook to work: NEVER EVER do something in the hook procedure that causes your hook to be triggered! I had the hook procedure for the WH_SHELL hook displaying a message box. now, obviously a message box is a window, and so is the static control that holds the text (unless MessageBox() uses TextOut() or DrawText(), I wouldn't know) and the button you click. this is a problem because WH_SHELL hooks are triggered by window creation and activation. so each time my filter function was called, I caused it to be called again at least three times. Yikes! you can imagine the rest, I had to fight even to get Task Manager up and functioning (although agonizingly slowly) to kill the process.
  #8  
Old 20-Mar-2005, 19:42
Max Payne's Avatar
Max Payne Max Payne is offline
Regular Member
 
Join Date: Apr 2004
Location: 3° 08 North 101° 42 East
Posts: 332
Max Payne is a jewel in the roughMax Payne is a jewel in the roughMax Payne is a jewel in the rough
yep, that would b tiresome.. hooking sometime is dangerous, i tried to hook the winzip befor to get its password window, and try to bruteforce the password window (i lost my pwd ), many unexpectd things happened that i have to restart my pc several times before i succeeded...
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds
 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 4) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need advice on a disturbing problem JUNK KED Open Discussion Forum 6 31-Mar-2005 13:51
driver problem Carrie7979 Computer Hardware Forum 7 27-Jan-2005 11:39
Tee chart problem Arun C++ Forum 0 01-Sep-2004 23:23
Multithreading problem YellowFish C++ Forum 5 26-Jul-2004 01:36
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 07:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:57.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.