private void comboUsername_TextChanged(object sender, EventArgs e) { if (_pid == -1) { if (isServiceUser()) { textPassword.Enabled = false; comboType.SelectedItem = "Service"; // hack for XP if (comboUsername.Text.ToUpper() == "NT AUTHORITY\\SYSTEM" && OSVersion.IsBelowOrEqual(WindowsVersion.XP)) { comboType.SelectedItem = "NewCredentials"; } } else { textPassword.Enabled = true; comboType.SelectedItem = "Interactive"; } } }
private void LoadStage1() { this.InitializeHighlightingColors(); this.LoadSettings(); if (!OSVersion.HasUac) { comboElevationLevel.Enabled = false; } bool visualStyles = Application.RenderWithVisualStyles; foreach (TabPage tab in tabControl.TabPages) { foreach (Control c in tab.Controls) { // If we don't have visual styles or we're on XP, fix control backgrounds. if (!visualStyles || OSVersion.IsBelowOrEqual(WindowsVersion.XP)) { if (c is CheckBox) { (c as CheckBox).FlatStyle = FlatStyle.Standard; } if (c is RadioButton) { (c as RadioButton).FlatStyle = FlatStyle.Standard; } } // Add event handlers to enable the apply button. if (c is CheckBox || c is ListView || c is NumericUpDown) { c.Click += (sender, e) => this.EnableApplyButton(); } else if (c is TextBox) { (c as TextBox).TextChanged += (sender, e) => this.EnableApplyButton(); } else if (c is ComboBox) { (c as ComboBox).SelectedIndexChanged += (sender, e) => this.EnableApplyButton(); } else if (c is NumericUpDown) { (c as NumericUpDown).ValueChanged += (sender, e) => this.EnableApplyButton(); } else if (c is ColorModifier) { (c as ColorModifier).ColorChanged += (sender, e) => this.EnableApplyButton(); } else if (c is Button || c is Label || c is GroupBox) { // Nothing } else { c.Click += (sender, e) => this.EnableApplyButton(); } } } }
public HeapsWindow(int pid, HeapInformation[] heaps) { InitializeComponent(); this.AddEscapeToClose(); this.SetTopMost(); listHeaps.SetDoubleBuffered(true); listHeaps.SetTheme("explorer"); listHeaps.AddShortcuts(); listHeaps.ContextMenu = menuHeap; GenericViewMenu.AddMenuItems(copyMenuItem.MenuItems, listHeaps, null); // Native threads don't work properly on XP. if (OSVersion.IsBelowOrEqual(WindowsVersion.XP)) { destroyMenuItem.Visible = false; } var comparer = new SortedListViewComparer(listHeaps); listHeaps.ListViewItemSorter = comparer; comparer.CustomSorters.Add(1, (l1, l2) => { HeapInformation heap1 = l1.Tag as HeapInformation; HeapInformation heap2 = l2.Tag as HeapInformation; return(heap1.BytesAllocated.CompareTo(heap2.BytesAllocated)); }); comparer.CustomSorters.Add(2, (l1, l2) => { HeapInformation heap1 = l1.Tag as HeapInformation; HeapInformation heap2 = l2.Tag as HeapInformation; return(heap1.BytesCommitted.CompareTo(heap2.BytesCommitted)); }); _pid = pid; IntPtr defaultHeap = IntPtr.Zero; try { using (var phandle = new ProcessHandle( pid, Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights)) defaultHeap = phandle.GetHeap(); } catch (WindowsException) { } long allocatedTotal = 0, committedTotal = 0; int entriesTotal = 0, tagsTotal = 0, pseudoTagsTotal = 0; foreach (HeapInformation heap in heaps) { ListViewItem litem = listHeaps.Items.Add(new ListViewItem( new string[] { Utils.FormatAddress(heap.Address), heap.BytesAllocated.ToString("N0") + " B", heap.BytesCommitted.ToString("N0") + " B", heap.EntryCount.ToString("N0") //heap.TagCount.ToString("N0"), //heap.PseudoTagCount.ToString("N0") })); litem.Tag = heap; // Make the default heap bold. if (heap.Address == defaultHeap) { litem.Font = new Font(litem.Font, FontStyle.Bold); } // Sum everything up. allocatedTotal += heap.BytesAllocated; committedTotal += heap.BytesCommitted; entriesTotal += heap.EntryCount; tagsTotal += heap.TagCount; pseudoTagsTotal += heap.PseudoTagCount; } // Totals row. listHeaps.Items.Add(new ListViewItem( new string[] { "Totals", allocatedTotal.ToString("N0") + " B", committedTotal.ToString("N0") + " B", entriesTotal.ToString("N0") //tagsTotal.ToString("N0"), //pseudoTagsTotal.ToString("N0") })).Tag = new HeapInformation( IntPtr.Zero, allocatedTotal, committedTotal, tagsTotal, entriesTotal, pseudoTagsTotal ); }