Exemplo n.º 1
0
        public FrmRegValueEditBinary(string keyPath, RegValueData value, Client c)
        {
            _connectClient = c;
            _keyPath = keyPath;
            _value = value;

            InitializeComponent();

            this.valueNameTxtBox.Text = value.Name;

            if (value.Kind == Microsoft.Win32.RegistryValueKind.Binary)
            {
                hexEditor.HexTable = (byte[])value.Data;
            }
            else if (value.Kind == Microsoft.Win32.RegistryValueKind.DWord)
            {
                hexEditor.HexTable = BitConverter.GetBytes((uint)(int)value.Data);
            }
            else if (value.Kind == Microsoft.Win32.RegistryValueKind.QWord)
            {
                hexEditor.HexTable = BitConverter.GetBytes((ulong)(long)value.Data);
            }
            else if (value.Kind == Microsoft.Win32.RegistryValueKind.String || value.Kind == Microsoft.Win32.RegistryValueKind.ExpandString)
            {
                //Convert string to bytes
                byte[] bytes = new byte[value.Data.ToString().Length * sizeof(char)];
                Buffer.BlockCopy(value.Data.ToString().ToCharArray(), 0, bytes, 0, bytes.Length);
                hexEditor.HexTable = bytes;
            }
            else if (value.Kind == Microsoft.Win32.RegistryValueKind.MultiString)
            {
                byte[] bytes = MultiStringToBytes((string[])value.Data);
                hexEditor.HexTable = bytes;
            }
        }
Exemplo n.º 2
0
        public FrmRegValueEditString(string keyPath, RegValueData value, Client c)
        {
            _connectClient = c;
            _keyPath = keyPath;
            _value = value;

            InitializeComponent();

            this.valueNameTxtBox.Text = value.Name;
            this.valueDataTxtBox.Text = value.Data.ToString();
        }
        public FrmRegValueEditMultiString(string keyPath, RegValueData value, Client c)
        {
            _connectClient = c;
            _keyPath = keyPath;
            _value = value;

            InitializeComponent();

            this.valueNameTxtBox.Text = value.Name;
            this.valueDataTxtBox.Text = String.Join("\r\n",((string[])value.Data));
        }
Exemplo n.º 4
0
        public FrmRegValueEditWord(string keyPath, RegValueData value, Client c)
        {
            _connectClient = c;
            _keyPath = keyPath;
            _value = value;

            InitializeComponent();

            this.valueNameTxtBox.Text = value.Name;

            if (value.Kind == RegistryValueKind.DWord) {
                this.Text = "Edit DWORD (32-bit) Value";
                this.valueDataTxtBox.Text = ((uint)(int)value.Data).ToString("X");
                this.valueDataTxtBox.MaxLength = HEXA_32BIT_MAX_LENGTH;
            }
            else if (value.Kind == RegistryValueKind.QWord) {
                this.Text = "Edit QWORD (64-bit) Value";
                this.valueDataTxtBox.Text = ((ulong)(long)value.Data).ToString("X");
                this.valueDataTxtBox.MaxLength = HEXA_64BIT_MAX_LENGTH;
            }
            valueBase = HEXA_BASE;
        }
Exemplo n.º 5
0
        public FrmRegValueEditWord(string keyPath, RegValueData value, Client c)
        {
            _connectClient = c;
            _keyPath = keyPath;
            _value = value;

            InitializeComponent();

            this.valueNameTxtBox.Text = value.Name;

            if (value.Kind == RegistryValueKind.DWord)
            {
                this.Text = "Edit DWORD (32-bit) Value";
                this.valueDataTxtBox.Type = WordType.DWORD;
                this.valueDataTxtBox.Text = ((uint)(int)value.Data).ToString("x");
            }
            else
            {
                this.Text = "Edit QWORD (64-bit) Value";
                this.valueDataTxtBox.Type = WordType.QWORD;
                this.valueDataTxtBox.Text = ((ulong)(long)value.Data).ToString("x");
            }
        }
Exemplo n.º 6
0
 private Form GetEditForm(string keyPath, RegValueData value, RegistryValueKind valueKind)
 {
     switch (valueKind)
     {
         case RegistryValueKind.String:
         case RegistryValueKind.ExpandString:
             return new FrmRegValueEditString(keyPath, value, _connectClient);
         case RegistryValueKind.DWord:
         case RegistryValueKind.QWord:
             return new FrmRegValueEditWord(keyPath, value, _connectClient);
         case RegistryValueKind.MultiString:
             return new FrmRegValueEditMultiString(keyPath, value, _connectClient);
         case RegistryValueKind.Binary:
             return new FrmRegValueEditBinary(keyPath, value, _connectClient);
         default:
             return null;
     }
 }
Exemplo n.º 7
0
        public void ChangeValueFromList(string keyPath, RegValueData value)
        {
            TreeNode key = GetTreeNode(keyPath);

            if (key != null)
            {
                lstRegistryKeys.Invoke((MethodInvoker)delegate
                {
                    //Can only change if the value exists in the tag
                    if (key.Tag != null && key.Tag.GetType() == typeof(List<RegValueData>))
                    {
                        List<RegValueData> ValuesFromNode = (List<RegValueData>)key.Tag;
                        var regValue = ValuesFromNode.Find(item => item.Name == value.Name);
                        regValue.Data = value.Data;

                        if (tvRegistryDirectory.SelectedNode == key)
                        {
                            //Make sure if it is a default value
                            string name = String.IsNullOrEmpty(value.Name) ? DEFAULT_REG_VALUE : value.Name;
                            var index = lstRegistryKeys.Items.IndexOfKey(name);
                            if (index != -1)
                            {
                                RegistryValueLstItem valueItem = (RegistryValueLstItem)lstRegistryKeys.Items[index];
                                valueItem.Data = value.GetDataAsString();
                            }
                        }
                        else
                        {
                            tvRegistryDirectory.SelectedNode = key;
                        }
                    }
                });
            }
        }
Exemplo n.º 8
0
        public void AddValueToList(string keyPath, RegValueData value)
        {
            TreeNode key = GetTreeNode(keyPath);

            if (key != null )
            {
                lstRegistryKeys.Invoke((MethodInvoker)delegate
                {
                    List<RegValueData> ValuesFromNode = null;
                    if (key.Tag != null && key.Tag.GetType() == typeof(List<RegValueData>)) {
                        ValuesFromNode = (List<RegValueData>)key.Tag;
                        ValuesFromNode.Add(value);
                    }
                    else
                    {
                        //The tag has a incorrect element or is missing data
                        ValuesFromNode = new List<RegValueData>();
                        ValuesFromNode.Add(value);
                        key.Tag = ValuesFromNode;
                    }

                    //Deactivate sorting
                    lstRegistryKeys.Sorting = SortOrder.None;

                    if (tvRegistryDirectory.SelectedNode == key)
                    {
                        RegistryValueLstItem item = new RegistryValueLstItem(value.Name, value.GetKindAsString(), value.GetDataAsString());
                        //unselect all
                        lstRegistryKeys.SelectedIndices.Clear();
                        lstRegistryKeys.Items.Add(item);
                        item.Selected = true;
                        lstRegistryKeys.LabelEdit = true;
                        item.BeginEdit();
                    }
                    else
                    {
                        tvRegistryDirectory.SelectedNode = key;
                    }
                });
            }
        }
Exemplo n.º 9
0
 public DoChangeRegistryValue(string keyPath, RegValueData value)
 {
     KeyPath = keyPath;
     Value = value;
 }