This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[kai/samba-autobuild/.git] / source / rpc_parse / parse_reg.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  Copyright (C) Marc Jacobsen                     1999.
8  *  Copyright (C) Simo Sorce                        2000.
9  *  
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *  
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *  
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24
25 #include "includes.h"
26
27 /*******************************************************************
28  Inits a structure.
29 ********************************************************************/
30
31 void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o,
32                                 uint16 unknown_0, uint32 level)
33 {
34         q_o->ptr = 1;
35         q_o->unknown_0 = unknown_0;
36         q_o->unknown_1 = 0x0; /* random - changes */
37         q_o->level = level;
38 }
39
40 /*******************************************************************
41 reads or writes a structure.
42 ********************************************************************/
43
44 BOOL reg_io_q_open_hkcr(char *desc,  REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth)
45 {
46         if (r_q == NULL)
47                 return False;
48
49         prs_debug(ps, depth, desc, "reg_io_q_open_hkcr");
50         depth++;
51
52         if(!prs_align(ps))
53                 return False;
54
55         if(!prs_uint32("ptr      ", ps, depth, &r_q->ptr))
56                 return False;
57
58         if (r_q->ptr != 0) {
59                 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0))
60                         return False;
61                 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
62                         return False;
63                 if(!prs_uint32("level    ", ps, depth, &r_q->level))
64                         return False;
65         }
66
67         return True;
68 }
69
70
71 /*******************************************************************
72 reads or writes a structure.
73 ********************************************************************/
74
75 BOOL reg_io_r_open_hkcr(char *desc,  REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth)
76 {
77         if (r_r == NULL)
78                 return False;
79
80         prs_debug(ps, depth, desc, "reg_io_r_open_hkcr");
81         depth++;
82
83         if(!prs_align(ps))
84                 return False;
85         
86         if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
87                 return False;
88
89         if(!prs_ntstatus("status", ps, depth, &r_r->status))
90                 return False;
91
92         return True;
93 }
94
95 /*******************************************************************
96  Inits a structure.
97 ********************************************************************/
98
99 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o,
100                           uint16 unknown_0, uint32 access_mask)
101 {
102         q_o->ptr = 1;
103         q_o->unknown_0 = unknown_0;
104         q_o->unknown_1 = 0x0;   /* random - changes */
105         q_o->access_mask = access_mask;
106
107 }
108
109 /*******************************************************************
110 reads or writes a structure.
111 ********************************************************************/
112 BOOL reg_io_q_open_hklm(char *desc, REG_Q_OPEN_HKLM * r_q, prs_struct *ps,
113                         int depth)
114 {
115         if (r_q == NULL)
116                 return False;
117
118         prs_debug(ps, depth, desc, "reg_io_q_open_hklm");
119         depth++;
120
121         if (!prs_align(ps))
122                 return False;
123
124         if (!prs_uint32("ptr      ", ps, depth, &(r_q->ptr)))
125                 return False;
126         if (r_q->ptr != 0)
127         {
128                 if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0)))
129                 return False;
130                 if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)))
131                 return False;
132                 if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask)))
133                 return False;
134         }
135
136         return True;
137 }
138
139
140 /*******************************************************************
141 reads or writes a structure.
142 ********************************************************************/
143 BOOL reg_io_r_open_hklm(char *desc, REG_R_OPEN_HKLM * r_r, prs_struct *ps,
144                         int depth)
145 {
146         if (r_r == NULL)
147                 return False;
148
149         prs_debug(ps, depth, desc, "reg_io_r_open_hklm");
150         depth++;
151
152         if (!prs_align(ps))
153                 return False;
154
155         if (!smb_io_pol_hnd("", &r_r->pol, ps, depth))
156                 return False;
157
158         if (!prs_ntstatus("status", ps, depth, &r_r->status))
159                 return False;
160
161         return True;
162 }
163
164
165 /*******************************************************************
166  Inits a structure.
167 ********************************************************************/
168
169 void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol)
170 {
171         memcpy(&q_u->pol, pol, sizeof(q_u->pol));
172 }
173
174 /*******************************************************************
175 reads or writes a structure.
176 ********************************************************************/
177
178 BOOL reg_io_q_flush_key(char *desc,  REG_Q_FLUSH_KEY *r_q, prs_struct *ps, int depth)
179 {
180         if (r_q == NULL)
181                 return False;
182
183         prs_debug(ps, depth, desc, "reg_io_q_flush_key");
184         depth++;
185
186         if(!prs_align(ps))
187                 return False;
188         
189         if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
190                 return False;
191
192         return True;
193 }
194
195 /*******************************************************************
196 reads or writes a structure.
197 ********************************************************************/
198
199 BOOL reg_io_r_flush_key(char *desc,  REG_R_FLUSH_KEY *r_r, prs_struct *ps, int depth)
200 {
201         if (r_r == NULL)
202                 return False;
203
204         prs_debug(ps, depth, desc, "reg_io_r_flush_key");
205         depth++;
206
207         if(!prs_align(ps))
208                 return False;
209         
210         if(!prs_ntstatus("status", ps, depth, &r_r->status))
211                 return False;
212
213         return True;
214 }
215
216 /*******************************************************************
217 reads or writes SEC_DESC_BUF and SEC_DATA structures.
218 ********************************************************************/
219
220 static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DESC_BUF *data, prs_struct *ps, int depth)
221 {
222         if (ptr != 0) {
223                 uint32 hdr_offset;
224                 uint32 old_offset;
225                 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset))
226                         return False;
227
228                 old_offset = prs_offset(ps);
229
230                 if (ptr3 != NULL) {
231                         if(!prs_uint32("ptr3", ps, depth, ptr3))
232                                 return False;
233                 }
234
235                 if (ptr3 == NULL || *ptr3 != 0) {
236                         if(!sec_io_desc_buf("data   ", &data, ps, depth)) /* JRA - this line is probably wrong... */
237                                 return False;
238                 }
239
240                 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset,
241                                    data->max_len, data->len))
242                                 return False;
243                 if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3)))
244                         return False;
245
246                 if(!prs_align(ps))
247                         return False;
248         }
249
250         return True;
251 }
252
253 /*******************************************************************
254  Inits a structure.
255 ********************************************************************/
256
257 void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd,
258                                 char *name, char *class, SEC_ACCESS *sam_access,
259                                 SEC_DESC_BUF *sec_buf)
260 {
261         int len_name  = name  != NULL ? strlen(name ) + 1: 0;
262         int len_class = class != NULL ? strlen(class) + 1: 0;
263
264         ZERO_STRUCTP(q_c);
265
266         memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
267
268         init_uni_hdr(&q_c->hdr_name, len_name);
269         init_unistr2(&q_c->uni_name, name, len_name);
270
271         init_uni_hdr(&q_c->hdr_class, len_class);
272         init_unistr2(&q_c->uni_class, class, len_class);
273
274         q_c->reserved = 0x00000000;
275         memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access));
276
277         q_c->ptr1 = 1;
278         q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
279
280         q_c->data = sec_buf;
281         q_c->ptr2 = 1;
282         init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len);
283         q_c->ptr3 = 1;
284         q_c->unknown_2 = 0x00000000;
285 }
286
287 /*******************************************************************
288 reads or writes a structure.
289 ********************************************************************/
290
291 BOOL reg_io_q_create_key(char *desc,  REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth)
292 {
293         if (r_q == NULL)
294                 return False;
295
296         prs_debug(ps, depth, desc, "reg_io_q_create_key");
297         depth++;
298
299         if(!prs_align(ps))
300                 return False;
301         
302         if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
303                 return False;
304
305         if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
306                 return False;
307         if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
308                 return False;
309         if(!prs_align(ps))
310                 return False;
311
312         if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
313                 return False;
314         if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
315                 return False;
316         if(!prs_align(ps))
317                 return False;
318
319         if(!prs_uint32("reserved", ps, depth, &r_q->reserved))
320                 return False;
321         if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth))
322                 return False;
323
324         if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
325                 return False;
326
327         if (r_q->ptr1 != 0) {
328                 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
329                         return False;
330         }
331
332         if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
333                 return False;
334         if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth))
335                 return False;
336
337         if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
338                 return False;
339
340         return True;
341 }
342
343 /*******************************************************************
344 reads or writes a structure.
345 ********************************************************************/
346
347 BOOL reg_io_r_create_key(char *desc,  REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth)
348 {
349         if (r_r == NULL)
350                 return False;
351
352         prs_debug(ps, depth, desc, "reg_io_r_create_key");
353         depth++;
354
355         if(!prs_align(ps))
356                 return False;
357         
358         if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth))
359                 return False;
360         if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
361                 return False;
362
363         if(!prs_ntstatus("status", ps, depth, &r_r->status))
364                 return False;
365
366         return True;
367 }
368
369
370 /*******************************************************************
371  Inits a structure.
372 ********************************************************************/
373
374 void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd,
375                                 char *name)
376 {
377         int len_name  = name  != NULL ? strlen(name ) + 1: 0;
378         ZERO_STRUCTP(q_c);
379
380         memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
381
382         init_uni_hdr(&q_c->hdr_name, len_name);
383         init_unistr2(&q_c->uni_name, name, len_name);
384 }
385
386 /*******************************************************************
387 reads or writes a structure.
388 ********************************************************************/
389
390 BOOL reg_io_q_delete_val(char *desc,  REG_Q_DELETE_VALUE *r_q, prs_struct *ps, int depth)
391 {
392         if (r_q == NULL)
393                 return False;
394
395         prs_debug(ps, depth, desc, "reg_io_q_delete_val");
396         depth++;
397
398         if(!prs_align(ps))
399                 return False;
400         
401         if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
402                 return False;
403
404         if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
405                 return False;
406         if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
407                 return False;
408         if(!prs_align(ps))
409                 return False;
410
411         return True;
412 }
413
414
415 /*******************************************************************
416 reads or writes a structure.
417 ********************************************************************/
418
419 BOOL reg_io_r_delete_val(char *desc,  REG_R_DELETE_VALUE *r_r, prs_struct *ps, int depth)
420 {
421         if (r_r == NULL)
422                 return False;
423
424         prs_debug(ps, depth, desc, "reg_io_r_delete_val");
425         depth++;
426
427         if(!prs_align(ps))
428                 return False;
429         
430         if(!prs_ntstatus("status", ps, depth, &r_r->status))
431                 return False;
432
433         return True;
434 }
435
436 /*******************************************************************
437  Inits a structure.
438 ********************************************************************/
439
440 void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
441                                 char *name)
442 {
443         int len_name  = name  != NULL ? strlen(name ) + 1: 0;
444         ZERO_STRUCTP(q_c);
445
446         memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
447
448         init_uni_hdr(&q_c->hdr_name, len_name);
449         init_unistr2(&q_c->uni_name, name, len_name);
450 }
451
452 /*******************************************************************
453 reads or writes a structure.
454 ********************************************************************/
455
456 BOOL reg_io_q_delete_key(char *desc,  REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth)
457 {
458         if (r_q == NULL)
459                 return False;
460
461         prs_debug(ps, depth, desc, "reg_io_q_delete_key");
462         depth++;
463
464         if(!prs_align(ps))
465                 return False;
466         
467         if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
468                 return False;
469
470         if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
471                 return False;
472         if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
473                 return False;
474         if(!prs_align(ps))
475                 return False;
476
477         return True;
478 }
479
480 /*******************************************************************
481 reads or writes a structure.
482 ********************************************************************/
483
484 BOOL reg_io_r_delete_key(char *desc,  REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth)
485 {
486         if (r_r == NULL)
487                 return False;
488
489         prs_debug(ps, depth, desc, "reg_io_r_delete_key");
490         depth++;
491
492         if(!prs_align(ps))
493                 return False;
494         
495         if(!prs_ntstatus("status", ps, depth, &r_r->status))
496                 return False;
497
498         return True;
499 }
500
501 /*******************************************************************
502  Inits a structure.
503 ********************************************************************/
504
505 void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd,
506                                 uint32 max_class_len)
507 {
508         ZERO_STRUCTP(q_o);
509
510         memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
511         init_uni_hdr(&q_o->hdr_class, max_class_len);
512         q_o->uni_class.uni_max_len = max_class_len;
513 }
514
515 /*******************************************************************
516 reads or writes a structure.
517 ********************************************************************/
518
519 BOOL reg_io_q_query_key(char *desc,  REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth)
520 {
521         if (r_q == NULL)
522                 return False;
523
524         prs_debug(ps, depth, desc, "reg_io_q_query_key");
525         depth++;
526
527         if(!prs_align(ps))
528                 return False;
529         
530         if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
531                 return False;
532         if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
533                 return False;
534         if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
535                 return False;
536
537         if(!prs_align(ps))
538                 return False;
539
540         return True;
541 }
542
543
544 /*******************************************************************
545 reads or writes a structure.
546 ********************************************************************/
547
548 BOOL reg_io_r_query_key(char *desc,  REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth)
549 {
550         if (r_r == NULL)
551                 return False;
552
553         prs_debug(ps, depth, desc, "reg_io_r_query_key");
554         depth++;
555
556         if(!prs_align(ps))
557                 return False;
558         
559         if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth))
560                 return False;
561         if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth))
562                 return False;
563
564         if(!prs_align(ps))
565                 return False;
566
567         if(!prs_uint32("num_subkeys   ", ps, depth, &r_r->num_subkeys))
568                 return False;
569         if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen))
570                 return False;
571         if(!prs_uint32("mak_subkeysize", ps, depth, &r_r->max_subkeysize))
572                 return False;
573         if(!prs_uint32("num_values    ", ps, depth, &r_r->num_values))
574                 return False;
575         if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen))
576                 return False;
577         if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize))
578                 return False;
579         if(!prs_uint32("sec_desc      ", ps, depth, &r_r->sec_desc))
580                 return False;
581         if(!smb_io_time("mod_time     ", &r_r->mod_time, ps, depth))
582                 return False;
583         
584         if(!prs_ntstatus("status", ps, depth, &r_r->status))
585                 return False;
586
587         return True;
588 }
589
590 /*******************************************************************
591  Inits a structure.
592 ********************************************************************/
593
594 void init_reg_q_unk_1a(REG_Q_UNK_1A *q_o, POLICY_HND *hnd)
595 {
596         memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
597 }
598
599 /*******************************************************************
600 reads or writes a structure.
601 ********************************************************************/
602
603 BOOL reg_io_q_unk_1a(char *desc,  REG_Q_UNK_1A *r_q, prs_struct *ps, int depth)
604 {
605         if (r_q == NULL)
606                 return False;
607
608         prs_debug(ps, depth, desc, "reg_io_q_unk_1a");
609         depth++;
610
611         if(!prs_align(ps))
612                 return False;
613         
614         if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
615                 return False;
616
617         return True;
618 }
619
620 /*******************************************************************
621 reads or writes a structure.
622 ********************************************************************/
623
624 BOOL reg_io_r_unk_1a(char *desc,  REG_R_UNK_1A *r_r, prs_struct *ps, int depth)
625 {
626         if (r_r == NULL)
627                 return False;
628
629         prs_debug(ps, depth, desc, "reg_io_r_unk_1a");
630         depth++;
631
632         if(!prs_align(ps))
633                 return False;
634         
635         if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
636                 return False;
637         if(!prs_ntstatus("status" , ps, depth, &r_r->status))
638                 return False;
639
640         return True;
641 }
642
643 /*******************************************************************
644  Inits a structure.
645 ********************************************************************/
646
647 void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o,
648                                 uint16 unknown_0, uint32 level)
649 {
650         q_o->ptr = 1;
651         q_o->unknown_0 = unknown_0;
652         q_o->unknown_1 = 0x0; /* random - changes */
653         q_o->level = level;
654 }
655
656 /*******************************************************************
657 reads or writes a structure.
658 ********************************************************************/
659
660 BOOL reg_io_q_open_hku(char *desc,  REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth)
661 {
662         if (r_q == NULL)
663                 return False;
664
665         prs_debug(ps, depth, desc, "reg_io_q_open_hku");
666         depth++;
667
668         if(!prs_align(ps))
669                 return False;
670         
671         if(!prs_uint32("ptr      ", ps, depth, &r_q->ptr))
672                 return False;
673         if (r_q->ptr != 0) {
674                 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0))
675                         return False;
676                 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
677                         return False;
678                 if(!prs_uint32("level    ", ps, depth, &r_q->level))
679                         return False;
680         }
681
682         return True;
683 }
684
685 /*******************************************************************
686 reads or writes a structure.
687 ********************************************************************/
688
689 BOOL reg_io_r_open_hku(char *desc,  REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth)
690 {
691         if (r_r == NULL)
692                 return False;
693
694         prs_debug(ps, depth, desc, "reg_io_r_open_hku");
695         depth++;
696
697         if(!prs_align(ps))
698                 return False;
699         
700         if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
701                 return False;
702
703         if(!prs_ntstatus("status", ps, depth, &r_r->status))
704                 return False;
705
706         return True;
707 }
708
709 /*******************************************************************
710  Inits an REG_Q_CLOSE structure.
711 ********************************************************************/
712
713 void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
714 {
715         DEBUG(5,("init_reg_q_close\n"));
716
717         memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
718 }
719
720 /*******************************************************************
721 reads or writes a structure.
722 ********************************************************************/
723
724 BOOL reg_io_q_close(char *desc,  REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
725 {
726         if (q_u == NULL)
727                 return False;
728
729         prs_debug(ps, depth, desc, "reg_io_q_unknown_1");
730         depth++;
731
732         if(!prs_align(ps))
733                 return False;
734
735         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
736                 return False;
737         if(!prs_align(ps))
738                 return False;
739
740         return True;
741 }
742
743 /*******************************************************************
744 reads or writes a structure.
745 ********************************************************************/
746
747 BOOL reg_io_r_close(char *desc,  REG_R_CLOSE *r_u, prs_struct *ps, int depth)
748 {
749         if (r_u == NULL)
750                 return False;
751
752         prs_debug(ps, depth, desc, "reg_io_r_unknown_1");
753         depth++;
754
755         if(!prs_align(ps))
756                 return False;
757
758         if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
759                 return False;
760         if(!prs_align(ps))
761                 return False;
762
763         if(!prs_ntstatus("status", ps, depth, &r_u->status))
764                 return False;
765
766         return True;
767 }
768
769 /*******************************************************************
770 makes a structure.
771 ********************************************************************/
772
773 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf)
774 {
775         memcpy(&q_i->pol, pol, sizeof(q_i->pol));
776
777         q_i->sec_info = DACL_SECURITY_INFORMATION;
778
779         q_i->ptr = 1;
780         init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len);
781         q_i->data = sec_desc_buf;
782 }
783
784 /*******************************************************************
785 reads or writes a structure.
786 ********************************************************************/
787
788 BOOL reg_io_q_set_key_sec(char *desc,  REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
789 {
790         if (r_q == NULL)
791                 return False;
792
793         prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
794         depth++;
795
796         if(!prs_align(ps))
797                 return False;
798         
799         if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
800                 return False;
801
802         if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
803                 return False;
804         if(!prs_uint32("ptr    ", ps, depth, &r_q->ptr))
805                 return False;
806
807         if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
808                 return False;
809
810         return True;
811 }
812
813 /*******************************************************************
814 reads or writes a structure.
815 ********************************************************************/
816
817 BOOL reg_io_r_set_key_sec(char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
818 {
819         if (r_q == NULL)
820                 return False;
821
822         prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
823         depth++;
824
825         if(!prs_align(ps))
826                 return False;
827         
828         if(!prs_ntstatus("status", ps, depth, &r_q->status))
829                 return False;
830
831         return True;
832 }
833
834
835 /*******************************************************************
836 makes a structure.
837 ********************************************************************/
838
839 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol, 
840                                 uint32 sec_buf_size, SEC_DESC_BUF *psdb)
841 {
842         memcpy(&q_i->pol, pol, sizeof(q_i->pol));
843
844         q_i->sec_info = OWNER_SECURITY_INFORMATION |
845                         GROUP_SECURITY_INFORMATION |
846                         DACL_SECURITY_INFORMATION;
847
848         q_i->ptr = psdb != NULL ? 1 : 0;
849         q_i->data = psdb;
850
851         init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0);
852 }
853
854 /*******************************************************************
855 reads or writes a structure.
856 ********************************************************************/
857
858 BOOL reg_io_q_get_key_sec(char *desc,  REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
859 {
860         if (r_q == NULL)
861                 return False;
862
863         prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
864         depth++;
865
866         if(!prs_align(ps))
867                 return False;
868         
869         if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
870                 return False;
871
872         if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
873                 return False;
874         if(!prs_uint32("ptr     ", ps, depth, &r_q->ptr))
875                 return False;
876
877         if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
878                 return False;
879
880         return True;
881 }
882
883 #if 0
884 /*******************************************************************
885 makes a structure.
886 ********************************************************************/
887  void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol, 
888                                 uint32 buf_len, uint8 *buf,
889                                 NTSTATUS status)
890 {
891         r_i->ptr = 1;
892         init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len);
893         init_sec_desc_buf(r_i->data, buf_len, 1);
894
895         r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
896 }
897 #endif 
898
899 /*******************************************************************
900 reads or writes a structure.
901 ********************************************************************/
902
903 BOOL reg_io_r_get_key_sec(char *desc,  REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
904 {
905         if (r_q == NULL)
906                 return False;
907
908         prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
909         depth++;
910
911         if(!prs_align(ps))
912                 return False;
913         
914         if(!prs_uint32("ptr      ", ps, depth, &r_q->ptr))
915                 return False;
916
917         if (r_q->ptr != 0) {
918                 if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth))
919                         return False;
920                 if(!sec_io_desc_buf("", &r_q->data, ps, depth))
921                         return False;
922                 if(!prs_align(ps))
923                         return False;
924         }
925
926         if(!prs_ntstatus("status", ps, depth, &r_q->status))
927                 return False;
928
929         return True;
930 }
931
932 /*******************************************************************
933 makes a structure.
934 ********************************************************************/
935
936 BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name)
937 {
938         int len_type = val_name != NULL ? strlen(val_name) + 1 : 0;
939
940         if (q_i == NULL)
941                 return False;
942
943         q_i->pol = *pol;
944
945         init_uni_hdr(&(q_i->hdr_type), len_type);
946         init_unistr2(&(q_i->uni_type), val_name, len_type);
947
948         q_i->ptr_reserved = 1;
949         q_i->ptr_buf = 1;
950
951         q_i->ptr_bufsize = 1;
952         q_i->bufsize = 0;
953         q_i->buf_unk = 0;
954
955         q_i->unk1 = 0;
956         q_i->ptr_buflen = 1;
957         q_i->buflen = 0;
958
959         q_i->ptr_buflen2 = 1;
960         q_i->buflen2 = 0;
961
962         return True;
963 }
964
965 /*******************************************************************
966 reads or writes a structure.
967 ********************************************************************/
968
969 BOOL reg_io_q_info(char *desc,  REG_Q_INFO *r_q, prs_struct *ps, int depth)
970 {
971         if (r_q == NULL)
972                 return False;
973
974         prs_debug(ps, depth, desc, "reg_io_q_info");
975         depth++;
976
977         if(!prs_align(ps))
978                 return False;
979         
980         if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
981                 return False;
982         if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth))
983                 return False;
984         if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth))
985                 return False;
986
987         if(!prs_align(ps))
988                 return False;
989         
990         if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved)))
991                 return False;
992
993         if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf)))
994                 return False;
995
996         if(r_q->ptr_buf) {
997                 if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize)))
998                         return False;
999                 if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize)))
1000                         return False;
1001                 if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk)))
1002                         return False;
1003         }
1004
1005         if(!prs_uint32("unk1", ps, depth, &(r_q->unk1)))
1006                 return False;
1007
1008         if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen)))
1009                 return False;
1010         if(!prs_uint32("buflen", ps, depth, &(r_q->buflen)))
1011                 return False;
1012
1013         if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2)))
1014                 return False;
1015         if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2)))
1016                 return False;
1017
1018         return True;
1019 }
1020
1021 /*******************************************************************
1022  Inits a structure.
1023 ********************************************************************/
1024
1025 BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1026                      BUFFER2* buf, uint32 type, NTSTATUS status)
1027 {
1028   if(r_r == NULL)
1029     return False;
1030
1031   
1032   r_r->ptr_type = 1;
1033   r_r->type = type;
1034
1035   /* if include_keyval is not set, don't send the key value, just
1036      the buflen data. probably used by NT5 to allocate buffer space - SK */
1037   r_r->ptr_uni_val = include_keyval ? 1:0;
1038   r_r->uni_val = buf;
1039
1040   r_r->ptr_max_len = 1;
1041   r_r->buf_max_len = r_r->uni_val->buf_max_len;
1042
1043   r_r->ptr_len = 1;
1044   r_r->buf_len = r_r->uni_val->buf_len;
1045
1046   r_r->status = status;
1047
1048   return True;
1049   
1050 }
1051
1052 /*******************************************************************
1053 reads or writes a structure.
1054 ********************************************************************/
1055
1056 BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
1057 {
1058         if (r_r == NULL)
1059                 return False;
1060
1061         prs_debug(ps, depth, desc, "reg_io_r_info");
1062         depth++;
1063
1064         if(!prs_align(ps))
1065                 return False;
1066         
1067         if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type)))
1068                 return False;
1069
1070         if (r_r->ptr_type != 0) {
1071                 if(!prs_uint32("type", ps, depth, &r_r->type))
1072                         return False;
1073         }
1074
1075         if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val)))
1076                 return False;
1077
1078         if(r_r->ptr_uni_val != 0) {
1079                 if(!smb_io_buffer2("uni_val", r_r->uni_val, r_r->ptr_uni_val, ps, depth))
1080                         return False;
1081         }
1082
1083         if(!prs_align(ps))
1084                 return False;
1085
1086         if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len)))
1087                 return False;
1088
1089         if (r_r->ptr_max_len != 0) {
1090                 if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len)))
1091                 return False;
1092         }
1093
1094         if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len)))
1095                 return False;
1096         if (r_r->ptr_len != 0) {
1097                 if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len)))
1098                         return False;
1099         }
1100
1101         if(!prs_ntstatus("status", ps, depth, &r_r->status))
1102                 return False;
1103
1104         return True;
1105 }
1106
1107 /*******************************************************************
1108 makes a structure.
1109 ********************************************************************/
1110
1111 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
1112                                 uint32 val_idx, uint32 max_val_len,
1113                                 uint32 max_buf_len)
1114 {
1115         ZERO_STRUCTP(q_i);
1116
1117         memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1118
1119         q_i->val_index = val_idx;
1120         init_uni_hdr(&q_i->hdr_name, max_val_len);
1121         q_i->uni_name.uni_max_len = max_val_len;
1122         
1123         q_i->ptr_type = 1;
1124         q_i->type = 0x0;
1125
1126         q_i->ptr_value = 1;
1127         q_i->buf_value.buf_max_len = max_buf_len;
1128
1129         q_i->ptr1 = 1;
1130         q_i->len_value1 = max_buf_len;
1131
1132         q_i->ptr2 = 1;
1133         q_i->len_value2 = 0;
1134 }
1135
1136 /*******************************************************************
1137 reads or writes a structure.
1138 ********************************************************************/
1139
1140 BOOL reg_io_q_enum_val(char *desc,  REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth)
1141 {
1142         if (q_q == NULL)
1143                 return False;
1144
1145         prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1146         depth++;
1147
1148         if(!prs_align(ps))
1149                 return False;
1150         
1151         if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1152                 return False;
1153         
1154         if(!prs_uint32("val_index", ps, depth, &q_q->val_index))
1155                 return False;
1156         if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1157                 return False;
1158         if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1159                 return False;
1160         if(!prs_align(ps))
1161                 return False;
1162
1163         if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type))
1164                 return False;
1165
1166         if (q_q->ptr_type != 0) {
1167                 if(!prs_uint32("type", ps, depth, &q_q->type))
1168                         return False;
1169         }
1170
1171         if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value))
1172                 return False;
1173         if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth))
1174                 return False;
1175         if(!prs_align(ps))
1176                 return False;
1177
1178         if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1179                 return False;
1180         if (q_q->ptr1 != 0) {
1181                 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1))
1182                         return False;
1183         }
1184         if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1185                 return False;
1186         if (q_q->ptr2 != 0) {
1187                 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2))
1188                         return False;
1189         }
1190
1191         return True;
1192 }
1193
1194 /*******************************************************************
1195 reads or writes a structure.
1196 ********************************************************************/
1197
1198 BOOL reg_io_r_enum_val(char *desc,  REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth)
1199 {
1200         if (r_q == NULL)
1201                 return False;
1202
1203         prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1204         depth++;
1205
1206         if(!prs_align(ps))
1207                 return False;
1208         
1209         if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth))
1210                 return False;
1211         if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1212                 return False;
1213         if(!prs_align(ps))
1214                 return False;
1215
1216         if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type))
1217                 return False;
1218
1219         if (r_q->ptr_type != 0) {
1220                 if(!prs_uint32("type", ps, depth, &r_q->type))
1221                         return False;
1222         }
1223
1224         if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value))
1225                 return False;
1226         if(!smb_io_buffer2("buf_value", r_q->buf_value, r_q->ptr_value, ps, depth))
1227                 return False;
1228         if(!prs_align(ps))
1229                 return False;
1230
1231         if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1232                 return False;
1233         if (r_q->ptr1 != 0) {
1234                 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1))
1235                         return False;
1236         }
1237
1238         if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1239                 return False;
1240         if (r_q->ptr2 != 0) {
1241                 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2))
1242                         return False;
1243         }
1244
1245         if(!prs_ntstatus("status", ps, depth, &r_q->status))
1246                 return False;
1247
1248         return True;
1249 }
1250
1251 /*******************************************************************
1252 makes a structure.
1253 ********************************************************************/
1254
1255 void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
1256                                 char *val_name, uint32 type,
1257                                 BUFFER3 *val)
1258 {
1259         int val_len = strlen(val_name) + 1;
1260
1261         ZERO_STRUCTP(q_i);
1262
1263         memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1264
1265         init_uni_hdr(&q_i->hdr_name, val_len);
1266         init_unistr2(&q_i->uni_name, val_name, val_len);
1267         
1268         q_i->type      = type;
1269         q_i->buf_value = val;
1270 }
1271
1272 /*******************************************************************
1273 reads or writes a structure.
1274 ********************************************************************/
1275
1276 BOOL reg_io_q_create_val(char *desc,  REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth)
1277 {
1278         if (q_q == NULL)
1279                 return False;
1280
1281         prs_debug(ps, depth, desc, "reg_io_q_create_val");
1282         depth++;
1283
1284         if(!prs_align(ps))
1285                 return False;
1286         
1287         if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1288                 return False;
1289         
1290         if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1291                 return False;
1292         if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1293                 return False;
1294         if(!prs_align(ps))
1295                 return False;
1296
1297         if(!prs_uint32("type", ps, depth, &q_q->type))
1298                 return False;
1299         if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth))
1300                 return False;
1301         if(!prs_align(ps))
1302                 return False;
1303
1304         return True;
1305 }
1306
1307 /*******************************************************************
1308 reads or writes a structure.
1309 ********************************************************************/
1310
1311 BOOL reg_io_r_create_val(char *desc,  REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth)
1312 {
1313         if (r_q == NULL)
1314                 return False;
1315
1316         prs_debug(ps, depth, desc, "reg_io_r_create_val");
1317         depth++;
1318
1319         if(!prs_align(ps))
1320                 return False;
1321         
1322         if(!prs_ntstatus("status", ps, depth, &r_q->status))
1323                 return False;
1324
1325         return True;
1326 }
1327
1328 /*******************************************************************
1329 makes a structure.
1330 ********************************************************************/
1331
1332 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx)
1333 {
1334         memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1335
1336         q_i->key_index = key_idx;
1337         q_i->key_name_len = 0;
1338         q_i->unknown_1 = 0x0414;
1339
1340         q_i->ptr1 = 1;
1341         q_i->unknown_2 = 0x0000020A;
1342         memset(q_i->pad1, 0, sizeof(q_i->pad1));
1343
1344         q_i->ptr2 = 1;
1345         memset(q_i->pad2, 0, sizeof(q_i->pad2));
1346
1347         q_i->ptr3 = 1;
1348         unix_to_nt_time(&q_i->time, 0);            /* current time? */
1349 }
1350
1351 /*******************************************************************
1352 reads or writes a structure.
1353 ********************************************************************/
1354
1355 BOOL reg_io_q_enum_key(char *desc,  REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth)
1356 {
1357         if (q_q == NULL)
1358                 return False;
1359
1360         prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1361         depth++;
1362
1363         if(!prs_align(ps))
1364                 return False;
1365         
1366         if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1367                 return False;
1368         
1369         if(!prs_uint32("key_index", ps, depth, &q_q->key_index))
1370                 return False;
1371         if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len))
1372                 return False;
1373         if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1))
1374                 return False;
1375
1376         if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1377                 return False;
1378
1379         if (q_q->ptr1 != 0) {
1380                 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2))
1381                         return False;
1382                 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)))
1383                         return False;
1384         }
1385
1386         if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1387                 return False;
1388
1389         if (q_q->ptr2 != 0) {
1390                 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)))
1391                         return False;
1392         }
1393
1394         if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3))
1395                 return False;
1396
1397         if (q_q->ptr3 != 0) {
1398                 if(!smb_io_time("", &q_q->time, ps, depth))
1399                         return False;
1400         }
1401
1402         return True;
1403 }
1404
1405 /*******************************************************************
1406 reads or writes a structure.
1407 ********************************************************************/
1408
1409 BOOL reg_io_r_enum_key(char *desc,  REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth)
1410 {
1411         if (r_q == NULL)
1412                 return False;
1413
1414         prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1415         depth++;
1416
1417         if(!prs_align(ps))
1418                 return False;
1419         
1420         if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len))
1421                 return False;
1422         if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
1423                 return False;
1424
1425         if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1426                 return False;
1427
1428         if (r_q->ptr1 != 0) {
1429                 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
1430                         return False;
1431                 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3))
1432                         return False;
1433                 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth))
1434                         return False;
1435                 if(!prs_align(ps))
1436                         return False;
1437         }
1438
1439         if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1440                 return False;
1441
1442         if (r_q->ptr2 != 0) {
1443                 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
1444                         return False;
1445         }
1446
1447         if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
1448                 return False;
1449
1450         if (r_q->ptr3 != 0) {
1451                 if(!smb_io_time("", &r_q->time, ps, depth))
1452                         return False;
1453         }
1454
1455         if(!prs_ntstatus("status", ps, depth, &r_q->status))
1456                 return False;
1457
1458         return True;
1459 }
1460
1461 /*******************************************************************
1462 makes a structure.
1463 ********************************************************************/
1464
1465 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
1466                                 char *key_name, uint32 unk)
1467 {
1468         int len_name = strlen(key_name)+1;
1469
1470         memcpy(&r_q->pol, pol, sizeof(r_q->pol));
1471
1472         init_uni_hdr(&r_q->hdr_name, len_name);
1473         init_unistr2(&r_q->uni_name, key_name, len_name);
1474
1475         r_q->unknown_0 = 0x00000000;
1476         r_q->unknown_1 = unk;
1477 }
1478
1479 /*******************************************************************
1480 reads or writes a structure.
1481 ********************************************************************/
1482
1483 BOOL reg_io_q_open_entry(char *desc,  REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
1484 {
1485         if (r_q == NULL)
1486                 return False;
1487
1488         prs_debug(ps, depth, desc, "reg_io_q_entry");
1489         depth++;
1490
1491         if(!prs_align(ps))
1492                 return False;
1493         
1494         if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1495                 return False;
1496         if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
1497                 return False;
1498         if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1499                 return False;
1500
1501         if(!prs_align(ps))
1502                 return False;
1503         
1504         if(!prs_uint32("unknown_0", ps, depth, &r_q->unknown_0))
1505                 return False;
1506         if(!prs_uint32("unknown_1", ps, depth, &r_q->unknown_1))
1507                 return False;
1508
1509         return True;
1510 }
1511
1512 /*******************************************************************
1513  Inits a structure.
1514 ********************************************************************/
1515
1516 void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
1517                            POLICY_HND *pol, NTSTATUS status)
1518 {
1519         memcpy(&r_r->pol, pol, sizeof(r_r->pol));
1520         r_r->status = status;
1521 }
1522
1523 /*******************************************************************
1524 reads or writes a structure.
1525 ********************************************************************/
1526
1527 BOOL reg_io_r_open_entry(char *desc,  REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
1528 {
1529         if (r_r == NULL)
1530                 return False;
1531
1532         prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1533         depth++;
1534
1535         if(!prs_align(ps))
1536                 return False;
1537         
1538         if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
1539                 return False;
1540
1541         if(!prs_ntstatus("status", ps, depth, &r_r->status))
1542                 return False;
1543
1544         return True;
1545 }
1546
1547 /*******************************************************************
1548 Inits a structure.
1549 ********************************************************************/
1550 void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s,
1551                          const char *msg, uint32 timeout, uint16 flags)
1552 {
1553         int msg_len;
1554         msg_len = strlen(msg);
1555
1556         q_s->ptr_0 = 1;
1557         q_s->ptr_1 = 1;
1558         q_s->ptr_2 = 1;
1559
1560         init_uni_hdr(&(q_s->hdr_msg), msg_len);
1561         init_unistr2(&(q_s->uni_msg), msg, msg_len);
1562
1563         q_s->timeout = timeout;
1564         q_s->flags = flags;
1565
1566 }
1567
1568 /*******************************************************************
1569 reads or writes a structure.
1570 ********************************************************************/
1571 BOOL reg_io_q_shutdown(char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps,
1572                        int depth)
1573 {
1574         if (q_s == NULL)
1575                 return False;
1576
1577         prs_debug(ps, depth, desc, "reg_io_q_shutdown");
1578         depth++;
1579
1580         if (!prs_align(ps))
1581                 return False;
1582
1583         if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0)))
1584                 return False;
1585         if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1)))
1586                 return False;
1587         if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2)))
1588                 return False;
1589
1590         if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth))
1591                 return False;
1592         if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth))
1593                 return False;
1594         if (!prs_align(ps))
1595                 return False;
1596
1597         if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
1598                 return False;
1599         if (!prs_uint16("flags  ", ps, depth, &(q_s->flags)))
1600                 return False;
1601
1602         return True;
1603 }
1604
1605 /*******************************************************************
1606 reads or writes a structure.
1607 ********************************************************************/
1608 BOOL reg_io_r_shutdown(char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps,
1609                        int depth)
1610 {
1611         if (r_s == NULL)
1612                 return False;
1613
1614         prs_debug(ps, depth, desc, "reg_io_r_shutdown");
1615         depth++;
1616
1617         if(!prs_align(ps))
1618                 return False;
1619
1620         if(!prs_ntstatus("status", ps, depth, &r_s->status))
1621                 return False;
1622
1623         return True;
1624 }
1625
1626 /*******************************************************************
1627 Inits a structure.
1628 ********************************************************************/
1629 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s)
1630 {
1631
1632         q_s->ptr_server = 0;
1633
1634 }
1635
1636 /*******************************************************************
1637 reads or writes a structure.
1638 ********************************************************************/
1639 BOOL reg_io_q_abort_shutdown(char *desc, REG_Q_ABORT_SHUTDOWN * q_s,
1640                              prs_struct *ps, int depth)
1641 {
1642         if (q_s == NULL)
1643                 return False;
1644
1645         prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
1646         depth++;
1647
1648         if (!prs_align(ps))
1649                 return False;
1650
1651         if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
1652                 return False;
1653         if (q_s->ptr_server != 0)
1654                 if (!prs_uint16("server", ps, depth, &(q_s->server)))
1655                         return False;
1656
1657         return True;
1658 }
1659
1660 /*******************************************************************
1661 reads or writes a structure.
1662 ********************************************************************/
1663 BOOL reg_io_r_abort_shutdown(char *desc, REG_R_ABORT_SHUTDOWN * r_s,
1664                              prs_struct *ps, int depth)
1665 {
1666         if (r_s == NULL)
1667                 return False;
1668
1669         prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
1670         depth++;
1671
1672         if (!prs_align(ps))
1673                 return False;
1674
1675         if (!prs_ntstatus("status", ps, depth, &r_s->status))
1676                 return False;
1677
1678         return True;
1679 }