1 | #!/bin/bash |
---|
2 | #/** |
---|
3 | #@file Registry.lib |
---|
4 | #@brief Librería o clase Registry |
---|
5 | #@class Boot |
---|
6 | #@brief Funciones para gestión del registro de Windows. |
---|
7 | #@version 1.0.1 |
---|
8 | #@warning License: GNU GPLv3+ |
---|
9 | #*/ |
---|
10 | |
---|
11 | |
---|
12 | #/** |
---|
13 | # ogAddRegistryKey path_mountpoint str_hive str_keyname |
---|
14 | #@brief Añade una nueva clave al registro de Windows. |
---|
15 | #@version 1.0.1 - Nueva función |
---|
16 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
17 | #@date 2011-05-18 |
---|
18 | #*/ ## |
---|
19 | function ogAddRegistryValue () |
---|
20 | { |
---|
21 | } |
---|
22 | |
---|
23 | #/** |
---|
24 | # ogAddRegistryValue path_mountpoint str_hive str_valuename str_valuedata |
---|
25 | #@brief Añade un nuevo valor (dupla nombre/valor) al registro de Windows. |
---|
26 | #@version 1.0.1 - Nueva función |
---|
27 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
28 | #@date 2011-05-18 |
---|
29 | #*/ ## |
---|
30 | function ogAddRegistryValue () |
---|
31 | { |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | #/** |
---|
36 | # ogGetRegistryPath path_mountpoint str_hive |
---|
37 | #@brief Función básica que devuelve el camino del fichero con una sección del registro. |
---|
38 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
39 | #@param str_hive sección del registro |
---|
40 | #@return str_path - camino del fichero de registro |
---|
41 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
42 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
43 | #@note hive = { default, sam, security, software, system, components } |
---|
44 | #@warning El sistema de archivos de Windows debe estar montada previamente. |
---|
45 | #@version 1.0.1 - Nueva función |
---|
46 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
47 | #@date 2011-05-18 |
---|
48 | #*/ ## |
---|
49 | function ogGetRegistryPath () |
---|
50 | { |
---|
51 | # Variables locales. |
---|
52 | local FILE FILENT FILEXP |
---|
53 | |
---|
54 | # Si se solicita, mostrar ayuda. |
---|
55 | if [ "$*" == "help" ]; then |
---|
56 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive" |
---|
57 | return |
---|
58 | fi |
---|
59 | # Error si no se reciben 2 parámetros. |
---|
60 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
61 | |
---|
62 | # Camino del fichero de registro en NT/2000 o XP/Vista/7. |
---|
63 | FILENT=$(ogGetPath "/$1/winnt/system32/config/$2") |
---|
64 | [ -f $FILENT ] && FILE="$FILENT" |
---|
65 | FILEXP=$(ogGetPath "/$1/windows/system32/config/$2") |
---|
66 | [ -f $FLEHXP ] && FILE="$FILEXP" |
---|
67 | [ ! -f $FILE ] && ogRaiseError OG_ERR_NOTFOUND "$1,$2" && return $? |
---|
68 | |
---|
69 | echo "$FILE" |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | #/** |
---|
74 | # ogGetRegistryValue path_mountpoint str_hive str_valuename |
---|
75 | #@brief Devuelve el dato de un valor del registro de Windows. |
---|
76 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
77 | #@param str_hive sección del registro |
---|
78 | #@param str_valuename nombre del valor |
---|
79 | #@return str_valuedata - datos del valor. |
---|
80 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
81 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
82 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
83 | #@note hive = { default, sam, security, software, system, components } |
---|
84 | #@warning Requisitos: chntpw, awk |
---|
85 | #@warning La partición de Windows debe estar montada previamente. |
---|
86 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
87 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
88 | #@date 2009-09-11 |
---|
89 | #*/ ## |
---|
90 | function ogGetRegistryValue () |
---|
91 | { |
---|
92 | # Variables locales. |
---|
93 | local FILE |
---|
94 | |
---|
95 | # Si se solicita, mostrar ayuda. |
---|
96 | if [ "$*" == "help" ]; then |
---|
97 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename" |
---|
98 | return |
---|
99 | fi |
---|
100 | # Error si no se reciben 3 parámetros. |
---|
101 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
102 | |
---|
103 | # Camino del fichero de registro. |
---|
104 | FILE=$(ogGetRegistryPath "$1" "$2") || return $? |
---|
105 | |
---|
106 | # Devolver el dato del valor de registro. |
---|
107 | # /* (comentario Doxygen) |
---|
108 | chntpw $FILE << FIN 2>/dev/null | awk '/> Value/ {getline;print $0;}' |
---|
109 | cd ${3%\\*} |
---|
110 | cat ${3##*\\} |
---|
111 | q |
---|
112 | FIN |
---|
113 | # (comentario Doxygen) */ |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | #/** |
---|
118 | # ogListRegistryKey path_mountpoint str_hive str_key |
---|
119 | #@brief Lista los nombres de claves de una determinada clave del registro de Windows. |
---|
120 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
121 | #@param str_hive sección del registro |
---|
122 | #@param str_key clave de registro |
---|
123 | #@return str_subkey ... - lista de subclaves |
---|
124 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
125 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
126 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
127 | #@note hive = { default, sam, security, software, system, components } |
---|
128 | #@warning Requisitos: chntpw, awk |
---|
129 | #@warning La partición de Windows debe estar montada previamente. |
---|
130 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
131 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
132 | #@date 2009-09-23 |
---|
133 | #@version 1.0.1 - Renombrada de ogListRegistryKeys |
---|
134 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
135 | #@date 2011-05-18 |
---|
136 | #*/ ## |
---|
137 | function ogListRegistryKey () |
---|
138 | { |
---|
139 | # Variables locales. |
---|
140 | local FILE |
---|
141 | |
---|
142 | # Si se solicita, mostrar ayuda. |
---|
143 | if [ "$*" == "help" ]; then |
---|
144 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" |
---|
145 | return |
---|
146 | fi |
---|
147 | # Error si no se reciben 3 parámetros. |
---|
148 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
149 | |
---|
150 | # Camino del fichero de registro. |
---|
151 | FILE=$(ogGetRegistryPath "$1" "$2") || return $? |
---|
152 | |
---|
153 | # Devolver la lista de claves de registro. |
---|
154 | chntpw $FILE << FIN 2>/dev/null | awk 'BEGIN {FS="[<>]"} $1~/^ $/ {print $2}' |
---|
155 | ls $3 |
---|
156 | q |
---|
157 | FIN |
---|
158 | } |
---|
159 | |
---|
160 | |
---|
161 | #/** |
---|
162 | # ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata |
---|
163 | #@brief Establece el dato asociado a un valor del registro de Windows. |
---|
164 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
165 | #@param str_hive tipo de registro |
---|
166 | #@param str_valuename nombre del valor de registro |
---|
167 | #@param str_valuedata dato del valor de registro |
---|
168 | #@return (nada) |
---|
169 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
170 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
171 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
172 | #@note hive = { default, sam, security, software, system, components } |
---|
173 | #@warning Requisitos: chntpw, awk |
---|
174 | #@warning La partición de Windows debe estar montada previamente. |
---|
175 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
176 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
177 | #@date 2009-09-24 |
---|
178 | #*/ ## |
---|
179 | function ogSetRegistryValue () |
---|
180 | { |
---|
181 | # Variables locales. |
---|
182 | local FILE |
---|
183 | |
---|
184 | # Si se solicita, mostrar ayuda. |
---|
185 | if [ "$*" == "help" ]; then |
---|
186 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename str_data" |
---|
187 | return |
---|
188 | fi |
---|
189 | # Error si no se reciben 4 parámetros. |
---|
190 | [ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
191 | |
---|
192 | # Camino del fichero de registro. |
---|
193 | FILE=$(ogGetRegistryPath "$1" "$2") || return $? |
---|
194 | |
---|
195 | # Cambiar el dato del valor de registro. |
---|
196 | chntpw $FILE << FIN &>/dev/null |
---|
197 | ed $3 |
---|
198 | $4 |
---|
199 | q |
---|
200 | y |
---|
201 | FIN |
---|
202 | } |
---|
203 | |
---|