[augeas-devel] Windows registry files?
David Lutterkort
lutter at redhat.com
Mon Oct 19 16:25:24 UTC 2009
On Mon, 2009-10-19 at 14:54 +0100, Richard W.M. Jones wrote:
> Transfering this discussion from #augeas, does Augeas support Windows
> Registry files?
Almost ;) Attached are a lens and corresponding test that works for your
user.reg and system.reg. The software.reg fails for at least a couple of
reasons:
* The lens doesn't handle DOS line endings
* sofwtare.reg contains braindead entries like ""foo bar"
baz" (i.e., w/o quoting the inner double quotes in any way)
I'll look into fixing these up and getting the lens to work on the real
w2k registries tomorrow.
David
-------------- next part --------------
(* Lens for the textual representation of Windows registry files, as used *)
(* by wine etc. *)
(* This is pretty quick and dirty, as it doesn't put a lot of finesse on *)
(* splitting up values that have structure, e.g. hex arrays or *)
(* collections of paths. *)
module Wine =
let comment = IniFile.comment ";;" ";;"
let empty = IniFile.empty
let dels = Util.del_str
let eol = IniFile.eol
let del_ws = Util.del_ws_spc
let header =
[ label "registry" . store /[a-zA-Z0-9 \t]*[a-zA-Z0-9]/ ] .
del /[ \t]*Version[ \t]*/ " Version " .
[ label "version" . store /[0-9.]+/ ] . eol
let qstr (l:lens) = dels "\"" . l . dels "\""
let typed_val =
([ label "type" . store /dword|hex(\\([0-9]+\\))?/ ] . dels ":" .
store /[a-zA-Z0-9,()]+(\\\\\n[ \t]*[a-zA-Z0-9,]+)*/)
|[ label "type" . store /str\\([0-9]+\\)/ ] . dels ":" .
dels "\"" . store /[^"\n]*/ . dels "\"" (* " Relax, emacs *)
let entry =
let key_re = /[^"\/#.\n][^"\/\n]*/ in
let qkey = qstr (key key_re) in
let eq = del /[ \t]*=[ \t]*/ "=" in
let qstore = qstr (store /([^"\n]|\\\\.)*/) in (* " Relax, emacs *)
[ qkey . eq . (qstore|typed_val) . eol ]
|[label ".anon" . dels "@" . eq . qstore .eol ]
let section =
let ts = [ label ".timestamp" . store Rx.integer ] in
[ label "section" . del /[ \t]*\\[/ "[" .
store /[^]\n]+/ . dels "]" . (del_ws . ts)? . eol .
(entry|empty|comment)* ]
let lns = header . (empty|comment)* . section*
-------------- next part --------------
module Test_wine =
let s1 = "WINE REGISTRY Version 2
;; All keys relative to \\Machine
[Software\\Borland\\Database Engine\\Settings\\SYSTEM\\INIT] 1255960431
\"SHAREDMEMLOCATION\"=\"9000\"
[Software\\Classes\\.gif] 1255960430
@=\"giffile\"
\"Content Type\"=\"image/gif\"
[Software\\Classes\\CLSID\\{083863F1-70DE-11D0-BD40-00A0C911CE86}\\Instance\\{1B544C20-FD0B-11CE-8C63-00AA0044B51E}] 1255960430
\"CLSID\"=\"{1B544C20-FD0B-11CE-8C63-00AA0044B51E}\"
\"FilterData\"=hex:02,00,00,00,00,00,60,00,02,00,00,00,00,00,00,00,30,70,69,33,\
9f,53,00,20,af,0b,a7,70,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
\"FriendlyName\"=\"AVI Splitter\"
[Software\\Classes\\CLSID\\{0AFACED1-E828-11D1-9187-B532F1E9575D}\\ShellFolder] 1255960429
\"Attributes\"=dword:60010000
\"CallForAttributes\"=dword:f0000000
"
test Wine.lns get s1 =
{ "registry" = "WINE REGISTRY" }
{ "version" = "2" }
{ "#comment" = "All keys relative to \Machine" }
{ }
{ "section" = "Software\Borland\Database Engine\Settings\SYSTEM\INIT"
{ ".timestamp" = "1255960431" }
{ "SHAREDMEMLOCATION" = "9000" }
{ } }
{ "section" = "Software\Classes\.gif"
{ ".timestamp" = "1255960430" }
{ ".anon" = "giffile" }
{ "Content Type" = "image/gif" }
{ } }
{ "section" = "Software\Classes\CLSID\{083863F1-70DE-11D0-BD40-00A0C911CE86}\Instance\{1B544C20-FD0B-11CE-8C63-00AA0044B51E}"
{ ".timestamp" = "1255960430" }
{ "CLSID" = "{1B544C20-FD0B-11CE-8C63-00AA0044B51E}" }
{ "FilterData" =
"02,00,00,00,00,00,60,00,02,00,00,00,00,00,00,00,30,70,69,33,\
9f,53,00,20,af,0b,a7,70,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00"
{ "type" = "hex" } }
{ "FriendlyName" = "AVI Splitter" }
{ } }
{ "section" = "Software\Classes\CLSID\{0AFACED1-E828-11D1-9187-B532F1E9575D}\ShellFolder"
{ ".timestamp" = "1255960429" }
{ "Attributes" = "60010000"
{ "type" = "dword" } }
{ "CallForAttributes" = "f0000000"
{ "type" = "dword" } } }
(* The weird 'str(2)' type *)
let s2 = "[Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders] 1248768928
\"AppData\"=str(2):\"%USERPROFILE%\\Application Data\"
\"Cache\"=str(2):\"%USERPROFILE%\\Local Settings\\Temporary Internet Files\"
\"Cookies\"=str(2):\"%USERPROFILE%\\Cookies\"
\"Desktop\"=str(2):\"%USERPROFILE%\\Desktop\"
"
test Wine.section get s2 =
{ "section" =
"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
{ ".timestamp" = "1248768928" }
{ "AppData" = "%USERPROFILE%\Application Data"
{ "type" = "str(2)" } }
{ "Cache" = "%USERPROFILE%\Local Settings\Temporary Internet Files"
{ "type" = "str(2)" } }
{ "Cookies" = "%USERPROFILE%\Cookies"
{ "type" = "str(2)" } }
{ "Desktop" = "%USERPROFILE%\Desktop"
{ "type" = "str(2)" } } }
(* Quoted doublequotes embedded in the string *)
let s3 = "[Software\\Classes\\CLSID\\Shell\\OpenHomePage\\Command] 1248768931
@=\"\\\"C:\\Program Files\\Internet Explorer\\iexplore.exe\\\"\"\n"
test Wine.section get s3 =
{ "section" =
"Software\Classes\CLSID\Shell\OpenHomePage\Command"
{ ".timestamp" = "1248768931" }
{ ".anon" = "\\\"C:\Program Files\Internet Explorer\iexplore.exe\\\"" } }
(* There's a str(7) type, too *)
let s4 = "[Software\\Microsoft\\Cryptography\\OID\\EncodingType 1\\CertDllVerifyRevocation\\DEFAULT] 1248768928
\"Dll\"=str(7):\"cryptnet.dll\0\"\n"
test Wine.section get s4 =
{ "section" =
"Software\Microsoft\Cryptography\OID\EncodingType 1\CertDllVerifyRevocation\DEFAULT"
{ ".timestamp" = "1248768928" }
{ "Dll" = "cryptnet.dll\0"
{ "type" = "str(7)" } } }
(* The Windows Registry Editor header *)
test Wine.header get "Windows Registry Editor Version 5.00\n" =
{ "registry" = "Windows Registry Editor" }
{ "version" = "5.00" }
(* The type hex(7) *)
let s5 = "[HKEY_LOCAL_MACHINE\SOFTWARE\ADFS]
\"Patches\"=hex(7):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,61,00,\
64,00,66,00,73,00,73,00,70,00,32,00,2e,00,6d,00,73,00,70,00,\
00,00,00,00,f8
"
test Wine.section get s5 =
{ "section" = "HKEY_LOCAL_MACHINE\SOFTWARE\ADFS"
{ "Patches" = "25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,61,00,\
64,00,66,00,73,00,73,00,70,00,32,00,2e,00,6d,00,73,00,70,00,\
00,00,00,00,f8"
{ "type" = "hex(7)" } } }
More information about the augeas-devel
mailing list