public ResourceListDialog(object valueInfo, bool IsAdd)
            : this()
        {
            Logger.Log("ResourceListDialog, Inside Constructor", Logger.RegistryViewerLoglevel);

            if (valueInfo is SubKeyValueInfo)
                this.ValueInfo = valueInfo as SubKeyValueInfo;
            else
                this.regValueInfo = valueInfo as RegistryValueInfo;

            SetInputData();
        }
        public DWORDValueEditorDialog(object valueInfo, bool bIsAdd)
            : this()
        {
            if (valueInfo is SubKeyValueInfo)
                this.ValueInfo = valueInfo as SubKeyValueInfo;
            else
                this.regValueInfo = valueInfo as RegistryValueInfo;

            this.txtValuename.ReadOnly = !bIsAdd;
            this.bIsAdd = bIsAdd;

            SetInputData();
        }
        public StringEditorDialog(object valueInfo, bool IsAdd)
            : this()
        {
            if (valueInfo is SubKeyValueInfo)
                this.ValueInfo = valueInfo as SubKeyValueInfo;
            else
                this.regValueInfo = valueInfo as RegistryValueInfo;

            this.txtValueName.ReadOnly = !IsAdd;
            this.bIsAdd = IsAdd;

            SetInputData();
        }
        public MultiStringValueEditorDialog(object valueInfo, bool IsAdd, RegistryViewerPlugin _plugin)
            : this()
        {
            if (valueInfo is SubKeyValueInfo)
                this.ValueInfo = valueInfo as SubKeyValueInfo;
            else
                this.regValueInfo = valueInfo as RegistryValueInfo;

            this.txtValuename.ReadOnly = !IsAdd;
            this.bIsAdd = IsAdd;
            this.plugin = _plugin;

            SetInputData();
        }
        public static void GetValueKind(SubKeyValueInfo valueInfo, string sType)
        {
            string[] splits = sType.Split(':');
            switch (splits[0])
            {
            case "hex":
                valueInfo.RegDataType = LWRegistryValueKind.REG_BINARY;
                break;

            case "dword":
                valueInfo.RegDataType = LWRegistryValueKind.REG_DWORD;
                break;

            case "qword":
                valueInfo.RegDataType = LWRegistryValueKind.REG_QUADWORD;
                break;

            case "":
                valueInfo.RegDataType = LWRegistryValueKind.REG_SZ;
                break;

            case "hex(7)":
                valueInfo.RegDataType = LWRegistryValueKind.REG_MULTI_SZ;
                break;

            case "hex(2)":
                valueInfo.RegDataType = LWRegistryValueKind.REG_EXPAND_SZ;
                break;

            case "hex(8)":
                valueInfo.RegDataType = LWRegistryValueKind.REG_RESOURCE_LIST;
                break;

            case "hex(9)":
                valueInfo.RegDataType = LWRegistryValueKind.REG_RESOURCE_REQUIREMENTS_LIST;
                break;

            default:
                valueInfo.RegDataType = LWRegistryValueKind.REG_SZ;
                break;
            }
        }
Exemple #6
0
        public static bool Win32AddSubKeyValue(SubKeyValueInfo valueInfo)
        {
            try
            {
                string[] sValues = valueInfo.sParentKey.GetValueNames();

                foreach (string sValue in sValues)
                {
                    if (sValue.Equals(valueInfo.sValue))
                    {
                        return(false);
                    }
                }

                return(Win32ModifySubKeyValue(valueInfo));
            }
            catch (Exception ex)
            {
                Logger.LogException("Win32CreateSubKey : ", ex);
                return(false);
            }
        }
        public static void GetValueData(SubKeyValueInfo valueInfo, string sData)
        {
            ASCIIEncoding encoder = new ASCIIEncoding();
            string[] splits = sData.Split(':');

            switch (valueInfo.RegDataType)
            {
                case LWRegistryValueKind.REG_BINARY:
                    string[] sDataArry = splits[2].Split(',');
                    byte[] byts = new byte[sDataArry.Length];
                    for (int idx = 0; idx < sDataArry.Length; idx++)
                        byts[idx] = Convert.ToByte(sDataArry[idx], 16);
                    valueInfo.sDataBuf = byts;
                    break;

                case LWRegistryValueKind.REG_DWORD:
                    valueInfo.sDataBuf = ((int)UInt32.Parse(splits[1], System.Globalization.NumberStyles.HexNumber)).ToString();
                    break;

                case LWRegistryValueKind.REG_QUADWORD:
                    valueInfo.sDataBuf = ((long)UInt64.Parse(splits[1], System.Globalization.NumberStyles.HexNumber)).ToString();
                    break;

                case LWRegistryValueKind.REG_EXPAND_SZ:
                    string[] eDataArry = splits[2].Split(',');
                    byte[] eByts = new byte[eDataArry.Length];
                    for (int idx = 0, index = 0; idx < eDataArry.Length; idx++)
                    {
                        if (eDataArry[idx] != "00" && !String.IsNullOrEmpty(eDataArry[idx]))
                        {
                            eByts[index] = Convert.ToByte(eDataArry[idx], 16);
                            index++;
                        }
                    }
                    valueInfo.sData = new ASCIIEncoding().GetString(eByts);
                    break;

                case LWRegistryValueKind.REG_SZ:
                    if (splits[0].StartsWith("\""))
                        splits[0] = splits[0].Substring(1);
                    if (splits[0].EndsWith("\""))
                        splits[0] = splits[0].Substring(0, splits[0].Length - 1);
                    valueInfo.sData = splits[0];
                    break;

                case LWRegistryValueKind.REG_MULTI_SZ:
                    string[] sDataArray = splits[2].Split(',');
                    List<byte> bytlist = new List<byte>();
                    for (int idx = 0; idx < sDataArray.Length; idx += 2)
                        bytlist.Add(Convert.ToByte(sDataArray[idx], 16));
                    byte[] mbyts = new byte[bytlist.Count];
                    bytlist.CopyTo(mbyts);
                    valueInfo.sDataBuf = encoder.GetString(mbyts).Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
                    break;

                case LWRegistryValueKind.REG_RESOURCE_LIST:
                case LWRegistryValueKind.REG_UNKNOWN:
                    string[] sRDataArray = splits[1].Split(',');
                    byte[] rbyts = new byte[sRDataArray.Length];
                    for (int idx = 0; idx < sRDataArray.Length; idx++)
                        rbyts[idx] = Convert.ToByte(sRDataArray[idx], 16);
                    valueInfo.sDataBuf = rbyts;
                    break;

                default:
                    break;
            }
        }
