Exemplo n.º 1
0
        static void ProcessSetConfig(string[] args, FeatureConfigurationAction actionToUse)
        {
            if (args.Length < 3)
            {
                string helpPrefix = actionToUse == FeatureConfigurationAction.Delete ? "del" : "add";
                Console.WriteLine("Syntax:   {0}config <numeric id> <enabled state>\n          [enabled state options] [variant] [variant payload kind] [variant payload] [group]\n", helpPrefix);
                Console.WriteLine("Enabled state types: 0 = Default, 1 = Disabled, 2 = Enabled\n");
                Console.WriteLine("Examples: {0}config 23456789 2\n          {0}config 23456789 2 1 1 0 0 4", helpPrefix);
                return;
            }

            if (!TryParseDecHexUint(args[1], out uint featureId))
            {
                Console.WriteLine("Couldn't parse feature ID");
                return;
            }
            if (!TryParseDecHexInt(args[2], out int enabledState))
            {
                Console.WriteLine("Couldn't parse enabled state");
                return;
            }
            int enabledStateOptions = 1;
            int variant             = 0;
            int variantPayloadKind  = 0;
            int variantPayload      = 0;
            int group = 4;

            if (args.Length > 4 && !TryParseDecHexInt(args[3], out enabledStateOptions))
            {
                Console.WriteLine("Couldn't parse enabled state options");
                return;
            }
            if (args.Length > 5 && !TryParseDecHexInt(args[4], out variant))
            {
                Console.WriteLine("Couldn't parse variant");
                return;
            }
            if (args.Length > 6 && !TryParseDecHexInt(args[5], out variantPayloadKind))
            {
                Console.WriteLine("Couldn't parse variant payload kind");
                return;
            }
            if (args.Length > 7 && !TryParseDecHexInt(args[6], out variantPayload))
            {
                Console.WriteLine("Couldn't parse variant payload");
                return;
            }
            if (args.Length > 8 && !TryParseDecHexInt(args[7], out group))
            {
                Console.WriteLine("Couldn't parse group");
                return;
            }
            var configs = new List <FeatureConfiguration>()
            {
                new FeatureConfiguration()
                {
                    FeatureId           = featureId,
                    EnabledState        = (FeatureEnabledState)enabledState,
                    EnabledStateOptions = enabledStateOptions,
                    Group              = group,
                    Variant            = variant,
                    VariantPayloadKind = variantPayloadKind,
                    VariantPayload     = variantPayload,
                    Action             = actionToUse
                }
            };
            int result = RtlFeatureManager.SetLiveFeatureConfigurations(configs, FeatureConfigurationSection.Runtime);

            if (result != 0)
            {
                Console.WriteLine("An error occurred while setting a live feature configuration (hr=0x{0:x8})", result);
                return;
            }
            if (!RtlFeatureManager.SetBootFeatureConfigurations(configs))
            {
                Console.WriteLine("An error occurred while setting a boot feature configuration");
            }
            else
            {
                Console.WriteLine("Successfully set feature configuration");
            }
        }
Exemplo n.º 2
0
        static void ProcessSetConfig(string[] args, FeatureConfigurationAction actionToUse)
        {
            if (args.Length < 4)
            {
                string helpPrefix = actionToUse == FeatureConfigurationAction.Delete ? "del" : "add";
                Console.WriteLine("Syntax:   {0}config <runtime | boot> <numeric id> <enabled state>\n          [enabled state options] [variant] [variant payload kind] [variant payload] [group]\n", helpPrefix);
                Console.WriteLine("If an invalid section is specified, 'runtime' will be used\n\nEnabled state types: 0 = Default, 1 = Disabled, 2 = Enabled\n");
                Console.WriteLine("Examples: {0}config runtime 123456 2\n          {0}config runtime 456789 2 1 4 1 0 0", helpPrefix);
                return;
            }
            FeatureConfigurationSection sectionToUse = FeatureConfigurationSection.Runtime;

            if (args[1] == "boot")
            {
                sectionToUse = FeatureConfigurationSection.Boot;
            }
            else
            {
                Console.WriteLine("Invalid action, only 'add' or 'delete' are supported");
                return;
            }
            if (!TryParseDecHexUint(args[2], out uint featureId))
            {
                Console.WriteLine("Couldn't parse feature ID");
                return;
            }
            if (!TryParseDecHexInt(args[3], out int enabledState))
            {
                Console.WriteLine("Couldn't parse enabled state");
                return;
            }
            int enabledStateOptions = 1;
            int variant             = 0;
            int variantPayloadKind  = 0;
            int variantPayload      = 0;
            int group = 4;

            if (args.Length > 4 && !TryParseDecHexInt(args[4], out enabledStateOptions))
            {
                Console.WriteLine("Couldn't parse enabled state options");
                return;
            }
            if (args.Length > 5 && !TryParseDecHexInt(args[5], out variant))
            {
                Console.WriteLine("Couldn't parse variant");
                return;
            }
            if (args.Length > 6 && !TryParseDecHexInt(args[6], out variantPayloadKind))
            {
                Console.WriteLine("Couldn't parse variant payload kind");
                return;
            }
            if (args.Length > 7 && !TryParseDecHexInt(args[7], out variantPayload))
            {
                Console.WriteLine("Couldn't parse variant payload");
                return;
            }
            if (args.Length > 8 && !TryParseDecHexInt(args[8], out group))
            {
                Console.WriteLine("Couldn't parse group");
                return;
            }
            int result = RtlFeatureManager.SetFeatureConfigurations(new List <FeatureConfiguration>()
            {
                new FeatureConfiguration()
                {
                    FeatureId           = featureId,
                    EnabledState        = (FeatureEnabledState)enabledState,
                    EnabledStateOptions = enabledStateOptions,
                    Group              = group,
                    Variant            = variant,
                    VariantPayloadKind = variantPayloadKind,
                    VariantPayload     = variantPayload,
                    Action             = actionToUse
                }
            }, sectionToUse);

            if (result != 0)
            {
                Console.WriteLine("An error occurred while setting the feature configuration (hr=0x{0:x8})", result);
            }
            else
            {
                Console.WriteLine("Successfully set feature configuration");
            }
        }