3 things:
[Samba.git] / source / rpc_parse / parse_reg.c
blob925d8b856e89c273f21ab8b00f235165a092288d
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 UNISTR2 unistr;
38 uint32 real_size = 0;
39 char *string;
40 char *list = NULL;
41 char *list2 = NULL;
43 if ( !buf2 || !val )
44 return 0;
46 real_size = val->size;
48 switch (val->type )
50 case REG_SZ:
51 string = (char*)val->data_p;
52 DEBUG(10,("reg_init_buffer2: REG_SZ string => [%s]\n", string));
54 init_unistr2( &unistr, (char*)val->data_p, strlen((char*)val->data_p)+1 );
55 init_buffer2( buf2, (char*)unistr.buffer, unistr.uni_str_len*2 );
56 real_size = unistr.uni_str_len*2;
57 break;
59 case REG_MULTI_SZ:
60 string = (char*)val->data_p;
61 real_size = 0;
62 while ( string && *string )
64 DEBUG(10,("reg_init_buffer2: REG_MULTI_SZ string => [%s], size => [%d]\n", string, real_size ));
66 init_unistr2( &unistr, string, strlen(string)+1 );
68 list2 = Realloc( list, real_size + unistr.uni_str_len*2 );
69 if ( !list2 )
70 break;
71 list = list2;
73 memcpy( list+real_size, unistr.buffer, unistr.uni_str_len*2 );
75 real_size += unistr.uni_str_len*2;
77 string += strlen(string)+1;
80 list2 = Realloc( list, real_size + 2 );
81 if ( !list2 )
82 break;
83 list = list2;
84 list[real_size++] = 0x0;
85 list[real_size++] = 0x0;
87 init_buffer2( buf2, (char*)list, real_size );
89 DEBUG(10,("reg_init_buffer2: REG_MULTI_SZ size => [%d]\n", real_size ));
91 break;
93 case REG_BINARY:
94 DEBUG(10,("reg_init_buffer2: REG_BINARY size => [%d]\n", val->size ));
96 init_buffer2( buf2, val->data_p, val->size );
97 break;
99 case REG_DWORD:
100 DEBUG(10,("reg_init_buffer2: REG_DWORD value => [%d]\n", *(uint32*)val->data_p));
101 init_buffer2( buf2, val->data_p, val->size );
102 break;
104 default:
105 DEBUG(0,("reg_init_buffer2: Unsupported registry data type [%d]\n", val->type));
106 break;
109 SAFE_FREE( list );
111 return real_size;
114 /*******************************************************************
115 Inits a structure.
116 ********************************************************************/
118 void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o,
119 uint16 unknown_0, uint32 level)
121 q_o->ptr = 1;
122 q_o->unknown_0 = unknown_0;
123 q_o->unknown_1 = 0x0; /* random - changes */
124 q_o->level = level;
127 /*******************************************************************
128 reads or writes a structure.
129 ********************************************************************/
131 BOOL reg_io_q_open_hkcr(char *desc, REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth)
133 if (r_q == NULL)
134 return False;
136 prs_debug(ps, depth, desc, "reg_io_q_open_hkcr");
137 depth++;
139 if(!prs_align(ps))
140 return False;
142 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
143 return False;
145 if (r_q->ptr != 0) {
146 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0))
147 return False;
148 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
149 return False;
150 if(!prs_uint32("level ", ps, depth, &r_q->level))
151 return False;
154 return True;
158 /*******************************************************************
159 reads or writes a structure.
160 ********************************************************************/
162 BOOL reg_io_r_open_hkcr(char *desc, REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth)
164 if (r_r == NULL)
165 return False;
167 prs_debug(ps, depth, desc, "reg_io_r_open_hkcr");
168 depth++;
170 if(!prs_align(ps))
171 return False;
173 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
174 return False;
176 if(!prs_ntstatus("status", ps, depth, &r_r->status))
177 return False;
179 return True;
182 /*******************************************************************
183 Inits a structure.
184 ********************************************************************/
186 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o,
187 uint16 unknown_0, uint32 access_mask)
189 q_o->ptr = 1;
190 q_o->unknown_0 = unknown_0;
191 q_o->unknown_1 = 0x0; /* random - changes */
192 q_o->access_mask = access_mask;
196 /*******************************************************************
197 reads or writes a structure.
198 ********************************************************************/
199 BOOL reg_io_q_open_hklm(char *desc, REG_Q_OPEN_HKLM * r_q, prs_struct *ps,
200 int depth)
202 if (r_q == NULL)
203 return False;
205 prs_debug(ps, depth, desc, "reg_io_q_open_hklm");
206 depth++;
208 if (!prs_align(ps))
209 return False;
211 if (!prs_uint32("ptr ", ps, depth, &(r_q->ptr)))
212 return False;
213 if (r_q->ptr != 0)
215 if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0)))
216 return False;
217 if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)))
218 return False;
219 if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask)))
220 return False;
223 return True;
227 /*******************************************************************
228 reads or writes a structure.
229 ********************************************************************/
230 BOOL reg_io_r_open_hklm(char *desc, REG_R_OPEN_HKLM * r_r, prs_struct *ps,
231 int depth)
233 if (r_r == NULL)
234 return False;
236 prs_debug(ps, depth, desc, "reg_io_r_open_hklm");
237 depth++;
239 if (!prs_align(ps))
240 return False;
242 if (!smb_io_pol_hnd("", &r_r->pol, ps, depth))
243 return False;
245 if (!prs_ntstatus("status", ps, depth, &r_r->status))
246 return False;
248 return True;
254 /*******************************************************************
255 Inits a structure.
256 ********************************************************************/
258 void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol)
260 memcpy(&q_u->pol, pol, sizeof(q_u->pol));
263 /*******************************************************************
264 reads or writes a structure.
265 ********************************************************************/
267 BOOL reg_io_q_flush_key(char *desc, REG_Q_FLUSH_KEY *r_q, prs_struct *ps, int depth)
269 if (r_q == NULL)
270 return False;
272 prs_debug(ps, depth, desc, "reg_io_q_flush_key");
273 depth++;
275 if(!prs_align(ps))
276 return False;
278 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
279 return False;
281 return True;
284 /*******************************************************************
285 reads or writes a structure.
286 ********************************************************************/
288 BOOL reg_io_r_flush_key(char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, int depth)
290 if (r_r == NULL)
291 return False;
293 prs_debug(ps, depth, desc, "reg_io_r_flush_key");
294 depth++;
296 if(!prs_align(ps))
297 return False;
299 if(!prs_ntstatus("status", ps, depth, &r_r->status))
300 return False;
302 return True;
305 /*******************************************************************
306 reads or writes SEC_DESC_BUF and SEC_DATA structures.
307 ********************************************************************/
309 static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DESC_BUF *data, prs_struct *ps, int depth)
311 if (ptr != 0) {
312 uint32 hdr_offset;
313 uint32 old_offset;
314 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset))
315 return False;
317 old_offset = prs_offset(ps);
319 if (ptr3 != NULL) {
320 if(!prs_uint32("ptr3", ps, depth, ptr3))
321 return False;
324 if (ptr3 == NULL || *ptr3 != 0) {
325 if(!sec_io_desc_buf("data ", &data, ps, depth)) /* JRA - this line is probably wrong... */
326 return False;
329 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset,
330 data->max_len, data->len))
331 return False;
332 if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3)))
333 return False;
335 if(!prs_align(ps))
336 return False;
339 return True;
342 /*******************************************************************
343 Inits a structure.
344 ********************************************************************/
346 void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd,
347 char *name, char *class, SEC_ACCESS *sam_access,
348 SEC_DESC_BUF *sec_buf)
350 int len_name = name != NULL ? strlen(name ) + 1: 0;
351 int len_class = class != NULL ? strlen(class) + 1: 0;
353 ZERO_STRUCTP(q_c);
355 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
357 init_uni_hdr(&q_c->hdr_name, len_name);
358 init_unistr2(&q_c->uni_name, name, len_name);
360 init_uni_hdr(&q_c->hdr_class, len_class);
361 init_unistr2(&q_c->uni_class, class, len_class);
363 q_c->reserved = 0x00000000;
364 memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access));
366 q_c->ptr1 = 1;
367 q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
369 q_c->data = sec_buf;
370 q_c->ptr2 = 1;
371 init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len);
372 q_c->ptr3 = 1;
373 q_c->unknown_2 = 0x00000000;
376 /*******************************************************************
377 reads or writes a structure.
378 ********************************************************************/
380 BOOL reg_io_q_create_key(char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth)
382 if (r_q == NULL)
383 return False;
385 prs_debug(ps, depth, desc, "reg_io_q_create_key");
386 depth++;
388 if(!prs_align(ps))
389 return False;
391 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
392 return False;
394 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
395 return False;
396 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
397 return False;
398 if(!prs_align(ps))
399 return False;
401 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
402 return False;
403 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
404 return False;
405 if(!prs_align(ps))
406 return False;
408 if(!prs_uint32("reserved", ps, depth, &r_q->reserved))
409 return False;
410 if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth))
411 return False;
413 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
414 return False;
416 if (r_q->ptr1 != 0) {
417 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
418 return False;
421 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
422 return False;
423 if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth))
424 return False;
426 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
427 return False;
429 return True;
432 /*******************************************************************
433 reads or writes a structure.
434 ********************************************************************/
436 BOOL reg_io_r_create_key(char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth)
438 if (r_r == NULL)
439 return False;
441 prs_debug(ps, depth, desc, "reg_io_r_create_key");
442 depth++;
444 if(!prs_align(ps))
445 return False;
447 if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth))
448 return False;
449 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
450 return False;
452 if(!prs_ntstatus("status", ps, depth, &r_r->status))
453 return False;
455 return True;
459 /*******************************************************************
460 Inits a structure.
461 ********************************************************************/
463 void init_reg_q_delete_val(REG_Q_DELETE_VALUE *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_val(char *desc, REG_Q_DELETE_VALUE *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_val");
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;
504 /*******************************************************************
505 reads or writes a structure.
506 ********************************************************************/
508 BOOL reg_io_r_delete_val(char *desc, REG_R_DELETE_VALUE *r_r, prs_struct *ps, int depth)
510 if (r_r == NULL)
511 return False;
513 prs_debug(ps, depth, desc, "reg_io_r_delete_val");
514 depth++;
516 if(!prs_align(ps))
517 return False;
519 if(!prs_ntstatus("status", ps, depth, &r_r->status))
520 return False;
522 return True;
525 /*******************************************************************
526 Inits a structure.
527 ********************************************************************/
529 void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
530 char *name)
532 int len_name = name != NULL ? strlen(name ) + 1: 0;
533 ZERO_STRUCTP(q_c);
535 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
537 init_uni_hdr(&q_c->hdr_name, len_name);
538 init_unistr2(&q_c->uni_name, name, len_name);
541 /*******************************************************************
542 reads or writes a structure.
543 ********************************************************************/
545 BOOL reg_io_q_delete_key(char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth)
547 if (r_q == NULL)
548 return False;
550 prs_debug(ps, depth, desc, "reg_io_q_delete_key");
551 depth++;
553 if(!prs_align(ps))
554 return False;
556 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
557 return False;
559 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
560 return False;
561 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
562 return False;
563 if(!prs_align(ps))
564 return False;
566 return True;
569 /*******************************************************************
570 reads or writes a structure.
571 ********************************************************************/
573 BOOL reg_io_r_delete_key(char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth)
575 if (r_r == NULL)
576 return False;
578 prs_debug(ps, depth, desc, "reg_io_r_delete_key");
579 depth++;
581 if(!prs_align(ps))
582 return False;
584 if(!prs_ntstatus("status", ps, depth, &r_r->status))
585 return False;
587 return True;
590 /*******************************************************************
591 Inits a structure.
592 ********************************************************************/
594 void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd,
595 uint32 max_class_len)
597 ZERO_STRUCTP(q_o);
599 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
600 init_uni_hdr(&q_o->hdr_class, max_class_len);
601 q_o->uni_class.uni_max_len = max_class_len;
604 /*******************************************************************
605 reads or writes a structure.
606 ********************************************************************/
608 BOOL reg_io_q_query_key(char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth)
610 if (r_q == NULL)
611 return False;
613 prs_debug(ps, depth, desc, "reg_io_q_query_key");
614 depth++;
616 if(!prs_align(ps))
617 return False;
619 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
620 return False;
621 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
622 return False;
623 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
624 return False;
626 if(!prs_align(ps))
627 return False;
629 return True;
633 /*******************************************************************
634 reads or writes a structure.
635 ********************************************************************/
637 BOOL reg_io_r_query_key(char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth)
639 if (r_r == NULL)
640 return False;
642 prs_debug(ps, depth, desc, "reg_io_r_query_key");
643 depth++;
645 if(!prs_align(ps))
646 return False;
648 if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth))
649 return False;
650 if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth))
651 return False;
653 if(!prs_align(ps))
654 return False;
656 if(!prs_uint32("num_subkeys ", ps, depth, &r_r->num_subkeys))
657 return False;
658 if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen))
659 return False;
660 if(!prs_uint32("reserved ", ps, depth, &r_r->reserved))
661 return False;
662 if(!prs_uint32("num_values ", ps, depth, &r_r->num_values))
663 return False;
664 if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen))
665 return False;
666 if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize))
667 return False;
668 if(!prs_uint32("sec_desc ", ps, depth, &r_r->sec_desc))
669 return False;
670 if(!smb_io_time("mod_time ", &r_r->mod_time, ps, depth))
671 return False;
673 if(!prs_ntstatus("status", ps, depth, &r_r->status))
674 return False;
676 return True;
679 /*******************************************************************
680 Inits a structure.
681 ********************************************************************/
683 void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A *q_o, POLICY_HND *hnd)
685 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
688 /*******************************************************************
689 reads or writes a structure.
690 ********************************************************************/
692 BOOL reg_io_q_unknown_1a(char *desc, REG_Q_UNKNOWN_1A *r_q, prs_struct *ps, int depth)
694 if (r_q == NULL)
695 return False;
697 prs_debug(ps, depth, desc, "reg_io_q_unknown_1a");
698 depth++;
700 if(!prs_align(ps))
701 return False;
703 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
704 return False;
706 return True;
709 /*******************************************************************
710 reads or writes a structure.
711 ********************************************************************/
713 BOOL reg_io_r_unknown_1a(char *desc, REG_R_UNKNOWN_1A *r_r, prs_struct *ps, int depth)
715 if (r_r == NULL)
716 return False;
718 prs_debug(ps, depth, desc, "reg_io_r_unknown_1a");
719 depth++;
721 if(!prs_align(ps))
722 return False;
724 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
725 return False;
726 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
727 return False;
729 return True;
732 /*******************************************************************
733 Inits a structure.
734 ********************************************************************/
736 void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o,
737 uint16 unknown_0, uint32 access_mask)
739 q_o->ptr = 1;
740 q_o->unknown_0 = unknown_0;
741 q_o->unknown_1 = 0x0; /* random - changes */
742 q_o->access_mask = access_mask;
745 /*******************************************************************
746 reads or writes a structure.
747 ********************************************************************/
749 BOOL reg_io_q_open_hku(char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth)
751 if (r_q == NULL)
752 return False;
754 prs_debug(ps, depth, desc, "reg_io_q_open_hku");
755 depth++;
757 if(!prs_align(ps))
758 return False;
760 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
761 return False;
762 if (r_q->ptr != 0) {
763 if(!prs_uint16("unknown_0 ", ps, depth, &r_q->unknown_0))
764 return False;
765 if(!prs_uint16("unknown_1 ", ps, depth, &r_q->unknown_1))
766 return False;
767 if(!prs_uint32("access_mask ", ps, depth, &r_q->access_mask))
768 return False;
771 return True;
774 /*******************************************************************
775 reads or writes a structure.
776 ********************************************************************/
778 BOOL reg_io_r_open_hku(char *desc, REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth)
780 if (r_r == NULL)
781 return False;
783 prs_debug(ps, depth, desc, "reg_io_r_open_hku");
784 depth++;
786 if(!prs_align(ps))
787 return False;
789 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
790 return False;
792 if(!prs_ntstatus("status", ps, depth, &r_r->status))
793 return False;
795 return True;
798 /*******************************************************************
799 Inits an REG_Q_CLOSE structure.
800 ********************************************************************/
802 void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
804 DEBUG(5,("init_reg_q_close\n"));
806 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
809 /*******************************************************************
810 reads or writes a structure.
811 ********************************************************************/
813 BOOL reg_io_q_close(char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
815 if (q_u == NULL)
816 return False;
818 prs_debug(ps, depth, desc, "reg_io_q_close");
819 depth++;
821 if(!prs_align(ps))
822 return False;
824 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
825 return False;
826 if(!prs_align(ps))
827 return False;
829 return True;
832 /*******************************************************************
833 reads or writes a structure.
834 ********************************************************************/
836 BOOL reg_io_r_close(char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth)
838 if (r_u == NULL)
839 return False;
841 prs_debug(ps, depth, desc, "reg_io_r_close");
842 depth++;
844 if(!prs_align(ps))
845 return False;
847 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
848 return False;
849 if(!prs_align(ps))
850 return False;
852 if(!prs_ntstatus("status", ps, depth, &r_u->status))
853 return False;
855 return True;
858 /*******************************************************************
859 makes a structure.
860 ********************************************************************/
862 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf)
864 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
866 q_i->sec_info = DACL_SECURITY_INFORMATION;
868 q_i->ptr = 1;
869 init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len);
870 q_i->data = sec_desc_buf;
873 /*******************************************************************
874 reads or writes a structure.
875 ********************************************************************/
877 BOOL reg_io_q_set_key_sec(char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
879 if (r_q == NULL)
880 return False;
882 prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
883 depth++;
885 if(!prs_align(ps))
886 return False;
888 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
889 return False;
891 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
892 return False;
893 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
894 return False;
896 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
897 return False;
899 return True;
902 /*******************************************************************
903 reads or writes a structure.
904 ********************************************************************/
906 BOOL reg_io_r_set_key_sec(char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
908 if (r_q == NULL)
909 return False;
911 prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
912 depth++;
914 if(!prs_align(ps))
915 return False;
917 if(!prs_ntstatus("status", ps, depth, &r_q->status))
918 return False;
920 return True;
924 /*******************************************************************
925 makes a structure.
926 ********************************************************************/
928 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol,
929 uint32 sec_buf_size, SEC_DESC_BUF *psdb)
931 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
933 q_i->sec_info = OWNER_SECURITY_INFORMATION |
934 GROUP_SECURITY_INFORMATION |
935 DACL_SECURITY_INFORMATION;
937 q_i->ptr = psdb != NULL ? 1 : 0;
938 q_i->data = psdb;
940 init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0);
943 /*******************************************************************
944 reads or writes a structure.
945 ********************************************************************/
947 BOOL reg_io_q_get_key_sec(char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
949 if (r_q == NULL)
950 return False;
952 prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
953 depth++;
955 if(!prs_align(ps))
956 return False;
958 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
959 return False;
961 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
962 return False;
963 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
964 return False;
966 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
967 return False;
969 return True;
972 #if 0
973 /*******************************************************************
974 makes a structure.
975 ********************************************************************/
976 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
977 uint32 buf_len, uint8 *buf,
978 NTSTATUS status)
980 r_i->ptr = 1;
981 init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len);
982 init_sec_desc_buf(r_i->data, buf_len, 1);
984 r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
986 #endif
988 /*******************************************************************
989 reads or writes a structure.
990 ********************************************************************/
992 BOOL reg_io_r_get_key_sec(char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
994 if (r_q == NULL)
995 return False;
997 prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
998 depth++;
1000 if(!prs_align(ps))
1001 return False;
1003 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
1004 return False;
1006 if (r_q->ptr != 0) {
1007 if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth))
1008 return False;
1009 if(!sec_io_desc_buf("", &r_q->data, ps, depth))
1010 return False;
1011 if(!prs_align(ps))
1012 return False;
1015 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1016 return False;
1018 return True;
1021 /*******************************************************************
1022 makes a structure.
1023 ********************************************************************/
1025 BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name)
1027 int len_type = val_name != NULL ? strlen(val_name) + 1 : 0;
1029 if (q_i == NULL)
1030 return False;
1032 q_i->pol = *pol;
1034 init_uni_hdr(&(q_i->hdr_type), len_type);
1035 init_unistr2(&(q_i->uni_type), val_name, len_type);
1037 q_i->ptr_reserved = 1;
1038 q_i->ptr_buf = 1;
1040 q_i->ptr_bufsize = 1;
1041 q_i->bufsize = 0;
1042 q_i->buf_unk = 0;
1044 q_i->unk1 = 0;
1045 q_i->ptr_buflen = 1;
1046 q_i->buflen = 0;
1048 q_i->ptr_buflen2 = 1;
1049 q_i->buflen2 = 0;
1051 return True;
1054 /*******************************************************************
1055 reads or writes a structure.
1056 ********************************************************************/
1058 BOOL reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth)
1060 if (r_q == NULL)
1061 return False;
1063 prs_debug(ps, depth, desc, "reg_io_q_info");
1064 depth++;
1066 if(!prs_align(ps))
1067 return False;
1069 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1070 return False;
1071 if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth))
1072 return False;
1073 if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth))
1074 return False;
1076 if(!prs_align(ps))
1077 return False;
1079 if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved)))
1080 return False;
1082 if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf)))
1083 return False;
1085 if(r_q->ptr_buf) {
1086 if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize)))
1087 return False;
1088 if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize)))
1089 return False;
1090 if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk)))
1091 return False;
1094 if(!prs_uint32("unk1", ps, depth, &(r_q->unk1)))
1095 return False;
1097 if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen)))
1098 return False;
1100 if (r_q->ptr_buflen) {
1101 if(!prs_uint32("buflen", ps, depth, &(r_q->buflen)))
1102 return False;
1103 if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2)))
1104 return False;
1105 if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2)))
1106 return False;
1109 return True;
1112 /*******************************************************************
1113 Inits a structure.
1114 New version to replace older init_reg_r_info()
1115 ********************************************************************/
1117 BOOL new_init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1118 REGISTRY_VALUE *val, NTSTATUS status)
1120 uint32 buf_len = 0;
1121 BUFFER2 buf2;
1123 if(r_r == NULL)
1124 return False;
1126 if ( !val )
1127 return False;
1129 r_r->ptr_type = 1;
1130 r_r->type = val->type;
1132 /* if include_keyval is not set, don't send the key value, just
1133 the buflen data. probably used by NT5 to allocate buffer space - SK */
1135 if ( include_keyval ) {
1136 r_r->ptr_uni_val = 1;
1137 buf_len = reg_init_buffer2( &r_r->uni_val, val );
1140 else {
1141 /* dummy buffer used so we can get the size */
1142 r_r->ptr_uni_val = 0;
1143 buf_len = reg_init_buffer2( &buf2, val );
1146 r_r->ptr_max_len = 1;
1147 r_r->buf_max_len = buf_len;
1149 r_r->ptr_len = 1;
1150 r_r->buf_len = buf_len;
1152 r_r->status = status;
1154 return True;
1157 /*******************************************************************
1158 Inits a structure.
1159 ********************************************************************/
1161 BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1162 BUFFER2* buf, uint32 type, NTSTATUS status)
1164 if(r_r == NULL)
1165 return False;
1167 r_r->ptr_type = 1;
1168 r_r->type = type;
1170 /* if include_keyval is not set, don't send the key value, just
1171 the buflen data. probably used by NT5 to allocate buffer space - SK */
1173 r_r->ptr_uni_val = include_keyval ? 1:0;
1174 r_r->uni_val = *buf;
1176 r_r->ptr_max_len = 1;
1177 r_r->buf_max_len = r_r->uni_val.buf_max_len;
1179 r_r->ptr_len = 1;
1180 r_r->buf_len = r_r->uni_val.buf_len;
1182 r_r->status = status;
1184 return True;
1187 /*******************************************************************
1188 reads or writes a structure.
1189 ********************************************************************/
1191 BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
1193 if (r_r == NULL)
1194 return False;
1196 prs_debug(ps, depth, desc, "reg_io_r_info");
1197 depth++;
1199 if(!prs_align(ps))
1200 return False;
1202 if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type)))
1203 return False;
1205 if (r_r->ptr_type != 0) {
1206 if(!prs_uint32("type", ps, depth, &r_r->type))
1207 return False;
1210 if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val)))
1211 return False;
1213 if(r_r->ptr_uni_val != 0) {
1214 if(!smb_io_buffer2("uni_val", &r_r->uni_val, r_r->ptr_uni_val, ps, depth))
1215 return False;
1218 if(!prs_align(ps))
1219 return False;
1221 if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len)))
1222 return False;
1224 if (r_r->ptr_max_len != 0) {
1225 if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len)))
1226 return False;
1229 if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len)))
1230 return False;
1231 if (r_r->ptr_len != 0) {
1232 if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len)))
1233 return False;
1236 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1237 return False;
1239 return True;
1242 /*******************************************************************
1243 makes a structure.
1244 ********************************************************************/
1246 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
1247 uint32 val_idx, uint32 max_val_len,
1248 uint32 max_buf_len)
1250 ZERO_STRUCTP(q_i);
1252 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1254 q_i->val_index = val_idx;
1255 init_uni_hdr(&q_i->hdr_name, max_val_len);
1256 q_i->uni_name.uni_max_len = max_val_len;
1258 q_i->ptr_type = 1;
1259 q_i->type = 0x0;
1261 q_i->ptr_value = 1;
1262 q_i->buf_value.buf_max_len = max_buf_len;
1264 q_i->ptr1 = 1;
1265 q_i->len_value1 = max_buf_len;
1267 q_i->ptr2 = 1;
1268 q_i->len_value2 = 0;
1271 /*******************************************************************
1272 makes a structure.
1273 ********************************************************************/
1275 void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val )
1277 uint32 real_size;
1279 DEBUG(8,("init_reg_r_enum_val: Enter\n"));
1281 ZERO_STRUCTP(r_u);
1283 /* value name */
1285 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename));
1287 init_uni_hdr( &r_u->hdr_name, strlen(val->valuename)+1 );
1288 init_unistr2( &r_u->uni_name, val->valuename, strlen(val->valuename)+1 );
1290 /* type */
1292 r_u->ptr_type = 1;
1293 r_u->type = val->type;
1295 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1297 r_u->ptr_value = 1;
1298 real_size = reg_init_buffer2( &r_u->buf_value, val );
1300 /* lengths */
1302 r_u->ptr1 = 1;
1303 r_u->len_value1 = real_size;
1305 r_u->ptr2 = 1;
1306 r_u->len_value2 = real_size;
1308 DEBUG(8,("init_reg_r_enum_val: Exit\n"));
1311 /*******************************************************************
1312 reads or writes a structure.
1313 ********************************************************************/
1315 BOOL reg_io_q_enum_val(char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth)
1317 if (q_q == NULL)
1318 return False;
1320 prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1321 depth++;
1323 if(!prs_align(ps))
1324 return False;
1326 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1327 return False;
1329 if(!prs_uint32("val_index", ps, depth, &q_q->val_index))
1330 return False;
1332 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1333 return False;
1334 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1335 return False;
1336 if(!prs_align(ps))
1337 return False;
1339 if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type))
1340 return False;
1342 if (q_q->ptr_type != 0) {
1343 if(!prs_uint32("type", ps, depth, &q_q->type))
1344 return False;
1347 if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value))
1348 return False;
1349 if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth))
1350 return False;
1351 if(!prs_align(ps))
1352 return False;
1354 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1355 return False;
1356 if (q_q->ptr1 != 0) {
1357 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1))
1358 return False;
1360 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1361 return False;
1362 if (q_q->ptr2 != 0) {
1363 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2))
1364 return False;
1367 return True;
1370 /*******************************************************************
1371 reads or writes a structure.
1372 ********************************************************************/
1374 BOOL reg_io_r_enum_val(char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth)
1376 if (r_q == NULL)
1377 return False;
1379 prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1380 depth++;
1382 if(!prs_align(ps))
1383 return False;
1385 if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth))
1386 return False;
1387 if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1388 return False;
1389 if(!prs_align(ps))
1390 return False;
1392 if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type))
1393 return False;
1395 if (r_q->ptr_type != 0) {
1396 if(!prs_uint32("type", ps, depth, &r_q->type))
1397 return False;
1400 if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value))
1401 return False;
1402 if(!smb_io_buffer2("buf_value", &r_q->buf_value, r_q->ptr_value, ps, depth))
1403 return False;
1404 if(!prs_align(ps))
1405 return False;
1407 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1408 return False;
1409 if (r_q->ptr1 != 0) {
1410 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1))
1411 return False;
1414 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1415 return False;
1416 if (r_q->ptr2 != 0) {
1417 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2))
1418 return False;
1421 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1422 return False;
1424 return True;
1427 /*******************************************************************
1428 makes a structure.
1429 ********************************************************************/
1431 void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
1432 char *val_name, uint32 type,
1433 BUFFER3 *val)
1435 int val_len = strlen(val_name) + 1;
1437 ZERO_STRUCTP(q_i);
1439 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1441 init_uni_hdr(&q_i->hdr_name, val_len);
1442 init_unistr2(&q_i->uni_name, val_name, val_len);
1444 q_i->type = type;
1445 q_i->buf_value = val;
1448 /*******************************************************************
1449 reads or writes a structure.
1450 ********************************************************************/
1452 BOOL reg_io_q_create_val(char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth)
1454 if (q_q == NULL)
1455 return False;
1457 prs_debug(ps, depth, desc, "reg_io_q_create_val");
1458 depth++;
1460 if(!prs_align(ps))
1461 return False;
1463 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1464 return False;
1466 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1467 return False;
1468 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1469 return False;
1470 if(!prs_align(ps))
1471 return False;
1473 if(!prs_uint32("type", ps, depth, &q_q->type))
1474 return False;
1475 if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth))
1476 return False;
1477 if(!prs_align(ps))
1478 return False;
1480 return True;
1483 /*******************************************************************
1484 reads or writes a structure.
1485 ********************************************************************/
1487 BOOL reg_io_r_create_val(char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth)
1489 if (r_q == NULL)
1490 return False;
1492 prs_debug(ps, depth, desc, "reg_io_r_create_val");
1493 depth++;
1495 if(!prs_align(ps))
1496 return False;
1498 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1499 return False;
1501 return True;
1504 /*******************************************************************
1505 makes a structure.
1506 ********************************************************************/
1508 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx)
1510 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1512 q_i->key_index = key_idx;
1513 q_i->key_name_len = 0;
1514 q_i->unknown_1 = 0x0414;
1516 q_i->ptr1 = 1;
1517 q_i->unknown_2 = 0x0000020A;
1518 memset(q_i->pad1, 0, sizeof(q_i->pad1));
1520 q_i->ptr2 = 1;
1521 memset(q_i->pad2, 0, sizeof(q_i->pad2));
1523 q_i->ptr3 = 1;
1524 unix_to_nt_time(&q_i->time, 0); /* current time? */
1527 /*******************************************************************
1528 makes a reply structure.
1529 ********************************************************************/
1531 void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey, uint32 unknown_1,
1532 uint32 unknown_2)
1534 if ( !r_u )
1535 return;
1537 r_u->unknown_1 = unknown_1;
1538 r_u->unknown_2 = unknown_2;
1539 r_u->unknown_3 = 0x0;
1541 r_u->key_name_len = (strlen(subkey)+1) * 2;
1542 if (r_u->key_name_len)
1543 r_u->ptr1 = 0x1;
1544 init_unistr3( &r_u->key_name, subkey );
1546 r_u->ptr2 = 0x1;
1547 r_u->ptr3 = 0x1;
1550 /*******************************************************************
1551 reads or writes a structure.
1552 ********************************************************************/
1554 BOOL reg_io_q_enum_key(char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth)
1556 if (q_q == NULL)
1557 return False;
1559 prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1560 depth++;
1562 if(!prs_align(ps))
1563 return False;
1565 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1566 return False;
1568 if(!prs_uint32("key_index", ps, depth, &q_q->key_index))
1569 return False;
1570 if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len))
1571 return False;
1572 if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1))
1573 return False;
1575 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1576 return False;
1578 if (q_q->ptr1 != 0) {
1579 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2))
1580 return False;
1581 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)))
1582 return False;
1585 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1586 return False;
1588 if (q_q->ptr2 != 0) {
1589 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)))
1590 return False;
1593 if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3))
1594 return False;
1596 if (q_q->ptr3 != 0) {
1597 if(!smb_io_time("", &q_q->time, ps, depth))
1598 return False;
1601 return True;
1604 /*******************************************************************
1605 reads or writes a structure.
1606 ********************************************************************/
1608 BOOL reg_io_r_enum_key(char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth)
1610 if (r_q == NULL)
1611 return False;
1613 prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1614 depth++;
1616 if(!prs_align(ps))
1617 return False;
1619 if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len))
1620 return False;
1621 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
1622 return False;
1624 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1625 return False;
1627 if (r_q->ptr1 != 0) {
1628 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
1629 return False;
1630 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3))
1631 return False;
1632 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth))
1633 return False;
1634 if(!prs_align(ps))
1635 return False;
1638 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1639 return False;
1641 if (r_q->ptr2 != 0) {
1642 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
1643 return False;
1646 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
1647 return False;
1649 if (r_q->ptr3 != 0) {
1650 if(!smb_io_time("", &r_q->time, ps, depth))
1651 return False;
1654 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1655 return False;
1657 return True;
1660 /*******************************************************************
1661 makes a structure.
1662 ********************************************************************/
1664 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
1665 char *key_name, uint32 access_desired)
1667 int len_name = strlen(key_name)+1;
1669 memcpy(&r_q->pol, pol, sizeof(r_q->pol));
1671 init_uni_hdr(&r_q->hdr_name, len_name);
1672 init_unistr2(&r_q->uni_name, key_name, len_name);
1674 r_q->unknown_0 = 0x00000000;
1675 r_q->access_desired = access_desired;
1678 /*******************************************************************
1679 reads or writes a structure.
1680 ********************************************************************/
1682 BOOL reg_io_q_open_entry(char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
1684 if (r_q == NULL)
1685 return False;
1687 prs_debug(ps, depth, desc, "reg_io_q_entry");
1688 depth++;
1690 if(!prs_align(ps))
1691 return False;
1693 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1694 return False;
1695 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
1696 return False;
1697 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1698 return False;
1700 if(!prs_align(ps))
1701 return False;
1703 if(!prs_uint32("unknown_0 ", ps, depth, &r_q->unknown_0))
1704 return False;
1705 if(!prs_uint32("asccess_desired ", ps, depth, &r_q->access_desired))
1706 return False;
1708 return True;
1711 /*******************************************************************
1712 Inits a structure.
1713 ********************************************************************/
1715 void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
1716 POLICY_HND *pol, NTSTATUS status)
1718 memcpy(&r_r->pol, pol, sizeof(r_r->pol));
1719 r_r->status = status;
1722 /*******************************************************************
1723 reads or writes a structure.
1724 ********************************************************************/
1726 BOOL reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
1728 if (r_r == NULL)
1729 return False;
1731 prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1732 depth++;
1734 if(!prs_align(ps))
1735 return False;
1737 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
1738 return False;
1740 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1741 return False;
1743 return True;
1746 /*******************************************************************
1747 Inits a structure.
1748 ********************************************************************/
1749 void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s,
1750 const char *msg, uint32 timeout, uint16 flags)
1752 int msg_len;
1753 msg_len = strlen(msg);
1755 q_s->ptr_0 = 1;
1756 q_s->ptr_1 = 1;
1757 q_s->ptr_2 = 1;
1759 init_uni_hdr(&(q_s->hdr_msg), msg_len);
1760 init_unistr2(&(q_s->uni_msg), msg, msg_len);
1762 q_s->timeout = timeout;
1763 q_s->flags = flags;
1767 /*******************************************************************
1768 reads or writes a structure.
1769 ********************************************************************/
1770 BOOL reg_io_q_shutdown(char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps,
1771 int depth)
1773 if (q_s == NULL)
1774 return False;
1776 prs_debug(ps, depth, desc, "reg_io_q_shutdown");
1777 depth++;
1779 if (!prs_align(ps))
1780 return False;
1782 if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0)))
1783 return False;
1784 if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1)))
1785 return False;
1786 if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2)))
1787 return False;
1789 if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth))
1790 return False;
1791 if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth))
1792 return False;
1793 if (!prs_align(ps))
1794 return False;
1796 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
1797 return False;
1798 if (!prs_uint16("flags ", ps, depth, &(q_s->flags)))
1799 return False;
1801 return True;
1804 /*******************************************************************
1805 reads or writes a structure.
1806 ********************************************************************/
1807 BOOL reg_io_r_shutdown(char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps,
1808 int depth)
1810 if (r_s == NULL)
1811 return False;
1813 prs_debug(ps, depth, desc, "reg_io_r_shutdown");
1814 depth++;
1816 if(!prs_align(ps))
1817 return False;
1819 if(!prs_ntstatus("status", ps, depth, &r_s->status))
1820 return False;
1822 return True;
1825 /*******************************************************************
1826 Inits a structure.
1827 ********************************************************************/
1828 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s)
1831 q_s->ptr_server = 0;
1835 /*******************************************************************
1836 reads or writes a structure.
1837 ********************************************************************/
1838 BOOL reg_io_q_abort_shutdown(char *desc, REG_Q_ABORT_SHUTDOWN * q_s,
1839 prs_struct *ps, int depth)
1841 if (q_s == NULL)
1842 return False;
1844 prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
1845 depth++;
1847 if (!prs_align(ps))
1848 return False;
1850 if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
1851 return False;
1852 if (q_s->ptr_server != 0)
1853 if (!prs_uint16("server", ps, depth, &(q_s->server)))
1854 return False;
1856 return True;
1859 /*******************************************************************
1860 reads or writes a structure.
1861 ********************************************************************/
1862 BOOL reg_io_r_abort_shutdown(char *desc, REG_R_ABORT_SHUTDOWN * r_s,
1863 prs_struct *ps, int depth)
1865 if (r_s == NULL)
1866 return False;
1868 prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
1869 depth++;
1871 if (!prs_align(ps))
1872 return False;
1874 if (!prs_ntstatus("status", ps, depth, &r_s->status))
1875 return False;
1877 return True;