Reloaded-Project / Reloaded.Injector

C# DLL Injection Library capable of injecting x86 DLLs to x86 process from x64 processes.
GNU Lesser General Public License v3.0
159 stars 32 forks source link

WaitHandleCannotBeOpenedException "No handle of the given name exists" #8

Open xxk-i opened 2 years ago

xxk-i commented 2 years ago

Not sure under which repo this issue should be (related to Reloaded.Memory.Buffers). I am running the following code in a new .NET framework Console App project (4.8) set to x64:

Process process = Process.Start("notepad.exe")
Injector injector = new Injector(process)

And in the output window are the following errors:

Exception thrown: 'System.Threading.WaitHandleCannotBeOpenedException' in mscorlib.dll
No handle of the given name exists.

Exception thrown: 'System.Exception' in PeNet.dll
Cannot find corresponding section.

Each exception is thrown multiple times. Despite this, continuing to injected a DLL and calling a function still seems to work though. The DLL I am testing with is making a CreateFileA hook using the example code in the Reloaded.Hooks documentation, and the existence of the following line seems to crash the host program:

_createFileAHook = ReloadedHooks.Instance.CreateHook<CreateFileA>(CreateFileAImpl, (long)createFileAPointer);

I have verified that the createFileAPointer is valid and accurate, and also attempted to run the injector in administrator mode but notepad (or any other app) still crash.

Unsure if the two issues are related, but at any rate the PeNet exception seems to be legitimate so I am curious if it is indeed an issue.

EDIT: The crash is due to the DLL's dependencies (e.x. Reloaded.Hook.Dll) not being present at the same directory as the executable being injected to (like notepad), so unrelated I guess(?)