コード例 #1
0
        private void LoadProcess(MemoryObject mo)
        {
            var         names = mo.ChildNames;
            ProcessItem pitem;

            if (!names.Contains("General"))
            {
                return;
            }

            IDictionary <string, string> generalDict;

            using (MemoryObject general = mo.GetChild("General"))
                generalDict = Dump.GetDictionary(general);

            pitem = new ProcessItem
            {
                Pid       = Dump.ParseInt32(generalDict["ProcessId"]),
                Name      = generalDict["Name"],
                ParentPid = Dump.ParseInt32(generalDict["ParentPid"])
            };

            if (generalDict.ContainsKey("HasParent"))
            {
                pitem.HasParent = Dump.ParseBool(generalDict["HasParent"]);
            }
            if (generalDict.ContainsKey("StartTime"))
            {
                pitem.CreateTime = Dump.ParseDateTime(generalDict["StartTime"]);
            }
            if (generalDict.ContainsKey("SessionId"))
            {
                pitem.SessionId = Dump.ParseInt32(generalDict["SessionId"]);
            }

            if (generalDict.ContainsKey("FileName"))
            {
                pitem.FileName = generalDict["FileName"];
            }

            if (generalDict.ContainsKey("FileDescription"))
            {
                pitem.VersionInfo = new ImageVersionInfo
                {
                    FileDescription = generalDict["FileDescription"],
                    CompanyName     = generalDict["FileCompanyName"],
                    FileVersion     = generalDict["FileVersion"],
                    FileName        = pitem.FileName
                };
            }

            if (generalDict.ContainsKey("CommandLine"))
            {
                pitem.CmdLine = generalDict["CommandLine"];
            }
            if (generalDict.ContainsKey("IsPosix"))
            {
                pitem.IsPosix = Dump.ParseBool(generalDict["IsPosix"]);
            }
            if (generalDict.ContainsKey("IsWow64"))
            {
                pitem.IsWow64 = Dump.ParseBool(generalDict["IsWow64"]);
            }
            if (generalDict.ContainsKey("IsBeingDebugged"))
            {
                pitem.IsBeingDebugged = Dump.ParseBool(generalDict["IsBeingDebugged"]);
            }
            if (generalDict.ContainsKey("UserName"))
            {
                pitem.Username = generalDict["UserName"];
            }
            if (generalDict.ContainsKey("ElevationType"))
            {
                pitem.ElevationType = (TokenElevationType)Dump.ParseInt32(generalDict["ElevationType"]);
            }

            if (generalDict.ContainsKey("CpuUsage"))
            {
                pitem.CpuUsage = float.Parse(generalDict["CpuUsage"]);
            }
            if (generalDict.ContainsKey("JobName"))
            {
                pitem.JobName = generalDict["JobName"];
            }
            if (generalDict.ContainsKey("IsInJob"))
            {
                pitem.IsInJob = Dump.ParseBool(generalDict["IsInJob"]);
            }
            if (generalDict.ContainsKey("IsInSignificantJob"))
            {
                pitem.IsInSignificantJob = Dump.ParseBool(generalDict["IsInSignificantJob"]);
            }
            if (generalDict.ContainsKey("Integrity"))
            {
                pitem.Integrity = generalDict["Integrity"];
            }
            if (generalDict.ContainsKey("IntegrityLevel"))
            {
                pitem.IntegrityLevel = Dump.ParseInt32(generalDict["IntegrityLevel"]);
            }
            if (generalDict.ContainsKey("IsDotNet"))
            {
                pitem.IsDotNet = Dump.ParseBool(generalDict["IsDotNet"]);
            }
            if (generalDict.ContainsKey("IsPacked"))
            {
                pitem.IsPacked = Dump.ParseBool(generalDict["IsPacked"]);
            }
            if (generalDict.ContainsKey("VerifyResult"))
            {
                pitem.VerifyResult = (VerifyResult)Dump.ParseInt32(generalDict["VerifyResult"]);
            }
            if (generalDict.ContainsKey("VerifySignerName"))
            {
                pitem.VerifySignerName = generalDict["VerifySignerName"];
            }
            if (generalDict.ContainsKey("ImportFunctions"))
            {
                pitem.ImportFunctions = Dump.ParseInt32(generalDict["ImportFunctions"]);
            }
            if (generalDict.ContainsKey("ImportModules"))
            {
                pitem.ImportModules = Dump.ParseInt32(generalDict["ImportModules"]);
            }

            if (names.Contains("SmallIcon"))
            {
                using (var smallIcon = mo.GetChild("SmallIcon"))
                    pitem.Icon = Dump.GetIcon(smallIcon);
            }

            if (names.Contains("VmCounters"))
            {
                using (var vmCounters = mo.GetChild("VmCounters"))
                    pitem.Process.VirtualMemoryCounters = Dump.GetStruct <VmCountersEx64>(vmCounters).ToVmCountersEx();
            }

            if (names.Contains("IoCounters"))
            {
                using (var ioCounters = mo.GetChild("IoCounters"))
                    pitem.Process.IoCounters = Dump.GetStruct <IoCounters>(ioCounters);
            }

            _processes.Add(pitem.Pid, pitem);
            treeProcesses.AddItem(pitem);
        }