TimeoutException when injecting from Windows Service

Jul 22, 2009 at 6:27 PM

I'm prototyping a Windows service that periodically obtains a list of new processes and attempts to inject a managed SetClipboardData() API hook.  Seeing a TimeoutException("Unable to wait for injection completion") during injection regardless of the process.  Seeing the timeout even for notepad/wordpad processes.  Here's part of the 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, Object[] InPassThruArgs)
at EasyHook.RemoteHooking.Inject(Int32 InTargetPID, String InLibraryPath_x86, String InLibraryPath_x64, Object[] InPassThruArgs)

I'm using EasyHook v2.6.  Any suggestions?

Jul 22, 2009 at 9:22 PM

For each failed injection attempt, I see the following entry in the EventViewer log:

Event Type:    Warning
Event Source:    EasyHook
Event Category:    None
Event ID:    0
Date:        7/22/2009
Time:        2:10:18 PM
User:        N/A
Description:
[warning]: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

Server stack trace:
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.SortedList`2.get_Item(TKey key)
   at EasyHook.HelperServiceInterface.InjectionException(Int32 InClientPID, Exception e)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at EasyHook.HelperServiceInterface.InjectionException(Int32 InClientPID, Exception e)
   at EasyHook.InjectionLoader.Main(String InParam)