Exemplo n.º 1
0
        /// <summary>
        /// Get interface object from host.
        /// <para>Fixed method from Easyhook for two-way communication.</para>
        /// </summary>
        /// <param name="channel"></param>
        /// <returns></returns>
        private InjectInterface IpcConnectClient(string channel)
        {
            IDictionary props = new Hashtable();

            props["name"]     = Util.GenerateName();
            props["port"]     = 0;
            props["portName"] = props["name"];
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(props, null);

            //BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            _channel = new IpcServerChannel(props, serverProvider);
            ChannelServices.RegisterChannel(_channel, false);

            InjectInterface Interface =
                (InjectInterface)Activator.GetObject(typeof(InjectInterface), "ipc://" + channel + "/" + channel);

            if (Interface == null)
            {
                throw new ArgumentException("Unable to create remote interface.");
            }

            return(Interface);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Injectable Process
 /// </summary>
 /// <param name="pid">target PID</param>
 /// <param name="sleepInterval">how much time dll thread will sleep once when idle</param>
 public InjectableProcess(int pid, int sleepInterval = SLEEP_TIME)
 {
     _pid = pid;
     _interface = new InjectInterface();
     SleepInterval = sleepInterval;
     //MARK:An IpcChannel that shall be keept alive until the server is not needed anymore.
     _channel = Util.IpcCreateServer(ref _channelName, WellKnownObjectMode.Singleton, _interface);//MARK:注意第三个参数
 }
Exemplo n.º 3
0
 /// <summary>
 /// Injectable Process
 /// </summary>
 /// <param name="pid">target PID</param>
 /// <param name="sleepInterval">how much time dll thread will sleep once when idle</param>
 public InjectableProcess(int pid, int sleepInterval = SLEEP_TIME)
 {
     _pid          = pid;
     _interface    = new InjectInterface();
     SleepInterval = sleepInterval;
     //MARK:An IpcChannel that shall be keept alive until the server is not needed anymore.
     _channel = Util.IpcCreateServer(ref _channelName, WellKnownObjectMode.Singleton, _interface);//MARK:注意第三个参数
 }
Exemplo n.º 4
0
        public Injectable(RemoteHooking.IContext inContext, String inChannelName)
        {
            ChannelName = inChannelName;

            _interface = IpcConnectClient(ChannelName);
            _interface.Ping();

            _sleepInterval                = _interface.SleepInterval;
            _interface.Wrapper            = new EventWrapper();
            _interface.Wrapper.OnCommand += OnCommand;
            _interface.OnResponse        += _interface.Wrapper.FireResponse;
            _interface.OnExit            += _interface.Wrapper.FireExit;
        }