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
)
284 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
285 int len_class
= class != NULL
? strlen(class) + 1: 0;
289 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
291 init_uni_hdr(&q_c
->hdr_name
, len_name
);
292 init_unistr2(&q_c
->uni_name
, name
, len_name
);
294 init_uni_hdr(&q_c
->hdr_class
, len_class
);
295 init_unistr2(&q_c
->uni_class
, class, len_class
);
297 q_c
->reserved
= 0x00000000;
298 memcpy(&q_c
->sam_access
, sam_access
, sizeof(q_c
->sam_access
));
301 q_c
->sec_info
= DACL_SECURITY_INFORMATION
| SACL_SECURITY_INFORMATION
;
305 init_buf_hdr(&q_c
->hdr_sec
, sec_buf
->len
, sec_buf
->len
);
307 q_c
->unknown_2
= 0x00000000;
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
314 BOOL
reg_io_q_create_key(const char *desc
, REG_Q_CREATE_KEY
*r_q
, prs_struct
*ps
, int depth
)
319 prs_debug(ps
, depth
, desc
, "reg_io_q_create_key");
325 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
328 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
330 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
335 if(!smb_io_unihdr ("", &r_q
->hdr_class
, ps
, depth
))
337 if(!smb_io_unistr2("", &r_q
->uni_class
, r_q
->hdr_class
.buffer
, ps
, depth
))
342 if(!prs_uint32("reserved", ps
, depth
, &r_q
->reserved
))
344 if(!sec_io_access("sam_access", &r_q
->sam_access
, ps
, depth
))
347 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
350 if (r_q
->ptr1
!= 0) {
351 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
355 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
357 if(!reg_io_hdrbuf_sec(r_q
->ptr2
, &r_q
->ptr3
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
360 if(!prs_uint32("unknown_2", ps
, depth
, &r_q
->unknown_2
))
366 /*******************************************************************
367 reads or writes a structure.
368 ********************************************************************/
370 BOOL
reg_io_r_create_key(const char *desc
, REG_R_CREATE_KEY
*r_r
, prs_struct
*ps
, int depth
)
375 prs_debug(ps
, depth
, desc
, "reg_io_r_create_key");
381 if(!smb_io_pol_hnd("", &r_r
->key_pol
, ps
, depth
))
383 if(!prs_uint32("unknown", ps
, depth
, &r_r
->unknown
))
386 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
393 /*******************************************************************
395 ********************************************************************/
397 void init_reg_q_delete_val(REG_Q_DELETE_VALUE
*q_c
, POLICY_HND
*hnd
,
400 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
403 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
405 init_uni_hdr(&q_c
->hdr_name
, len_name
);
406 init_unistr2(&q_c
->uni_name
, name
, len_name
);
409 /*******************************************************************
410 reads or writes a structure.
411 ********************************************************************/
413 BOOL
reg_io_q_delete_val(const char *desc
, REG_Q_DELETE_VALUE
*r_q
, prs_struct
*ps
, int depth
)
418 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_val");
424 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
427 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
429 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
438 /*******************************************************************
439 reads or writes a structure.
440 ********************************************************************/
442 BOOL
reg_io_r_delete_val(const char *desc
, REG_R_DELETE_VALUE
*r_r
, prs_struct
*ps
, int depth
)
447 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_val");
453 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
459 /*******************************************************************
461 ********************************************************************/
463 void init_reg_q_delete_key(REG_Q_DELETE_KEY
*q_c
, POLICY_HND
*hnd
,
466 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
469 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
471 init_uni_hdr(&q_c
->hdr_name
, len_name
);
472 init_unistr2(&q_c
->uni_name
, name
, len_name
);
475 /*******************************************************************
476 reads or writes a structure.
477 ********************************************************************/
479 BOOL
reg_io_q_delete_key(const char *desc
, REG_Q_DELETE_KEY
*r_q
, prs_struct
*ps
, int depth
)
484 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_key");
490 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
493 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
495 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
503 /*******************************************************************
504 reads or writes a structure.
505 ********************************************************************/
507 BOOL
reg_io_r_delete_key(const char *desc
, REG_R_DELETE_KEY
*r_r
, prs_struct
*ps
, int depth
)
512 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_key");
518 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
524 /*******************************************************************
526 ********************************************************************/
528 void init_reg_q_query_key(REG_Q_QUERY_KEY
*q_o
, POLICY_HND
*hnd
,
529 uint32 max_class_len
)
533 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
534 init_uni_hdr(&q_o
->hdr_class
, max_class_len
);
535 q_o
->uni_class
.uni_max_len
= max_class_len
;
538 /*******************************************************************
539 reads or writes a structure.
540 ********************************************************************/
542 BOOL
reg_io_q_query_key(const char *desc
, REG_Q_QUERY_KEY
*r_q
, prs_struct
*ps
, int depth
)
547 prs_debug(ps
, depth
, desc
, "reg_io_q_query_key");
553 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
555 if(!smb_io_unihdr ("", &r_q
->hdr_class
, ps
, depth
))
557 if(!smb_io_unistr2("", &r_q
->uni_class
, r_q
->hdr_class
.buffer
, ps
, depth
))
567 /*******************************************************************
568 reads or writes a structure.
569 ********************************************************************/
571 BOOL
reg_io_r_query_key(const char *desc
, REG_R_QUERY_KEY
*r_r
, prs_struct
*ps
, int depth
)
576 prs_debug(ps
, depth
, desc
, "reg_io_r_query_key");
582 if(!smb_io_unihdr ("", &r_r
->hdr_class
, ps
, depth
))
584 if(!smb_io_unistr2("", &r_r
->uni_class
, r_r
->hdr_class
.buffer
, ps
, depth
))
590 if(!prs_uint32("num_subkeys ", ps
, depth
, &r_r
->num_subkeys
))
592 if(!prs_uint32("max_subkeylen ", ps
, depth
, &r_r
->max_subkeylen
))
594 if(!prs_uint32("reserved ", ps
, depth
, &r_r
->reserved
))
596 if(!prs_uint32("num_values ", ps
, depth
, &r_r
->num_values
))
598 if(!prs_uint32("max_valnamelen", ps
, depth
, &r_r
->max_valnamelen
))
600 if(!prs_uint32("max_valbufsize", ps
, depth
, &r_r
->max_valbufsize
))
602 if(!prs_uint32("sec_desc ", ps
, depth
, &r_r
->sec_desc
))
604 if(!smb_io_time("mod_time ", &r_r
->mod_time
, ps
, depth
))
607 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
613 /*******************************************************************
615 ********************************************************************/
617 void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A
*q_o
, POLICY_HND
*hnd
)
619 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
623 /*******************************************************************
624 reads or writes a structure.
625 ********************************************************************/
627 BOOL
reg_io_q_unknown_1a(const char *desc
, REG_Q_UNKNOWN_1A
*r_q
, prs_struct
*ps
, int depth
)
632 prs_debug(ps
, depth
, desc
, "reg_io_q_unknown_1a");
638 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
644 /*******************************************************************
645 reads or writes a structure.
646 ********************************************************************/
648 BOOL
reg_io_r_unknown_1a(const char *desc
, REG_R_UNKNOWN_1A
*r_r
, prs_struct
*ps
, int depth
)
653 prs_debug(ps
, depth
, desc
, "reg_io_r_unknown_1a");
659 if(!prs_uint32("unknown", ps
, depth
, &r_r
->unknown
))
661 if(!prs_ntstatus("status" , ps
, depth
, &r_r
->status
))
668 /*******************************************************************
669 reads or writes a structure.
670 ********************************************************************/
672 BOOL
reg_io_q_save_key(const char *desc
, REG_Q_SAVE_KEY
*r_q
, prs_struct
*ps
, int depth
)
677 prs_debug(ps
, depth
, desc
, "reg_io_q_save_key");
683 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
686 if(!smb_io_unihdr ("hdr_file", &r_q
->hdr_file
, ps
, depth
))
688 if(!smb_io_unistr2("uni_file", &r_q
->uni_file
, r_q
->hdr_file
.buffer
, ps
, depth
))
691 if(!prs_uint32("unknown", ps
, depth
, &r_q
->unknown
))
697 /*******************************************************************
698 reads or writes a structure.
699 ********************************************************************/
701 BOOL
reg_io_r_save_key(const char *desc
, REG_R_SAVE_KEY
*r_r
, prs_struct
*ps
, int depth
)
706 prs_debug(ps
, depth
, desc
, "reg_io_r_save_key");
712 if(!prs_ntstatus("status" , ps
, depth
, &r_r
->status
))
718 /*******************************************************************
720 ********************************************************************/
722 void init_reg_q_open_hku(REG_Q_OPEN_HKU
*q_o
,
723 uint16 unknown_0
, uint32 access_mask
)
726 q_o
->unknown_0
= unknown_0
;
727 q_o
->unknown_1
= 0x0; /* random - changes */
728 q_o
->access_mask
= access_mask
;
731 /*******************************************************************
732 reads or writes a structure.
733 ********************************************************************/
735 BOOL
reg_io_q_open_hku(const char *desc
, REG_Q_OPEN_HKU
*r_q
, prs_struct
*ps
, int depth
)
740 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hku");
746 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
749 if(!prs_uint16("unknown_0 ", ps
, depth
, &r_q
->unknown_0
))
751 if(!prs_uint16("unknown_1 ", ps
, depth
, &r_q
->unknown_1
))
753 if(!prs_uint32("access_mask ", ps
, depth
, &r_q
->access_mask
))
760 /*******************************************************************
761 reads or writes a structure.
762 ********************************************************************/
764 BOOL
reg_io_r_open_hku(const char *desc
, REG_R_OPEN_HKU
*r_r
, prs_struct
*ps
, int depth
)
769 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hku");
775 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
778 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
784 /*******************************************************************
785 Inits an REG_Q_CLOSE structure.
786 ********************************************************************/
788 void init_reg_q_close(REG_Q_CLOSE
*q_c
, POLICY_HND
*hnd
)
790 DEBUG(5,("init_reg_q_close\n"));
792 memcpy(&q_c
->pol
, hnd
, sizeof(q_c
->pol
));
795 /*******************************************************************
796 reads or writes a structure.
797 ********************************************************************/
799 BOOL
reg_io_q_close(const char *desc
, REG_Q_CLOSE
*q_u
, prs_struct
*ps
, int depth
)
804 prs_debug(ps
, depth
, desc
, "reg_io_q_close");
810 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
818 /*******************************************************************
819 reads or writes a structure.
820 ********************************************************************/
822 BOOL
reg_io_r_close(const char *desc
, REG_R_CLOSE
*r_u
, prs_struct
*ps
, int depth
)
827 prs_debug(ps
, depth
, desc
, "reg_io_r_close");
833 if(!smb_io_pol_hnd("", &r_u
->pol
, ps
, depth
))
838 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
844 /*******************************************************************
846 ********************************************************************/
848 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC
*q_i
, POLICY_HND
*pol
, SEC_DESC_BUF
*sec_desc_buf
)
850 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
852 q_i
->sec_info
= DACL_SECURITY_INFORMATION
;
855 init_buf_hdr(&q_i
->hdr_sec
, sec_desc_buf
->len
, sec_desc_buf
->len
);
856 q_i
->data
= sec_desc_buf
;
859 /*******************************************************************
860 reads or writes a structure.
861 ********************************************************************/
863 BOOL
reg_io_q_set_key_sec(const char *desc
, REG_Q_SET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
868 prs_debug(ps
, depth
, desc
, "reg_io_q_set_key_sec");
874 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
877 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
879 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
882 if(!reg_io_hdrbuf_sec(r_q
->ptr
, NULL
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
888 /*******************************************************************
889 reads or writes a structure.
890 ********************************************************************/
892 BOOL
reg_io_r_set_key_sec(const char *desc
, REG_R_SET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
897 prs_debug(ps
, depth
, desc
, "reg_io_r_set_key_sec");
903 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
910 /*******************************************************************
912 ********************************************************************/
914 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC
*q_i
, POLICY_HND
*pol
,
915 uint32 sec_buf_size
, SEC_DESC_BUF
*psdb
)
917 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
919 q_i
->sec_info
= OWNER_SECURITY_INFORMATION
|
920 GROUP_SECURITY_INFORMATION
|
921 DACL_SECURITY_INFORMATION
;
923 q_i
->ptr
= psdb
!= NULL
? 1 : 0;
926 init_buf_hdr(&q_i
->hdr_sec
, sec_buf_size
, 0);
929 /*******************************************************************
930 reads or writes a structure.
931 ********************************************************************/
933 BOOL
reg_io_q_get_key_sec(const char *desc
, REG_Q_GET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
938 prs_debug(ps
, depth
, desc
, "reg_io_q_get_key_sec");
944 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
947 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
949 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
952 if(!reg_io_hdrbuf_sec(r_q
->ptr
, NULL
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
959 /*******************************************************************
961 ********************************************************************/
962 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC
*r_i
, POLICY_HND
*pol
,
963 uint32 buf_len
, uint8
*buf
,
967 init_buf_hdr(&r_i
->hdr_sec
, buf_len
, buf_len
);
968 init_sec_desc_buf(r_i
->data
, buf_len
, 1);
970 r_i
->status
= status
; /* 0x0000 0000 or 0x0000 007a */
974 /*******************************************************************
975 reads or writes a structure.
976 ********************************************************************/
978 BOOL
reg_io_r_get_key_sec(const char *desc
, REG_R_GET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
983 prs_debug(ps
, depth
, desc
, "reg_io_r_get_key_sec");
989 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
993 if(!smb_io_hdrbuf("", &r_q
->hdr_sec
, ps
, depth
))
995 if(!sec_io_desc_buf("", &r_q
->data
, ps
, depth
))
1001 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1007 /*******************************************************************
1009 ********************************************************************/
1011 BOOL
init_reg_q_info(REG_Q_INFO
*q_i
, POLICY_HND
*pol
, char* val_name
)
1013 int len_type
= val_name
!= NULL
? strlen(val_name
) + 1 : 0;
1020 init_uni_hdr(&(q_i
->hdr_type
), len_type
);
1021 init_unistr2(&(q_i
->uni_type
), val_name
, len_type
);
1023 q_i
->ptr_reserved
= 1;
1026 q_i
->ptr_bufsize
= 1;
1031 q_i
->ptr_buflen
= 1;
1034 q_i
->ptr_buflen2
= 1;
1040 /*******************************************************************
1041 reads or writes a structure.
1042 ********************************************************************/
1044 BOOL
reg_io_q_info(const char *desc
, REG_Q_INFO
*r_q
, prs_struct
*ps
, int depth
)
1049 prs_debug(ps
, depth
, desc
, "reg_io_q_info");
1055 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
1057 if(!smb_io_unihdr ("", &r_q
->hdr_type
, ps
, depth
))
1059 if(!smb_io_unistr2("", &r_q
->uni_type
, r_q
->hdr_type
.buffer
, ps
, depth
))
1065 if(!prs_uint32("ptr_reserved", ps
, depth
, &(r_q
->ptr_reserved
)))
1068 if(!prs_uint32("ptr_buf", ps
, depth
, &(r_q
->ptr_buf
)))
1072 if(!prs_uint32("ptr_bufsize", ps
, depth
, &(r_q
->ptr_bufsize
)))
1074 if(!prs_uint32("bufsize", ps
, depth
, &(r_q
->bufsize
)))
1076 if(!prs_uint32("buf_unk", ps
, depth
, &(r_q
->buf_unk
)))
1080 if(!prs_uint32("unk1", ps
, depth
, &(r_q
->unk1
)))
1083 if(!prs_uint32("ptr_buflen", ps
, depth
, &(r_q
->ptr_buflen
)))
1086 if (r_q
->ptr_buflen
) {
1087 if(!prs_uint32("buflen", ps
, depth
, &(r_q
->buflen
)))
1089 if(!prs_uint32("ptr_buflen2", ps
, depth
, &(r_q
->ptr_buflen2
)))
1091 if(!prs_uint32("buflen2", ps
, depth
, &(r_q
->buflen2
)))
1098 /*******************************************************************
1100 New version to replace older init_reg_r_info()
1101 ********************************************************************/
1103 BOOL
new_init_reg_r_info(uint32 include_keyval
, REG_R_INFO
*r_r
,
1104 REGISTRY_VALUE
*val
, NTSTATUS status
)
1116 r_r
->type
= val
->type
;
1118 /* if include_keyval is not set, don't send the key value, just
1119 the buflen data. probably used by NT5 to allocate buffer space - SK */
1121 if ( include_keyval
) {
1122 r_r
->ptr_uni_val
= 1;
1123 buf_len
= reg_init_buffer2( &r_r
->uni_val
, val
);
1127 /* dummy buffer used so we can get the size */
1128 r_r
->ptr_uni_val
= 0;
1129 buf_len
= reg_init_buffer2( &buf2
, val
);
1132 r_r
->ptr_max_len
= 1;
1133 r_r
->buf_max_len
= buf_len
;
1136 r_r
->buf_len
= buf_len
;
1138 r_r
->status
= status
;
1143 /*******************************************************************
1145 ********************************************************************/
1147 BOOL
init_reg_r_info(uint32 include_keyval
, REG_R_INFO
*r_r
,
1148 BUFFER2
* buf
, uint32 type
, NTSTATUS status
)
1156 /* if include_keyval is not set, don't send the key value, just
1157 the buflen data. probably used by NT5 to allocate buffer space - SK */
1159 r_r
->ptr_uni_val
= include_keyval
? 1:0;
1160 r_r
->uni_val
= *buf
;
1162 r_r
->ptr_max_len
= 1;
1163 r_r
->buf_max_len
= r_r
->uni_val
.buf_max_len
;
1166 r_r
->buf_len
= r_r
->uni_val
.buf_len
;
1168 r_r
->status
= status
;
1173 /*******************************************************************
1174 reads or writes a structure.
1175 ********************************************************************/
1177 BOOL
reg_io_r_info(const char *desc
, REG_R_INFO
*r_r
, prs_struct
*ps
, int depth
)
1182 prs_debug(ps
, depth
, desc
, "reg_io_r_info");
1188 if(!prs_uint32("ptr_type", ps
, depth
, &(r_r
->ptr_type
)))
1191 if (r_r
->ptr_type
!= 0) {
1192 if(!prs_uint32("type", ps
, depth
, &r_r
->type
))
1196 if(!prs_uint32("ptr_uni_val", ps
, depth
, &(r_r
->ptr_uni_val
)))
1199 if(r_r
->ptr_uni_val
!= 0) {
1200 if(!smb_io_buffer2("uni_val", &r_r
->uni_val
, r_r
->ptr_uni_val
, ps
, depth
))
1207 if(!prs_uint32("ptr_max_len", ps
, depth
, &(r_r
->ptr_max_len
)))
1210 if (r_r
->ptr_max_len
!= 0) {
1211 if(!prs_uint32("buf_max_len", ps
, depth
, &(r_r
->buf_max_len
)))
1215 if(!prs_uint32("ptr_len", ps
, depth
, &(r_r
->ptr_len
)))
1217 if (r_r
->ptr_len
!= 0) {
1218 if(!prs_uint32("buf_len", ps
, depth
, &(r_r
->buf_len
)))
1222 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
1228 /*******************************************************************
1230 ********************************************************************/
1232 void init_reg_q_enum_val(REG_Q_ENUM_VALUE
*q_i
, POLICY_HND
*pol
,
1233 uint32 val_idx
, uint32 max_val_len
,
1238 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1240 q_i
->val_index
= val_idx
;
1241 init_uni_hdr(&q_i
->hdr_name
, max_val_len
);
1242 q_i
->uni_name
.uni_max_len
= max_val_len
;
1248 q_i
->buf_value
.buf_max_len
= max_buf_len
;
1251 q_i
->len_value1
= max_buf_len
;
1254 q_i
->len_value2
= 0;
1257 /*******************************************************************
1259 ********************************************************************/
1261 void init_reg_r_enum_val(REG_R_ENUM_VALUE
*r_u
, REGISTRY_VALUE
*val
)
1265 DEBUG(8,("init_reg_r_enum_val: Enter\n"));
1271 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val
->valuename
));
1273 init_uni_hdr( &r_u
->hdr_name
, strlen(val
->valuename
)+1 );
1274 init_unistr2( &r_u
->uni_name
, val
->valuename
, strlen(val
->valuename
)+1 );
1279 r_u
->type
= val
->type
;
1281 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1284 real_size
= reg_init_buffer2( &r_u
->buf_value
, val
);
1289 r_u
->len_value1
= real_size
;
1292 r_u
->len_value2
= real_size
;
1294 DEBUG(8,("init_reg_r_enum_val: Exit\n"));
1297 /*******************************************************************
1298 reads or writes a structure.
1299 ********************************************************************/
1301 BOOL
reg_io_q_enum_val(const char *desc
, REG_Q_ENUM_VALUE
*q_q
, prs_struct
*ps
, int depth
)
1306 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_val");
1312 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1315 if(!prs_uint32("val_index", ps
, depth
, &q_q
->val_index
))
1318 if(!smb_io_unihdr ("hdr_name", &q_q
->hdr_name
, ps
, depth
))
1320 if(!smb_io_unistr2("uni_name", &q_q
->uni_name
, q_q
->hdr_name
.buffer
, ps
, depth
))
1325 if(!prs_uint32("ptr_type", ps
, depth
, &q_q
->ptr_type
))
1328 if (q_q
->ptr_type
!= 0) {
1329 if(!prs_uint32("type", ps
, depth
, &q_q
->type
))
1333 if(!prs_uint32("ptr_value", ps
, depth
, &q_q
->ptr_value
))
1335 if(!smb_io_buffer2("buf_value", &q_q
->buf_value
, q_q
->ptr_value
, ps
, depth
))
1340 if(!prs_uint32("ptr1", ps
, depth
, &q_q
->ptr1
))
1342 if (q_q
->ptr1
!= 0) {
1343 if(!prs_uint32("len_value1", ps
, depth
, &q_q
->len_value1
))
1346 if(!prs_uint32("ptr2", ps
, depth
, &q_q
->ptr2
))
1348 if (q_q
->ptr2
!= 0) {
1349 if(!prs_uint32("len_value2", ps
, depth
, &q_q
->len_value2
))
1356 /*******************************************************************
1357 reads or writes a structure.
1358 ********************************************************************/
1360 BOOL
reg_io_r_enum_val(const char *desc
, REG_R_ENUM_VALUE
*r_q
, prs_struct
*ps
, int depth
)
1365 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_val");
1371 if(!smb_io_unihdr ("hdr_name", &r_q
->hdr_name
, ps
, depth
))
1373 if(!smb_io_unistr2("uni_name", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
1378 if(!prs_uint32("ptr_type", ps
, depth
, &r_q
->ptr_type
))
1381 if (r_q
->ptr_type
!= 0) {
1382 if(!prs_uint32("type", ps
, depth
, &r_q
->type
))
1386 if(!prs_uint32("ptr_value", ps
, depth
, &r_q
->ptr_value
))
1388 if(!smb_io_buffer2("buf_value", &r_q
->buf_value
, r_q
->ptr_value
, ps
, depth
))
1393 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
1395 if (r_q
->ptr1
!= 0) {
1396 if(!prs_uint32("len_value1", ps
, depth
, &r_q
->len_value1
))
1400 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
1402 if (r_q
->ptr2
!= 0) {
1403 if(!prs_uint32("len_value2", ps
, depth
, &r_q
->len_value2
))
1407 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1413 /*******************************************************************
1415 ********************************************************************/
1417 void init_reg_q_create_val(REG_Q_CREATE_VALUE
*q_i
, POLICY_HND
*pol
,
1418 char *val_name
, uint32 type
,
1421 int val_len
= strlen(val_name
) + 1;
1425 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1427 init_uni_hdr(&q_i
->hdr_name
, val_len
);
1428 init_unistr2(&q_i
->uni_name
, val_name
, val_len
);
1431 q_i
->buf_value
= val
;
1434 /*******************************************************************
1435 reads or writes a structure.
1436 ********************************************************************/
1438 BOOL
reg_io_q_create_val(const char *desc
, REG_Q_CREATE_VALUE
*q_q
, prs_struct
*ps
, int depth
)
1443 prs_debug(ps
, depth
, desc
, "reg_io_q_create_val");
1449 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1452 if(!smb_io_unihdr ("hdr_name", &q_q
->hdr_name
, ps
, depth
))
1454 if(!smb_io_unistr2("uni_name", &q_q
->uni_name
, q_q
->hdr_name
.buffer
, ps
, depth
))
1459 if(!prs_uint32("type", ps
, depth
, &q_q
->type
))
1461 if(!smb_io_buffer3("buf_value", q_q
->buf_value
, ps
, depth
))
1469 /*******************************************************************
1470 reads or writes a structure.
1471 ********************************************************************/
1473 BOOL
reg_io_r_create_val(const char *desc
, REG_R_CREATE_VALUE
*r_q
, prs_struct
*ps
, int depth
)
1478 prs_debug(ps
, depth
, desc
, "reg_io_r_create_val");
1484 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1490 /*******************************************************************
1492 ********************************************************************/
1494 void init_reg_q_enum_key(REG_Q_ENUM_KEY
*q_i
, POLICY_HND
*pol
, uint32 key_idx
)
1496 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1498 q_i
->key_index
= key_idx
;
1499 q_i
->key_name_len
= 0;
1500 q_i
->unknown_1
= 0x0414;
1503 q_i
->unknown_2
= 0x0000020A;
1504 memset(q_i
->pad1
, 0, sizeof(q_i
->pad1
));
1507 memset(q_i
->pad2
, 0, sizeof(q_i
->pad2
));
1510 unix_to_nt_time(&q_i
->time
, 0); /* current time? */
1513 /*******************************************************************
1514 makes a reply structure.
1515 ********************************************************************/
1517 void init_reg_r_enum_key(REG_R_ENUM_KEY
*r_u
, char *subkey
, uint32 unknown_1
,
1523 r_u
->unknown_1
= unknown_1
;
1524 r_u
->unknown_2
= unknown_2
;
1525 r_u
->unknown_3
= 0x0;
1527 r_u
->key_name_len
= (strlen(subkey
)+1) * 2;
1528 if (r_u
->key_name_len
)
1530 init_unistr3( &r_u
->key_name
, subkey
);
1536 /*******************************************************************
1537 reads or writes a structure.
1538 ********************************************************************/
1540 BOOL
reg_io_q_enum_key(const char *desc
, REG_Q_ENUM_KEY
*q_q
, prs_struct
*ps
, int depth
)
1545 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_key");
1551 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1554 if(!prs_uint32("key_index", ps
, depth
, &q_q
->key_index
))
1556 if(!prs_uint16("key_name_len", ps
, depth
, &q_q
->key_name_len
))
1558 if(!prs_uint16("unknown_1", ps
, depth
, &q_q
->unknown_1
))
1561 if(!prs_uint32("ptr1", ps
, depth
, &q_q
->ptr1
))
1564 if (q_q
->ptr1
!= 0) {
1565 if(!prs_uint32("unknown_2", ps
, depth
, &q_q
->unknown_2
))
1567 if(!prs_uint8s(False
, "pad1", ps
, depth
, q_q
->pad1
, sizeof(q_q
->pad1
)))
1571 if(!prs_uint32("ptr2", ps
, depth
, &q_q
->ptr2
))
1574 if (q_q
->ptr2
!= 0) {
1575 if(!prs_uint8s(False
, "pad2", ps
, depth
, q_q
->pad2
, sizeof(q_q
->pad2
)))
1579 if(!prs_uint32("ptr3", ps
, depth
, &q_q
->ptr3
))
1582 if (q_q
->ptr3
!= 0) {
1583 if(!smb_io_time("", &q_q
->time
, ps
, depth
))
1590 /*******************************************************************
1591 reads or writes a structure.
1592 ********************************************************************/
1594 BOOL
reg_io_r_enum_key(const char *desc
, REG_R_ENUM_KEY
*r_q
, prs_struct
*ps
, int depth
)
1599 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_key");
1605 if(!prs_uint16("key_name_len", ps
, depth
, &r_q
->key_name_len
))
1607 if(!prs_uint16("unknown_1", ps
, depth
, &r_q
->unknown_1
))
1610 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
1613 if (r_q
->ptr1
!= 0) {
1614 if(!prs_uint32("unknown_2", ps
, depth
, &r_q
->unknown_2
))
1616 if(!prs_uint32("unknown_3", ps
, depth
, &r_q
->unknown_3
))
1618 if(!smb_io_unistr3("key_name", &r_q
->key_name
, ps
, depth
))
1624 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
1627 if (r_q
->ptr2
!= 0) {
1628 if(!prs_uint8s(False
, "pad2", ps
, depth
, r_q
->pad2
, sizeof(r_q
->pad2
)))
1632 if(!prs_uint32("ptr3", ps
, depth
, &r_q
->ptr3
))
1635 if (r_q
->ptr3
!= 0) {
1636 if(!smb_io_time("", &r_q
->time
, ps
, depth
))
1640 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1646 /*******************************************************************
1648 ********************************************************************/
1650 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY
*r_q
, POLICY_HND
*pol
,
1651 char *key_name
, uint32 access_desired
)
1653 int len_name
= strlen(key_name
)+1;
1655 memcpy(&r_q
->pol
, pol
, sizeof(r_q
->pol
));
1657 init_uni_hdr(&r_q
->hdr_name
, len_name
);
1658 init_unistr2(&r_q
->uni_name
, key_name
, len_name
);
1660 r_q
->unknown_0
= 0x00000000;
1661 r_q
->access_desired
= access_desired
;
1664 /*******************************************************************
1665 reads or writes a structure.
1666 ********************************************************************/
1668 BOOL
reg_io_q_open_entry(const char *desc
, REG_Q_OPEN_ENTRY
*r_q
, prs_struct
*ps
, int depth
)
1673 prs_debug(ps
, depth
, desc
, "reg_io_q_entry");
1679 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
1681 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
1683 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
1689 if(!prs_uint32("unknown_0 ", ps
, depth
, &r_q
->unknown_0
))
1691 if(!prs_uint32("access_desired ", ps
, depth
, &r_q
->access_desired
))
1697 /*******************************************************************
1699 ********************************************************************/
1701 void init_reg_r_open_entry(REG_R_OPEN_ENTRY
*r_r
,
1702 POLICY_HND
*pol
, NTSTATUS status
)
1704 if (NT_STATUS_IS_OK(status
)) {
1705 memcpy(&r_r
->pol
, pol
, sizeof(r_r
->pol
));
1707 ZERO_STRUCT(r_r
->pol
);
1709 r_r
->status
= status
;
1712 /*******************************************************************
1713 reads or writes a structure.
1714 ********************************************************************/
1716 BOOL
reg_io_r_open_entry(const char *desc
, REG_R_OPEN_ENTRY
*r_r
, prs_struct
*ps
, int depth
)
1721 prs_debug(ps
, depth
, desc
, "reg_io_r_open_entry");
1727 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
1730 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
1736 /*******************************************************************
1738 ********************************************************************/
1739 void init_reg_q_shutdown(REG_Q_SHUTDOWN
* q_s
, const char *msg
,
1740 uint32 timeout
, BOOL do_reboot
, BOOL force
)
1743 msg_len
= strlen(msg
);
1749 init_uni_hdr(&(q_s
->hdr_msg
), msg_len
);
1750 init_unistr2(&(q_s
->uni_msg
), msg
, msg_len
);
1752 q_s
->timeout
= timeout
;
1754 q_s
->reboot
= do_reboot
? 1 : 0;
1755 q_s
->force
= force
? 1 : 0;
1759 /*******************************************************************
1760 reads or writes a structure.
1761 ********************************************************************/
1762 BOOL
reg_io_q_shutdown(const char *desc
, REG_Q_SHUTDOWN
* q_s
, prs_struct
*ps
,
1768 prs_debug(ps
, depth
, desc
, "reg_io_q_shutdown");
1774 if (!prs_uint32("ptr_0", ps
, depth
, &(q_s
->ptr_0
)))
1776 if (!prs_uint32("ptr_1", ps
, depth
, &(q_s
->ptr_1
)))
1778 if (!prs_uint32("ptr_2", ps
, depth
, &(q_s
->ptr_2
)))
1781 if (!smb_io_unihdr("hdr_msg", &(q_s
->hdr_msg
), ps
, depth
))
1783 if (!smb_io_unistr2("uni_msg", &(q_s
->uni_msg
), q_s
->hdr_msg
.buffer
, ps
, depth
))
1788 if (!prs_uint32("timeout", ps
, depth
, &(q_s
->timeout
)))
1790 if (!prs_uint8("force ", ps
, depth
, &(q_s
->force
)))
1792 if (!prs_uint8("reboot ", ps
, depth
, &(q_s
->reboot
)))
1798 /*******************************************************************
1799 reads or writes a structure.
1800 ********************************************************************/
1801 BOOL
reg_io_r_shutdown(const char *desc
, REG_R_SHUTDOWN
* r_s
, prs_struct
*ps
,
1807 prs_debug(ps
, depth
, desc
, "reg_io_r_shutdown");
1813 if(!prs_ntstatus("status", ps
, depth
, &r_s
->status
))
1819 /*******************************************************************
1821 ********************************************************************/
1822 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN
* q_s
)
1825 q_s
->ptr_server
= 0;
1829 /*******************************************************************
1830 reads or writes a structure.
1831 ********************************************************************/
1832 BOOL
reg_io_q_abort_shutdown(const char *desc
, REG_Q_ABORT_SHUTDOWN
* q_s
,
1833 prs_struct
*ps
, int depth
)
1838 prs_debug(ps
, depth
, desc
, "reg_io_q_abort_shutdown");
1844 if (!prs_uint32("ptr_server", ps
, depth
, &(q_s
->ptr_server
)))
1846 if (q_s
->ptr_server
!= 0)
1847 if (!prs_uint16("server", ps
, depth
, &(q_s
->server
)))
1853 /*******************************************************************
1854 reads or writes a structure.
1855 ********************************************************************/
1856 BOOL
reg_io_r_abort_shutdown(const char *desc
, REG_R_ABORT_SHUTDOWN
* r_s
,
1857 prs_struct
*ps
, int depth
)
1862 prs_debug(ps
, depth
, desc
, "reg_io_r_abort_shutdown");
1868 if (!prs_ntstatus("status", ps
, depth
, &r_s
->status
))