DLL Injection

s0beit s0beit at myg0t.com
Mon Nov 26 17:31:15 PST 2012


On Tuesday, 27 November 2012 at 01:01:10 UTC, s0beit wrote:
> I recently had this problem, and I think I've solved it for now
> if anyone is still looking for a fix ... it's really ghetto but
> it seems to work for me.
>
> extern (Windows) BOOL DllMain(HMODULE hModule, ULONG ulReason,
> LPVOID pvReserved)
> {
> 	if(ulReason == DLL_PROCESS_ATTACH)
> 	{
> 		DllMainReal(hModule);
>
> 		core.memory.GC.collect(); //collect garbage before the return
>
> 		asm
> 		{
> 			mov EAX, 1;
> 			ret; // Don't give the garbage collector the chance to make
> things messy
> 		}
> 	}
>
> 	return TRUE;
> }

Actually completely disregard, what was actually happening was me 
being stupid. The reason why it didn't fault here is because I 
totally screwed up the stack and I believe that caused the 
exception handler to trigger when the DllMain call was finished. 
I don't know why this would prevent my module from crashing, but 
it did. It also halted execution of the rest of my code, go 
figure. No solution for this still. I'll keep working on it, but 
right now all I've got to go on is invalid memory access in one 
of the GC's Free functions.


More information about the Digitalmars-d-learn mailing list