Enable checking/resetting of account lockout and bad password based on policy
[Samba/gebeck_regimport.git] / source / rpc_parse / parse_reg.c
blob69c0dfc75486a9d367a4e5fe238db0c14a5b737e
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 * Copyright (C) Paul Ashton 1997.
7 * Copyright (C) Marc Jacobsen 1999.
8 * Copyright (C) Simo Sorce 2000.
9 * Copyright (C) Gerald Carter 2002.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "includes.h"
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_PARSE
31 /*******************************************************************
32 Fill in a BUFFER2 for the data given a REGISTRY_VALUE
33 *******************************************************************/
35 static uint32 reg_init_buffer2( BUFFER2 *buf2, REGISTRY_VALUE *val )
37 uint32 real_size = 0;
39 if ( !buf2 || !val )
40 return 0;
42 real_size = regval_size(val);
43 init_buffer2( buf2, (unsigned char*)regval_data_p(val), real_size );
45 return real_size;
48 /*******************************************************************
49 Inits a structure.
50 ********************************************************************/
52 void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o,
53 uint16 unknown_0, uint32 level)
55 q_o->ptr = 1;
56 q_o->unknown_0 = unknown_0;
57 q_o->unknown_1 = 0x0; /* random - changes */
58 q_o->level = level;
61 /*******************************************************************
62 reads or writes a structure.
63 ********************************************************************/
65 BOOL reg_io_q_open_hkcr(const char *desc, REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth)
67 if (r_q == NULL)
68 return False;
70 prs_debug(ps, depth, desc, "reg_io_q_open_hkcr");
71 depth++;
73 if(!prs_align(ps))
74 return False;
76 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
77 return False;
79 if (r_q->ptr != 0) {
80 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0))
81 return False;
82 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
83 return False;
84 if(!prs_uint32("level ", ps, depth, &r_q->level))
85 return False;
88 return True;
92 /*******************************************************************
93 reads or writes a structure.
94 ********************************************************************/
96 BOOL reg_io_r_open_hkcr(const char *desc, REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth)
98 if (r_r == NULL)
99 return False;
101 prs_debug(ps, depth, desc, "reg_io_r_open_hkcr");
102 depth++;
104 if(!prs_align(ps))
105 return False;
107 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
108 return False;
110 if(!prs_ntstatus("status", ps, depth, &r_r->status))
111 return False;
113 return True;
116 /*******************************************************************
117 Inits a structure.
118 ********************************************************************/
120 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o,
121 uint16 unknown_0, uint32 access_mask)
123 q_o->ptr = 1;
124 q_o->unknown_0 = unknown_0;
125 q_o->unknown_1 = 0x0; /* random - changes */
126 q_o->access_mask = access_mask;
130 /*******************************************************************
131 reads or writes a structure.
132 ********************************************************************/
133 BOOL reg_io_q_open_hklm(const char *desc, REG_Q_OPEN_HKLM * r_q, prs_struct *ps,
134 int depth)
136 if (r_q == NULL)
137 return False;
139 prs_debug(ps, depth, desc, "reg_io_q_open_hklm");
140 depth++;
142 if (!prs_align(ps))
143 return False;
145 if (!prs_uint32("ptr ", ps, depth, &(r_q->ptr)))
146 return False;
147 if (r_q->ptr != 0)
149 if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0)))
150 return False;
151 if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)))
152 return False;
153 if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask)))
154 return False;
157 return True;
161 /*******************************************************************
162 reads or writes a structure.
163 ********************************************************************/
164 BOOL reg_io_r_open_hklm(const char *desc, REG_R_OPEN_HKLM * r_r, prs_struct *ps,
165 int depth)
167 if (r_r == NULL)
168 return False;
170 prs_debug(ps, depth, desc, "reg_io_r_open_hklm");
171 depth++;
173 if (!prs_align(ps))
174 return False;
176 if (!smb_io_pol_hnd("", &r_r->pol, ps, depth))
177 return False;
179 if (!prs_ntstatus("status", ps, depth, &r_r->status))
180 return False;
182 return True;
188 /*******************************************************************
189 Inits a structure.
190 ********************************************************************/
192 void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol)
194 memcpy(&q_u->pol, pol, sizeof(q_u->pol));
197 /*******************************************************************
198 reads or writes a structure.
199 ********************************************************************/
201 BOOL reg_io_q_flush_key(const char *desc, REG_Q_FLUSH_KEY *r_q, prs_struct *ps, int depth)
203 if (r_q == NULL)
204 return False;
206 prs_debug(ps, depth, desc, "reg_io_q_flush_key");
207 depth++;
209 if(!prs_align(ps))
210 return False;
212 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
213 return False;
215 return True;
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, int depth)
224 if (r_r == NULL)
225 return False;
227 prs_debug(ps, depth, desc, "reg_io_r_flush_key");
228 depth++;
230 if(!prs_align(ps))
231 return False;
233 if(!prs_ntstatus("status", ps, depth, &r_r->status))
234 return False;
236 return True;
239 /*******************************************************************
240 reads or writes SEC_DESC_BUF and SEC_DATA structures.
241 ********************************************************************/
243 static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DESC_BUF *data, prs_struct *ps, int depth)
245 if (ptr != 0) {
246 uint32 hdr_offset;
247 uint32 old_offset;
248 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset))
249 return False;
251 old_offset = prs_offset(ps);
253 if (ptr3 != NULL) {
254 if(!prs_uint32("ptr3", ps, depth, ptr3))
255 return False;
258 if (ptr3 == NULL || *ptr3 != 0) {
259 if(!sec_io_desc_buf("data ", &data, ps, depth)) /* JRA - this line is probably wrong... */
260 return False;
263 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset,
264 data->max_len, data->len))
265 return False;
266 if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3)))
267 return False;
269 if(!prs_align(ps))
270 return False;
273 return True;
276 /*******************************************************************
277 Inits a structure.
278 ********************************************************************/
280 void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd,
281 char *name, char *class, SEC_ACCESS *sam_access,
282 SEC_DESC_BUF *sec_buf)
284 ZERO_STRUCTP(q_c);
286 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
288 init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE);
289 init_uni_hdr(&q_c->hdr_name, &q_c->uni_name);
291 init_unistr2(&q_c->uni_class, class, UNI_STR_TERMINATE);
292 init_uni_hdr(&q_c->hdr_class, &q_c->uni_class);
294 q_c->reserved = 0x00000000;
295 memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access));
297 q_c->ptr1 = 1;
298 q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
300 q_c->data = sec_buf;
301 q_c->ptr2 = 1;
302 init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len);
303 q_c->ptr3 = 1;
304 q_c->unknown_2 = 0x00000000;
307 /*******************************************************************
308 reads or writes a structure.
309 ********************************************************************/
311 BOOL reg_io_q_create_key(const char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth)
313 if (r_q == NULL)
314 return False;
316 prs_debug(ps, depth, desc, "reg_io_q_create_key");
317 depth++;
319 if(!prs_align(ps))
320 return False;
322 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
323 return False;
325 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
326 return False;
327 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
328 return False;
329 if(!prs_align(ps))
330 return False;
332 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
333 return False;
334 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
335 return False;
336 if(!prs_align(ps))
337 return False;
339 if(!prs_uint32("reserved", ps, depth, &r_q->reserved))
340 return False;
341 if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth))
342 return False;
344 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
345 return False;
347 if (r_q->ptr1 != 0) {
348 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
349 return False;
352 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
353 return False;
354 if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth))
355 return False;
357 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
358 return False;
360 return True;
363 /*******************************************************************
364 reads or writes a structure.
365 ********************************************************************/
367 BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth)
369 if (r_r == NULL)
370 return False;
372 prs_debug(ps, depth, desc, "reg_io_r_create_key");
373 depth++;
375 if(!prs_align(ps))
376 return False;
378 if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth))
379 return False;
380 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
381 return False;
383 if(!prs_ntstatus("status", ps, depth, &r_r->status))
384 return False;
386 return True;
390 /*******************************************************************
391 Inits a structure.
392 ********************************************************************/
394 void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd,
395 char *name)
397 ZERO_STRUCTP(q_c);
399 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
401 init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE);
402 init_uni_hdr(&q_c->hdr_name, &q_c->uni_name);
405 /*******************************************************************
406 reads or writes a structure.
407 ********************************************************************/
409 BOOL reg_io_q_delete_val(const char *desc, REG_Q_DELETE_VALUE *r_q, prs_struct *ps, int depth)
411 if (r_q == NULL)
412 return False;
414 prs_debug(ps, depth, desc, "reg_io_q_delete_val");
415 depth++;
417 if(!prs_align(ps))
418 return False;
420 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
421 return False;
423 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
424 return False;
425 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
426 return False;
427 if(!prs_align(ps))
428 return False;
430 return True;
434 /*******************************************************************
435 reads or writes a structure.
436 ********************************************************************/
438 BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_r, prs_struct *ps, int depth)
440 if (r_r == NULL)
441 return False;
443 prs_debug(ps, depth, desc, "reg_io_r_delete_val");
444 depth++;
446 if(!prs_align(ps))
447 return False;
449 if(!prs_ntstatus("status", ps, depth, &r_r->status))
450 return False;
452 return True;
455 /*******************************************************************
456 Inits a structure.
457 ********************************************************************/
459 void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
460 char *name)
462 ZERO_STRUCTP(q_c);
464 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
466 init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE);
467 init_uni_hdr(&q_c->hdr_name, &q_c->uni_name);
470 /*******************************************************************
471 reads or writes a structure.
472 ********************************************************************/
474 BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth)
476 if (r_q == NULL)
477 return False;
479 prs_debug(ps, depth, desc, "reg_io_q_delete_key");
480 depth++;
482 if(!prs_align(ps))
483 return False;
485 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
486 return False;
488 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
489 return False;
490 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
491 return False;
492 if(!prs_align(ps))
493 return False;
495 return True;
498 /*******************************************************************
499 reads or writes a structure.
500 ********************************************************************/
502 BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth)
504 if (r_r == NULL)
505 return False;
507 prs_debug(ps, depth, desc, "reg_io_r_delete_key");
508 depth++;
510 if(!prs_align(ps))
511 return False;
513 if(!prs_ntstatus("status", ps, depth, &r_r->status))
514 return False;
516 return True;
519 /*******************************************************************
520 Inits a structure.
521 ********************************************************************/
523 void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, UNISTR2 *uni2)
525 ZERO_STRUCTP(q_o);
527 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
528 init_uni_hdr(&q_o->hdr_class, uni2);
531 /*******************************************************************
532 reads or writes a structure.
533 ********************************************************************/
535 BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth)
537 if (r_q == NULL)
538 return False;
540 prs_debug(ps, depth, desc, "reg_io_q_query_key");
541 depth++;
543 if(!prs_align(ps))
544 return False;
546 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
547 return False;
548 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
549 return False;
550 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
551 return False;
553 if(!prs_align(ps))
554 return False;
556 return True;
560 /*******************************************************************
561 reads or writes a structure.
562 ********************************************************************/
564 BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth)
566 if (r_r == NULL)
567 return False;
569 prs_debug(ps, depth, desc, "reg_io_r_query_key");
570 depth++;
572 if(!prs_align(ps))
573 return False;
575 if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth))
576 return False;
577 if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth))
578 return False;
580 if(!prs_align(ps))
581 return False;
583 if(!prs_uint32("num_subkeys ", ps, depth, &r_r->num_subkeys))
584 return False;
585 if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen))
586 return False;
587 if(!prs_uint32("reserved ", ps, depth, &r_r->reserved))
588 return False;
589 if(!prs_uint32("num_values ", ps, depth, &r_r->num_values))
590 return False;
591 if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen))
592 return False;
593 if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize))
594 return False;
595 if(!prs_uint32("sec_desc ", ps, depth, &r_r->sec_desc))
596 return False;
597 if(!smb_io_time("mod_time ", &r_r->mod_time, ps, depth))
598 return False;
600 if(!prs_ntstatus("status", ps, depth, &r_r->status))
601 return False;
603 return True;
606 /*******************************************************************
607 Inits a structure.
608 ********************************************************************/
610 void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A *q_o, POLICY_HND *hnd)
612 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
616 /*******************************************************************
617 reads or writes a structure.
618 ********************************************************************/
620 BOOL reg_io_q_unknown_1a(const char *desc, REG_Q_UNKNOWN_1A *r_q, prs_struct *ps, int depth)
622 if (r_q == NULL)
623 return False;
625 prs_debug(ps, depth, desc, "reg_io_q_unknown_1a");
626 depth++;
628 if(!prs_align(ps))
629 return False;
631 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
632 return False;
634 return True;
637 /*******************************************************************
638 reads or writes a structure.
639 ********************************************************************/
641 BOOL reg_io_r_unknown_1a(const char *desc, REG_R_UNKNOWN_1A *r_r, prs_struct *ps, int depth)
643 if (r_r == NULL)
644 return False;
646 prs_debug(ps, depth, desc, "reg_io_r_unknown_1a");
647 depth++;
649 if(!prs_align(ps))
650 return False;
652 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
653 return False;
654 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
655 return False;
657 return True;
661 /*******************************************************************
662 reads or writes a structure.
663 ********************************************************************/
665 BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *r_q, prs_struct *ps, int depth)
667 if (r_q == NULL)
668 return False;
670 prs_debug(ps, depth, desc, "reg_io_q_save_key");
671 depth++;
673 if(!prs_align(ps))
674 return False;
676 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
677 return False;
679 if(!smb_io_unihdr ("hdr_file", &r_q->hdr_file, ps, depth))
680 return False;
681 if(!smb_io_unistr2("uni_file", &r_q->uni_file, r_q->hdr_file.buffer, ps, depth))
682 return False;
684 if(!prs_uint32("unknown", ps, depth, &r_q->unknown))
685 return False;
687 return True;
690 /*******************************************************************
691 reads or writes a structure.
692 ********************************************************************/
694 BOOL reg_io_r_save_key(const char *desc, REG_R_SAVE_KEY *r_r, prs_struct *ps, int depth)
696 if (r_r == NULL)
697 return False;
699 prs_debug(ps, depth, desc, "reg_io_r_save_key");
700 depth++;
702 if(!prs_align(ps))
703 return False;
705 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
706 return False;
708 return True;
711 /*******************************************************************
712 Inits a structure.
713 ********************************************************************/
715 void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o,
716 uint16 unknown_0, uint32 access_mask)
718 q_o->ptr = 1;
719 q_o->unknown_0 = unknown_0;
720 q_o->unknown_1 = 0x0; /* random - changes */
721 q_o->access_mask = access_mask;
724 /*******************************************************************
725 reads or writes a structure.
726 ********************************************************************/
728 BOOL reg_io_q_open_hku(const char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth)
730 if (r_q == NULL)
731 return False;
733 prs_debug(ps, depth, desc, "reg_io_q_open_hku");
734 depth++;
736 if(!prs_align(ps))
737 return False;
739 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
740 return False;
741 if (r_q->ptr != 0) {
742 if(!prs_uint16("unknown_0 ", ps, depth, &r_q->unknown_0))
743 return False;
744 if(!prs_uint16("unknown_1 ", ps, depth, &r_q->unknown_1))
745 return False;
746 if(!prs_uint32("access_mask ", ps, depth, &r_q->access_mask))
747 return False;
750 return True;
753 /*******************************************************************
754 reads or writes a structure.
755 ********************************************************************/
757 BOOL reg_io_r_open_hku(const char *desc, REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth)
759 if (r_r == NULL)
760 return False;
762 prs_debug(ps, depth, desc, "reg_io_r_open_hku");
763 depth++;
765 if(!prs_align(ps))
766 return False;
768 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
769 return False;
771 if(!prs_ntstatus("status", ps, depth, &r_r->status))
772 return False;
774 return True;
777 /*******************************************************************
778 Inits an REG_Q_CLOSE structure.
779 ********************************************************************/
781 void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
783 DEBUG(5,("init_reg_q_close\n"));
785 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
788 /*******************************************************************
789 reads or writes a structure.
790 ********************************************************************/
792 BOOL reg_io_q_close(const char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
794 if (q_u == NULL)
795 return False;
797 prs_debug(ps, depth, desc, "reg_io_q_close");
798 depth++;
800 if(!prs_align(ps))
801 return False;
803 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
804 return False;
805 if(!prs_align(ps))
806 return False;
808 return True;
811 /*******************************************************************
812 reads or writes a structure.
813 ********************************************************************/
815 BOOL reg_io_r_close(const char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth)
817 if (r_u == NULL)
818 return False;
820 prs_debug(ps, depth, desc, "reg_io_r_close");
821 depth++;
823 if(!prs_align(ps))
824 return False;
826 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
827 return False;
828 if(!prs_align(ps))
829 return False;
831 if(!prs_ntstatus("status", ps, depth, &r_u->status))
832 return False;
834 return True;
837 /*******************************************************************
838 makes a structure.
839 ********************************************************************/
841 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf)
843 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
845 q_i->sec_info = DACL_SECURITY_INFORMATION;
847 q_i->ptr = 1;
848 init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len);
849 q_i->data = sec_desc_buf;
852 /*******************************************************************
853 reads or writes a structure.
854 ********************************************************************/
856 BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
858 if (r_q == NULL)
859 return False;
861 prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
862 depth++;
864 if(!prs_align(ps))
865 return False;
867 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
868 return False;
870 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
871 return False;
872 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
873 return False;
875 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
876 return False;
878 return True;
881 /*******************************************************************
882 reads or writes a structure.
883 ********************************************************************/
885 BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth)
887 if (r_q == NULL)
888 return False;
890 prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
891 depth++;
893 if(!prs_align(ps))
894 return False;
896 if(!prs_ntstatus("status", ps, depth, &r_q->status))
897 return False;
899 return True;
903 /*******************************************************************
904 makes a structure.
905 ********************************************************************/
907 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol,
908 uint32 sec_buf_size, SEC_DESC_BUF *psdb)
910 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
912 q_i->sec_info = OWNER_SECURITY_INFORMATION |
913 GROUP_SECURITY_INFORMATION |
914 DACL_SECURITY_INFORMATION;
916 q_i->ptr = psdb != NULL ? 1 : 0;
917 q_i->data = psdb;
919 init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0);
922 /*******************************************************************
923 reads or writes a structure.
924 ********************************************************************/
926 BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
928 if (r_q == NULL)
929 return False;
931 prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
932 depth++;
934 if(!prs_align(ps))
935 return False;
937 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
938 return False;
940 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
941 return False;
942 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
943 return False;
945 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
946 return False;
948 return True;
951 #if 0
952 /*******************************************************************
953 makes a structure.
954 ********************************************************************/
955 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
956 uint32 buf_len, uint8 *buf,
957 NTSTATUS status)
959 r_i->ptr = 1;
960 init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len);
961 init_sec_desc_buf(r_i->data, buf_len, 1);
963 r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
965 #endif
967 /*******************************************************************
968 reads or writes a structure.
969 ********************************************************************/
971 BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth)
973 if (r_q == NULL)
974 return False;
976 prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
977 depth++;
979 if(!prs_align(ps))
980 return False;
982 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
983 return False;
985 if (r_q->ptr != 0) {
986 if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth))
987 return False;
988 if(!sec_io_desc_buf("", &r_q->data, ps, depth))
989 return False;
990 if(!prs_align(ps))
991 return False;
994 if(!prs_ntstatus("status", ps, depth, &r_q->status))
995 return False;
997 return True;
1000 /*******************************************************************
1001 makes a structure.
1002 ********************************************************************/
1004 BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name)
1006 if (q_i == NULL)
1007 return False;
1009 q_i->pol = *pol;
1011 init_unistr2(&q_i->uni_type, val_name, UNI_STR_TERMINATE);
1012 init_uni_hdr(&q_i->hdr_type, &q_i->uni_type);
1014 q_i->ptr_reserved = 1;
1015 q_i->ptr_buf = 1;
1017 q_i->ptr_bufsize = 1;
1018 q_i->bufsize = 0;
1019 q_i->buf_unk = 0;
1021 q_i->unk1 = 0;
1022 q_i->ptr_buflen = 1;
1023 q_i->buflen = 0;
1025 q_i->ptr_buflen2 = 1;
1026 q_i->buflen2 = 0;
1028 return True;
1031 /*******************************************************************
1032 reads or writes a structure.
1033 ********************************************************************/
1035 BOOL reg_io_q_info(const char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth)
1037 if (r_q == NULL)
1038 return False;
1040 prs_debug(ps, depth, desc, "reg_io_q_info");
1041 depth++;
1043 if(!prs_align(ps))
1044 return False;
1046 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1047 return False;
1048 if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth))
1049 return False;
1050 if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth))
1051 return False;
1053 if(!prs_align(ps))
1054 return False;
1056 if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved)))
1057 return False;
1059 if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf)))
1060 return False;
1062 if(r_q->ptr_buf) {
1063 if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize)))
1064 return False;
1065 if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize)))
1066 return False;
1067 if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk)))
1068 return False;
1071 if(!prs_uint32("unk1", ps, depth, &(r_q->unk1)))
1072 return False;
1074 if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen)))
1075 return False;
1077 if (r_q->ptr_buflen) {
1078 if(!prs_uint32("buflen", ps, depth, &(r_q->buflen)))
1079 return False;
1080 if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2)))
1081 return False;
1082 if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2)))
1083 return False;
1086 return True;
1089 /*******************************************************************
1090 Inits a structure.
1091 New version to replace older init_reg_r_info()
1092 ********************************************************************/
1094 BOOL new_init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1095 REGISTRY_VALUE *val, NTSTATUS status)
1097 uint32 buf_len = 0;
1098 BUFFER2 buf2;
1100 if(r_r == NULL)
1101 return False;
1103 if ( !val )
1104 return False;
1106 r_r->ptr_type = 1;
1107 r_r->type = val->type;
1109 /* if include_keyval is not set, don't send the key value, just
1110 the buflen data. probably used by NT5 to allocate buffer space - SK */
1112 if ( include_keyval ) {
1113 r_r->ptr_uni_val = 1;
1114 buf_len = reg_init_buffer2( &r_r->uni_val, val );
1117 else {
1118 /* dummy buffer used so we can get the size */
1119 r_r->ptr_uni_val = 0;
1120 buf_len = reg_init_buffer2( &buf2, val );
1123 r_r->ptr_max_len = 1;
1124 r_r->buf_max_len = buf_len;
1126 r_r->ptr_len = 1;
1127 r_r->buf_len = buf_len;
1129 r_r->status = status;
1131 return True;
1134 /*******************************************************************
1135 Inits a structure.
1136 ********************************************************************/
1138 BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1139 BUFFER2* buf, uint32 type, NTSTATUS status)
1141 if(r_r == NULL)
1142 return False;
1144 r_r->ptr_type = 1;
1145 r_r->type = type;
1147 /* if include_keyval is not set, don't send the key value, just
1148 the buflen data. probably used by NT5 to allocate buffer space - SK */
1150 r_r->ptr_uni_val = include_keyval ? 1:0;
1151 r_r->uni_val = *buf;
1153 r_r->ptr_max_len = 1;
1154 r_r->buf_max_len = r_r->uni_val.buf_max_len;
1156 r_r->ptr_len = 1;
1157 r_r->buf_len = r_r->uni_val.buf_len;
1159 r_r->status = status;
1161 return True;
1164 /*******************************************************************
1165 reads or writes a structure.
1166 ********************************************************************/
1168 BOOL reg_io_r_info(const char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
1170 if (r_r == NULL)
1171 return False;
1173 prs_debug(ps, depth, desc, "reg_io_r_info");
1174 depth++;
1176 if(!prs_align(ps))
1177 return False;
1179 if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type)))
1180 return False;
1182 if (r_r->ptr_type != 0) {
1183 if(!prs_uint32("type", ps, depth, &r_r->type))
1184 return False;
1187 if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val)))
1188 return False;
1190 if(r_r->ptr_uni_val != 0) {
1191 if(!smb_io_buffer2("uni_val", &r_r->uni_val, r_r->ptr_uni_val, ps, depth))
1192 return False;
1195 if(!prs_align(ps))
1196 return False;
1198 if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len)))
1199 return False;
1201 if (r_r->ptr_max_len != 0) {
1202 if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len)))
1203 return False;
1206 if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len)))
1207 return False;
1208 if (r_r->ptr_len != 0) {
1209 if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len)))
1210 return False;
1213 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1214 return False;
1216 return True;
1219 /*******************************************************************
1220 makes a structure.
1221 ********************************************************************/
1223 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
1224 uint32 val_idx, UNISTR2 *uni2,
1225 uint32 max_buf_len)
1227 ZERO_STRUCTP(q_i);
1229 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1231 q_i->val_index = val_idx;
1232 init_uni_hdr(&q_i->hdr_name, uni2);
1234 q_i->ptr_type = 1;
1235 q_i->type = 0x0;
1237 q_i->ptr_value = 1;
1238 q_i->buf_value.buf_max_len = max_buf_len;
1240 q_i->ptr1 = 1;
1241 q_i->len_value1 = max_buf_len;
1243 q_i->ptr2 = 1;
1244 q_i->len_value2 = 0;
1247 /*******************************************************************
1248 makes a structure.
1249 ********************************************************************/
1251 void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val )
1253 uint32 real_size;
1255 DEBUG(8,("init_reg_r_enum_val: Enter\n"));
1257 ZERO_STRUCTP(r_u);
1259 /* value name */
1261 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename));
1263 init_unistr2( &r_u->uni_name, val->valuename, UNI_STR_TERMINATE);
1264 init_uni_hdr( &r_u->hdr_name, &r_u->uni_name);
1266 /* type */
1268 r_u->ptr_type = 1;
1269 r_u->type = val->type;
1271 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1273 r_u->ptr_value = 1;
1274 real_size = reg_init_buffer2( &r_u->buf_value, val );
1276 /* lengths */
1278 r_u->ptr1 = 1;
1279 r_u->len_value1 = real_size;
1281 r_u->ptr2 = 1;
1282 r_u->len_value2 = real_size;
1284 DEBUG(8,("init_reg_r_enum_val: Exit\n"));
1287 /*******************************************************************
1288 reads or writes a structure.
1289 ********************************************************************/
1291 BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth)
1293 if (q_q == NULL)
1294 return False;
1296 prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1297 depth++;
1299 if(!prs_align(ps))
1300 return False;
1302 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1303 return False;
1305 if(!prs_uint32("val_index", ps, depth, &q_q->val_index))
1306 return False;
1308 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1309 return False;
1310 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1311 return False;
1312 if(!prs_align(ps))
1313 return False;
1315 if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type))
1316 return False;
1318 if (q_q->ptr_type != 0) {
1319 if(!prs_uint32("type", ps, depth, &q_q->type))
1320 return False;
1323 if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value))
1324 return False;
1325 if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth))
1326 return False;
1327 if(!prs_align(ps))
1328 return False;
1330 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1331 return False;
1332 if (q_q->ptr1 != 0) {
1333 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1))
1334 return False;
1336 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1337 return False;
1338 if (q_q->ptr2 != 0) {
1339 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2))
1340 return False;
1343 return True;
1346 /*******************************************************************
1347 reads or writes a structure.
1348 ********************************************************************/
1350 BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth)
1352 if (r_q == NULL)
1353 return False;
1355 prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1356 depth++;
1358 if(!prs_align(ps))
1359 return False;
1361 if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth))
1362 return False;
1363 if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1364 return False;
1365 if(!prs_align(ps))
1366 return False;
1368 if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type))
1369 return False;
1371 if (r_q->ptr_type != 0) {
1372 if(!prs_uint32("type", ps, depth, &r_q->type))
1373 return False;
1376 if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value))
1377 return False;
1378 if(!smb_io_buffer2("buf_value", &r_q->buf_value, r_q->ptr_value, ps, depth))
1379 return False;
1380 if(!prs_align(ps))
1381 return False;
1383 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1384 return False;
1385 if (r_q->ptr1 != 0) {
1386 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1))
1387 return False;
1390 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1391 return False;
1392 if (r_q->ptr2 != 0) {
1393 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2))
1394 return False;
1397 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1398 return False;
1400 return True;
1403 /*******************************************************************
1404 makes a structure.
1405 ********************************************************************/
1407 void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
1408 char *val_name, uint32 type,
1409 BUFFER3 *val)
1411 ZERO_STRUCTP(q_i);
1413 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1415 init_unistr2(&q_i->uni_name, val_name, UNI_STR_TERMINATE);
1416 init_uni_hdr(&q_i->hdr_name, &q_i->uni_name);
1418 q_i->type = type;
1419 q_i->buf_value = val;
1422 /*******************************************************************
1423 reads or writes a structure.
1424 ********************************************************************/
1426 BOOL reg_io_q_create_val(const char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth)
1428 if (q_q == NULL)
1429 return False;
1431 prs_debug(ps, depth, desc, "reg_io_q_create_val");
1432 depth++;
1434 if(!prs_align(ps))
1435 return False;
1437 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1438 return False;
1440 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1441 return False;
1442 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1443 return False;
1444 if(!prs_align(ps))
1445 return False;
1447 if(!prs_uint32("type", ps, depth, &q_q->type))
1448 return False;
1449 if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth))
1450 return False;
1451 if(!prs_align(ps))
1452 return False;
1454 return True;
1457 /*******************************************************************
1458 reads or writes a structure.
1459 ********************************************************************/
1461 BOOL reg_io_r_create_val(const char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth)
1463 if (r_q == NULL)
1464 return False;
1466 prs_debug(ps, depth, desc, "reg_io_r_create_val");
1467 depth++;
1469 if(!prs_align(ps))
1470 return False;
1472 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1473 return False;
1475 return True;
1478 /*******************************************************************
1479 makes a structure.
1480 ********************************************************************/
1482 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx)
1484 memcpy(&q_i->pol, pol, sizeof(q_i->pol));
1486 q_i->key_index = key_idx;
1487 q_i->key_name_len = 0;
1488 q_i->unknown_1 = 0x0414;
1490 q_i->ptr1 = 1;
1491 q_i->unknown_2 = 0x0000020A;
1492 memset(q_i->pad1, 0, sizeof(q_i->pad1));
1494 q_i->ptr2 = 1;
1495 memset(q_i->pad2, 0, sizeof(q_i->pad2));
1497 q_i->ptr3 = 1;
1498 unix_to_nt_time(&q_i->time, 0); /* current time? */
1501 /*******************************************************************
1502 makes a reply structure.
1503 ********************************************************************/
1505 void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey, uint32 unknown_1,
1506 uint32 unknown_2)
1508 if ( !r_u )
1509 return;
1511 r_u->unknown_1 = unknown_1;
1512 r_u->unknown_2 = unknown_2;
1513 r_u->unknown_3 = 0x0;
1515 r_u->key_name_len = (strlen(subkey)+1) * 2;
1516 if (r_u->key_name_len)
1517 r_u->ptr1 = 0x1;
1518 init_unistr3( &r_u->key_name, subkey );
1520 r_u->ptr2 = 0x1;
1521 r_u->ptr3 = 0x1;
1524 /*******************************************************************
1525 reads or writes a structure.
1526 ********************************************************************/
1528 BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth)
1530 if (q_q == NULL)
1531 return False;
1533 prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1534 depth++;
1536 if(!prs_align(ps))
1537 return False;
1539 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1540 return False;
1542 if(!prs_uint32("key_index", ps, depth, &q_q->key_index))
1543 return False;
1544 if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len))
1545 return False;
1546 if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1))
1547 return False;
1549 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1550 return False;
1552 if (q_q->ptr1 != 0) {
1553 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2))
1554 return False;
1555 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)))
1556 return False;
1559 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1560 return False;
1562 if (q_q->ptr2 != 0) {
1563 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)))
1564 return False;
1567 if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3))
1568 return False;
1570 if (q_q->ptr3 != 0) {
1571 if(!smb_io_time("", &q_q->time, ps, depth))
1572 return False;
1575 return True;
1578 /*******************************************************************
1579 reads or writes a structure.
1580 ********************************************************************/
1582 BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth)
1584 if (r_q == NULL)
1585 return False;
1587 prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1588 depth++;
1590 if(!prs_align(ps))
1591 return False;
1593 if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len))
1594 return False;
1595 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
1596 return False;
1598 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1599 return False;
1601 if (r_q->ptr1 != 0) {
1602 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
1603 return False;
1604 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3))
1605 return False;
1606 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth))
1607 return False;
1608 if(!prs_align(ps))
1609 return False;
1612 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1613 return False;
1615 if (r_q->ptr2 != 0) {
1616 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
1617 return False;
1620 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
1621 return False;
1623 if (r_q->ptr3 != 0) {
1624 if(!smb_io_time("", &r_q->time, ps, depth))
1625 return False;
1628 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1629 return False;
1631 return True;
1634 /*******************************************************************
1635 makes a structure.
1636 ********************************************************************/
1638 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
1639 char *key_name, uint32 access_desired)
1641 memcpy(&r_q->pol, pol, sizeof(r_q->pol));
1643 init_unistr2(&r_q->uni_name, key_name, UNI_STR_TERMINATE);
1644 init_uni_hdr(&r_q->hdr_name, &r_q->uni_name);
1646 r_q->unknown_0 = 0x00000000;
1647 r_q->access_desired = access_desired;
1650 /*******************************************************************
1651 reads or writes a structure.
1652 ********************************************************************/
1654 BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
1656 if (r_q == NULL)
1657 return False;
1659 prs_debug(ps, depth, desc, "reg_io_q_entry");
1660 depth++;
1662 if(!prs_align(ps))
1663 return False;
1665 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1666 return False;
1667 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
1668 return False;
1669 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1670 return False;
1672 if(!prs_align(ps))
1673 return False;
1675 if(!prs_uint32("unknown_0 ", ps, depth, &r_q->unknown_0))
1676 return False;
1677 if(!prs_uint32("access_desired ", ps, depth, &r_q->access_desired))
1678 return False;
1680 return True;
1683 /*******************************************************************
1684 Inits a structure.
1685 ********************************************************************/
1687 void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
1688 POLICY_HND *pol, NTSTATUS status)
1690 if (NT_STATUS_IS_OK(status)) {
1691 memcpy(&r_r->pol, pol, sizeof(r_r->pol));
1692 } else {
1693 ZERO_STRUCT(r_r->pol);
1695 r_r->status = status;
1698 /*******************************************************************
1699 reads or writes a structure.
1700 ********************************************************************/
1702 BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
1704 if (r_r == NULL)
1705 return False;
1707 prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1708 depth++;
1710 if(!prs_align(ps))
1711 return False;
1713 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
1714 return False;
1716 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1717 return False;
1719 return True;
1722 /*******************************************************************
1723 Inits a structure.
1724 ********************************************************************/
1726 void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s, const char *msg,
1727 uint32 timeout, BOOL do_reboot, BOOL force)
1729 q_s->ptr_0 = 1;
1730 q_s->ptr_1 = 1;
1731 q_s->ptr_2 = 1;
1733 init_unistr2(&q_s->uni_msg, msg, UNI_FLAGS_NONE);
1734 init_uni_hdr(&q_s->hdr_msg, &q_s->uni_msg);
1736 q_s->timeout = timeout;
1738 q_s->reboot = do_reboot ? 1 : 0;
1739 q_s->force = force ? 1 : 0;
1742 /*******************************************************************
1743 reads or writes a structure.
1744 ********************************************************************/
1746 BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps,
1747 int depth)
1749 if (q_s == NULL)
1750 return False;
1752 prs_debug(ps, depth, desc, "reg_io_q_shutdown");
1753 depth++;
1755 if (!prs_align(ps))
1756 return False;
1758 if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0)))
1759 return False;
1760 if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1)))
1761 return False;
1762 if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2)))
1763 return False;
1765 if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth))
1766 return False;
1767 if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth))
1768 return False;
1769 if (!prs_align(ps))
1770 return False;
1772 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
1773 return False;
1774 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
1775 return False;
1776 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
1777 return False;
1779 return True;
1782 /*******************************************************************
1783 reads or writes a structure.
1784 ********************************************************************/
1785 BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps,
1786 int depth)
1788 if (r_s == NULL)
1789 return False;
1791 prs_debug(ps, depth, desc, "reg_io_r_shutdown");
1792 depth++;
1794 if(!prs_align(ps))
1795 return False;
1797 if(!prs_ntstatus("status", ps, depth, &r_s->status))
1798 return False;
1800 return True;
1803 /*******************************************************************
1804 Inits a structure.
1805 ********************************************************************/
1806 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s)
1809 q_s->ptr_server = 0;
1813 /*******************************************************************
1814 reads or writes a structure.
1815 ********************************************************************/
1816 BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN * q_s,
1817 prs_struct *ps, int depth)
1819 if (q_s == NULL)
1820 return False;
1822 prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
1823 depth++;
1825 if (!prs_align(ps))
1826 return False;
1828 if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
1829 return False;
1830 if (q_s->ptr_server != 0)
1831 if (!prs_uint16("server", ps, depth, &(q_s->server)))
1832 return False;
1834 return True;
1837 /*******************************************************************
1838 reads or writes a structure.
1839 ********************************************************************/
1840 BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN * r_s,
1841 prs_struct *ps, int depth)
1843 if (r_s == NULL)
1844 return False;
1846 prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
1847 depth++;
1849 if (!prs_align(ps))
1850 return False;
1852 if (!prs_ntstatus("status", ps, depth, &r_s->status))
1853 return False;
1855 return True;