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 


[c++]communicate from .exe and dll

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

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri Jun 06, 2008 8:23 am    Post subject: [c++]communicate from .exe and dll Reply with quote

hi

i wrote a dll and a seperate exe(which mainly acts as an injector for the dll).

i was wondering how i can sendmessage from dll(DLLMain )to exe right after it got injected and have "confirmation" message sent back from the exe to the dll in order to activate its function/thread.

by doing this,it makes sure that only my application can inject this dll not any other injectors.

im not sure how i can do this using sendmessage inside the DLLmain and how i can receive and sendmessage from exe back to dll for activation.

some simple code examples would be much appreciated.

thank you

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils


Last edited by Bizarro on Fri Jun 06, 2008 10:22 am; edited 1 time in total
Back to top
View user's profile Send private message
Ferocious
Advanced Cheater
Reputation: 0

Joined: 06 Feb 2008
Posts: 54

PostPosted: Fri Jun 06, 2008 8:44 am    Post subject: Reply with quote

use IPC instead.

CreatePipe etc etc.

_________________
I wanna hack, but I don't know how...
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri Jun 06, 2008 8:46 am    Post subject: Reply with quote

the reason i wanna use sendmessage becuase its much simpler.
i only need this for checking purpose. and the .exe is closed right after it injects the dll.

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri Jun 06, 2008 8:51 am    Post subject: Reply with quote

Just make a new message and send it from the dll to your exe

like say

EXE:
Code:

// Define this in your dll as well.
#define WM_DLL_MSG  (WM_USER + 0x300)

// In your WndProc handler filter for the msg.
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    switch ( uMsg )
    {
        case WM_DLL_MSG:
               DestroyWindow( hWnd );
               break;
        default:
               return DefWindowProc( hWnd, uMsg, wParam, lParam );
    }
    return 0;
}


DLL:
Code:
HWND hWnd = FindWindow( _T("MyExeClass"), NULL );
if ( hWnd )
    SendMessage( hWnd, WM_DLL_MSG, 0, 0 );


Hope this helps Smile

_________________
Back to top
View user's profile Send private message
Ferocious
Advanced Cheater
Reputation: 0

Joined: 06 Feb 2008
Posts: 54

PostPosted: Fri Jun 06, 2008 8:52 am    Post subject: Reply with quote

if you insisting on using SendMessage,

you could just create a handler in your application,

and send message from your dll with the handler ID.

_________________
I wanna hack, but I don't know how...
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri Jun 06, 2008 9:18 am    Post subject: Reply with quote

ty lurc

i will try it out.

so i need to send MSG1 from dll to exe first
then after receiving MSG1 in exe.
the exe will send MSG2 to dll and close itself

after dll confirm MSG2, it will process the normal proc.
if MSG2 is not received, it will crash

is this logic ok?


oh also, do i need to specify wParam (eg.8888) just to distinguish from normal system msg

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Fri Jun 06, 2008 12:44 pm    Post subject: Reply with quote

You could also use an MMF which works fairly the same as a named pipe.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri Jun 06, 2008 1:06 pm    Post subject: Reply with quote

Wiccaan wrote:
You could also use an MMF which works fairly the same as a named pipe.


whats MMF, can u elaborate on that ?o.o

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri Jun 06, 2008 1:46 pm    Post subject: Reply with quote

Bizarro wrote:
ty lurc

i will try it out.

so i need to send MSG1 from dll to exe first
then after receiving MSG1 in exe.
the exe will send MSG2 to dll and close itself

after dll confirm MSG2, it will process the normal proc.
if MSG2 is not received, it will crash

is this logic ok?


oh also, do i need to specify wParam (eg.8888) just to distinguish from normal system msg


You must be handling messages from your dll if u want to send messages to it meaning you have to make a window for it.
a msg from your dll to your exe should be enough, its probly safe not to need to confirm.

And no, unless you actually plan to do anything with wParam/lParam there is no need for it to have a value.

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

Joined: 01 May 2007
Posts: 2648

PostPosted: Fri Jun 06, 2008 2:11 pm    Post subject: Reply with quote

lurc wrote:
Bizarro wrote:
ty lurc

i will try it out.

so i need to send MSG1 from dll to exe first
then after receiving MSG1 in exe.
the exe will send MSG2 to dll and close itself

after dll confirm MSG2, it will process the normal proc.
if MSG2 is not received, it will crash

is this logic ok?


oh also, do i need to specify wParam (eg.8888) just to distinguish from normal system msg


You must be handling messages from your dll if u want to send messages to it meaning you have to make a window for it.
a msg from your dll to your exe should be enough, its probly safe not to need to confirm.

And no, unless you actually plan to do anything with wParam/lParam there is no need for it to have a value.


hmm
i don't see the point of sending message from dll to exe.
the reason i wanna do this is becuase if any other injector injects my dll, it will not be effective.

so if someone use other injector, succesfully injects my dll. and my its sends a message to my exe would not be useful

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Fri Jun 06, 2008 6:54 pm    Post subject: Reply with quote

Bizarro wrote:
Wiccaan wrote:
You could also use an MMF which works fairly the same as a named pipe.


whats MMF, can u elaborate on that ?o.o


MMF stands for Memory-Mapped File, you can read more about it here:
http://en.wikipedia.org/wiki/Memory-mapped_file

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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