error in CreateAndInject

Jan 21, 2013 at 9:08 PM

When I call CreateAndInject I get this error.
.net framework 4.0 visual studio 2010 EasyHook 2.7.0.0

The given user library does not export a proper Run(EasyHook.InjectionLoader+
REMOTE_ENTRY_INFO, System.String) 
method in the 'EasyHook.IEntryPoint' interface.

I have this run implemented:
public void Run(RemoteHooking.IContext InContext, String channelName)
        { 
        	try
       		{	InitializeForRun();
              		RemoteHooking.WakeUpProcess();
        	} catch (Exception e)
        	{ MessageBox.Show(e.StackTrace); 
		}
        }

Coordinator
Jan 23, 2013 at 12:27 AM

Could you please post what your constructor looks like also?

Jan 23, 2013 at 3:22 PM

 

 public EntryPoint(RemoteHooking.IContext inContext, string inChannelName)

{ // Name the current thread.

  if (Thread.CurrentThread.Name == null)

  Thread.CurrentThread.Name = "test001";           

  // Connect to server.           

  IProcessSynchronizer sync = RemoteHooking.IpcConnectClient<ProcessSynchronizerInterface>(inChannelName).ProcessSynchronizer;           

          // Initialize the guest's core.           

  Core.Initialize(sync);                  

}

Coordinator
Jan 24, 2013 at 10:14 AM

Odd - I can't see anything wrong with it..

Is this using the 2.7.4761.0 release?

Jan 24, 2013 at 7:22 PM

I replaced the version of Easyhook that I used before ( an older one) with the 2.7.4761.0 version and now I dont get that error any more.

Instead I get another error @:

 public static void EndInjection(Int32 InTargetPID)       

{            lock (InjectionList)           

{                InjectionList[InTargetPID].ThreadLock.ReleaseMutex(); / this works
                 InjectionList.Remove(InTargetPID); // this works           

}       // here I get the error

}

the error is the following one:

{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Sandbox, Version=1.0.0.0, Culture=neutral, PublicKeyToken=edd3625b4cd77e26' or one of its dependencies. The system cannot find the file specified.   at Sandbox.Inject.EntryPoint..ctor(IContext inContext, String inChannelName)   --- End of inner exception stack trace ---   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, Boolean InRequireStrongName, Object[] InPassThruArgs)   at EasyHook.RemoteHooking.CreateAndInject(String InEXEPath, String InCommandLine, Int32 InProcessCreationFlags, String InLibraryPath_x86, String InLibraryPath_x64, Int32& OutProcessId, Object[] InPassThruArgs)}

 

Please tell me why does it say that the file is missing. 

Can it be that the file is expected to be in this location:

C:\Windows\Microsoft.NET\assembly\GAC_32\EasyHook\v4.0_2.7.4499.0__4b580fca19d0b0c5

 

With Kind Regards,

Ovidiu Marian

Jan 24, 2013 at 7:25 PM

In this class from the dll that should be injected Sandbox.Inject.EntryPoint Constructor I call methods from the main app named Sandbox.

Could this be a problem ? since Sandbox.Inject has Sandbox.exe ( the main app ) as a reference to it.

 

Coordinator
Jan 25, 2013 at 5:57 AM

The reference to your main app could be the issue, try again without that reference as a sanity check. If that works, then try again with the types you need to reference in the same assembly, or else in another assembly that you use in both your main app and your injected assembly.

Any references in your injected assembly need to be on its search path (i.e. in the same directory, or within the GAC). If you register your injected assembly in the GAC then it will only be able to reference other GAC registered assemblies.

2.7 doesn't require you to use the GAC any longer so I suggest trying without using that GAC also (see the ProcessMonitor example and the logic it uses when not running as an Administrator).