From 772d58066dd074b961b39fcdfc01bc956b193cb5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 6 Aug 2005 01:09:27 +0000 Subject: r9159: abstract the winreg js functions into a nice library interface (This used to be commit 5e398700627fb2c16bf39b9c851f640f5412c7d4) --- source4/scripting/libjs/winreg.js | 115 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 source4/scripting/libjs/winreg.js (limited to 'source4/scripting/libjs') diff --git a/source4/scripting/libjs/winreg.js b/source4/scripting/libjs/winreg.js new file mode 100644 index 0000000000..129cfe0898 --- /dev/null +++ b/source4/scripting/libjs/winreg.js @@ -0,0 +1,115 @@ +/* + winreg rpc utility functions + Copyright Andrew Tridgell 2005 + released under the GNU GPL v2 or later +*/ + + +/* + open a hive +*/ +function winreg_open_hive(reg, hive) +{ + var io = irpcObj(); + io.input.system_name = NULL; + io.input.access_required = reg.SEC_FLAG_MAXIMUM_ALLOWED; + var status; + if (hive == "HKLM") { + status = reg.winreg_OpenHKLM(io); + } else if (hive == "HKCR") { + status = reg.winreg_OpenHKCR(io); + } else if (hive == "HKPD") { + status = reg.winreg_OpenHKPD(io); + } else if (hive == "HKU") { + status = reg.winreg_OpenHKU(io); + } else { + println("Unknown hive " + hive); + return undefined; + } + if (!status.is_ok) { + return undefined; + } + return io.output.handle; +} + +/* + open a handle to a path +*/ +function winreg_open_path(reg, path) +{ + var s = string_init(); + var i, components = s.split('\\', path); + var list = new Object(); + + list.length = 0; + + var handle = winreg_open_hive(reg, components[0]); + if (handle == undefined) { + return undefined; + } + + for (i=1;i= 0;idx++) { + io.input.enum_index = idx; + var status = reg.winreg_EnumKey(io); + if (!status.is_ok) return; + var out = io.output; + if (out.result != "WERR_OK") { + return list; + } + + list[list.length] = out.out_name.name; + list.length++; + } + + return list; +} -- cgit