| View previous topic :: View next topic |
| Author |
Message |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Fri Jun 06, 2008 8:23 am Post subject: [c++]communicate from .exe and dll |
|
|
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 |
|
 |
Ferocious Advanced Cheater
Reputation: 0
Joined: 06 Feb 2008 Posts: 54
|
Posted: Fri Jun 06, 2008 8:44 am Post subject: |
|
|
use IPC instead.
CreatePipe etc etc.
_________________
I wanna hack, but I don't know how... |
|
| Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Fri Jun 06, 2008 8:46 am Post subject: |
|
|
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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Jun 06, 2008 8:51 am Post subject: |
|
|
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
_________________
|
|
| Back to top |
|
 |
Ferocious Advanced Cheater
Reputation: 0
Joined: 06 Feb 2008 Posts: 54
|
Posted: Fri Jun 06, 2008 8:52 am Post subject: |
|
|
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 |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Fri Jun 06, 2008 9:18 am Post subject: |
|
|
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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Fri Jun 06, 2008 12:44 pm Post subject: |
|
|
You could also use an MMF which works fairly the same as a named pipe.
_________________
- Retired. |
|
| Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Fri Jun 06, 2008 1:06 pm Post subject: |
|
|
| 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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Jun 06, 2008 1:46 pm Post subject: |
|
|
| 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 |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Fri Jun 06, 2008 2:11 pm Post subject: |
|
|
| 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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Fri Jun 06, 2008 6:54 pm Post subject: |
|
|
| 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 |
|
 |
|