Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help getting window handle from inside injected dll

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
selethd
How do I cheat?
Reputation: 0

Joined: 20 May 2009
Posts: 3

PostPosted: Mon Aug 22, 2011 8:20 pm    Post subject: Help getting window handle from inside injected dll Reply with quote

I have a .dll that is injected into a game process, when the game loads.

once the.dll is loaded, in its init, it.....
hooks the send and recieve functions of the game
creates a thread

in the thread it creates a window to display the contents of the hooked send and recv winsock functions

What I would like is for my .dll's created window, to position itself alongside the game's window, and if hte game's window is moved, for the dll's window to move also.

So I need a way to have my thread check the position of the host games window.

How can I get a handle to this window from the Init phase of my injected .dll?

I have searched all over the net, and people say to send the windows handle by letting the injector get the handle and pass it to the .dll, but the game itself loads my dll. So I really need the .dll to get this from within the process.

im using c++ on a windows system 32bit win7

thanks for any help, im still sort of a noob at all of this injectiion and hooking stuff.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 204

Joined: 25 Jan 2006
Posts: 8579
Location: 127.0.0.1

PostPosted: Mon Aug 22, 2011 9:04 pm    Post subject: Reply with quote

You could go about it a few ways:

Use FindWindow with a specific class / window name that you are sure of belongs to the game. Typically you wont run into issues with things having the same class name if you plan on cheating a single client game. (Things that wont have multiple clients open etc.)

Use EnumWindows to enumerate the windows on the machine to attempt to locate the one that matches the game. You can use the window title to try to find a match.

Use EnumThreadWindows with the processes main thread id so you can directly iterate through the current processes windows only.

You can also hook CreateWindowExA/CreateWindowExW (or whatever it uses to create the window) and store the handle after it is created inside your dll.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Aug 24, 2011 3:40 pm    Post subject: Reply with quote

subclass the window so when it gets a wm_move, it forwards it to your window then calls the next procedure in the hook chain
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites