ramensoftware/windhawk · error · std::runtime_error

Unsupported RegistryKey value

Error message

Unsupported RegistryKey value

What it means

The base-key portion of the RegistryKey value must be one of the supported hives: HKEY_CURRENT_USER/HKCU, HKEY_USERS/HKU, or HKEY_LOCAL_MACHINE/HKLM. Any other base key name is rejected at StorageManager construction because the code cannot map it to an HKEY.

Solutions

  1. Use a supported hive prefix: HKEY_CURRENT_USER (HKCU), HKEY_USERS (HKU), or HKEY_LOCAL_MACHINE (HKLM)
  2. Fix the spelling/casing of the base key in the RegistryKey value
  3. Pick a hive that matches the deployment (HKCU for per-user, HKLM for machine-wide)

Example fix

// before
"RegistryKey": "HKEY_CLASSES_ROOT\Software\Windhawk"
// after
"RegistryKey": "HKEY_CURRENT_USER\Software\Windhawk"
Defensive patterns

Strategy: validation

Validate before calling

static const std::wstring hives[] = {L"HKEY_CURRENT_USER", L"HKCU", L"HKEY_USERS", L"HKU", L"HKEY_LOCAL_MACHINE", L"HKLM"};
std::wstring base = key.substr(0, key.find(L'\\'));
bool ok = std::find(std::begin(hives), std::end(hives), base) != std::end(hives);

Prevention

When it happens

Trigger: StorageManager constructor sees a RegistryKey whose text before the first backslash is not one of the six accepted hive aliases — e.g. "HKEY_CLASSES_ROOT\..." or a misspelled hive.

Common situations: Typo in the hive name (HKCU vs HKCU-Users); attempting to point settings at an unsupported hive like HKEY_CLASSES_ROOT; copy-pasting a full registry path with extra prefix.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of ramensoftware/windhawk@61d99ed8e1 (2026-09-12). Data as JSON: /api/errors/031865be0fbcb032. Report an issue: GitHub.

Appendix: source

Thrown at src/windhawk/app/storage_manager.cpp:251

            throw std::runtime_error("Missing RegistryKey value");
        }

        auto firstBackslash = registryKey.find(L'\\');
        if (firstBackslash == registryKey.npos) {
            throw std::runtime_error("Invalid RegistryKey value");
        }

        HKEY hkey;

        std::wstring baseKey = registryKey.substr(0, firstBackslash);
        if (baseKey == L"HKEY_CURRENT_USER" || baseKey == L"HKCU") {
            hkey = HKEY_CURRENT_USER;
        } else if (baseKey == L"HKEY_USERS" || baseKey == L"HKU") {
            hkey = HKEY_USERS;
        } else if (baseKey == L"HKEY_LOCAL_MACHINE" || baseKey == L"HKLM") {
            hkey = HKEY_LOCAL_MACHINE;
        } else {
            throw std::runtime_error("Unsupported RegistryKey value");
        }

        std::wstring subKey = registryKey.substr(firstBackslash + 1);

        settingsPath = RegistryPath{hkey, std::move(subKey)};
    }
}

StorageManager::~StorageManager() = default;

View on GitHub (pinned to 61d99ed8e1)