Hi everyone,
I am trying to learn about how to use EasyHook but I am not even able to run the example provided. I seem to have all files in my "Debug" (FileMonInject.dll) directory but I'm still getting exceptions about missing files.
The following is my code.
Code:
namespace Hooking
{
public class FileMonInterface : MarshalByRefObject
{
public void IsInstalled(Int32 InClientPID)
{
Console.WriteLine("FileMon has been installed in target {0}.\r\n", InClientPID);
}
public void OnCreateFile(Int32 InClientPID, String[] InFileNames)
{
for (int i = 0; i < InFileNames.Length; i++)
{
Console.WriteLine(InFileNames[i]);
}
}
public void ReportException(Exception InInfo)
{
Console.WriteLine("The target process has reported" +
" an error:\r\n" + InInfo.ToString());
}
public void Ping()
{
}
}
class Hooking
{
static String ChannelName = null;
public Hooking()
{
hook();
}
static public void hook() {
try
{
Config.Register(
"A FileMon like demo application.",
"FileMon.exe",
"FileMonInject.dll");
Console.WriteLine("Registered!");
RemoteHooking.IpcCreateServer<FileMonInterface>(ref
ChannelName, WellKnownObjectMode.SingleCall);
RemoteHooking.Inject(2776, "FileMonInject.dll", "FileMonInject.dll", ChannelName);
Console.ReadLine();
}
catch (Exception ExtInfo)
{
Console.WriteLine("There was an error while connecting to target:\r\n{0}", ExtInfo.ToString());
}
}
}
}
So RemoteHooking.Inject(...) is failing with the following Exception.
Code:
There was an error while connecting to target:
System.IO.FileNotFoundException: File or Assembly "FileMonInject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d34a061f079be347" or its dependency cannot be found. The system cannot find the file.
I hope in this section I will not get flamed to death 
Update:
No idea why, but now I am getting something completely else.
Code:
There was an error while connecting to target:
System.Reflection.TargetInvocationException: Target has thrown exception. ---> System.Runtime.Remoting.RemotingException: Tried to call method of type "FileMon.FileMonInterface" declared in "Hooking.FileMonInterface".
Update 2:
System.Runtime.Remoting.RemotingException: Failed to connect to an IPC Port: Access is denied.
Any clue on this one?
EDIT:
Just ignore this, I managed to inject a DLL via EasyHook into WoW