FileNotFoundException occurs in PrepareInjection()

Aug 11, 2014 at 7:50 AM
Development and Test environment is Windows 8.1 x64.

I tried hooking in some unnatural state, and faced System.IO.FileNotFoundException.

I traced that, and in PrepareInjection() in RemoteHook.cs,
// Line 587
 if ((UserAsm = Assembly.ReflectionOnlyLoad(InRemoteInfo.UserLibraryName)) == null && (UserAsm = Assembly.ReflectionOnlyLoadFrom(InRemoteInfo.UserLibrary)) == null)
                throw new DllNotFoundException("The given assembly could not be found.");
Exception occured in first statement. so I changed above code to
try
{
    UserAsm = Assembly.ReflectionOnlyLoad(InRemoteInfo.UserLibraryName);
}
catch
{
    try
    {
        UserAsm = Assembly.ReflectionOnlyLoadFrom(InRemoteInfo.UserLibrary);
        if (UserAsm == null)
            throw;
    }
    catch
    {
        throw new DllNotFoundException("The given assembly could not be found.");
    }
}
then I could pass this part.

In addition, I met the following exception,
 System.InvalidOperationException was caught
  HResult=-2146233079
  Message=환경 변수를 사용하려면 Process 개체의 UseShellExecute 속성을 false로 설정해야 합니다.
  (The Process object must have the UseShellExecute property set to false in order to use environment variables.)
  Source=System
  StackTrace:
       Location: System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
       Location: System.Diagnostics.Process.Start()
       Location: EasyHook.WOW64Bypass.Install() File EasyHook\WOW64Bypass.cs:Line 65
       Location: EasyHook.WOW64Bypass.Inject(Int32 InHostPID, Int32 InTargetPID, Int32 InWakeUpTID, Int32 InNativeOptions, String InLibraryPath_x86, String InLibraryPath_x64, Boolean InRequireStrongName, Object[] InPassThruArgs) File EasyHook\WOW64Bypass.cs:Line 89
       Location: 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) File EasyHook\RemoteHook.cs:Line 685
       Location: EasyHook.RemoteHooking.Inject(Int32 InTargetPID, InjectionOptions InOptions, String InLibraryPath_x86, String InLibraryPath_x64, Object[] InPassThruArgs) File EasyHook\RemoteHook.cs:Line 504
       ......
  InnerException: