*****************************************************************
***                Registry NSIS plugin v1.8                  ***
*****************************************************************

2005 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)


Features:
- Powerful registry search:
   -fast algorithm
   -principle of turn in stack (first in -> last out)
     i.e. search from first registry key to last
   -search for key, value and/or string in any root
   -search with name and/or type
   -search with banner support
   -search with subkeys or not
- Check is registry key exists
- Read value of any type and size
- Write value of any type and size
- Create key
- Delete value     (same as DeleteRegValue)
- Delete key       (same as DeleteRegKey)
- Copy value
- Move value
- Copy key
- Move key
- Export key contents to the file in REGEDIT4 format
- Import key contents from the file to the registry
- Converts string to hex values
- Converts hex values to string

**** Output variables ****
.r0-.r9 == $0-$9
.R0-.R9 == $R0-$R9


**** Registry Search ****
registry::Open /NOUNLOAD "[fullpath]" "[Options]" .r0
registry::Find /NOUNLOAD .r1 .r2 .r3 .r4
registry::Close


### Open for search ###
registry::Open /NOUNLOAD "[fullpath]" "[Options]" .r0

"[fullpath]"  - Registry path (Root\SubKey)

	Root:
	HKEY_CLASSES_ROOT      HKCR
	HKEY_CURRENT_USER      HKCU
	HKEY_LOCAL_MACHINE     HKLM
	HKEY_USERS             HKU
	HKEY_PERFORMANCE_DATA  HKPD
	HKEY_CURRENT_CONFIG    HKCC
	HKEY_DYN_DATA          HKDD

"[Options]"   - "/K=[1|0] /V=[1|0] /S=[1|0] /N=[name] /T=[TYPE] /G=[1|0] /B=[0|1|2]"

	/K=[1|0]
	/K=1  - Search Keys (default)
	/K=0  - Don't search Keys

	/V=[1|0]
	/V=1  - Search Values (default)
	/V=0  - Don't search Values

	/S=[1|0]
	/S=1  - Search Strings (default)
	/S=0  - Don't search Values

	/N=[name]   (can be in quotes "[name]", '[name]', `[name]`)
	             - Search for all (default)
	/N=          - Search for empty
	/N=version   - Search for "version"

	/T=[TYPE]
	                                    - Search for all types (default)
	/T=REG_BINARY                       - Search for REG_BINARY
	/T=REG_DWORD                        - Search for REG_DWORD
	/T=REG_DWORD_BIG_ENDIAN             - Search for REG_DWORD_BIG_ENDIAN
	/T=REG_EXPAND_SZ                    - Search for REG_EXPAND_SZ
	/T=REG_MULTI_SZ                     - Search for REG_MULTI_SZ
	/T=REG_NONE                         - Search for REG_NONE
	/T=REG_SZ                           - Search for REG_SZ
	/T=REG_LINK                         - Search for REG_LINK
	/T=REG_RESOURCE_LIST                - Search for REG_RESOURCE_LIST
	/T=REG_FULL_RESOURCE_DESCRIPTOR     - Search for REG_FULL_RESOURCE_DESCRIPTOR
	/T=REG_RESOURCE_REQUIREMENTS_LIST   - Search for REG_RESOURCE_REQUIREMENTS_LIST
	/T=REG_QWORD                        - Search for REG_QWORD

	/G=[1|0]
	/G=1  - Search with subkeys (default)
	/G=0  - Don't search subkeys

	/B=[0|1|2]
	/B=0  - Banner isn't used (default)
	/B=1  - Banner isn't used, but show
		in the details current searching path
	/B=2  - Banner is used. Return: "path", "", "", "", "BANNER"
		when starts to search in new key

.r0  - $0=0  success
       $0=-1 error


### Find first and next (call one or more times) ###
registry::Find /NOUNLOAD .r1 .r2 .r3 .r4

.r1  - $1="path"
.r2  - $2="value" or "key"
.r3  - $3="string"
.r4  - $4="TYPE"
	TYPE:
	""                                -Search is finished
	"BANNER"                          -Banner is used, return only path
	"REG_KEY"                         -Registry key is found
	"REG_BINARY"                      -Raw binary data
	"REG_DWORD"                       -Double word in machine format (low-endian on Intel)
	"REG_DWORD_BIG_ENDIAN"            -Double word in big-endian format
	"REG_EXPAND_SZ"                   -String with unexpanded environment variables
	"REG_MULTI_SZ"                    -Multiple strings, next string separated by new line '$\n'
	"REG_NONE"                        -Undefined type
	"REG_SZ"                          -Null-terminated string
	"REG_LINK"                        -Unicode symbolic link
	"REG_RESOURCE_LIST"               -Device-driver resource list
	"REG_FULL_RESOURCE_DESCRIPTOR"    -Resource list in the hardware description
	"REG_RESOURCE_REQUIREMENTS_LIST"  -
	"REG_QWORD"                       -64-bit number
	"INVALID"                         -Invalid type code


### Close search (free memory, free stack) ###
registry::Close


