Ejemplo n.º 1
0
        public static bool List(FProcessInfoCollection processes)
        {
            processes.Clear();
            IntPtr hSnap = RKernel32.CreateToolhelp32Snapshot(ETh32cs.SnapProcess, 0);

            if (RApi.IsValidHandle(hSnap))
            {
                SProcessEntry32 pe32 = new SProcessEntry32();
                pe32.dwSize = (uint)Marshal.SizeOf(pe32);
                bool next = RKernel32.Process32First(hSnap, ref pe32);
                while (next)
                {
                    FProcessInfo process = new FProcessInfo();
                    process.Id           = pe32.th32ProcessID;
                    process.Threads      = (int)pe32.cntThreads;
                    process.FileName     = pe32.szExeFile;
                    process.PriClassBase = pe32.pcPriClassBase;
                    processes.Push(process);
                    next = RKernel32.Process32Next(hSnap, ref pe32);
                }
                RKernel32.CloseHandle(hSnap);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static FProcessInfo[] Fetch()
        {
            IntPtr hSnap = RKernel32.CreateToolhelp32Snapshot(ETh32cs.SnapProcess, 0);

            if (!RApi.IsValidHandle(hSnap))
            {
                return(null);
            }
            FObjects <FProcessInfo> process = new FObjects <FProcessInfo>();
            SProcessEntry32         pe32    = new SProcessEntry32();

            pe32.dwSize = (uint)Marshal.SizeOf(pe32);
            bool next = RKernel32.Process32First(hSnap, ref pe32);

            while (next)
            {
                FProcessInfo info = new FProcessInfo();
                info.Id       = pe32.th32ProcessID;
                info.Threads  = (int)pe32.cntThreads;
                info.FileName = pe32.szExeFile;
                process.Push(info);
                next = RKernel32.Process32Next(hSnap, ref pe32);
            }
            RKernel32.CloseHandle(hSnap);
            return(process.ToArray());
        }
Ejemplo n.º 3
0
 public FModuleInfoCollection(FProcessInfo process)
 {
     _process = process;
 }