{"record":{"id":"96d824d15f1e62d0","repo":"java-native-access/jna","slug":"unsupported-type","errorCode":null,"errorMessage":"Unsupported type: ","messagePattern":"Unsupported type: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java","lineNumber":2230,"sourceCode":"                            s = byteData.getString(offset);\n                            offset += s.length();\n                            offset += 1;\n                        }\n\n                        if (s.length() == 0) {\n                            // A sequence of null-terminated strings,\n                            // terminated by an empty string (\\0).\n                            // => The first empty string terminates the\n                            break;\n                        } else {\n                            result.add(s);\n                        }\n                    }\n                    keyValues.put(nameString, result.toArray(new String[0]));\n                    break;\n                }\n                default:\n                    throw new RuntimeException(\"Unsupported type: \"\n                        + lpType.getValue());\n            }\n        }\n        return keyValues;\n    }\n\n    /**\n     * Get a table of registry values.\n     *\n     * @param root\n     *            Registry root.\n     * @param keyPath\n     *            Regitry key path.\n     * @return Table of values.\n     */\n    public static TreeMap<String, Object> registryGetValues(HKEY root,\n            String keyPath) {\n        return registryGetValues(root, keyPath, 0);","sourceCodeStart":2212,"sourceCodeEnd":2248,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java#L2212-L2248","documentation":"registryGetValues enumerates each value, switches on the type reported by RegQueryValueEx, and decodes REG_SZ/REG_EXPAND_SZ, REG_DWORD, REG_QWORD, REG_BINARY and REG_MULTI_SZ into Java objects. A value whose type falls outside this set (e.g. REG_LINK, REG_RESOURCE_LIST, REG_FULL_RESOURCE_DESCRIPTOR, REG_RESOURCE_REQUIREMENTS_LIST) hits the default branch and throws this RuntimeException naming the numeric type. The library refuses to guess a decoding for unknown registry types.","triggerScenarios":"Calling Advapi32Util.registryGetValues(key) or registryGetValues(root, key, samDesiredExtra) on a key that contains a non-empty value of a type not in the supported set (REG_LINK, REG_RESOURCE_LIST, REG_FULL_RESOURCE_DESCRIPTOR, REG_RESOURCE_REQUIREMENTS_LIST, or vendor-defined types).","commonSituations":"Bulk-enumerating HKLM\\SYSTEM\\CurrentControlSet\\Services or hardware Enum keys that commonly store resource-descriptor values; reading keys written by drivers or OEM tools using private types; security-scanning scripts walking whole hives.","solutions":["Catch RuntimeException around registryGetValues per key and skip/log keys containing unsupported types.","Read individual values with registryGetValue and only the names you expect, avoiding unknown types.","Use Advapi32.registryQueryInfoKey yourself to inspect types and handle unsupported ones explicitly before decoding.","Update JNA - newer versions handle more registry types during enumeration."],"exampleFix":"// before\nTreeMap<String, Object> vals = Advapi32Util.registryGetValues(root, key); // throws on REG_RESOURCE_LIST\n\n// after\nTreeMap<String, Object> vals;\ntry {\n    vals = Advapi32Util.registryGetValues(root, key);\n} catch (RuntimeException e) {\n    LOG.debug(\"Key {} has values with unsupported types, skipping\", key);\n    vals = new TreeMap<>();\n}","handlingStrategy":"try-catch","validationCode":"// pre-check each value's type with RegQueryValueEx and skip unsupported ones:\nMemory lpData = new Memory(4); IntByReference lpcb = new IntByReference(0);\nIntByReference lpType = new IntByReference();\nAdvapi32.INSTANCE.RegQueryValueEx(hKey, valueName, 0, lpType, (Pointer) null, lpcb);\nboolean supported = lpType.getValue() == WinNT.REG_SZ || lpType.getValue() == WinNT.REG_EXPAND_SZ\n    || lpType.getValue() == WinNT.REG_MULTI_SZ || lpType.getValue() == WinNT.REG_DWORD\n    || lpType.getValue() == WinNT.REG_QWORD || lpType.getValue() == WinNT.REG_BINARY;","typeGuard":null,"tryCatchPattern":"try { return Advapi32Util.registryGetValues(root, key, 0); }\ncatch (RuntimeException e) { log.debug(\"Skipping key {} with unsupported value types\", key); return Collections.emptyMap(); }","preventionTips":["Skip known-problematic keys (Services subkeys, hardware Enum) during hive walks","Decode value-by-value with registryGetValue and handle unknown types per name","Log the numeric type from the message for diagnosis","Keep JNA updated; newer versions extend the supported type set"],"tags":["windows-registry","unsupported-type","enumeration","jna"],"backgroundTag":"unsupported-enum-value","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}