s3-rpc_client: Added a winreg helper to enum keys.
[vlendec/samba-autobuild/.git] / source3 / rpc_client / cli_winreg.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *
4  *  WINREG client routines
5  *
6  *  Copyright (c) 2011      Andreas Schneider <asn@samba.org>
7  *
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.
12  *
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.
17  *
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/>.
20  */
21
22 #ifndef CLI_WINREG_H
23 #define CLI_WINREG_H
24
25 /**
26  * @brief Query a key for the specified dword value.
27  *
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
30  * corretly.
31  *
32  * @param[in]  mem_ctx  The memory context to use.
33  *
34  * @param[in]  h        The binding handle for the rpc connection.
35  *
36  * @param[in]  key_handle A handle to a key that MUST have been opened
37  *                        previously.
38  *
39  * @param[in]  value    The name of the value to query.
40  *
41  * @param[out] data     A pointer to store the data of the value.
42  *
43  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
44  *
45  * @return              NT_STATUS_OK on success or a corresponding error if
46  *                      there was a problem on the connection.
47  */
48 NTSTATUS dcerpc_winreg_query_dword(TALLOC_CTX *mem_ctx,
49                                    struct dcerpc_binding_handle *h,
50                                    struct policy_handle *key_handle,
51                                    const char *value,
52                                    uint32_t *data,
53                                    WERROR *pwerr);
54
55 /**
56  * @brief Query a key for the specified binary value.
57  *
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.
60  *
61  * @param[in]  mem_ctx  The memory context to use.
62  *
63  * @param[in]  h        The binding handle for the rpc connection.
64  *
65  * @param[in]  key_handle A handle to a key that MUST have been opened
66  *                        previously.
67  *
68  * @param[in]  value    The name of the value to query.
69  *
70  * @param[out] data     A pointer to store the data of the value.
71  *
72  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
73  *
74  * @return              NT_STATUS_OK on success or a corresponding error if
75  *                      there was a problem on the connection.
76  */
77 NTSTATUS dcerpc_winreg_query_binary(TALLOC_CTX *mem_ctx,
78                                     struct dcerpc_binding_handle *h,
79                                     struct policy_handle *key_handle,
80                                     const char *value,
81                                     DATA_BLOB *data,
82                                     WERROR *pwerr);
83
84 /**
85  * @brief Query a key for the specified multi sz value.
86  *
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.
89  *
90  * @param[in]  mem_ctx  The memory context to use.
91  *
92  * @param[in]  h        The binding handle for the rpc connection.
93  *
94  * @param[in]  key_handle A handle to a key that MUST have been opened
95  *                        previously.
96  *
97  * @param[in]  value    The name of the value to query.
98  *
99  * @param[out] data     A pointer to store the data of the value.
100  *
101  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
102  *
103  * @return              NT_STATUS_OK on success or a corresponding error if
104  *                      there was a problem on the connection.
105  */
106 NTSTATUS dcerpc_winreg_query_multi_sz(TALLOC_CTX *mem_ctx,
107                                       struct dcerpc_binding_handle *h,
108                                       struct policy_handle *key_handle,
109                                       const char *value,
110                                       const char ***data,
111                                       WERROR *pwerr);
112
113 /**
114  * @brief Set a value with the specified dword data.
115  *
116  * @param[in]  mem_ctx  The memory context to use.
117  *
118  * @param[in]  h        The binding handle for the rpc connection.
119  *
120  * @param[in]  key_handle A handle to a key that MUST have been opened
121  *                        previously.
122  *
123  * @param[in]  value    The name of the value to set.
124  *
125  * @param[in]  data     The data to store in the value.
126  *
127  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
128  *
129  * @return              NT_STATUS_OK on success or a corresponding error if
130  *                      there was a problem on the connection.
131  */
132 NTSTATUS dcerpc_winreg_set_dword(TALLOC_CTX *mem_ctx,
133                                  struct dcerpc_binding_handle *h,
134                                  struct policy_handle *key_handle,
135                                  const char *value,
136                                  uint32_t data,
137                                  WERROR *pwerr);
138
139 /**
140  * @brief Set a value with the specified sz data.
141  *
142  * @param[in]  mem_ctx  The memory context to use.
143  *
144  * @param[in]  h        The binding handle for the rpc connection.
145  *
146  * @param[in]  key_handle A handle to a key that MUST have been opened
147  *                        previously.
148  *
149  * @param[in]  value    The name of the value to set.
150  *
151  * @param[in]  data     The data to store in the value.
152  *
153  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
154  *
155  * @return              NT_STATUS_OK on success or a corresponding error if
156  *                      there was a problem on the connection.
157  */
158 NTSTATUS dcerpc_winreg_set_sz(TALLOC_CTX *mem_ctx,
159                               struct dcerpc_binding_handle *h,
160                               struct policy_handle *key_handle,
161                               const char *value,
162                               const char *data,
163                               WERROR *pwerr);
164
165 /**
166  * @brief Set a value with the specified expand sz data.
167  *
168  * @param[in]  mem_ctx  The memory context to use.
169  *
170  * @param[in]  h        The binding handle for the rpc connection.
171  *
172  * @param[in]  key_handle A handle to a key that MUST have been opened
173  *                        previously.
174  *
175  * @param[in]  value    The name of the value to set.
176  *
177  * @param[in]  data     The data to store in the value.
178  *
179  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
180  *
181  * @return              NT_STATUS_OK on success or a corresponding error if
182  *                      there was a problem on the connection.
183  */
184 NTSTATUS dcerpc_winreg_set_expand_sz(TALLOC_CTX *mem_ctx,
185                                      struct dcerpc_binding_handle *h,
186                                      struct policy_handle *key_handle,
187                                      const char *value,
188                                      const char *data,
189                                      WERROR *pwerr);
190
191 /**
192  * @brief Set a value with the specified multi sz data.
193  *
194  * @param[in]  mem_ctx  The memory context to use.
195  *
196  * @param[in]  h        The binding handle for the rpc connection.
197  *
198  * @param[in]  key_handle A handle to a key that MUST have been opened
199  *                        previously.
200  *
201  * @param[in]  value    The name of the value to set.
202  *
203  * @param[in]  data     The data to store in the value.
204  *
205  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
206  *
207  * @return              NT_STATUS_OK on success or a corresponding error if
208  *                      there was a problem on the connection.
209  */
210 NTSTATUS dcerpc_winreg_set_multi_sz(TALLOC_CTX *mem_ctx,
211                                     struct dcerpc_binding_handle *h,
212                                     struct policy_handle *key_handle,
213                                     const char *value,
214                                     const char **data,
215                                     WERROR *pwerr);
216
217 /**
218  * @brief Add a value to the multi sz data.
219  *
220  * This reads the multi sz data from the given value and adds the data to the
221  * multi sz. Then it saves it to the regsitry.
222  *
223  * @param[in]  mem_ctx  The memory context to use.
224  *
225  * @param[in]  h        The binding handle for the rpc connection.
226  *
227  * @param[in]  key_handle A handle to a key that MUST have been opened
228  *                        previously.
229  *
230  * @param[in]  value    The name of the value to set.
231  *
232  * @param[in]  data     The data to add.
233  *
234  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
235  *
236  * @return              NT_STATUS_OK on success or a corresponding error if
237  *                      there was a problem on the connection.
238  */
239 NTSTATUS dcerpc_winreg_add_multi_sz(TALLOC_CTX *mem_ctx,
240                                     struct dcerpc_binding_handle *h,
241                                     struct policy_handle *key_handle,
242                                     const char *value,
243                                     const char *data,
244                                     WERROR *pwerr);
245
246 /**
247  * @brief Enumerate on the given keyhandle to get the subkey names.
248  *
249  * @param[in]  mem_ctx  The memory context to use.
250  *
251  * @param[in]  h        The binding handle for the rpc connection.
252  *
253  * @param[in]  key_handle A handle to a key that MUST have been opened
254  *                        previously.
255  *
256  * @param[out] pnum_subkeys A pointer to store the number of subkeys.
257  *
258  * @param[out] psubkeys A pointer to store the names of the subkeys.
259  *
260  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
261  *
262  * @return              NT_STATUS_OK on success or a corresponding error if
263  *                      there was a problem on the connection.
264  */
265 NTSTATUS dcerpc_winreg_enum_keys(TALLOC_CTX *mem_ctx,
266                                  struct dcerpc_binding_handle *h,
267                                  struct policy_handle *key_hnd,
268                                  uint32_t *pnum_subkeys,
269                                  const char ***psubkeys,
270                                  WERROR *pwerr);
271
272 #endif /* CLI_WINREG_H */
273
274 /* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */