- created pdb_sethexpwd(), to be called from all pwd apis that need to
[samba.git] / source3 / rpc_parse / parse_reg.c
1 /* 
2  *  Unix SMB/Netbios implementation.
3  *  Version 1.9.
4  *  RPC Pipe client / server routines
5  *  Copyright (C) Andrew Tridgell              1992-1997,
6  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7  *  Copyright (C) Paul Ashton                       1997.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24
25 #include "includes.h"
26
27 extern int DEBUGLEVEL;
28
29
30 /*******************************************************************
31 creates a structure.
32 ********************************************************************/
33 void make_reg_q_open_policy(REG_Q_OPEN_POLICY *r_q,
34                                 uint16 unknown_0, uint32 level, uint16 unknown_1)
35 {
36         r_q->ptr = 1;
37         r_q->unknown_0 = unknown_0;
38         r_q->level = level;
39         r_q->unknown_1 = unknown_1;
40 }
41
42 /*******************************************************************
43 reads or writes a structure.
44 ********************************************************************/
45 void reg_io_q_open_policy(char *desc,  REG_Q_OPEN_POLICY *r_q, prs_struct *ps, int depth)
46 {
47         if (r_q == NULL) return;
48
49         prs_debug(ps, depth, desc, "reg_io_q_open_policy");
50         depth++;
51
52         prs_align(ps);
53         
54         prs_uint32("ptr      ", ps, depth, &(r_q->ptr      ));
55         if (r_q->ptr != 0)
56         {
57                 prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0));
58                 prs_uint32("level    ", ps, depth, &(r_q->level    ));
59                 prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
60         }
61 }
62
63
64 /*******************************************************************
65 creates a structure.
66 ********************************************************************/
67 void make_reg_r_open_policy(REG_R_OPEN_POLICY *r_r,
68                                 POLICY_HND *pol, uint32 status)
69 {
70         if (r_r == NULL) return;
71
72         memcpy(&(r_r->pol), pol, sizeof(r_r->pol));
73         r_r->status = status;
74 }
75
76 /*******************************************************************
77 reads or writes a structure.
78 ********************************************************************/
79 void reg_io_r_open_policy(char *desc,  REG_R_OPEN_POLICY *r_r, prs_struct *ps, int depth)
80 {
81         if (r_r == NULL) return;
82
83         prs_debug(ps, depth, desc, "reg_io_r_open_policy");
84         depth++;
85
86         prs_align(ps);
87         
88         smb_io_pol_hnd("", &(r_r->pol), ps, depth);
89
90         prs_uint32("status", ps, depth, &(r_r->status));
91 }
92
93
94 /*******************************************************************
95 reads or writes a structure.
96 ********************************************************************/
97 void reg_io_q_close(char *desc,  REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
98 {
99         if (q_u == NULL) return;
100
101         prs_debug(ps, depth, desc, "reg_io_q_unknown_1");
102         depth++;
103
104         prs_align(ps);
105
106         smb_io_pol_hnd("", &(q_u->pol), ps, depth); 
107         prs_align(ps);
108 }
109
110 /*******************************************************************
111 reads or writes a structure.
112 ********************************************************************/
113 void reg_io_r_close(char *desc,  REG_R_CLOSE *r_u, prs_struct *ps, int depth)
114 {
115         if (r_u == NULL) return;
116
117         prs_debug(ps, depth, desc, "reg_io_r_unknown_1");
118         depth++;
119
120         prs_align(ps);
121
122         smb_io_pol_hnd("", &(r_u->pol), ps, depth); 
123         prs_align(ps);
124
125         prs_uint32("status", ps, depth, &(r_u->status));
126 }
127 /*******************************************************************
128 creates a structure.
129 ********************************************************************/
130 void make_reg_q_info(REG_Q_INFO *r_q,
131                                 POLICY_HND *pol, char *product_type,
132                                 NTTIME *prod_time, uint8 major_version, uint8 minor_version,
133                                 uint32 unknown)
134 {
135         int type_len = strlen(product_type);
136
137         memcpy(&(r_q->pol), pol, sizeof(r_q->pol));
138         make_uni_hdr(&(r_q->hdr_type), type_len, type_len, 1);
139         make_unistr2(&(r_q->uni_type), product_type, type_len);
140
141         r_q->ptr1 = 1;
142         memcpy(&(r_q->time), prod_time, sizeof(r_q->time));
143         r_q->major_version1 = major_version;
144         r_q->minor_version1 = minor_version;
145         bzero(r_q->pad1, sizeof(r_q->pad1));
146
147         r_q->ptr2 = 1;
148         r_q->major_version2 = major_version;
149         r_q->minor_version2 = minor_version;
150         bzero(r_q->pad2, sizeof(r_q->pad2));
151
152         r_q->ptr3 = 1;
153         r_q->unknown = unknown;
154 }
155
156 /*******************************************************************
157 reads or writes a structure.
158 ********************************************************************/
159 void reg_io_q_info(char *desc,  REG_Q_INFO *r_q, prs_struct *ps, int depth)
160 {
161         if (r_q == NULL) return;
162
163         prs_debug(ps, depth, desc, "reg_io_q_info");
164         depth++;
165
166         prs_align(ps);
167         
168         smb_io_pol_hnd("", &(r_q->pol), ps, depth); 
169         smb_io_unihdr ("", &(r_q->hdr_type), ps, depth);
170         smb_io_unistr2("", &(r_q->uni_type), r_q->hdr_type.buffer, ps, depth);
171
172         prs_uint32("ptr1", ps, depth, &(r_q->ptr1));
173
174         if (r_q->ptr1 != 0)
175         {
176                 smb_io_time("", &(r_q->time), ps, depth);
177                 prs_uint8 ("major_version1", ps, depth, &(r_q->major_version1));
178                 prs_uint8 ("minor_version1", ps, depth, &(r_q->minor_version1));
179                 prs_uint8s(False, "pad1", ps, depth, r_q->pad1, sizeof(r_q->pad1));
180         }
181
182         prs_uint32("ptr2", ps, depth, &(r_q->ptr2));
183
184         if (r_q->ptr2 != 0)
185         {
186                 prs_uint8 ("major_version2", ps, depth, &(r_q->major_version2));
187                 prs_uint8 ("minor_version2", ps, depth, &(r_q->minor_version2));
188                 prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2));
189         }
190
191         prs_uint32("ptr3", ps, depth, &(r_q->ptr3));
192
193         if (r_q->ptr3 != 0)
194         {
195                 prs_uint32("unknown", ps, depth, &(r_q->unknown));
196         }
197 }
198
199
200 /*******************************************************************
201 creates a structure.
202 ********************************************************************/
203 void make_reg_r_info(REG_R_INFO *r_r,
204                                 uint32 level, char *os_type,
205                                 uint32 unknown_0, uint32 unknown_1,
206                                 uint32 status)
207 {
208         int type_len = strlen(os_type);
209
210         r_r->ptr1 = 1;
211         r_r->level = level;
212
213         r_r->ptr_type = 1;
214         make_uninotstr2(&(r_r->uni_type), os_type, type_len);
215
216         r_r->ptr2 = 1;
217         r_r->unknown_0 = unknown_0;
218
219         r_r->ptr3 = 1;
220         r_r->unknown_1 = unknown_1;
221
222         r_r->status = status;
223 }
224
225 /*******************************************************************
226 reads or writes a structure.
227 ********************************************************************/
228 void reg_io_r_info(char *desc,  REG_R_INFO *r_r, prs_struct *ps, int depth)
229 {
230         if (r_r == NULL) return;
231
232         prs_debug(ps, depth, desc, "reg_io_r_info");
233         depth++;
234
235         prs_align(ps);
236         
237         prs_uint32("ptr1", ps, depth, &(r_r->ptr1));
238
239         if (r_r->ptr1 != 0)
240         {
241                 prs_uint32("level", ps, depth, &(r_r->level));
242
243                 prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type));
244                 smb_io_uninotstr2("", &(r_r->uni_type), r_r->ptr_type, ps, depth);
245                 prs_align(ps);
246
247                 prs_uint32("ptr2", ps, depth, &(r_r->ptr2));
248
249                 if (r_r->ptr2 != 0)
250                 {
251                         prs_uint32("unknown_0", ps, depth, &(r_r->unknown_0));
252                 }
253
254                 prs_uint32("ptr3", ps, depth, &(r_r->ptr3));
255
256                 if (r_r->ptr3 != 0)
257                 {
258                         prs_uint32("unknown_1", ps, depth, &(r_r->unknown_1));
259                 }
260         }
261
262         prs_uint32("status", ps, depth, &(r_r->status));
263 }
264
265
266 /*******************************************************************
267 creates a structure.
268 ********************************************************************/
269 void make_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q,
270                                 POLICY_HND *pol, char *name,
271                                 uint32 unknown_0, uint32 unknown_1, uint16 unknown_2)
272 {
273         int len_name = strlen(name);
274
275         memcpy(&(r_q->pol), pol, sizeof(r_q->pol));
276
277         make_uni_hdr(&(r_q->hdr_name), len_name, len_name, 1);
278         make_unistr2(&(r_q->uni_name), name, len_name);
279
280         r_q->unknown_0 = unknown_0;
281         r_q->unknown_1 = unknown_1;
282         r_q->unknown_2 = unknown_2;
283 }
284
285 /*******************************************************************
286 reads or writes a structure.
287 ********************************************************************/
288 void reg_io_q_open_entry(char *desc,  REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
289 {
290         if (r_q == NULL) return;
291
292         prs_debug(ps, depth, desc, "reg_io_q_entry");
293         depth++;
294
295         prs_align(ps);
296         
297         smb_io_pol_hnd("", &(r_q->pol), ps, depth);
298         smb_io_unihdr ("", &(r_q->hdr_name), ps, depth);
299         smb_io_unistr2("", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth);
300
301         prs_uint32("unknown_0", ps, depth, &(r_q->unknown_0));
302         prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
303         prs_uint16("unknown_2", ps, depth, &(r_q->unknown_2));
304 }
305
306
307 /*******************************************************************
308 creates a structure.
309 ********************************************************************/
310 void make_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
311                                 POLICY_HND *pol, uint32 status)
312 {
313         if (r_r == NULL) return;
314
315         memcpy(&(r_r->pol), pol, sizeof(r_r->pol));
316         r_r->status = status;
317 }
318
319 /*******************************************************************
320 reads or writes a structure.
321 ********************************************************************/
322 void reg_io_r_open_entry(char *desc,  REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
323 {
324         if (r_r == NULL) return;
325
326         prs_debug(ps, depth, desc, "reg_io_r_open_entry");
327         depth++;
328
329         prs_align(ps);
330         
331         smb_io_pol_hnd("", &(r_r->pol), ps, depth);
332
333         prs_uint32("status", ps, depth, &(r_r->status));
334 }
335