internal static string GetListeningProcess(int iPort)
        {
            string result;

            try
            {
                int num = TcpClientIDNative.GetPIDForConn(iPort, 2u, TcpClientIDNative.TcpTableType.OwnerPidListener);
                if (num < 1)
                {
                    num = TcpClientIDNative.GetPIDForConn(iPort, 23u, TcpClientIDNative.TcpTableType.OwnerPidListener);
                }
                if (num < 1)
                {
                    result = string.Empty;
                }
                else
                {
                    string text = Process.GetProcessById(num).ProcessName.ToLower();
                    if (string.IsNullOrEmpty(text))
                    {
                        text = "unknown";
                    }
                    result = text + ":" + num.ToString();
                }
            }
            catch (Exception ex)
            {
                ////TCPClientProcessor.Proxylog.Logger.Error(ex);
                result = string.Empty;
            }
            return(result);
        }
Beispiel #2
0
        public static TcpClientObject GetPortDetails(Socket client)
        {
            TcpClientObject objClient = new TcpClientObject(client, -1, string.Empty);

            try
            {
                objClient.ClientID = TcpClientIDNative.LocalPortToPIDMap(((IPEndPoint)client.RemoteEndPoint).Port);
            }
            catch (Exception ex)
            {
                ////TCPClientProcessor.Proxylog.Logger.Error(ex);
            }

            return(objClient);
        }
 private static int GetPIDForPort(int iTargetPort)
 {
     try
     {
         int num = TcpClientIDNative.GetPIDForConn(iTargetPort, 2u, TcpClientIDNative.TcpTableType.OwnerPidConnections);
         int result;
         if (num > 0)
         {
             result = num;
             return(result);
         }
         result = TcpClientIDNative.GetPIDForConn(iTargetPort, 23u, TcpClientIDNative.TcpTableType.OwnerPidConnections);
         return(result);
     }
     catch (Exception ex)
     {
         ////TCPClientProcessor.Proxylog.Logger.Error(ex);
     }
     return(0);
 }
 internal static int LocalPortToPIDMap(int iPort)
 {
     return(TcpClientIDNative.GetPIDForPort(iPort));
 }