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/>.
23 #include "../librpc/gen_ndr/ndr_winreg_c.h"
24 #include "rpc_client/cli_winreg.h"
26 NTSTATUS
dcerpc_winreg_query_dword(TALLOC_CTX
*mem_ctx
,
27 struct dcerpc_binding_handle
*h
,
28 struct policy_handle
*key_handle
,
33 struct winreg_String wvalue
;
34 enum winreg_Type type
;
35 uint32_t value_len
= 0;
36 uint32_t data_size
= 0;
37 WERROR result
= WERR_OK
;
43 status
= dcerpc_winreg_QueryValue(h
,
52 if (!NT_STATUS_IS_OK(status
)) {
55 if (!W_ERROR_IS_OK(result
)) {
60 if (type
!= REG_DWORD
) {
61 *pwerr
= WERR_INVALID_DATATYPE
;
66 *pwerr
= WERR_INVALID_DATA
;
70 blob
= data_blob_talloc(mem_ctx
, NULL
, data_size
);
71 if (blob
.data
== NULL
) {
77 status
= dcerpc_winreg_QueryValue(h
,
86 if (!NT_STATUS_IS_OK(status
)) {
89 if (!W_ERROR_IS_OK(result
)) {
95 *data
= IVAL(blob
.data
, 0);
101 NTSTATUS
dcerpc_winreg_query_binary(TALLOC_CTX
*mem_ctx
,
102 struct dcerpc_binding_handle
*h
,
103 struct policy_handle
*key_handle
,
108 struct winreg_String wvalue
;
109 enum winreg_Type type
;
110 WERROR result
= WERR_OK
;
111 uint32_t value_len
= 0;
112 uint32_t data_size
= 0;
118 status
= dcerpc_winreg_QueryValue(h
,
127 if (!NT_STATUS_IS_OK(status
)) {
130 if (!W_ERROR_IS_OK(result
)) {
135 if (type
!= REG_BINARY
) {
136 *pwerr
= WERR_INVALID_DATATYPE
;
140 blob
= data_blob_talloc(mem_ctx
, NULL
, data_size
);
141 if (blob
.data
== NULL
) {
147 status
= dcerpc_winreg_QueryValue(h
,
156 if (!NT_STATUS_IS_OK(status
)) {
159 if (!W_ERROR_IS_OK(result
)) {
165 data
->data
= blob
.data
;
166 data
->length
= blob
.length
;
172 NTSTATUS
dcerpc_winreg_set_dword(TALLOC_CTX
*mem_ctx
,
173 struct dcerpc_binding_handle
*h
,
174 struct policy_handle
*key_handle
,
179 struct winreg_String wvalue
;
181 WERROR result
= WERR_OK
;
185 blob
= data_blob_talloc(mem_ctx
, NULL
, 4);
186 SIVAL(blob
.data
, 0, data
);
188 status
= dcerpc_winreg_SetValue(h
,
196 if (!NT_STATUS_IS_OK(status
)) {
199 if (!W_ERROR_IS_OK(result
)) {
206 NTSTATUS
dcerpc_winreg_set_sz(TALLOC_CTX
*mem_ctx
,
207 struct dcerpc_binding_handle
*h
,
208 struct policy_handle
*key_handle
,
213 struct winreg_String wvalue
;
215 WERROR result
= WERR_OK
;
220 blob
= data_blob_string_const("");
222 if (!push_reg_sz(mem_ctx
, &blob
, data
)) {
223 DEBUG(2, ("dcerpc_winreg_set_sz: Could not marshall "
224 "string %s for %s\n",
231 status
= dcerpc_winreg_SetValue(h
,
239 if (!NT_STATUS_IS_OK(status
)) {
242 if (!W_ERROR_IS_OK(result
)) {
249 NTSTATUS
dcerpc_winreg_set_expand_sz(TALLOC_CTX
*mem_ctx
,
250 struct dcerpc_binding_handle
*h
,
251 struct policy_handle
*key_handle
,
256 struct winreg_String wvalue
;
258 WERROR result
= WERR_OK
;
263 blob
= data_blob_string_const("");
265 if (!push_reg_sz(mem_ctx
, &blob
, data
)) {
266 DEBUG(2, ("dcerpc_winreg_set_expand_sz: Could not marshall "
267 "string %s for %s\n",
274 status
= dcerpc_winreg_SetValue(h
,
282 if (!NT_STATUS_IS_OK(status
)) {
285 if (!W_ERROR_IS_OK(result
)) {
292 /* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */