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.
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 )
42 real_size = regval_size(val);
43 init_buffer2( buf2, (unsigned char*)regval_data_p(val), real_size );
48 /*******************************************************************
50 ********************************************************************/
52 void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o,
53 uint16 unknown_0, uint32 level)
56 q_o->unknown_0 = unknown_0;
57 q_o->unknown_1 = 0x0; /* random - changes */
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)
70 prs_debug(ps, depth, desc, "reg_io_q_open_hkcr");
76 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
80 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0))
82 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
84 if(!prs_uint32("level ", ps, depth, &r_q->level))
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)
101 prs_debug(ps, depth, desc, "reg_io_r_open_hkcr");
107 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
110 if(!prs_ntstatus("status", ps, depth, &r_r->status))
116 /*******************************************************************
118 ********************************************************************/
120 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o,
121 uint16 unknown_0, uint32 access_mask)
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,
139 prs_debug(ps, depth, desc, "reg_io_q_open_hklm");
145 if (!prs_uint32("ptr ", ps, depth, &(r_q->ptr)))
149 if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0)))
151 if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)))
153 if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask)))
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,
170 prs_debug(ps, depth, desc, "reg_io_r_open_hklm");
176 if (!smb_io_pol_hnd("", &r_r->pol, ps, depth))
179 if (!prs_ntstatus("status", ps, depth, &r_r->status))
188 /*******************************************************************
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)
206 prs_debug(ps, depth, desc, "reg_io_q_flush_key");
212 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
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)
227 prs_debug(ps, depth, desc, "reg_io_r_flush_key");
233 if(!prs_ntstatus("status", ps, depth, &r_r->status))
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)
248 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset))
251 old_offset = prs_offset(ps);
254 if(!prs_uint32("ptr3", ps, depth, ptr3))
258 if (ptr3 == NULL || *ptr3 != 0) {
259 if(!sec_io_desc_buf("data ", &data, ps, depth)) /* JRA - this line is probably wrong... */
263 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset,
264 data->max_len, data->len))
266 if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3)))
276 /*******************************************************************
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)
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));
298 q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
302 init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len);
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)
316 prs_debug(ps, depth, desc, "reg_io_q_create_key");
322 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
325 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
327 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
332 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
334 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
339 if(!prs_uint32("reserved", ps, depth, &r_q->reserved))
341 if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth))
344 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
347 if (r_q->ptr1 != 0) {
348 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
352 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
354 if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth))
357 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
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)
372 prs_debug(ps, depth, desc, "reg_io_r_create_key");
378 if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth))
380 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
383 if(!prs_ntstatus("status", ps, depth, &r_r->status))
390 /*******************************************************************
392 ********************************************************************/
394 void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd,
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)
414 prs_debug(ps, depth, desc, "reg_io_q_delete_val");
420 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
423 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
425 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
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)
443 prs_debug(ps, depth, desc, "reg_io_r_delete_val");
449 if(!prs_ntstatus("status", ps, depth, &r_r->status))
455 /*******************************************************************
457 ********************************************************************/
459 void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
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)
479 prs_debug(ps, depth, desc, "reg_io_q_delete_key");
485 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth))
488 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
490 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
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)
507 prs_debug(ps, depth, desc, "reg_io_r_delete_key");
513 if(!prs_ntstatus("status", ps, depth, &r_r->status))
519 /*******************************************************************
521 ********************************************************************/
523 void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, UNISTR2 *uni2)
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)
540 prs_debug(ps, depth, desc, "reg_io_q_query_key");
546 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
548 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth))
550 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth))
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)
569 prs_debug(ps, depth, desc, "reg_io_r_query_key");
575 if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth))
577 if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth))
583 if(!prs_uint32("num_subkeys ", ps, depth, &r_r->num_subkeys))
585 if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen))
587 if(!prs_uint32("reserved ", ps, depth, &r_r->reserved))
589 if(!prs_uint32("num_values ", ps, depth, &r_r->num_values))
591 if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen))
593 if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize))
595 if(!prs_uint32("sec_desc ", ps, depth, &r_r->sec_desc))
597 if(!smb_io_time("mod_time ", &r_r->mod_time, ps, depth))
600 if(!prs_ntstatus("status", ps, depth, &r_r->status))
606 /*******************************************************************
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)
625 prs_debug(ps, depth, desc, "reg_io_q_unknown_1a");
631 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
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)
646 prs_debug(ps, depth, desc, "reg_io_r_unknown_1a");
652 if(!prs_uint32("unknown", ps, depth, &r_r->unknown))
654 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
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)
670 prs_debug(ps, depth, desc, "reg_io_q_save_key");
676 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
679 if(!smb_io_unihdr ("hdr_file", &r_q->hdr_file, ps, depth))
681 if(!smb_io_unistr2("uni_file", &r_q->uni_file, r_q->hdr_file.buffer, ps, depth))
684 if(!prs_uint32("unknown", ps, depth, &r_q->unknown))
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)
699 prs_debug(ps, depth, desc, "reg_io_r_save_key");
705 if(!prs_ntstatus("status" , ps, depth, &r_r->status))
711 /*******************************************************************
713 ********************************************************************/
715 void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o,
716 uint16 unknown_0, uint32 access_mask)
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)
733 prs_debug(ps, depth, desc, "reg_io_q_open_hku");
739 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
742 if(!prs_uint16("unknown_0 ", ps, depth, &r_q->unknown_0))
744 if(!prs_uint16("unknown_1 ", ps, depth, &r_q->unknown_1))
746 if(!prs_uint32("access_mask ", ps, depth, &r_q->access_mask))
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)
762 prs_debug(ps, depth, desc, "reg_io_r_open_hku");
768 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
771 if(!prs_ntstatus("status", ps, depth, &r_r->status))
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)
797 prs_debug(ps, depth, desc, "reg_io_q_close");
803 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
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)
820 prs_debug(ps, depth, desc, "reg_io_r_close");
826 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
831 if(!prs_ntstatus("status", ps, depth, &r_u->status))
837 /*******************************************************************
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;
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)
861 prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
867 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
870 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
872 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
875 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
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)
890 prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
896 if(!prs_ntstatus("status", ps, depth, &r_q->status))
903 /*******************************************************************
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;
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)
931 prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
937 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
940 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info))
942 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
945 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth))
952 /*******************************************************************
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,
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 */
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)
976 prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
982 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
986 if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth))
988 if(!sec_io_desc_buf("", &r_q->data, ps, depth))
994 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1000 /*******************************************************************
1002 ********************************************************************/
1004 BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name)
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;
1017 q_i->ptr_bufsize = 1;
1022 q_i->ptr_buflen = 1;
1025 q_i->ptr_buflen2 = 1;
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)
1040 prs_debug(ps, depth, desc, "reg_io_q_info");
1046 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1048 if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth))
1050 if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth))
1056 if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved)))
1059 if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf)))
1063 if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize)))
1065 if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize)))
1067 if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk)))
1071 if(!prs_uint32("unk1", ps, depth, &(r_q->unk1)))
1074 if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen)))
1077 if (r_q->ptr_buflen) {
1078 if(!prs_uint32("buflen", ps, depth, &(r_q->buflen)))
1080 if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2)))
1082 if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2)))
1089 /*******************************************************************
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)
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 );
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;
1127 r_r->buf_len = buf_len;
1129 r_r->status = status;
1134 /*******************************************************************
1136 ********************************************************************/
1138 BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r,
1139 BUFFER2* buf, uint32 type, NTSTATUS status)
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;
1157 r_r->buf_len = r_r->uni_val.buf_len;
1159 r_r->status = status;
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)
1173 prs_debug(ps, depth, desc, "reg_io_r_info");
1179 if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type)))
1182 if (r_r->ptr_type != 0) {
1183 if(!prs_uint32("type", ps, depth, &r_r->type))
1187 if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val)))
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))
1198 if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len)))
1201 if (r_r->ptr_max_len != 0) {
1202 if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len)))
1206 if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len)))
1208 if (r_r->ptr_len != 0) {
1209 if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len)))
1213 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1219 /*******************************************************************
1221 ********************************************************************/
1223 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
1224 uint32 val_idx, UNISTR2 *uni2,
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);
1238 q_i->buf_value.buf_max_len = max_buf_len;
1241 q_i->len_value1 = max_buf_len;
1244 q_i->len_value2 = 0;
1247 /*******************************************************************
1249 ********************************************************************/
1251 void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val )
1255 DEBUG(8,("init_reg_r_enum_val: Enter\n"));
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);
1269 r_u->type = val->type;
1271 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1274 real_size = reg_init_buffer2( &r_u->buf_value, val );
1279 r_u->len_value1 = real_size;
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)
1296 prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1302 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1305 if(!prs_uint32("val_index", ps, depth, &q_q->val_index))
1308 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1310 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1315 if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type))
1318 if (q_q->ptr_type != 0) {
1319 if(!prs_uint32("type", ps, depth, &q_q->type))
1323 if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value))
1325 if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth))
1330 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1332 if (q_q->ptr1 != 0) {
1333 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1))
1336 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1338 if (q_q->ptr2 != 0) {
1339 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2))
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)
1355 prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1361 if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth))
1363 if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1368 if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type))
1371 if (r_q->ptr_type != 0) {
1372 if(!prs_uint32("type", ps, depth, &r_q->type))
1376 if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value))
1378 if(!smb_io_buffer2("buf_value", &r_q->buf_value, r_q->ptr_value, ps, depth))
1383 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1385 if (r_q->ptr1 != 0) {
1386 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1))
1390 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1392 if (r_q->ptr2 != 0) {
1393 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2))
1397 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1403 /*******************************************************************
1405 ********************************************************************/
1407 void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
1408 char *val_name, uint32 type,
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);
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)
1431 prs_debug(ps, depth, desc, "reg_io_q_create_val");
1437 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1440 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth))
1442 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth))
1447 if(!prs_uint32("type", ps, depth, &q_q->type))
1449 if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth))
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)
1466 prs_debug(ps, depth, desc, "reg_io_r_create_val");
1472 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1478 /*******************************************************************
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;
1491 q_i->unknown_2 = 0x0000020A;
1492 memset(q_i->pad1, 0, sizeof(q_i->pad1));
1495 memset(q_i->pad2, 0, sizeof(q_i->pad2));
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,
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)
1518 init_unistr3( &r_u->key_name, subkey );
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)
1533 prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1539 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1542 if(!prs_uint32("key_index", ps, depth, &q_q->key_index))
1544 if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len))
1546 if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1))
1549 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1))
1552 if (q_q->ptr1 != 0) {
1553 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2))
1555 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)))
1559 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2))
1562 if (q_q->ptr2 != 0) {
1563 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)))
1567 if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3))
1570 if (q_q->ptr3 != 0) {
1571 if(!smb_io_time("", &q_q->time, ps, depth))
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)
1587 prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1593 if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len))
1595 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1))
1598 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1))
1601 if (r_q->ptr1 != 0) {
1602 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2))
1604 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3))
1606 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth))
1612 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2))
1615 if (r_q->ptr2 != 0) {
1616 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)))
1620 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3))
1623 if (r_q->ptr3 != 0) {
1624 if(!smb_io_time("", &r_q->time, ps, depth))
1628 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1634 /*******************************************************************
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)
1659 prs_debug(ps, depth, desc, "reg_io_q_entry");
1665 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth))
1667 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth))
1669 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth))
1675 if(!prs_uint32("unknown_0 ", ps, depth, &r_q->unknown_0))
1677 if(!prs_uint32("access_desired ", ps, depth, &r_q->access_desired))
1683 /*******************************************************************
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));
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)
1707 prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1713 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth))
1716 if(!prs_ntstatus("status", ps, depth, &r_r->status))
1722 /*******************************************************************
1724 ********************************************************************/
1726 void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s, const char *msg,
1727 uint32 timeout, BOOL do_reboot, BOOL force)
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,
1752 prs_debug(ps, depth, desc, "reg_io_q_shutdown");
1758 if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0)))
1760 if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1)))
1762 if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2)))
1765 if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth))
1767 if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth))
1772 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
1774 if (!prs_uint8("force ", ps, depth, &(q_s->force)))
1776 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
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,
1791 prs_debug(ps, depth, desc, "reg_io_r_shutdown");
1797 if(!prs_ntstatus("status", ps, depth, &r_s->status))
1803 /*******************************************************************
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)
1822 prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
1828 if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
1830 if (q_s->ptr_server != 0)
1831 if (!prs_uint16("server", ps, depth, &(q_s->server)))
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)
1846 prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
1852 if (!prs_ntstatus("status", ps, depth, &r_s->status))