Exemple #1
0
 public static bool HasRightToWriteInRegistry(RegistryKey registry = null)
 {
     using (WindowsIdentity.GetCurrent().Impersonate())
     {
         bool result = new RegistryFunctions().CanSetRegKeyValue(AppConsts.KEY_SRP_NODE, AppConsts.KEY_SRP_DEFAULT_LEVEL, registry);
         return(result);
     }
 }
Exemple #2
0
        public string CleanDataFromRegistry(string name, string Path, string states)
        {
            var value = "";

            value = RegistryFunctions.GlobalReadFromRegistry(name, Path);
            if (!string.IsNullOrEmpty(value))
            {
                return(value);
            }
            return(states);
        }
Exemple #3
0
 public void GetDataFromRegistry(string Key)
 {
     if (Key == null)
     {
         throw new ArgumentNullException("Key");
     }
     try
     {
         RegistryFunctions.GlobalReadFromRegistry(Key,
                                                  AcadSettings.RegistryPath);
     }
     catch (Exception ex)
     {
         MessengerManager.MessengerManager.AddLog(ex.Message);
     }
 }
Exemple #4
0
 public void WriteDataToRegistry(string Key, string Val)
 {
     if (Key == null)
     {
         throw new ArgumentNullException("Key");
     }
     try
     {
         RegistryFunctions.GlobalWriteToRegistry(Key, Val,
                                                 AcadSettings.RegistryPath);
     }
     catch (Exception ex)
     {
         MessengerManager.MessengerManager.AddLog(ex.Message);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="forceIconUpdate">
        ///     Using only during startup. Because we need to set right initial icon
        /// </param>
        public void LoadDataFromRegistry(bool update = true)
        {
            string result;

            // Load data from Registry
//            string HkcuResult = new RegistryFunctions().GetRegKeyValue(AppConsts.KEY_SRP_NODE, AppConsts.KEY_SRP_DEFAULT_LEVEL, RegistryValueKind.DWord, Registry.CurrentUser);
            string HklmResult = new RegistryFunctions().GetRegKeyValue(AppConsts.KEY_SRP_NODE, AppConsts.KEY_SRP_DEFAULT_LEVEL, RegistryValueKind.DWord);

            result = new RegistryFunctions().GetRegKeyValue(AppConsts.KEY_SRP_NODE, AppConsts.KEY_SRP_POLICY_SCOPE, RegistryValueKind.DWord);
            AppData.PolicyScore = result == AppConsts.KEY_SRP_POLICY_SCORE_ON;

            result = new RegistryFunctions().GetRegKeyValue(AppConsts.KEY_SRP_NODE, AppConsts.KEY_SRP_AUTHENTI_CODE_ENABLED, RegistryValueKind.DWord);
            AppData.AuthentiCodeEnabled = result == AppConsts.KEY_SRP_AUTHENTI_CODE_ENABLED_ON;

            result = new RegistryFunctions().GetRegKeyValue(AppConsts.KEY_SRP_NODE, AppConsts.KEY_SRP_TRANSPARENT_ENABLED, RegistryValueKind.DWord);
            AppData.TransparentEnabled = result != AppConsts.KEY_SRP_TRANSPARENT_ENABLED_OFF;

//            Status _HkcuRunning = StringToStatus(HkcuResult);
            Status _HklmRunning = StringToStatus(HklmResult);

            //Status _HkcuRunning = HkcuResult == AppConsts.SRP_OFF;
            //Status _HklmRunning = HklmResult == AppConsts.SRP_OFF;

            // If necessary -- change Icon status
            if ((/*AppData.HkcuRunning != _HkcuRunning ||*/ AppData.HklmRunning != _HklmRunning) && !update)
            {
                //AppData.HkcuRunning = _HkcuRunning;
                AppData.HklmRunning = _HklmRunning;

                UpdateIconStatus(AppData.HklmRunning);
            }

            // Useless?
            if (AppData._HklmRunning == Status.sNotAvailable && AppData.HklmRunning != Status.sNotAvailable)
            {
                AppData._HklmRunning = AppData.HklmRunning;
            }
        }
Exemple #6
0
        //Adding check that Registry values exist
        //FEATURE_BROWSER_EMULATION- Defines in which document mode WebBrowser Control(Internal browser) should launch (IE 11 )
        //FEATURE_SCRIPTURL_MITIGATION - feature allows the href attribute of a objects to support the javascript prototcol.
        //                               It is by default disabled for WebBrowser Control and enabled for IE
        public static void CheckRegistryValues()
        {
            bool   osBitTypeIs64     = false;
            string appExeName        = string.Empty;
            string registryKeyPath   = string.Empty;
            string requiredValueName = string.Empty;
            object requiredValue     = string.Empty;

            try
            {
                //Find out the OS bit type
                osBitTypeIs64 = Environment.Is64BitOperatingSystem;

                //Get the App name
                appExeName = System.AppDomain.CurrentDomain.FriendlyName;

                //######################## FEATURE_BROWSER_EMULATION ###########################
                if (osBitTypeIs64)
                {
                    registryKeyPath = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                }
                else
                {
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                }
                requiredValueName = appExeName;
                requiredValue     = string.Empty;
                object installedIEVersion =
                    RegistryFunctions.GetRegistryValue(eRegistryRoot.HKEY_LOCAL_MACHINE, @"Software\Microsoft\Internet Explorer", "svcUpdateVersion");
                if (installedIEVersion != null)
                {
                    if (installedIEVersion != null)
                    {
                        requiredValue = (installedIEVersion.ToString().Split(new char[] { '.' }))[0] + "000";
                    }
                }
                if (requiredValue.ToString() == string.Empty || requiredValue.ToString() == "000")
                {
                    requiredValue = "11000"; //defualt value
                }
                //write registry key to the User level if failed to write to Local Machine level

                if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_LOCAL_MACHINE, registryKeyPath,
                                                               requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                {
                    //Try User Level
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                    if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_CURRENT_USER, registryKeyPath,
                                                                   requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to add the required registry key 'FEATURE_BROWSER_EMULATION' value to both Local Machine and User level");
                    }
                }
                //End

                //######################## FEATURE_SCRIPTURL_MITIGATION ###########################
                if (osBitTypeIs64)
                {
                    registryKeyPath = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                }
                else
                {
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                }
                requiredValueName = appExeName;
                requiredValue     = 1;
                //write registry key to the User level if failed to write to Local Machine level
                if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_LOCAL_MACHINE, registryKeyPath,
                                                               requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                {
                    //Try User Level
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                    if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_CURRENT_USER, registryKeyPath,
                                                                   requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to add the required registry key 'FEATURE_SCRIPTURL_MITIGATION' value to both Local Machine and User level");
                    }
                }
                //End
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to complete the registry values check", ex);
                Reporter.ToUser(eUserMsgKey.RegistryValuesCheckFailed);
            }
        }