REG Syntax (.reg files)

Tested with Regedit 4.10.1998.

EBNF (Extended Backus Naur Form)
<Reg file> = <Header> { <Key block> '\n' }
<Header> = 'REGEDIT4\n\n' | 'REGEDIT 5.00\n'
<Key block> = '[' <Key name> ']\n' { <Value block> '\n' }

<Key name> = [ '-' ] <Root key name> [ { <Subkey name> '\' } <Subkey name> ]
<Subkey name> = { #32..#255 }
<Root key name> = 'HKEY_LOCAL_MACHINE' | 'HKEY_USERS' | 'HKEY_CURRENT_USER' | 'HKEY_CLASSES_ROOT' | 'HKEY_CURRENT_CONFIG' | 'HKEY_DYN_DATA'

<Value block> = <Value name> '=' <Value context>
<Value name> = '@' | <Reg string>
<Reg string> = '"' { '\"' | "\\" | "\n" | "\r" | #0..#255 } '"'
<Value context> = '-' | <String block> | <DWORD block> | <Hex block>

<String block> = <Reg string>
<DWORD block> = 'dword:' <Hex 00000000..FFFFFFFF>
<Hex block> = 'hex' [ '(' <Value type> ')' ] ':' [ <Byte chain> ]
<Value type> = <Hex 0..ffffffff>
<Byte Chain> = <First Byte line> { ',\\' '\n' <Byte line> }
<First byte line> = <Byte> { ',' <Byte> } //whole line: 80 chars =
25 <Byte>s max.
<Byte> = <Hex 00..ff>
<Byte line> = ' ' <Byte> { ',' <Byte> }

Sample

REGEDIT4

 

[HKEY_LOCAL_MACHINE\Pluto Schrott\New]

"value"="data"

@="data of default value"

"three"=dword:00000003

"empty REG_EXPAND_SZ"=hex(2):00

"Binary"=hex(3):63,59,63,6E,75,73

"strange type -2"=hex(fffffffe):76,65,72,79,20,73,74,72,61,6E,67,65

"Big binary value"=hex:44,65,72,20,42,61,6c,6c,20,62,65,73,74,65,68,74,20,61,\

75,73,20,65,69,6e,65,72,20,4c,65,64,65,72,2d,20,6f,64,65,72,20,4b,75,6e,73,\

74,73,74,6f,66,66,68,fc,6c,6c,65,2e,20,45,72,20,6d,75,73,73,20,72,75,6e,64,\

20,73,65,69,6e,2e,00

"FileName with masked \\ chars"="C:\\one.bmp"

"Delete this value"=-

 

[-HKEY_CURRENT_USER\Delete this key]