Example #1
0
        public void Refresh(Process p, ProcessModule m, bool isDisabled)
        {
            SetStringProperty("ProcessID", p.Id);
            SetStringProperty("MainExecutable", m.FileName);
            if (SetStringProperty("Name", System.IO.Path.GetFileName(m.FileName)))
            {
                SetStringProperty("ToolTipCaption", Name);
            }

            SetStringProperty("Path", System.IO.Path.GetDirectoryName(m.FileName));
            SetStringProperty("ModuleMemorySize", Localisation.BytesToSize(m.ModuleMemorySize));

            FileVersionInfoCache.CacheInfo ci = FileVersionInfoCache.Get(m.FileName, m);
            if (ci != null)
            {
                if (SetStringProperty("FileDescription", ci.FileDescription))
                {
                    SetStringProperty("ToolTip", ci.FileDescription);
                }
                SetStringProperty("FileVersion", ci.FileVersion);
                SetStringProperty("Product", ci.ProductName);
                SetStringProperty("ProductVersion", ci.ProductVersion);
            }

            SetRunning(!Path.ToLower().Contains(Environment.GetEnvironmentVariable("windir").ToLower()));
            SetDisabled(isDisabled);
        }
Example #2
0
        public void Refresh(Process p)
        {
            if (KnownSystemServices == null)
            {
                KnownSystemServices = new Dictionary <string, string>()
                {
                    { "smss", Resources.IDS_PROCESS_SMSS },
                    { "svchost", Resources.IDS_PROCESS_SVCHOST },
                    { "services", Resources.IDS_PROCESS_SERVICES },
                    { "csrss", Resources.IDS_PROCESS_CSRSS }
                };
            }

            bool isSystemProcess = false;

            if (KnownSystemServices.ContainsKey(p.ProcessName))
            {
                if (!ConstructionIsFinished)
                {
                    SetStringProperty("MainExecutable", KnownSystemServices[p.ProcessName]);
                    SetStringProperty("ToolTip", KnownSystemServices[p.ProcessName]);
                    SetStringProperty("User", "SYSTEM");
                }
                isSystemProcess = true;
            }
            else if (SetStringProperty("MainExecutable", NativeProcessFunctions.GetSafeProcessName(p)))
            {
                NotifyPropertyChanged("InstallLocation");
                ToolTip = MainExecutable;
                NotifyPropertyChanged("ToolTip");
            }
            SetStringProperty("Name", p.ProcessName);

            if (!isSystemProcess)
            {
                SetStringProperty("User", NativeProcessFunctions.GetUserInfo(p));
            }


            bool isRunning  = false;
            bool isDisabled = false;

            if (Environment.UserName.Equals(User))
            {
                isRunning = true;
            }

            try
            {
                if (p.Id >= 10)
                {
                    if (!ConstructionIsFinished)
                    {
                        if (!isSystemProcess)
                        {
                            FileVersionInfoCache.CacheInfo ci = FileVersionInfoCache.Get(MainExecutable, p.MainModule);
                            if (ci != null)
                            {
                                SetStringProperty("FileDescription", ci.FileDescription);
                                SetStringProperty("FileVersion", ci.FileVersion);
                                SetStringProperty("Product", ci.ProductName);
                                SetStringProperty("ProductVersion", ci.ProductVersion);
                            }
                        }
                        ProcessInfoCache.Data pi = ProcessInfoCache.Get(p);
                        if (pi != null)
                        {
                            SetStringProperty("CommandLine", pi.CommandLine);
                            SetStringProperty("FileDescription", pi.CommandLine);
                        }
                        SetStringProperty("StartTime", p.StartTime.TimeOfDay);
                    }
                    SetStringProperty("MainWindowHandle", p.MainWindowHandle);
                    SetStringProperty("MainWindowTitle", p.MainWindowTitle);
                    SetStringProperty("Responding", p.Responding);

                    SetStringProperty("TotalRunTime", DateTime.Now - p.StartTime);
                    SetStringProperty("TotalProcessorTime", p.TotalProcessorTime);
                    SetStringProperty("PrivilegedProcessorTime", p.PrivilegedProcessorTime);
                    SetStringProperty("ThreadCount", p.Threads.Count);
                    SetStringProperty("HandleCount", p.HandleCount);
                    if (!isSystemProcess)
                    {
                        SetStringProperty("ProcessPriorityClass", p.PriorityClass);
                    }
                    SetStringProperty("SessionId", p.SessionId);
                    SetStringProperty("NonpagedSystemMemorySize64", Localisation.BytesToSize(p.NonpagedSystemMemorySize64));
                    SetStringProperty("PagedMemorySize64", Localisation.BytesToSize(p.PagedMemorySize64));
                    SetStringProperty("PagedSystemMemorySize64", Localisation.BytesToSize(p.PagedSystemMemorySize64));
                    SetStringProperty("PeakPagedMemorySize64", Localisation.BytesToSize(p.PeakPagedMemorySize64));
                    SetStringProperty("PeakVirtualMemorySize64", Localisation.BytesToSize(p.PeakVirtualMemorySize64));
                    SetStringProperty("PeakWorkingSet64", Localisation.BytesToSize(p.PeakWorkingSet64));
                    SetStringProperty("PrivateMemorySize64", Localisation.BytesToSize(p.PrivateMemorySize64));
                    SetStringProperty("VirtualMemorySize64", Localisation.BytesToSize(p.VirtualMemorySize64));
                    SetStringProperty("WorkingSet64", Localisation.BytesToSize(p.WorkingSet64));
                }
                else
                {
                    isDisabled = true;
                }
            }
            catch (Exception e)
            {
                Log.Error(string.Format("Exception caught while decoding process '{0}'", p), e);
            }

            if (User.Equals("SYSTEM", StringComparison.OrdinalIgnoreCase))
            {
                isDisabled = true;
            }
            string toolTipCaption = FileDescription;

            if (string.IsNullOrEmpty(toolTipCaption))
            {
                toolTipCaption = Name;
            }
            if (!toolTipCaption.Equals(ToolTipCaption))
            {
                ToolTipCaption = toolTipCaption;
                NotifyPropertyChanged("ToolTipCaption");
            }


            SetRunning(isRunning);
            SetDisabled(isDisabled);
        }