rpcclient registry commands.
[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_pol(REG_Q_OPEN_POLICY *q_o,
34                                 uint16 unknown_0, uint32 level)
35 {
36         q_o->ptr = 1;
37         q_o->unknown_0 = unknown_0;
38         q_o->unknown_1 = 0x0; /* random - changes */
39         q_o->level = level;
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_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
59                 prs_uint32("level    ", ps, depth, &(r_q->level    ));
60         }
61 }
62
63
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
67 void reg_io_r_open_policy(char *desc,  REG_R_OPEN_POLICY *r_r, prs_struct *ps, int depth)
68 {
69         if (r_r == NULL) return;
70
71         prs_debug(ps, depth, desc, "reg_io_r_open_policy");
72         depth++;
73
74         prs_align(ps);
75         
76         smb_io_pol_hnd("", &(r_r->pol), ps, depth);
77
78         prs_uint32("status", ps, depth, &(r_r->status));
79 }
80
81
82
83 /*******************************************************************
84 creates a structure.
85 ********************************************************************/
86 void make_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd,
87                                 char *name, char *class,
88                                 SEC_INFO *sam_access)
89 {
90         int len_name  = name  != NULL ? strlen(name ) + 1: 0;
91         int len_class = class != NULL ? strlen(class) + 1: 0;
92
93         static char data[] =
94         {
95                 0x01, 0x00, 0x00, 0x80,
96                 0x00, 0x00, 0x00, 0x00,
97                 0x00, 0x00, 0x00, 0x00,
98                 0x00, 0x00, 0x00, 0x00,
99                 0x00, 0x00, 0x00, 0x00
100         };
101
102         ZERO_STRUCTP(q_c);
103
104         memcpy(&(q_c->pnt_pol), hnd, sizeof(q_c->pnt_pol));
105
106         make_uni_hdr(&(q_c->hdr_name), len_name, len_name, 1);
107         make_unistr2(&(q_c->uni_name), name, len_name);
108
109         make_uni_hdr(&(q_c->hdr_class), len_class, len_class, 1);
110         make_unistr2(&(q_c->uni_class), class, len_class);
111
112         q_c->reserved = 0x00000000;
113         memcpy(&(q_c->sam_access), sam_access, sizeof(q_c->sam_access));
114
115         q_c->ptr1 = 1;
116         q_c->unknown_0 = 0x0000000C;
117
118         q_c->ptr2 = 1;
119         q_c->unk_len1 = 0x14;
120         q_c->unk_len2 = 0x14;
121         q_c->unknown_1 = 0x00020000;
122
123         make_buffer2(&q_c->buf_unk, data, sizeof(data));
124
125         q_c->unknown_2 = 0x00000000;
126 }
127
128 /*******************************************************************
129 reads or writes a structure.
130 ********************************************************************/
131 void reg_io_q_create_key(char *desc,  REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth)
132 {
133         if (r_q == NULL) return;
134
135         prs_debug(ps, depth, desc, "reg_io_q_create_key");
136         depth++;
137
138         prs_align(ps);
139         
140         smb_io_pol_hnd("", &(r_q->pnt_pol), ps, depth);
141
142         smb_io_unihdr ("", &(r_q->hdr_name), ps, depth);
143         smb_io_unistr2("", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth);
144         prs_align(ps);
145
146         smb_io_unihdr ("", &(r_q->hdr_class), ps, depth);
147         smb_io_unistr2("", &(r_q->uni_class), r_q->hdr_class.buffer, ps, depth);
148         prs_align(ps);
149
150         prs_uint32("reserved", ps, depth, &(r_q->reserved));
151         sec_io_info("sam_access", &r_q->sam_access, ps, depth);
152
153         prs_uint32("ptr1", ps, depth, &(r_q->ptr1));
154         if (r_q->ptr2 != 0)
155         {
156                 prs_uint32("unknown_0", ps, depth, &(r_q->unknown_0));
157         }
158
159         prs_uint32("ptr2", ps, depth, &(r_q->ptr2));
160         if (r_q->ptr2)
161         {
162                 prs_uint32("unk_len1", ps, depth, &(r_q->unk_len1));
163                 prs_uint32("unk_len2", ps, depth, &(r_q->unk_len2));
164                 prs_uint32("unknown_1", ps, depth, &(r_q->unknown_1));
165                 smb_io_buffer2("buf_unk", &r_q->buf_unk, 1, ps, depth);
166                 prs_align(ps);
167
168                 prs_uint32("unknown_2", ps, depth, &(r_q->unknown_2));
169         }
170
171         prs_align(ps);
172 }
173
174
175 /*******************************************************************
176 reads or writes a structure.
177 ********************************************************************/
178 void reg_io_r_create_key(char *desc,  REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth)
179 {
180         if (r_r == NULL) return;
181
182         prs_debug(ps, depth, desc, "reg_io_r_create_key");
183         depth++;
184
185         prs_align(ps);
186         
187         smb_io_pol_hnd("", &(r_r->key_pol), ps, depth);
188         prs_uint32("unknown", ps, depth, &(r_r->unknown));
189
190         prs_uint32("status", ps, depth, &(r_r->status));
191 }
192
193
194 /*******************************************************************
195 creates a structure.
196 ********************************************************************/
197 void make_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd,
198                                 uint32 max_class_len)
199 {
200         ZERO_STRUCTP(q_o);
201
202         memcpy(&(q_o->pol), hnd, sizeof(q_o->pol));
203         make_uni_hdr(&q_o->hdr_class, max_class_len, 0, max_class_len > 0 ? 1 : 0);
204         q_o->uni_class.uni_max_len = max_class_len;
205 }
206
207 /*******************************************************************
208 reads or writes a structure.
209 ********************************************************************/
210 void reg_io_q_query_key(char *desc,  REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth)
211 {
212         if (r_q == NULL) return;
213
214         prs_debug(ps, depth, desc, "reg_io_q_query_key");
215         depth++;
216
217         prs_align(ps);
218         
219         smb_io_pol_hnd("", &(r_q->pol), ps, depth);
220         smb_io_unihdr ("", &(r_q->hdr_class), ps, depth);
221         smb_io_unistr2("", &(r_q->uni_class), r_q->hdr_class.buffer, ps, depth);
222
223         prs_align(ps);
224 }
225
226
227 /*******************************************************************
228 reads or writes a structure.
229 ********************************************************************/
230 void reg_io_r_query_key(char *desc,  REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth)
231 {
232         if (r_r == NULL) return;
233
234         prs_debug(ps, depth, desc, "reg_io_r_query_key");
235         depth++;
236
237         prs_align(ps);
238         
239         smb_io_unihdr ("", &(r_r->hdr_class), ps, depth);
240         smb_io_unistr2("", &(r_r->uni_class), r_r->hdr_class.buffer, ps, depth);
241
242         prs_align(ps);
243
244         prs_uint32("num_subkeys   ", ps, depth, &(r_r->num_subkeys   ));
245         prs_uint32("max_subkeylen ", ps, depth, &(r_r->max_subkeylen ));
246         prs_uint32("mak_subkeysize", ps, depth, &(r_r->max_subkeysize));
247         prs_uint32("num_values    ", ps, depth, &(r_r->num_values    ));
248         prs_uint32("max_valnamelen", ps, depth, &(r_r->max_valnamelen));
249         prs_uint32("max_valbufsize", ps, depth, &(r_r->max_valbufsize));
250         prs_uint32("sec_desc      ", ps, depth, &(r_r->sec_desc      ));
251         smb_io_time("mod_time     ", &(r_r->mod_time), ps, depth);
252         
253         prs_uint32("status", ps, depth, &(r_r->status));
254 }
255
256
257 /*******************************************************************
258 creates a structure.
259 ********************************************************************/
260 void make_reg_q_unk_1a(REG_Q_UNK_1A *q_o, POLICY_HND *hnd)
261 {
262         memcpy(&(q_o->pol), hnd, sizeof(q_o->pol));
263 }
264
265 /*******************************************************************
266 reads or writes a structure.
267 ********************************************************************/
268 void reg_io_q_unk_1a(char *desc,  REG_Q_UNK_1A *r_q, prs_struct *ps, int depth)
269 {
270         if (r_q == NULL) return;
271
272         prs_debug(ps, depth, desc, "reg_io_q_unk_1a");
273         depth++;
274
275         prs_align(ps);
276         
277         smb_io_pol_hnd("", &(r_q->pol), ps, depth);
278 }
279
280
281 /*******************************************************************
282 reads or writes a structure.
283 ********************************************************************/
284 void reg_io_r_unk_1a(char *desc,  REG_R_UNK_1A *r_r, prs_struct *ps, int depth)
285 {
286         if (r_r == NULL) return;
287
288         prs_debug(ps, depth, desc, "reg_io_r_unk_1a");
289         depth++;
290
291         prs_align(ps);
292         
293         prs_uint32("unknown", ps, depth, &(r_r->unknown));
294         prs_uint32("status" , ps, depth, &(r_r->status ));
295 }
296
297
298 /*******************************************************************
299 creates a structure.
300 ********************************************************************/
301 void make_reg_q_open_unk_4(REG_Q_OPEN_UNK_4 *q_o,
302                                 uint16 unknown_0, uint32 level)
303 {
304         q_o->ptr = 1;
305         q_o->unknown_0 = unknown_0;
306         q_o->unknown_1 = 0x0; /* random - changes */
307         q_o->level = level;
308 }
309
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
313 void reg_io_q_open_unk_4(char *desc,  REG_Q_OPEN_UNK_4 *r_q, prs_struct *ps, int depth)
314 {
315         if (r_q == NULL) return;
316
317         prs_debug(ps, depth, desc, "reg_io_q_open_unk_4");
318         depth++;
319
320         prs_align(ps);
321         
322         prs_uint32("ptr      ", ps, depth, &(r_q->ptr      ));
323         if (r_q->ptr != 0)
324         {
325                 prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0));
326                 prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
327                 prs_uint32("level    ", ps, depth, &(r_q->level    ));
328         }
329 }
330
331
332 /*******************************************************************
333 reads or writes a structure.
334 ********************************************************************/
335 void reg_io_r_open_unk_4(char *desc,  REG_R_OPEN_UNK_4 *r_r, prs_struct *ps, int depth)
336 {
337         if (r_r == NULL) return;
338
339         prs_debug(ps, depth, desc, "reg_io_r_open_unk_4");
340         depth++;
341
342         prs_align(ps);
343         
344         smb_io_pol_hnd("", &(r_r->pol), ps, depth);
345
346         prs_uint32("status", ps, depth, &(r_r->status));
347 }
348
349
350 /*******************************************************************
351 makes an REG_Q_CLOSE structure.
352 ********************************************************************/
353 void make_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
354 {
355         if (q_c == NULL || hnd == NULL) return;
356
357         DEBUG(5,("make_reg_q_close\n"));
358
359         memcpy(&(q_c->pol), hnd, sizeof(q_c->pol));
360 }
361
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
365 void reg_io_q_close(char *desc,  REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
366 {
367         if (q_u == NULL) return;
368
369         prs_debug(ps, depth, desc, "reg_io_q_unknown_1");
370         depth++;
371
372         prs_align(ps);
373
374         smb_io_pol_hnd("", &(q_u->pol), ps, depth); 
375         prs_align(ps);
376 }
377
378 /*******************************************************************
379 reads or writes a structure.
380 ********************************************************************/
381 void reg_io_r_close(char *desc,  REG_R_CLOSE *r_u, prs_struct *ps, int depth)
382 {
383         if (r_u == NULL) return;
384
385         prs_debug(ps, depth, desc, "reg_io_r_unknown_1");
386         depth++;
387
388         prs_align(ps);
389
390         smb_io_pol_hnd("", &(r_u->pol), ps, depth); 
391         prs_align(ps);
392
393         prs_uint32("status", ps, depth, &(r_u->status));
394 }
395
396 /*******************************************************************
397 makes a structure.
398 ********************************************************************/
399 void make_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol, 
400                                 uint32 buf_len, SEC_DESC_BUF *sec_buf)
401 {
402         if (q_i == NULL) return;
403
404         memcpy(&(q_i->pol), pol, sizeof(q_i->pol));
405
406         q_i->unknown = 0x7;
407
408         q_i->ptr = 1;
409         q_i->data = sec_buf;
410
411         make_buf_hdr(&(q_i->hdr_sec), buf_len, 0);
412         make_sec_desc_buf(q_i->data, buf_len, 0);
413 }
414
415 /*******************************************************************
416 reads or writes a structure.
417 ********************************************************************/
418 void reg_io_q_get_key_sec(char *desc,  REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
419 {
420         if (r_q == NULL) return;
421
422         prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
423         depth++;
424
425         prs_align(ps);
426         
427         smb_io_pol_hnd("", &(r_q->pol), ps, depth); 
428
429         prs_uint32("unknown", ps, depth, &(r_q->unknown));
430         prs_uint32("ptr    ", ps, depth, &(r_q->ptr    ));
431
432         if (r_q->ptr != 0)
433         {
434                 smb_io_hdrbuf  ("hdr_sec", &(r_q->hdr_sec), ps, depth);
435                 sec_io_desc_buf("data   ",   r_q->data    , ps, depth);
436
437                 prs_align(ps);
438         }
439 }
440
441 /*******************************************************************
442 makes a structure.
443 ********************************************************************/
444 void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol, 
445                                 uint32 buf_len, uint8 *buf,
446                                 uint32 status)
447 {
448         if (r_i == NULL) return;
449
450         r_i->ptr = 1;
451         make_buf_hdr(&(r_i->hdr_sec), buf_len, buf_len);
452         make_sec_desc_buf(r_i->data, buf_len, 1);
453
454         r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
455 }
456
457 /*******************************************************************
458 reads or writes a structure.
459 ********************************************************************/
460 void reg_io_r_get_key_sec(char *desc,  REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
461 {
462         if (r_q == NULL) return;
463
464         prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
465         depth++;
466
467         prs_align(ps);
468         
469         prs_uint32("ptr      ", ps, depth, &(r_q->ptr      ));
470
471         if (r_q->ptr != 0)
472         {
473                 smb_io_hdrbuf("", &(r_q->hdr_sec), ps, depth);
474                 sec_io_desc_buf("", r_q->data, ps, depth);
475
476                 prs_align(ps);
477         }
478
479         prs_uint32("status", ps, depth, &(r_q->status));
480 }
481
482
483 /*******************************************************************
484 makes a structure.
485 ********************************************************************/
486 void make_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char *product_type,
487                                 time_t unix_time, uint8 major, uint8 minor)
488 {
489         int len_type  = strlen(product_type);
490
491         if (q_i == NULL) return;
492
493         memcpy(&(q_i->pol), pol, sizeof(q_i->pol));
494
495         make_uni_hdr(&(q_i->hdr_type), len_type, len_type, 1);
496         make_unistr2(&(q_i->uni_type), product_type, len_type);
497
498         q_i->ptr1 = 1;
499         unix_to_nt_time(&(q_i->time), unix_time);
500         q_i->major_version1 = major;
501         q_i->minor_version1 = minor;
502         memset(q_i->pad1, 0, sizeof(q_i->pad1));
503
504         q_i->ptr2 = 1;
505         q_i->major_version2 = major;
506         q_i->minor_version2 = minor;
507         memset(q_i->pad2, 0, sizeof(q_i->pad2));
508
509         q_i->ptr3 = 1;
510         q_i->unknown = 0x00000000;
511 }
512
513 /*******************************************************************
514 reads or writes a structure.
515 ********************************************************************/
516 void reg_io_q_info(char *desc,  REG_Q_INFO *r_q, prs_struct *ps, int depth)
517 {
518         if (r_q == NULL) return;
519
520         prs_debug(ps, depth, desc, "reg_io_q_info");
521         depth++;
522
523         prs_align(ps);
524         
525         smb_io_pol_hnd("", &(r_q->pol), ps, depth); 
526         smb_io_unihdr ("", &(r_q->hdr_type), ps, depth);
527         smb_io_unistr2("", &(r_q->uni_type), r_q->hdr_type.buffer, ps, depth);
528
529         prs_align(ps);
530         
531         prs_uint32("ptr1", ps, depth, &(r_q->ptr1));
532
533         if (r_q->ptr1 != 0)
534         {
535                 smb_io_time("", &(r_q->time), ps, depth);
536                 prs_uint8 ("major_version1", ps, depth, &(r_q->major_version1));
537                 prs_uint8 ("minor_version1", ps, depth, &(r_q->minor_version1));
538                 prs_uint8s(False, "pad1", ps, depth, r_q->pad1, sizeof(r_q->pad1));
539         }
540
541         prs_uint32("ptr2", ps, depth, &(r_q->ptr2));
542
543         if (r_q->ptr2 != 0)
544         {
545                 prs_uint8 ("major_version2", ps, depth, &(r_q->major_version2));
546                 prs_uint8 ("minor_version2", ps, depth, &(r_q->minor_version2));
547                 prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2));
548         }
549
550         prs_uint32("ptr3", ps, depth, &(r_q->ptr3));
551
552         if (r_q->ptr3 != 0)
553         {
554                 prs_uint32("unknown", ps, depth, &(r_q->unknown));
555         }
556 }
557
558
559 /*******************************************************************
560 creates a structure.
561 ********************************************************************/
562 void make_reg_r_info(REG_R_INFO *r_r,
563                                 uint32 level, char *os_type,
564                                 uint32 unknown_0, uint32 unknown_1,
565                                 uint32 status)
566 {
567         uint8 buf[512];
568         int len = struni2((uint16*)buf, os_type);
569
570         r_r->ptr1 = 1;
571         r_r->level = level;
572
573         r_r->ptr_type = 1;
574         make_buffer2(&(r_r->uni_type), buf, len*2);
575
576         r_r->ptr2 = 1;
577         r_r->unknown_0 = unknown_0;
578
579         r_r->ptr3 = 1;
580         r_r->unknown_1 = unknown_1;
581
582         r_r->status = status;
583 }
584
585 /*******************************************************************
586 reads or writes a structure.
587 ********************************************************************/
588 void reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
589 {
590         if (r_r == NULL) return;
591
592         prs_debug(ps, depth, desc, "reg_io_r_info");
593         depth++;
594
595         prs_align(ps);
596         
597         prs_uint32("ptr1", ps, depth, &(r_r->ptr1));
598
599         if (r_r->ptr1 != 0)
600         {
601                 prs_uint32("level", ps, depth, &(r_r->level));
602                 prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type));
603
604                 smb_io_buffer2("uni_type", &(r_r->uni_type), r_r->ptr_type, ps, depth);
605
606                 prs_uint32("ptr2", ps, depth, &(r_r->ptr2));
607
608                 if (r_r->ptr2 != 0)
609                 {
610                         prs_uint32("unknown_0", ps, depth, &(r_r->unknown_0));
611                 }
612
613                 prs_uint32("ptr3", ps, depth, &(r_r->ptr3));
614
615                 if (r_r->ptr3 != 0)
616                 {
617                         prs_uint32("unknown_1", ps, depth, &(r_r->unknown_1));
618                 }
619
620         }
621         prs_uint32("status", ps, depth, &(r_r->status));
622 }
623
624 /*******************************************************************
625 makes a structure.
626 ********************************************************************/
627 void make_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
628                                 uint32 val_idx, uint32 max_val_len,
629                                 uint32 max_buf_len)
630 {
631         if (q_i == NULL) return;
632
633         ZERO_STRUCTP(q_i);
634
635         memcpy(&(q_i->pol), pol, sizeof(q_i->pol));
636
637         q_i->val_index = val_idx;
638         make_uni_hdr(&q_i->hdr_name, max_val_len, 0, 1);
639         q_i->uni_name.uni_max_len = max_val_len;
640         
641         q_i->ptr_type = 1;
642         q_i->type = 0x0;
643
644         q_i->ptr_value = 1;
645         q_i->buf_value.buf_max_len = max_buf_len;
646
647         q_i->ptr1 = 1;
648         q_i->len_value1 = max_buf_len;
649
650         q_i->ptr2 = 1;
651         q_i->len_value2 = 0;
652 }
653
654 /*******************************************************************
655 reads or writes a structure.
656 ********************************************************************/
657 void reg_io_q_enum_val(char *desc,  REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth)
658 {
659         if (q_q == NULL) return;
660
661         prs_debug(ps, depth, desc, "reg_io_q_enum_val");
662         depth++;
663
664         prs_align(ps);
665         
666         smb_io_pol_hnd("", &(q_q->pol), ps, depth); 
667         
668         prs_uint32("val_index", ps, depth, &(q_q->val_index));
669         smb_io_unihdr ("hdr_name", &(q_q->hdr_name), ps, depth);
670         smb_io_unistr2("uni_name", &(q_q->uni_name), q_q->hdr_name.buffer, ps, depth);
671         prs_align(ps);
672
673         prs_uint32("ptr_type", ps, depth, &(q_q->ptr_type));
674
675         if (q_q->ptr_type != 0)
676         {
677                 prs_uint32("type", ps, depth, &(q_q->type));
678         }
679
680         prs_uint32("ptr_value", ps, depth, &(q_q->ptr_value));
681         smb_io_buffer2("buf_value", &(q_q->buf_value), q_q->ptr_value, ps, depth);
682         prs_align(ps);
683
684         prs_uint32("ptr1", ps, depth, &(q_q->ptr1));
685         if (q_q->ptr1 != 0)
686         {
687                 prs_uint32("len_value1", ps, depth, &(q_q->len_value1));
688         }
689         prs_uint32("ptr2", ps, depth, &(q_q->ptr2));
690         if (q_q->ptr2 != 0)
691         {
692                 prs_uint32("len_value2", ps, depth, &(q_q->len_value2));
693         }
694 }
695
696 /*******************************************************************
697 reads or writes a structure.
698 ********************************************************************/
699 void reg_io_r_enum_val(char *desc,  REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth)
700 {
701         if (r_q == NULL) return;
702
703         prs_debug(ps, depth, desc, "reg_io_r_enum_val");
704         depth++;
705
706         prs_align(ps);
707         
708         smb_io_unihdr ("hdr_name", &(r_q->hdr_name), ps, depth);
709         smb_io_unistr2("uni_name", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth);
710         prs_align(ps);
711
712         prs_uint32("ptr_type", ps, depth, &(r_q->ptr_type));
713
714         if (r_q->ptr_type != 0)
715         {
716                 prs_uint32("type", ps, depth, &(r_q->type));
717         }
718
719         prs_uint32("ptr_value", ps, depth, &(r_q->ptr_value));
720         smb_io_buffer2("buf_value", r_q->buf_value, r_q->ptr_value, ps, depth);
721         prs_align(ps);
722
723         prs_uint32("ptr1", ps, depth, &(r_q->ptr1));
724         if (r_q->ptr1 != 0)
725         {
726                 prs_uint32("len_value1", ps, depth, &(r_q->len_value1));
727         }
728
729         prs_uint32("ptr2", ps, depth, &(r_q->ptr2));
730         if (r_q->ptr2 != 0)
731         {
732                 prs_uint32("len_value2", ps, depth, &(r_q->len_value2));
733         }
734
735         prs_uint32("status", ps, depth, &(r_q->status));
736 }
737
738 /*******************************************************************
739 makes a structure.
740 ********************************************************************/
741 void make_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
742                                 char *val_name, uint32 type,
743                                 BUFFER3 *val)
744 {
745         int val_len = strlen(val_name) + 1;
746
747         if (q_i == NULL) return;
748
749         ZERO_STRUCTP(q_i);
750
751         memcpy(&(q_i->pol), pol, sizeof(q_i->pol));
752
753         make_uni_hdr(&q_i->hdr_name, val_len, val_len, 1);
754         make_unistr2(&(q_i->uni_name), val_name, val_len);
755         
756         q_i->type      = type;
757         q_i->buf_value = val;
758 }
759
760 /*******************************************************************
761 reads or writes a structure.
762 ********************************************************************/
763 void reg_io_q_create_val(char *desc,  REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth)
764 {
765         if (q_q == NULL) return;
766
767         prs_debug(ps, depth, desc, "reg_io_q_create_val");
768         depth++;
769
770         prs_align(ps);
771         
772         smb_io_pol_hnd("", &(q_q->pol), ps, depth); 
773         
774         smb_io_unihdr ("hdr_name", &(q_q->hdr_name), ps, depth);
775         smb_io_unistr2("uni_name", &(q_q->uni_name), q_q->hdr_name.buffer, ps, depth);
776         prs_align(ps);
777
778         prs_uint32("type", ps, depth, &(q_q->type));
779         smb_io_buffer3("buf_value", q_q->buf_value, ps, depth);
780         prs_align(ps);
781 }
782
783 /*******************************************************************
784 reads or writes a structure.
785 ********************************************************************/
786 void reg_io_r_create_val(char *desc,  REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth)
787 {
788         if (r_q == NULL) return;
789
790         prs_debug(ps, depth, desc, "reg_io_r_create_val");
791         depth++;
792
793         prs_align(ps);
794         
795         prs_uint32("status", ps, depth, &(r_q->status));
796 }
797
798 /*******************************************************************
799 makes a structure.
800 ********************************************************************/
801 void make_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx)
802 {
803         if (q_i == NULL) return;
804
805         memcpy(&(q_i->pol), pol, sizeof(q_i->pol));
806
807         q_i->key_index = key_idx;
808         q_i->key_name_len = 0;
809         q_i->unknown_1 = 0x0414;
810
811         q_i->ptr1 = 1;
812         q_i->unknown_2 = 0x0000020A;
813         memset(q_i->pad1, 0, sizeof(q_i->pad1));
814
815         q_i->ptr2 = 1;
816         memset(q_i->pad2, 0, sizeof(q_i->pad2));
817
818         q_i->ptr3 = 1;
819         unix_to_nt_time(&q_i->time, 0);            /* current time? */
820 }
821
822 /*******************************************************************
823 reads or writes a structure.
824 ********************************************************************/
825 void reg_io_q_enum_key(char *desc,  REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth)
826 {
827         if (q_q == NULL) return;
828
829         prs_debug(ps, depth, desc, "reg_io_q_enum_key");
830         depth++;
831
832         prs_align(ps);
833         
834         smb_io_pol_hnd("", &(q_q->pol), ps, depth); 
835         
836         prs_uint32("key_index", ps, depth, &(q_q->key_index));
837         prs_uint16("key_name_len", ps, depth, &(q_q->key_name_len));
838         prs_uint16("unknown_1", ps, depth, &(q_q->unknown_1));
839
840         prs_uint32("ptr1", ps, depth, &(q_q->ptr1));
841
842         if (q_q->ptr1 != 0)
843         {
844                 prs_uint32("unknown_2", ps, depth, &(q_q->unknown_2));
845                 prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1));
846         }
847
848         prs_uint32("ptr2", ps, depth, &(q_q->ptr2));
849
850         if (q_q->ptr2 != 0)
851         {
852                 prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2));
853         }
854
855         prs_uint32("ptr3", ps, depth, &(q_q->ptr3));
856
857         if (q_q->ptr3 != 0)
858         {
859                 smb_io_time("", &(q_q->time), ps, depth);
860         }
861 }
862
863 /*******************************************************************
864 reads or writes a structure.
865 ********************************************************************/
866 void reg_io_r_enum_key(char *desc,  REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth)
867 {
868         if (r_q == NULL) return;
869
870         prs_debug(ps, depth, desc, "reg_io_r_enum_key");
871         depth++;
872
873         prs_align(ps);
874         
875         prs_uint16("key_name_len", ps, depth, &(r_q->key_name_len));
876         prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
877
878         prs_uint32("ptr1", ps, depth, &(r_q->ptr1));
879
880         if (r_q->ptr1 != 0)
881         {
882                 prs_uint32("unknown_2", ps, depth, &(r_q->unknown_2));
883                 prs_uint32("unknown_3", ps, depth, &(r_q->unknown_3));
884                 smb_io_unistr3("key_name", &(r_q->key_name), ps, depth);
885                 prs_align(ps);
886         }
887
888         prs_uint32("ptr2", ps, depth, &(r_q->ptr2));
889
890         if (r_q->ptr2 != 0)
891         {
892                 prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2));
893         }
894
895         prs_uint32("ptr3", ps, depth, &(r_q->ptr3));
896
897         if (r_q->ptr3 != 0)
898         {
899                 smb_io_time("", &(r_q->time), ps, depth);
900         }
901
902         prs_uint32("status", ps, depth, &(r_q->status));
903 }
904
905
906 /*******************************************************************
907 makes a structure.
908 ********************************************************************/
909 void make_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
910                                 char *key_name, uint32 unk)
911 {
912         int len_name = strlen(key_name)+1;
913
914         if (r_q == NULL) return;
915
916         memcpy(&(r_q->pol), pol, sizeof(r_q->pol));
917
918         make_uni_hdr(&(r_q->hdr_name), len_name, len_name, 1);
919         make_unistr2(&(r_q->uni_name), key_name, len_name);
920
921         r_q->unknown_0 = 0x00000000;
922         r_q->unknown_1 = unk;
923 }
924
925 /*******************************************************************
926 reads or writes a structure.
927 ********************************************************************/
928 void reg_io_q_open_entry(char *desc,  REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
929 {
930         if (r_q == NULL) return;
931
932         prs_debug(ps, depth, desc, "reg_io_q_entry");
933         depth++;
934
935         prs_align(ps);
936         
937         smb_io_pol_hnd("", &(r_q->pol), ps, depth);
938         smb_io_unihdr ("", &(r_q->hdr_name), ps, depth);
939         smb_io_unistr2("", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth);
940
941         prs_align(ps);
942         
943         prs_uint32("unknown_0", ps, depth, &(r_q->unknown_0));
944         prs_uint32("unknown_1", ps, depth, &(r_q->unknown_1));
945 }
946
947
948 /*******************************************************************
949 creates a structure.
950 ********************************************************************/
951 void make_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
952                                 POLICY_HND *pol, uint32 status)
953 {
954         if (r_r == NULL) return;
955
956         memcpy(&(r_r->pol), pol, sizeof(r_r->pol));
957         r_r->status = status;
958 }
959
960 /*******************************************************************
961 reads or writes a structure.
962 ********************************************************************/
963 void reg_io_r_open_entry(char *desc,  REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
964 {
965         if (r_r == NULL) return;
966
967         prs_debug(ps, depth, desc, "reg_io_r_open_entry");
968         depth++;
969
970         prs_align(ps);
971         
972         smb_io_pol_hnd("", &(r_r->pol), ps, depth);
973
974         prs_uint32("status", ps, depth, &(r_r->status));
975 }
976