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) Jeremy Cooper 2004
10 * Copyright (C) Gerald Carter 2002-2005.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #define DBGC_CLASS DBGC_RPC_PARSE
32 /*******************************************************************
33 Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE
34 *******************************************************************/
36 static uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val )
43 real_size = regval_size(val);
44 init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size );
49 /*******************************************************************
50 Inits a hive connect request structure
51 ********************************************************************/
53 void init_reg_q_open_hive( REG_Q_OPEN_HIVE *q_o, uint32 access_desired )
56 q_o->server = TALLOC_P( get_talloc_ctx(), uint16);
59 q_o->access = access_desired;
62 /*******************************************************************
63 Marshalls a hive connect request
64 ********************************************************************/
66 BOOL reg_io_q_open_hive(const char *desc, REG_Q_OPEN_HIVE *q_u,
67 prs_struct *ps, int depth)
69 prs_debug(ps, depth, desc, "reg_io_q_open_hive");
75 if(!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
80 if(!prs_uint32("access", ps, depth, &q_u->access))
87 /*******************************************************************
88 Unmarshalls a hive connect response
89 ********************************************************************/
91 BOOL reg_io_r_open_hive(const char *desc, REG_R_OPEN_HIVE *r_u,
92 prs_struct *ps, int depth)
97 prs_debug(ps, depth, desc, "reg_io_r_open_hive");
103 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
106 if(!prs_werror("status", ps, depth, &r_u->status))
112 /*******************************************************************
114 ********************************************************************/
116 void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol)
118 memcpy(&q_u->pol, pol, sizeof(q_u->pol));
121 /*******************************************************************
122 reads or writes a structure.
123 ********************************************************************/
125 BOOL reg_io_q_flush_key(const char *desc, REG_Q_FLUSH_KEY *q_u, prs_struct *ps, int depth)
130 prs_debug(ps, depth, desc, "reg_io_q_flush_key");
136 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
142 /*******************************************************************
143 Unmarshalls a registry key flush response
144 ********************************************************************/
146 BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_u,
147 prs_struct *ps, int depth)
152 prs_debug(ps, depth, desc, "reg_io_r_flush_key");
158 if(!prs_werror("status", ps, depth, &r_u->status))
164 /*******************************************************************
165 reads or writes SEC_DESC_BUF and SEC_DATA structures.
166 ********************************************************************/
168 static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec,
169 SEC_DESC_BUF *data, prs_struct *ps, int depth)
174 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth,
178 old_offset = prs_offset(ps);
181 if(!prs_uint32("ptr3", ps, depth, ptr3))
185 if (ptr3 == NULL || *ptr3 != 0) {
186 /* JRA - this next line is probably wrong... */
187 if(!sec_io_desc_buf("data ", &data, ps, depth))
191 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth,
192 hdr_offset, data->max_len, data->len))
194 if(!prs_set_offset(ps, old_offset + data->len +
195 sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3)))
205 /*******************************************************************
206 Inits a registry key create request
207 ********************************************************************/
209 void init_reg_q_create_key_ex(REG_Q_CREATE_KEY_EX *q_c, POLICY_HND *hnd,
210 char *name, char *key_class, uint32 access_desired,
211 SEC_DESC_BUF *sec_buf)
215 memcpy(&q_c->handle, hnd, sizeof(q_c->handle));
218 init_unistr4( &q_c->name, name, UNI_STR_TERMINATE );
219 init_unistr4( &q_c->key_class, key_class, UNI_STR_TERMINATE );
221 q_c->access = access_desired;
223 q_c->sec_info = TALLOC_P( get_talloc_ctx(), uint32 );
224 *q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
228 init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len);
230 q_c->disposition = TALLOC_P( get_talloc_ctx(), uint32 );
233 /*******************************************************************
234 Marshalls a registry key create request
235 ********************************************************************/
237 BOOL reg_io_q_create_key_ex(const char *desc, REG_Q_CREATE_KEY_EX *q_u,
238 prs_struct *ps, int depth)
243 prs_debug(ps, depth, desc, "reg_io_q_create_key_ex");
249 if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
252 if(!prs_unistr4 ("name", ps, depth, &q_u->name))
257 if(!prs_unistr4 ("key_class", ps, depth, &q_u->key_class))
262 if(!prs_uint32("options", ps, depth, &q_u->options))
264 if(!prs_uint32("access", ps, depth, &q_u->access))
267 if(!prs_pointer("sec_info", ps, depth, (void**)&q_u->sec_info, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
270 if ( q_u->sec_info ) {
271 if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2))
273 if(!reg_io_hdrbuf_sec(q_u->ptr2, &q_u->ptr3, &q_u->hdr_sec, q_u->data, ps, depth))
277 if(!prs_pointer("disposition", ps, depth, (void**)&q_u->disposition, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
283 /*******************************************************************
284 Unmarshalls a registry key create response
285 ********************************************************************/
287 BOOL reg_io_r_create_key_ex(const char *desc, REG_R_CREATE_KEY_EX *r_u,
288 prs_struct *ps, int depth)
293 prs_debug(ps, depth, desc, "reg_io_r_create_key_ex");
299 if(!smb_io_pol_hnd("", &r_u->handle, ps, depth))
301 if(!prs_uint32("disposition", ps, depth, &r_u->disposition))
304 if(!prs_werror("status", ps, depth, &r_u->status))
311 /*******************************************************************
313 ********************************************************************/
315 void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd,
320 memcpy(&q_c->handle, hnd, sizeof(q_c->handle));
321 init_unistr4(&q_c->name, name, UNI_STR_TERMINATE);
324 /*******************************************************************
325 reads or writes a structure.
326 ********************************************************************/
328 BOOL reg_io_q_delete_value(const char *desc, REG_Q_DELETE_VALUE *q_u,
329 prs_struct *ps, int depth)
334 prs_debug(ps, depth, desc, "reg_io_q_delete_value");
340 if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
343 if(!prs_unistr4("name", ps, depth, &q_u->name))
350 /*******************************************************************
351 reads or writes a structure.
352 ********************************************************************/
354 BOOL reg_io_r_delete_value(const char *desc, REG_R_DELETE_VALUE *r_u,
355 prs_struct *ps, int depth)
360 prs_debug(ps, depth, desc, "reg_io_r_delete_value");
366 if(!prs_werror("status", ps, depth, &r_u->status))
372 /*******************************************************************
374 ********************************************************************/
376 void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
381 memcpy(&q_c->handle, hnd, sizeof(q_c->handle));
383 init_unistr4(&q_c->name, name, UNI_STR_TERMINATE);
386 /*******************************************************************
387 reads or writes a structure.
388 ********************************************************************/
390 BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *q_u,
391 prs_struct *ps, int depth)
396 prs_debug(ps, depth, desc, "reg_io_q_delete_key");
402 if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
405 if(!prs_unistr4("", ps, depth, &q_u->name))
411 /*******************************************************************
412 reads or writes a structure.
413 ********************************************************************/
415 BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_u, prs_struct *ps, int depth)
420 prs_debug(ps, depth, desc, "reg_io_r_delete_key");
426 if(!prs_werror("status", ps, depth, &r_u->status))
432 /*******************************************************************
434 ********************************************************************/
436 void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, const char *key_class)
440 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
441 init_unistr4(&q_o->key_class, key_class, UNI_STR_TERMINATE);
444 /*******************************************************************
445 reads or writes a structure.
446 ********************************************************************/
448 BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *q_u, prs_struct *ps, int depth)
453 prs_debug(ps, depth, desc, "reg_io_q_query_key");
459 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
461 if(!prs_unistr4("key_class", ps, depth, &q_u->key_class))
468 /*******************************************************************
469 reads or writes a structure.
470 ********************************************************************/
472 BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_u, prs_struct *ps, int depth)
477 prs_debug(ps, depth, desc, "reg_io_r_query_key");
483 if(!prs_unistr4("key_class", ps, depth, &r_u->key_class))
489 if(!prs_uint32("num_subkeys ", ps, depth, &r_u->num_subkeys))
491 if(!prs_uint32("max_subkeylen ", ps, depth, &r_u->max_subkeylen))
493 if(!prs_uint32("reserved ", ps, depth, &r_u->reserved))
495 if(!prs_uint32("num_values ", ps, depth, &r_u->num_values))
497 if(!prs_uint32("max_valnamelen", ps, depth, &r_u->max_valnamelen))
499 if(!prs_uint32("max_valbufsize", ps, depth, &r_u->max_valbufsize))
501 if(!prs_uint32("sec_desc ", ps, depth, &r_u->sec_desc))
503 if(!smb_io_time("mod_time ", &r_u->mod_time, ps, depth))
506 if(!prs_werror("status", ps, depth, &r_u->status))
512 /*******************************************************************
514 ********************************************************************/
516 void init_reg_q_getversion(REG_Q_GETVERSION *q_o, POLICY_HND *hnd)
518 memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
522 /*******************************************************************
523 reads or writes a structure.
524 ********************************************************************/
526 BOOL reg_io_q_getversion(const char *desc, REG_Q_GETVERSION *q_u, prs_struct *ps, int depth)
531 prs_debug(ps, depth, desc, "reg_io_q_getversion");
537 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
543 /*******************************************************************
544 reads or writes a structure.
545 ********************************************************************/
547 BOOL reg_io_r_getversion(const char *desc, REG_R_GETVERSION *r_u, prs_struct *ps, int depth)
552 prs_debug(ps, depth, desc, "reg_io_r_getversion");
558 if(!prs_uint32("win_version", ps, depth, &r_u->win_version))
560 if(!prs_werror("status" , ps, depth, &r_u->status))
567 /*******************************************************************
568 reads or writes a structure.
569 ********************************************************************/
571 BOOL reg_io_q_restore_key(const char *desc, REG_Q_RESTORE_KEY *q_u, prs_struct *ps, int depth)
576 prs_debug(ps, depth, desc, "reg_io_q_restore_key");
582 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
585 if(!prs_unistr4("filename", ps, depth, &q_u->filename))
588 if(!prs_uint32("flags", ps, depth, &q_u->flags))
594 /*******************************************************************
595 reads or writes a structure.
596 ********************************************************************/
598 BOOL reg_io_r_restore_key(const char *desc, REG_R_RESTORE_KEY *r_u, prs_struct *ps, int depth)
603 prs_debug(ps, depth, desc, "reg_io_r_restore_key");
609 if(!prs_werror("status" , ps, depth, &r_u->status))
615 /*******************************************************************
616 ********************************************************************/
618 void init_q_reg_save_key( REG_Q_SAVE_KEY *q_u, POLICY_HND *handle, const char *fname )
620 memcpy(&q_u->pol, handle, sizeof(q_u->pol));
621 init_unistr4( &q_u->filename, fname, UNI_STR_TERMINATE );
622 q_u->sec_attr = NULL;
625 /*******************************************************************
626 reads or writes a structure.
627 ********************************************************************/
629 BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *q_u, prs_struct *ps, int depth)
634 prs_debug(ps, depth, desc, "reg_io_q_save_key");
640 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
643 if(!prs_unistr4("filename", ps, depth, &q_u->filename))
646 #if 0 /* reg_io_sec_attr() */
647 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
654 /*******************************************************************
655 reads or writes a structure.
656 ********************************************************************/
658 BOOL reg_io_r_save_key(const char *desc, REG_R_SAVE_KEY *r_u, prs_struct *ps, int depth)
663 prs_debug(ps, depth, desc, "reg_io_r_save_key");
669 if(!prs_werror("status" , ps, depth, &r_u->status))
675 /*******************************************************************
676 Inits an REG_Q_CLOSE structure.
677 ********************************************************************/
679 void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
681 DEBUG(5,("init_reg_q_close\n"));
683 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
686 /*******************************************************************
687 reads or writes a structure.
688 ********************************************************************/
690 BOOL reg_io_q_close(const char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
695 prs_debug(ps, depth, desc, "reg_io_q_close");
701 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
709 /*******************************************************************
710 reads or writes a structure.
711 ********************************************************************/
713 BOOL reg_io_r_close(const char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth)
718 prs_debug(ps, depth, desc, "reg_io_r_close");
724 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
729 if(!prs_werror("status", ps, depth, &r_u->status))
735 /*******************************************************************
737 ********************************************************************/
739 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_u, POLICY_HND *pol,
740 uint32 sec_info, SEC_DESC_BUF *sec_desc_buf)
742 memcpy(&q_u->handle, pol, sizeof(q_u->handle));
744 q_u->sec_info = sec_info;
747 init_buf_hdr(&q_u->hdr_sec, sec_desc_buf->len, sec_desc_buf->len);
748 q_u->data = sec_desc_buf;
751 /*******************************************************************
752 reads or writes a structure.
753 ********************************************************************/
755 BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *q_u, prs_struct *ps, int depth)
760 prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
766 if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
769 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
771 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
774 if(!reg_io_hdrbuf_sec(q_u->ptr, NULL, &q_u->hdr_sec, q_u->data, ps, depth))
780 /*******************************************************************
781 reads or writes a structure.
782 ********************************************************************/
784 BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *q_u, prs_struct *ps, int depth)
789 prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
795 if(!prs_werror("status", ps, depth, &q_u->status))
802 /*******************************************************************
804 ********************************************************************/
806 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_u, POLICY_HND *pol,
807 uint32 sec_info, uint32 sec_buf_size,
810 memcpy(&q_u->handle, pol, sizeof(q_u->handle));
812 q_u->sec_info = sec_info;
814 q_u->ptr = psdb != NULL ? 1 : 0;
817 init_buf_hdr(&q_u->hdr_sec, sec_buf_size, 0);
820 /*******************************************************************
821 reads or writes a structure.
822 ********************************************************************/
824 BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *q_u, prs_struct *ps, int depth)
829 prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
835 if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
838 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
840 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
843 if(!reg_io_hdrbuf_sec(q_u->ptr, NULL, &q_u->hdr_sec, q_u->data, ps, depth))
850 /*******************************************************************
852 ********************************************************************/
853 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
854 uint32 buf_len, uint8 *buf,
858 init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len);
859 init_sec_desc_buf(r_i->data, buf_len, 1);
861 r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
865 /*******************************************************************
866 reads or writes a structure.
867 ********************************************************************/
869 BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *q_u, prs_struct *ps, int depth)
874 prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
880 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
884 if(!smb_io_hdrbuf("", &q_u->hdr_sec, ps, depth))
886 if(!sec_io_desc_buf("", &q_u->data, ps, depth))
892 if(!prs_werror("status", ps, depth, &q_u->status))
898 /*******************************************************************
900 ********************************************************************/
902 BOOL init_reg_q_query_value(REG_Q_QUERY_VALUE *q_u, POLICY_HND *pol, const char *val_name,
903 REGVAL_BUFFER *value_output)
910 init_unistr4(&q_u->name, val_name, UNI_STR_TERMINATE);
912 q_u->ptr_reserved = 1;
915 q_u->ptr_bufsize = 1;
916 q_u->bufsize = value_output->buf_max_len;
921 q_u->buflen = value_output->buf_max_len;
923 q_u->ptr_buflen2 = 1;
929 /*******************************************************************
930 reads or writes a structure.
931 ********************************************************************/
933 BOOL reg_io_q_query_value(const char *desc, REG_Q_QUERY_VALUE *q_u, prs_struct *ps, int depth)
938 prs_debug(ps, depth, desc, "reg_io_q_query_value");
944 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
946 if(!prs_unistr4("name", ps, depth, &q_u->name))
952 if(!prs_uint32("ptr_reserved", ps, depth, &(q_u->ptr_reserved)))
955 if(!prs_uint32("ptr_buf", ps, depth, &(q_u->ptr_buf)))
959 if(!prs_uint32("ptr_bufsize", ps, depth, &(q_u->ptr_bufsize)))
961 if(!prs_uint32("bufsize", ps, depth, &(q_u->bufsize)))
963 if(!prs_uint32("buf_unk", ps, depth, &(q_u->buf_unk)))
967 if(!prs_uint32("unk1", ps, depth, &(q_u->unk1)))
970 if(!prs_uint32("ptr_buflen", ps, depth, &(q_u->ptr_buflen)))
973 if (q_u->ptr_buflen) {
974 if(!prs_uint32("buflen", ps, depth, &(q_u->buflen)))
976 if(!prs_uint32("ptr_buflen2", ps, depth, &(q_u->ptr_buflen2)))
978 if(!prs_uint32("buflen2", ps, depth, &(q_u->buflen2)))
985 /*******************************************************************
987 New version to replace older init_reg_r_query_value()
988 ********************************************************************/
990 BOOL init_reg_r_query_value(uint32 include_keyval, REG_R_QUERY_VALUE *r_u,
991 REGISTRY_VALUE *val, WERROR status)
999 r_u->type = TALLOC_P( get_talloc_ctx(), uint32 );
1000 *r_u->type = val->type;
1002 buf_len = reg_init_regval_buffer( &buf2, val );
1004 r_u->buf_max_len = TALLOC_P( get_talloc_ctx(), uint32 );
1005 *r_u->buf_max_len = buf_len;
1007 r_u->buf_len = TALLOC_P( get_talloc_ctx(), uint32 );
1008 *r_u->buf_len = buf_len;
1010 /* if include_keyval is not set, don't send the key value, just
1011 the buflen data. probably used by NT5 to allocate buffer space - SK */
1013 if ( include_keyval ) {
1014 r_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER );
1015 /* steal the memory */
1019 r_u->status = status;
1024 /*******************************************************************
1025 reads or writes a structure.
1026 ********************************************************************/
1028 BOOL reg_io_r_query_value(const char *desc, REG_R_QUERY_VALUE *r_u, prs_struct *ps, int depth)
1033 prs_debug(ps, depth, desc, "reg_io_r_query_value");
1039 if ( !prs_pointer("type", ps, depth, (void**)&r_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1042 if ( !prs_pointer("value", ps, depth, (void**)&r_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer))
1047 if ( !prs_pointer("buf_max_len", ps, depth, (void**)&r_u->buf_max_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1049 if ( !prs_pointer("buf_len", ps, depth, (void**)&r_u->buf_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1052 if(!prs_werror("status", ps, depth, &r_u->status))
1058 /*******************************************************************
1060 ********************************************************************/
1062 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_u, POLICY_HND *pol,
1064 uint32 max_name_len, uint32 max_buf_len)
1068 memcpy(&q_u->pol, pol, sizeof(q_u->pol));
1070 q_u->val_index = val_idx;
1072 q_u->name.size = max_name_len*2;
1073 q_u->name.string = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR2 );
1074 q_u->name.string->uni_max_len = max_name_len;
1076 q_u->type = TALLOC_P( get_talloc_ctx(), uint32 );
1079 q_u->value = TALLOC_ZERO_P( get_talloc_ctx(), REGVAL_BUFFER );
1080 q_u->value->buf_max_len = max_buf_len;
1082 q_u->buffer_len = TALLOC_P( get_talloc_ctx(), uint32 );
1083 *q_u->buffer_len = max_buf_len;
1085 q_u->name_len = TALLOC_P( get_talloc_ctx(), uint32 );
1086 *q_u->name_len = 0x0;
1089 /*******************************************************************
1091 ********************************************************************/
1093 void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val )
1101 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename));
1103 init_unistr4( &r_u->name, val->valuename, UNI_STR_TERMINATE);
1107 r_u->type = TALLOC_P( get_talloc_ctx(), uint32 );
1108 *r_u->type = val->type;
1110 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1112 r_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER );
1113 real_size = reg_init_regval_buffer( r_u->value, val );
1117 r_u->buffer_len1 = TALLOC_P( get_talloc_ctx(), uint32 );
1118 *r_u->buffer_len1 = real_size;
1119 r_u->buffer_len2 = TALLOC_P( get_talloc_ctx(), uint32 );
1120 *r_u->buffer_len2 = real_size;
1123 /*******************************************************************
1124 reads or writes a structure.
1125 ********************************************************************/
1127 BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_u, prs_struct *ps, int depth)
1132 prs_debug(ps, depth, desc, "reg_io_q_enum_val");
1138 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
1141 if(!prs_uint32("val_index", ps, depth, &q_u->val_index))
1144 if(!prs_unistr4("name", ps, depth, &q_u->name ))
1149 if(!prs_pointer("type", ps, depth, (void**)&q_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1152 if ( !prs_pointer("value", ps, depth, (void**)&q_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer))
1157 if(!prs_pointer("buffer_len", ps, depth, (void**)&q_u->buffer_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1159 if(!prs_pointer("name_len", ps, depth, (void**)&q_u->name_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1165 /*******************************************************************
1166 reads or writes a structure.
1167 ********************************************************************/
1169 BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_u, prs_struct *ps, int depth)
1174 prs_debug(ps, depth, desc, "reg_io_r_enum_val");
1180 if(!prs_unistr4("name", ps, depth, &r_u->name ))
1185 if(!prs_pointer("type", ps, depth, (void**)&r_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1188 if ( !prs_pointer("value", ps, depth, (void**)&r_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer))
1193 if(!prs_pointer("buffer_len1", ps, depth, (void**)&r_u->buffer_len1, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1195 if(!prs_pointer("buffer_len2", ps, depth, (void**)&r_u->buffer_len2, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
1198 if(!prs_werror("status", ps, depth, &r_u->status))
1204 /*******************************************************************
1206 ********************************************************************/
1208 void init_reg_q_set_val(REG_Q_SET_VALUE *q_u, POLICY_HND *pol,
1209 char *val_name, uint32 type,
1214 memcpy(&q_u->handle, pol, sizeof(q_u->handle));
1216 init_unistr4(&q_u->name, val_name, UNI_STR_TERMINATE);
1220 q_u->size = val->buf_len;
1223 /*******************************************************************
1224 reads or writes a structure.
1225 ********************************************************************/
1227 BOOL reg_io_q_set_value(const char *desc, REG_Q_SET_VALUE *q_u, prs_struct *ps, int depth)
1232 prs_debug(ps, depth, desc, "reg_io_q_set_value");
1238 if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
1241 if(!prs_unistr4("name", ps, depth, &q_u->name ))
1246 if(!prs_uint32("type", ps, depth, &q_u->type))
1249 if(!smb_io_rpc_blob("value", &q_u->value, ps, depth ))
1254 if(!prs_uint32("size", ps, depth, &q_u->size))
1260 /*******************************************************************
1261 reads or writes a structure.
1262 ********************************************************************/
1264 BOOL reg_io_r_set_value(const char *desc, REG_R_SET_VALUE *q_u, prs_struct *ps, int depth)
1269 prs_debug(ps, depth, desc, "reg_io_r_set_value");
1275 if(!prs_werror("status", ps, depth, &q_u->status))
1281 /*******************************************************************
1283 ********************************************************************/
1285 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_u, POLICY_HND *pol, uint32 key_idx)
1287 memcpy(&q_u->pol, pol, sizeof(q_u->pol));
1289 q_u->key_index = key_idx;
1290 q_u->key_name_len = 0;
1291 q_u->unknown_1 = 0x0414;
1294 q_u->unknown_2 = 0x0000020A;
1295 memset(q_u->pad1, 0, sizeof(q_u->pad1));
1298 memset(q_u->pad2, 0, sizeof(q_u->pad2));
1301 unix_to_nt_time(&q_u->time, 0); /* current time? */
1304 /*******************************************************************
1305 makes a reply structure.
1306 ********************************************************************/
1308 void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey )
1313 init_unistr4( &r_u->keyname, subkey, UNI_STR_TERMINATE );
1314 r_u->classname = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 );
1315 r_u->time = TALLOC_ZERO_P( get_talloc_ctx(), NTTIME );
1318 /*******************************************************************
1319 reads or writes a structure.
1320 ********************************************************************/
1322 BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_u, prs_struct *ps, int depth)
1327 prs_debug(ps, depth, desc, "reg_io_q_enum_key");
1333 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
1336 if(!prs_uint32("key_index", ps, depth, &q_u->key_index))
1338 if(!prs_uint16("key_name_len", ps, depth, &q_u->key_name_len))
1340 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
1343 if(!prs_uint32("ptr1", ps, depth, &q_u->ptr1))
1346 if (q_u->ptr1 != 0) {
1347 if(!prs_uint32("unknown_2", ps, depth, &q_u->unknown_2))
1349 if(!prs_uint8s(False, "pad1", ps, depth, q_u->pad1, sizeof(q_u->pad1)))
1353 if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2))
1356 if (q_u->ptr2 != 0) {
1357 if(!prs_uint8s(False, "pad2", ps, depth, q_u->pad2, sizeof(q_u->pad2)))
1361 if(!prs_uint32("ptr3", ps, depth, &q_u->ptr3))
1364 if (q_u->ptr3 != 0) {
1365 if(!smb_io_time("", &q_u->time, ps, depth))
1372 /*******************************************************************
1373 reads or writes a structure.
1374 ********************************************************************/
1376 BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *q_u, prs_struct *ps, int depth)
1381 prs_debug(ps, depth, desc, "reg_io_r_enum_key");
1386 if ( !prs_unistr4( "keyname", ps, depth, &q_u->keyname ) )
1391 if (!prs_pointer("class", ps, depth, (void**)&q_u->classname, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
1396 if (!prs_pointer("time", ps, depth, (void**)&q_u->time, sizeof(NTTIME), (PRS_POINTER_CAST)smb_io_nttime))
1401 if(!prs_werror("status", ps, depth, &q_u->status))
1407 /*******************************************************************
1409 ********************************************************************/
1411 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *q_u, POLICY_HND *pol,
1412 char *key_name, uint32 access_desired)
1414 memcpy(&q_u->pol, pol, sizeof(q_u->pol));
1416 init_unistr4(&q_u->name, key_name, UNI_STR_TERMINATE);
1418 q_u->unknown_0 = 0x00000000;
1419 q_u->access = access_desired;
1422 /*******************************************************************
1423 reads or writes a structure.
1424 ********************************************************************/
1426 BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *q_u, prs_struct *ps, int depth)
1431 prs_debug(ps, depth, desc, "reg_io_q_open_entry");
1437 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
1439 if(!prs_unistr4("name", ps, depth, &q_u->name))
1445 if(!prs_uint32("unknown_0 ", ps, depth, &q_u->unknown_0))
1447 if(!prs_uint32("access", ps, depth, &q_u->access))
1453 /*******************************************************************
1454 reads or writes a structure.
1455 ********************************************************************/
1457 BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_u, prs_struct *ps, int depth)
1462 prs_debug(ps, depth, desc, "reg_io_r_open_entry");
1468 if(!smb_io_pol_hnd("handle", &r_u->handle, ps, depth))
1471 if(!prs_werror("status", ps, depth, &r_u->status))
1477 /*******************************************************************
1479 ********************************************************************/
1481 void init_reg_q_shutdown(REG_Q_SHUTDOWN *q_u, const char *msg,
1482 uint32 timeout, BOOL do_reboot, BOOL force)
1484 q_u->server = TALLOC_P( get_talloc_ctx(), uint16 );
1487 if ( msg && *msg ) {
1488 q_u->message = TALLOC_P( get_talloc_ctx(), UNISTR4 );
1489 init_unistr4( q_u->message, msg, UNI_FLAGS_NONE );
1492 q_u->timeout = timeout;
1494 q_u->reboot = do_reboot ? 1 : 0;
1495 q_u->force = force ? 1 : 0;
1498 /*******************************************************************
1499 Inits a REG_Q_SHUTDOWN_EX structure.
1500 ********************************************************************/
1502 void init_reg_q_shutdown_ex(REG_Q_SHUTDOWN_EX * q_u_ex, const char *msg,
1503 uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason)
1509 init_reg_q_shutdown( &q_u, msg, timeout, do_reboot, force );
1513 q_u_ex->server = q_u.server;
1514 q_u_ex->message = q_u.message;
1516 q_u_ex->reboot = q_u.reboot;
1517 q_u_ex->force = q_u.force;
1519 q_u_ex->reason = reason;
1522 /*******************************************************************
1523 reads or writes a structure.
1524 ********************************************************************/
1526 BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN *q_u, prs_struct *ps,
1532 prs_debug(ps, depth, desc, "reg_io_q_shutdown");
1538 if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
1543 if (!prs_pointer("message", ps, depth, (void**)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
1549 if (!prs_uint32("timeout", ps, depth, &(q_u->timeout)))
1552 if (!prs_uint8("force ", ps, depth, &(q_u->force)))
1554 if (!prs_uint8("reboot ", ps, depth, &(q_u->reboot)))
1561 /*******************************************************************
1562 reads or writes a structure.
1563 ********************************************************************/
1564 BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN *r_u, prs_struct *ps,
1570 prs_debug(ps, depth, desc, "reg_io_r_shutdown");
1576 if(!prs_werror("status", ps, depth, &r_u->status))
1582 /*******************************************************************
1583 reads or writes a REG_Q_SHUTDOWN_EX structure.
1584 ********************************************************************/
1586 BOOL reg_io_q_shutdown_ex(const char *desc, REG_Q_SHUTDOWN_EX *q_u, prs_struct *ps,
1592 prs_debug(ps, depth, desc, "reg_io_q_shutdown_ex");
1598 if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
1603 if (!prs_pointer("message", ps, depth, (void**)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
1609 if (!prs_uint32("timeout", ps, depth, &(q_u->timeout)))
1612 if (!prs_uint8("force ", ps, depth, &(q_u->force)))
1614 if (!prs_uint8("reboot ", ps, depth, &(q_u->reboot)))
1619 if (!prs_uint32("reason", ps, depth, &(q_u->reason)))
1626 /*******************************************************************
1627 reads or writes a REG_R_SHUTDOWN_EX structure.
1628 ********************************************************************/
1629 BOOL reg_io_r_shutdown_ex(const char *desc, REG_R_SHUTDOWN_EX *r_u, prs_struct *ps,
1635 prs_debug(ps, depth, desc, "reg_io_r_shutdown_ex");
1641 if(!prs_werror("status", ps, depth, &r_u->status))
1649 /*******************************************************************
1651 ********************************************************************/
1652 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN *q_u)
1654 q_u->server = TALLOC_P( get_talloc_ctx(), uint16 );
1658 /*******************************************************************
1659 reads or writes a structure.
1660 ********************************************************************/
1661 BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN *q_u,
1662 prs_struct *ps, int depth)
1667 prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
1673 if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
1681 /*******************************************************************
1682 reads or writes a structure.
1683 ********************************************************************/
1684 BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN *r_u,
1685 prs_struct *ps, int depth)
1690 prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
1696 if (!prs_werror("status", ps, depth, &r_u->status))