| View previous topic :: View next topic |
| Author |
Message |
ShurikeN Advanced Cheater
Reputation: 0
Joined: 09 Jan 2008 Posts: 84
|
Posted: Fri Jun 06, 2008 5:53 am Post subject: [help]My first time DLL Injection |
|
|
i tried to inject this test dll into minesweeper, i used winjector and it says successfully injected but the messagebox doesn't show up. Am i missing something here?
| Code: |
#include <windows.h>
BOOL APIENTRY DllMain ( HINSTANCE hInst, DWORD dwReason, LPVOID reserved )
{
if( dwReason == DLL_PROCESS_ATTACH )
MessageBox( 0, "Attached!", 0, 0 );
return TRUE;
}
|
_________________
| Code: | XXXXXX XXXXXX
XXXXX XXXXX
XXXXXXXX
D I R E C T
XXXXXXXX
XXXXX XXXXX
XXXXXX XXXXXX
GameDev
|
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Fri Jun 06, 2008 6:49 am Post subject: |
|
|
| Use CreateThread. |
|
| Back to top |
|
 |
ShurikeN Advanced Cheater
Reputation: 0
Joined: 09 Jan 2008 Posts: 84
|
Posted: Fri Jun 06, 2008 7:28 am Post subject: |
|
|
didn't work too. I thought it was my compiler (CodeBlocks) but when i tried it on my OLD Dev-C++ it gives the same result.
| Code: |
#include <windows.h>
DWORD ThreadID;
DWORD WINAPI NewThread( LPVOID lParam ) {
MessageBox( 0, "Attached!", 0, 0 );
ExitThread( 0 );
}
BOOL APIENTRY DllMain( HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved ) {
if( dwReason == DLL_PROCESS_ATTACH ) {
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)&NewThread, 0, 0, &ThreadID );
}
return 1;
}
|
_________________
| Code: | XXXXXX XXXXXX
XXXXX XXXXX
XXXXXXXX
D I R E C T
XXXXXXXX
XXXXX XXXXX
XXXXXX XXXXXX
GameDev
|
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Fri Jun 06, 2008 9:18 am Post subject: |
|
|
| It's not necessary to use CreateThread. It should work fine. Try removing if(dwReason....) part. |
|
| Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Fri Jun 06, 2008 9:26 am Post subject: |
|
|
try this
u need to add a loop. otherwise it will only check once/
| Code: |
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
MessageBox( 0, "Attached!", 0, 0 );
break;
case DLL_PROCESS_DETACH:
break;
}
|
_________________
w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils |
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri Jun 06, 2008 9:34 am Post subject: |
|
|
| Bizarro wrote: | try this
u need to add a loop. otherwise it will only check once/
| Code: |
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
MessageBox( 0, "Attached!", 0, 0 );
break;
case DLL_PROCESS_DETACH:
break;
}
|
|
so it suppose to pop up the message one time isnt it ? _________________
Stylo |
|
| Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Fri Jun 06, 2008 9:37 am Post subject: |
|
|
| 1qaz wrote: | | Bizarro wrote: | try this
u need to add a loop. otherwise it will only check once/
| Code: |
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
MessageBox( 0, "Attached!", 0, 0 );
break;
case DLL_PROCESS_DETACH:
break;
}
|
|
so it suppose to pop up the message one time isnt it ? |
yea.
thats why createthread is suggested once its attached _________________
w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils
Last edited by Bizarro on Fri Jun 06, 2008 9:38 am; edited 1 time in total |
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Fri Jun 06, 2008 9:37 am Post subject: |
|
|
Make sure you are not using the Dev-C++/Code::Blocks compiler, it messes with the .dll format and does not give it a proper entry point.
Compile it in MSVC 08 and it will work just fine.  |
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Fri Jun 06, 2008 10:26 am Post subject: |
|
|
| tombana wrote: | | It's not necessary to use CreateThread. It should work fine. Try removing if(dwReason....) part. |
If he'll remove that compare statement how can it detect if he injected or not ? he wants to make sure a successful injection. |
|
| Back to top |
|
 |
Estx Expert Cheater
Reputation: 0
Joined: 04 Mar 2008 Posts: 172
|
Posted: Fri Jun 06, 2008 10:27 am Post subject: |
|
|
MessageBoxA instead of MessageBox should work fine for minesweeper.
| Code: | #include <windows.h>
BOOL APIENTRY DllMain ( HINSTANCE hInst, DWORD dwReason, LPVOID reserved )
{
if( dwReason == DLL_PROCESS_ATTACH )
MessageBoxA(0, "Attached!", 0, 0);
return TRUE;
} |
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Fri Jun 06, 2008 10:39 am Post subject: |
|
|
| Rot1 wrote: | | tombana wrote: | | It's not necessary to use CreateThread. It should work fine. Try removing if(dwReason....) part. |
If he'll remove that compare statement how can it detect if he injected or not ? he wants to make sure a successful injection. |
I meant just for testing, to make sure the problem is not that part. If you would remove it, the messagebox would be displayed when injection is succesfull, but also when a new thread is created or when the process is quit. |
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Fri Jun 06, 2008 10:56 am Post subject: |
|
|
For dev-cpp, atleast, try compiling it as C instead of C++. _________________
|
|
| Back to top |
|
 |
ShurikeN Advanced Cheater
Reputation: 0
Joined: 09 Jan 2008 Posts: 84
|
Posted: Fri Jun 06, 2008 5:23 pm Post subject: |
|
|
| HalfPrime wrote: | | For dev-cpp, atleast, try compiling it as C instead of C++. |
great! it worked. Although i tried in CodeBlocks but no luck. now i have to use old Dev-C++ for DLL programming  _________________
| Code: | XXXXXX XXXXXX
XXXXX XXXXX
XXXXXXXX
D I R E C T
XXXXXXXX
XXXXX XXXXX
XXXXXX XXXXXX
GameDev
|
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
|
| Back to top |
|
 |
ShurikeN Advanced Cheater
Reputation: 0
Joined: 09 Jan 2008 Posts: 84
|
Posted: Fri Jun 06, 2008 8:03 pm Post subject: |
|
|
i love visual studio but i prefer to use CodeBlocks because its installer is light (about 20mb only). The fact that i don't have my own PC i just store the installer in my flashdisk and port it whenever i sit on someone's PC. _________________
| Code: | XXXXXX XXXXXX
XXXXX XXXXX
XXXXXXXX
D I R E C T
XXXXXXXX
XXXXX XXXXX
XXXXXX XXXXXX
GameDev
|
|
|
| Back to top |
|
 |
|