public HandlePropertiesWindow(SystemHandleEntry handle)
        {
            InitializeComponent();
            this.KeyPreview = true;
            this.KeyDown   += (sender, e) =>
            {
                if (e.KeyCode == Keys.Escape)
                {
                    this.Close();
                    e.Handled = true;
                }
            };

            var handleInfo = handle.GetHandleInfo();

            textName.Text = _name = handleInfo.BestName;
            if (textName.Text == "")
            {
                textName.Text = "(unnamed object)";
            }
            textType.Text          = _typeName = handleInfo.TypeName;
            textAddress.Text       = "0x" + handle.Object.ToString("x");
            textGrantedAccess.Text = "0x" + handle.GrantedAccess.ToString("x");

            if (handle.GrantedAccess != 0)
            {
                try
                {
                    Type accessEnumType = NativeTypeFactory.GetAccessType(handleInfo.TypeName);

                    textGrantedAccess.Text += " (" +
                                              NativeTypeFactory.GetAccessString(accessEnumType, handle.GrantedAccess) +
                                              ")";
                }
                catch (NotSupportedException)
                { }
            }

            var basicInfo = handle.GetBasicInfo();

            labelReferences.Text = "References: " + (basicInfo.PointerCount - 1).ToString();
            labelHandles.Text    = "Handles: " + basicInfo.HandleCount.ToString();
            labelPaged.Text      = "Paged: " + basicInfo.PagedPoolUsage.ToString();
            labelNonPaged.Text   = "Non-Paged: " + basicInfo.NonPagedPoolUsage.ToString();
        }
예제 #2
0
        public void Init()
        {
            try
            {
                ObjectInformation handleInfo = ObjectHandle.GetHandleInfo();

                _name = textName.Text = handleInfo.BestName;

                if (string.IsNullOrEmpty(textName.Text))
                {
                    textName.Text = "(unnamed object)";
                }

                _typeName              = textType.Text = handleInfo.TypeName;
                textAddress.Text       = "0x" + ObjectHandle.Object.ToString("x");
                textGrantedAccess.Text = "0x" + ObjectHandle.GrantedAccess.ToString("x");

                if (ObjectHandle.GrantedAccess != 0)
                {
                    try
                    {
                        Type accessEnumType = NativeTypeFactory.GetAccessType(handleInfo.TypeName);
                        textGrantedAccess.Text += " (" + NativeTypeFactory.GetAccessString(accessEnumType, ObjectHandle.GrantedAccess) + ")";
                    }
                    catch (NotSupportedException)
                    {
                    }
                }

                ObjectBasicInformation basicInfo = ObjectHandle.GetBasicInfo();

                labelReferences.Text = "References: " + (basicInfo.PointerCount - 1);
                labelHandles.Text    = "Handles: " + basicInfo.HandleCount.ToString();
                labelPaged.Text      = "Paged: " + basicInfo.PagedPoolUsage.ToString();
                labelNonPaged.Text   = "Non-Paged: " + basicInfo.NonPagedPoolUsage.ToString();

                if (HandlePropertiesCallback != null)
                {
                    try
                    {
                        HandlePropertiesCallback(groupObjectInfo, _name, _typeName);
                    }
                    catch
                    {
                    }

                    if (groupObjectInfo.Controls.Count == 0)
                    {
                        groupObjectInfo.Visible = false;
                    }
                    else if (groupObjectInfo.Controls.Count == 1)
                    {
                        Control control = groupObjectInfo.Controls[0];

                        // If it's a user control, dock it.
                        if (control is UserControl)
                        {
                            control.Dock   = DockStyle.Fill;
                            control.Margin = new Padding(3);
                        }
                        else
                        {
                            control.Location = new System.Drawing.Point(10, 20);
                        }
                    }
                }
            }
            catch (Exception)
            { }

            this.ActiveControl = this.label1;
        }