add another registry rpc (opnum 0x14). Have no idea what it's real name
[Samba.git] / source / rpc_parse / parse_reg.c
blob473e2554b40e0972f3390eaea3cf104863bcfc22
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));
689 /*******************************************************************
690 reads or writes a structure.
691 ********************************************************************/
693 BOOL reg_io_q_unknown_1a(char *desc, REG_Q_UNKNOWN_1A *r_q, prs_struct *ps, int depth)
695 if (r_q == NULL)
696 return False;
698 prs_debug(ps, depth, desc, "reg_io_q_unknown_1a");
699 depth++;
701 if(!prs_align(ps))
702 return False;
704 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
705 return False;
707 return True;
710 /*******************************************************************
711 reads or writes a structure.
712 ********************************************************************/
714 BOOL reg_io_r_unknown_1a(char *desc, REG_R_UNKNOWN_1A *r_r, prs_struct *ps, int depth)
716 if (r_r == NULL)
717 return False;
719 prs_debug(ps, depth, desc, "reg_io_r_unknown_1a");
720 depth++;
722 if(!prs_align(ps))
723 return False;
725 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
726 return False;
727 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
728 return False;
730 return True;
734 /*******************************************************************
735 reads or writes a structure.
736 ********************************************************************/
738 BOOL reg_io_q_save_key(char *desc, REG_Q_SAVE_KEY *r_q, prs_struct *ps, int depth)
740 if (r_q == NULL)
741 return False;
743 prs_debug(ps, depth, desc, "reg_io_q_save_key");
744 depth++;
746 if(!prs_align(ps))
747 return False;
749 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
750 return False;
752 if(!smb_io_unihdr ("hdr_file", &r_q->hdr_file, ps, depth))
753 return False;
754 if(!smb_io_unistr2("uni_file", &r_q->uni_file, r_q->hdr_file.buffer, ps, depth))
755 return False;
757 if(!prs_uint32("unknown", ps, depth, &r_q->unknown))
758 return False;
760 return True;
763 /*******************************************************************
764 reads or writes a structure.
765 ********************************************************************/
767 BOOL reg_io_r_save_key(char *desc, REG_R_SAVE_KEY *r_r, prs_struct *ps, int depth)
769 if (r_r == NULL)
770 return False;
772 prs_debug(ps, depth, desc, "reg_io_r_save_key");
773 depth++;
775 if(!prs_align(ps))
776 return False;
778 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
779 return False;
781 return True;
784 /*******************************************************************
785 Inits a structure.
786 ********************************************************************/
788 void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o,
789 uint16 unknown_0, uint32 access_mask)
791 q_o->ptr = 1;
792 q_o->unknown_0 = unknown_0;
793 q_o->unknown_1 = 0x0; /* random - changes */
794 q_o->access_mask = access_mask;
797 /*******************************************************************
798 reads or writes a structure.
799 ********************************************************************/
801 BOOL reg_io_q_open_hku(char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth)
803 if (r_q == NULL)
804 return False;
806 prs_debug(ps, depth, desc, "reg_io_q_open_hku");
807 depth++;
809 if(!prs_align(ps))
810 return False;
812 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
813 return False;
814 if (r_q->ptr != 0) {
815 if(!prs_uint16("unknown_0 ", ps, depth, &r_q->unknown_0))
816 return False;
817 if(!prs_uint16("unknown_1 ", ps, depth, &r_q->unknown_1))
818 return False;
819 if(!prs_uint32("access_mask ", ps, depth, &r_q->access_mask))
820 return False;
823 return True;
826 /*******************************************************************
827 reads or writes a structure.
828 ********************************************************************/
830 BOOL reg_io_r_open_hku(char *desc, REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth)
832 if (r_r == NULL)
833 return False;
835 prs_debug(ps, depth, desc, "reg_io_r_open_hku");
836 depth++;
838 if(!prs_align(ps))
839 return False;
841 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
842 return False;
844 if(!prs_ntstatus("status", ps, depth, &r_r->status))
845 return False;
847 return True;
850 /*******************************************************************
851 Inits an REG_Q_CLOSE structure.
852 ********************************************************************/
854 void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
856 DEBUG(5,("init_reg_q_close\n"));
858 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
861 /*******************************************************************
862 reads or writes a structure.
863 ********************************************************************/
865 BOOL reg_io_q_close(char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
867 if (q_u == NULL)
868 return False;
870 prs_debug(ps, depth, desc, "reg_io_q_close");
871 depth++;
873 if(!prs_align(ps))
874 return False;
876 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
877 return False;
878 if(!prs_align(ps))
879 return False;
881 return True;
884 /*******************************************************************
885 reads or writes a structure.
886 ********************************************************************/
888 BOOL reg_io_r_close(char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth)
890 if (r_u == NULL)
891 return False;
893 prs_debug(ps, depth, desc, "reg_io_r_close");
894 depth++;
896 if(!prs_align(ps))
897 return False;
899 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
900 return False;
901 if(!prs_align(ps))
902 return False;
904 if(!prs_ntstatus("status", ps, depth, &r_u->status))
905 return False;
907 return True;
910 /*******************************************************************
911 makes a structure.
912 ********************************************************************/
914 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf)
916 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
918 q_i->sec_info = DACL_SECURITY_INFORMATION;
920 q_i->ptr = 1;
921 init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len);
922 q_i->data = sec_desc_buf;
925 /*******************************************************************
926 reads or writes a structure.
927 ********************************************************************/
929 BOOL reg_io_q_set_key_sec(char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
931 if (r_q == NULL)
932 return False;
934 prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
935 depth++;
937 if(!prs_align(ps))
938 return False;
940 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
941 return False;
943 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
944 return False;
945 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
946 return False;
948 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
949 return False;
951 return True;
954 /*******************************************************************
955 reads or writes a structure.
956 ********************************************************************/
958 BOOL reg_io_r_set_key_sec(char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
960 if (r_q == NULL)
961 return False;
963 prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
964 depth++;
966 if(!prs_align(ps))
967 return False;
969 if(!prs_ntstatus("status", ps, depth, &r_q->status))
970 return False;
972 return True;
976 /*******************************************************************
977 makes a structure.
978 ********************************************************************/
980 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol,
981 uint32 sec_buf_size, SEC_DESC_BUF *psdb)
983 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
985 q_i->sec_info = OWNER_SECURITY_INFORMATION |
986 GROUP_SECURITY_INFORMATION |
987 DACL_SECURITY_INFORMATION;
989 q_i->ptr = psdb != NULL ? 1 : 0;
990 q_i->data = psdb;
992 init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0);
995 /*******************************************************************
996 reads or writes a structure.
997 ********************************************************************/
999 BOOL reg_io_q_get_key_sec(char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
1001 if (r_q == NULL)
1002 return False;
1004 prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
1005 depth++;
1007 if(!prs_align(ps))
1008 return False;
1010 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1011 return False;
1013 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
1014 return False;
1015 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
1016 return False;
1018 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
1019 return False;
1021 return True;
1024 #if 0
1025 /*******************************************************************
1026 makes a structure.
1027 ********************************************************************/
1028 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
1029 uint32 buf_len, uint8 *buf,
1030 NTSTATUS status)
1032 r_i->ptr = 1;
1033 init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len);
1034 init_sec_desc_buf(r_i->data, buf_len, 1);
1036 r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
1038 #endif
1040 /*******************************************************************
1041 reads or writes a structure.
1042 ********************************************************************/
1044 BOOL reg_io_r_get_key_sec(char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
1046 if (r_q == NULL)
1047 return False;
1049 prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
1050 depth++;
1052 if(!prs_align(ps))
1053 return False;
1055 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
1056 return False;
1058 if (r_q->ptr != 0) {
1059 if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth))
1060 return False;
1061 if(!sec_io_desc_buf("", &r_q->data, ps, depth))
1062 return False;
1063 if(!prs_align(ps))
1064 return False;
1067 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1068 return False;
1070 return True;
1073 /*******************************************************************
1074 makes a structure.
1075 ********************************************************************/
1077 BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name)
1079 int len_type = val_name != NULL ? strlen(val_name) + 1 : 0;
1081 if (q_i == NULL)
1082 return False;
1084 q_i->pol = *pol;
1086 init_uni_hdr(&(q_i->hdr_type), len_type);
1087 init_unistr2(&(q_i->uni_type), val_name, len_type);
1089 q_i->ptr_reserved = 1;
1090 q_i->ptr_buf = 1;
1092 q_i->ptr_bufsize = 1;
1093 q_i->bufsize = 0;
1094 q_i->buf_unk = 0;
1096 q_i->unk1 = 0;
1097 q_i->ptr_buflen = 1;
1098 q_i->buflen = 0;
1100 q_i->ptr_buflen2 = 1;
1101 q_i->buflen2 = 0;
1103 return True;
1106 /*******************************************************************
1107 reads or writes a structure.
1108 ********************************************************************/
1110 BOOL reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth)
1112 if (r_q == NULL)
1113 return False;
1115 prs_debug(ps, depth, desc, "reg_io_q_info");
1116 depth++;
1118 if(!prs_align(ps))
1119 return False;
1121 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1122 return False;
1123 if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth))
1124 return False;
1125 if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth))
1126 return False;
1128 if(!prs_align(ps))
1129 return False;
1131 if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved)))
1132 return False;
1134 if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf)))
1135 return False;
1137 if(r_q->ptr_buf) {
1138 if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize)))
1139 return False;
1140 if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize)))
1141 return False;
1142 if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk)))
1143 return False;
1146 if(!prs_uint32("unk1", ps, depth, &(r_q->unk1)))
1147 return False;
1149 if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen)))
1150 return False;
1152 if (r_q->ptr_buflen) {
1153 if(!prs_uint32("buflen", ps, depth, &(r_q->buflen)))
1154 return False;
1155 if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2)))
1156 return False;
1157 if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2)))
1158 return False;
1161 return True;
1164 /*******************************************************************
1165 Inits a structure.
1166 New version to replace older init_reg_r_info()
1167 ********************************************************************/
1169 BOOL new_init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1170 REGISTRY_VALUE *val, NTSTATUS status)
1172 uint32 buf_len = 0;
1173 BUFFER2 buf2;
1175 if(r_r == NULL)
1176 return False;
1178 if ( !val )
1179 return False;
1181 r_r->ptr_type = 1;
1182 r_r->type = val->type;
1184 /* if include_keyval is not set, don't send the key value, just
1185 the buflen data. probably used by NT5 to allocate buffer space - SK */
1187 if ( include_keyval ) {
1188 r_r->ptr_uni_val = 1;
1189 buf_len = reg_init_buffer2( &r_r->uni_val, val );
1192 else {
1193 /* dummy buffer used so we can get the size */
1194 r_r->ptr_uni_val = 0;
1195 buf_len = reg_init_buffer2( &buf2, val );
1198 r_r->ptr_max_len = 1;
1199 r_r->buf_max_len = buf_len;
1201 r_r->ptr_len = 1;
1202 r_r->buf_len = buf_len;
1204 r_r->status = status;
1206 return True;
1209 /*******************************************************************
1210 Inits a structure.
1211 ********************************************************************/
1213 BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1214 BUFFER2* buf, uint32 type, NTSTATUS status)
1216 if(r_r == NULL)
1217 return False;
1219 r_r->ptr_type = 1;
1220 r_r->type = type;
1222 /* if include_keyval is not set, don't send the key value, just
1223 the buflen data. probably used by NT5 to allocate buffer space - SK */
1225 r_r->ptr_uni_val = include_keyval ? 1:0;
1226 r_r->uni_val = *buf;
1228 r_r->ptr_max_len = 1;
1229 r_r->buf_max_len = r_r->uni_val.buf_max_len;
1231 r_r->ptr_len = 1;
1232 r_r->buf_len = r_r->uni_val.buf_len;
1234 r_r->status = status;
1236 return True;
1239 /*******************************************************************
1240 reads or writes a structure.
1241 ********************************************************************/
1243 BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
1245 if (r_r == NULL)
1246 return False;
1248 prs_debug(ps, depth, desc, "reg_io_r_info");
1249 depth++;
1251 if(!prs_align(ps))
1252 return False;
1254 if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type)))
1255 return False;
1257 if (r_r->ptr_type != 0) {
1258 if(!prs_uint32("type", ps, depth, &r_r->type))
1259 return False;
1262 if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val)))
1263 return False;
1265 if(r_r->ptr_uni_val != 0) {
1266 if(!smb_io_buffer2("uni_val", &r_r->uni_val, r_r->ptr_uni_val, ps, depth))
1267 return False;
1270 if(!prs_align(ps))
1271 return False;
1273 if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len)))
1274 return False;
1276 if (r_r->ptr_max_len != 0) {
1277 if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len)))
1278 return False;
1281 if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len)))
1282 return False;
1283 if (r_r->ptr_len != 0) {
1284 if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len)))
1285 return False;
1288 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1289 return False;
1291 return True;
1294 /*******************************************************************
1295 makes a structure.
1296 ********************************************************************/
1298 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
1299 uint32 val_idx, uint32 max_val_len,
1300 uint32 max_buf_len)
1302 ZERO_STRUCTP(q_i);
1304 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1306 q_i->val_index = val_idx;
1307 init_uni_hdr(&q_i->hdr_name, max_val_len);
1308 q_i->uni_name.uni_max_len = max_val_len;
1310 q_i->ptr_type = 1;
1311 q_i->type = 0x0;
1313 q_i->ptr_value = 1;
1314 q_i->buf_value.buf_max_len = max_buf_len;
1316 q_i->ptr1 = 1;
1317 q_i->len_value1 = max_buf_len;
1319 q_i->ptr2 = 1;
1320 q_i->len_value2 = 0;
1323 /*******************************************************************
1324 makes a structure.
1325 ********************************************************************/
1327 void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val )
1329 uint32 real_size;
1331 DEBUG(8,("init_reg_r_enum_val: Enter\n"));
1333 ZERO_STRUCTP(r_u);
1335 /* value name */
1337 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename));
1339 init_uni_hdr( &r_u->hdr_name, strlen(val->valuename)+1 );
1340 init_unistr2( &r_u->uni_name, val->valuename, strlen(val->valuename)+1 );
1342 /* type */
1344 r_u->ptr_type = 1;
1345 r_u->type = val->type;
1347 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1349 r_u->ptr_value = 1;
1350 real_size = reg_init_buffer2( &r_u->buf_value, val );
1352 /* lengths */
1354 r_u->ptr1 = 1;
1355 r_u->len_value1 = real_size;
1357 r_u->ptr2 = 1;
1358 r_u->len_value2 = real_size;
1360 DEBUG(8,("init_reg_r_enum_val: Exit\n"));
1363 /*******************************************************************
1364 reads or writes a structure.
1365 ********************************************************************/
1367 BOOL reg_io_q_enum_val(char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth)
1369 if (q_q == NULL)
1370 return False;
1372 prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1373 depth++;
1375 if(!prs_align(ps))
1376 return False;
1378 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1379 return False;
1381 if(!prs_uint32("val_index", ps, depth, &q_q->val_index))
1382 return False;
1384 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1385 return False;
1386 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1387 return False;
1388 if(!prs_align(ps))
1389 return False;
1391 if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type))
1392 return False;
1394 if (q_q->ptr_type != 0) {
1395 if(!prs_uint32("type", ps, depth, &q_q->type))
1396 return False;
1399 if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value))
1400 return False;
1401 if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth))
1402 return False;
1403 if(!prs_align(ps))
1404 return False;
1406 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1407 return False;
1408 if (q_q->ptr1 != 0) {
1409 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1))
1410 return False;
1412 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1413 return False;
1414 if (q_q->ptr2 != 0) {
1415 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2))
1416 return False;
1419 return True;
1422 /*******************************************************************
1423 reads or writes a structure.
1424 ********************************************************************/
1426 BOOL reg_io_r_enum_val(char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth)
1428 if (r_q == NULL)
1429 return False;
1431 prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1432 depth++;
1434 if(!prs_align(ps))
1435 return False;
1437 if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth))
1438 return False;
1439 if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1440 return False;
1441 if(!prs_align(ps))
1442 return False;
1444 if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type))
1445 return False;
1447 if (r_q->ptr_type != 0) {
1448 if(!prs_uint32("type", ps, depth, &r_q->type))
1449 return False;
1452 if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value))
1453 return False;
1454 if(!smb_io_buffer2("buf_value", &r_q->buf_value, r_q->ptr_value, ps, depth))
1455 return False;
1456 if(!prs_align(ps))
1457 return False;
1459 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1460 return False;
1461 if (r_q->ptr1 != 0) {
1462 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1))
1463 return False;
1466 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1467 return False;
1468 if (r_q->ptr2 != 0) {
1469 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2))
1470 return False;
1473 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1474 return False;
1476 return True;
1479 /*******************************************************************
1480 makes a structure.
1481 ********************************************************************/
1483 void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
1484 char *val_name, uint32 type,
1485 BUFFER3 *val)
1487 int val_len = strlen(val_name) + 1;
1489 ZERO_STRUCTP(q_i);
1491 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1493 init_uni_hdr(&q_i->hdr_name, val_len);
1494 init_unistr2(&q_i->uni_name, val_name, val_len);
1496 q_i->type = type;
1497 q_i->buf_value = val;
1500 /*******************************************************************
1501 reads or writes a structure.
1502 ********************************************************************/
1504 BOOL reg_io_q_create_val(char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth)
1506 if (q_q == NULL)
1507 return False;
1509 prs_debug(ps, depth, desc, "reg_io_q_create_val");
1510 depth++;
1512 if(!prs_align(ps))
1513 return False;
1515 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1516 return False;
1518 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1519 return False;
1520 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1521 return False;
1522 if(!prs_align(ps))
1523 return False;
1525 if(!prs_uint32("type", ps, depth, &q_q->type))
1526 return False;
1527 if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth))
1528 return False;
1529 if(!prs_align(ps))
1530 return False;
1532 return True;
1535 /*******************************************************************
1536 reads or writes a structure.
1537 ********************************************************************/
1539 BOOL reg_io_r_create_val(char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth)
1541 if (r_q == NULL)
1542 return False;
1544 prs_debug(ps, depth, desc, "reg_io_r_create_val");
1545 depth++;
1547 if(!prs_align(ps))
1548 return False;
1550 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1551 return False;
1553 return True;
1556 /*******************************************************************
1557 makes a structure.
1558 ********************************************************************/
1560 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx)
1562 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1564 q_i->key_index = key_idx;
1565 q_i->key_name_len = 0;
1566 q_i->unknown_1 = 0x0414;
1568 q_i->ptr1 = 1;
1569 q_i->unknown_2 = 0x0000020A;
1570 memset(q_i->pad1, 0, sizeof(q_i->pad1));
1572 q_i->ptr2 = 1;
1573 memset(q_i->pad2, 0, sizeof(q_i->pad2));
1575 q_i->ptr3 = 1;
1576 unix_to_nt_time(&q_i->time, 0); /* current time? */
1579 /*******************************************************************
1580 makes a reply structure.
1581 ********************************************************************/
1583 void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey, uint32 unknown_1,
1584 uint32 unknown_2)
1586 if ( !r_u )
1587 return;
1589 r_u->unknown_1 = unknown_1;
1590 r_u->unknown_2 = unknown_2;
1591 r_u->unknown_3 = 0x0;
1593 r_u->key_name_len = (strlen(subkey)+1) * 2;
1594 if (r_u->key_name_len)
1595 r_u->ptr1 = 0x1;
1596 init_unistr3( &r_u->key_name, subkey );
1598 r_u->ptr2 = 0x1;
1599 r_u->ptr3 = 0x1;
1602 /*******************************************************************
1603 reads or writes a structure.
1604 ********************************************************************/
1606 BOOL reg_io_q_enum_key(char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth)
1608 if (q_q == NULL)
1609 return False;
1611 prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1612 depth++;
1614 if(!prs_align(ps))
1615 return False;
1617 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1618 return False;
1620 if(!prs_uint32("key_index", ps, depth, &q_q->key_index))
1621 return False;
1622 if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len))
1623 return False;
1624 if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1))
1625 return False;
1627 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1628 return False;
1630 if (q_q->ptr1 != 0) {
1631 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2))
1632 return False;
1633 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)))
1634 return False;
1637 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1638 return False;
1640 if (q_q->ptr2 != 0) {
1641 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)))
1642 return False;
1645 if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3))
1646 return False;
1648 if (q_q->ptr3 != 0) {
1649 if(!smb_io_time("", &q_q->time, ps, depth))
1650 return False;
1653 return True;
1656 /*******************************************************************
1657 reads or writes a structure.
1658 ********************************************************************/
1660 BOOL reg_io_r_enum_key(char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth)
1662 if (r_q == NULL)
1663 return False;
1665 prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1666 depth++;
1668 if(!prs_align(ps))
1669 return False;
1671 if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len))
1672 return False;
1673 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
1674 return False;
1676 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1677 return False;
1679 if (r_q->ptr1 != 0) {
1680 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
1681 return False;
1682 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3))
1683 return False;
1684 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth))
1685 return False;
1686 if(!prs_align(ps))
1687 return False;
1690 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1691 return False;
1693 if (r_q->ptr2 != 0) {
1694 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
1695 return False;
1698 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
1699 return False;
1701 if (r_q->ptr3 != 0) {
1702 if(!smb_io_time("", &r_q->time, ps, depth))
1703 return False;
1706 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1707 return False;
1709 return True;
1712 /*******************************************************************
1713 makes a structure.
1714 ********************************************************************/
1716 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
1717 char *key_name, uint32 access_desired)
1719 int len_name = strlen(key_name)+1;
1721 memcpy(&r_q->pol, pol, sizeof(r_q->pol));
1723 init_uni_hdr(&r_q->hdr_name, len_name);
1724 init_unistr2(&r_q->uni_name, key_name, len_name);
1726 r_q->unknown_0 = 0x00000000;
1727 r_q->access_desired = access_desired;
1730 /*******************************************************************
1731 reads or writes a structure.
1732 ********************************************************************/
1734 BOOL reg_io_q_open_entry(char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
1736 if (r_q == NULL)
1737 return False;
1739 prs_debug(ps, depth, desc, "reg_io_q_entry");
1740 depth++;
1742 if(!prs_align(ps))
1743 return False;
1745 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1746 return False;
1747 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
1748 return False;
1749 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1750 return False;
1752 if(!prs_align(ps))
1753 return False;
1755 if(!prs_uint32("unknown_0 ", ps, depth, &r_q->unknown_0))
1756 return False;
1757 if(!prs_uint32("asccess_desired ", ps, depth, &r_q->access_desired))
1758 return False;
1760 return True;
1763 /*******************************************************************
1764 Inits a structure.
1765 ********************************************************************/
1767 void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
1768 POLICY_HND *pol, NTSTATUS status)
1770 memcpy(&r_r->pol, pol, sizeof(r_r->pol));
1771 r_r->status = status;
1774 /*******************************************************************
1775 reads or writes a structure.
1776 ********************************************************************/
1778 BOOL reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
1780 if (r_r == NULL)
1781 return False;
1783 prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1784 depth++;
1786 if(!prs_align(ps))
1787 return False;
1789 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
1790 return False;
1792 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1793 return False;
1795 return True;
1798 /*******************************************************************
1799 Inits a structure.
1800 ********************************************************************/
1801 void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s,
1802 const char *msg, uint32 timeout, uint16 flags)
1804 int msg_len;
1805 msg_len = strlen(msg);
1807 q_s->ptr_0 = 1;
1808 q_s->ptr_1 = 1;
1809 q_s->ptr_2 = 1;
1811 init_uni_hdr(&(q_s->hdr_msg), msg_len);
1812 init_unistr2(&(q_s->uni_msg), msg, msg_len);
1814 q_s->timeout = timeout;
1815 q_s->flags = flags;
1819 /*******************************************************************
1820 reads or writes a structure.
1821 ********************************************************************/
1822 BOOL reg_io_q_shutdown(char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps,
1823 int depth)
1825 if (q_s == NULL)
1826 return False;
1828 prs_debug(ps, depth, desc, "reg_io_q_shutdown");
1829 depth++;
1831 if (!prs_align(ps))
1832 return False;
1834 if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0)))
1835 return False;
1836 if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1)))
1837 return False;
1838 if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2)))
1839 return False;
1841 if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth))
1842 return False;
1843 if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth))
1844 return False;
1845 if (!prs_align(ps))
1846 return False;
1848 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
1849 return False;
1850 if (!prs_uint16("flags ", ps, depth, &(q_s->flags)))
1851 return False;
1853 return True;
1856 /*******************************************************************
1857 reads or writes a structure.
1858 ********************************************************************/
1859 BOOL reg_io_r_shutdown(char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps,
1860 int depth)
1862 if (r_s == NULL)
1863 return False;
1865 prs_debug(ps, depth, desc, "reg_io_r_shutdown");
1866 depth++;
1868 if(!prs_align(ps))
1869 return False;
1871 if(!prs_ntstatus("status", ps, depth, &r_s->status))
1872 return False;
1874 return True;
1877 /*******************************************************************
1878 Inits a structure.
1879 ********************************************************************/
1880 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s)
1883 q_s->ptr_server = 0;
1887 /*******************************************************************
1888 reads or writes a structure.
1889 ********************************************************************/
1890 BOOL reg_io_q_abort_shutdown(char *desc, REG_Q_ABORT_SHUTDOWN * q_s,
1891 prs_struct *ps, int depth)
1893 if (q_s == NULL)
1894 return False;
1896 prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
1897 depth++;
1899 if (!prs_align(ps))
1900 return False;
1902 if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
1903 return False;
1904 if (q_s->ptr_server != 0)
1905 if (!prs_uint16("server", ps, depth, &(q_s->server)))
1906 return False;
1908 return True;
1911 /*******************************************************************
1912 reads or writes a structure.
1913 ********************************************************************/
1914 BOOL reg_io_r_abort_shutdown(char *desc, REG_R_ABORT_SHUTDOWN * r_s,
1915 prs_struct *ps, int depth)
1917 if (r_s == NULL)
1918 return False;
1920 prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
1921 depth++;
1923 if (!prs_align(ps))
1924 return False;
1926 if (!prs_ntstatus("status", ps, depth, &r_s->status))
1927 return False;
1929 return True;