D Dll injection problem

Gyron Threk at web.de
Tue Mar 27 13:33:38 PDT 2012


Hey there, I want to inject a dll which was created in D into a c 
Program.

Informations:
DMD vs. 2.058
IDE: MonoDevelop with Mono-D
System: Windows 7 64bit

Program Informations:
32-bit
written in c

The Injector is working for sure, so thats not the Problem.

the Source of the DLL:
import std.c.windows.windows;
import core.sys.windows.dll;

__gshared HINSTANCE g_hInst;

extern (Windows)
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID 
pvReserved)
{
     final switch (ulReason)
     {
	case DLL_PROCESS_ATTACH:
	    g_hInst = hInstance;
	    dll_process_attach( hInstance, true );
	    break;

	case DLL_PROCESS_DETACH:
	    dll_process_detach( hInstance, true );
	    break;

	case DLL_THREAD_ATTACH:
	    dll_thread_attach( true, true );
	    break;

	case DLL_THREAD_DETACH:
	    dll_thread_detach( true, true );
	    break;
     }
     return true;
}

It builds fine, but If I inject it, the program (where the dll is 
injected) says that the dll is not a valid image.
screenshot: http://imagr.eu/up/4f72240329a846_Unbenannt.png

Maybe it's because I have no def file.
But i dont know how to link it with Mono-D.



More information about the Digitalmars-d-learn mailing list