public HookProcess(Process process, OverlayConfig overlayConfig, OverlayInterface overlayInterface) { if (HookManager.IsHooked(process.Id)) { throw new ProcessAlreadyHookedException(); } overlayInterface.ProcessID = process.Id; OverlayInterface = overlayInterface; Server = RemoteHooking.IpcCreateServer<OverlayInterface>(ref ChannelName, WellKnownObjectMode.Singleton, OverlayInterface); try { var libraryName = typeof (OverlayInterface).Assembly.GetName() .Name + ".dll"; var location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, libraryName); RemoteHooking.Inject(process.Id, InjectionOptions.NoService | InjectionOptions.DoNotRequireStrongName, location, location, ChannelName, overlayConfig); } catch (Exception ex) { throw new InjectionFailedException(ex); } HookManager.AddHookedProcess(process.Id); InjectedProcess = process; }
public EntryPoint(RemoteHooking.IContext inContext, string inChannelName, OverlayConfig overlayConfig) { _interface = RemoteHooking.IpcConnectClient<OverlayInterface>(inChannelName); _interface.Ping(); IDictionary properties = new Hashtable(); properties["name"] = inChannelName; properties["portName"] = inChannelName + Guid.NewGuid() .ToString("N"); var provider = new BinaryServerFormatterSinkProvider(); provider.TypeFilterLevel = TypeFilterLevel.Full; _serverChannel = new IpcServerChannel(properties, provider); ChannelServices.RegisterChannel(_serverChannel, false); }