{"record":{"id":"ae64ea6317347421","repo":"thebookisclosed/ViVe","slug":"enabledstate-must-not-be-higher-than-2","errorCode":null,"errorMessage":"EnabledState must not be higher than 2.","messagePattern":"EnabledState must not be higher than 2\\.","errorType":"exception","errorClass":"FeaturePropertyOverflowException","httpStatus":null,"severity":"error","filePath":"ViVe/NativeStructs.cs","lineNumber":63,"sourceCode":"            }\n            set\n            {\n                if ((uint)value > 15)\n                    throw new FeaturePropertyOverflowException(\"Priority\", 15);\n                CompactState = (CompactState & 0xFFFFFFF0) | (uint)value;\n            }\n        }\n\n        public RTL_FEATURE_ENABLED_STATE EnabledState\n        {\n            get\n            {\n                return (RTL_FEATURE_ENABLED_STATE)((CompactState & 0x30) >> 4);\n            }\n            set\n            {\n                if ((uint)value > 2)\n                    throw new FeaturePropertyOverflowException(\"EnabledState\", 2);\n                CompactState = (CompactState & 0xFFFFFFCF) | ((uint)value << 4);\n            }\n        }\n\n        public bool IsWexpConfiguration\n        {\n            get\n            {\n                return ((CompactState & 0x40) >> 6) == 1;\n            }\n            set\n            {\n                CompactState = (CompactState & 0xFFFFFFBF) | ((value ? (uint)1 : 0) << 6);\n            }\n        }\n\n        public bool HasSubscriptions\n        {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/thebookisclosed/ViVe/blob/3f8c6a3425983412da1e8b26cd757c3aa17b3f25/ViVe/NativeStructs.cs#L45-L81","documentation":"EnabledState in RTL_FEATURE_CONFIGURATION is packed into bits 4-5 of CompactState and therefore supports only the defined values 0-2 (Disabled, Enabled, plus the defined RTL_FEATURE_ENABLED_STATE range). Assigning any value above 2 would collide with neighboring packed bits, so the setter throws FeaturePropertyOverflowException(\"EnabledState\", 2).","triggerScenarios":"Assigning an out-of-range cast value to config.EnabledState, e.g. config.EnabledState = (RTL_FEATURE_ENABLED_STATE)rawValue where rawValue > 2.","commonSituations":"Decoding packed native data without masking bits 4-5; treating EnabledStateOptions bit flags as an EnabledState value; reading garbage from an unvalidated registry blob.","solutions":["Mask the raw value: (raw >> 4) & 0x3 before casting to RTL_FEATURE_ENABLED_STATE","Only assign defined RTL_FEATURE_ENABLED_STATE members (Disabled/Enabled, values 0-2)","Use RTL_FEATURE_ENABLED_STATE_OPTIONS for 'leave unchanged' semantics instead of out-of-range sentinel values"],"exampleFix":"// before\nconfig.EnabledState = (RTL_FEATURE_ENABLED_STATE)rawDword;\n// after\nconfig.EnabledState = (RTL_FEATURE_ENABLED_STATE)((rawDword >> 4) & 0x3);","handlingStrategy":"validation","validationCode":"uint v = (uint)rawEnabledState;\nif (v > 2) throw new ArgumentOutOfRangeException(nameof(rawEnabledState), \"EnabledState must be 0-2.\");\nconfig.EnabledState = (RTL_FEATURE_ENABLED_STATE)v;","typeGuard":"static bool IsValidEnabledState(uint v) => v <= 2;","tryCatchPattern":"try { config.EnabledState = value; }\ncatch (FeaturePropertyOverflowException ex)\n{\n    // fall back to EnabledState.Disabled or surface a decode error\n}","preventionTips":["Mask decoded values: (raw >> 4) & 0x3","Use EnabledStateOptions/Update fields for 'unchanged' semantics, not sentinel numbers","Only assign RTL_FEATURE_ENABLED_STATE.Disabled or .Enabled"],"tags":["csharp","bitfield","enum","value-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"3f8c6a3425983412da1e8b26cd757c3aa17b3f25","analyzedAt":"2026-09-14T11:10:27.021Z","contentChangedAt":"2026-09-14T11:10:27.021Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}