Fix bug 7045 - Bad (non memory copying) interfaces in smbc_setXXXX calls.
[Samba.git] / source / rpc_client / cli_reg.c
blobba98e25d632a8021110733ffe67ecf9f2d5d6a74
1 /*
2 Unix SMB/CIFS implementation.
3 RPC Pipe client
5 Copyright (C) Gerald (Jerry) Carter 2005-2006
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "rpc_client.h"
24 /*******************************************************************
25 connect to a registry hive root (open a registry policy)
26 *******************************************************************/
28 NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
29 uint32 reg_type, uint32 access_mask,
30 POLICY_HND *reg_hnd)
32 ZERO_STRUCTP(reg_hnd);
34 switch (reg_type)
36 case HKEY_CLASSES_ROOT:
37 return rpccli_winreg_OpenHKCR( cli, mem_ctx, NULL,
38 access_mask, reg_hnd, NULL);
40 case HKEY_LOCAL_MACHINE:
41 return rpccli_winreg_OpenHKLM( cli, mem_ctx, NULL,
42 access_mask, reg_hnd, NULL);
44 case HKEY_USERS:
45 return rpccli_winreg_OpenHKU( cli, mem_ctx, NULL,
46 access_mask, reg_hnd, NULL);
48 case HKEY_CURRENT_USER:
49 return rpccli_winreg_OpenHKCU( cli, mem_ctx, NULL,
50 access_mask, reg_hnd, NULL);
52 case HKEY_PERFORMANCE_DATA:
53 return rpccli_winreg_OpenHKPD( cli, mem_ctx, NULL,
54 access_mask, reg_hnd, NULL);
56 default:
57 /* fall through to end of function */
58 break;
61 return NT_STATUS_INVALID_PARAMETER;
64 /*******************************************************************
65 Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE
66 *******************************************************************/
68 uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val )
70 uint32 real_size = 0;
72 if ( !buf2 || !val )
73 return 0;
75 real_size = regval_size(val);
76 init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size );
78 return real_size;