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
))
78 if(!prs_uint32("access", ps
, depth
, &q_u
->access
))
85 /*******************************************************************
86 Unmarshalls a hive connect response
87 ********************************************************************/
89 BOOL
reg_io_r_open_hive(const char *desc
, REG_R_OPEN_HIVE
*r_u
,
90 prs_struct
*ps
, int depth
)
95 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hive");
101 if(!smb_io_pol_hnd("", &r_u
->pol
, ps
, depth
))
104 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
110 /*******************************************************************
112 ********************************************************************/
114 void init_reg_q_flush_key(REG_Q_FLUSH_KEY
*q_u
, POLICY_HND
*pol
)
116 memcpy(&q_u
->pol
, pol
, sizeof(q_u
->pol
));
119 /*******************************************************************
120 reads or writes a structure.
121 ********************************************************************/
123 BOOL
reg_io_q_flush_key(const char *desc
, REG_Q_FLUSH_KEY
*q_u
, prs_struct
*ps
, int depth
)
128 prs_debug(ps
, depth
, desc
, "reg_io_q_flush_key");
134 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
140 /*******************************************************************
141 Unmarshalls a registry key flush response
142 ********************************************************************/
144 BOOL
reg_io_r_flush_key(const char *desc
, REG_R_FLUSH_KEY
*r_u
,
145 prs_struct
*ps
, int depth
)
150 prs_debug(ps
, depth
, desc
, "reg_io_r_flush_key");
156 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
162 /*******************************************************************
163 reads or writes SEC_DESC_BUF and SEC_DATA structures.
164 ********************************************************************/
166 static BOOL
reg_io_hdrbuf_sec(uint32 ptr
, uint32
*ptr3
, BUFHDR
*hdr_sec
,
167 SEC_DESC_BUF
*data
, prs_struct
*ps
, int depth
)
172 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec
, ps
, depth
,
176 old_offset
= prs_offset(ps
);
179 if(!prs_uint32("ptr3", ps
, depth
, ptr3
))
183 if (ptr3
== NULL
|| *ptr3
!= 0) {
184 /* JRA - this next line is probably wrong... */
185 if(!sec_io_desc_buf("data ", &data
, ps
, depth
))
189 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec
, ps
, depth
,
190 hdr_offset
, data
->max_len
, data
->len
))
192 if(!prs_set_offset(ps
, old_offset
+ data
->len
+
193 sizeof(uint32
) * ((ptr3
!= NULL
) ? 5 : 3)))
203 /*******************************************************************
204 Inits a registry key create request
205 ********************************************************************/
207 void init_reg_q_create_key(REG_Q_CREATE_KEY
*q_c
, POLICY_HND
*hnd
,
208 char *name
, char *class, uint32 access_desired
,
209 SEC_DESC_BUF
*sec_buf
)
213 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
216 init_unistr4( &q_c
->name
, name
, UNI_STR_TERMINATE
);
217 init_unistr4( &q_c
->class, class, UNI_STR_TERMINATE
);
219 q_c
->access
= access_desired
;
221 q_c
->sec_info
= TALLOC_P( get_talloc_ctx(), uint32
);
222 *q_c
->sec_info
= DACL_SECURITY_INFORMATION
| SACL_SECURITY_INFORMATION
;
226 init_buf_hdr(&q_c
->hdr_sec
, sec_buf
->len
, sec_buf
->len
);
228 q_c
->unknown_2
= 0x00000000;
231 /*******************************************************************
232 Marshalls a registry key create request
233 ********************************************************************/
235 BOOL
reg_io_q_create_key(const char *desc
, REG_Q_CREATE_KEY
*q_u
,
236 prs_struct
*ps
, int depth
)
241 prs_debug(ps
, depth
, desc
, "reg_io_q_create_key");
247 if(!smb_io_pol_hnd("", &q_u
->pnt_pol
, ps
, depth
))
250 if(!prs_unistr4 ("name", ps
, depth
, &q_u
->name
))
255 if(!prs_unistr4 ("class", ps
, depth
, &q_u
->class))
260 if(!prs_uint32("reserved", ps
, depth
, &q_u
->reserved
))
262 if(!prs_uint32("access", ps
, depth
, &q_u
->access
))
265 if(!prs_pointer("sec_info", ps
, depth
, (void**)&q_u
->sec_info
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
268 if(!prs_uint32("ptr2", ps
, depth
, &q_u
->ptr2
))
270 if(!reg_io_hdrbuf_sec(q_u
->ptr2
, &q_u
->ptr3
, &q_u
->hdr_sec
, q_u
->data
,
275 if(!prs_uint32("unknown_2", ps
, depth
, &q_u
->unknown_2
))
282 /*******************************************************************
283 Unmarshalls a registry key create response
284 ********************************************************************/
286 BOOL
reg_io_r_create_key(const char *desc
, REG_R_CREATE_KEY
*r_u
,
287 prs_struct
*ps
, int depth
)
292 prs_debug(ps
, depth
, desc
, "reg_io_r_create_key");
298 if(!smb_io_pol_hnd("", &r_u
->key_pol
, ps
, depth
))
300 if(!prs_uint32("unknown", ps
, depth
, &r_u
->unknown
))
303 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
310 /*******************************************************************
312 ********************************************************************/
314 void init_reg_q_delete_val(REG_Q_DELETE_VALUE
*q_c
, POLICY_HND
*hnd
,
319 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
320 init_unistr4(&q_c
->name
, name
, UNI_STR_TERMINATE
);
323 /*******************************************************************
324 reads or writes a structure.
325 ********************************************************************/
327 BOOL
reg_io_q_delete_val(const char *desc
, REG_Q_DELETE_VALUE
*q_u
,
328 prs_struct
*ps
, int depth
)
333 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_val");
339 if(!smb_io_pol_hnd("", &q_u
->pnt_pol
, ps
, depth
))
342 if(!prs_unistr4("name", ps
, depth
, &q_u
->name
))
351 /*******************************************************************
352 reads or writes a structure.
353 ********************************************************************/
355 BOOL
reg_io_r_delete_val(const char *desc
, REG_R_DELETE_VALUE
*r_u
,
356 prs_struct
*ps
, int depth
)
361 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_val");
367 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
373 /*******************************************************************
375 ********************************************************************/
377 void init_reg_q_delete_key(REG_Q_DELETE_KEY
*q_c
, POLICY_HND
*hnd
,
382 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
384 init_unistr4(&q_c
->name
, name
, UNI_STR_TERMINATE
);
387 /*******************************************************************
388 reads or writes a structure.
389 ********************************************************************/
391 BOOL
reg_io_q_delete_key(const char *desc
, REG_Q_DELETE_KEY
*q_u
,
392 prs_struct
*ps
, int depth
)
397 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_key");
403 if(!smb_io_pol_hnd("", &q_u
->pnt_pol
, ps
, depth
))
406 if(!prs_unistr4("", ps
, depth
, &q_u
->name
))
414 /*******************************************************************
415 reads or writes a structure.
416 ********************************************************************/
418 BOOL
reg_io_r_delete_key(const char *desc
, REG_R_DELETE_KEY
*r_u
, prs_struct
*ps
, int depth
)
423 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_key");
429 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
435 /*******************************************************************
437 ********************************************************************/
439 void init_reg_q_query_key(REG_Q_QUERY_KEY
*q_o
, POLICY_HND
*hnd
, const char *class)
443 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
444 init_unistr4(&q_o
->class, class, UNI_STR_TERMINATE
);
447 /*******************************************************************
448 reads or writes a structure.
449 ********************************************************************/
451 BOOL
reg_io_q_query_key(const char *desc
, REG_Q_QUERY_KEY
*q_u
, prs_struct
*ps
, int depth
)
456 prs_debug(ps
, depth
, desc
, "reg_io_q_query_key");
462 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
464 if(!prs_unistr4("class", ps
, depth
, &q_u
->class))
474 /*******************************************************************
475 reads or writes a structure.
476 ********************************************************************/
478 BOOL
reg_io_r_query_key(const char *desc
, REG_R_QUERY_KEY
*r_u
, prs_struct
*ps
, int depth
)
483 prs_debug(ps
, depth
, desc
, "reg_io_r_query_key");
489 if(!prs_unistr4("class", ps
, depth
, &r_u
->class))
495 if(!prs_uint32("num_subkeys ", ps
, depth
, &r_u
->num_subkeys
))
497 if(!prs_uint32("max_subkeylen ", ps
, depth
, &r_u
->max_subkeylen
))
499 if(!prs_uint32("reserved ", ps
, depth
, &r_u
->reserved
))
501 if(!prs_uint32("num_values ", ps
, depth
, &r_u
->num_values
))
503 if(!prs_uint32("max_valnamelen", ps
, depth
, &r_u
->max_valnamelen
))
505 if(!prs_uint32("max_valbufsize", ps
, depth
, &r_u
->max_valbufsize
))
507 if(!prs_uint32("sec_desc ", ps
, depth
, &r_u
->sec_desc
))
509 if(!smb_io_time("mod_time ", &r_u
->mod_time
, ps
, depth
))
512 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
518 /*******************************************************************
520 ********************************************************************/
522 void init_reg_q_getversion(REG_Q_GETVERSION
*q_o
, POLICY_HND
*hnd
)
524 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
528 /*******************************************************************
529 reads or writes a structure.
530 ********************************************************************/
532 BOOL
reg_io_q_getversion(const char *desc
, REG_Q_GETVERSION
*q_u
, prs_struct
*ps
, int depth
)
537 prs_debug(ps
, depth
, desc
, "reg_io_q_getversion");
543 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
549 /*******************************************************************
550 reads or writes a structure.
551 ********************************************************************/
553 BOOL
reg_io_r_getversion(const char *desc
, REG_R_GETVERSION
*r_u
, prs_struct
*ps
, int depth
)
558 prs_debug(ps
, depth
, desc
, "reg_io_r_getversion");
564 if(!prs_uint32("unknown", ps
, depth
, &r_u
->unknown
))
566 if(!prs_werror("status" , ps
, depth
, &r_u
->status
))
573 /*******************************************************************
574 reads or writes a structure.
575 ********************************************************************/
577 BOOL
reg_io_q_restore_key(const char *desc
, REG_Q_RESTORE_KEY
*q_u
, prs_struct
*ps
, int depth
)
582 prs_debug(ps
, depth
, desc
, "reg_io_q_restore_key");
588 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
591 if(!prs_unistr4("filename", ps
, depth
, &q_u
->filename
))
594 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
600 /*******************************************************************
601 reads or writes a structure.
602 ********************************************************************/
604 BOOL
reg_io_r_restore_key(const char *desc
, REG_R_RESTORE_KEY
*r_u
, prs_struct
*ps
, int depth
)
609 prs_debug(ps
, depth
, desc
, "reg_io_r_restore_key");
615 if(!prs_werror("status" , ps
, depth
, &r_u
->status
))
621 /*******************************************************************
622 reads or writes a structure.
623 ********************************************************************/
625 BOOL
reg_io_q_save_key(const char *desc
, REG_Q_SAVE_KEY
*q_u
, prs_struct
*ps
, int depth
)
630 prs_debug(ps
, depth
, desc
, "reg_io_q_save_key");
636 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
639 if(!prs_unistr4("filename", ps
, depth
, &q_u
->filename
))
642 #if 0 /* reg_io_sec_attr() */
643 if(!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
650 /*******************************************************************
651 reads or writes a structure.
652 ********************************************************************/
654 BOOL
reg_io_r_save_key(const char *desc
, REG_R_SAVE_KEY
*r_u
, prs_struct
*ps
, int depth
)
659 prs_debug(ps
, depth
, desc
, "reg_io_r_save_key");
665 if(!prs_werror("status" , ps
, depth
, &r_u
->status
))
671 /*******************************************************************
672 Inits an REG_Q_CLOSE structure.
673 ********************************************************************/
675 void init_reg_q_close(REG_Q_CLOSE
*q_c
, POLICY_HND
*hnd
)
677 DEBUG(5,("init_reg_q_close\n"));
679 memcpy(&q_c
->pol
, hnd
, sizeof(q_c
->pol
));
682 /*******************************************************************
683 reads or writes a structure.
684 ********************************************************************/
686 BOOL
reg_io_q_close(const char *desc
, REG_Q_CLOSE
*q_u
, prs_struct
*ps
, int depth
)
691 prs_debug(ps
, depth
, desc
, "reg_io_q_close");
697 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
705 /*******************************************************************
706 reads or writes a structure.
707 ********************************************************************/
709 BOOL
reg_io_r_close(const char *desc
, REG_R_CLOSE
*r_u
, prs_struct
*ps
, int depth
)
714 prs_debug(ps
, depth
, desc
, "reg_io_r_close");
720 if(!smb_io_pol_hnd("", &r_u
->pol
, ps
, depth
))
725 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
731 /*******************************************************************
733 ********************************************************************/
735 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC
*q_u
, POLICY_HND
*pol
,
736 uint32 sec_info
, SEC_DESC_BUF
*sec_desc_buf
)
738 memcpy(&q_u
->pol
, pol
, sizeof(q_u
->pol
));
740 q_u
->sec_info
= sec_info
;
743 init_buf_hdr(&q_u
->hdr_sec
, sec_desc_buf
->len
, sec_desc_buf
->len
);
744 q_u
->data
= sec_desc_buf
;
747 /*******************************************************************
748 reads or writes a structure.
749 ********************************************************************/
751 BOOL
reg_io_q_set_key_sec(const char *desc
, REG_Q_SET_KEY_SEC
*q_u
, prs_struct
*ps
, int depth
)
756 prs_debug(ps
, depth
, desc
, "reg_io_q_set_key_sec");
762 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
765 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
767 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
770 if(!reg_io_hdrbuf_sec(q_u
->ptr
, NULL
, &q_u
->hdr_sec
, q_u
->data
, ps
, depth
))
776 /*******************************************************************
777 reads or writes a structure.
778 ********************************************************************/
780 BOOL
reg_io_r_set_key_sec(const char *desc
, REG_R_SET_KEY_SEC
*q_u
, prs_struct
*ps
, int depth
)
785 prs_debug(ps
, depth
, desc
, "reg_io_r_set_key_sec");
791 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
798 /*******************************************************************
800 ********************************************************************/
802 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC
*q_u
, POLICY_HND
*pol
,
803 uint32 sec_info
, uint32 sec_buf_size
,
806 memcpy(&q_u
->pol
, pol
, sizeof(q_u
->pol
));
808 q_u
->sec_info
= sec_info
;
810 q_u
->ptr
= psdb
!= NULL
? 1 : 0;
813 init_buf_hdr(&q_u
->hdr_sec
, sec_buf_size
, 0);
816 /*******************************************************************
817 reads or writes a structure.
818 ********************************************************************/
820 BOOL
reg_io_q_get_key_sec(const char *desc
, REG_Q_GET_KEY_SEC
*q_u
, prs_struct
*ps
, int depth
)
825 prs_debug(ps
, depth
, desc
, "reg_io_q_get_key_sec");
831 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
834 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
836 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
839 if(!reg_io_hdrbuf_sec(q_u
->ptr
, NULL
, &q_u
->hdr_sec
, q_u
->data
, ps
, depth
))
846 /*******************************************************************
848 ********************************************************************/
849 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC
*r_i
, POLICY_HND
*pol
,
850 uint32 buf_len
, uint8
*buf
,
854 init_buf_hdr(&r_i
->hdr_sec
, buf_len
, buf_len
);
855 init_sec_desc_buf(r_i
->data
, buf_len
, 1);
857 r_i
->status
= status
; /* 0x0000 0000 or 0x0000 007a */
861 /*******************************************************************
862 reads or writes a structure.
863 ********************************************************************/
865 BOOL
reg_io_r_get_key_sec(const char *desc
, REG_R_GET_KEY_SEC
*q_u
, prs_struct
*ps
, int depth
)
870 prs_debug(ps
, depth
, desc
, "reg_io_r_get_key_sec");
876 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
880 if(!smb_io_hdrbuf("", &q_u
->hdr_sec
, ps
, depth
))
882 if(!sec_io_desc_buf("", &q_u
->data
, ps
, depth
))
888 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
894 /*******************************************************************
896 ********************************************************************/
898 BOOL
init_reg_q_info(REG_Q_INFO
*q_u
, POLICY_HND
*pol
, const char *val_name
,
899 REGVAL_BUFFER
*value_output
)
906 init_unistr4(&q_u
->name
, val_name
, UNI_STR_TERMINATE
);
908 q_u
->ptr_reserved
= 1;
911 q_u
->ptr_bufsize
= 1;
912 q_u
->bufsize
= value_output
->buf_max_len
;
917 q_u
->buflen
= value_output
->buf_max_len
;
919 q_u
->ptr_buflen2
= 1;
925 /*******************************************************************
926 reads or writes a structure.
927 ********************************************************************/
929 BOOL
reg_io_q_info(const char *desc
, REG_Q_INFO
*q_u
, prs_struct
*ps
, int depth
)
934 prs_debug(ps
, depth
, desc
, "reg_io_q_info");
940 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
942 if(!prs_unistr4("name", ps
, depth
, &q_u
->name
))
948 if(!prs_uint32("ptr_reserved", ps
, depth
, &(q_u
->ptr_reserved
)))
951 if(!prs_uint32("ptr_buf", ps
, depth
, &(q_u
->ptr_buf
)))
955 if(!prs_uint32("ptr_bufsize", ps
, depth
, &(q_u
->ptr_bufsize
)))
957 if(!prs_uint32("bufsize", ps
, depth
, &(q_u
->bufsize
)))
959 if(!prs_uint32("buf_unk", ps
, depth
, &(q_u
->buf_unk
)))
963 if(!prs_uint32("unk1", ps
, depth
, &(q_u
->unk1
)))
966 if(!prs_uint32("ptr_buflen", ps
, depth
, &(q_u
->ptr_buflen
)))
969 if (q_u
->ptr_buflen
) {
970 if(!prs_uint32("buflen", ps
, depth
, &(q_u
->buflen
)))
972 if(!prs_uint32("ptr_buflen2", ps
, depth
, &(q_u
->ptr_buflen2
)))
974 if(!prs_uint32("buflen2", ps
, depth
, &(q_u
->buflen2
)))
981 /*******************************************************************
983 New version to replace older init_reg_r_info()
984 ********************************************************************/
986 BOOL
init_reg_r_info(uint32 include_keyval
, REG_R_INFO
*r_u
,
987 REGISTRY_VALUE
*val
, WERROR status
)
995 r_u
->type
= TALLOC_P( get_talloc_ctx(), uint32
);
996 *r_u
->type
= val
->type
;
998 buf_len
= reg_init_regval_buffer( &buf2
, val
);
1000 r_u
->buf_max_len
= TALLOC_P( get_talloc_ctx(), uint32
);
1001 *r_u
->buf_max_len
= buf_len
;
1003 r_u
->buf_len
= TALLOC_P( get_talloc_ctx(), uint32
);
1004 *r_u
->buf_len
= buf_len
;
1006 /* if include_keyval is not set, don't send the key value, just
1007 the buflen data. probably used by NT5 to allocate buffer space - SK */
1009 if ( include_keyval
) {
1010 r_u
->value
= TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER
);
1011 /* steal the memory */
1015 r_u
->status
= status
;
1020 /*******************************************************************
1021 reads or writes a structure.
1022 ********************************************************************/
1024 BOOL
reg_io_r_info(const char *desc
, REG_R_INFO
*r_u
, prs_struct
*ps
, int depth
)
1029 prs_debug(ps
, depth
, desc
, "reg_io_r_info");
1035 if ( !prs_pointer("type", ps
, depth
, (void**)&r_u
->type
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
1038 if ( !prs_pointer("value", ps
, depth
, (void**)&r_u
->value
, sizeof(REGVAL_BUFFER
), (PRS_POINTER_CAST
)smb_io_regval_buffer
))
1043 if ( !prs_pointer("buf_max_len", ps
, depth
, (void**)&r_u
->buf_max_len
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
1045 if ( !prs_pointer("buf_len", ps
, depth
, (void**)&r_u
->buf_len
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
1048 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1054 /*******************************************************************
1056 ********************************************************************/
1058 void init_reg_q_enum_val(REG_Q_ENUM_VALUE
*q_u
, POLICY_HND
*pol
,
1059 uint32 val_idx
, char *name
,
1064 memcpy(&q_u
->pol
, pol
, sizeof(q_u
->pol
));
1066 q_u
->val_index
= val_idx
;
1068 init_unistr4( &q_u
->name
, name
, UNI_STR_TERMINATE
);
1070 q_u
->type
= TALLOC_P( get_talloc_ctx(), uint32
);
1073 q_u
->value
= TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER
);
1074 q_u
->value
->buf_max_len
= max_buf_len
;
1076 q_u
->len_value1
= TALLOC_P( get_talloc_ctx(), uint32
);
1077 *q_u
->len_value1
= max_buf_len
;
1079 q_u
->len_value2
= TALLOC_P( get_talloc_ctx(), uint32
);
1080 *q_u
->len_value2
= max_buf_len
;
1083 /*******************************************************************
1085 ********************************************************************/
1087 void init_reg_r_enum_val(REG_R_ENUM_VALUE
*r_u
, REGISTRY_VALUE
*val
)
1091 DEBUG(8,("init_reg_r_enum_val: Enter\n"));
1097 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val
->valuename
));
1099 init_unistr4( &r_u
->name
, val
->valuename
, UNI_STR_TERMINATE
);
1103 r_u
->type
= TALLOC_P( get_talloc_ctx(), uint32
);
1104 *r_u
->type
= val
->type
;
1106 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1108 r_u
->value
= TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER
);
1109 real_size
= reg_init_regval_buffer( r_u
->value
, val
);
1113 r_u
->len_value1
= TALLOC_P( get_talloc_ctx(), uint32
);
1114 *r_u
->len_value1
= real_size
;
1116 r_u
->len_value2
= TALLOC_P( get_talloc_ctx(), uint32
);
1117 *r_u
->len_value2
= real_size
;
1119 DEBUG(8,("init_reg_r_enum_val: Exit\n"));
1122 /*******************************************************************
1123 reads or writes a structure.
1124 ********************************************************************/
1126 BOOL
reg_io_q_enum_val(const char *desc
, REG_Q_ENUM_VALUE
*q_u
, prs_struct
*ps
, int depth
)
1131 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_val");
1137 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
1140 if(!prs_uint32("val_index", ps
, depth
, &q_u
->val_index
))
1143 if(!prs_unistr4("name", ps
, depth
, &q_u
->name
))
1148 if(!prs_pointer("type", ps
, depth
, (void**)&q_u
->type
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
1151 if ( !prs_pointer("value", ps
, depth
, (void**)&q_u
->value
, sizeof(REGVAL_BUFFER
), (PRS_POINTER_CAST
)smb_io_regval_buffer
))
1156 if(!prs_pointer("len_value1", ps
, depth
, (void**)&q_u
->len_value1
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
1158 if(!prs_pointer("len_value2", ps
, depth
, (void**)&q_u
->len_value2
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
1164 /*******************************************************************
1165 reads or writes a structure.
1166 ********************************************************************/
1168 BOOL
reg_io_r_enum_val(const char *desc
, REG_R_ENUM_VALUE
*r_u
, prs_struct
*ps
, int depth
)
1173 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_val");
1179 if(!prs_unistr4("name", ps
, depth
, &r_u
->name
))
1184 if(!prs_pointer("type", ps
, depth
, (void**)&r_u
->type
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
1187 if ( !prs_pointer("value", ps
, depth
, (void**)&r_u
->value
, sizeof(REGVAL_BUFFER
), (PRS_POINTER_CAST
)smb_io_regval_buffer
))
1192 if(!prs_pointer("len_value1", ps
, depth
, (void**)&r_u
->len_value1
, sizeof(uint32
), (PRS_POINTER_CAST
)prs_uint32
))
1194 if(!prs_pointer("len_value2", ps
, depth
, (void**)&r_u
->len_value2
, 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
->pol
, pol
, sizeof(q_u
->pol
));
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_val(const char *desc
, REG_Q_SET_VALUE
*q_u
, prs_struct
*ps
, int depth
)
1232 prs_debug(ps
, depth
, desc
, "reg_io_q_set_val");
1238 if(!smb_io_pol_hnd("", &q_u
->pol
, 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_val(const char *desc
, REG_R_SET_VALUE
*q_u
, prs_struct
*ps
, int depth
)
1269 prs_debug(ps
, depth
, desc
, "reg_io_r_set_val");
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
, uint32 unknown_1
,
1314 r_u
->unknown_1
= unknown_1
;
1315 r_u
->unknown_2
= unknown_2
;
1316 r_u
->unknown_3
= 0x0;
1318 r_u
->key_name_len
= (strlen(subkey
)+1) * 2;
1319 if (r_u
->key_name_len
)
1321 init_unistr3( &r_u
->key_name
, subkey
);
1327 /*******************************************************************
1328 reads or writes a structure.
1329 ********************************************************************/
1331 BOOL
reg_io_q_enum_key(const char *desc
, REG_Q_ENUM_KEY
*q_u
, prs_struct
*ps
, int depth
)
1336 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_key");
1342 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
1345 if(!prs_uint32("key_index", ps
, depth
, &q_u
->key_index
))
1347 if(!prs_uint16("key_name_len", ps
, depth
, &q_u
->key_name_len
))
1349 if(!prs_uint16("unknown_1", ps
, depth
, &q_u
->unknown_1
))
1352 if(!prs_uint32("ptr1", ps
, depth
, &q_u
->ptr1
))
1355 if (q_u
->ptr1
!= 0) {
1356 if(!prs_uint32("unknown_2", ps
, depth
, &q_u
->unknown_2
))
1358 if(!prs_uint8s(False
, "pad1", ps
, depth
, q_u
->pad1
, sizeof(q_u
->pad1
)))
1362 if(!prs_uint32("ptr2", ps
, depth
, &q_u
->ptr2
))
1365 if (q_u
->ptr2
!= 0) {
1366 if(!prs_uint8s(False
, "pad2", ps
, depth
, q_u
->pad2
, sizeof(q_u
->pad2
)))
1370 if(!prs_uint32("ptr3", ps
, depth
, &q_u
->ptr3
))
1373 if (q_u
->ptr3
!= 0) {
1374 if(!smb_io_time("", &q_u
->time
, ps
, depth
))
1381 /*******************************************************************
1382 reads or writes a structure.
1383 ********************************************************************/
1385 BOOL
reg_io_r_enum_key(const char *desc
, REG_R_ENUM_KEY
*q_u
, prs_struct
*ps
, int depth
)
1390 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_key");
1396 if(!prs_uint16("key_name_len", ps
, depth
, &q_u
->key_name_len
))
1398 if(!prs_uint16("unknown_1", ps
, depth
, &q_u
->unknown_1
))
1401 if(!prs_uint32("ptr1", ps
, depth
, &q_u
->ptr1
))
1404 if (q_u
->ptr1
!= 0) {
1405 if(!prs_uint32("unknown_2", ps
, depth
, &q_u
->unknown_2
))
1407 if(!prs_uint32("unknown_3", ps
, depth
, &q_u
->unknown_3
))
1409 if(!smb_io_unistr3("key_name", &q_u
->key_name
, ps
, depth
))
1415 if(!prs_uint32("ptr2", ps
, depth
, &q_u
->ptr2
))
1418 if (q_u
->ptr2
!= 0) {
1419 if(!prs_uint8s(False
, "pad2", ps
, depth
, q_u
->pad2
, sizeof(q_u
->pad2
)))
1423 if(!prs_uint32("ptr3", ps
, depth
, &q_u
->ptr3
))
1426 if (q_u
->ptr3
!= 0) {
1427 if(!smb_io_time("", &q_u
->time
, ps
, depth
))
1431 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
1437 /*******************************************************************
1439 ********************************************************************/
1441 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY
*q_u
, POLICY_HND
*pol
,
1442 char *key_name
, uint32 access_desired
)
1444 memcpy(&q_u
->pol
, pol
, sizeof(q_u
->pol
));
1446 init_unistr4(&q_u
->name
, key_name
, UNI_STR_TERMINATE
);
1448 q_u
->unknown_0
= 0x00000000;
1449 q_u
->access
= access_desired
;
1452 /*******************************************************************
1453 reads or writes a structure.
1454 ********************************************************************/
1456 BOOL
reg_io_q_open_entry(const char *desc
, REG_Q_OPEN_ENTRY
*q_u
, prs_struct
*ps
, int depth
)
1461 prs_debug(ps
, depth
, desc
, "reg_io_q_open_entry");
1467 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
1469 if(!prs_unistr4("name", ps
, depth
, &q_u
->name
))
1475 if(!prs_uint32("unknown_0 ", ps
, depth
, &q_u
->unknown_0
))
1477 if(!prs_uint32("access", ps
, depth
, &q_u
->access
))
1483 /*******************************************************************
1485 ********************************************************************/
1487 void init_reg_r_open_entry(REG_R_OPEN_ENTRY
*r_u
,
1488 POLICY_HND
*pol
, WERROR werr
)
1490 if (W_ERROR_IS_OK(werr
)) {
1491 memcpy(&r_u
->pol
, pol
, sizeof(r_u
->pol
));
1493 ZERO_STRUCT(r_u
->pol
);
1498 /*******************************************************************
1499 reads or writes a structure.
1500 ********************************************************************/
1502 BOOL
reg_io_r_open_entry(const char *desc
, REG_R_OPEN_ENTRY
*r_u
, prs_struct
*ps
, int depth
)
1507 prs_debug(ps
, depth
, desc
, "reg_io_r_open_entry");
1513 if(!smb_io_pol_hnd("", &r_u
->pol
, ps
, depth
))
1516 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1522 /*******************************************************************
1524 ********************************************************************/
1526 void init_reg_q_shutdown(REG_Q_SHUTDOWN
*q_u
, const char *msg
,
1527 uint32 timeout
, BOOL do_reboot
, BOOL force
)
1529 q_u
->server
= TALLOC_P( get_talloc_ctx(), uint16
);
1532 q_u
->message
= TALLOC_P( get_talloc_ctx(), UNISTR4
);
1533 init_unistr4( q_u
->message
, msg
, UNI_FLAGS_NONE
);
1535 q_u
->timeout
= timeout
;
1537 q_u
->reboot
= do_reboot
? 1 : 0;
1538 q_u
->force
= force
? 1 : 0;
1541 /*******************************************************************
1542 Inits a REG_Q_SHUTDOWN_EX structure.
1543 ********************************************************************/
1545 void init_reg_q_shutdown_ex(REG_Q_SHUTDOWN_EX
* q_u_ex
, const char *msg
,
1546 uint32 timeout
, BOOL do_reboot
, BOOL force
, uint32 reason
)
1552 init_reg_q_shutdown( &q_u
, msg
, timeout
, do_reboot
, force
);
1556 q_u_ex
->server
= q_u
.server
;
1557 q_u_ex
->message
= q_u
.message
;
1559 q_u_ex
->reboot
= q_u
.reboot
;
1560 q_u_ex
->force
= q_u
.force
;
1562 q_u_ex
->reason
= reason
;
1565 /*******************************************************************
1566 reads or writes a structure.
1567 ********************************************************************/
1569 BOOL
reg_io_q_shutdown(const char *desc
, REG_Q_SHUTDOWN
*q_u
, prs_struct
*ps
,
1575 prs_debug(ps
, depth
, desc
, "reg_io_q_shutdown");
1581 if (!prs_pointer("server", ps
, depth
, (void**)&q_u
->server
, sizeof(uint16
), (PRS_POINTER_CAST
)prs_uint16
))
1584 if (!prs_pointer("message", ps
, depth
, (void**)&q_u
->message
, sizeof(UNISTR4
), (PRS_POINTER_CAST
)prs_unistr4
))
1590 if (!prs_uint32("timeout", ps
, depth
, &(q_u
->timeout
)))
1593 if (!prs_uint8("force ", ps
, depth
, &(q_u
->force
)))
1595 if (!prs_uint8("reboot ", ps
, depth
, &(q_u
->reboot
)))
1602 /*******************************************************************
1603 reads or writes a structure.
1604 ********************************************************************/
1605 BOOL
reg_io_r_shutdown(const char *desc
, REG_R_SHUTDOWN
*r_u
, prs_struct
*ps
,
1611 prs_debug(ps
, depth
, desc
, "reg_io_r_shutdown");
1617 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1623 /*******************************************************************
1624 reads or writes a REG_Q_SHUTDOWN_EX structure.
1625 ********************************************************************/
1627 BOOL
reg_io_q_shutdown_ex(const char *desc
, REG_Q_SHUTDOWN_EX
*q_u
, prs_struct
*ps
,
1633 prs_debug(ps
, depth
, desc
, "reg_io_q_shutdown_ex");
1639 if (!prs_pointer("server", ps
, depth
, (void**)&q_u
->server
, sizeof(uint16
), (PRS_POINTER_CAST
)prs_uint16
))
1642 if (!prs_pointer("message", ps
, depth
, (void**)&q_u
->message
, sizeof(UNISTR4
), (PRS_POINTER_CAST
)prs_unistr4
))
1648 if (!prs_uint32("timeout", ps
, depth
, &(q_u
->timeout
)))
1651 if (!prs_uint8("force ", ps
, depth
, &(q_u
->force
)))
1653 if (!prs_uint8("reboot ", ps
, depth
, &(q_u
->reboot
)))
1658 if (!prs_uint32("reason", ps
, depth
, &(q_u
->reason
)))
1665 /*******************************************************************
1666 reads or writes a REG_R_SHUTDOWN_EX structure.
1667 ********************************************************************/
1668 BOOL
reg_io_r_shutdown_ex(const char *desc
, REG_R_SHUTDOWN_EX
*r_u
, prs_struct
*ps
,
1674 prs_debug(ps
, depth
, desc
, "reg_io_r_shutdown_ex");
1680 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1688 /*******************************************************************
1690 ********************************************************************/
1691 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN
*q_u
)
1693 q_u
->server
= TALLOC_P( get_talloc_ctx(), uint16
);
1697 /*******************************************************************
1698 reads or writes a structure.
1699 ********************************************************************/
1700 BOOL
reg_io_q_abort_shutdown(const char *desc
, REG_Q_ABORT_SHUTDOWN
*q_u
,
1701 prs_struct
*ps
, int depth
)
1706 prs_debug(ps
, depth
, desc
, "reg_io_q_abort_shutdown");
1712 if (!prs_pointer("server", ps
, depth
, (void**)&q_u
->server
, sizeof(uint16
), (PRS_POINTER_CAST
)prs_uint16
))
1718 /*******************************************************************
1719 reads or writes a structure.
1720 ********************************************************************/
1721 BOOL
reg_io_r_abort_shutdown(const char *desc
, REG_R_ABORT_SHUTDOWN
*r_u
,
1722 prs_struct
*ps
, int depth
)
1727 prs_debug(ps
, depth
, desc
, "reg_io_r_abort_shutdown");
1733 if (!prs_werror("status", ps
, depth
, &r_u
->status
))