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 


Message DLL to Console application.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Dec 02, 2008 8:08 am    Post subject: Message DLL to Console application. Reply with quote

Hey,

how could I send a message from a dll to my console application.
The console application is using the dll already.
But I have no idea how I could do that.

Any suggestions?
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Tue Dec 02, 2008 8:42 am    Post subject: Reply with quote

if its only one way communication, sendmessage or postmessage is the easiest of all

if you need consant duplex communication between two or more processes, use named pipe. u can send either string type or byte type data

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Dec 02, 2008 8:58 am    Post subject: Reply with quote

Yea I thought of Post/Send-Message too, but I don't know how to revice the message in the Console application then.
TranslateMessage() and DispatchMessage().
But DispatchMessage() calls the WinProc which doesn't exist in this case.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Tue Dec 02, 2008 9:20 am    Post subject: Reply with quote

Once the DLL is in the memory of the console you can call console APIs, for instance, printf, and the output will be shown on the console window, use it the same as you would've used them in the console application.

In your DLL:
Code:
printf("X.DLL called printf!\n");


Remember, you're in the process's memory.
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Dec 02, 2008 9:41 am    Post subject: Reply with quote

Thanks Symbol. That makes sense x).
The problem is, that it's a dll with a system-wide hook.
So I need to send the message to a constant handle.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Tue Dec 02, 2008 10:23 am    Post subject: Reply with quote

You could also redirect the window procedure to your own window procedure:
Code:
LONG oldWndProc = SetWindowLong(hwnd, GWL_WNDPROC, (LONG)newWndProc);

LRESULT CALLBACK myWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
...
...
}

return CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
}


Or simply make a window. Rolling Eyes
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Tue Dec 02, 2008 10:28 am    Post subject: Reply with quote

look at GetStdHandle ... ReadConsole WriteConsole so forth ;p

http:// msdn . microsoft . com/en-us/library/ms685032(VS.85).aspx

those are some good suggestions Symbol and Bizarro i feel that SendMessage accompanied by a threaded GetMessage that pools the message queue relativily slowly so as to not have a overbearing performance degradation would the best internal method.

another valid solution would be to use Indirection to write data/code directly to the process memory you could even recycle String locations ...
making a Green Application would be funneh Razz
Back to top
View user's profile Send private message MSN Messenger
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