public ProcessMemoryViewer(RemoteProcess process, ClassNodeView classesView) { Contract.Requires(process != null); Contract.Requires(classesView != null); this.classesView = classesView; InitializeComponent(); sectionsDataGridView.AutoGenerateColumns = false; if (process.IsValid) { DataTable dt = new DataTable(); dt.Columns.Add("address", typeof(string)); dt.Columns.Add("address_val", typeof(IntPtr)); dt.Columns.Add("size", typeof(ulong)); dt.Columns.Add("name", typeof(string)); dt.Columns.Add("protection", typeof(string)); dt.Columns.Add("type", typeof(string)); dt.Columns.Add("module", typeof(string)); process.NativeHelper.EnumerateRemoteSectionsAndModules(process.Process.Handle, delegate(IntPtr baseAddress, IntPtr regionSize, string name, NativeMethods.StateEnum state, NativeMethods.AllocationProtectEnum protection, NativeMethods.TypeEnum type, string modulePath) { var row = dt.NewRow(); row["address"] = baseAddress.ToString("X"); row["address_val"] = baseAddress; row["size"] = (ulong)regionSize.ToInt64(); row["name"] = name; row["protection"] = protection.ToString(); row["type"] = type.ToString(); row["module"] = Path.GetFileName(modulePath); dt.Rows.Add(row); }, null); sectionsDataGridView.DataSource = dt; } }
public ProcessInfoForm(RemoteProcess process, ClassNodeView classesView) { Contract.Requires(process != null); Contract.Requires(classesView != null); this.process = process; this.classesView = classesView; InitializeComponent(); tabControl.ImageList = new ImageList(); tabControl.ImageList.Images.Add(Properties.Resources.B16x16_Category); tabControl.ImageList.Images.Add(Properties.Resources.B16x16_Page_White_Stack); modulesTabPage.ImageIndex = 0; sectionsTabPage.ImageIndex = 1; modulesDataGridView.AutoGenerateColumns = false; sectionsDataGridView.AutoGenerateColumns = false; // TODO: Workaround, Mono can't display a DataGridViewImageColumn. if (NativeMethods.IsUnix()) { moduleIconDataGridViewImageColumn.Visible = false; } if (process.IsValid) { var sections = new DataTable(); sections.Columns.Add("address", typeof(string)); sections.Columns.Add("size", typeof(string)); sections.Columns.Add("name", typeof(string)); sections.Columns.Add("protection", typeof(string)); sections.Columns.Add("type", typeof(string)); sections.Columns.Add("module", typeof(string)); sections.Columns.Add("section", typeof(Section)); var modules = new DataTable(); modules.Columns.Add("icon", typeof(Icon)); modules.Columns.Add("name", typeof(string)); modules.Columns.Add("address", typeof(string)); modules.Columns.Add("size", typeof(string)); modules.Columns.Add("path", typeof(string)); modules.Columns.Add("module", typeof(Module)); process.EnumerateRemoteSectionsAndModules( delegate(Section section) { var row = sections.NewRow(); row["address"] = section.Start.ToString(Constants.StringHexFormat); row["size"] = section.Size.ToString(Constants.StringHexFormat); row["name"] = section.Name; row["protection"] = section.Protection.ToString(); row["type"] = section.Type.ToString(); row["module"] = section.ModuleName; row["section"] = section; sections.Rows.Add(row); }, delegate(Module module) { var row = modules.NewRow(); row["icon"] = NativeMethods.GetIconForFile(module.Path); row["name"] = module.Name; row["address"] = module.Start.ToString(Constants.StringHexFormat); row["size"] = module.Size.ToString(Constants.StringHexFormat); row["path"] = module.Path; row["module"] = module; modules.Rows.Add(row); } ); sectionsDataGridView.DataSource = sections; modulesDataGridView.DataSource = modules; } }