**** KeyExists (check is registry key exists) ****
registry::KeyExists "[fullpath]" .r0

.r0  - $0=0  key exists
       $0=-1 key doesn't exists


**** Registry Read ****
registry::Read "[fullpath]" "[value]" .r0 .r1 .r2 .r3 .r4

Outputs same as registry::Find


**** Registry Write ****
registry::Write "[fullpath]" "[value]" "[string]" "[TYPE]" .r0

"[TYPE]"  - Type of string to write
	REG_SZ                         (e.g. String #1)              same as WriteRegStr
	REG_EXPAND_SZ                  (e.g. %WINDIR%\notepad.exe)   same as WriteRegExpandStr
	REG_MULTI_SZ                   (e.g. First$\nSecond$\nThird)
	REG_DWORD                      (e.g. 1234567890)             same as WriteRegDWORD
	REG_DWORD_BIG_ENDIAN           (e.g. 1234567890)
	REG_BINARY                     (e.g. 591B0000451F)           same as WriteRegBin
	REG_NONE                       (e.g. 591B0000451F)
	REG_LINK                       (e.g. 591B0000451F)
	REG_RESOURCE_LIST              (e.g. 591B0000451F)
	REG_FULL_RESOURCE_DESCRIPTOR   (e.g. 591B0000451F)
	REG_RESOURCE_REQUIREMENTS_LIST (e.g. 591B0000451F)
	REG_QWORD                      (e.g. 591B0000451F)

.r0  - $0=0  success
       $0=-1 error


**** Registry Extra Read ****
registry::ReadExtra "[fullpath]" "[value]" "[number]" .r0 .r1 .r2 .r3 .r4

"[number]"  - Number of bytes to read from.
              If negative number of bytes from end.

Outputs same as registry::Find


**** Registry Extra Write ****
registry::WriteExtra "[fullpath]" "[value]" "[string]" .r0

"[string]"  - Append this string to the existed one

.r0  - $0=0  success
       $0=-1 error


**** Create Registry Key ****
registry::CreateKey "[fullpath]" .r0

"[fullpath]"  - Key to create (recursively if necessary)

.r0  - $0=1  [fullpath] already exists
       $0=0  [fullpath] successfully created
       $0=-1 error


**** Delete Registry Value (same as DeleteRegValue) ****
registry::DeleteValue "[fullpath]" "[value]" .r0

.r0  - $0=0  success
       $0=-1 error


**** Delete Registry Key (same as DeleteRegKey) ****
registry::DeleteKey "[fullpath]" .r0

.r0  - $0=0  success
       $0=-1 error


**** Copy Registry Value ****
registry::CopyValue "[fullpath_source]" "[value_source]" "[fullpath_target]" "[value_target]" .r0

.r0  - $0=0  success
       $0=-1 error


**** Move Registry Value ****
registry::MoveValue "[fullpath_source]" "[value_source]" "[fullpath_target]" "[value_target]" .r0

.r0  - $0=0  success
       $0=-1 error


**** Copy Registry Key ****
registry::CopyKey "[fullpath_source]" "[fullpath_target]\[new_key_name]" .r0

.r0  - $0=0  success
       $0=-1 error


**** Move Registry Key ****
registry::MoveKey "[fullpath_source]" "[fullpath_target]\[new_key_name]" .r0

.r0  - $0=0  success
       $0=-1 error


**** Registry Export (save to the file in REGEDIT4 format) ****
registry::SaveKey "[fullpath]" "[file]" "[Options]" .r0

"[fullpath]"  - Registry path (Root\SubKey)

	Root:
	HKEY_CLASSES_ROOT      HKCR
	HKEY_CURRENT_USER      HKCU
	HKEY_LOCAL_MACHINE     HKLM
	HKEY_USERS             HKU
	HKEY_PERFORMANCE_DATA  HKPD
	HKEY_CURRENT_CONFIG    HKCC
	HKEY_DYN_DATA          HKDD

"[file]"      - Export to this file

"[Options]"   - "/D=[0|1|2] /G=[1|0] /B=[0|1]"

	/D=[0|1|2]
	/D=0  - Don't delete any keys (default)
	/D=1  - Delete only root key before restoring
	/D=2  - Delete keys before restoring

	/G=[1|0]
	/G=1  - Search with subkeys (default)
	/G=0  - Don't search subkeys

	/B=[0|1]
	/B=0  - Don't show searching path (default)
	/B=1  - Show in the details current searching path

.r0  - $0=0  success
       $0=-1 error


**** Registry Import (restore from the file) ****
registry::RestoreKey "[file]" .r0

.r0  - $0=0  success
       $0=-1 error

Note:
registry::RestoreKey simply exec regedit:  regedit /s "[file]"


**** StrToHex (converts string to hex values) ****
registry::StrToHex "[string]" .r0

"[string]"  - String to convert

.r0  - $0=Hex string


**** HexToStr (converts hex values to string) ****
registry::HexToStr "[string]" .r0

"[string]"  - Hex string to convert

.r0  - $0=String
