Um... just creeping here around and thought that I could try this library out.
Even though I am kinda experienced with C# and VB.NET this we're a bit complicated. I got this working really fine until I come to the point where I need to define the PortableExcutable. After researching the source code of the JLibrary can't really understand what is wrong :/
Code:
// This is from the JLibrary source
IMAGE_NT_HEADER32 result = new IMAGE_NT_HEADER32();
if (result.OptionalHeader.DataDirectory[14].Size > 0)
{
// I got returned with this error
str = "Image contains a CLR runtime header. Currently only native binaries are supported; no .NET dependent libraries.";
}
If someone could explain a bit of the PE headers to make this more clear, if I understand correctly my dll is not in correct PE format.
Also hit me up if I the dll path is defined wrong, even thought the argument should be as string and I am directly giving the full file path.
Code:
//This is from my code, inj is a dictionary with the dll name and with the dll path as the value
Using img As New PortableExecutable(inj.Value)
hModule = injector.Inject(img, processId)
End Using
Edit:
After sometime I found Jason's post about CLR injector. So my dll is not compatible with the injection method. Correct me if I am wrong.
Here is a part of the post that I mentioned
However, now we have another problem; How do we initialize the CLR with managed code, if you need to CLR to execute managed code? The short answer is we can't. We'll still need to resort to some native code to initialize the CLR, then we can start executing our managed code. See the end of this post for the native .dll that provides an external function to load managed dlls.
Cheers!