Exemple #8
0
        public static bool Win32ModifySubKeyValue(SubKeyValueInfo valueInfo)
        {
            try
            {
                RegistryKey subKey = valueInfo.sParentKey;

                switch (valueInfo.RegDataType)
                {
                case LWRegistryValueKind.REG_BINARY:
                    subKey.SetValue(valueInfo.sValue,
                                    valueInfo.sDataBuf, RegistryValueKind.Binary);
                    break;

                case LWRegistryValueKind.REG_DWORD:
                    //Use sDataBuf
                    subKey.SetValue(valueInfo.sValue,
                                    valueInfo.sDataBuf, RegistryValueKind.DWord);
                    break;

                case LWRegistryValueKind.REG_EXPAND_SZ:
                    //Use sData
                    subKey.SetValue(valueInfo.sValue,
                                    valueInfo.sData, RegistryValueKind.ExpandString);
                    break;

                case LWRegistryValueKind.REG_QUADWORD:
                    subKey.SetValue(valueInfo.sValue,
                                    valueInfo.sDataBuf, RegistryValueKind.QWord);
                    break;

                case LWRegistryValueKind.REG_SZ:
                    //Use sData
                    subKey.SetValue(valueInfo.sValue,
                                    valueInfo.sData, RegistryValueKind.String);
                    break;

                case LWRegistryValueKind.REG_MULTI_SZ:
                    //Use sDataBuf
                    subKey.SetValue(valueInfo.sValue,
                                    valueInfo.sDataBuf, RegistryValueKind.MultiString);
                    break;

                case LWRegistryValueKind.REG_RESOURCE_LIST:
                case LWRegistryValueKind.REG_RESOURCE_REQUIREMENTS_LIST:
                case LWRegistryValueKind.REG_FULL_RESOURCE_DESCRIPTOR:
                    //Use sDataBuf
                    //subKey.SetValue(valueInfo.sValue,
                    //        valueInfo.sDataBuf, RegistryValueKind.Unknown);
                    string[] sKey = valueInfo.sParentKey.Name.Split(new char[] { '\\' }, 2);
                    RegSetValue(GetRegistryHive(valueInfo.hKey), sKey[1], valueInfo.sValue, valueInfo.sDataBuf);
                    break;

                case LWRegistryValueKind.REG_NONE:
                    subKey.SetValue(valueInfo.sValue,
                                    valueInfo.sData, RegistryValueKind.Unknown);
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("Win32CreateSubKey : ", ex);

                return(false);
            }

            return(true);
        }
        public static bool Win32ModifySubKeyValue(SubKeyValueInfo valueInfo)
        {
            try
            {
                RegistryKey subKey = valueInfo.sParentKey;

                switch (valueInfo.RegDataType)
                {
                    case LWRegistryValueKind.REG_BINARY:
                        subKey.SetValue(valueInfo.sValue,
                                valueInfo.sDataBuf, RegistryValueKind.Binary);
                        break;

                    case LWRegistryValueKind.REG_DWORD:
                        //Use sDataBuf
                        subKey.SetValue(valueInfo.sValue,
                                valueInfo.sDataBuf, RegistryValueKind.DWord);
                        break;

                    case LWRegistryValueKind.REG_EXPAND_SZ:
                        //Use sData
                        subKey.SetValue(valueInfo.sValue,
                                valueInfo.sData, RegistryValueKind.ExpandString);
                        break;

                    case LWRegistryValueKind.REG_QUADWORD:
                        subKey.SetValue(valueInfo.sValue,
                                valueInfo.sDataBuf, RegistryValueKind.QWord);
                        break;

                    case LWRegistryValueKind.REG_SZ:
                        //Use sData
                        subKey.SetValue(valueInfo.sValue,
                                valueInfo.sData, RegistryValueKind.String);
                        break;
                    case LWRegistryValueKind.REG_MULTI_SZ:
                        //Use sDataBuf
                        subKey.SetValue(valueInfo.sValue,
                                valueInfo.sDataBuf, RegistryValueKind.MultiString);
                        break;

                    case LWRegistryValueKind.REG_RESOURCE_LIST:
                    case LWRegistryValueKind.REG_RESOURCE_REQUIREMENTS_LIST:
                    case LWRegistryValueKind.REG_FULL_RESOURCE_DESCRIPTOR:
                        //Use sDataBuf
                        //subKey.SetValue(valueInfo.sValue,
                        //        valueInfo.sDataBuf, RegistryValueKind.Unknown);
                        string[] sKey = valueInfo.sParentKey.Name.Split(new char[] { '\\' } , 2);
                        RegSetValue(GetRegistryHive(valueInfo.hKey), sKey[1], valueInfo.sValue, valueInfo.sDataBuf);
                        break;

                    case LWRegistryValueKind.REG_NONE:
                        subKey.SetValue(valueInfo.sValue,
                                valueInfo.sData, RegistryValueKind.Unknown);
                        break;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("Win32CreateSubKey : ", ex);

                return false;
            }

            return true;
        }
Exemple #10
0
        public static void Win32RegValueKind(RegistryKey hKey, string sValue, SubKeyValueInfo keyValueInfo)
        {
            string        sDataType = string.Empty;
            StringBuilder sbTemp    = new StringBuilder();

            keyValueInfo.sData    = string.Empty;
            keyValueInfo.sDataBuf = null;
            object            sDataBuf = null;
            int               type;
            RegistryValueKind valueKind = hKey.GetValueKind(sValue);

            switch (valueKind)
            {
            case RegistryValueKind.Unknown:
                keyValueInfo.RegDataType = LWRegistryValueKind.REG_RESOURCE_LIST;
                string[] sKey = hKey.ToString().Split(new char[] { '\\' }, 2);
                sDataBuf = RegGetValue(GetRegistryHive(keyValueInfo.hKey), sKey[1], sValue, out type);
                keyValueInfo.intDataType = type;
                if (sDataBuf != null)
                {
                    byte[] sBinaryData = sDataBuf as byte[];
                    foreach (byte byt in sBinaryData)
                    {
                        string stringValue = BitConverter.ToString(new byte[] { byt });
                        if (stringValue.Length == 1)
                        {
                            stringValue = "0" + stringValue;
                        }
                        sbTemp.Append(stringValue);
                        sbTemp.Append(" ");
                    }
                    keyValueInfo.sData = sbTemp.ToString();
                }
                break;

            case RegistryValueKind.Binary:
                keyValueInfo.RegDataType = LWRegistryValueKind.REG_BINARY;
                sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                if (sDataBuf != null)
                {
                    byte[] sBinaryData = sDataBuf as byte[];
                    if (sBinaryData != null)
                    {
                        foreach (byte byt in sBinaryData)
                        {
                            string stringValue = BitConverter.ToString(new byte[] { byt });
                            if (stringValue.Length == 1)
                            {
                                stringValue = "0" + stringValue;
                            }
                            sbTemp.Append(stringValue);
                            sbTemp.Append(" ");
                        }
                    }
                }
                keyValueInfo.sData = sbTemp.ToString();
                break;

            case RegistryValueKind.DWord:
                keyValueInfo.RegDataType = LWRegistryValueKind.REG_DWORD;
                keyValueInfo.sDataBuf    = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                if (keyValueInfo.sDataBuf != null)
                {
                    string sTemp = keyValueInfo.sDataBuf.ToString();
                    sTemp = RegistryUtils.DecimalToBase((UInt32)Convert.ToInt32(keyValueInfo.sDataBuf), 16);
                    keyValueInfo.sData = string.Concat("0x", sTemp.PadLeft(8, '0'), "(", ((uint)Convert.ToInt32(keyValueInfo.sDataBuf)).ToString(), ")");
                }
                break;

            case RegistryValueKind.ExpandString:
                keyValueInfo.RegDataType = LWRegistryValueKind.REG_EXPAND_SZ;
                sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                if (sDataBuf != null)
                {
                    keyValueInfo.sData = sDataBuf.ToString();
                }
                break;

            case RegistryValueKind.MultiString:
                keyValueInfo.RegDataType = LWRegistryValueKind.REG_MULTI_SZ;
                sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                if (sDataBuf != null)
                {
                    string[] sStringData = sDataBuf as string[];
                    if (sStringData != null)
                    {
                        foreach (string sr in sStringData)
                        {
                            sbTemp.Append(sr);
                            sbTemp.Append(" ");
                        }
                    }
                }
                keyValueInfo.sData = sbTemp.ToString();
                break;

            case RegistryValueKind.QWord:
                keyValueInfo.RegDataType = LWRegistryValueKind.REG_QUADWORD;
                sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                if (sDataBuf != null)
                {
                    string sTemp = sDataBuf.ToString();
                    sTemp = RegistryUtils.DecimalToBase((UInt64)Convert.ToInt64(sDataBuf), 16);
                    keyValueInfo.sData = string.Concat("0x", sTemp.PadLeft(16, '0'), "(", ((ulong)Convert.ToInt64(sDataBuf)).ToString(), ")");
                }
                break;

            case RegistryValueKind.String:
                keyValueInfo.RegDataType = LWRegistryValueKind.REG_SZ;
                sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                if (sDataBuf != null)
                {
                    keyValueInfo.sData = sDataBuf.ToString();
                }
                break;

            default:
                keyValueInfo.RegDataType = LWRegistryValueKind.REG_NONE;
                sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                if (sDataBuf != null)
                {
                    keyValueInfo.sData = sDataBuf.ToString();
                }
                else
                {
                    keyValueInfo.sData = "(zero-length binary value)";
                }
                break;
            }
        }
        public static void Win32RegValueKind(RegistryKey hKey, string sValue, SubKeyValueInfo keyValueInfo)
        {
            string sDataType = string.Empty;
            StringBuilder sbTemp = new StringBuilder();
            keyValueInfo.sData = string.Empty;
            keyValueInfo.sDataBuf = null;
            object sDataBuf = null;
            int type;
            RegistryValueKind valueKind = hKey.GetValueKind(sValue);

            switch (valueKind)
            {
                case RegistryValueKind.Unknown:
                    keyValueInfo.RegDataType = LWRegistryValueKind.REG_RESOURCE_LIST;
                    string[] sKey = hKey.ToString().Split(new char[] { '\\' } , 2);
                    sDataBuf = RegGetValue(GetRegistryHive(keyValueInfo.hKey), sKey[1], sValue, out type);
                    keyValueInfo.intDataType = type;
                    if (sDataBuf != null)
                    {
                        byte[] sBinaryData = sDataBuf as byte[];
                        foreach (byte byt in sBinaryData)
                        {
                            string stringValue = BitConverter.ToString(new byte[] { byt });
                            if (stringValue.Length == 1)
                                stringValue = "0" + stringValue;
                            sbTemp.Append(stringValue);
                            sbTemp.Append(" ");
                        }
                        keyValueInfo.sData = sbTemp.ToString();
                    }
                    break;

                case RegistryValueKind.Binary:
                    keyValueInfo.RegDataType = LWRegistryValueKind.REG_BINARY;
                    sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    if (sDataBuf != null)
                    {
                        byte[] sBinaryData = sDataBuf as byte[];
                        if (sBinaryData != null)
                        {
                            foreach (byte byt in sBinaryData)
                            {
                                string stringValue = BitConverter.ToString(new byte[] { byt });
                                if (stringValue.Length == 1)
                                    stringValue = "0" + stringValue;
                                sbTemp.Append(stringValue);
                                sbTemp.Append(" ");
                            }
                        }
                    }
                    keyValueInfo.sData = sbTemp.ToString();
                    break;

                case RegistryValueKind.DWord:
                    keyValueInfo.RegDataType = LWRegistryValueKind.REG_DWORD;
                    keyValueInfo.sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    if (keyValueInfo.sDataBuf != null)
                    {
                        string sTemp = keyValueInfo.sDataBuf.ToString();
                        sTemp = RegistryUtils.DecimalToBase((UInt32)Convert.ToInt32(keyValueInfo.sDataBuf), 16);
                        keyValueInfo.sData = string.Concat("0x", sTemp.PadLeft(8,'0'), "(", ((uint)Convert.ToInt32(keyValueInfo.sDataBuf)).ToString(), ")");
                    }
                    break;

                case RegistryValueKind.ExpandString:
                    keyValueInfo.RegDataType = LWRegistryValueKind.REG_EXPAND_SZ;
                    sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    if (sDataBuf != null)
                    {
                        keyValueInfo.sData = sDataBuf.ToString();
                    }
                    break;

                case RegistryValueKind.MultiString:
                    keyValueInfo.RegDataType = LWRegistryValueKind.REG_MULTI_SZ;
                    sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    if (sDataBuf != null)
                    {
                        string[] sStringData = sDataBuf as string[];
                        if (sStringData != null)
                        {
                            foreach (string sr in sStringData)
                            {
                                sbTemp.Append(sr);
                                sbTemp.Append(" ");
                            }
                        }
                    }
                    keyValueInfo.sData = sbTemp.ToString();
                    break;

                case RegistryValueKind.QWord:
                    keyValueInfo.RegDataType = LWRegistryValueKind.REG_QUADWORD;
                    sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    if (sDataBuf != null)
                    {
                        string sTemp = sDataBuf.ToString();
                        sTemp = RegistryUtils.DecimalToBase((UInt64)Convert.ToInt64(sDataBuf), 16);
                        keyValueInfo.sData = string.Concat("0x", sTemp.PadLeft(16,'0'), "(", ((ulong)Convert.ToInt64(sDataBuf)).ToString(), ")");
                    }
                    break;

                case RegistryValueKind.String:
                    keyValueInfo.RegDataType = LWRegistryValueKind.REG_SZ;
                    sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    if (sDataBuf != null)
                    {
                        keyValueInfo.sData = sDataBuf.ToString();
                    }
                    break;

                default:
                    keyValueInfo.RegDataType = LWRegistryValueKind.REG_NONE;
                    sDataBuf = hKey.GetValue(sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    if (sDataBuf != null)
                        keyValueInfo.sData = sDataBuf.ToString();
                    else
                        keyValueInfo.sData = "(zero-length binary value)";
                    break;
            }
        }
        public static bool Win32AddSubKeyValue(SubKeyValueInfo valueInfo)
        {
            try
            {
                string[] sValues = valueInfo.sParentKey.GetValueNames();

                foreach (string sValue in sValues)
                    if (sValue.Equals(valueInfo.sValue))
                        return false;

                return Win32ModifySubKeyValue(valueInfo);
            }
            catch (Exception ex)
            {
                Logger.LogException("Win32CreateSubKey : ", ex);
                return false;
            }
        }
        private void Do_RecursiveImportKey(StreamReader reader)
        {
            HKEY hKey = HKEY.HEKY_CURRENT_USER;
            RegistryKey sSubKey = null;
            List<LACTreeNode> KeyNodes = new List<LACTreeNode>();
            Hostinfo hn = ctx as Hostinfo;
            IntPtr pRootKey = IntPtr.Zero;
            LACTreeNode pluginNode = plugin.GetPlugInNode();

            if (pluginNode.Nodes.Count != 0 && Configurations.currentPlatform != LikewiseTargetPlatform.Windows)
            {
                Do_CloseRegKeyHandles(pluginNode.Nodes[1] as LACTreeNode);
                pluginNode.Nodes[1].Nodes.Clear();
            }

            while (!reader.EndOfStream)
            {
                string currentLine = reader.ReadLine();
                if (currentLine != null && currentLine.StartsWith("["))
                {
                    hKey = HKEY.HEKY_CURRENT_USER;
                    sSubKey = null;
                    LACTreeNode KeyNode = null;

                    string[] splits = currentLine.Split('\\');
                    if (splits != null && splits.Length != 0)
                    {
                        if (pRootKey != IntPtr.Zero)
                            RegistryInteropWrapper.ApiRegCloseKey(plugin.handle.Handle, pRootKey);

                        foreach (string sName in splits)
                        {
                            string sKeyName = sName.EndsWith("]") ? sName.Substring(0, sName.Length - 1) : sName;
                            sKeyName = sKeyName.StartsWith("[") ? sKeyName.Substring(1) : sKeyName;

                            //Check for the Win defined the HKEY
                            if (sName.StartsWith("["))
                            {
                                Icon ic = Properties.Resources.Reports;

                                if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
                                {
                                    switch (sKeyName.Trim().ToUpper())
                                    {
                                        case "HKEY_CLASSES_ROOT":
                                            hKey = HKEY.HKEY_CLASSES_ROOT;
                                            KeyNode = Manage.CreateIconNode(Properties.Resources.HKEY_CLASSES_ROOT,
                                                                             ic,
                                                                             typeof(RegistryViewerClassesPage),
                                                                             plugin);
                                            KeyNode.Tag = HKEY.HKEY_CLASSES_ROOT;
                                            KeyNodes.Add(KeyNode);
                                            break;

                                        case "HKEY_CURRENT_CONFIG":
                                            hKey = HKEY.HKEY_CURRENT_CONFIG;
                                            KeyNode = Manage.CreateIconNode(Properties.Resources.HKEY_CURRENT_CONFIG,
                                                                             ic,
                                                                             typeof(RegistryViewerConfigPage),
                                                                             plugin);
                                            KeyNode.Tag = HKEY.HKEY_CURRENT_CONFIG;
                                            KeyNodes.Add(KeyNode);
                                            break;

                                        case "HKEY_CURRENT_USER":
                                            hKey = HKEY.HEKY_CURRENT_USER;
                                            KeyNode = Manage.CreateIconNode(Properties.Resources.HKEY_CURRENT_USER,
                                                                             ic,
                                                                             typeof(RegistryViewerUserPage),
                                                                             plugin);
                                            KeyNode.Tag = HKEY.HEKY_CURRENT_USER;
                                            KeyNodes.Add(KeyNode);
                                            break;

                                        case "HKEY_LOCAL_MACHINE":
                                            hKey = HKEY.HKEY_LOCAL_MACHINE;
                                            KeyNode = Manage.CreateIconNode(Properties.Resources.HKEY_LOCAL_MACHINE,
                                                                             ic,
                                                                             typeof(RegistryViewerMachinePage),
                                                                             plugin);
                                            KeyNode.Tag = HKEY.HKEY_LOCAL_MACHINE;
                                            KeyNodes.Add(KeyNode);
                                            break;

                                        case "HKEY_USERS":
                                            hKey = HKEY.HKEY_USERS;
                                            KeyNode = Manage.CreateIconNode(Properties.Resources.HKEY_USERS,
                                                                             ic,
                                                                             typeof(RegistryViewerUsersPage),
                                                                             plugin);
                                            KeyNode.Tag = HKEY.HKEY_USERS;
                                            KeyNodes.Add(KeyNode);
                                            break;
                                    }
                                    RegistryInteropWrapperWindows.Win32RegOpenRemoteBaseKey(hKey,
                                          out sSubKey);
                                }
                                else
                                {
                                    plugin.RegRootKeySelected = Properties.Resources.HKEY_LIKEWISE_IMPORT;
                                    hKey = HKEY.HKEY_LIKEWISE;
                                    KeyNode = Manage.CreateIconNode(Properties.Resources.HKEY_LIKEWISE_IMPORT,
                                                                     ic,
                                                                     typeof(RegistryViewerLikewisePage),
                                                                     plugin);
                                    KeyNode.Tag = HKEY.HKEY_LIKEWISE;
                                    KeyNodes.Add(KeyNode);

                                    if (pluginNode.Nodes[1].Tag != null && pluginNode.Nodes[1].Tag is RegistryEnumKeyInfo)
                                    {
                                        RegistryEnumKeyInfo rootKeyInfo = pluginNode.Nodes[1].Tag as RegistryEnumKeyInfo;
                                        if (rootKeyInfo.pKey != IntPtr.Zero)
                                            pRootKey = rootKeyInfo.pKey;
                                        else
                                            RegistryInteropWrapper.ApiRegOpenKeyExW(plugin.handle.Handle,
                                                                                    IntPtr.Zero,
                                                                                    plugin.RegRootKeySelected,
                                                                                    out pRootKey);
                                    }
                                    else
                                    {
                                        RegistryInteropWrapper.ApiRegOpenKeyExW(plugin.handle.Handle,
                                                                                IntPtr.Zero,
                                                                                plugin.RegRootKeySelected,
                                                                                out pRootKey);
                                    }
                                    //Create the keys under Likewise_Import
                                    if (!sKeyName.Trim().ToUpper().Equals(plugin.RegRootKeySelected))
                                        RegistryInteropWrapper.ApiRegOpenKeyExW(plugin.handle.Handle, pRootKey,
                                            sKeyName, out pRootKey);
                                }
                            }
                            else if (sSubKey != null)
                            {
                                sSubKey = RegistryInteropWrapperWindows.Win32CreateSubKey(sSubKey, sKeyName);
                            }
                            else if (pRootKey != IntPtr.Zero)
                            {
                                IntPtr pSubKey = IntPtr.Zero;
                                RegistryInteropWrapper.ApiRegOpenKeyExW(plugin.handle.Handle, pRootKey, sKeyName, out pSubKey);
                                RegistryInteropWrapper.ApiRegCloseKey(plugin.handle.Handle, pRootKey);
                                pRootKey = pSubKey;
                            }
                        }
                    }
                }
                else if (currentLine != null && currentLine.Contains("="))
                {
                    string[] splits = currentLine.Split('=');
                    if (splits != null && splits.Length != 0)
                    {
                        if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
                        {
                            SubKeyValueInfo valueInfo = new SubKeyValueInfo();
                            valueInfo.hKey = hKey;
                            valueInfo.IsDefaultValue = false;

                            if (splits[0].StartsWith("\""))
                                valueInfo.sValue = splits[0].Substring(1, splits[0].Length - 2);
                            else if (splits[0].Equals("@"))
                                valueInfo.sValue = "";
                            else
                                valueInfo.sValue = splits[0];

                            valueInfo.sParentKey = sSubKey;
                            valueInfo.hKey = hKey;
                            RegistryHelper.GetValueKind(valueInfo, splits[1]);

                            if ((valueInfo.RegDataType == LWRegistryValueKind.REG_BINARY) ||
                              (valueInfo.RegDataType == LWRegistryValueKind.REG_MULTI_SZ) ||
                              (valueInfo.RegDataType == LWRegistryValueKind.REG_EXPAND_SZ) ||
                              (valueInfo.RegDataType == LWRegistryValueKind.REG_RESOURCE_LIST))
                            {
                                while (!reader.EndOfStream && currentLine.Contains(@"\"))
                                {
                                    splits[1] += currentLine;
                                    currentLine = reader.ReadLine();
                                }
                                splits[1] += currentLine;
                                splits[1] = splits[1].Replace('\\', ',');
                                splits[1] = splits[1].Replace(" ", "");
                                splits[1] = splits[1].EndsWith(",") ? splits[1].Substring(0, splits[1].Length - 1) : splits[1];
                            }

                            RegistryHelper.GetValueData(valueInfo, splits[1]);
                            RegistryInteropWrapperWindows.Win32AddSubKeyValue(valueInfo);
                        }
                        else
                        {
                            RegistryValueInfo regValueInfo = new RegistryValueInfo();
                            regValueInfo.pParentKey = pRootKey;

                            if (splits[0].StartsWith("\""))
                                regValueInfo.pValueName = splits[0].Substring(1, splits[0].Length - 2);
                            else
                                regValueInfo.pValueName = splits[0];

                            RegistryHelper.GetValueKind(regValueInfo, splits[1]);

                            if ((regValueInfo.pType == (ulong)RegistryApi.REG_BINARY) ||
                             (regValueInfo.pType == (ulong)RegistryApi.REG_MULTI_SZ) ||
                             (regValueInfo.pType == (ulong)RegistryApi.REG_EXPAND_SZ) ||
                             (regValueInfo.pType == (ulong)RegistryApi.REG_RESOURCE_LIST) ||
                             (regValueInfo.pType == (ulong)RegistryApi.REG_RESOURCE_REQUIREMENTS_LIST) ||
                             (regValueInfo.pType == (ulong)RegistryApi.REG_FULL_RESOURCE_DESCRIPTOR))
                            {
                                while (!reader.EndOfStream && currentLine.Contains(@"\"))
                                {
                                    splits[1] += currentLine;
                                    currentLine = reader.ReadLine();
                                }
                                splits[1] += currentLine;
                                splits[1] = splits[1].Replace('\\', ',');
                                splits[1] = splits[1].Replace(" ", "");
                                splits[1] = splits[1].EndsWith(",") ? splits[1].Substring(0, splits[1].Length - 1) : splits[1];
                            }

                            RegistryHelper.GetValueData(regValueInfo, splits[1]);
                            RegistryInteropWrapper.ApiRegSetValueEx(plugin.handle.Handle,
                                                   regValueInfo.pParentKey,
                                                   regValueInfo.pValueName,
                                                   (uint)regValueInfo.pType,
                                                    regValueInfo.bDataBuf as byte[]);
                        }
                    }
                }
            }
        }
        public static object GetFormatSpecificData(SubKeyValueInfo valueInfo)
        {
            object sData = null;

            switch (valueInfo.RegDataType)
            {
            case LWRegistryValueKind.REG_BINARY:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                byte[] byts = valueInfo.sDataBuf as byte[];
                sData = GetBinaryData(byts);
                break;

            case LWRegistryValueKind.REG_DWORD:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                sData = RegistryUtils.DecimalToBase((UInt32)Convert.ToInt32(valueInfo.sDataBuf), 16).PadLeft(8, '0');
                break;

            case LWRegistryValueKind.REG_EXPAND_SZ:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                byte[]      eByts    = new ASCIIEncoding().GetBytes(valueInfo.sDataBuf.ToString() + "\r\n");
                List <byte> eBytList = new List <byte>();
                foreach (byte byt in eByts)
                {
                    if (byt == 10 || byt == 13)
                    {
                        eBytList.Add((byte)00);
                    }
                    else
                    {
                        eBytList.Add(byt);
                        eBytList.Add((byte)00);
                    }
                }
                eByts = new byte[eBytList.Count];
                eBytList.CopyTo(eByts);
                sData = GetBinaryData(eByts);
                break;

            case LWRegistryValueKind.REG_SZ:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                sData = string.Concat("\"", valueInfo.sDataBuf, "\"");
                break;

            case LWRegistryValueKind.REG_MULTI_SZ:
                string[]      sDataArry = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames) as string[];
                StringBuilder sTempArry = new StringBuilder();
                List <byte>   bytList   = new List <byte>();
                foreach (string value in sDataArry)
                {
                    sTempArry.AppendLine(value);
                }
                byte[] sByts = new ASCIIEncoding().GetBytes(sTempArry.ToString() + "\r\n");
                foreach (byte byt in sByts)
                {
                    if (byt == 10 || byt == 13)
                    {
                        bytList.Add((byte)00);
                    }
                    else
                    {
                        bytList.Add(byt);
                        bytList.Add((byte)00);
                    }
                }
                sByts = new byte[bytList.Count];
                bytList.CopyTo(sByts);
                sData = GetBinaryData(sByts);
                break;

            case LWRegistryValueKind.REG_QUADWORD:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                sData = RegistryUtils.DecimalToBase((UInt64)Convert.ToUInt32(valueInfo.sDataBuf), 16).PadLeft(16, '0');
                break;

            case LWRegistryValueKind.REG_RESOURCE_LIST:
            case LWRegistryValueKind.REG_UNKNOWN:
                string[] sKey        = valueInfo.sParentKey.ToString().Split(new char[] { '\\' }, 2);
                object   data        = RegistryInteropWrapperWindows.RegGetValue(RegistryInteropWrapperWindows.GetRegistryHive(valueInfo.hKey), sKey[1], valueInfo.sValue, out valueInfo.intDataType);
                byte[]   bBinarydata = data as byte[];
                sData = GetBinaryData(bBinarydata);
                break;

            default:
                break;
            }
            return(sData);
        }
        public static void GetValueData(SubKeyValueInfo valueInfo, string sData)
        {
            ASCIIEncoding encoder = new ASCIIEncoding();

            string[] splits = sData.Split(':');

            switch (valueInfo.RegDataType)
            {
            case LWRegistryValueKind.REG_BINARY:
                string[] sDataArry = splits[2].Split(',');
                byte[]   byts      = new byte[sDataArry.Length];
                for (int idx = 0; idx < sDataArry.Length; idx++)
                {
                    byts[idx] = Convert.ToByte(sDataArry[idx], 16);
                }
                valueInfo.sDataBuf = byts;
                break;

            case LWRegistryValueKind.REG_DWORD:
                valueInfo.sDataBuf = ((int)UInt32.Parse(splits[1], System.Globalization.NumberStyles.HexNumber)).ToString();
                break;

            case LWRegistryValueKind.REG_QUADWORD:
                valueInfo.sDataBuf = ((long)UInt64.Parse(splits[1], System.Globalization.NumberStyles.HexNumber)).ToString();
                break;

            case LWRegistryValueKind.REG_EXPAND_SZ:
                string[] eDataArry = splits[2].Split(',');
                byte[]   eByts     = new byte[eDataArry.Length];
                for (int idx = 0, index = 0; idx < eDataArry.Length; idx++)
                {
                    if (eDataArry[idx] != "00" && !String.IsNullOrEmpty(eDataArry[idx]))
                    {
                        eByts[index] = Convert.ToByte(eDataArry[idx], 16);
                        index++;
                    }
                }
                valueInfo.sData = new ASCIIEncoding().GetString(eByts);
                break;

            case LWRegistryValueKind.REG_SZ:
                if (splits[0].StartsWith("\""))
                {
                    splits[0] = splits[0].Substring(1);
                }
                if (splits[0].EndsWith("\""))
                {
                    splits[0] = splits[0].Substring(0, splits[0].Length - 1);
                }
                valueInfo.sData = splits[0];
                break;

            case LWRegistryValueKind.REG_MULTI_SZ:
                string[]    sDataArray = splits[2].Split(',');
                List <byte> bytlist    = new List <byte>();
                for (int idx = 0; idx < sDataArray.Length; idx += 2)
                {
                    bytlist.Add(Convert.ToByte(sDataArray[idx], 16));
                }
                byte[] mbyts = new byte[bytlist.Count];
                bytlist.CopyTo(mbyts);
                valueInfo.sDataBuf = encoder.GetString(mbyts).Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
                break;

            case LWRegistryValueKind.REG_RESOURCE_LIST:
            case LWRegistryValueKind.REG_UNKNOWN:
                string[] sRDataArray = splits[1].Split(',');
                byte[]   rbyts       = new byte[sRDataArray.Length];
                for (int idx = 0; idx < sRDataArray.Length; idx++)
                {
                    rbyts[idx] = Convert.ToByte(sRDataArray[idx], 16);
                }
                valueInfo.sDataBuf = rbyts;
                break;

            default:
                break;
            }
        }
        public static object GetFormatSpecificData(SubKeyValueInfo valueInfo)
        {
            object sData = null;

            switch (valueInfo.RegDataType)
            {
                case LWRegistryValueKind.REG_BINARY:
                    valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    byte[] byts = valueInfo.sDataBuf as byte[];
                    sData = GetBinaryData(byts);
                    break;

                case LWRegistryValueKind.REG_DWORD:
                    valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    sData = RegistryUtils.DecimalToBase((UInt32)Convert.ToInt32(valueInfo.sDataBuf), 16).PadLeft(8, '0');
                    break;

                case LWRegistryValueKind.REG_EXPAND_SZ:
                    valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    byte[] eByts = new ASCIIEncoding().GetBytes(valueInfo.sDataBuf.ToString() + "\r\n");
                    List<byte> eBytList = new List<byte>();
                    foreach (byte byt in eByts)
                    {
                        if (byt == 10 || byt == 13)
                            eBytList.Add((byte)00);
                        else
                        {
                            eBytList.Add(byt);
                            eBytList.Add((byte)00);
                        }
                    }
                    eByts = new byte[eBytList.Count];
                    eBytList.CopyTo(eByts);
                    sData = GetBinaryData(eByts);
                    break;

                case LWRegistryValueKind.REG_SZ:
                    valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    sData = string.Concat("\"", valueInfo.sDataBuf, "\"");
                    break;

                case LWRegistryValueKind.REG_MULTI_SZ:
                    string[] sDataArry = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames) as string[];
                    StringBuilder sTempArry = new StringBuilder();
                    List<byte> bytList = new List<byte>();
                    foreach (string value in sDataArry)
                        sTempArry.AppendLine(value);
                    byte[] sByts = new ASCIIEncoding().GetBytes(sTempArry.ToString() + "\r\n");
                    foreach (byte byt in sByts)
                    {
                        if (byt == 10 || byt == 13)
                            bytList.Add((byte)00);
                        else
                        {
                            bytList.Add(byt);
                            bytList.Add((byte)00);
                        }
                    }
                    sByts = new byte[bytList.Count];
                    bytList.CopyTo(sByts);
                    sData = GetBinaryData(sByts);
                    break;

                case LWRegistryValueKind.REG_QUADWORD:
                    valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                    sData = RegistryUtils.DecimalToBase((UInt64)Convert.ToUInt32(valueInfo.sDataBuf), 16).PadLeft(16, '0');
                    break;

                case LWRegistryValueKind.REG_RESOURCE_LIST:
                case LWRegistryValueKind.REG_UNKNOWN:
                    string[] sKey = valueInfo.sParentKey.ToString().Split(new char[] { '\\' } , 2);
                    object data = RegistryInteropWrapperWindows.RegGetValue(RegistryInteropWrapperWindows.GetRegistryHive(valueInfo.hKey), sKey[1], valueInfo.sValue, out valueInfo.intDataType);
                    byte[] bBinarydata = data as byte[];
                    sData = GetBinaryData(bBinarydata);
                    break;

                default:
                    break;
            }
            return sData;
        }
        public static void GetValueKind(SubKeyValueInfo valueInfo, string sType)
        {
            string[] splits = sType.Split(':');
            switch (splits[0])
            {
                case "hex":
                    valueInfo.RegDataType = LWRegistryValueKind.REG_BINARY;
                    break;

                case "dword":
                    valueInfo.RegDataType = LWRegistryValueKind.REG_DWORD;
                    break;

                case "qword":
                    valueInfo.RegDataType = LWRegistryValueKind.REG_QUADWORD;
                    break;

                case "":
                    valueInfo.RegDataType = LWRegistryValueKind.REG_SZ;
                    break;

                case "hex(7)":
                    valueInfo.RegDataType = LWRegistryValueKind.REG_MULTI_SZ;
                    break;

                case "hex(2)":
                    valueInfo.RegDataType = LWRegistryValueKind.REG_EXPAND_SZ;
                    break;

                case "hex(8)":
                    valueInfo.RegDataType = LWRegistryValueKind.REG_RESOURCE_LIST;
                    break;

                case "hex(9)":
                    valueInfo.RegDataType = LWRegistryValueKind.REG_RESOURCE_REQUIREMENTS_LIST;
                    break;

                default:
                    valueInfo.RegDataType = LWRegistryValueKind.REG_SZ;
                    break;
            }
        }
        private void Do_ExportKeyValues(StreamWriter writer, object ObjInfo, uint valuecount)
        {
            if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
            {
                SubKeyValueInfo valueInfo = null;
                RegistryKey key = ObjInfo as RegistryKey;

                if (key.ValueCount != 0)
                {
                    foreach (string sValueName in key.GetValueNames())
                    {
                        try
                        {
                            valueInfo = new SubKeyValueInfo();
                            valueInfo.sValue = sValueName;
                            valueInfo.sParentKey = key;
                            RegistryInteropWrapperWindows.Win32RegValueKind(key, sValueName, valueInfo);
                            string sValue = String.IsNullOrEmpty(valueInfo.sValue) ?
                                                        "@" :
                                                        string.Concat("\"", valueInfo.sValue, "\"");
                            writer.WriteLine(String.Concat(sValue, "=", RegistryHelper.GetFormatSpecificType((ulong)valueInfo.RegDataType), RegistryHelper.GetFormatSpecificData(valueInfo)));
                        }
                        catch (Exception e)
                        {
                            Logger.LogException("Do_ExportKeyValues()| Exception occured for the KeyValue :" + sValueName, e);
                        }
                    }
                }
            }
            else
            {
                if (valuecount != 0)
                {
                    List<RegistryValueInfo> values = new List<RegistryValueInfo>();
                    RegistryEnumKeyInfo keyInfo = ObjInfo as RegistryEnumKeyInfo;

                    RegistryInteropWrapper.ApiRegEnumValues(
                                        plugin.handle.Handle,
                                        keyInfo.pKey,
                                        valuecount,
                                        out values);

                    if (values != null && values.Count != 0)
                    {
                        foreach (RegistryValueInfo value in values)
                        {
                            if (!String.IsNullOrEmpty(value.pValueName))
                            {
                                try
                                {
                                    RegistryInteropWrapper.ApiRegGetValue(plugin.handle.Handle, value, out value.bDataBuf);
                                    string sRegValueName = value.pValueName.Equals("@") ?
                                                        value.pValueName :
                                                        string.Concat("\"", value.pValueName, "\"");
                                    writer.WriteLine(String.Concat(sRegValueName, "=", RegistryHelper.GetFormatSpecificType(value.pType), RegistryHelper.GetFormatSpecificData(value)));
                                }
                                catch (Exception e)
                                {
                                    Logger.LogException("Do_ExportKeyValues()| Exception occured for the KeyValue :" + value.pValueName, e);
                                }
                            }
                        }
                    }
                }
            }
        }
        public void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;
            LACTreeNode node = mi.Tag as LACTreeNode;

            //Since both are having the different set up proreties each. made two seperate objects.
            //For windows supported registry
            SubKeyValueInfo valueInfo = null;
            SubKeyInfo keyInfo = null;

            //For linux supported registry
            RegistryEnumKeyInfo regKeyInfo = null;
            RegistryValueInfo regValueInfo = null;

            if (mi != null)
            {
				if(mi.Text.Trim().Equals("&Refresh"))
				{
					 treeNode.IsModified = true;
                     treeNode.sc.ShowControl(treeNode);
                     return;
				}
				else if(mi.Text.Trim().Equals("&Help"))
				{
                     ProcessStartInfo psi = new ProcessStartInfo();
                     psi.UseShellExecute = true;
                     psi.FileName = CommonResources.GetString("LAC_Help");
                     psi.Verb = "open";
                     psi.WindowStyle = ProcessWindowStyle.Normal;
                     Process.Start(psi);
                     return;
				}
				else
				{
	                if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
	                {
	                    keyInfo = node == null ? null : node.Tag as SubKeyInfo;
	                    valueInfo = node == null ? mi.Tag as SubKeyValueInfo : null;
	                }
	                else
					{
		                regKeyInfo = node == null ? null : node.Tag as RegistryEnumKeyInfo;
		                regValueInfo = node == null ? mi.Tag as RegistryValueInfo : null;
                        node = node == null ? treeNode : node;

                        if(!treeNode.Text.Trim().Equals(Properties.Resources.HKEY_THIS_MACHINE, StringComparison.InvariantCultureIgnoreCase))
                        {
			                if (regKeyInfo != null)
			                {
			                    RegistryInteropWrapper.ApiRegOpenKeyExW(plugin.handle.Handle,
			                                           plugin.pRootHandle,
			                                           regKeyInfo.sKeyname,
			                                           out regKeyInfo.pKey);
		                    }
							else  if (regValueInfo != null)
		                    {
                                RegistryEnumKeyInfo subKeyInfo = treeNode.Tag as RegistryEnumKeyInfo;
		                        RegistryInteropWrapper.ApiRegOpenKeyExW(plugin.handle.Handle,
	                                               plugin.pRootHandle,
                                                   subKeyInfo.sKeyname,
	                                               out regValueInfo.pParentKey);
							}
						}
						else
						{
							if(regKeyInfo != null)
								regKeyInfo.pKey = plugin.pRootHandle;
							else if(regValueInfo != null)
								regValueInfo.pParentKey = plugin.pRootHandle;
						}
					}
				}

                switch (mi.Text.Trim())
                {
					//Modify
                    case "Modify":
                        if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
                        {
                            valueInfo = mi.Tag is SubKeyValueInfo ? mi.Tag as SubKeyValueInfo : lvRegistryPage.SelectedItems[0].Tag as SubKeyValueInfo;
                            if (valueInfo != null)
                            {
                                DoEditorWork(valueInfo, false, (ulong)valueInfo.RegDataType);
                            }
                        }
                        else if (regValueInfo != null)
                        {
                            DoEditorWork(regValueInfo, false, regValueInfo.pType);
                        }

                        break;

                    //Modify Binary Data
                    case "Modify Binary Data":
                        valueInfo = mi.Tag is SubKeyValueInfo ? mi.Tag as SubKeyValueInfo : lvRegistryPage.SelectedItems[0].Tag as SubKeyValueInfo;
                        if (valueInfo != null)
                        {
                            SubKeyValueInfo tempValueInfo = new SubKeyValueInfo();
                            tempValueInfo.hKey = valueInfo.hKey;
                            tempValueInfo.RegDataType = LWRegistryValueKind.REG_BINARY;
                            tempValueInfo.sData = valueInfo.sData;
                            tempValueInfo.sDataBuf = valueInfo.sDataBuf;
                            tempValueInfo.sParentKey = valueInfo.sParentKey;
                            tempValueInfo.sValue = valueInfo.sValue;
                            DoEditorWork(tempValueInfo, false, (ulong)tempValueInfo.RegDataType);
                        }
                        else if (regValueInfo != null)
                            DoEditorWork(regValueInfo, false, (ulong)RegistryApi.REG_BINARY);
                        break;

                    //Delete
                    case "&Delete":
                        if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
                        {
                            if (keyInfo != null) Do_DeleteKey(keyInfo, node);
                            else if (valueInfo != null) Do_DeleteKeyValue(valueInfo);
                        }
                        else
                        {
                            if (regKeyInfo != null) Do_DeleteKey(regKeyInfo, node);
                            else if (regValueInfo != null) Do_DeleteKeyValue(regValueInfo);
                        }
						break;

                    //Rename
                    case "&Rename":
                        if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
                        {
                            if (keyInfo != null) Do_RenameKey(keyInfo, node);
                            else if (valueInfo != null) Do_RenameKeyValue(valueInfo, treeNode);
                        }
                        else
                        {
                            if (regKeyInfo != null) Do_RenameKey(regKeyInfo, node);
                            else if (regValueInfo != null) Do_RenameKeyValue(regValueInfo, treeNode);
                        }
						break;

                    //Key
                    case "Key":
                        if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
                            Do_CreateKey(keyInfo, node);
                        else
                            Do_CreateKey(regKeyInfo, node);
                        break;

                    //&Import...
                    case "&Import...":
                        Do_ImportRegistry();
                        break;

                    //&Export...
                    case "&Export...":
                        Do_ExportRegistry();
                        break;

                    //String Value
                    case "String Value":
                        if (keyInfo != null)
                        {
                            valueInfo = new SubKeyValueInfo();
                            valueInfo.hKey = keyInfo.hKey;
                            valueInfo.IsDefaultValue = false;
                            valueInfo.RegDataType = LWRegistryValueKind.REG_SZ;
                            valueInfo.sParentKey = keyInfo.sSubKey;
                            DoEditorWork(valueInfo, true, (ulong)valueInfo.RegDataType);
                        }
                        else if (regKeyInfo != null)
                        {
                            regValueInfo = new RegistryValueInfo();
                            regValueInfo.pType = (ulong)RegistryApi.REG_SZ;
                            regValueInfo.pParentKey = regKeyInfo.pKey;
                            DoEditorWork(regValueInfo, true, regValueInfo.pType);
                        }
                        break;

                    //DWORD Value
                    case "DWORD Value":
                        if (keyInfo != null)
                        {
                            valueInfo = new SubKeyValueInfo();
                            valueInfo.hKey = keyInfo.hKey;
                            valueInfo.IsDefaultValue = false;
                            valueInfo.RegDataType = LWRegistryValueKind.REG_DWORD;
                            valueInfo.sParentKey = keyInfo.sSubKey;
                            DoEditorWork(valueInfo, true, (ulong)valueInfo.RegDataType);
                        }
                        else if (regKeyInfo != null)
                        {
                            regValueInfo = new RegistryValueInfo();
                            regValueInfo.pType = (ulong)RegistryApi.REG_DWORD;
                            regValueInfo.pParentKey = regKeyInfo.pKey;
                            DoEditorWork(regValueInfo, true, regValueInfo.pType);
                        }
                        break;

                    //Binary Value
                    case "Binary Value":
                        if (keyInfo != null)
                        {
                            valueInfo = new SubKeyValueInfo();
                            valueInfo.hKey = keyInfo.hKey;
                            valueInfo.IsDefaultValue = false;
                            valueInfo.RegDataType = LWRegistryValueKind.REG_BINARY;
                            valueInfo.sParentKey = keyInfo.sSubKey;
                            DoEditorWork(valueInfo, true, (ulong)valueInfo.RegDataType);
                        }
                        else if (regKeyInfo != null)
                        {
                            regValueInfo = new RegistryValueInfo();
                            regValueInfo.pType = (ulong)RegistryApi.REG_BINARY;
                            regValueInfo.pParentKey = regKeyInfo.pKey;
                            DoEditorWork(regValueInfo, true, regValueInfo.pType);
                        }
                        break;

                    //Multi-String Value
                    case "Multi-String Value":
                        if (keyInfo != null)
                        {
                            valueInfo = new SubKeyValueInfo();
                            valueInfo.hKey = keyInfo.hKey;
                            valueInfo.IsDefaultValue = false;
                            valueInfo.RegDataType = LWRegistryValueKind.REG_MULTI_SZ;
                            valueInfo.sParentKey = keyInfo.sSubKey;
                            DoEditorWork(valueInfo, true, (ulong)valueInfo.RegDataType);
                        }
                        else if (regKeyInfo != null)
                        {
                            regValueInfo = new RegistryValueInfo();
                            regValueInfo.pType = (ulong)RegistryApi.REG_MULTI_SZ;
                            regValueInfo.pParentKey = regKeyInfo.pKey;
                            DoEditorWork(regValueInfo, true, regValueInfo.pType);
                        }
                        break;

                    //Expandable String Value
                    case "Expandable String Value":
                        if (keyInfo != null)
                        {
                            valueInfo = new SubKeyValueInfo();
                            valueInfo.hKey = keyInfo.hKey;
                            valueInfo.IsDefaultValue = false;
                            valueInfo.RegDataType = LWRegistryValueKind.REG_EXPAND_SZ;
                            valueInfo.sParentKey = keyInfo.sSubKey;
                            DoEditorWork(valueInfo, true, (ulong)valueInfo.RegDataType);
                        }
                        else if (regKeyInfo != null)
                        {
                            regValueInfo = new RegistryValueInfo();
                            regValueInfo.pType = (ulong)RegistryApi.REG_EXPAND_SZ;
                            regValueInfo.pParentKey = regKeyInfo.pKey;
                            DoEditorWork(regValueInfo, true, regValueInfo.pType);
                        }
                        break;

                    default:
                        break;
                }
            }
        }
        private void EnumChildNodes(RegistryKey sSubKey, HKEY hKey)
        {
            Array sSubKeys = null;
            Array sValues = null;
            Dictionary<string, LACTreeNode> nodesAdded = new Dictionary<string, LACTreeNode>();
            Dictionary<string, LACTreeNode> nodesToAdd = new Dictionary<string, LACTreeNode>();

            foreach (LACTreeNode n in treeNode.Nodes)
                nodesAdded.Add(n.Text.Trim(), n);

            if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
            {
                if (sSubKey != null)
                {
                    if (nodeType != RegistryViewerPlugin.NodeType.HKEY_SUBKEY)
                    {
                        SubKeyInfo subKeyInfo = new SubKeyInfo();
                        subKeyInfo.sKey = sSubKey.Name;
                        subKeyInfo.hKey = hKey;
                        subKeyInfo.sSubKey = sSubKey;
                        treeNode.Tag = subKeyInfo;
                    }
                    RegistryInteropWrapperWindows.Win32RegSubKeyList(sSubKey, out sSubKeys);

                    if (sSubKeys != null && sSubKeys.Length != 0)
                    {
                        foreach (string key in sSubKeys)
                        {
                            RegistryKey subKey = RegistryInteropWrapperWindows.Win32RegOpenRemoteSubKey(sSubKey, key);

                            Icon ic = Properties.Resources.Reports;
                            LACTreeNode node = Manage.CreateIconNode(key,
                                              ic,
                                              typeof(RegistryViewerKeyPage),
                                              plugin);
                            node.sc = plugin.GetPlugInNode().sc;

                            SubKeyInfo subKeyInfo = new SubKeyInfo();
                            subKeyInfo.sKey = key;
                            subKeyInfo.hKey = hKey;
                            subKeyInfo.sSubKey = subKey;

                            node.Tag = subKeyInfo;

                            if (!nodesAdded.ContainsKey(key.Trim()))
                                nodesToAdd.Add(key, node);
                        }
                    }

                    RegistryInteropWrapperWindows.Win32RegSubKeyValueList(sSubKey, out sValues);

                    ListViewItem lvItem = new ListViewItem(new string[] { "(Default)", "REG_SZ", "(value not set)" });
                    SubKeyValueInfo valueInfo = new SubKeyValueInfo();
                    valueInfo.hKey = hKey;
                    valueInfo.sParentKey = sSubKey;
                    valueInfo.sValue = "";
                    valueInfo.sData = "(value not set)";
                    valueInfo.RegDataType = LWRegistryValueKind.REG_SZ;
                    valueInfo.IsDefaultValue = true;

                    lvItem.Tag = valueInfo;
                    lvRegistryPage.Items.Add(lvItem);

                    if (sValues != null && sValues.Length != 0)
                    {
                        foreach (string value in sValues)
                        {
                            valueInfo = new SubKeyValueInfo();
                            RegistryInteropWrapperWindows.Win32RegValueKind(sSubKey, value, valueInfo);
                            valueInfo.hKey = hKey;
                            valueInfo.sParentKey = sSubKey;
                            valueInfo.sValue = value;
                            valueInfo.IsDefaultValue = false;

                            if (String.IsNullOrEmpty(value))
                            {
                                valueInfo.IsDefaultValue = true;
                                lvItem = new ListViewItem(new string[] { "(Default)", GetRegValueStringType(valueInfo.RegDataType), valueInfo.sData });
                                lvRegistryPage.Items.RemoveAt(0);
                            }
                            else
                                lvItem = new ListViewItem(new string[] { value, GetRegValueStringType(valueInfo.RegDataType), valueInfo.sData });

                            lvItem.Tag = valueInfo;
                            lvRegistryPage.Items.Add(lvItem);
                        }
                    }
                }
            }

            LACTreeNode[] nodestoAddedRe = new LACTreeNode[nodesToAdd.Count];
            int idx = 0;
            if (nodesToAdd != null && nodesToAdd.Count != 0)
            {
                foreach (string key in nodesToAdd.Keys) {
                    nodestoAddedRe[idx] = nodesToAdd[key];
                    idx++;
                }
            }

            if (nodestoAddedRe != null && nodestoAddedRe.Length != 0)
                treeNode.Nodes.AddRange(nodestoAddedRe);
        }
        private bool Do_AddKeyValue(SubKeyValueInfo valueInfo)
        {
            bool bSuccess = false;

            if (valueInfo != null)
            {
                bSuccess = RegistryInteropWrapperWindows.Win32AddSubKeyValue(valueInfo);
            }

            return bSuccess;
        }