At the prompting, start to add infrastructure to detect the presence of
[Samba/gebeck_regimport.git] / source3 / rpc_parse / parse_reg.c
blobb4d20bf2baa32b66d4e6ffd96fce217ef388f254
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 * Copyright (C) Gerald Carter 2002.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "includes.h"
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_PARSE
31 /*******************************************************************
32 Fill in a BUFFER2 for the data given a REGISTRY_VALUE
33 *******************************************************************/
35 static uint32 reg_init_buffer2( BUFFER2 *buf2, REGISTRY_VALUE *val )
37 uint32 real_size = 0;
39 if ( !buf2 || !val )
40 return 0;
42 real_size = regval_size(val);
43 init_buffer2( buf2, (char*)regval_data_p(val), real_size );
45 return real_size;
48 /*******************************************************************
49 Inits a structure.
50 ********************************************************************/
52 void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o,
53 uint16 unknown_0, uint32 level)
55 q_o->ptr = 1;
56 q_o->unknown_0 = unknown_0;
57 q_o->unknown_1 = 0x0; /* random - changes */
58 q_o->level = level;
61 /*******************************************************************
62 reads or writes a structure.
63 ********************************************************************/
65 BOOL reg_io_q_open_hkcr(const char *desc, REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth)
67 if (r_q == NULL)
68 return False;
70 prs_debug(ps, depth, desc, "reg_io_q_open_hkcr");
71 depth++;
73 if(!prs_align(ps))
74 return False;
76 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
77 return False;
79 if (r_q->ptr != 0) {
80 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0))
81 return False;
82 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
83 return False;
84 if(!prs_uint32("level ", ps, depth, &r_q->level))
85 return False;
88 return True;
92 /*******************************************************************
93 reads or writes a structure.
94 ********************************************************************/
96 BOOL reg_io_r_open_hkcr(const char *desc, REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth)
98 if (r_r == NULL)
99 return False;
101 prs_debug(ps, depth, desc, "reg_io_r_open_hkcr");
102 depth++;
104 if(!prs_align(ps))
105 return False;
107 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
108 return False;
110 if(!prs_ntstatus("status", ps, depth, &r_r->status))
111 return False;
113 return True;
116 /*******************************************************************
117 Inits a structure.
118 ********************************************************************/
120 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o,
121 uint16 unknown_0, uint32 access_mask)
123 q_o->ptr = 1;
124 q_o->unknown_0 = unknown_0;
125 q_o->unknown_1 = 0x0; /* random - changes */
126 q_o->access_mask = access_mask;
130 /*******************************************************************
131 reads or writes a structure.
132 ********************************************************************/
133 BOOL reg_io_q_open_hklm(const char *desc, REG_Q_OPEN_HKLM * r_q, prs_struct *ps,
134 int depth)
136 if (r_q == NULL)
137 return False;
139 prs_debug(ps, depth, desc, "reg_io_q_open_hklm");
140 depth++;
142 if (!prs_align(ps))
143 return False;
145 if (!prs_uint32("ptr ", ps, depth, &(r_q->ptr)))
146 return False;
147 if (r_q->ptr != 0)
149 if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0)))
150 return False;
151 if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)))
152 return False;
153 if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask)))
154 return False;
157 return True;
161 /*******************************************************************
162 reads or writes a structure.
163 ********************************************************************/
164 BOOL reg_io_r_open_hklm(const char *desc, REG_R_OPEN_HKLM * r_r, prs_struct *ps,
165 int depth)
167 if (r_r == NULL)
168 return False;
170 prs_debug(ps, depth, desc, "reg_io_r_open_hklm");
171 depth++;
173 if (!prs_align(ps))
174 return False;
176 if (!smb_io_pol_hnd("", &r_r->pol, ps, depth))
177 return False;
179 if (!prs_ntstatus("status", ps, depth, &r_r->status))
180 return False;
182 return True;
188 /*******************************************************************
189 Inits a structure.
190 ********************************************************************/
192 void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol)
194 memcpy(&q_u->pol, pol, sizeof(q_u->pol));
197 /*******************************************************************
198 reads or writes a structure.
199 ********************************************************************/
201 BOOL reg_io_q_flush_key(const char *desc, REG_Q_FLUSH_KEY *r_q, prs_struct *ps, int depth)
203 if (r_q == NULL)
204 return False;
206 prs_debug(ps, depth, desc, "reg_io_q_flush_key");
207 depth++;
209 if(!prs_align(ps))
210 return False;
212 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
213 return False;
215 return True;
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, int depth)
224 if (r_r == NULL)
225 return False;
227 prs_debug(ps, depth, desc, "reg_io_r_flush_key");
228 depth++;
230 if(!prs_align(ps))
231 return False;
233 if(!prs_ntstatus("status", ps, depth, &r_r->status))
234 return False;
236 return True;
239 /*******************************************************************
240 reads or writes SEC_DESC_BUF and SEC_DATA structures.
241 ********************************************************************/
243 static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DESC_BUF *data, prs_struct *ps, int depth)
245 if (ptr != 0) {
246 uint32 hdr_offset;
247 uint32 old_offset;
248 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset))
249 return False;
251 old_offset = prs_offset(ps);
253 if (ptr3 != NULL) {
254 if(!prs_uint32("ptr3", ps, depth, ptr3))
255 return False;
258 if (ptr3 == NULL || *ptr3 != 0) {
259 if(!sec_io_desc_buf("data ", &data, ps, depth)) /* JRA - this line is probably wrong... */
260 return False;
263 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset,
264 data->max_len, data->len))
265 return False;
266 if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3)))
267 return False;
269 if(!prs_align(ps))
270 return False;
273 return True;
276 /*******************************************************************
277 Inits a structure.
278 ********************************************************************/
280 void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd,
281 char *name, char *class, SEC_ACCESS *sam_access,
282 SEC_DESC_BUF *sec_buf)
284 int len_name = name != NULL ? strlen(name ) + 1: 0;
285 int len_class = class != NULL ? strlen(class) + 1: 0;
287 ZERO_STRUCTP(q_c);
289 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
291 init_uni_hdr(&q_c->hdr_name, len_name);
292 init_unistr2(&q_c->uni_name, name, len_name);
294 init_uni_hdr(&q_c->hdr_class, len_class);
295 init_unistr2(&q_c->uni_class, class, len_class);
297 q_c->reserved = 0x00000000;
298 memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access));
300 q_c->ptr1 = 1;
301 q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
303 q_c->data = sec_buf;
304 q_c->ptr2 = 1;
305 init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len);
306 q_c->ptr3 = 1;
307 q_c->unknown_2 = 0x00000000;
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
314 BOOL reg_io_q_create_key(const char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth)
316 if (r_q == NULL)
317 return False;
319 prs_debug(ps, depth, desc, "reg_io_q_create_key");
320 depth++;
322 if(!prs_align(ps))
323 return False;
325 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
326 return False;
328 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
329 return False;
330 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
331 return False;
332 if(!prs_align(ps))
333 return False;
335 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
336 return False;
337 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
338 return False;
339 if(!prs_align(ps))
340 return False;
342 if(!prs_uint32("reserved", ps, depth, &r_q->reserved))
343 return False;
344 if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth))
345 return False;
347 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
348 return False;
350 if (r_q->ptr1 != 0) {
351 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
352 return False;
355 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
356 return False;
357 if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth))
358 return False;
360 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
361 return False;
363 return True;
366 /*******************************************************************
367 reads or writes a structure.
368 ********************************************************************/
370 BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth)
372 if (r_r == NULL)
373 return False;
375 prs_debug(ps, depth, desc, "reg_io_r_create_key");
376 depth++;
378 if(!prs_align(ps))
379 return False;
381 if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth))
382 return False;
383 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
384 return False;
386 if(!prs_ntstatus("status", ps, depth, &r_r->status))
387 return False;
389 return True;
393 /*******************************************************************
394 Inits a structure.
395 ********************************************************************/
397 void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd,
398 char *name)
400 int len_name = name != NULL ? strlen(name ) + 1: 0;
401 ZERO_STRUCTP(q_c);
403 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
405 init_uni_hdr(&q_c->hdr_name, len_name);
406 init_unistr2(&q_c->uni_name, name, len_name);
409 /*******************************************************************
410 reads or writes a structure.
411 ********************************************************************/
413 BOOL reg_io_q_delete_val(const char *desc, REG_Q_DELETE_VALUE *r_q, prs_struct *ps, int depth)
415 if (r_q == NULL)
416 return False;
418 prs_debug(ps, depth, desc, "reg_io_q_delete_val");
419 depth++;
421 if(!prs_align(ps))
422 return False;
424 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
425 return False;
427 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
428 return False;
429 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
430 return False;
431 if(!prs_align(ps))
432 return False;
434 return True;
438 /*******************************************************************
439 reads or writes a structure.
440 ********************************************************************/
442 BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_r, prs_struct *ps, int depth)
444 if (r_r == NULL)
445 return False;
447 prs_debug(ps, depth, desc, "reg_io_r_delete_val");
448 depth++;
450 if(!prs_align(ps))
451 return False;
453 if(!prs_ntstatus("status", ps, depth, &r_r->status))
454 return False;
456 return True;
459 /*******************************************************************
460 Inits a structure.
461 ********************************************************************/
463 void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
464 char *name)
466 int len_name = name != NULL ? strlen(name ) + 1: 0;
467 ZERO_STRUCTP(q_c);
469 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
471 init_uni_hdr(&q_c->hdr_name, len_name);
472 init_unistr2(&q_c->uni_name, name, len_name);
475 /*******************************************************************
476 reads or writes a structure.
477 ********************************************************************/
479 BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth)
481 if (r_q == NULL)
482 return False;
484 prs_debug(ps, depth, desc, "reg_io_q_delete_key");
485 depth++;
487 if(!prs_align(ps))
488 return False;
490 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
491 return False;
493 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
494 return False;
495 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
496 return False;
497 if(!prs_align(ps))
498 return False;
500 return True;
503 /*******************************************************************
504 reads or writes a structure.
505 ********************************************************************/
507 BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth)
509 if (r_r == NULL)
510 return False;
512 prs_debug(ps, depth, desc, "reg_io_r_delete_key");
513 depth++;
515 if(!prs_align(ps))
516 return False;
518 if(!prs_ntstatus("status", ps, depth, &r_r->status))
519 return False;
521 return True;
524 /*******************************************************************
525 Inits a structure.
526 ********************************************************************/
528 void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd,
529 uint32 max_class_len)
531 ZERO_STRUCTP(q_o);
533 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
534 init_uni_hdr(&q_o->hdr_class, max_class_len);
535 q_o->uni_class.uni_max_len = max_class_len;
538 /*******************************************************************
539 reads or writes a structure.
540 ********************************************************************/
542 BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth)
544 if (r_q == NULL)
545 return False;
547 prs_debug(ps, depth, desc, "reg_io_q_query_key");
548 depth++;
550 if(!prs_align(ps))
551 return False;
553 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
554 return False;
555 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
556 return False;
557 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
558 return False;
560 if(!prs_align(ps))
561 return False;
563 return True;
567 /*******************************************************************
568 reads or writes a structure.
569 ********************************************************************/
571 BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth)
573 if (r_r == NULL)
574 return False;
576 prs_debug(ps, depth, desc, "reg_io_r_query_key");
577 depth++;
579 if(!prs_align(ps))
580 return False;
582 if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth))
583 return False;
584 if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth))
585 return False;
587 if(!prs_align(ps))
588 return False;
590 if(!prs_uint32("num_subkeys ", ps, depth, &r_r->num_subkeys))
591 return False;
592 if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen))
593 return False;
594 if(!prs_uint32("reserved ", ps, depth, &r_r->reserved))
595 return False;
596 if(!prs_uint32("num_values ", ps, depth, &r_r->num_values))
597 return False;
598 if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen))
599 return False;
600 if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize))
601 return False;
602 if(!prs_uint32("sec_desc ", ps, depth, &r_r->sec_desc))
603 return False;
604 if(!smb_io_time("mod_time ", &r_r->mod_time, ps, depth))
605 return False;
607 if(!prs_ntstatus("status", ps, depth, &r_r->status))
608 return False;
610 return True;
613 /*******************************************************************
614 Inits a structure.
615 ********************************************************************/
617 void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A *q_o, POLICY_HND *hnd)
619 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
623 /*******************************************************************
624 reads or writes a structure.
625 ********************************************************************/
627 BOOL reg_io_q_unknown_1a(const char *desc, REG_Q_UNKNOWN_1A *r_q, prs_struct *ps, int depth)
629 if (r_q == NULL)
630 return False;
632 prs_debug(ps, depth, desc, "reg_io_q_unknown_1a");
633 depth++;
635 if(!prs_align(ps))
636 return False;
638 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
639 return False;
641 return True;
644 /*******************************************************************
645 reads or writes a structure.
646 ********************************************************************/
648 BOOL reg_io_r_unknown_1a(const char *desc, REG_R_UNKNOWN_1A *r_r, prs_struct *ps, int depth)
650 if (r_r == NULL)
651 return False;
653 prs_debug(ps, depth, desc, "reg_io_r_unknown_1a");
654 depth++;
656 if(!prs_align(ps))
657 return False;
659 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
660 return False;
661 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
662 return False;
664 return True;
668 /*******************************************************************
669 reads or writes a structure.
670 ********************************************************************/
672 BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *r_q, prs_struct *ps, int depth)
674 if (r_q == NULL)
675 return False;
677 prs_debug(ps, depth, desc, "reg_io_q_save_key");
678 depth++;
680 if(!prs_align(ps))
681 return False;
683 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
684 return False;
686 if(!smb_io_unihdr ("hdr_file", &r_q->hdr_file, ps, depth))
687 return False;
688 if(!smb_io_unistr2("uni_file", &r_q->uni_file, r_q->hdr_file.buffer, ps, depth))
689 return False;
691 if(!prs_uint32("unknown", ps, depth, &r_q->unknown))
692 return False;
694 return True;
697 /*******************************************************************
698 reads or writes a structure.
699 ********************************************************************/
701 BOOL reg_io_r_save_key(const char *desc, REG_R_SAVE_KEY *r_r, prs_struct *ps, int depth)
703 if (r_r == NULL)
704 return False;
706 prs_debug(ps, depth, desc, "reg_io_r_save_key");
707 depth++;
709 if(!prs_align(ps))
710 return False;
712 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
713 return False;
715 return True;
718 /*******************************************************************
719 Inits a structure.
720 ********************************************************************/
722 void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o,
723 uint16 unknown_0, uint32 access_mask)
725 q_o->ptr = 1;
726 q_o->unknown_0 = unknown_0;
727 q_o->unknown_1 = 0x0; /* random - changes */
728 q_o->access_mask = access_mask;
731 /*******************************************************************
732 reads or writes a structure.
733 ********************************************************************/
735 BOOL reg_io_q_open_hku(const char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth)
737 if (r_q == NULL)
738 return False;
740 prs_debug(ps, depth, desc, "reg_io_q_open_hku");
741 depth++;
743 if(!prs_align(ps))
744 return False;
746 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
747 return False;
748 if (r_q->ptr != 0) {
749 if(!prs_uint16("unknown_0 ", ps, depth, &r_q->unknown_0))
750 return False;
751 if(!prs_uint16("unknown_1 ", ps, depth, &r_q->unknown_1))
752 return False;
753 if(!prs_uint32("access_mask ", ps, depth, &r_q->access_mask))
754 return False;
757 return True;
760 /*******************************************************************
761 reads or writes a structure.
762 ********************************************************************/
764 BOOL reg_io_r_open_hku(const char *desc, REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth)
766 if (r_r == NULL)
767 return False;
769 prs_debug(ps, depth, desc, "reg_io_r_open_hku");
770 depth++;
772 if(!prs_align(ps))
773 return False;
775 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
776 return False;
778 if(!prs_ntstatus("status", ps, depth, &r_r->status))
779 return False;
781 return True;
784 /*******************************************************************
785 Inits an REG_Q_CLOSE structure.
786 ********************************************************************/
788 void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
790 DEBUG(5,("init_reg_q_close\n"));
792 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
795 /*******************************************************************
796 reads or writes a structure.
797 ********************************************************************/
799 BOOL reg_io_q_close(const char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
801 if (q_u == NULL)
802 return False;
804 prs_debug(ps, depth, desc, "reg_io_q_close");
805 depth++;
807 if(!prs_align(ps))
808 return False;
810 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
811 return False;
812 if(!prs_align(ps))
813 return False;
815 return True;
818 /*******************************************************************
819 reads or writes a structure.
820 ********************************************************************/
822 BOOL reg_io_r_close(const char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth)
824 if (r_u == NULL)
825 return False;
827 prs_debug(ps, depth, desc, "reg_io_r_close");
828 depth++;
830 if(!prs_align(ps))
831 return False;
833 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
834 return False;
835 if(!prs_align(ps))
836 return False;
838 if(!prs_ntstatus("status", ps, depth, &r_u->status))
839 return False;
841 return True;
844 /*******************************************************************
845 makes a structure.
846 ********************************************************************/
848 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf)
850 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
852 q_i->sec_info = DACL_SECURITY_INFORMATION;
854 q_i->ptr = 1;
855 init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len);
856 q_i->data = sec_desc_buf;
859 /*******************************************************************
860 reads or writes a structure.
861 ********************************************************************/
863 BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
865 if (r_q == NULL)
866 return False;
868 prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
869 depth++;
871 if(!prs_align(ps))
872 return False;
874 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
875 return False;
877 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
878 return False;
879 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
880 return False;
882 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
883 return False;
885 return True;
888 /*******************************************************************
889 reads or writes a structure.
890 ********************************************************************/
892 BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
894 if (r_q == NULL)
895 return False;
897 prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
898 depth++;
900 if(!prs_align(ps))
901 return False;
903 if(!prs_ntstatus("status", ps, depth, &r_q->status))
904 return False;
906 return True;
910 /*******************************************************************
911 makes a structure.
912 ********************************************************************/
914 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol,
915 uint32 sec_buf_size, SEC_DESC_BUF *psdb)
917 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
919 q_i->sec_info = OWNER_SECURITY_INFORMATION |
920 GROUP_SECURITY_INFORMATION |
921 DACL_SECURITY_INFORMATION;
923 q_i->ptr = psdb != NULL ? 1 : 0;
924 q_i->data = psdb;
926 init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0);
929 /*******************************************************************
930 reads or writes a structure.
931 ********************************************************************/
933 BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
935 if (r_q == NULL)
936 return False;
938 prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
939 depth++;
941 if(!prs_align(ps))
942 return False;
944 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
945 return False;
947 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
948 return False;
949 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
950 return False;
952 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
953 return False;
955 return True;
958 #if 0
959 /*******************************************************************
960 makes a structure.
961 ********************************************************************/
962 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
963 uint32 buf_len, uint8 *buf,
964 NTSTATUS status)
966 r_i->ptr = 1;
967 init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len);
968 init_sec_desc_buf(r_i->data, buf_len, 1);
970 r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
972 #endif
974 /*******************************************************************
975 reads or writes a structure.
976 ********************************************************************/
978 BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
980 if (r_q == NULL)
981 return False;
983 prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
984 depth++;
986 if(!prs_align(ps))
987 return False;
989 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
990 return False;
992 if (r_q->ptr != 0) {
993 if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth))
994 return False;
995 if(!sec_io_desc_buf("", &r_q->data, ps, depth))
996 return False;
997 if(!prs_align(ps))
998 return False;
1001 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1002 return False;
1004 return True;
1007 /*******************************************************************
1008 makes a structure.
1009 ********************************************************************/
1011 BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name)
1013 int len_type = val_name != NULL ? strlen(val_name) + 1 : 0;
1015 if (q_i == NULL)
1016 return False;
1018 q_i->pol = *pol;
1020 init_uni_hdr(&(q_i->hdr_type), len_type);
1021 init_unistr2(&(q_i->uni_type), val_name, len_type);
1023 q_i->ptr_reserved = 1;
1024 q_i->ptr_buf = 1;
1026 q_i->ptr_bufsize = 1;
1027 q_i->bufsize = 0;
1028 q_i->buf_unk = 0;
1030 q_i->unk1 = 0;
1031 q_i->ptr_buflen = 1;
1032 q_i->buflen = 0;
1034 q_i->ptr_buflen2 = 1;
1035 q_i->buflen2 = 0;
1037 return True;
1040 /*******************************************************************
1041 reads or writes a structure.
1042 ********************************************************************/
1044 BOOL reg_io_q_info(const char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth)
1046 if (r_q == NULL)
1047 return False;
1049 prs_debug(ps, depth, desc, "reg_io_q_info");
1050 depth++;
1052 if(!prs_align(ps))
1053 return False;
1055 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1056 return False;
1057 if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth))
1058 return False;
1059 if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth))
1060 return False;
1062 if(!prs_align(ps))
1063 return False;
1065 if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved)))
1066 return False;
1068 if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf)))
1069 return False;
1071 if(r_q->ptr_buf) {
1072 if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize)))
1073 return False;
1074 if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize)))
1075 return False;
1076 if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk)))
1077 return False;
1080 if(!prs_uint32("unk1", ps, depth, &(r_q->unk1)))
1081 return False;
1083 if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen)))
1084 return False;
1086 if (r_q->ptr_buflen) {
1087 if(!prs_uint32("buflen", ps, depth, &(r_q->buflen)))
1088 return False;
1089 if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2)))
1090 return False;
1091 if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2)))
1092 return False;
1095 return True;
1098 /*******************************************************************
1099 Inits a structure.
1100 New version to replace older init_reg_r_info()
1101 ********************************************************************/
1103 BOOL new_init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1104 REGISTRY_VALUE *val, NTSTATUS status)
1106 uint32 buf_len = 0;
1107 BUFFER2 buf2;
1109 if(r_r == NULL)
1110 return False;
1112 if ( !val )
1113 return False;
1115 r_r->ptr_type = 1;
1116 r_r->type = val->type;
1118 /* if include_keyval is not set, don't send the key value, just
1119 the buflen data. probably used by NT5 to allocate buffer space - SK */
1121 if ( include_keyval ) {
1122 r_r->ptr_uni_val = 1;
1123 buf_len = reg_init_buffer2( &r_r->uni_val, val );
1126 else {
1127 /* dummy buffer used so we can get the size */
1128 r_r->ptr_uni_val = 0;
1129 buf_len = reg_init_buffer2( &buf2, val );
1132 r_r->ptr_max_len = 1;
1133 r_r->buf_max_len = buf_len;
1135 r_r->ptr_len = 1;
1136 r_r->buf_len = buf_len;
1138 r_r->status = status;
1140 return True;
1143 /*******************************************************************
1144 Inits a structure.
1145 ********************************************************************/
1147 BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1148 BUFFER2* buf, uint32 type, NTSTATUS status)
1150 if(r_r == NULL)
1151 return False;
1153 r_r->ptr_type = 1;
1154 r_r->type = type;
1156 /* if include_keyval is not set, don't send the key value, just
1157 the buflen data. probably used by NT5 to allocate buffer space - SK */
1159 r_r->ptr_uni_val = include_keyval ? 1:0;
1160 r_r->uni_val = *buf;
1162 r_r->ptr_max_len = 1;
1163 r_r->buf_max_len = r_r->uni_val.buf_max_len;
1165 r_r->ptr_len = 1;
1166 r_r->buf_len = r_r->uni_val.buf_len;
1168 r_r->status = status;
1170 return True;
1173 /*******************************************************************
1174 reads or writes a structure.
1175 ********************************************************************/
1177 BOOL reg_io_r_info(const char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
1179 if (r_r == NULL)
1180 return False;
1182 prs_debug(ps, depth, desc, "reg_io_r_info");
1183 depth++;
1185 if(!prs_align(ps))
1186 return False;
1188 if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type)))
1189 return False;
1191 if (r_r->ptr_type != 0) {
1192 if(!prs_uint32("type", ps, depth, &r_r->type))
1193 return False;
1196 if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val)))
1197 return False;
1199 if(r_r->ptr_uni_val != 0) {
1200 if(!smb_io_buffer2("uni_val", &r_r->uni_val, r_r->ptr_uni_val, ps, depth))
1201 return False;
1204 if(!prs_align(ps))
1205 return False;
1207 if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len)))
1208 return False;
1210 if (r_r->ptr_max_len != 0) {
1211 if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len)))
1212 return False;
1215 if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len)))
1216 return False;
1217 if (r_r->ptr_len != 0) {
1218 if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len)))
1219 return False;
1222 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1223 return False;
1225 return True;
1228 /*******************************************************************
1229 makes a structure.
1230 ********************************************************************/
1232 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
1233 uint32 val_idx, uint32 max_val_len,
1234 uint32 max_buf_len)
1236 ZERO_STRUCTP(q_i);
1238 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1240 q_i->val_index = val_idx;
1241 init_uni_hdr(&q_i->hdr_name, max_val_len);
1242 q_i->uni_name.uni_max_len = max_val_len;
1244 q_i->ptr_type = 1;
1245 q_i->type = 0x0;
1247 q_i->ptr_value = 1;
1248 q_i->buf_value.buf_max_len = max_buf_len;
1250 q_i->ptr1 = 1;
1251 q_i->len_value1 = max_buf_len;
1253 q_i->ptr2 = 1;
1254 q_i->len_value2 = 0;
1257 /*******************************************************************
1258 makes a structure.
1259 ********************************************************************/
1261 void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val )
1263 uint32 real_size;
1265 DEBUG(8,("init_reg_r_enum_val: Enter\n"));
1267 ZERO_STRUCTP(r_u);
1269 /* value name */
1271 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename));
1273 init_uni_hdr( &r_u->hdr_name, strlen(val->valuename)+1 );
1274 init_unistr2( &r_u->uni_name, val->valuename, strlen(val->valuename)+1 );
1276 /* type */
1278 r_u->ptr_type = 1;
1279 r_u->type = val->type;
1281 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1283 r_u->ptr_value = 1;
1284 real_size = reg_init_buffer2( &r_u->buf_value, val );
1286 /* lengths */
1288 r_u->ptr1 = 1;
1289 r_u->len_value1 = real_size;
1291 r_u->ptr2 = 1;
1292 r_u->len_value2 = real_size;
1294 DEBUG(8,("init_reg_r_enum_val: Exit\n"));
1297 /*******************************************************************
1298 reads or writes a structure.
1299 ********************************************************************/
1301 BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth)
1303 if (q_q == NULL)
1304 return False;
1306 prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1307 depth++;
1309 if(!prs_align(ps))
1310 return False;
1312 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1313 return False;
1315 if(!prs_uint32("val_index", ps, depth, &q_q->val_index))
1316 return False;
1318 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1319 return False;
1320 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1321 return False;
1322 if(!prs_align(ps))
1323 return False;
1325 if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type))
1326 return False;
1328 if (q_q->ptr_type != 0) {
1329 if(!prs_uint32("type", ps, depth, &q_q->type))
1330 return False;
1333 if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value))
1334 return False;
1335 if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth))
1336 return False;
1337 if(!prs_align(ps))
1338 return False;
1340 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1341 return False;
1342 if (q_q->ptr1 != 0) {
1343 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1))
1344 return False;
1346 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1347 return False;
1348 if (q_q->ptr2 != 0) {
1349 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2))
1350 return False;
1353 return True;
1356 /*******************************************************************
1357 reads or writes a structure.
1358 ********************************************************************/
1360 BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth)
1362 if (r_q == NULL)
1363 return False;
1365 prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1366 depth++;
1368 if(!prs_align(ps))
1369 return False;
1371 if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth))
1372 return False;
1373 if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1374 return False;
1375 if(!prs_align(ps))
1376 return False;
1378 if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type))
1379 return False;
1381 if (r_q->ptr_type != 0) {
1382 if(!prs_uint32("type", ps, depth, &r_q->type))
1383 return False;
1386 if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value))
1387 return False;
1388 if(!smb_io_buffer2("buf_value", &r_q->buf_value, r_q->ptr_value, ps, depth))
1389 return False;
1390 if(!prs_align(ps))
1391 return False;
1393 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1394 return False;
1395 if (r_q->ptr1 != 0) {
1396 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1))
1397 return False;
1400 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1401 return False;
1402 if (r_q->ptr2 != 0) {
1403 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2))
1404 return False;
1407 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1408 return False;
1410 return True;
1413 /*******************************************************************
1414 makes a structure.
1415 ********************************************************************/
1417 void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
1418 char *val_name, uint32 type,
1419 BUFFER3 *val)
1421 int val_len = strlen(val_name) + 1;
1423 ZERO_STRUCTP(q_i);
1425 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1427 init_uni_hdr(&q_i->hdr_name, val_len);
1428 init_unistr2(&q_i->uni_name, val_name, val_len);
1430 q_i->type = type;
1431 q_i->buf_value = val;
1434 /*******************************************************************
1435 reads or writes a structure.
1436 ********************************************************************/
1438 BOOL reg_io_q_create_val(const char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth)
1440 if (q_q == NULL)
1441 return False;
1443 prs_debug(ps, depth, desc, "reg_io_q_create_val");
1444 depth++;
1446 if(!prs_align(ps))
1447 return False;
1449 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1450 return False;
1452 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1453 return False;
1454 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1455 return False;
1456 if(!prs_align(ps))
1457 return False;
1459 if(!prs_uint32("type", ps, depth, &q_q->type))
1460 return False;
1461 if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth))
1462 return False;
1463 if(!prs_align(ps))
1464 return False;
1466 return True;
1469 /*******************************************************************
1470 reads or writes a structure.
1471 ********************************************************************/
1473 BOOL reg_io_r_create_val(const char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth)
1475 if (r_q == NULL)
1476 return False;
1478 prs_debug(ps, depth, desc, "reg_io_r_create_val");
1479 depth++;
1481 if(!prs_align(ps))
1482 return False;
1484 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1485 return False;
1487 return True;
1490 /*******************************************************************
1491 makes a structure.
1492 ********************************************************************/
1494 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx)
1496 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1498 q_i->key_index = key_idx;
1499 q_i->key_name_len = 0;
1500 q_i->unknown_1 = 0x0414;
1502 q_i->ptr1 = 1;
1503 q_i->unknown_2 = 0x0000020A;
1504 memset(q_i->pad1, 0, sizeof(q_i->pad1));
1506 q_i->ptr2 = 1;
1507 memset(q_i->pad2, 0, sizeof(q_i->pad2));
1509 q_i->ptr3 = 1;
1510 unix_to_nt_time(&q_i->time, 0); /* current time? */
1513 /*******************************************************************
1514 makes a reply structure.
1515 ********************************************************************/
1517 void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey, uint32 unknown_1,
1518 uint32 unknown_2)
1520 if ( !r_u )
1521 return;
1523 r_u->unknown_1 = unknown_1;
1524 r_u->unknown_2 = unknown_2;
1525 r_u->unknown_3 = 0x0;
1527 r_u->key_name_len = (strlen(subkey)+1) * 2;
1528 if (r_u->key_name_len)
1529 r_u->ptr1 = 0x1;
1530 init_unistr3( &r_u->key_name, subkey );
1532 r_u->ptr2 = 0x1;
1533 r_u->ptr3 = 0x1;
1536 /*******************************************************************
1537 reads or writes a structure.
1538 ********************************************************************/
1540 BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth)
1542 if (q_q == NULL)
1543 return False;
1545 prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1546 depth++;
1548 if(!prs_align(ps))
1549 return False;
1551 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1552 return False;
1554 if(!prs_uint32("key_index", ps, depth, &q_q->key_index))
1555 return False;
1556 if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len))
1557 return False;
1558 if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1))
1559 return False;
1561 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1562 return False;
1564 if (q_q->ptr1 != 0) {
1565 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2))
1566 return False;
1567 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)))
1568 return False;
1571 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1572 return False;
1574 if (q_q->ptr2 != 0) {
1575 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)))
1576 return False;
1579 if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3))
1580 return False;
1582 if (q_q->ptr3 != 0) {
1583 if(!smb_io_time("", &q_q->time, ps, depth))
1584 return False;
1587 return True;
1590 /*******************************************************************
1591 reads or writes a structure.
1592 ********************************************************************/
1594 BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth)
1596 if (r_q == NULL)
1597 return False;
1599 prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1600 depth++;
1602 if(!prs_align(ps))
1603 return False;
1605 if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len))
1606 return False;
1607 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
1608 return False;
1610 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1611 return False;
1613 if (r_q->ptr1 != 0) {
1614 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
1615 return False;
1616 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3))
1617 return False;
1618 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth))
1619 return False;
1620 if(!prs_align(ps))
1621 return False;
1624 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1625 return False;
1627 if (r_q->ptr2 != 0) {
1628 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
1629 return False;
1632 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
1633 return False;
1635 if (r_q->ptr3 != 0) {
1636 if(!smb_io_time("", &r_q->time, ps, depth))
1637 return False;
1640 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1641 return False;
1643 return True;
1646 /*******************************************************************
1647 makes a structure.
1648 ********************************************************************/
1650 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
1651 char *key_name, uint32 access_desired)
1653 int len_name = strlen(key_name)+1;
1655 memcpy(&r_q->pol, pol, sizeof(r_q->pol));
1657 init_uni_hdr(&r_q->hdr_name, len_name);
1658 init_unistr2(&r_q->uni_name, key_name, len_name);
1660 r_q->unknown_0 = 0x00000000;
1661 r_q->access_desired = access_desired;
1664 /*******************************************************************
1665 reads or writes a structure.
1666 ********************************************************************/
1668 BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
1670 if (r_q == NULL)
1671 return False;
1673 prs_debug(ps, depth, desc, "reg_io_q_entry");
1674 depth++;
1676 if(!prs_align(ps))
1677 return False;
1679 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1680 return False;
1681 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
1682 return False;
1683 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1684 return False;
1686 if(!prs_align(ps))
1687 return False;
1689 if(!prs_uint32("unknown_0 ", ps, depth, &r_q->unknown_0))
1690 return False;
1691 if(!prs_uint32("access_desired ", ps, depth, &r_q->access_desired))
1692 return False;
1694 return True;
1697 /*******************************************************************
1698 Inits a structure.
1699 ********************************************************************/
1701 void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
1702 POLICY_HND *pol, NTSTATUS status)
1704 if (NT_STATUS_IS_OK(status)) {
1705 memcpy(&r_r->pol, pol, sizeof(r_r->pol));
1706 } else {
1707 ZERO_STRUCT(r_r->pol);
1709 r_r->status = status;
1712 /*******************************************************************
1713 reads or writes a structure.
1714 ********************************************************************/
1716 BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
1718 if (r_r == NULL)
1719 return False;
1721 prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1722 depth++;
1724 if(!prs_align(ps))
1725 return False;
1727 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
1728 return False;
1730 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1731 return False;
1733 return True;
1736 /*******************************************************************
1737 Inits a structure.
1738 ********************************************************************/
1739 void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s, const char *msg,
1740 uint32 timeout, BOOL do_reboot, BOOL force)
1742 int msg_len;
1743 msg_len = strlen(msg);
1745 q_s->ptr_0 = 1;
1746 q_s->ptr_1 = 1;
1747 q_s->ptr_2 = 1;
1749 init_uni_hdr(&(q_s->hdr_msg), msg_len);
1750 init_unistr2(&(q_s->uni_msg), msg, msg_len);
1752 q_s->timeout = timeout;
1754 q_s->reboot = do_reboot ? 1 : 0;
1755 q_s->force = force ? 1 : 0;
1759 /*******************************************************************
1760 reads or writes a structure.
1761 ********************************************************************/
1762 BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps,
1763 int depth)
1765 if (q_s == NULL)
1766 return False;
1768 prs_debug(ps, depth, desc, "reg_io_q_shutdown");
1769 depth++;
1771 if (!prs_align(ps))
1772 return False;
1774 if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0)))
1775 return False;
1776 if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1)))
1777 return False;
1778 if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2)))
1779 return False;
1781 if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth))
1782 return False;
1783 if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth))
1784 return False;
1785 if (!prs_align(ps))
1786 return False;
1788 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
1789 return False;
1790 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
1791 return False;
1792 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
1793 return False;
1795 return True;
1798 /*******************************************************************
1799 reads or writes a structure.
1800 ********************************************************************/
1801 BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps,
1802 int depth)
1804 if (r_s == NULL)
1805 return False;
1807 prs_debug(ps, depth, desc, "reg_io_r_shutdown");
1808 depth++;
1810 if(!prs_align(ps))
1811 return False;
1813 if(!prs_ntstatus("status", ps, depth, &r_s->status))
1814 return False;
1816 return True;
1819 /*******************************************************************
1820 Inits a structure.
1821 ********************************************************************/
1822 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s)
1825 q_s->ptr_server = 0;
1829 /*******************************************************************
1830 reads or writes a structure.
1831 ********************************************************************/
1832 BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN * q_s,
1833 prs_struct *ps, int depth)
1835 if (q_s == NULL)
1836 return False;
1838 prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
1839 depth++;
1841 if (!prs_align(ps))
1842 return False;
1844 if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
1845 return False;
1846 if (q_s->ptr_server != 0)
1847 if (!prs_uint16("server", ps, depth, &(q_s->server)))
1848 return False;
1850 return True;
1853 /*******************************************************************
1854 reads or writes a structure.
1855 ********************************************************************/
1856 BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN * r_s,
1857 prs_struct *ps, int depth)
1859 if (r_s == NULL)
1860 return False;
1862 prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
1863 depth++;
1865 if (!prs_align(ps))
1866 return False;
1868 if (!prs_ntstatus("status", ps, depth, &r_s->status))
1869 return False;
1871 return True;