{"record":{"id":"e22d27a0e6273718","repo":"ramensoftware/windhawk","slug":"regdeletevalue","errorCode":null,"errorMessage":"RegDeleteValue","messagePattern":"RegDeleteValue","errorType":"error_code","errorClass":"SettingsError","httpStatus":null,"severity":"error","filePath":"src/windhawk-core/windows/src/registry.rs","lineNumber":548,"sourceCode":"        })\n    }\n\n    fn set_binary(&mut self, name: &str, value: &[u8]) -> Result<(), SettingsError> {\n        self.set_raw(name, REG_BINARY, value)\n    }\n\n    fn remove(&mut self, name: &str) -> Result<(), SettingsError> {\n        self.check_name(\"remove\", name)?;\n        let Some(hkey) = self.hkey() else {\n            return Ok(());\n        };\n        let name_w = to_wide(name);\n        // SAFETY: name_w is NUL-terminated; hkey is a valid open key.\n        let rc = unsafe { RegDeleteValueW(hkey, name_w.as_ptr()) };\n        if rc == ERROR_SUCCESS || rc == ERROR_FILE_NOT_FOUND {\n            Ok(())\n        } else {\n            Err(self.err(\"remove\", rc, \"RegDeleteValue\"))\n        }\n    }\n\n    fn enum_values(&self) -> Result<Vec<(String, TreeValue)>, SettingsError> {\n        let Some(hkey) = self.hkey() else {\n            return Ok(Vec::new());\n        };\n        let mut out = Vec::new();\n        let mut index: u32 = 0;\n        loop {\n            // Value names are bounded at 16383 chars; +1 for the NUL.\n            let mut name_buf = vec![0u16; 16384];\n            let mut name_len = name_buf.len() as u32;\n            // SAFETY: name_buf has name_len units; the data out params are\n            // null (we re-read each value by name to type it uniformly).\n            let rc = unsafe {\n                RegEnumValueW(\n                    hkey,","sourceCodeStart":530,"sourceCodeEnd":566,"githubUrl":"https://github.com/ramensoftware/windhawk/blob/61d99ed8e182e1af1b60109612b6763ad1b4b74e/src/windhawk-core/windows/src/registry.rs#L530-L566","documentation":"This error surfaces the raw Windows registry return code when `RegDeleteValueW` fails for a reason other than success or ERROR_FILE_NOT_FOUND. The wrapper deliberately treats a missing value as success (idempotent remove); any other code (e.g. ERROR_ACCESS_DENIED, ERROR_KEY_DELETED) becomes a SettingsError named after the 'remove' operation.","triggerScenarios":"Calling registry-backed settings `remove(name)` on a value the current process lacks delete rights for, or after the parent key handle has been invalidated/deleted; also value names with characters rejected by the registry beyond the wrapper's own NUL check.","commonSituations":"Trying to remove values under HKLM or other protected hives without elevation; antivirus or policy locking the key; another process deleted the key between opening and removing.","solutions":["Re-run the process elevated if the key is under HKLM/HKU protected areas","Check the embedded Windows error code (rc) to identify the exact Win32 failure","Verify the key handle is still valid and the key was not deleted concurrently","Confirm the value name matches exactly (case is fine, but no stray NUL or invalid chars)"],"exampleFix":"// before\nmatch settings.remove(\"MyValue\") { Err(e) => panic!(\"{}\", e), ... }\n// after\nmatch settings.remove(\"MyValue\") {\n    Ok(()) => {},\n    Err(e) if e.is_access_denied() => eprintln!(\"elevate to remove protected value\"),\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"try-catch","validationCode":"if name.contains('\\0') { return Err(\"value name contains NUL\"); }","typeGuard":null,"tryCatchPattern":"match settings.remove(name) {\n    Ok(()) => {}, // includes already-absent values\n    Err(e) => eprintln!(\"remove failed: {e}; check elevation/permissions\"),\n}","preventionTips":["Run elevated when touching HKLM/HKU protected values","Treat ERROR_FILE_NOT_FOUND as success — the wrapper already does","Don't delete the parent key while values are being removed","Log the embedded Win32 code for diagnosis"],"tags":["windows","registry","win32"],"backgroundTag":"permission-denied","analyzedSha":"61d99ed8e182e1af1b60109612b6763ad1b4b74e","analyzedAt":"2026-09-12T14:02:41.115Z","contentChangedAt":"2026-09-12T14:02:41.115Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}