Ejemplo n.º 1
0
 public override void Refresh(ObservableCollection <DataObject> objects)
 {
     using (var manager = new RefreshManager <ProcessDataObject>(objects))
     {
         foreach (Process p in Process.GetProcesses())
         {
             ProcessDataObject pdo = null;
             try
             {
                 if (manager.Contains(p.Id.ToString(), out pdo))
                 {
                     pdo.Refresh(p);
                 }
                 else
                 {
                     objects.Add(new ProcessDataObject(p));
                 }
             }
             catch (Exception e)
             {
                 Log.Error(string.Format("Exception caught while analysing process {0}", p), e);
             }
         }
     }
 }
Ejemplo n.º 2
0
        public override void Refresh(ObservableCollection <DataObject> objects)
        {
            using (var manager = new RefreshManager <ServiceDataObject>(objects))
            {
                using (NativeSCManager scm = new NativeSCManager(MachineName))
                {
                    foreach (ENUM_SERVICE_STATUS_PROCESS essp in scm.Refresh(ServicesType))
                    {
                        using (NativeService ns = new NativeService(scm, essp.ServiceName))
                        {
                            ServiceDataObject sdo = null;

                            if (manager.Contains(essp.ServiceName, out sdo))
                            {
                                sdo.UpdateFrom(essp);
                            }
                            else
                            {
                                objects.Add(new ServiceDataObject(ns, essp));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void RefreshEntries(RefreshManager <UninstallerDataObject> manager, RegistryKey rootKey, string keyName)
 {
     using (RegistryKey hkKey = rootKey.OpenSubKey(keyName, false))
     {
         foreach (string subKeyName in hkKey.GetSubKeyNames())
         {
             string keyPath = string.Format("{0}\\{1}", keyName, subKeyName);
             UninstallerDataObject mdo;
             try
             {
                 if (manager.Contains(subKeyName, out mdo))
                 {
                     mdo.Refresh(rootKey, keyPath, subKeyName);
                 }
                 else
                 {
                     mdo = new UninstallerDataObject(rootKey, keyPath, subKeyName);
                     if (!string.IsNullOrEmpty(mdo.ApplicationName))
                     {
                         manager.Objects.Add(mdo);
                     }
                 }
             }
             catch (Exception e)
             {
                 Log.Error(string.Format("unable to analyse registry key {0}", keyPath), e);
             }
         }
     }
 }
Ejemplo n.º 4
0
        public override void Refresh(ObservableCollection <DataObject> objects)
        {
            using (var manager = new RefreshManager <WindowDataObject>(objects))
            {
                foreach (int hwnd in NativeWindowFunctions.EnumWindows())
                {
                    string           internalID = hwnd.ToString("X4");
                    WindowDataObject wdo;

                    if (manager.Contains(internalID, out wdo))
                    {
                        if (!wdo.Refresh(hwnd))
                        {
                            objects.Remove(wdo);
                        }
                    }
                    else
                    {
                        wdo = new WindowDataObject(hwnd);
                        if (!string.IsNullOrEmpty(wdo.Title))
                        {
                            objects.Add(wdo);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override void Refresh(ObservableCollection <DataObject> objects)
        {
            using (var manager = new RefreshManager <ModuleDataObject>(objects))
            {
                foreach (Process p in Process.GetProcesses())
                {
                    bool isDisabled = false;
                    if (p.Id < 10)
                    {
                        continue;
                    }
                    else if (p.ProcessName.Equals("smss") ||
                             p.ProcessName.Equals("svchost") ||
                             p.ProcessName.Equals("services") ||
                             p.ProcessName.Equals("csrss"))
                    {
                        continue;
                    }
                    else
                    {
                        string username = pserv4.processes.NativeProcessFunctions.GetUserInfo(p);
                        if (username.Equals("SYSTEM", StringComparison.OrdinalIgnoreCase))
                        {
                            isDisabled = true;
                        }
                    }
                    ProcessModuleCollection pmc = null;
                    try
                    {
                        pmc = p.Modules;
                    }
                    catch (Exception e)
                    {
                        Log.Error(string.Format("Exception caught while accessing modules of process {0}", p), e);
                    }
                    if (pmc != null)
                    {
                        foreach (ProcessModule m in pmc)
                        {
                            string ID = string.Format("{0}.{1}", p.Id, m.FileName);

                            ModuleDataObject mdo;
                            if (manager.Contains(ID, out mdo))
                            {
                                mdo.Refresh(p, m, isDisabled);
                            }
                            else
                            {
                                objects.Add(new ModuleDataObject(p, m, isDisabled));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public override void Refresh(ObservableCollection<DataObject> objects)
        {
            using(var manager = new RefreshManager<ServiceDataObject>(objects))
            {
                using (NativeSCManager scm = new NativeSCManager(MachineName))
                {
                    foreach (ENUM_SERVICE_STATUS_PROCESS essp in scm.Refresh(ServicesType))
                    {
                        using (NativeService ns = new NativeService(scm, essp.ServiceName))
                        {
                            ServiceDataObject sdo = null;

                            if (manager.Contains(essp.ServiceName, out sdo))
                            {
                                sdo.UpdateFrom(essp);
                            }
                            else
                            {
                                objects.Add(new ServiceDataObject(ns, essp));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void ChangeDirectory(string newDirectory)
        {
            Log.InfoFormat("ChangeDirectory: {0}", newDirectory);
            if (CurrentDirectory != newDirectory)
            {
                CurrentDirectory = newDirectory;

                using(RefreshManager<DirectoryItem> refreshManager = new RefreshManager<DirectoryItem>(Items))
                {
                    foreach(string filename in Directory.GetFiles(newDirectory))
                    {
                        DirectoryItem directoryItem;
                        string key = filename.ToLower();
                        if( refreshManager.Contains(key, out directoryItem))
                        {
                            // todo: refresh this
                        }
                        else
                        {
                            Items.Add(new DirectoryItem(newDirectory, filename, key));
                        }
                    }
                }
            }
            Log.InfoFormat("ChangeDirectory: Items has now {0} elements", Items.Count);
        }
Ejemplo n.º 8
0
        private void RefreshEntries(RefreshManager<UninstallerDataObject> manager, RegistryKey rootKey, string keyName)
        {
            using(RegistryKey hkKey = rootKey.OpenSubKey(keyName,false))
            {
                foreach (string subKeyName in hkKey.GetSubKeyNames())
                {
                    string keyPath = string.Format("{0}\\{1}", keyName, subKeyName);
                    UninstallerDataObject mdo;
                    try
                    {
                        if (manager.Contains(subKeyName, out mdo))
                        {
                            mdo.Refresh(rootKey, keyPath, subKeyName);
                        }
                        else
                        {
                            mdo = new UninstallerDataObject(rootKey, keyPath, subKeyName);
                            if (!string.IsNullOrEmpty(mdo.ApplicationName))
                            {
                                manager.Objects.Add(mdo);
                            }
                        }
                    }
                    catch(Exception e)
                    {
                        Log.Error(string.Format("unable to analyse registry key {0}", keyPath), e);
                    }

                }
            }
        }
Ejemplo n.º 9
0
        public override void Refresh(ObservableCollection<DataObject> objects)
        {
            using (var manager = new RefreshManager<ModuleDataObject>(objects))
            {
                foreach (Process p in Process.GetProcesses())
                {
                    bool isDisabled = false;
                    if (p.Id < 10)
                    {
                        continue;
                    }
                    else if (p.ProcessName.Equals("smss") ||
                        p.ProcessName.Equals("svchost") ||
                        p.ProcessName.Equals("services") ||
                        p.ProcessName.Equals("csrss"))
                    {
                        continue;
                    }
                    else
                    {
                        string username = pserv4.processes.NativeProcessFunctions.GetUserInfo(p);
                        if (username.Equals("SYSTEM", StringComparison.OrdinalIgnoreCase))
                        {
                            isDisabled = true;
                        }
                    }
                    ProcessModuleCollection pmc = null;
                    try
                    {
                        pmc = p.Modules;
                    }
                    catch(Exception e)
                    {
                        Log.Error(string.Format("Exception caught while accessing modules of process {0}", p), e);
                    }
                    if( pmc != null )
                    {
                        foreach (ProcessModule m in pmc)
                        {
                            string ID = string.Format("{0}.{1}", p.Id, m.FileName);

                            ModuleDataObject mdo;
                            if (manager.Contains(ID, out mdo))
                            {
                                mdo.Refresh(p, m, isDisabled);
                            }
                            else
                            {
                                objects.Add(new ModuleDataObject(p, m, isDisabled));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public override void Refresh(ObservableCollection<DataObject> objects)
 {
     using (var manager = new RefreshManager<ProcessDataObject>(objects))
     {
         foreach (Process p in Process.GetProcesses())
         {
             ProcessDataObject pdo = null;
             try
             {
                 if (manager.Contains(p.Id.ToString(), out pdo))
                 {
                     pdo.Refresh(p);
                 }
                 else
                 {
                     objects.Add(new ProcessDataObject(p));
                 }
             }
             catch(Exception e)
             {
                 Log.Error(string.Format("Exception caught while analysing process {0}", p), e);
             }
         }
     }
 }
Ejemplo n.º 11
0
        public override void Refresh(ObservableCollection<DataObject> objects)
        {
            using (var manager = new RefreshManager<WindowDataObject>(objects))
            {
                foreach (int hwnd in NativeWindowFunctions.EnumWindows())
                {
                    string internalID = hwnd.ToString("X4");
                    WindowDataObject wdo;

                    if (manager.Contains(internalID, out wdo))
                    {
                        if( !wdo.Refresh(hwnd) )
                        {
                            objects.Remove(wdo);
                        }
                    }
                    else
                    {
                        wdo = new WindowDataObject(hwnd);
                        if (!string.IsNullOrEmpty(wdo.Title))
                        {
                            objects.Add(wdo);
                        }
                    }
                }
            }
        }