/[RomCheater]/trunk/RomCheater.PluginFramework/Core/ConfigPlugin.cs
ViewVC logotype

Diff of /trunk/RomCheater.PluginFramework/Core/ConfigPlugin.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.PluginFramework/Core/ConfigPlugin.cs	2012/05/09 23:23:38	99
+++ trunk/RomCheater.PluginFramework/Core/ConfigPlugin.cs	2012/05/28 09:37:16	177
@@ -1,4 +1,7 @@
-´╗┐using System;
+´╗┐//#define DISABLE_VERBOSE_LOGGING_FOR_PERFORMANCE_BOOST // when defined will disable verbose logging for performance speed-up
+#define DISALLOW_VERBOSE_LOGGING // when defined will disallow verbose logging for performance reasons
+#define ALLOW_SYSTEM_PROCESSES_TO_BE_INLUCDED // when defined system processes will be included in process list
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -6,6 +9,7 @@
 using System.Diagnostics;
 using libWin32.Win32.Threading;
 using RomCheater.Logging;
+using System.IO;
 
 namespace RomCheater.PluginFramework.Core
 {
@@ -25,46 +29,80 @@
         }
         private void init()
         {
+//            loggerflags flags = logger.GetLoggingFlags();
+
+//#if DISABLE_VERBOSE_LOGGING_FOR_PERFORMANCE_BOOST
+//            ushort performance_flags = flags.Value;
+//            if (flags.HasFlag(loggerflags.VERBOSE_DEBUG))
+//            {
+//                performance_flags = (ushort)(performance_flags &~ loggerflags.VERBOSE_DEBUG.Value);
+//            }
+//            if (flags.HasFlag(loggerflags.VERBOSE_ERROR))
+//            {
+//                performance_flags = (ushort)(performance_flags &~ loggerflags.VERBOSE_ERROR.Value);
+//            }
+//#endif
+//            logger.SetLoggingFlags(performance_flags);
+
             List<ProcContainer> proc_list = new List<ProcContainer>();
             foreach (Process proc in Process.GetProcesses())
             {
+                string proc_name = proc.ProcessName.ToLower();
                 try
                 {
                     bool isSystem = false;
-                    string proc_name = proc.ProcessName.ToLower();
                     string proc_user = ThreadControl.GetProcessOwner(proc.Handle, out isSystem).ToLower();
+#if !ALLOW_SYSTEM_PROCESSES_TO_BE_INLUCDED
                     if (isSystem)
                     {
+#if !DISALLOW_VERBOSE_LOGGING
                         logger.VerboseDebug.WriteLine("    not adding process {0} because it is a system process", proc_name);
+#endif
                         continue;
                     }
+#endif
                     ProcContainer container = null;
                     try
-                    {                       
+                    {
                         container = new ProcContainer(proc);
+                        #if !DISALLOW_VERBOSE_LOGGING
                         logger.VerboseDebug.WriteLine("  adding process {0} ", proc_name);
+#endif
+                        proc_list.Add(container);
                     }
-                    catch (Exception ex)
+                    catch (FileNotFoundException) { }
+                    catch (Exception)
                     {
                         //throw;
-                        logger.VerboseDebug.WriteLine("    not adding process {0} because it thew an exception [{1}]", proc_name, ex.Message);
-                        continue;
+                        #if !DISALLOW_VERBOSE_LOGGING
+                        logger.VerboseError.WriteLine("    not adding process {0} because it thew an exception [{1}]", proc_name, ex.ToString());
+#endif
+                        //continue;
                     }
-                    proc_list.Add(container);
                 }
-                catch (System.ComponentModel.Win32Exception)
+                catch (System.ComponentModel.Win32Exception ex)
                 {
-                    continue;
+                    if (!((uint)ex.ErrorCode == 0x80004005))
+                    {
+                        #if !DISALLOW_VERBOSE_LOGGING
+                        logger.VerboseError.WriteLine("    not adding process {0} because it thew an exception [{1}]", proc_name, ex.ToString());
+#endif
+                    }                   
+                    //continue;
                 }
                 catch (Exception)
                 {
-                    continue;
+                    #if !DISALLOW_VERBOSE_LOGGING
+                    logger.VerboseError.WriteLine("    not adding process {0} because it thew an exception [{1}]", proc_name, ex.ToString());
+#endif
+                    //continue;
                 }
             }
             proc_list = proc_list.OrderBy(p => p.Name).ToList();
             Predicate<ProcContainer> predicate = new Predicate<ProcContainer>(IsNotValidProcess);
             proc_list.RemoveAll(predicate);
             ValidProcessesForPlugin = proc_list;
+            //logger.SetLoggingFlags(flags); // reset flags
         }
 
         protected abstract bool IsNotValidProcess(ProcContainer p);

 

  ViewVC Help
Powered by ViewVC 1.1.22