Пример #1
0
        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);
        }
Пример #2
0
 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);
 }