Problem with madexcept + dll injection

delphi package - automated exception handling
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Problem with madexcept + dll injection

Post by madshi »

I've seen your reply, but I'm very busy atm, so it might take a couple of days before I get to this.
Vizit0r
Posts: 15
Joined: Tue Apr 26, 2016 7:19 pm

Re: Problem with madexcept + dll injection

Post by Vizit0r »

no problem, i'm just ask for confirmation of receiving this bug report.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Problem with madexcept + dll injection

Post by madshi »

Ok, I've looked into your test projects. For some reason, the target process always crashes on my PC when trying to inject the dll with your CreateRemoteThread code. FWIW, I've recompiled the sources myself instead of using your binary files. The crash even occurs when injecting kernel32.dll, so it has nothing to do with the dll.

As a test I've replaced your "InjectLib" function with madCodeHook's "InjectLibrary" API. After doing that your test projects work just fine. Doesn't matter if I compile the dll with madExcept or not, injection always succeeds. Well, the dll complains about not having found a window or something, but I suppose that's as designed.

So at this point I can't reproduce the problem, when using madCodeHook's DLL injection APIs. With your injection APIs I always get a crash, so I can't really look into the problem any further.
Vizit0r
Posts: 15
Joined: Tue Apr 26, 2016 7:19 pm

Re: Problem with madexcept + dll injection

Post by Vizit0r »

copy that, will test inject with your function InjectLib and will report about results.
Vizit0r
Posts: 15
Joined: Tue Apr 26, 2016 7:19 pm

Re: Problem with madexcept + dll injection

Post by Vizit0r »

if in project2 i'm changing line

Code: Select all

      if not InjectLib(pi.dwProcessId, pi.hProcess, 'client_dll.dll') then
to

Code: Select all

    if not InjectLibraryW(pi.hProcess, 'client_dll.dll') then
- all time injecting fails, InjectLibraryW returns false.


madCodeHook 2.

Try also InjectLibraryA, same.

In my main app - same.

What i'm doing incorrect?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Problem with madexcept + dll injection

Post by madshi »

Works for me, using madCodeHook 3, of course.
Vizit0r
Posts: 15
Joined: Tue Apr 26, 2016 7:19 pm

Re: Problem with madexcept + dll injection

Post by Vizit0r »

i can't install madCodeHook3, "no license" label in installer.

So, no way for me?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Problem with madexcept + dll injection

Post by madshi »

Well, I think the key problem is the injection. At least on my PC your injection code always crashes, while madCodeHook 3's injection always succeeds. On my PC it doesn't seem to make a difference whether madExcept is enabeld in the dll or not.

The original purpose of this thread was to analyze why madExcept makes problems for a dll that is injected into another process. From what I can see, madExcept does not make a problem. Or at least I can't reproduce it. I'm still willing to analyze further, but I can't do anything if I can't reproduce the problem.
Vizit0r
Posts: 15
Joined: Tue Apr 26, 2016 7:19 pm

Re: Problem with madexcept + dll injection

Post by Vizit0r »

i have no idea, why my injection method always crash on your PC.
You write, that on "madCodeHook 3's injection always succeeds". That's fine, but madCodeHook 3 not available for me.

Can you test it also on madCodeHook 2( which can be used from my side)?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Problem with madexcept + dll injection

Post by madshi »

madCodeHook 2 is heavily outdated. It was made for 32bit XP. It still works somewhat on Vista and Windows 7 (32bit), but anything newer than that, and especially 64bit OSs, is simply not supported by madCodeHook 2 at all.

With your injection method, the target process always crashes. Not the process which does the injection. I'm not sure why the target process crashes. I've spent like 30 minutes trying to figure out why it crashes, but didn't find the reason. At that point I stopped. I simply can't justify spending so much time debugging crashes in code that isn't mine.
Vizit0r
Posts: 15
Joined: Tue Apr 26, 2016 7:19 pm

Re: Problem with madexcept + dll injection

Post by Vizit0r »

okey, i'm understood.

Thanks for you spent time.
Post Reply