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