-3

I'm trying to work a dll injection, I've tryed 100 of things but none of them works, I'm now on a windows 7 32 bits (to avoid 32/64 conflict). I've used two famous dll injector found on the web (AutoInject and Extreme injector V2) and a handmade one. I'm trying to mesagebox in notepad (can't be more simple right?) I sould also add that my windows run under Vmware. here My main for my dll (build with Code-Block)

#if BUILD_DLL
#define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
#define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
{
  switch (reason)
    {
     case DLL_PROCESS_ATTACH:
       MessageBox (0, "Hello from injected DLL!\n", "Hi", MB_ICONINFORMATION);
       break;
     case DLL_PROCESS_DETACH:
       break;
     case DLL_THREAD_ATTACH:
       break;
     case DLL_THREAD_DETACH:
       break;
    }
   return TRUE;
 }

I don't know what to try now

gfauchart
  • 82
  • 10
  • 1
    First of all don't do [weird](http://blogs.msdn.com/b/oldnewthing/archive/2004/01/27/63401.aspx) [stuff](http://blogs.msdn.com/b/oldnewthing/archive/2004/01/28/63880.aspx) in DllMain. With that out of the way, you aren't helping us very much... do the injectors report any errors? Have you verified whether the DLL gets loaded with something like ProcessExplorer? Sidenote: It looks as if you're compiling for ANSI/MBCS, and I'm pretty sure that notepad is UNICODE. – Nik Bougalis Mar 25 '13 at 20:43
  • both says injection succes, i'm going to try ProcessExplorer – gfauchart Mar 25 '13 at 20:48
  • Nik is right on both counts. You need to change the MessageBox call for something like OutputDebugString, and you need to compile the DLL as Unicode. ANSI went out of date over a decade ago. – Cody Gray - on strike Mar 25 '13 at 21:06

2 Answers2

1

I found the solution to my problem, If anyone have the same problem: Just use Visual Sudio instead of code block

gfauchart
  • 82
  • 10
0

According to Howto call MessageBox in dllmain you cannot call MessageBox inside DllMain (it's severely restricted in what you can do). tenfour suggests using something like OutputDebugString.

Community
  • 1
  • 1
Martin
  • 5,945
  • 7
  • 50
  • 77
  • I've tryed the main found on this link: http://www.mpgh.net/forum/290-crossfire-spammers-injectors-multi-tools/332194-how-make-dll-injection-c.html If Messagebox is the problem i'm going to try other output way – gfauchart Mar 25 '13 at 20:47