Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / samba / source / rpc_parse / parse_reg.c
blobcc970e41500120b4075b9964b4a91a05cf173217
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) Hewlett-Packard Company 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 void init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char *product_type,
872 time_t unix_time, uint8 major, uint8 minor)
874 int len_type = strlen(product_type);
876 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
878 init_uni_hdr(&q_i->hdr_type, len_type);
879 init_unistr2(&q_i->uni_type, product_type, len_type);
881 q_i->ptr1 = 1;
882 unix_to_nt_time(&q_i->time, unix_time);
883 q_i->major_version1 = major;
884 q_i->minor_version1 = minor;
885 memset(q_i->pad1, 0, sizeof(q_i->pad1));
887 q_i->ptr2 = 1;
888 q_i->major_version2 = major;
889 q_i->minor_version2 = minor;
890 memset(q_i->pad2, 0, sizeof(q_i->pad2));
892 q_i->ptr3 = 1;
893 q_i->unknown = 0x00000000;
896 /*******************************************************************
897 reads or writes a structure.
898 ********************************************************************/
900 BOOL reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth)
902 if (r_q == NULL)
903 return False;
905 prs_debug(ps, depth, desc, "reg_io_q_info");
906 depth++;
908 if(!prs_align(ps))
909 return False;
911 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
912 return False;
913 if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth))
914 return False;
915 if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth))
916 return False;
918 if(!prs_align(ps))
919 return False;
921 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
922 return False;
924 if (r_q->ptr1 != 0) {
925 if(!smb_io_time("", &r_q->time, ps, depth))
926 return False;
927 if(!prs_uint8 ("major_version1", ps, depth, &r_q->major_version1))
928 return False;
929 if(!prs_uint8 ("minor_version1", ps, depth, &r_q->minor_version1))
930 return False;
931 if(!prs_uint8s(False, "pad1", ps, depth, r_q->pad1, sizeof(r_q->pad1)))
932 return False;
935 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
936 return False;
938 if (r_q->ptr2 != 0) {
939 if(!prs_uint8 ("major_version2", ps, depth, &r_q->major_version2))
940 return False;
941 if(!prs_uint8 ("minor_version2", ps, depth, &r_q->minor_version2))
942 return False;
943 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
944 return False;
947 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
948 return False;
950 if (r_q->ptr3 != 0) {
951 if(!prs_uint32("unknown", ps, depth, &r_q->unknown))
952 return False;
955 return True;
958 /*******************************************************************
959 Inits a structure.
960 ********************************************************************/
962 void init_reg_r_info(REG_R_INFO *r_r,
963 uint32 level, char *os_type,
964 uint32 unknown_0, uint32 unknown_1,
965 uint32 status)
967 uint8 buf[512];
968 int len = dos_struni2((char *)buf, os_type, sizeof(buf));
970 r_r->ptr1 = 1;
971 r_r->level = level;
973 r_r->ptr_type = 1;
974 init_buffer2(&r_r->uni_type, buf, len*2);
976 r_r->ptr2 = 1;
977 r_r->unknown_0 = unknown_0;
979 r_r->ptr3 = 1;
980 r_r->unknown_1 = unknown_1;
982 r_r->status = status;
985 /*******************************************************************
986 reads or writes a structure.
987 ********************************************************************/
989 BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
991 if (r_r == NULL)
992 return False;
994 prs_debug(ps, depth, desc, "reg_io_r_info");
995 depth++;
997 if(!prs_align(ps))
998 return False;
1000 if(!prs_uint32("ptr1", ps, depth, &r_r->ptr1))
1001 return False;
1003 if (r_r->ptr1 != 0) {
1004 if(!prs_uint32("level", ps, depth, &r_r->level))
1005 return False;
1006 if(!prs_uint32("ptr_type", ps, depth, &r_r->ptr_type))
1007 return False;
1009 if(!smb_io_buffer2("uni_type", &r_r->uni_type, r_r->ptr_type, ps, depth))
1010 return False;
1011 if(!prs_align(ps))
1012 return False;
1014 if(!prs_uint32("ptr2", ps, depth, &r_r->ptr2))
1015 return False;
1017 if (r_r->ptr2 != 0) {
1018 if(!prs_uint32("unknown_0", ps, depth, &r_r->unknown_0))
1019 return False;
1022 if(!prs_uint32("ptr3", ps, depth, &r_r->ptr3))
1023 return False;
1025 if (r_r->ptr3 != 0) {
1026 if(!prs_uint32("unknown_1", ps, depth, &r_r->unknown_1))
1027 return False;
1031 if(!prs_uint32("status", ps, depth, &r_r->status))
1032 return False;
1034 return True;
1037 /*******************************************************************
1038 makes a structure.
1039 ********************************************************************/
1041 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
1042 uint32 val_idx, uint32 max_val_len,
1043 uint32 max_buf_len)
1045 ZERO_STRUCTP(q_i);
1047 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1049 q_i->val_index = val_idx;
1050 init_uni_hdr(&q_i->hdr_name, max_val_len);
1051 q_i->uni_name.uni_max_len = max_val_len;
1053 q_i->ptr_type = 1;
1054 q_i->type = 0x0;
1056 q_i->ptr_value = 1;
1057 q_i->buf_value.buf_max_len = max_buf_len;
1059 q_i->ptr1 = 1;
1060 q_i->len_value1 = max_buf_len;
1062 q_i->ptr2 = 1;
1063 q_i->len_value2 = 0;
1066 /*******************************************************************
1067 reads or writes a structure.
1068 ********************************************************************/
1070 BOOL reg_io_q_enum_val(char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth)
1072 if (q_q == NULL)
1073 return False;
1075 prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1076 depth++;
1078 if(!prs_align(ps))
1079 return False;
1081 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1082 return False;
1084 if(!prs_uint32("val_index", ps, depth, &q_q->val_index))
1085 return False;
1086 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1087 return False;
1088 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1089 return False;
1090 if(!prs_align(ps))
1091 return False;
1093 if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type))
1094 return False;
1096 if (q_q->ptr_type != 0) {
1097 if(!prs_uint32("type", ps, depth, &q_q->type))
1098 return False;
1101 if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value))
1102 return False;
1103 if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth))
1104 return False;
1105 if(!prs_align(ps))
1106 return False;
1108 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1109 return False;
1110 if (q_q->ptr1 != 0) {
1111 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1))
1112 return False;
1114 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1115 return False;
1116 if (q_q->ptr2 != 0) {
1117 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2))
1118 return False;
1121 return True;
1124 /*******************************************************************
1125 reads or writes a structure.
1126 ********************************************************************/
1128 BOOL reg_io_r_enum_val(char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth)
1130 if (r_q == NULL)
1131 return False;
1133 prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1134 depth++;
1136 if(!prs_align(ps))
1137 return False;
1139 if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth))
1140 return False;
1141 if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1142 return False;
1143 if(!prs_align(ps))
1144 return False;
1146 if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type))
1147 return False;
1149 if (r_q->ptr_type != 0) {
1150 if(!prs_uint32("type", ps, depth, &r_q->type))
1151 return False;
1154 if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value))
1155 return False;
1156 if(!smb_io_buffer2("buf_value", r_q->buf_value, r_q->ptr_value, ps, depth))
1157 return False;
1158 if(!prs_align(ps))
1159 return False;
1161 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1162 return False;
1163 if (r_q->ptr1 != 0) {
1164 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1))
1165 return False;
1168 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1169 return False;
1170 if (r_q->ptr2 != 0) {
1171 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2))
1172 return False;
1175 if(!prs_uint32("status", ps, depth, &r_q->status))
1176 return False;
1178 return True;
1181 /*******************************************************************
1182 makes a structure.
1183 ********************************************************************/
1185 void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
1186 char *val_name, uint32 type,
1187 BUFFER3 *val)
1189 int val_len = strlen(val_name) + 1;
1191 ZERO_STRUCTP(q_i);
1193 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1195 init_uni_hdr(&q_i->hdr_name, val_len);
1196 init_unistr2(&q_i->uni_name, val_name, val_len);
1198 q_i->type = type;
1199 q_i->buf_value = val;
1202 /*******************************************************************
1203 reads or writes a structure.
1204 ********************************************************************/
1206 BOOL reg_io_q_create_val(char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth)
1208 if (q_q == NULL)
1209 return False;
1211 prs_debug(ps, depth, desc, "reg_io_q_create_val");
1212 depth++;
1214 if(!prs_align(ps))
1215 return False;
1217 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1218 return False;
1220 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1221 return False;
1222 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1223 return False;
1224 if(!prs_align(ps))
1225 return False;
1227 if(!prs_uint32("type", ps, depth, &q_q->type))
1228 return False;
1229 if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth))
1230 return False;
1231 if(!prs_align(ps))
1232 return False;
1234 return True;
1237 /*******************************************************************
1238 reads or writes a structure.
1239 ********************************************************************/
1241 BOOL reg_io_r_create_val(char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth)
1243 if (r_q == NULL)
1244 return False;
1246 prs_debug(ps, depth, desc, "reg_io_r_create_val");
1247 depth++;
1249 if(!prs_align(ps))
1250 return False;
1252 if(!prs_uint32("status", ps, depth, &r_q->status))
1253 return False;
1255 return True;
1258 /*******************************************************************
1259 makes a structure.
1260 ********************************************************************/
1262 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx)
1264 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1266 q_i->key_index = key_idx;
1267 q_i->key_name_len = 0;
1268 q_i->unknown_1 = 0x0414;
1270 q_i->ptr1 = 1;
1271 q_i->unknown_2 = 0x0000020A;
1272 memset(q_i->pad1, 0, sizeof(q_i->pad1));
1274 q_i->ptr2 = 1;
1275 memset(q_i->pad2, 0, sizeof(q_i->pad2));
1277 q_i->ptr3 = 1;
1278 unix_to_nt_time(&q_i->time, 0); /* current time? */
1281 /*******************************************************************
1282 reads or writes a structure.
1283 ********************************************************************/
1285 BOOL reg_io_q_enum_key(char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth)
1287 if (q_q == NULL)
1288 return False;
1290 prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1291 depth++;
1293 if(!prs_align(ps))
1294 return False;
1296 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1297 return False;
1299 if(!prs_uint32("key_index", ps, depth, &q_q->key_index))
1300 return False;
1301 if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len))
1302 return False;
1303 if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1))
1304 return False;
1306 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1307 return False;
1309 if (q_q->ptr1 != 0) {
1310 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2))
1311 return False;
1312 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)))
1313 return False;
1316 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1317 return False;
1319 if (q_q->ptr2 != 0) {
1320 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)))
1321 return False;
1324 if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3))
1325 return False;
1327 if (q_q->ptr3 != 0) {
1328 if(!smb_io_time("", &q_q->time, ps, depth))
1329 return False;
1332 return True;
1335 /*******************************************************************
1336 reads or writes a structure.
1337 ********************************************************************/
1339 BOOL reg_io_r_enum_key(char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth)
1341 if (r_q == NULL)
1342 return False;
1344 prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1345 depth++;
1347 if(!prs_align(ps))
1348 return False;
1350 if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len))
1351 return False;
1352 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
1353 return False;
1355 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1356 return False;
1358 if (r_q->ptr1 != 0) {
1359 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
1360 return False;
1361 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3))
1362 return False;
1363 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth))
1364 return False;
1365 if(!prs_align(ps))
1366 return False;
1369 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1370 return False;
1372 if (r_q->ptr2 != 0) {
1373 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
1374 return False;
1377 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
1378 return False;
1380 if (r_q->ptr3 != 0) {
1381 if(!smb_io_time("", &r_q->time, ps, depth))
1382 return False;
1385 if(!prs_uint32("status", ps, depth, &r_q->status))
1386 return False;
1388 return True;
1391 /*******************************************************************
1392 makes a structure.
1393 ********************************************************************/
1395 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
1396 char *key_name, uint32 unk)
1398 int len_name = strlen(key_name)+1;
1400 memcpy(&r_q->pol, pol, sizeof(r_q->pol));
1402 init_uni_hdr(&r_q->hdr_name, len_name);
1403 init_unistr2(&r_q->uni_name, key_name, len_name);
1405 r_q->unknown_0 = 0x00000000;
1406 r_q->unknown_1 = unk;
1409 /*******************************************************************
1410 reads or writes a structure.
1411 ********************************************************************/
1413 BOOL reg_io_q_open_entry(char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
1415 if (r_q == NULL)
1416 return False;
1418 prs_debug(ps, depth, desc, "reg_io_q_entry");
1419 depth++;
1421 if(!prs_align(ps))
1422 return False;
1424 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1425 return False;
1426 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
1427 return False;
1428 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1429 return False;
1431 if(!prs_align(ps))
1432 return False;
1434 if(!prs_uint32("unknown_0", ps, depth, &r_q->unknown_0))
1435 return False;
1436 if(!prs_uint32("unknown_1", ps, depth, &r_q->unknown_1))
1437 return False;
1439 return True;
1442 /*******************************************************************
1443 Inits a structure.
1444 ********************************************************************/
1446 void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
1447 POLICY_HND *pol, uint32 status)
1449 memcpy(&r_r->pol, pol, sizeof(r_r->pol));
1450 r_r->status = status;
1453 /*******************************************************************
1454 reads or writes a structure.
1455 ********************************************************************/
1457 BOOL reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
1459 if (r_r == NULL)
1460 return False;
1462 prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1463 depth++;
1465 if(!prs_align(ps))
1466 return False;
1468 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
1469 return False;
1471 if(!prs_uint32("status", ps, depth, &r_r->status))
1472 return False;
1474 return True;