Пример #1
0
        public IChannelClientToServer ConnectToClient(int portNumber)
        {
            IChannelClientToServer remoteObject = null;

            try
            {
                //connect to the MissionControl client at port number given to client from hookengine
                m_ServerToClientChannel = new TcpClientChannel("WinSniperClient" + portNumber.ToString(), null);
                ChannelServices.RegisterChannel(m_ServerToClientChannel, true);
                string url = "tcp://localhost:" + portNumber.ToString() + "/WinSniperClient.rem";
                //get the marshalled object from MissionControl
                remoteObject = (IChannelClientToServer)Activator.GetObject(
                    typeof(IChannelClientToServer), url);
            }
            catch (Exception e)
            {
                sLogger.LogError("Client server could not be found");
                return(null);
            }
            return(remoteObject);
        }
Пример #2
0
        public Window GetWindow(string windowName)
        {
            IChannelClientToServer serverToClientStream = null;

            try
            {
                int  handle;
                uint procId = GetProcId(windowName, out handle);
                if (m_HookTracker.Contains(procId))
                {
                    serverToClientStream = (IChannelClientToServer)m_HookTracker[procId];
                }
                else
                {
                    Thread hookwindow_thread = new Thread(new ParameterizedThreadStart(DllInjector));

                    object[] param = new object[] { windowName };
                    hookwindow_thread.Start((object)param);
                    m_ThreadSynchronizer.WaitOne(m_Timeout);
                    if (!m_success)
                    {
                        return(null);
                    }
                    serverToClientStream = ConnectToClient(m_PortToClient);
                    if (serverToClientStream == null)
                    {
                        return(null);
                    }
                    m_HookTracker.Add(procId, serverToClientStream);
                }

                return(new Window(serverToClientStream, handle));
            }
            catch (Mayday ex)
            {
                sLogger.LogError(ex.Message);
                return(null);
            }
        }
Пример #3
0
 public Window(IChannelClientToServer stream, int windowHandle)
 {
     m_ClientChannel = stream;
     m_WindowHandle  = windowHandle;
 }