Exemplo n.º 1
0
 private void txtPath_Leave(object sender, EventArgs e)
 {
     if (txtPath.Text.Length > 0 && txtPath.Text.ToUpper().StartsWith("HKEY_"))
     {
         string[] parts = txtPath.Text.Split('\\');
         if (parts.Length > 1)
         {
             Microsoft.Win32.RegistryHive rh = RegistryQueryInstance.GetRegistryHiveFromString(parts[0]);
             cboRegistryHive.Text = rh.ToString();
             txtPath.Text         = txtPath.Text.Substring(parts[0].Length + 1);
         }
     }
 }
Exemplo n.º 2
0
        public static void WriteToRegistry(Microsoft.Win32.RegistryHive ParentKeyHive, string SubKeyName, string sKey, string sValue)
        {
            Microsoft.Win32.RegistryKey objSubKey = null;

            Microsoft.Win32.RegistryKey objParentKey = null;


            try {
                switch (ParentKeyHive)
                {
                case Microsoft.Win32.RegistryHive.ClassesRoot:
                    objParentKey = Microsoft.Win32.Registry.ClassesRoot;
                    break;

                case Microsoft.Win32.RegistryHive.CurrentUser:
                    objParentKey = Microsoft.Win32.Registry.CurrentUser;
                    break;

                case Microsoft.Win32.RegistryHive.LocalMachine:
                    objParentKey = Microsoft.Win32.Registry.LocalMachine;
                    break;

                case Microsoft.Win32.RegistryHive.Users:
                    objParentKey = Microsoft.Win32.Registry.Users;

                    break;
                }


                //Open
                objSubKey = objParentKey.OpenSubKey(SubKeyName, true);
                //create if doesn't exist
                if (objSubKey == null)
                {
                    objSubKey = objParentKey.CreateSubKey(SubKeyName);
                }


                objSubKey.SetValue(sKey, sValue);
            } catch (UnauthorizedAccessException exae) {
                WOTStatistics.Core.WOTHelper.AddToLog("Unauthorized Access: " + exae.Message);
            } catch (Exception ex) {
                WOTStatistics.Core.WOTHelper.AddToLog("Error: " + ex.Message);
            }

            objSubKey    = null;
            objParentKey = null;
        }
Exemplo n.º 3
0
        } // End Function RecursivelyListKeys

        public static string ToHiveName(Microsoft.Win32.RegistryHive regHive)
        {
            switch (regHive)
            {
            case Microsoft.Win32.RegistryHive.CurrentUser:
                return("HKEY_CURRENT_USER");

            case Microsoft.Win32.RegistryHive.LocalMachine:
                return("HKEY_LOCAL_MACHINE");

            case Microsoft.Win32.RegistryHive.PerformanceData:
                return("HKEY_PERFORMANCE_DATA");

            case Microsoft.Win32.RegistryHive.Users:
                return("HKEY_USERS");

            case Microsoft.Win32.RegistryHive.ClassesRoot:
                return("HKEY_CLASSES_ROOT");

            case Microsoft.Win32.RegistryHive.CurrentConfig:
                return("HKEY_CURRENT_CONFIG");
                // case Microsoft.Win32.RegistryHive.DynData: return "HKEY_DYN_DATA";

                // default: return regHive.ToString();
            } // End switch (regHive)

            string hiveName = regHive.ToString();

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("HKEY");

            foreach (char c in hiveName)
            {
                if (char.IsUpper(c))
                {
                    sb.Append("_");
                }

                sb.Append(c);
            } // Next c

            hiveName = sb.ToString().ToUpper();
            sb.Clear();
            sb = null;

            return(hiveName);
        } // End Function ToHiveName
        public static bool _OpenRemoteBaseKey_Microsoft_Win32_RegistryHive_System_String( )
        {
            //class object
            Microsoft.Win32.RegistryKey _Microsoft_Win32_RegistryKey = new Microsoft.Win32.RegistryKey();

            //Parameters
            Microsoft.Win32.RegistryHive hKey = null;
            System.String machineName         = null;

            //ReturnType/Value
            Microsoft.Win32.RegistryKey returnVal_Real        = null;
            Microsoft.Win32.RegistryKey returnVal_Intercepted = null;

            //Exception
            System.Exception exception_Real        = null;
            System.Exception exception_Intercepted = null;

            InterceptionMaintenance.disableInterception( );

            try
            {
                returnVal_Real = _Microsoft_Win32_RegistryKey.OpenRemoteBaseKey(hKey, machineName);
            }

            catch (System.Exception e)
            {
                exception_Real = e;
            }


            InterceptionMaintenance.enableInterception( );

            try
            {
                returnVal_Intercepted = _Microsoft_Win32_RegistryKey.OpenRemoteBaseKey(hKey, machineName);
            }

            catch (System.Exception e)
            {
                exception_Intercepted = e;
            }


            return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted));
        }
        private void InitRegistryKey(Microsoft.Win32.RegistryHive hive, string name)
        {
            switch (hive)
            {
            case Microsoft.Win32.RegistryHive.ClassesRoot:
                _registryHive = HKEY_CLASSES_ROOT;
                break;

            case Microsoft.Win32.RegistryHive.CurrentConfig:
                _registryHive = HKEY_CURRENT_CONFIG;
                break;

            case Microsoft.Win32.RegistryHive.CurrentUser:
                _registryHive = HKEY_CURRENT_USER;
                break;

            // case RegistryHive.DynData:
            // _registryHive = HKEY_DYN_DATA;
            // break;

            case Microsoft.Win32.RegistryHive.LocalMachine:
                _registryHive = HKEY_LOCAL_MACHINE;
                break;

            case Microsoft.Win32.RegistryHive.PerformanceData:
                _registryHive = HKEY_PERFORMANCE_DATA;
                break;

            case Microsoft.Win32.RegistryHive.Users:
                _registryHive = HKEY_USERS;
                break;

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException("hive", (int)hive, typeof(Microsoft.Win32.RegistryHive));
            }
            _registrySubName = name;
        }
