So I'm trying to use easyhook to hook to notepad atm, but I can't get a basic example to work. I made a really basic DLL that just reports back the processID of the application it is in. The code is self explaining;
C# console app;
Code:
namespace ConsoleGUI
{
public class RemoteGUIInterface : MarshalByRefObject
{
public void GUICallback(String msg)
{
Console.WriteLine("msg=" + msg);
}
public void ReportException(Exception InInfo)
{
Console.WriteLine("ReportException:\r\n" + InInfo.ToString());
}
}
class Program
{
static String ChannelName = null;
static void Main(string[] args)
{
Int32 TargetPID = Process.GetProcessesByName("notepad")[0].Id;
Console.WriteLine("*** TargetPID:" + TargetPID);
Config.Register("ConsoleGUI.exe", "WoWInject.dll");
RemoteHooking.IpcCreateServer<RemoteGUIInterface>(ref ChannelName, WellKnownObjectMode.SingleCall);
Console.WriteLine("*** inject @ ChannelName:" + ChannelName);
RemoteHooking.Inject(TargetPID, "WoWInject.dll", "WoWInject.dll", ChannelName);
Console.ReadLine();
}
}
}
C# dll;
Code:
namespace WoWInject
{
public class Main : EasyHook.IEntryPoint
{
ConsoleGUI.RemoteGUIInterface Interface;
public Main(RemoteHooking.IContext InContext, String InChannelName)
{
Interface = RemoteHooking.IpcConnectClient<ConsoleGUI.RemoteGUIInterface>(InChannelName);
Interface.GUICallback("RemoteHooking.IpcConnectClient done");
}
public void Run(RemoteHooking.IContext InContext, String InChannelName)
{
Interface.GUICallback("CurrentProcessId=" + RemoteHooking.GetCurrentProcessId());
}
}
}
However, I just can't get past the following error. I'm running winxp 32 bit, all EasyHook files are in place. It's a bit tough since I have little experience with C# and visual studio, I have no idea what the problem is... It's complaining that it cannot find the the already running application ??
Code:
System.Reflection.TargetInvocationException was unhandled
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at EasyHook.HelperServiceInterface.WaitForInjection(Int32 InTargetPID)
at EasyHook.RemoteHooking.InjectEx(Int32 InHostPID, Int32 InTargetPID, Int32 InWakeUpTID, Int32 InNativeOptions, String InLibraryPath_x86, String InLibraryPath_x64, Boolean InCanBypassWOW64, Boolean InCanCreateService, Object[] InPassThruArgs)
at EasyHook.RemoteHooking.Inject(Int32 InTargetPID, String InLibraryPath_x86, String InLibraryPath_x64, Object[] InPassThruArgs)
at ConsoleGUI.Program.Main(String[] args) in E:\Documents and Settings\test\My Documents\Visual Studio 2008\Projects\BobBot\ConsoleGUI\Program.cs:line 35
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.FileNotFoundException
Message="Could not load file or assembly 'ConsoleGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=984bf1c17d0d5735' or one of its dependencies. The system cannot find the file specified."
Source="WoWInject"
FileName="ConsoleGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=984bf1c17d0d5735"
FusionLog=""
StackTrace:
at WoWInject.Main..ctor(IContext InContext, String InChannelName)
InnerException: