public bool injectIntoProcess(Process process,string assemblyToInject, string className, string methodName, bool x64, bool runtime40) { try { if (process.isNull()) { "The value of the process variable was null".error(); return false; } "Injecting into process {0}:{1} dll {1}".info(process.Id,process.ProcessName, assemblyToInject); var suffix = (x64) ? "64-" : "32-"; suffix += (runtime40) ? "4.0" : "3.5"; var hwnd = process.MainWindowHandle; if (hwnd == IntPtr.Zero) { "Could not get MainWindow handle".error(); return false; } "Got main Window Handle: {0}".info(hwnd); var snoopAssembly = @"Snoop\Snoop\Snoop.exe".assembly(); var directoryName = snoopAssembly.Location.directoryName(); var fileName = directoryName.pathCombine("ManagedInjectorLauncher" + suffix+ ".exe"); var windowHandle= hwnd; var arguments = string.Concat(new object[] { windowHandle, " \"", assemblyToInject,"\" \"", className, "\" \"", methodName,"\"" }); "Starting process {0} with arguments {1}".info(fileName, arguments); fileName.startProcess(arguments); return true; } catch(Exception ex) { ex.logStackTrace(); return false; } }