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
)
46 real_size
= val
->size
;
51 string
= (char*)val
->data_p
;
52 DEBUG(10,("reg_init_buffer2: REG_SZ string => [%s]\n", string
));
54 init_unistr2( &unistr
, (char*)val
->data_p
, strlen((char*)val
->data_p
)+1 );
55 init_buffer2( buf2
, (char*)unistr
.buffer
, unistr
.uni_str_len
*2 );
56 real_size
= unistr
.uni_str_len
*2;
60 string
= (char*)val
->data_p
;
62 while ( string
&& *string
)
64 DEBUG(10,("reg_init_buffer2: REG_MULTI_SZ string => [%s], size => [%d]\n", string
, real_size
));
66 init_unistr2( &unistr
, string
, strlen(string
)+1 );
68 list2
= Realloc( list
, real_size
+ unistr
.uni_str_len
*2 );
73 memcpy( list
+real_size
, unistr
.buffer
, unistr
.uni_str_len
*2 );
75 real_size
+= unistr
.uni_str_len
*2;
77 string
+= strlen(string
)+1;
80 list2
= Realloc( list
, real_size
+ 2 );
84 list
[real_size
++] = 0x0;
85 list
[real_size
++] = 0x0;
87 init_buffer2( buf2
, (char*)list
, real_size
);
89 DEBUG(10,("reg_init_buffer2: REG_MULTI_SZ size => [%d]\n", real_size
));
94 DEBUG(10,("reg_init_buffer2: REG_BINARY size => [%d]\n", val
->size
));
96 init_buffer2( buf2
, val
->data_p
, val
->size
);
100 DEBUG(10,("reg_init_buffer2: REG_DWORD value => [%d]\n", *(uint32
*)val
->data_p
));
101 init_buffer2( buf2
, val
->data_p
, val
->size
);
105 DEBUG(0,("reg_init_buffer2: Unsupported registry data type [%d]\n", val
->type
));
114 /*******************************************************************
116 ********************************************************************/
118 void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR
*q_o
,
119 uint16 unknown_0
, uint32 level
)
122 q_o
->unknown_0
= unknown_0
;
123 q_o
->unknown_1
= 0x0; /* random - changes */
127 /*******************************************************************
128 reads or writes a structure.
129 ********************************************************************/
131 BOOL
reg_io_q_open_hkcr(char *desc
, REG_Q_OPEN_HKCR
*r_q
, prs_struct
*ps
, int depth
)
136 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hkcr");
142 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
146 if(!prs_uint16("unknown_0", ps
, depth
, &r_q
->unknown_0
))
148 if(!prs_uint16("unknown_1", ps
, depth
, &r_q
->unknown_1
))
150 if(!prs_uint32("level ", ps
, depth
, &r_q
->level
))
158 /*******************************************************************
159 reads or writes a structure.
160 ********************************************************************/
162 BOOL
reg_io_r_open_hkcr(char *desc
, REG_R_OPEN_HKCR
*r_r
, prs_struct
*ps
, int depth
)
167 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hkcr");
173 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
176 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
182 /*******************************************************************
184 ********************************************************************/
186 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM
* q_o
,
187 uint16 unknown_0
, uint32 access_mask
)
190 q_o
->unknown_0
= unknown_0
;
191 q_o
->unknown_1
= 0x0; /* random - changes */
192 q_o
->access_mask
= access_mask
;
196 /*******************************************************************
197 reads or writes a structure.
198 ********************************************************************/
199 BOOL
reg_io_q_open_hklm(char *desc
, REG_Q_OPEN_HKLM
* r_q
, prs_struct
*ps
,
205 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hklm");
211 if (!prs_uint32("ptr ", ps
, depth
, &(r_q
->ptr
)))
215 if (!prs_uint16("unknown_0", ps
, depth
, &(r_q
->unknown_0
)))
217 if (!prs_uint16("unknown_1", ps
, depth
, &(r_q
->unknown_1
)))
219 if (!prs_uint32("access_mask", ps
, depth
, &(r_q
->access_mask
)))
227 /*******************************************************************
228 reads or writes a structure.
229 ********************************************************************/
230 BOOL
reg_io_r_open_hklm(char *desc
, REG_R_OPEN_HKLM
* r_r
, prs_struct
*ps
,
236 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hklm");
242 if (!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
245 if (!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
254 /*******************************************************************
256 ********************************************************************/
258 void init_reg_q_flush_key(REG_Q_FLUSH_KEY
*q_u
, POLICY_HND
*pol
)
260 memcpy(&q_u
->pol
, pol
, sizeof(q_u
->pol
));
263 /*******************************************************************
264 reads or writes a structure.
265 ********************************************************************/
267 BOOL
reg_io_q_flush_key(char *desc
, REG_Q_FLUSH_KEY
*r_q
, prs_struct
*ps
, int depth
)
272 prs_debug(ps
, depth
, desc
, "reg_io_q_flush_key");
278 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
284 /*******************************************************************
285 reads or writes a structure.
286 ********************************************************************/
288 BOOL
reg_io_r_flush_key(char *desc
, REG_R_FLUSH_KEY
*r_r
, prs_struct
*ps
, int depth
)
293 prs_debug(ps
, depth
, desc
, "reg_io_r_flush_key");
299 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
305 /*******************************************************************
306 reads or writes SEC_DESC_BUF and SEC_DATA structures.
307 ********************************************************************/
309 static BOOL
reg_io_hdrbuf_sec(uint32 ptr
, uint32
*ptr3
, BUFHDR
*hdr_sec
, SEC_DESC_BUF
*data
, prs_struct
*ps
, int depth
)
314 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec
, ps
, depth
, &hdr_offset
))
317 old_offset
= prs_offset(ps
);
320 if(!prs_uint32("ptr3", ps
, depth
, ptr3
))
324 if (ptr3
== NULL
|| *ptr3
!= 0) {
325 if(!sec_io_desc_buf("data ", &data
, ps
, depth
)) /* JRA - this line is probably wrong... */
329 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec
, ps
, depth
, hdr_offset
,
330 data
->max_len
, data
->len
))
332 if(!prs_set_offset(ps
, old_offset
+ data
->len
+ sizeof(uint32
) * ((ptr3
!= NULL
) ? 5 : 3)))
342 /*******************************************************************
344 ********************************************************************/
346 void init_reg_q_create_key(REG_Q_CREATE_KEY
*q_c
, POLICY_HND
*hnd
,
347 char *name
, char *class, SEC_ACCESS
*sam_access
,
348 SEC_DESC_BUF
*sec_buf
)
350 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
351 int len_class
= class != NULL
? strlen(class) + 1: 0;
355 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
357 init_uni_hdr(&q_c
->hdr_name
, len_name
);
358 init_unistr2(&q_c
->uni_name
, name
, len_name
);
360 init_uni_hdr(&q_c
->hdr_class
, len_class
);
361 init_unistr2(&q_c
->uni_class
, class, len_class
);
363 q_c
->reserved
= 0x00000000;
364 memcpy(&q_c
->sam_access
, sam_access
, sizeof(q_c
->sam_access
));
367 q_c
->sec_info
= DACL_SECURITY_INFORMATION
| SACL_SECURITY_INFORMATION
;
371 init_buf_hdr(&q_c
->hdr_sec
, sec_buf
->len
, sec_buf
->len
);
373 q_c
->unknown_2
= 0x00000000;
376 /*******************************************************************
377 reads or writes a structure.
378 ********************************************************************/
380 BOOL
reg_io_q_create_key(char *desc
, REG_Q_CREATE_KEY
*r_q
, prs_struct
*ps
, int depth
)
385 prs_debug(ps
, depth
, desc
, "reg_io_q_create_key");
391 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
394 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
396 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
401 if(!smb_io_unihdr ("", &r_q
->hdr_class
, ps
, depth
))
403 if(!smb_io_unistr2("", &r_q
->uni_class
, r_q
->hdr_class
.buffer
, ps
, depth
))
408 if(!prs_uint32("reserved", ps
, depth
, &r_q
->reserved
))
410 if(!sec_io_access("sam_access", &r_q
->sam_access
, ps
, depth
))
413 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
416 if (r_q
->ptr1
!= 0) {
417 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
421 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
423 if(!reg_io_hdrbuf_sec(r_q
->ptr2
, &r_q
->ptr3
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
426 if(!prs_uint32("unknown_2", ps
, depth
, &r_q
->unknown_2
))
432 /*******************************************************************
433 reads or writes a structure.
434 ********************************************************************/
436 BOOL
reg_io_r_create_key(char *desc
, REG_R_CREATE_KEY
*r_r
, prs_struct
*ps
, int depth
)
441 prs_debug(ps
, depth
, desc
, "reg_io_r_create_key");
447 if(!smb_io_pol_hnd("", &r_r
->key_pol
, ps
, depth
))
449 if(!prs_uint32("unknown", ps
, depth
, &r_r
->unknown
))
452 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
459 /*******************************************************************
461 ********************************************************************/
463 void init_reg_q_delete_val(REG_Q_DELETE_VALUE
*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_val(char *desc
, REG_Q_DELETE_VALUE
*r_q
, prs_struct
*ps
, int depth
)
484 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_val");
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
))
504 /*******************************************************************
505 reads or writes a structure.
506 ********************************************************************/
508 BOOL
reg_io_r_delete_val(char *desc
, REG_R_DELETE_VALUE
*r_r
, prs_struct
*ps
, int depth
)
513 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_val");
519 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
525 /*******************************************************************
527 ********************************************************************/
529 void init_reg_q_delete_key(REG_Q_DELETE_KEY
*q_c
, POLICY_HND
*hnd
,
532 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
535 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
537 init_uni_hdr(&q_c
->hdr_name
, len_name
);
538 init_unistr2(&q_c
->uni_name
, name
, len_name
);
541 /*******************************************************************
542 reads or writes a structure.
543 ********************************************************************/
545 BOOL
reg_io_q_delete_key(char *desc
, REG_Q_DELETE_KEY
*r_q
, prs_struct
*ps
, int depth
)
550 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_key");
556 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
559 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
561 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
569 /*******************************************************************
570 reads or writes a structure.
571 ********************************************************************/
573 BOOL
reg_io_r_delete_key(char *desc
, REG_R_DELETE_KEY
*r_r
, prs_struct
*ps
, int depth
)
578 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_key");
584 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
590 /*******************************************************************
592 ********************************************************************/
594 void init_reg_q_query_key(REG_Q_QUERY_KEY
*q_o
, POLICY_HND
*hnd
,
595 uint32 max_class_len
)
599 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
600 init_uni_hdr(&q_o
->hdr_class
, max_class_len
);
601 q_o
->uni_class
.uni_max_len
= max_class_len
;
604 /*******************************************************************
605 reads or writes a structure.
606 ********************************************************************/
608 BOOL
reg_io_q_query_key(char *desc
, REG_Q_QUERY_KEY
*r_q
, prs_struct
*ps
, int depth
)
613 prs_debug(ps
, depth
, desc
, "reg_io_q_query_key");
619 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
621 if(!smb_io_unihdr ("", &r_q
->hdr_class
, ps
, depth
))
623 if(!smb_io_unistr2("", &r_q
->uni_class
, r_q
->hdr_class
.buffer
, ps
, depth
))
633 /*******************************************************************
634 reads or writes a structure.
635 ********************************************************************/
637 BOOL
reg_io_r_query_key(char *desc
, REG_R_QUERY_KEY
*r_r
, prs_struct
*ps
, int depth
)
642 prs_debug(ps
, depth
, desc
, "reg_io_r_query_key");
648 if(!smb_io_unihdr ("", &r_r
->hdr_class
, ps
, depth
))
650 if(!smb_io_unistr2("", &r_r
->uni_class
, r_r
->hdr_class
.buffer
, ps
, depth
))
656 if(!prs_uint32("num_subkeys ", ps
, depth
, &r_r
->num_subkeys
))
658 if(!prs_uint32("max_subkeylen ", ps
, depth
, &r_r
->max_subkeylen
))
660 if(!prs_uint32("reserved ", ps
, depth
, &r_r
->reserved
))
662 if(!prs_uint32("num_values ", ps
, depth
, &r_r
->num_values
))
664 if(!prs_uint32("max_valnamelen", ps
, depth
, &r_r
->max_valnamelen
))
666 if(!prs_uint32("max_valbufsize", ps
, depth
, &r_r
->max_valbufsize
))
668 if(!prs_uint32("sec_desc ", ps
, depth
, &r_r
->sec_desc
))
670 if(!smb_io_time("mod_time ", &r_r
->mod_time
, ps
, depth
))
673 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
679 /*******************************************************************
681 ********************************************************************/
683 void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A
*q_o
, POLICY_HND
*hnd
)
685 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
688 /*******************************************************************
689 reads or writes a structure.
690 ********************************************************************/
692 BOOL
reg_io_q_unknown_1a(char *desc
, REG_Q_UNKNOWN_1A
*r_q
, prs_struct
*ps
, int depth
)
697 prs_debug(ps
, depth
, desc
, "reg_io_q_unknown_1a");
703 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
709 /*******************************************************************
710 reads or writes a structure.
711 ********************************************************************/
713 BOOL
reg_io_r_unknown_1a(char *desc
, REG_R_UNKNOWN_1A
*r_r
, prs_struct
*ps
, int depth
)
718 prs_debug(ps
, depth
, desc
, "reg_io_r_unknown_1a");
724 if(!prs_uint32("unknown", ps
, depth
, &r_r
->unknown
))
726 if(!prs_ntstatus("status" , ps
, depth
, &r_r
->status
))
732 /*******************************************************************
734 ********************************************************************/
736 void init_reg_q_open_hku(REG_Q_OPEN_HKU
*q_o
,
737 uint16 unknown_0
, uint32 access_mask
)
740 q_o
->unknown_0
= unknown_0
;
741 q_o
->unknown_1
= 0x0; /* random - changes */
742 q_o
->access_mask
= access_mask
;
745 /*******************************************************************
746 reads or writes a structure.
747 ********************************************************************/
749 BOOL
reg_io_q_open_hku(char *desc
, REG_Q_OPEN_HKU
*r_q
, prs_struct
*ps
, int depth
)
754 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hku");
760 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
763 if(!prs_uint16("unknown_0 ", ps
, depth
, &r_q
->unknown_0
))
765 if(!prs_uint16("unknown_1 ", ps
, depth
, &r_q
->unknown_1
))
767 if(!prs_uint32("access_mask ", ps
, depth
, &r_q
->access_mask
))
774 /*******************************************************************
775 reads or writes a structure.
776 ********************************************************************/
778 BOOL
reg_io_r_open_hku(char *desc
, REG_R_OPEN_HKU
*r_r
, prs_struct
*ps
, int depth
)
783 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hku");
789 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
792 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
798 /*******************************************************************
799 Inits an REG_Q_CLOSE structure.
800 ********************************************************************/
802 void init_reg_q_close(REG_Q_CLOSE
*q_c
, POLICY_HND
*hnd
)
804 DEBUG(5,("init_reg_q_close\n"));
806 memcpy(&q_c
->pol
, hnd
, sizeof(q_c
->pol
));
809 /*******************************************************************
810 reads or writes a structure.
811 ********************************************************************/
813 BOOL
reg_io_q_close(char *desc
, REG_Q_CLOSE
*q_u
, prs_struct
*ps
, int depth
)
818 prs_debug(ps
, depth
, desc
, "reg_io_q_close");
824 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
832 /*******************************************************************
833 reads or writes a structure.
834 ********************************************************************/
836 BOOL
reg_io_r_close(char *desc
, REG_R_CLOSE
*r_u
, prs_struct
*ps
, int depth
)
841 prs_debug(ps
, depth
, desc
, "reg_io_r_close");
847 if(!smb_io_pol_hnd("", &r_u
->pol
, ps
, depth
))
852 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
858 /*******************************************************************
860 ********************************************************************/
862 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC
*q_i
, POLICY_HND
*pol
, SEC_DESC_BUF
*sec_desc_buf
)
864 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
866 q_i
->sec_info
= DACL_SECURITY_INFORMATION
;
869 init_buf_hdr(&q_i
->hdr_sec
, sec_desc_buf
->len
, sec_desc_buf
->len
);
870 q_i
->data
= sec_desc_buf
;
873 /*******************************************************************
874 reads or writes a structure.
875 ********************************************************************/
877 BOOL
reg_io_q_set_key_sec(char *desc
, REG_Q_SET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
882 prs_debug(ps
, depth
, desc
, "reg_io_q_set_key_sec");
888 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
891 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
893 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
896 if(!reg_io_hdrbuf_sec(r_q
->ptr
, NULL
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
902 /*******************************************************************
903 reads or writes a structure.
904 ********************************************************************/
906 BOOL
reg_io_r_set_key_sec(char *desc
, REG_R_SET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
911 prs_debug(ps
, depth
, desc
, "reg_io_r_set_key_sec");
917 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
924 /*******************************************************************
926 ********************************************************************/
928 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC
*q_i
, POLICY_HND
*pol
,
929 uint32 sec_buf_size
, SEC_DESC_BUF
*psdb
)
931 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
933 q_i
->sec_info
= OWNER_SECURITY_INFORMATION
|
934 GROUP_SECURITY_INFORMATION
|
935 DACL_SECURITY_INFORMATION
;
937 q_i
->ptr
= psdb
!= NULL
? 1 : 0;
940 init_buf_hdr(&q_i
->hdr_sec
, sec_buf_size
, 0);
943 /*******************************************************************
944 reads or writes a structure.
945 ********************************************************************/
947 BOOL
reg_io_q_get_key_sec(char *desc
, REG_Q_GET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
952 prs_debug(ps
, depth
, desc
, "reg_io_q_get_key_sec");
958 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
961 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
963 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
966 if(!reg_io_hdrbuf_sec(r_q
->ptr
, NULL
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
973 /*******************************************************************
975 ********************************************************************/
976 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC
*r_i
, POLICY_HND
*pol
,
977 uint32 buf_len
, uint8
*buf
,
981 init_buf_hdr(&r_i
->hdr_sec
, buf_len
, buf_len
);
982 init_sec_desc_buf(r_i
->data
, buf_len
, 1);
984 r_i
->status
= status
; /* 0x0000 0000 or 0x0000 007a */
988 /*******************************************************************
989 reads or writes a structure.
990 ********************************************************************/
992 BOOL
reg_io_r_get_key_sec(char *desc
, REG_R_GET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
997 prs_debug(ps
, depth
, desc
, "reg_io_r_get_key_sec");
1003 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
1006 if (r_q
->ptr
!= 0) {
1007 if(!smb_io_hdrbuf("", &r_q
->hdr_sec
, ps
, depth
))
1009 if(!sec_io_desc_buf("", &r_q
->data
, ps
, depth
))
1015 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1021 /*******************************************************************
1023 ********************************************************************/
1025 BOOL
init_reg_q_info(REG_Q_INFO
*q_i
, POLICY_HND
*pol
, char* val_name
)
1027 int len_type
= val_name
!= NULL
? strlen(val_name
) + 1 : 0;
1034 init_uni_hdr(&(q_i
->hdr_type
), len_type
);
1035 init_unistr2(&(q_i
->uni_type
), val_name
, len_type
);
1037 q_i
->ptr_reserved
= 1;
1040 q_i
->ptr_bufsize
= 1;
1045 q_i
->ptr_buflen
= 1;
1048 q_i
->ptr_buflen2
= 1;
1054 /*******************************************************************
1055 reads or writes a structure.
1056 ********************************************************************/
1058 BOOL
reg_io_q_info(char *desc
, REG_Q_INFO
*r_q
, prs_struct
*ps
, int depth
)
1063 prs_debug(ps
, depth
, desc
, "reg_io_q_info");
1069 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
1071 if(!smb_io_unihdr ("", &r_q
->hdr_type
, ps
, depth
))
1073 if(!smb_io_unistr2("", &r_q
->uni_type
, r_q
->hdr_type
.buffer
, ps
, depth
))
1079 if(!prs_uint32("ptr_reserved", ps
, depth
, &(r_q
->ptr_reserved
)))
1082 if(!prs_uint32("ptr_buf", ps
, depth
, &(r_q
->ptr_buf
)))
1086 if(!prs_uint32("ptr_bufsize", ps
, depth
, &(r_q
->ptr_bufsize
)))
1088 if(!prs_uint32("bufsize", ps
, depth
, &(r_q
->bufsize
)))
1090 if(!prs_uint32("buf_unk", ps
, depth
, &(r_q
->buf_unk
)))
1094 if(!prs_uint32("unk1", ps
, depth
, &(r_q
->unk1
)))
1097 if(!prs_uint32("ptr_buflen", ps
, depth
, &(r_q
->ptr_buflen
)))
1100 if (r_q
->ptr_buflen
) {
1101 if(!prs_uint32("buflen", ps
, depth
, &(r_q
->buflen
)))
1103 if(!prs_uint32("ptr_buflen2", ps
, depth
, &(r_q
->ptr_buflen2
)))
1105 if(!prs_uint32("buflen2", ps
, depth
, &(r_q
->buflen2
)))
1112 /*******************************************************************
1114 New version to replace older init_reg_r_info()
1115 ********************************************************************/
1117 BOOL
new_init_reg_r_info(uint32 include_keyval
, REG_R_INFO
*r_r
,
1118 REGISTRY_VALUE
*val
, NTSTATUS status
)
1130 r_r
->type
= val
->type
;
1132 /* if include_keyval is not set, don't send the key value, just
1133 the buflen data. probably used by NT5 to allocate buffer space - SK */
1135 if ( include_keyval
) {
1136 r_r
->ptr_uni_val
= 1;
1137 buf_len
= reg_init_buffer2( &r_r
->uni_val
, val
);
1141 /* dummy buffer used so we can get the size */
1142 r_r
->ptr_uni_val
= 0;
1143 buf_len
= reg_init_buffer2( &buf2
, val
);
1146 r_r
->ptr_max_len
= 1;
1147 r_r
->buf_max_len
= buf_len
;
1150 r_r
->buf_len
= buf_len
;
1152 r_r
->status
= status
;
1157 /*******************************************************************
1159 ********************************************************************/
1161 BOOL
init_reg_r_info(uint32 include_keyval
, REG_R_INFO
*r_r
,
1162 BUFFER2
* buf
, uint32 type
, NTSTATUS status
)
1170 /* if include_keyval is not set, don't send the key value, just
1171 the buflen data. probably used by NT5 to allocate buffer space - SK */
1173 r_r
->ptr_uni_val
= include_keyval
? 1:0;
1174 r_r
->uni_val
= *buf
;
1176 r_r
->ptr_max_len
= 1;
1177 r_r
->buf_max_len
= r_r
->uni_val
.buf_max_len
;
1180 r_r
->buf_len
= r_r
->uni_val
.buf_len
;
1182 r_r
->status
= status
;
1187 /*******************************************************************
1188 reads or writes a structure.
1189 ********************************************************************/
1191 BOOL
reg_io_r_info(char *desc
, REG_R_INFO
*r_r
, prs_struct
*ps
, int depth
)
1196 prs_debug(ps
, depth
, desc
, "reg_io_r_info");
1202 if(!prs_uint32("ptr_type", ps
, depth
, &(r_r
->ptr_type
)))
1205 if (r_r
->ptr_type
!= 0) {
1206 if(!prs_uint32("type", ps
, depth
, &r_r
->type
))
1210 if(!prs_uint32("ptr_uni_val", ps
, depth
, &(r_r
->ptr_uni_val
)))
1213 if(r_r
->ptr_uni_val
!= 0) {
1214 if(!smb_io_buffer2("uni_val", &r_r
->uni_val
, r_r
->ptr_uni_val
, ps
, depth
))
1221 if(!prs_uint32("ptr_max_len", ps
, depth
, &(r_r
->ptr_max_len
)))
1224 if (r_r
->ptr_max_len
!= 0) {
1225 if(!prs_uint32("buf_max_len", ps
, depth
, &(r_r
->buf_max_len
)))
1229 if(!prs_uint32("ptr_len", ps
, depth
, &(r_r
->ptr_len
)))
1231 if (r_r
->ptr_len
!= 0) {
1232 if(!prs_uint32("buf_len", ps
, depth
, &(r_r
->buf_len
)))
1236 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
1242 /*******************************************************************
1244 ********************************************************************/
1246 void init_reg_q_enum_val(REG_Q_ENUM_VALUE
*q_i
, POLICY_HND
*pol
,
1247 uint32 val_idx
, uint32 max_val_len
,
1252 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1254 q_i
->val_index
= val_idx
;
1255 init_uni_hdr(&q_i
->hdr_name
, max_val_len
);
1256 q_i
->uni_name
.uni_max_len
= max_val_len
;
1262 q_i
->buf_value
.buf_max_len
= max_buf_len
;
1265 q_i
->len_value1
= max_buf_len
;
1268 q_i
->len_value2
= 0;
1271 /*******************************************************************
1273 ********************************************************************/
1275 void init_reg_r_enum_val(REG_R_ENUM_VALUE
*r_u
, REGISTRY_VALUE
*val
)
1279 DEBUG(8,("init_reg_r_enum_val: Enter\n"));
1285 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val
->valuename
));
1287 init_uni_hdr( &r_u
->hdr_name
, strlen(val
->valuename
)+1 );
1288 init_unistr2( &r_u
->uni_name
, val
->valuename
, strlen(val
->valuename
)+1 );
1293 r_u
->type
= val
->type
;
1295 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
1298 real_size
= reg_init_buffer2( &r_u
->buf_value
, val
);
1303 r_u
->len_value1
= real_size
;
1306 r_u
->len_value2
= real_size
;
1308 DEBUG(8,("init_reg_r_enum_val: Exit\n"));
1311 /*******************************************************************
1312 reads or writes a structure.
1313 ********************************************************************/
1315 BOOL
reg_io_q_enum_val(char *desc
, REG_Q_ENUM_VALUE
*q_q
, prs_struct
*ps
, int depth
)
1320 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_val");
1326 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1329 if(!prs_uint32("val_index", ps
, depth
, &q_q
->val_index
))
1332 if(!smb_io_unihdr ("hdr_name", &q_q
->hdr_name
, ps
, depth
))
1334 if(!smb_io_unistr2("uni_name", &q_q
->uni_name
, q_q
->hdr_name
.buffer
, ps
, depth
))
1339 if(!prs_uint32("ptr_type", ps
, depth
, &q_q
->ptr_type
))
1342 if (q_q
->ptr_type
!= 0) {
1343 if(!prs_uint32("type", ps
, depth
, &q_q
->type
))
1347 if(!prs_uint32("ptr_value", ps
, depth
, &q_q
->ptr_value
))
1349 if(!smb_io_buffer2("buf_value", &q_q
->buf_value
, q_q
->ptr_value
, ps
, depth
))
1354 if(!prs_uint32("ptr1", ps
, depth
, &q_q
->ptr1
))
1356 if (q_q
->ptr1
!= 0) {
1357 if(!prs_uint32("len_value1", ps
, depth
, &q_q
->len_value1
))
1360 if(!prs_uint32("ptr2", ps
, depth
, &q_q
->ptr2
))
1362 if (q_q
->ptr2
!= 0) {
1363 if(!prs_uint32("len_value2", ps
, depth
, &q_q
->len_value2
))
1370 /*******************************************************************
1371 reads or writes a structure.
1372 ********************************************************************/
1374 BOOL
reg_io_r_enum_val(char *desc
, REG_R_ENUM_VALUE
*r_q
, prs_struct
*ps
, int depth
)
1379 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_val");
1385 if(!smb_io_unihdr ("hdr_name", &r_q
->hdr_name
, ps
, depth
))
1387 if(!smb_io_unistr2("uni_name", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
1392 if(!prs_uint32("ptr_type", ps
, depth
, &r_q
->ptr_type
))
1395 if (r_q
->ptr_type
!= 0) {
1396 if(!prs_uint32("type", ps
, depth
, &r_q
->type
))
1400 if(!prs_uint32("ptr_value", ps
, depth
, &r_q
->ptr_value
))
1402 if(!smb_io_buffer2("buf_value", &r_q
->buf_value
, r_q
->ptr_value
, ps
, depth
))
1407 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
1409 if (r_q
->ptr1
!= 0) {
1410 if(!prs_uint32("len_value1", ps
, depth
, &r_q
->len_value1
))
1414 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
1416 if (r_q
->ptr2
!= 0) {
1417 if(!prs_uint32("len_value2", ps
, depth
, &r_q
->len_value2
))
1421 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1427 /*******************************************************************
1429 ********************************************************************/
1431 void init_reg_q_create_val(REG_Q_CREATE_VALUE
*q_i
, POLICY_HND
*pol
,
1432 char *val_name
, uint32 type
,
1435 int val_len
= strlen(val_name
) + 1;
1439 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1441 init_uni_hdr(&q_i
->hdr_name
, val_len
);
1442 init_unistr2(&q_i
->uni_name
, val_name
, val_len
);
1445 q_i
->buf_value
= val
;
1448 /*******************************************************************
1449 reads or writes a structure.
1450 ********************************************************************/
1452 BOOL
reg_io_q_create_val(char *desc
, REG_Q_CREATE_VALUE
*q_q
, prs_struct
*ps
, int depth
)
1457 prs_debug(ps
, depth
, desc
, "reg_io_q_create_val");
1463 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1466 if(!smb_io_unihdr ("hdr_name", &q_q
->hdr_name
, ps
, depth
))
1468 if(!smb_io_unistr2("uni_name", &q_q
->uni_name
, q_q
->hdr_name
.buffer
, ps
, depth
))
1473 if(!prs_uint32("type", ps
, depth
, &q_q
->type
))
1475 if(!smb_io_buffer3("buf_value", q_q
->buf_value
, ps
, depth
))
1483 /*******************************************************************
1484 reads or writes a structure.
1485 ********************************************************************/
1487 BOOL
reg_io_r_create_val(char *desc
, REG_R_CREATE_VALUE
*r_q
, prs_struct
*ps
, int depth
)
1492 prs_debug(ps
, depth
, desc
, "reg_io_r_create_val");
1498 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1504 /*******************************************************************
1506 ********************************************************************/
1508 void init_reg_q_enum_key(REG_Q_ENUM_KEY
*q_i
, POLICY_HND
*pol
, uint32 key_idx
)
1510 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1512 q_i
->key_index
= key_idx
;
1513 q_i
->key_name_len
= 0;
1514 q_i
->unknown_1
= 0x0414;
1517 q_i
->unknown_2
= 0x0000020A;
1518 memset(q_i
->pad1
, 0, sizeof(q_i
->pad1
));
1521 memset(q_i
->pad2
, 0, sizeof(q_i
->pad2
));
1524 unix_to_nt_time(&q_i
->time
, 0); /* current time? */
1527 /*******************************************************************
1528 makes a reply structure.
1529 ********************************************************************/
1531 void init_reg_r_enum_key(REG_R_ENUM_KEY
*r_u
, char *subkey
, uint32 unknown_1
,
1537 r_u
->unknown_1
= unknown_1
;
1538 r_u
->unknown_2
= unknown_2
;
1539 r_u
->unknown_3
= 0x0;
1541 r_u
->key_name_len
= (strlen(subkey
)+1) * 2;
1542 if (r_u
->key_name_len
)
1544 init_unistr3( &r_u
->key_name
, subkey
);
1550 /*******************************************************************
1551 reads or writes a structure.
1552 ********************************************************************/
1554 BOOL
reg_io_q_enum_key(char *desc
, REG_Q_ENUM_KEY
*q_q
, prs_struct
*ps
, int depth
)
1559 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_key");
1565 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1568 if(!prs_uint32("key_index", ps
, depth
, &q_q
->key_index
))
1570 if(!prs_uint16("key_name_len", ps
, depth
, &q_q
->key_name_len
))
1572 if(!prs_uint16("unknown_1", ps
, depth
, &q_q
->unknown_1
))
1575 if(!prs_uint32("ptr1", ps
, depth
, &q_q
->ptr1
))
1578 if (q_q
->ptr1
!= 0) {
1579 if(!prs_uint32("unknown_2", ps
, depth
, &q_q
->unknown_2
))
1581 if(!prs_uint8s(False
, "pad1", ps
, depth
, q_q
->pad1
, sizeof(q_q
->pad1
)))
1585 if(!prs_uint32("ptr2", ps
, depth
, &q_q
->ptr2
))
1588 if (q_q
->ptr2
!= 0) {
1589 if(!prs_uint8s(False
, "pad2", ps
, depth
, q_q
->pad2
, sizeof(q_q
->pad2
)))
1593 if(!prs_uint32("ptr3", ps
, depth
, &q_q
->ptr3
))
1596 if (q_q
->ptr3
!= 0) {
1597 if(!smb_io_time("", &q_q
->time
, ps
, depth
))
1604 /*******************************************************************
1605 reads or writes a structure.
1606 ********************************************************************/
1608 BOOL
reg_io_r_enum_key(char *desc
, REG_R_ENUM_KEY
*r_q
, prs_struct
*ps
, int depth
)
1613 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_key");
1619 if(!prs_uint16("key_name_len", ps
, depth
, &r_q
->key_name_len
))
1621 if(!prs_uint16("unknown_1", ps
, depth
, &r_q
->unknown_1
))
1624 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
1627 if (r_q
->ptr1
!= 0) {
1628 if(!prs_uint32("unknown_2", ps
, depth
, &r_q
->unknown_2
))
1630 if(!prs_uint32("unknown_3", ps
, depth
, &r_q
->unknown_3
))
1632 if(!smb_io_unistr3("key_name", &r_q
->key_name
, ps
, depth
))
1638 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
1641 if (r_q
->ptr2
!= 0) {
1642 if(!prs_uint8s(False
, "pad2", ps
, depth
, r_q
->pad2
, sizeof(r_q
->pad2
)))
1646 if(!prs_uint32("ptr3", ps
, depth
, &r_q
->ptr3
))
1649 if (r_q
->ptr3
!= 0) {
1650 if(!smb_io_time("", &r_q
->time
, ps
, depth
))
1654 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1660 /*******************************************************************
1662 ********************************************************************/
1664 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY
*r_q
, POLICY_HND
*pol
,
1665 char *key_name
, uint32 access_desired
)
1667 int len_name
= strlen(key_name
)+1;
1669 memcpy(&r_q
->pol
, pol
, sizeof(r_q
->pol
));
1671 init_uni_hdr(&r_q
->hdr_name
, len_name
);
1672 init_unistr2(&r_q
->uni_name
, key_name
, len_name
);
1674 r_q
->unknown_0
= 0x00000000;
1675 r_q
->access_desired
= access_desired
;
1678 /*******************************************************************
1679 reads or writes a structure.
1680 ********************************************************************/
1682 BOOL
reg_io_q_open_entry(char *desc
, REG_Q_OPEN_ENTRY
*r_q
, prs_struct
*ps
, int depth
)
1687 prs_debug(ps
, depth
, desc
, "reg_io_q_entry");
1693 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
1695 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
1697 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
1703 if(!prs_uint32("unknown_0 ", ps
, depth
, &r_q
->unknown_0
))
1705 if(!prs_uint32("asccess_desired ", ps
, depth
, &r_q
->access_desired
))
1711 /*******************************************************************
1713 ********************************************************************/
1715 void init_reg_r_open_entry(REG_R_OPEN_ENTRY
*r_r
,
1716 POLICY_HND
*pol
, NTSTATUS status
)
1718 memcpy(&r_r
->pol
, pol
, sizeof(r_r
->pol
));
1719 r_r
->status
= status
;
1722 /*******************************************************************
1723 reads or writes a structure.
1724 ********************************************************************/
1726 BOOL
reg_io_r_open_entry(char *desc
, REG_R_OPEN_ENTRY
*r_r
, prs_struct
*ps
, int depth
)
1731 prs_debug(ps
, depth
, desc
, "reg_io_r_open_entry");
1737 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
1740 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
1746 /*******************************************************************
1748 ********************************************************************/
1749 void init_reg_q_shutdown(REG_Q_SHUTDOWN
* q_s
,
1750 const char *msg
, uint32 timeout
, uint16 flags
)
1753 msg_len
= strlen(msg
);
1759 init_uni_hdr(&(q_s
->hdr_msg
), msg_len
);
1760 init_unistr2(&(q_s
->uni_msg
), msg
, msg_len
);
1762 q_s
->timeout
= timeout
;
1767 /*******************************************************************
1768 reads or writes a structure.
1769 ********************************************************************/
1770 BOOL
reg_io_q_shutdown(char *desc
, REG_Q_SHUTDOWN
* q_s
, prs_struct
*ps
,
1776 prs_debug(ps
, depth
, desc
, "reg_io_q_shutdown");
1782 if (!prs_uint32("ptr_0", ps
, depth
, &(q_s
->ptr_0
)))
1784 if (!prs_uint32("ptr_1", ps
, depth
, &(q_s
->ptr_1
)))
1786 if (!prs_uint32("ptr_2", ps
, depth
, &(q_s
->ptr_2
)))
1789 if (!smb_io_unihdr("hdr_msg", &(q_s
->hdr_msg
), ps
, depth
))
1791 if (!smb_io_unistr2("uni_msg", &(q_s
->uni_msg
), q_s
->hdr_msg
.buffer
, ps
, depth
))
1796 if (!prs_uint32("timeout", ps
, depth
, &(q_s
->timeout
)))
1798 if (!prs_uint16("flags ", ps
, depth
, &(q_s
->flags
)))
1804 /*******************************************************************
1805 reads or writes a structure.
1806 ********************************************************************/
1807 BOOL
reg_io_r_shutdown(char *desc
, REG_R_SHUTDOWN
* r_s
, prs_struct
*ps
,
1813 prs_debug(ps
, depth
, desc
, "reg_io_r_shutdown");
1819 if(!prs_ntstatus("status", ps
, depth
, &r_s
->status
))
1825 /*******************************************************************
1827 ********************************************************************/
1828 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN
* q_s
)
1831 q_s
->ptr_server
= 0;
1835 /*******************************************************************
1836 reads or writes a structure.
1837 ********************************************************************/
1838 BOOL
reg_io_q_abort_shutdown(char *desc
, REG_Q_ABORT_SHUTDOWN
* q_s
,
1839 prs_struct
*ps
, int depth
)
1844 prs_debug(ps
, depth
, desc
, "reg_io_q_abort_shutdown");
1850 if (!prs_uint32("ptr_server", ps
, depth
, &(q_s
->ptr_server
)))
1852 if (q_s
->ptr_server
!= 0)
1853 if (!prs_uint16("server", ps
, depth
, &(q_s
->server
)))
1859 /*******************************************************************
1860 reads or writes a structure.
1861 ********************************************************************/
1862 BOOL
reg_io_r_abort_shutdown(char *desc
, REG_R_ABORT_SHUTDOWN
* r_s
,
1863 prs_struct
*ps
, int depth
)
1868 prs_debug(ps
, depth
, desc
, "reg_io_r_abort_shutdown");
1874 if (!prs_ntstatus("status", ps
, depth
, &r_s
->status
))