sync with SAMBA_2_2
[Samba/gbeck.git] / source / rpc_parse / parse_reg.c
bloba7602434e54842687eb39000e628c056b9e03321
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
8 * Copyright (C) Marc Jacobsen 1999.
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.
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.
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.
26 #include "includes.h"
28 extern int DEBUGLEVEL;
31 /*******************************************************************
32 Inits a structure.
33 ********************************************************************/
35 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM *q_o,
36 uint16 unknown_0, uint32 level)
38 q_o->ptr = 1;
39 q_o->unknown_0 = unknown_0;
40 q_o->unknown_1 = 0x0; /* random - changes */
41 q_o->level = level;
44 /*******************************************************************
45 reads or writes a structure.
46 ********************************************************************/
48 BOOL reg_io_q_open_hklm(char *desc, REG_Q_OPEN_HKLM *r_q, prs_struct *ps, int depth)
50 if (r_q == NULL)
51 return False;
53 prs_debug(ps, depth, desc, "reg_io_q_open_hklm");
54 depth++;
56 if(!prs_align(ps))
57 return False;
59 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
60 return False;
62 if (r_q->ptr != 0) {
63 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0))
64 return False;
65 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
66 return False;
67 if(!prs_uint32("level ", ps, depth, &r_q->level))
68 return False;
71 return True;
75 /*******************************************************************
76 reads or writes a structure.
77 ********************************************************************/
79 BOOL reg_io_r_open_hklm(char *desc, REG_R_OPEN_HKLM *r_r, prs_struct *ps, int depth)
81 if (r_r == NULL)
82 return False;
84 prs_debug(ps, depth, desc, "reg_io_r_open_hklm");
85 depth++;
87 if(!prs_align(ps))
88 return False;
90 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
91 return False;
93 if(!prs_uint32("status", ps, depth, &r_r->status))
94 return False;
96 return True;
100 /*******************************************************************
101 Inits a structure.
102 ********************************************************************/
104 void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol)
106 memcpy(&q_u->pol, pol, sizeof(q_u->pol));
109 /*******************************************************************
110 reads or writes a structure.
111 ********************************************************************/
113 BOOL reg_io_q_flush_key(char *desc, REG_Q_FLUSH_KEY *r_q, prs_struct *ps, int depth)
115 if (r_q == NULL)
116 return False;
118 prs_debug(ps, depth, desc, "reg_io_q_flush_key");
119 depth++;
121 if(!prs_align(ps))
122 return False;
124 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
125 return False;
127 return True;
130 /*******************************************************************
131 reads or writes a structure.
132 ********************************************************************/
134 BOOL reg_io_r_flush_key(char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, int depth)
136 if (r_r == NULL)
137 return False;
139 prs_debug(ps, depth, desc, "reg_io_r_flush_key");
140 depth++;
142 if(!prs_align(ps))
143 return False;
145 if(!prs_uint32("status", ps, depth, &r_r->status))
146 return False;
148 return True;
151 /*******************************************************************
152 reads or writes SEC_DESC_BUF and SEC_DATA structures.
153 ********************************************************************/
155 static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DESC_BUF *data, prs_struct *ps, int depth)
157 if (ptr != 0) {
158 uint32 hdr_offset;
159 uint32 old_offset;
160 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset))
161 return False;
163 old_offset = prs_offset(ps);
165 if (ptr3 != NULL) {
166 if(!prs_uint32("ptr3", ps, depth, ptr3))
167 return False;
170 if (ptr3 == NULL || *ptr3 != 0) {
171 if(!sec_io_desc_buf("data ", &data, ps, depth)) /* JRA - this line is probably wrong... */
172 return False;
175 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset,
176 data->max_len, data->len))
177 return False;
178 if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3)))
179 return False;
181 if(!prs_align(ps))
182 return False;
185 return True;
188 /*******************************************************************
189 Inits a structure.
190 ********************************************************************/
192 void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd,
193 char *name, char *class, SEC_ACCESS *sam_access,
194 SEC_DESC_BUF *sec_buf)
196 int len_name = name != NULL ? strlen(name ) + 1: 0;
197 int len_class = class != NULL ? strlen(class) + 1: 0;
199 ZERO_STRUCTP(q_c);
201 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
203 init_uni_hdr(&q_c->hdr_name, len_name);
204 init_unistr2(&q_c->uni_name, name, len_name);
206 init_uni_hdr(&q_c->hdr_class, len_class);
207 init_unistr2(&q_c->uni_class, class, len_class);
209 q_c->reserved = 0x00000000;
210 memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access));
212 q_c->ptr1 = 1;
213 q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
215 q_c->data = sec_buf;
216 q_c->ptr2 = 1;
217 init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len);
218 q_c->ptr3 = 1;
219 q_c->unknown_2 = 0x00000000;
222 /*******************************************************************
223 reads or writes a structure.
224 ********************************************************************/
226 BOOL reg_io_q_create_key(char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth)
228 if (r_q == NULL)
229 return False;
231 prs_debug(ps, depth, desc, "reg_io_q_create_key");
232 depth++;
234 if(!prs_align(ps))
235 return False;
237 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
238 return False;
240 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
241 return False;
242 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
243 return False;
244 if(!prs_align(ps))
245 return False;
247 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
248 return False;
249 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
250 return False;
251 if(!prs_align(ps))
252 return False;
254 if(!prs_uint32("reserved", ps, depth, &r_q->reserved))
255 return False;
256 if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth))
257 return False;
259 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
260 return False;
262 if (r_q->ptr1 != 0) {
263 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
264 return False;
267 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
268 return False;
269 if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth))
270 return False;
272 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
273 return False;
275 return True;
278 /*******************************************************************
279 reads or writes a structure.
280 ********************************************************************/
282 BOOL reg_io_r_create_key(char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth)
284 if (r_r == NULL)
285 return False;
287 prs_debug(ps, depth, desc, "reg_io_r_create_key");
288 depth++;
290 if(!prs_align(ps))
291 return False;
293 if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth))
294 return False;
295 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
296 return False;
298 if(!prs_uint32("status", ps, depth, &r_r->status))
299 return False;
301 return True;
305 /*******************************************************************
306 Inits a structure.
307 ********************************************************************/
309 void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd,
310 char *name)
312 int len_name = name != NULL ? strlen(name ) + 1: 0;
313 ZERO_STRUCTP(q_c);
315 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
317 init_uni_hdr(&q_c->hdr_name, len_name);
318 init_unistr2(&q_c->uni_name, name, len_name);
321 /*******************************************************************
322 reads or writes a structure.
323 ********************************************************************/
325 BOOL reg_io_q_delete_val(char *desc, REG_Q_DELETE_VALUE *r_q, prs_struct *ps, int depth)
327 if (r_q == NULL)
328 return False;
330 prs_debug(ps, depth, desc, "reg_io_q_delete_val");
331 depth++;
333 if(!prs_align(ps))
334 return False;
336 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
337 return False;
339 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
340 return False;
341 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
342 return False;
343 if(!prs_align(ps))
344 return False;
346 return True;
350 /*******************************************************************
351 reads or writes a structure.
352 ********************************************************************/
354 BOOL reg_io_r_delete_val(char *desc, REG_R_DELETE_VALUE *r_r, prs_struct *ps, int depth)
356 if (r_r == NULL)
357 return False;
359 prs_debug(ps, depth, desc, "reg_io_r_delete_val");
360 depth++;
362 if(!prs_align(ps))
363 return False;
365 if(!prs_uint32("status", ps, depth, &r_r->status))
366 return False;
368 return True;
371 /*******************************************************************
372 Inits a structure.
373 ********************************************************************/
375 void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
376 char *name)
378 int len_name = name != NULL ? strlen(name ) + 1: 0;
379 ZERO_STRUCTP(q_c);
381 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
383 init_uni_hdr(&q_c->hdr_name, len_name);
384 init_unistr2(&q_c->uni_name, name, len_name);
387 /*******************************************************************
388 reads or writes a structure.
389 ********************************************************************/
391 BOOL reg_io_q_delete_key(char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth)
393 if (r_q == NULL)
394 return False;
396 prs_debug(ps, depth, desc, "reg_io_q_delete_key");
397 depth++;
399 if(!prs_align(ps))
400 return False;
402 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
403 return False;
405 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
406 return False;
407 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
408 return False;
409 if(!prs_align(ps))
410 return False;
412 return True;
415 /*******************************************************************
416 reads or writes a structure.
417 ********************************************************************/
419 BOOL reg_io_r_delete_key(char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth)
421 if (r_r == NULL)
422 return False;
424 prs_debug(ps, depth, desc, "reg_io_r_delete_key");
425 depth++;
427 if(!prs_align(ps))
428 return False;
430 if(!prs_uint32("status", ps, depth, &r_r->status))
431 return False;
433 return True;
436 /*******************************************************************
437 Inits a structure.
438 ********************************************************************/
440 void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd,
441 uint32 max_class_len)
443 ZERO_STRUCTP(q_o);
445 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
446 init_uni_hdr(&q_o->hdr_class, max_class_len);
447 q_o->uni_class.uni_max_len = max_class_len;
450 /*******************************************************************
451 reads or writes a structure.
452 ********************************************************************/
454 BOOL reg_io_q_query_key(char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth)
456 if (r_q == NULL)
457 return False;
459 prs_debug(ps, depth, desc, "reg_io_q_query_key");
460 depth++;
462 if(!prs_align(ps))
463 return False;
465 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
466 return False;
467 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
468 return False;
469 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
470 return False;
472 if(!prs_align(ps))
473 return False;
475 return True;
479 /*******************************************************************
480 reads or writes a structure.
481 ********************************************************************/
483 BOOL reg_io_r_query_key(char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth)
485 if (r_r == NULL)
486 return False;
488 prs_debug(ps, depth, desc, "reg_io_r_query_key");
489 depth++;
491 if(!prs_align(ps))
492 return False;
494 if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth))
495 return False;
496 if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth))
497 return False;
499 if(!prs_align(ps))
500 return False;
502 if(!prs_uint32("num_subkeys ", ps, depth, &r_r->num_subkeys))
503 return False;
504 if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen))
505 return False;
506 if(!prs_uint32("mak_subkeysize", ps, depth, &r_r->max_subkeysize))
507 return False;
508 if(!prs_uint32("num_values ", ps, depth, &r_r->num_values))
509 return False;
510 if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen))
511 return False;
512 if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize))
513 return False;
514 if(!prs_uint32("sec_desc ", ps, depth, &r_r->sec_desc))
515 return False;
516 if(!smb_io_time("mod_time ", &r_r->mod_time, ps, depth))
517 return False;
519 if(!prs_uint32("status", ps, depth, &r_r->status))
520 return False;
522 return True;
525 /*******************************************************************
526 Inits a structure.
527 ********************************************************************/
529 void init_reg_q_unk_1a(REG_Q_UNK_1A *q_o, POLICY_HND *hnd)
531 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
534 /*******************************************************************
535 reads or writes a structure.
536 ********************************************************************/
538 BOOL reg_io_q_unk_1a(char *desc, REG_Q_UNK_1A *r_q, prs_struct *ps, int depth)
540 if (r_q == NULL)
541 return False;
543 prs_debug(ps, depth, desc, "reg_io_q_unk_1a");
544 depth++;
546 if(!prs_align(ps))
547 return False;
549 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
550 return False;
552 return True;
555 /*******************************************************************
556 reads or writes a structure.
557 ********************************************************************/
559 BOOL reg_io_r_unk_1a(char *desc, REG_R_UNK_1A *r_r, prs_struct *ps, int depth)
561 if (r_r == NULL)
562 return False;
564 prs_debug(ps, depth, desc, "reg_io_r_unk_1a");
565 depth++;
567 if(!prs_align(ps))
568 return False;
570 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
571 return False;
572 if(!prs_uint32("status" , ps, depth, &r_r->status))
573 return False;
575 return True;
578 /*******************************************************************
579 Inits a structure.
580 ********************************************************************/
582 void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o,
583 uint16 unknown_0, uint32 level)
585 q_o->ptr = 1;
586 q_o->unknown_0 = unknown_0;
587 q_o->unknown_1 = 0x0; /* random - changes */
588 q_o->level = level;
591 /*******************************************************************
592 reads or writes a structure.
593 ********************************************************************/
595 BOOL reg_io_q_open_hku(char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth)
597 if (r_q == NULL)
598 return False;
600 prs_debug(ps, depth, desc, "reg_io_q_open_hku");
601 depth++;
603 if(!prs_align(ps))
604 return False;
606 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
607 return False;
608 if (r_q->ptr != 0) {
609 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0))
610 return False;
611 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
612 return False;
613 if(!prs_uint32("level ", ps, depth, &r_q->level))
614 return False;
617 return True;
620 /*******************************************************************
621 reads or writes a structure.
622 ********************************************************************/
624 BOOL reg_io_r_open_hku(char *desc, REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth)
626 if (r_r == NULL)
627 return False;
629 prs_debug(ps, depth, desc, "reg_io_r_open_hku");
630 depth++;
632 if(!prs_align(ps))
633 return False;
635 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
636 return False;
638 if(!prs_uint32("status", ps, depth, &r_r->status))
639 return False;
641 return True;
644 /*******************************************************************
645 Inits an REG_Q_CLOSE structure.
646 ********************************************************************/
648 void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
650 DEBUG(5,("init_reg_q_close\n"));
652 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
655 /*******************************************************************
656 reads or writes a structure.
657 ********************************************************************/
659 BOOL reg_io_q_close(char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
661 if (q_u == NULL)
662 return False;
664 prs_debug(ps, depth, desc, "reg_io_q_unknown_1");
665 depth++;
667 if(!prs_align(ps))
668 return False;
670 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
671 return False;
672 if(!prs_align(ps))
673 return False;
675 return True;
678 /*******************************************************************
679 reads or writes a structure.
680 ********************************************************************/
682 BOOL reg_io_r_close(char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth)
684 if (r_u == NULL)
685 return False;
687 prs_debug(ps, depth, desc, "reg_io_r_unknown_1");
688 depth++;
690 if(!prs_align(ps))
691 return False;
693 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
694 return False;
695 if(!prs_align(ps))
696 return False;
698 if(!prs_uint32("status", ps, depth, &r_u->status))
699 return False;
701 return True;
704 /*******************************************************************
705 makes a structure.
706 ********************************************************************/
708 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf)
710 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
712 q_i->sec_info = DACL_SECURITY_INFORMATION;
714 q_i->ptr = 1;
715 init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len);
716 q_i->data = sec_desc_buf;
719 /*******************************************************************
720 reads or writes a structure.
721 ********************************************************************/
723 BOOL reg_io_q_set_key_sec(char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
725 if (r_q == NULL)
726 return False;
728 prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
729 depth++;
731 if(!prs_align(ps))
732 return False;
734 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
735 return False;
737 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
738 return False;
739 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
740 return False;
742 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
743 return False;
745 return True;
748 /*******************************************************************
749 reads or writes a structure.
750 ********************************************************************/
752 BOOL reg_io_r_set_key_sec(char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
754 if (r_q == NULL)
755 return False;
757 prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
758 depth++;
760 if(!prs_align(ps))
761 return False;
763 if(!prs_uint32("status", ps, depth, &r_q->status))
764 return False;
766 return True;
770 /*******************************************************************
771 makes a structure.
772 ********************************************************************/
774 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol,
775 uint32 sec_buf_size, SEC_DESC_BUF *psdb)
777 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
779 q_i->sec_info = OWNER_SECURITY_INFORMATION |
780 GROUP_SECURITY_INFORMATION |
781 DACL_SECURITY_INFORMATION;
783 q_i->ptr = psdb != NULL ? 1 : 0;
784 q_i->data = psdb;
786 init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0);
789 /*******************************************************************
790 reads or writes a structure.
791 ********************************************************************/
793 BOOL reg_io_q_get_key_sec(char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
795 if (r_q == NULL)
796 return False;
798 prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
799 depth++;
801 if(!prs_align(ps))
802 return False;
804 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
805 return False;
807 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
808 return False;
809 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
810 return False;
812 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
813 return False;
815 return True;
818 #if 0
819 /*******************************************************************
820 makes a structure.
821 ********************************************************************/
822 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
823 uint32 buf_len, uint8 *buf,
824 uint32 status)
826 r_i->ptr = 1;
827 init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len);
828 init_sec_desc_buf(r_i->data, buf_len, 1);
830 r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
832 #endif
834 /*******************************************************************
835 reads or writes a structure.
836 ********************************************************************/
838 BOOL reg_io_r_get_key_sec(char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
840 if (r_q == NULL)
841 return False;
843 prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
844 depth++;
846 if(!prs_align(ps))
847 return False;
849 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
850 return False;
852 if (r_q->ptr != 0) {
853 if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth))
854 return False;
855 if(!sec_io_desc_buf("", &r_q->data, ps, depth))
856 return False;
857 if(!prs_align(ps))
858 return False;
861 if(!prs_uint32("status", ps, depth, &r_q->status))
862 return False;
864 return True;
867 /*******************************************************************
868 makes a structure.
869 ********************************************************************/
871 BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name)
873 int len_type = val_name != NULL ? strlen(val_name) + 1 : 0;
875 if (q_i == NULL)
876 return False;
878 q_i->pol = *pol;
880 init_uni_hdr(&(q_i->hdr_type), len_type);
881 init_unistr2(&(q_i->uni_type), val_name, len_type);
883 q_i->ptr_reserved = 1;
884 q_i->ptr_buf = 1;
886 q_i->ptr_bufsize = 1;
887 q_i->bufsize = 0;
888 q_i->buf_unk = 0;
890 q_i->unk1 = 0;
891 q_i->ptr_buflen = 1;
892 q_i->buflen = 0;
894 q_i->ptr_buflen2 = 1;
895 q_i->buflen2 = 0;
897 return True;
900 /*******************************************************************
901 reads or writes a structure.
902 ********************************************************************/
904 BOOL reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth)
906 if (r_q == NULL)
907 return False;
909 prs_debug(ps, depth, desc, "reg_io_q_info");
910 depth++;
912 if(!prs_align(ps))
913 return False;
915 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
916 return False;
917 if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth))
918 return False;
919 if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth))
920 return False;
922 if(!prs_align(ps))
923 return False;
925 if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved)))
926 return False;
928 if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf)))
929 return False;
931 if(r_q->ptr_buf) {
932 if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize)))
933 return False;
934 if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize)))
935 return False;
936 if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk)))
937 return False;
940 if(!prs_uint32("unk1", ps, depth, &(r_q->unk1)))
941 return False;
943 if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen)))
944 return False;
945 if(!prs_uint32("buflen", ps, depth, &(r_q->buflen)))
946 return False;
948 if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2)))
949 return False;
950 if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2)))
951 return False;
953 return True;
956 /*******************************************************************
957 Inits a structure.
958 ********************************************************************/
960 BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
961 BUFFER2* buf, uint32 type, uint32 status)
963 if(r_r == NULL)
964 return False;
967 r_r->ptr_type = 1;
968 r_r->type = type;
970 /* if include_keyval is not set, don't send the key value, just
971 the buflen data. probably used by NT5 to allocate buffer space - SK */
972 r_r->ptr_uni_val = include_keyval ? 1:0;
973 r_r->uni_val = buf;
975 r_r->ptr_max_len = 1;
976 r_r->buf_max_len = r_r->uni_val->buf_max_len;
978 r_r->ptr_len = 1;
979 r_r->buf_len = r_r->uni_val->buf_len;
981 r_r->status = status;
983 return True;
987 /*******************************************************************
988 reads or writes a structure.
989 ********************************************************************/
991 BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
993 if (r_r == NULL)
994 return False;
996 prs_debug(ps, depth, desc, "reg_io_r_info");
997 depth++;
999 if(!prs_align(ps))
1000 return False;
1002 if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type)))
1003 return False;
1005 if (r_r->ptr_type != 0) {
1006 if(!prs_uint32("type", ps, depth, &r_r->type))
1007 return False;
1010 if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val)))
1011 return False;
1013 if(r_r->ptr_uni_val != 0) {
1014 if(!smb_io_buffer2("uni_val", r_r->uni_val, r_r->ptr_uni_val, ps, depth))
1015 return False;
1018 if(!prs_align(ps))
1019 return False;
1021 if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len)))
1022 return False;
1024 if (r_r->ptr_max_len != 0) {
1025 if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len)))
1026 return False;
1029 if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len)))
1030 return False;
1031 if (r_r->ptr_len != 0) {
1032 if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len)))
1033 return False;
1036 if(!prs_uint32("status", ps, depth, &r_r->status))
1037 return False;
1039 return True;
1042 /*******************************************************************
1043 makes a structure.
1044 ********************************************************************/
1046 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
1047 uint32 val_idx, uint32 max_val_len,
1048 uint32 max_buf_len)
1050 ZERO_STRUCTP(q_i);
1052 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1054 q_i->val_index = val_idx;
1055 init_uni_hdr(&q_i->hdr_name, max_val_len);
1056 q_i->uni_name.uni_max_len = max_val_len;
1058 q_i->ptr_type = 1;
1059 q_i->type = 0x0;
1061 q_i->ptr_value = 1;
1062 q_i->buf_value.buf_max_len = max_buf_len;
1064 q_i->ptr1 = 1;
1065 q_i->len_value1 = max_buf_len;
1067 q_i->ptr2 = 1;
1068 q_i->len_value2 = 0;
1071 /*******************************************************************
1072 reads or writes a structure.
1073 ********************************************************************/
1075 BOOL reg_io_q_enum_val(char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth)
1077 if (q_q == NULL)
1078 return False;
1080 prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1081 depth++;
1083 if(!prs_align(ps))
1084 return False;
1086 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1087 return False;
1089 if(!prs_uint32("val_index", ps, depth, &q_q->val_index))
1090 return False;
1091 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1092 return False;
1093 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1094 return False;
1095 if(!prs_align(ps))
1096 return False;
1098 if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type))
1099 return False;
1101 if (q_q->ptr_type != 0) {
1102 if(!prs_uint32("type", ps, depth, &q_q->type))
1103 return False;
1106 if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value))
1107 return False;
1108 if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth))
1109 return False;
1110 if(!prs_align(ps))
1111 return False;
1113 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1114 return False;
1115 if (q_q->ptr1 != 0) {
1116 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1))
1117 return False;
1119 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1120 return False;
1121 if (q_q->ptr2 != 0) {
1122 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2))
1123 return False;
1126 return True;
1129 /*******************************************************************
1130 reads or writes a structure.
1131 ********************************************************************/
1133 BOOL reg_io_r_enum_val(char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth)
1135 if (r_q == NULL)
1136 return False;
1138 prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1139 depth++;
1141 if(!prs_align(ps))
1142 return False;
1144 if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth))
1145 return False;
1146 if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1147 return False;
1148 if(!prs_align(ps))
1149 return False;
1151 if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type))
1152 return False;
1154 if (r_q->ptr_type != 0) {
1155 if(!prs_uint32("type", ps, depth, &r_q->type))
1156 return False;
1159 if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value))
1160 return False;
1161 if(!smb_io_buffer2("buf_value", r_q->buf_value, r_q->ptr_value, ps, depth))
1162 return False;
1163 if(!prs_align(ps))
1164 return False;
1166 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1167 return False;
1168 if (r_q->ptr1 != 0) {
1169 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1))
1170 return False;
1173 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1174 return False;
1175 if (r_q->ptr2 != 0) {
1176 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2))
1177 return False;
1180 if(!prs_uint32("status", ps, depth, &r_q->status))
1181 return False;
1183 return True;
1186 /*******************************************************************
1187 makes a structure.
1188 ********************************************************************/
1190 void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
1191 char *val_name, uint32 type,
1192 BUFFER3 *val)
1194 int val_len = strlen(val_name) + 1;
1196 ZERO_STRUCTP(q_i);
1198 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1200 init_uni_hdr(&q_i->hdr_name, val_len);
1201 init_unistr2(&q_i->uni_name, val_name, val_len);
1203 q_i->type = type;
1204 q_i->buf_value = val;
1207 /*******************************************************************
1208 reads or writes a structure.
1209 ********************************************************************/
1211 BOOL reg_io_q_create_val(char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth)
1213 if (q_q == NULL)
1214 return False;
1216 prs_debug(ps, depth, desc, "reg_io_q_create_val");
1217 depth++;
1219 if(!prs_align(ps))
1220 return False;
1222 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1223 return False;
1225 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1226 return False;
1227 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1228 return False;
1229 if(!prs_align(ps))
1230 return False;
1232 if(!prs_uint32("type", ps, depth, &q_q->type))
1233 return False;
1234 if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth))
1235 return False;
1236 if(!prs_align(ps))
1237 return False;
1239 return True;
1242 /*******************************************************************
1243 reads or writes a structure.
1244 ********************************************************************/
1246 BOOL reg_io_r_create_val(char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth)
1248 if (r_q == NULL)
1249 return False;
1251 prs_debug(ps, depth, desc, "reg_io_r_create_val");
1252 depth++;
1254 if(!prs_align(ps))
1255 return False;
1257 if(!prs_uint32("status", ps, depth, &r_q->status))
1258 return False;
1260 return True;
1263 /*******************************************************************
1264 makes a structure.
1265 ********************************************************************/
1267 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx)
1269 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1271 q_i->key_index = key_idx;
1272 q_i->key_name_len = 0;
1273 q_i->unknown_1 = 0x0414;
1275 q_i->ptr1 = 1;
1276 q_i->unknown_2 = 0x0000020A;
1277 memset(q_i->pad1, 0, sizeof(q_i->pad1));
1279 q_i->ptr2 = 1;
1280 memset(q_i->pad2, 0, sizeof(q_i->pad2));
1282 q_i->ptr3 = 1;
1283 unix_to_nt_time(&q_i->time, 0); /* current time? */
1286 /*******************************************************************
1287 reads or writes a structure.
1288 ********************************************************************/
1290 BOOL reg_io_q_enum_key(char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth)
1292 if (q_q == NULL)
1293 return False;
1295 prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1296 depth++;
1298 if(!prs_align(ps))
1299 return False;
1301 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1302 return False;
1304 if(!prs_uint32("key_index", ps, depth, &q_q->key_index))
1305 return False;
1306 if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len))
1307 return False;
1308 if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1))
1309 return False;
1311 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1312 return False;
1314 if (q_q->ptr1 != 0) {
1315 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2))
1316 return False;
1317 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)))
1318 return False;
1321 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1322 return False;
1324 if (q_q->ptr2 != 0) {
1325 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)))
1326 return False;
1329 if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3))
1330 return False;
1332 if (q_q->ptr3 != 0) {
1333 if(!smb_io_time("", &q_q->time, ps, depth))
1334 return False;
1337 return True;
1340 /*******************************************************************
1341 reads or writes a structure.
1342 ********************************************************************/
1344 BOOL reg_io_r_enum_key(char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth)
1346 if (r_q == NULL)
1347 return False;
1349 prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1350 depth++;
1352 if(!prs_align(ps))
1353 return False;
1355 if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len))
1356 return False;
1357 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
1358 return False;
1360 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1361 return False;
1363 if (r_q->ptr1 != 0) {
1364 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
1365 return False;
1366 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3))
1367 return False;
1368 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth))
1369 return False;
1370 if(!prs_align(ps))
1371 return False;
1374 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1375 return False;
1377 if (r_q->ptr2 != 0) {
1378 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
1379 return False;
1382 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
1383 return False;
1385 if (r_q->ptr3 != 0) {
1386 if(!smb_io_time("", &r_q->time, ps, depth))
1387 return False;
1390 if(!prs_uint32("status", ps, depth, &r_q->status))
1391 return False;
1393 return True;
1396 /*******************************************************************
1397 makes a structure.
1398 ********************************************************************/
1400 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
1401 char *key_name, uint32 unk)
1403 int len_name = strlen(key_name)+1;
1405 memcpy(&r_q->pol, pol, sizeof(r_q->pol));
1407 init_uni_hdr(&r_q->hdr_name, len_name);
1408 init_unistr2(&r_q->uni_name, key_name, len_name);
1410 r_q->unknown_0 = 0x00000000;
1411 r_q->unknown_1 = unk;
1414 /*******************************************************************
1415 reads or writes a structure.
1416 ********************************************************************/
1418 BOOL reg_io_q_open_entry(char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
1420 if (r_q == NULL)
1421 return False;
1423 prs_debug(ps, depth, desc, "reg_io_q_entry");
1424 depth++;
1426 if(!prs_align(ps))
1427 return False;
1429 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1430 return False;
1431 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
1432 return False;
1433 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1434 return False;
1436 if(!prs_align(ps))
1437 return False;
1439 if(!prs_uint32("unknown_0", ps, depth, &r_q->unknown_0))
1440 return False;
1441 if(!prs_uint32("unknown_1", ps, depth, &r_q->unknown_1))
1442 return False;
1444 return True;
1447 /*******************************************************************
1448 Inits a structure.
1449 ********************************************************************/
1451 void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
1452 POLICY_HND *pol, uint32 status)
1454 memcpy(&r_r->pol, pol, sizeof(r_r->pol));
1455 r_r->status = status;
1458 /*******************************************************************
1459 reads or writes a structure.
1460 ********************************************************************/
1462 BOOL reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
1464 if (r_r == NULL)
1465 return False;
1467 prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1468 depth++;
1470 if(!prs_align(ps))
1471 return False;
1473 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
1474 return False;
1476 if(!prs_uint32("status", ps, depth, &r_r->status))
1477 return False;
1479 return True;