2 * Unix SMB/CIFS implementation.
4 * WINREG client routines
6 * Copyright (c) 2011 Andreas Schneider <asn@samba.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
26 * @brief Query a key for the specified dword value.
28 * Get the data that is associated with the named value of a specified registry
29 * open key. This function ensures that the key is a dword and converts it
32 * @param[in] mem_ctx The memory context to use.
34 * @param[in] h The binding handle for the rpc connection.
36 * @param[in] key_handle A handle to a key that MUST have been opened
39 * @param[in] value The name of the value to query.
41 * @param[out] data A pointer to store the data of the value.
43 * @param[out] pwerr A pointer to a WERROR to store result of the query.
45 * @return NT_STATUS_OK on success or a corresponding error if
46 * there was a problem on the connection.
48 NTSTATUS
dcerpc_winreg_query_dword(TALLOC_CTX
*mem_ctx
,
49 struct dcerpc_binding_handle
*h
,
50 struct policy_handle
*key_handle
,
56 * @brief Query a key for the specified binary value.
58 * Get the data that is associated with the named value of a specified registry
59 * open key. This function ensures that the key is a binary value.
61 * @param[in] mem_ctx The memory context to use.
63 * @param[in] h The binding handle for the rpc connection.
65 * @param[in] key_handle A handle to a key that MUST have been opened
68 * @param[in] value The name of the value to query.
70 * @param[out] data A pointer to store the data of the value.
72 * @param[out] pwerr A pointer to a WERROR to store result of the query.
74 * @return NT_STATUS_OK on success or a corresponding error if
75 * there was a problem on the connection.
77 NTSTATUS
dcerpc_winreg_query_binary(TALLOC_CTX
*mem_ctx
,
78 struct dcerpc_binding_handle
*h
,
79 struct policy_handle
*key_handle
,
85 * @brief Query a key for the specified multi sz value.
87 * Get the data that is associated with the named value of a specified registry
88 * open key. This function ensures that the key is a multi sz value.
90 * @param[in] mem_ctx The memory context to use.
92 * @param[in] h The binding handle for the rpc connection.
94 * @param[in] key_handle A handle to a key that MUST have been opened
97 * @param[in] value The name of the value to query.
99 * @param[out] data A pointer to store the data of the value.
101 * @param[out] pwerr A pointer to a WERROR to store result of the query.
103 * @return NT_STATUS_OK on success or a corresponding error if
104 * there was a problem on the connection.
106 NTSTATUS
dcerpc_winreg_query_multi_sz(TALLOC_CTX
*mem_ctx
,
107 struct dcerpc_binding_handle
*h
,
108 struct policy_handle
*key_handle
,
114 * @brief Query a key for the specified sz value.
116 * Get the data that is associated with the named value of a specified registry
117 * open key. This function ensures that the key is a multi sz value.
119 * @param[in] mem_ctx The memory context to use.
121 * @param[in] h The binding handle for the rpc connection.
123 * @param[in] key_handle A handle to a key that MUST have been opened
126 * @param[in] value The name of the value to query.
128 * @param[out] data A pointer to store the data of the value.
130 * @param[out] pwerr A pointer to a WERROR to store result of the query.
132 * @return NT_STATUS_OK on success or a corresponding error if
133 * there was a problem on the connection.
135 NTSTATUS
dcerpc_winreg_query_sz(TALLOC_CTX
*mem_ctx
,
136 struct dcerpc_binding_handle
*h
,
137 struct policy_handle
*key_handle
,
143 * @brief Query a key for the specified security descriptor.
145 * Get the data that is associated with the named value of a specified registry
146 * open key. This function ensures that the key is a security descriptor.
148 * @param[in] mem_ctx The memory context to use.
150 * @param[in] h The binding handle for the rpc connection.
152 * @param[in] key_handle A handle to a key that MUST have been opened
155 * @param[in] value The name of the value to query.
157 * @param[out] data A pointer to store the data of the value.
159 * @param[out] pwerr A pointer to a WERROR to store result of the query.
161 * @return NT_STATUS_OK on success or a corresponding error if
162 * there was a problem on the connection.
164 NTSTATUS
dcerpc_winreg_query_sd(TALLOC_CTX
*mem_ctx
,
165 struct dcerpc_binding_handle
*h
,
166 struct policy_handle
*key_handle
,
168 struct security_descriptor
**data
,
172 * @brief Set a value with the specified dword data.
174 * @param[in] mem_ctx The memory context to use.
176 * @param[in] h The binding handle for the rpc connection.
178 * @param[in] key_handle A handle to a key that MUST have been opened
181 * @param[in] value The name of the value to set.
183 * @param[in] data The data to store in the value.
185 * @param[out] pwerr A pointer to a WERROR to store result of the query.
187 * @return NT_STATUS_OK on success or a corresponding error if
188 * there was a problem on the connection.
190 NTSTATUS
dcerpc_winreg_set_dword(TALLOC_CTX
*mem_ctx
,
191 struct dcerpc_binding_handle
*h
,
192 struct policy_handle
*key_handle
,
198 * @brief Set a value with the specified sz data.
200 * @param[in] mem_ctx The memory context to use.
202 * @param[in] h The binding handle for the rpc connection.
204 * @param[in] key_handle A handle to a key that MUST have been opened
207 * @param[in] value The name of the value to set.
209 * @param[in] data The data to store in the value.
211 * @param[out] pwerr A pointer to a WERROR to store result of the query.
213 * @return NT_STATUS_OK on success or a corresponding error if
214 * there was a problem on the connection.
216 NTSTATUS
dcerpc_winreg_set_sz(TALLOC_CTX
*mem_ctx
,
217 struct dcerpc_binding_handle
*h
,
218 struct policy_handle
*key_handle
,
224 * @brief Set a value with the specified expand sz data.
226 * @param[in] mem_ctx The memory context to use.
228 * @param[in] h The binding handle for the rpc connection.
230 * @param[in] key_handle A handle to a key that MUST have been opened
233 * @param[in] value The name of the value to set.
235 * @param[in] data The data to store in the value.
237 * @param[out] pwerr A pointer to a WERROR to store result of the query.
239 * @return NT_STATUS_OK on success or a corresponding error if
240 * there was a problem on the connection.
242 NTSTATUS
dcerpc_winreg_set_expand_sz(TALLOC_CTX
*mem_ctx
,
243 struct dcerpc_binding_handle
*h
,
244 struct policy_handle
*key_handle
,
250 * @brief Set a value with the specified multi sz data.
252 * @param[in] mem_ctx The memory context to use.
254 * @param[in] h The binding handle for the rpc connection.
256 * @param[in] key_handle A handle to a key that MUST have been opened
259 * @param[in] value The name of the value to set.
261 * @param[in] data The data to store in the value.
263 * @param[out] pwerr A pointer to a WERROR to store result of the query.
265 * @return NT_STATUS_OK on success or a corresponding error if
266 * there was a problem on the connection.
268 NTSTATUS
dcerpc_winreg_set_multi_sz(TALLOC_CTX
*mem_ctx
,
269 struct dcerpc_binding_handle
*h
,
270 struct policy_handle
*key_handle
,
276 * @brief Set a value with the specified binary data.
278 * @param[in] mem_ctx The memory context to use.
280 * @param[in] h The binding handle for the rpc connection.
282 * @param[in] key_handle A handle to a key that MUST have been opened
285 * @param[in] value The name of the value to set.
287 * @param[in] data The data to store in the value.
289 * @param[out] pwerr A pointer to a WERROR to store result of the query.
291 * @return NT_STATUS_OK on success or a corresponding error if
292 * there was a problem on the connection.
294 NTSTATUS
dcerpc_winreg_set_binary(TALLOC_CTX
*mem_ctx
,
295 struct dcerpc_binding_handle
*h
,
296 struct policy_handle
*key_handle
,
302 * @brief Set a value with the specified security descriptor.
304 * @param[in] mem_ctx The memory context to use.
306 * @param[in] h The binding handle for the rpc connection.
308 * @param[in] key_handle A handle to a key that MUST have been opened
311 * @param[in] value The name of the value to set.
313 * @param[in] data The security descriptor to store in the value.
315 * @param[out] pwerr A pointer to a WERROR to store result of the query.
317 * @return NT_STATUS_OK on success or a corresponding error if
318 * there was a problem on the connection.
320 NTSTATUS
dcerpc_winreg_set_sd(TALLOC_CTX
*mem_ctx
,
321 struct dcerpc_binding_handle
*h
,
322 struct policy_handle
*key_handle
,
324 const struct security_descriptor
*data
,
328 * @brief Add a value to the multi sz data.
330 * This reads the multi sz data from the given value and adds the data to the
331 * multi sz. Then it saves it to the regsitry.
333 * @param[in] mem_ctx The memory context to use.
335 * @param[in] h The binding handle for the rpc connection.
337 * @param[in] key_handle A handle to a key that MUST have been opened
340 * @param[in] value The name of the value to set.
342 * @param[in] data The data to add.
344 * @param[out] pwerr A pointer to a WERROR to store result of the query.
346 * @return NT_STATUS_OK on success or a corresponding error if
347 * there was a problem on the connection.
349 NTSTATUS
dcerpc_winreg_add_multi_sz(TALLOC_CTX
*mem_ctx
,
350 struct dcerpc_binding_handle
*h
,
351 struct policy_handle
*key_handle
,
357 * @brief Enumerate on the given keyhandle to get the subkey names.
359 * @param[in] mem_ctx The memory context to use.
361 * @param[in] h The binding handle for the rpc connection.
363 * @param[in] key_handle A handle to a key that MUST have been opened
366 * @param[out] pnum_subkeys A pointer to store the number of subkeys.
368 * @param[out] psubkeys A pointer to store the names of the subkeys.
370 * @param[out] pwerr A pointer to a WERROR to store result of the query.
372 * @return NT_STATUS_OK on success or a corresponding error if
373 * there was a problem on the connection.
375 NTSTATUS
dcerpc_winreg_enum_keys(TALLOC_CTX
*mem_ctx
,
376 struct dcerpc_binding_handle
*h
,
377 struct policy_handle
*key_hnd
,
378 uint32_t *pnum_subkeys
,
379 const char ***psubkeys
,
384 * @brief Enumerate values of an opened key handle and retrieve the data.
386 * @param[in] mem_ctx The memory context to use.
388 * @param[in] winreg_handle The binding handle for the rpc connection.
390 * @param[in] key_hnd The opened key handle.
392 * @param[out] pnum_values A pointer to store the number of values we found.
394 * @param[out] pnames A pointer to store all the names of the values we found.
396 * @param[out] _type A pointer to store all the types coresponding with the
398 * @param[out] pdata A pointer to store the data coresponding to the values.
400 * @param[out] pwerr A pointer to the WERROR. WERR_OK on success
401 * WERR_OK on success, the corresponding DOS error
402 * code if something's gone wrong.
404 * @return NT_STATUS_OK on success or a corresponding error if
405 * there was a problem on the connection.
408 NTSTATUS
dcerpc_winreg_enumvals(TALLOC_CTX
*mem_ctx
,
409 struct dcerpc_binding_handle
*h
,
410 struct policy_handle
*key_hnd
,
411 uint32_t *pnum_values
,
412 const char ***pnames
,
413 enum winreg_Type
**_type
,
420 * @brief A function to delete a key and its subkeys recurively.
422 * @param[in] mem_ctx The memory context to use.
424 * @param[in] winreg_handle The binding handle for the rpc connection.
426 * @param[in] hive_handle A opened hive handle to the key.
428 * @param[in] access_mask The access mask to access the key.
430 * @param[in] key The key to delete
432 * @param[out] WERR_OK on success, the corresponding DOS error
433 * code if something gone wrong.
435 * @return NT_STATUS_OK on success or a corresponding error if
436 * there was a problem on the connection.
439 NTSTATUS
dcerpc_winreg_delete_subkeys_recursive(TALLOC_CTX
*mem_ctx
,
440 struct dcerpc_binding_handle
*h
,
441 struct policy_handle
*hive_handle
,
442 uint32_t access_mask
,
447 #endif /* CLI_WINREG_H */
449 /* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */