Beispiel #1
0
        private static string[] ExpandFSPaths(Ruleset.PathsRow path)
        {
            var Result = new List <string>();

            if (!AdvRegistry.IsRegistryPath(path.Path))
            {
                Result.Add(AdvEnvironment.ExpandEnvironmentVariables(path.Path));
            }

            return(Result.ToArray());
        }
Beispiel #2
0
        private static int Benchmark(Ruleset ruleset, int benchmarkTime)
        {
            int accessCounter = 0;

            var time = DateTime.Now.AddMinutes(benchmarkTime);

            while (DateTime.Now < time)
            {
                foreach (Ruleset.PathsRow path in ruleset.Paths)
                {
                    // Try to open every file in list.
                    foreach (var fsPath in ExpandFSPaths(path))
                    {
                        FileStream file = null;
                        try
                        {
                            if (File.Exists(fsPath))
                            {
                                file = File.Open(fsPath, FileMode.Open, FileAccess.Read);
                            }
                        }
                        catch
                        {
                        }
                        finally
                        {
                            if (file != null)
                            {
                                file.Close();
                            }
                        }
                    }

                    if (AdvRegistry.IsRegistryPath(path.Path) && AdvRegistry.IsKeyExists(path.Path))
                    {
                        AdvRegistry.GetValueData(path.Path);
                    }
                }
                accessCounter++;
                Console.Write(".");
            }
            Console.WriteLine();

            return(accessCounter);
        }
Beispiel #3
0
 public void IsRegistryPathOnIcorrectData()
 {
     string[] TestRegistryPaths = new[]
     {
         @"C:\Documents and Settings",
         @"C:\Documents and Settings\All Users\Favorites",
         @"D:\Documents\Pictures",
         @"HKY_CURRENT_USER\Printers\\DeviceOld",
         @"HKEY_LOCAL_MACHIN\SOFTWARE\FGUpdate\Config\\Time1"
     };
     foreach (var RegistryPath in TestRegistryPaths)
     {
         if (AdvRegistry.IsRegistryPath(RegistryPath))
         {
             Assert.Fail("AdvRegistry.IsRegistryPath returned true on:\r\n" + RegistryPath);
         }
     }
 }
Beispiel #4
0
 public void IsRegistryPath()
 {
     string[] TestRegistryPaths = new[]
     {
         @"HKEY_LOCAL_MACHINE\SOFTWARE\FGUpdate\Config",
         @"HKEY_LOCAL_MACHINE\SOFTWARE\Windows 3.1 Migration Status\REG.DAT",
         @"HKEY_USERS\S-1-5-21-515967899-606747145-682003330-500\Identities\{30EA52FF-4D40-469E-B12F-CE5262A1495F}\Software\Microsoft\Outlook Express\5.0\Rules\Filter\FFA\Actions\000",
         @"HKEY_CURRENT_USER\Printers\\DeviceOld",
         @"HKEY_LOCAL_MACHINE\SOFTWARE"
     };
     foreach (var RegistryPath in TestRegistryPaths)
     {
         if (!AdvRegistry.IsRegistryPath(RegistryPath))
         {
             Assert.Fail("AdvRegistry.IsRegistryPath returned false on:\r\n" + RegistryPath);
         }
     }
 }