Exemplo n.º 6
0
 public IRegistryKey OpenBaseKey(Microsoft.Win32.RegistryHive hKey, Microsoft.Win32.RegistryView view)
 {
     return(RegistryKey.Wrap(Microsoft.Win32.RegistryKey.OpenBaseKey(hKey, view)));
 }
Exemplo n.º 7
0
 public static Microsoft.Win32.RegistryKey OpenRemoteBaseKey(Microsoft.Win32.RegistryHive hKey, string machineName, Microsoft.Win32.RegistryView view)
 {
     throw null;
 }
Exemplo n.º 8
0
 public static Microsoft.Win32.RegistryKey OpenBaseKey(Microsoft.Win32.RegistryHive hKey, Microsoft.Win32.RegistryView view)
 {
     throw null;
 }
 public static extern int RegConnectRegistry(
     string lpMachineName,
     Microsoft.Win32.RegistryHive hive,
     out IntPtr phkResult
     );
Exemplo n.º 10
0
 /// <summary>
 /// Creates new instance.
 /// </summary>
 /// <param name="description">Dscription.</param>
 /// <param name="hive">Registry hive.</param>
 /// <param name="valueName">Value name.</param>
 public SystemPolicyAttribute(string description, Microsoft.Win32.RegistryHive hive, string valueName = "")
     : base("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", description, valueName)
 {
     Category = "System";
     Hive     = hive;
 }
Exemplo n.º 11
0
 public static string CreateStoragePath(Microsoft.Win32.RegistryHive hive, Microsoft.Win32.RegistryView view, string path, string name)
 {
     return($"reg:\\\\{view}:{hive}\\{path}\\{name}");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RegistryMonitor"/> class.
 /// </summary>
 /// <param name="registryHive">The registry hive.</param>
 /// <param name="subKey">The sub key.</param>
 public RegistryMonitor(Microsoft.Win32.RegistryHive registryHive, string subKey)
 {
     InitRegistryKey(registryHive, subKey);
 }
Exemplo n.º 13
0
 public UnlockRPC(string HostName, Microsoft.Win32.RegistryHive mainCatalog, string subKey)
 {
     this.HostName    = HostName;
     this.mainCatalog = mainCatalog;
     this.subKey      = subKey;
 }
Exemplo n.º 14
0
 public IRegistryKey OpenRemoteBaseKey(Microsoft.Win32.RegistryHive hKey, string machineName, Microsoft.Win32.RegistryView view)
 {
     return(RegistryKey.Wrap(Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(hKey, machineName, view)));
 }
Exemplo n.º 15
0
 public RegistryPointer(Microsoft.Win32.RegistryHive registryHive, System.String subKey, System.String name)
 {
     this.RegistryHive = registryHive;
     this.SubKey       = subKey;
     this.Name         = name;
 }
Exemplo n.º 16
0
 public static Microsoft.Win32.RegistryKey OpenBaseKey(Microsoft.Win32.RegistryHive hKey, Microsoft.Win32.RegistryView view)
 {
     return(default(Microsoft.Win32.RegistryKey));
 }
Exemplo n.º 17
0
 public IRegistryKey OpenRemoteBaseKey(Microsoft.Win32.RegistryHive hKey, string machineName)
 {
     return((RegistryKey)Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(hKey, machineName));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Creates new instance.
 /// </summary>
 /// <param name="description">Dscription.</param>
 /// <param name="hive">Registry hive.</param>
 /// <param name="valueName">Value name.</param>
 public WindowsSystemPolicyAttribute(string description, Microsoft.Win32.RegistryHive hive, string valueName = "")
     : base(@"Software\Policies\Microsoft\Windows\System", description, valueName)
 {
     Category = "System";
     Hive     = hive;
 }
Exemplo n.º 19
0
 // Events:
 // Methods:
 Void Microsoft.Win32.RegistryKey::.ctor(Microsoft.Win32.RegistryHive)
 Void Microsoft.Win32.RegistryKey::.ctor(Microsoft.Win32.RegistryHiveIntPtrBoolean)