nefarius / Injector

Command line utility to inject and eject DLLs
MIT License
609 stars 100 forks source link

Injection via Injector fails while injecting via System Informer succeeds #28

Closed ProjectHSI closed 9 months ago

ProjectHSI commented 10 months ago

Bug description

Recently while using a tool that depends on this project, I noticed that the DLL I was trying to use wasn't being injected. Using Injector directly results in the LoadLibraryW error that has been mentioned many-a times before, or the "Could not create thread in remote process." error if using the x86 version of Injector. However, using System Informer to inject the DLL worked.

Steps to reproduce

While I'm unsure of what exactly caused this problem I will try to provide as much detail as I can.

Actual result: A runtime error is thrown with "Call to LoadLibraryW in remote process failed.". If running the x86 version of the injector, "Could not create thread in remote process." is thrown instead, probably as I'm running x64 Windows (though A:I is a 32-bit game). Expected result: Cinematic Tools is loaded into Alien: Isolation. Result of that is a console window opening attached to the game and an ImGui window opening that looks like the window below.

Screenshots

Injector:

Screenshot 2024-01-09 152904

Expected Result: Console:

Screenshot 2024-01-09 153733

ImGUI Window:

Screenshot 2024-01-09 153844

Machine info

CPU-Architecture: x64 Windows version: Windows 10 22H2, 19045.3803, Windows Feature Experience Pack 1000.19053.10000 Software/driver version(s): Injector: 1.3.0

Any other helpful information

System Informer's injection process starts here.

PHLib (part of System Informer that does injecting as well as other things not relevant here) is build-able by itself. This may not align with the project and that's fine but PHLib could be imported (with modifications) and used during the injection.

ProjectHSI commented 10 months ago

@nefarius (sorry if you already read this and have acknowledged the issue, there wasn't any communication from you on this issue or the issue this was mentioned in.

nefarius commented 10 months ago

I read everything, rest assured, and I have nothing to comment on. I neither know the cause nor how to fix, neither have the time anyway. So unless someone else chimes in, this will simply sit here and collect dust.

bot-1450 commented 9 months ago

Are you sure process name should go case-sensitive? We always ignore the case. Have you tried with process id?

https://github.com/nefarius/Injector/blob/ea463844518aa7243b873a89631c223d83dad13f/Injector/Main.cpp#L111

https://github.com/nefarius/Injector/blob/ea463844518aa7243b873a89631c223d83dad13f/Injector/Injector.cpp#L294

ProjectHSI commented 9 months ago

I'll try that, but it should in that case just not inject into the right process.

ProjectHSI commented 9 months ago

Appears to fail with the same message.

bot-1450 commented 9 months ago

Cannot reproduce. Things go fine here.

Injector_x86_amd64_arm64\Win32>Injector.exe -n AI.exe -i CT_AlienIsolation.dll
Injector x86 [Version 20230813]
Copyright (c) 2009 Cypher, 2012-2023 Nefarius. All rights reserved.

Successfully injected module!

Commonly, The target process and referenced module should share the same bitness. Since both the process and module are x86, you should use Win32 version of Injector.

Please, double check permissions or other things. You may also step into the source and print GetLastError in order to figure out why.

ProjectHSI commented 9 months ago

Cannot reproduce. Things go fine here.

Injector_x86_amd64_arm64\Win32>Injector.exe -n AI.exe -i CT_AlienIsolation.dll
Injector x86 [Version 20230813]
Copyright (c) 2009 Cypher, 2012-2023 Nefarius. All rights reserved.

Successfully injected module!

Commonly, The target process and referenced module should share the same bitness. Since both the process and module are x86, you should use Win32 version of Injector.

Please, double check permissions or other things. You may also step into the source and print GetLastError in order to figure out why.

I was using the x64 injector. Injecting with the Win32 version works fine (although ejecting the module doesn't seem to do anything. This could be a bug with the module though and not Injector.)

This does close this issue as user error and not a bug with Injector. The issue mentioned under OpenCAGE's issue tracker will be adjusted accordingly.

I might open a PR (or an issue) to have case-sensitivity as a toggle though, as I think it would help eliminate users not figuring out what to do.

Once again, this issue can be closed as user error.

ProjectHSI commented 9 months ago

The underlying confusion that lead to this can be fixed by merging #29.

ProjectHSI commented 9 months ago

Apparently I messed up when looking at how CinematicTools was injected when using OpenCAGE; the issue that I linked to this apparently wasn't related to this repo as OpenCAGE doesn't use Injector.

At least I cleared some confusion for people using this project, right? 🤷‍♂️

(Is there a phrase for this kind of mistake?)

nefarius commented 9 months ago

At least you confused me 🤣