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.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #define DBGC_CLASS DBGC_RPC_PARSE
30 /*******************************************************************
32 ********************************************************************/
34 void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR
*q_o
,
35 uint16 unknown_0
, uint32 level
)
38 q_o
->unknown_0
= unknown_0
;
39 q_o
->unknown_1
= 0x0; /* random - changes */
43 /*******************************************************************
44 reads or writes a structure.
45 ********************************************************************/
47 BOOL
reg_io_q_open_hkcr(char *desc
, REG_Q_OPEN_HKCR
*r_q
, prs_struct
*ps
, int depth
)
52 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hkcr");
58 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
62 if(!prs_uint16("unknown_0", ps
, depth
, &r_q
->unknown_0
))
64 if(!prs_uint16("unknown_1", ps
, depth
, &r_q
->unknown_1
))
66 if(!prs_uint32("level ", ps
, depth
, &r_q
->level
))
74 /*******************************************************************
75 reads or writes a structure.
76 ********************************************************************/
78 BOOL
reg_io_r_open_hkcr(char *desc
, REG_R_OPEN_HKCR
*r_r
, prs_struct
*ps
, int depth
)
83 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hkcr");
89 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
92 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
98 /*******************************************************************
100 ********************************************************************/
102 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM
* q_o
,
103 uint16 unknown_0
, uint32 access_mask
)
106 q_o
->unknown_0
= unknown_0
;
107 q_o
->unknown_1
= 0x0; /* random - changes */
108 q_o
->access_mask
= access_mask
;
112 /*******************************************************************
113 reads or writes a structure.
114 ********************************************************************/
115 BOOL
reg_io_q_open_hklm(char *desc
, REG_Q_OPEN_HKLM
* r_q
, prs_struct
*ps
,
121 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hklm");
127 if (!prs_uint32("ptr ", ps
, depth
, &(r_q
->ptr
)))
131 if (!prs_uint16("unknown_0", ps
, depth
, &(r_q
->unknown_0
)))
133 if (!prs_uint16("unknown_1", ps
, depth
, &(r_q
->unknown_1
)))
135 if (!prs_uint32("access_mask", ps
, depth
, &(r_q
->access_mask
)))
143 /*******************************************************************
144 reads or writes a structure.
145 ********************************************************************/
146 BOOL
reg_io_r_open_hklm(char *desc
, REG_R_OPEN_HKLM
* r_r
, prs_struct
*ps
,
152 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hklm");
158 if (!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
161 if (!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
168 /*******************************************************************
170 ********************************************************************/
172 void init_reg_q_flush_key(REG_Q_FLUSH_KEY
*q_u
, POLICY_HND
*pol
)
174 memcpy(&q_u
->pol
, pol
, sizeof(q_u
->pol
));
177 /*******************************************************************
178 reads or writes a structure.
179 ********************************************************************/
181 BOOL
reg_io_q_flush_key(char *desc
, REG_Q_FLUSH_KEY
*r_q
, prs_struct
*ps
, int depth
)
186 prs_debug(ps
, depth
, desc
, "reg_io_q_flush_key");
192 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
198 /*******************************************************************
199 reads or writes a structure.
200 ********************************************************************/
202 BOOL
reg_io_r_flush_key(char *desc
, REG_R_FLUSH_KEY
*r_r
, prs_struct
*ps
, int depth
)
207 prs_debug(ps
, depth
, desc
, "reg_io_r_flush_key");
213 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
219 /*******************************************************************
220 reads or writes SEC_DESC_BUF and SEC_DATA structures.
221 ********************************************************************/
223 static BOOL
reg_io_hdrbuf_sec(uint32 ptr
, uint32
*ptr3
, BUFHDR
*hdr_sec
, SEC_DESC_BUF
*data
, prs_struct
*ps
, int depth
)
228 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec
, ps
, depth
, &hdr_offset
))
231 old_offset
= prs_offset(ps
);
234 if(!prs_uint32("ptr3", ps
, depth
, ptr3
))
238 if (ptr3
== NULL
|| *ptr3
!= 0) {
239 if(!sec_io_desc_buf("data ", &data
, ps
, depth
)) /* JRA - this line is probably wrong... */
243 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec
, ps
, depth
, hdr_offset
,
244 data
->max_len
, data
->len
))
246 if(!prs_set_offset(ps
, old_offset
+ data
->len
+ sizeof(uint32
) * ((ptr3
!= NULL
) ? 5 : 3)))
256 /*******************************************************************
258 ********************************************************************/
260 void init_reg_q_create_key(REG_Q_CREATE_KEY
*q_c
, POLICY_HND
*hnd
,
261 char *name
, char *class, SEC_ACCESS
*sam_access
,
262 SEC_DESC_BUF
*sec_buf
)
264 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
265 int len_class
= class != NULL
? strlen(class) + 1: 0;
269 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
271 init_uni_hdr(&q_c
->hdr_name
, len_name
);
272 init_unistr2(&q_c
->uni_name
, name
, len_name
);
274 init_uni_hdr(&q_c
->hdr_class
, len_class
);
275 init_unistr2(&q_c
->uni_class
, class, len_class
);
277 q_c
->reserved
= 0x00000000;
278 memcpy(&q_c
->sam_access
, sam_access
, sizeof(q_c
->sam_access
));
281 q_c
->sec_info
= DACL_SECURITY_INFORMATION
| SACL_SECURITY_INFORMATION
;
285 init_buf_hdr(&q_c
->hdr_sec
, sec_buf
->len
, sec_buf
->len
);
287 q_c
->unknown_2
= 0x00000000;
290 /*******************************************************************
291 reads or writes a structure.
292 ********************************************************************/
294 BOOL
reg_io_q_create_key(char *desc
, REG_Q_CREATE_KEY
*r_q
, prs_struct
*ps
, int depth
)
299 prs_debug(ps
, depth
, desc
, "reg_io_q_create_key");
305 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
308 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
310 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
315 if(!smb_io_unihdr ("", &r_q
->hdr_class
, ps
, depth
))
317 if(!smb_io_unistr2("", &r_q
->uni_class
, r_q
->hdr_class
.buffer
, ps
, depth
))
322 if(!prs_uint32("reserved", ps
, depth
, &r_q
->reserved
))
324 if(!sec_io_access("sam_access", &r_q
->sam_access
, ps
, depth
))
327 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
330 if (r_q
->ptr1
!= 0) {
331 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
335 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
337 if(!reg_io_hdrbuf_sec(r_q
->ptr2
, &r_q
->ptr3
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
340 if(!prs_uint32("unknown_2", ps
, depth
, &r_q
->unknown_2
))
346 /*******************************************************************
347 reads or writes a structure.
348 ********************************************************************/
350 BOOL
reg_io_r_create_key(char *desc
, REG_R_CREATE_KEY
*r_r
, prs_struct
*ps
, int depth
)
355 prs_debug(ps
, depth
, desc
, "reg_io_r_create_key");
361 if(!smb_io_pol_hnd("", &r_r
->key_pol
, ps
, depth
))
363 if(!prs_uint32("unknown", ps
, depth
, &r_r
->unknown
))
366 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
373 /*******************************************************************
375 ********************************************************************/
377 void init_reg_q_delete_val(REG_Q_DELETE_VALUE
*q_c
, POLICY_HND
*hnd
,
380 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
383 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
385 init_uni_hdr(&q_c
->hdr_name
, len_name
);
386 init_unistr2(&q_c
->uni_name
, name
, len_name
);
389 /*******************************************************************
390 reads or writes a structure.
391 ********************************************************************/
393 BOOL
reg_io_q_delete_val(char *desc
, REG_Q_DELETE_VALUE
*r_q
, prs_struct
*ps
, int depth
)
398 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_val");
404 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
407 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
409 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
418 /*******************************************************************
419 reads or writes a structure.
420 ********************************************************************/
422 BOOL
reg_io_r_delete_val(char *desc
, REG_R_DELETE_VALUE
*r_r
, prs_struct
*ps
, int depth
)
427 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_val");
433 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
439 /*******************************************************************
441 ********************************************************************/
443 void init_reg_q_delete_key(REG_Q_DELETE_KEY
*q_c
, POLICY_HND
*hnd
,
446 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
449 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
451 init_uni_hdr(&q_c
->hdr_name
, len_name
);
452 init_unistr2(&q_c
->uni_name
, name
, len_name
);
455 /*******************************************************************
456 reads or writes a structure.
457 ********************************************************************/
459 BOOL
reg_io_q_delete_key(char *desc
, REG_Q_DELETE_KEY
*r_q
, prs_struct
*ps
, int depth
)
464 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_key");
470 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
473 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
475 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
483 /*******************************************************************
484 reads or writes a structure.
485 ********************************************************************/
487 BOOL
reg_io_r_delete_key(char *desc
, REG_R_DELETE_KEY
*r_r
, prs_struct
*ps
, int depth
)
492 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_key");
498 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
504 /*******************************************************************
506 ********************************************************************/
508 void init_reg_q_query_key(REG_Q_QUERY_KEY
*q_o
, POLICY_HND
*hnd
,
509 uint32 max_class_len
)
513 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
514 init_uni_hdr(&q_o
->hdr_class
, max_class_len
);
515 q_o
->uni_class
.uni_max_len
= max_class_len
;
518 /*******************************************************************
519 reads or writes a structure.
520 ********************************************************************/
522 BOOL
reg_io_q_query_key(char *desc
, REG_Q_QUERY_KEY
*r_q
, prs_struct
*ps
, int depth
)
527 prs_debug(ps
, depth
, desc
, "reg_io_q_query_key");
533 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
535 if(!smb_io_unihdr ("", &r_q
->hdr_class
, ps
, depth
))
537 if(!smb_io_unistr2("", &r_q
->uni_class
, r_q
->hdr_class
.buffer
, ps
, depth
))
547 /*******************************************************************
548 reads or writes a structure.
549 ********************************************************************/
551 BOOL
reg_io_r_query_key(char *desc
, REG_R_QUERY_KEY
*r_r
, prs_struct
*ps
, int depth
)
556 prs_debug(ps
, depth
, desc
, "reg_io_r_query_key");
562 if(!smb_io_unihdr ("", &r_r
->hdr_class
, ps
, depth
))
564 if(!smb_io_unistr2("", &r_r
->uni_class
, r_r
->hdr_class
.buffer
, ps
, depth
))
570 if(!prs_uint32("num_subkeys ", ps
, depth
, &r_r
->num_subkeys
))
572 if(!prs_uint32("max_subkeylen ", ps
, depth
, &r_r
->max_subkeylen
))
574 if(!prs_uint32("reserved ", ps
, depth
, &r_r
->reserved
))
576 if(!prs_uint32("num_values ", ps
, depth
, &r_r
->num_values
))
578 if(!prs_uint32("max_valnamelen", ps
, depth
, &r_r
->max_valnamelen
))
580 if(!prs_uint32("max_valbufsize", ps
, depth
, &r_r
->max_valbufsize
))
582 if(!prs_uint32("sec_desc ", ps
, depth
, &r_r
->sec_desc
))
584 if(!smb_io_time("mod_time ", &r_r
->mod_time
, ps
, depth
))
587 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
593 /*******************************************************************
595 ********************************************************************/
597 void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A
*q_o
, POLICY_HND
*hnd
)
599 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
602 /*******************************************************************
603 reads or writes a structure.
604 ********************************************************************/
606 BOOL
reg_io_q_unknown_1a(char *desc
, REG_Q_UNKNOWN_1A
*r_q
, prs_struct
*ps
, int depth
)
611 prs_debug(ps
, depth
, desc
, "reg_io_q_unknown_1a");
617 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
623 /*******************************************************************
624 reads or writes a structure.
625 ********************************************************************/
627 BOOL
reg_io_r_unknown_1a(char *desc
, REG_R_UNKNOWN_1A
*r_r
, prs_struct
*ps
, int depth
)
632 prs_debug(ps
, depth
, desc
, "reg_io_r_unknown_1a");
638 if(!prs_uint32("unknown", ps
, depth
, &r_r
->unknown
))
640 if(!prs_ntstatus("status" , ps
, depth
, &r_r
->status
))
646 /*******************************************************************
648 ********************************************************************/
650 void init_reg_q_open_hku(REG_Q_OPEN_HKU
*q_o
,
651 uint16 unknown_0
, uint32 access_mask
)
654 q_o
->unknown_0
= unknown_0
;
655 q_o
->unknown_1
= 0x0; /* random - changes */
656 q_o
->access_mask
= access_mask
;
659 /*******************************************************************
660 reads or writes a structure.
661 ********************************************************************/
663 BOOL
reg_io_q_open_hku(char *desc
, REG_Q_OPEN_HKU
*r_q
, prs_struct
*ps
, int depth
)
668 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hku");
674 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
677 if(!prs_uint16("unknown_0 ", ps
, depth
, &r_q
->unknown_0
))
679 if(!prs_uint16("unknown_1 ", ps
, depth
, &r_q
->unknown_1
))
681 if(!prs_uint32("access_mask ", ps
, depth
, &r_q
->access_mask
))
688 /*******************************************************************
689 reads or writes a structure.
690 ********************************************************************/
692 BOOL
reg_io_r_open_hku(char *desc
, REG_R_OPEN_HKU
*r_r
, prs_struct
*ps
, int depth
)
697 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hku");
703 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
706 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
712 /*******************************************************************
713 Inits an REG_Q_CLOSE structure.
714 ********************************************************************/
716 void init_reg_q_close(REG_Q_CLOSE
*q_c
, POLICY_HND
*hnd
)
718 DEBUG(5,("init_reg_q_close\n"));
720 memcpy(&q_c
->pol
, hnd
, sizeof(q_c
->pol
));
723 /*******************************************************************
724 reads or writes a structure.
725 ********************************************************************/
727 BOOL
reg_io_q_close(char *desc
, REG_Q_CLOSE
*q_u
, prs_struct
*ps
, int depth
)
732 prs_debug(ps
, depth
, desc
, "reg_io_q_close");
738 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
746 /*******************************************************************
747 reads or writes a structure.
748 ********************************************************************/
750 BOOL
reg_io_r_close(char *desc
, REG_R_CLOSE
*r_u
, prs_struct
*ps
, int depth
)
755 prs_debug(ps
, depth
, desc
, "reg_io_r_close");
761 if(!smb_io_pol_hnd("", &r_u
->pol
, ps
, depth
))
766 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
772 /*******************************************************************
774 ********************************************************************/
776 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC
*q_i
, POLICY_HND
*pol
, SEC_DESC_BUF
*sec_desc_buf
)
778 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
780 q_i
->sec_info
= DACL_SECURITY_INFORMATION
;
783 init_buf_hdr(&q_i
->hdr_sec
, sec_desc_buf
->len
, sec_desc_buf
->len
);
784 q_i
->data
= sec_desc_buf
;
787 /*******************************************************************
788 reads or writes a structure.
789 ********************************************************************/
791 BOOL
reg_io_q_set_key_sec(char *desc
, REG_Q_SET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
796 prs_debug(ps
, depth
, desc
, "reg_io_q_set_key_sec");
802 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
805 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
807 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
810 if(!reg_io_hdrbuf_sec(r_q
->ptr
, NULL
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
816 /*******************************************************************
817 reads or writes a structure.
818 ********************************************************************/
820 BOOL
reg_io_r_set_key_sec(char *desc
, REG_R_SET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
825 prs_debug(ps
, depth
, desc
, "reg_io_r_set_key_sec");
831 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
838 /*******************************************************************
840 ********************************************************************/
842 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC
*q_i
, POLICY_HND
*pol
,
843 uint32 sec_buf_size
, SEC_DESC_BUF
*psdb
)
845 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
847 q_i
->sec_info
= OWNER_SECURITY_INFORMATION
|
848 GROUP_SECURITY_INFORMATION
|
849 DACL_SECURITY_INFORMATION
;
851 q_i
->ptr
= psdb
!= NULL
? 1 : 0;
854 init_buf_hdr(&q_i
->hdr_sec
, sec_buf_size
, 0);
857 /*******************************************************************
858 reads or writes a structure.
859 ********************************************************************/
861 BOOL
reg_io_q_get_key_sec(char *desc
, REG_Q_GET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
866 prs_debug(ps
, depth
, desc
, "reg_io_q_get_key_sec");
872 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
875 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
877 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
880 if(!reg_io_hdrbuf_sec(r_q
->ptr
, NULL
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
887 /*******************************************************************
889 ********************************************************************/
890 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC
*r_i
, POLICY_HND
*pol
,
891 uint32 buf_len
, uint8
*buf
,
895 init_buf_hdr(&r_i
->hdr_sec
, buf_len
, buf_len
);
896 init_sec_desc_buf(r_i
->data
, buf_len
, 1);
898 r_i
->status
= status
; /* 0x0000 0000 or 0x0000 007a */
902 /*******************************************************************
903 reads or writes a structure.
904 ********************************************************************/
906 BOOL
reg_io_r_get_key_sec(char *desc
, REG_R_GET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
911 prs_debug(ps
, depth
, desc
, "reg_io_r_get_key_sec");
917 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
921 if(!smb_io_hdrbuf("", &r_q
->hdr_sec
, ps
, depth
))
923 if(!sec_io_desc_buf("", &r_q
->data
, ps
, depth
))
929 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
935 /*******************************************************************
937 ********************************************************************/
939 BOOL
init_reg_q_info(REG_Q_INFO
*q_i
, POLICY_HND
*pol
, char* val_name
)
941 int len_type
= val_name
!= NULL
? strlen(val_name
) + 1 : 0;
948 init_uni_hdr(&(q_i
->hdr_type
), len_type
);
949 init_unistr2(&(q_i
->uni_type
), val_name
, len_type
);
951 q_i
->ptr_reserved
= 1;
954 q_i
->ptr_bufsize
= 1;
962 q_i
->ptr_buflen2
= 1;
968 /*******************************************************************
969 reads or writes a structure.
970 ********************************************************************/
972 BOOL
reg_io_q_info(char *desc
, REG_Q_INFO
*r_q
, prs_struct
*ps
, int depth
)
977 prs_debug(ps
, depth
, desc
, "reg_io_q_info");
983 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
985 if(!smb_io_unihdr ("", &r_q
->hdr_type
, ps
, depth
))
987 if(!smb_io_unistr2("", &r_q
->uni_type
, r_q
->hdr_type
.buffer
, ps
, depth
))
993 if(!prs_uint32("ptr_reserved", ps
, depth
, &(r_q
->ptr_reserved
)))
996 if(!prs_uint32("ptr_buf", ps
, depth
, &(r_q
->ptr_buf
)))
1000 if(!prs_uint32("ptr_bufsize", ps
, depth
, &(r_q
->ptr_bufsize
)))
1002 if(!prs_uint32("bufsize", ps
, depth
, &(r_q
->bufsize
)))
1004 if(!prs_uint32("buf_unk", ps
, depth
, &(r_q
->buf_unk
)))
1008 if(!prs_uint32("unk1", ps
, depth
, &(r_q
->unk1
)))
1011 if(!prs_uint32("ptr_buflen", ps
, depth
, &(r_q
->ptr_buflen
)))
1014 if (r_q
->ptr_buflen
) {
1015 if(!prs_uint32("buflen", ps
, depth
, &(r_q
->buflen
)))
1017 if(!prs_uint32("ptr_buflen2", ps
, depth
, &(r_q
->ptr_buflen2
)))
1019 if(!prs_uint32("buflen2", ps
, depth
, &(r_q
->buflen2
)))
1026 /*******************************************************************
1028 ********************************************************************/
1030 BOOL
init_reg_r_info(uint32 include_keyval
, REG_R_INFO
*r_r
,
1031 BUFFER2
* buf
, uint32 type
, NTSTATUS status
)
1040 /* if include_keyval is not set, don't send the key value, just
1041 the buflen data. probably used by NT5 to allocate buffer space - SK */
1042 r_r
->ptr_uni_val
= include_keyval
? 1:0;
1045 r_r
->ptr_max_len
= 1;
1046 r_r
->buf_max_len
= r_r
->uni_val
->buf_max_len
;
1049 r_r
->buf_len
= r_r
->uni_val
->buf_len
;
1051 r_r
->status
= status
;
1057 /*******************************************************************
1058 reads or writes a structure.
1059 ********************************************************************/
1061 BOOL
reg_io_r_info(char *desc
, REG_R_INFO
*r_r
, prs_struct
*ps
, int depth
)
1066 prs_debug(ps
, depth
, desc
, "reg_io_r_info");
1072 if(!prs_uint32("ptr_type", ps
, depth
, &(r_r
->ptr_type
)))
1075 if (r_r
->ptr_type
!= 0) {
1076 if(!prs_uint32("type", ps
, depth
, &r_r
->type
))
1080 if(!prs_uint32("ptr_uni_val", ps
, depth
, &(r_r
->ptr_uni_val
)))
1083 if(r_r
->ptr_uni_val
!= 0) {
1084 if(!smb_io_buffer2("uni_val", r_r
->uni_val
, r_r
->ptr_uni_val
, ps
, depth
))
1091 if(!prs_uint32("ptr_max_len", ps
, depth
, &(r_r
->ptr_max_len
)))
1094 if (r_r
->ptr_max_len
!= 0) {
1095 if(!prs_uint32("buf_max_len", ps
, depth
, &(r_r
->buf_max_len
)))
1099 if(!prs_uint32("ptr_len", ps
, depth
, &(r_r
->ptr_len
)))
1101 if (r_r
->ptr_len
!= 0) {
1102 if(!prs_uint32("buf_len", ps
, depth
, &(r_r
->buf_len
)))
1106 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
1112 /*******************************************************************
1114 ********************************************************************/
1116 void init_reg_q_enum_val(REG_Q_ENUM_VALUE
*q_i
, POLICY_HND
*pol
,
1117 uint32 val_idx
, uint32 max_val_len
,
1122 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1124 q_i
->val_index
= val_idx
;
1125 init_uni_hdr(&q_i
->hdr_name
, max_val_len
);
1126 q_i
->uni_name
.uni_max_len
= max_val_len
;
1132 q_i
->buf_value
.buf_max_len
= max_buf_len
;
1135 q_i
->len_value1
= max_buf_len
;
1138 q_i
->len_value2
= 0;
1141 /*******************************************************************
1142 reads or writes a structure.
1143 ********************************************************************/
1145 BOOL
reg_io_q_enum_val(char *desc
, REG_Q_ENUM_VALUE
*q_q
, prs_struct
*ps
, int depth
)
1150 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_val");
1156 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1159 if(!prs_uint32("val_index", ps
, depth
, &q_q
->val_index
))
1161 if(!smb_io_unihdr ("hdr_name", &q_q
->hdr_name
, ps
, depth
))
1163 if(!smb_io_unistr2("uni_name", &q_q
->uni_name
, q_q
->hdr_name
.buffer
, ps
, depth
))
1168 if(!prs_uint32("ptr_type", ps
, depth
, &q_q
->ptr_type
))
1171 if (q_q
->ptr_type
!= 0) {
1172 if(!prs_uint32("type", ps
, depth
, &q_q
->type
))
1176 if(!prs_uint32("ptr_value", ps
, depth
, &q_q
->ptr_value
))
1178 if(!smb_io_buffer2("buf_value", &q_q
->buf_value
, q_q
->ptr_value
, ps
, depth
))
1183 if(!prs_uint32("ptr1", ps
, depth
, &q_q
->ptr1
))
1185 if (q_q
->ptr1
!= 0) {
1186 if(!prs_uint32("len_value1", ps
, depth
, &q_q
->len_value1
))
1189 if(!prs_uint32("ptr2", ps
, depth
, &q_q
->ptr2
))
1191 if (q_q
->ptr2
!= 0) {
1192 if(!prs_uint32("len_value2", ps
, depth
, &q_q
->len_value2
))
1199 /*******************************************************************
1200 reads or writes a structure.
1201 ********************************************************************/
1203 BOOL
reg_io_r_enum_val(char *desc
, REG_R_ENUM_VALUE
*r_q
, prs_struct
*ps
, int depth
)
1208 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_val");
1214 if(!smb_io_unihdr ("hdr_name", &r_q
->hdr_name
, ps
, depth
))
1216 if(!smb_io_unistr2("uni_name", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
1221 if(!prs_uint32("ptr_type", ps
, depth
, &r_q
->ptr_type
))
1224 if (r_q
->ptr_type
!= 0) {
1225 if(!prs_uint32("type", ps
, depth
, &r_q
->type
))
1229 if(!prs_uint32("ptr_value", ps
, depth
, &r_q
->ptr_value
))
1231 if(!smb_io_buffer2("buf_value", r_q
->buf_value
, r_q
->ptr_value
, ps
, depth
))
1236 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
1238 if (r_q
->ptr1
!= 0) {
1239 if(!prs_uint32("len_value1", ps
, depth
, &r_q
->len_value1
))
1243 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
1245 if (r_q
->ptr2
!= 0) {
1246 if(!prs_uint32("len_value2", ps
, depth
, &r_q
->len_value2
))
1250 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1256 /*******************************************************************
1258 ********************************************************************/
1260 void init_reg_q_create_val(REG_Q_CREATE_VALUE
*q_i
, POLICY_HND
*pol
,
1261 char *val_name
, uint32 type
,
1264 int val_len
= strlen(val_name
) + 1;
1268 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1270 init_uni_hdr(&q_i
->hdr_name
, val_len
);
1271 init_unistr2(&q_i
->uni_name
, val_name
, val_len
);
1274 q_i
->buf_value
= val
;
1277 /*******************************************************************
1278 reads or writes a structure.
1279 ********************************************************************/
1281 BOOL
reg_io_q_create_val(char *desc
, REG_Q_CREATE_VALUE
*q_q
, prs_struct
*ps
, int depth
)
1286 prs_debug(ps
, depth
, desc
, "reg_io_q_create_val");
1292 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1295 if(!smb_io_unihdr ("hdr_name", &q_q
->hdr_name
, ps
, depth
))
1297 if(!smb_io_unistr2("uni_name", &q_q
->uni_name
, q_q
->hdr_name
.buffer
, ps
, depth
))
1302 if(!prs_uint32("type", ps
, depth
, &q_q
->type
))
1304 if(!smb_io_buffer3("buf_value", q_q
->buf_value
, ps
, depth
))
1312 /*******************************************************************
1313 reads or writes a structure.
1314 ********************************************************************/
1316 BOOL
reg_io_r_create_val(char *desc
, REG_R_CREATE_VALUE
*r_q
, prs_struct
*ps
, int depth
)
1321 prs_debug(ps
, depth
, desc
, "reg_io_r_create_val");
1327 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1333 /*******************************************************************
1335 ********************************************************************/
1337 void init_reg_q_enum_key(REG_Q_ENUM_KEY
*q_i
, POLICY_HND
*pol
, uint32 key_idx
)
1339 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1341 q_i
->key_index
= key_idx
;
1342 q_i
->key_name_len
= 0;
1343 q_i
->unknown_1
= 0x0414;
1346 q_i
->unknown_2
= 0x0000020A;
1347 memset(q_i
->pad1
, 0, sizeof(q_i
->pad1
));
1350 memset(q_i
->pad2
, 0, sizeof(q_i
->pad2
));
1353 unix_to_nt_time(&q_i
->time
, 0); /* current time? */
1356 /*******************************************************************
1357 makes a reply structure.
1358 ********************************************************************/
1360 void init_reg_r_enum_key(REG_R_ENUM_KEY
*r_u
, char *subkey
, uint32 unknown_1
,
1366 r_u
->unknown_1
= unknown_1
;
1367 r_u
->unknown_2
= unknown_2
;
1368 r_u
->unknown_3
= 0x0;
1370 r_u
->key_name_len
= (strlen(subkey
)+1) * 2;
1371 if (r_u
->key_name_len
)
1373 init_unistr3( &r_u
->key_name
, subkey
);
1379 /*******************************************************************
1380 reads or writes a structure.
1381 ********************************************************************/
1383 BOOL
reg_io_q_enum_key(char *desc
, REG_Q_ENUM_KEY
*q_q
, prs_struct
*ps
, int depth
)
1388 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_key");
1394 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1397 if(!prs_uint32("key_index", ps
, depth
, &q_q
->key_index
))
1399 if(!prs_uint16("key_name_len", ps
, depth
, &q_q
->key_name_len
))
1401 if(!prs_uint16("unknown_1", ps
, depth
, &q_q
->unknown_1
))
1404 if(!prs_uint32("ptr1", ps
, depth
, &q_q
->ptr1
))
1407 if (q_q
->ptr1
!= 0) {
1408 if(!prs_uint32("unknown_2", ps
, depth
, &q_q
->unknown_2
))
1410 if(!prs_uint8s(False
, "pad1", ps
, depth
, q_q
->pad1
, sizeof(q_q
->pad1
)))
1414 if(!prs_uint32("ptr2", ps
, depth
, &q_q
->ptr2
))
1417 if (q_q
->ptr2
!= 0) {
1418 if(!prs_uint8s(False
, "pad2", ps
, depth
, q_q
->pad2
, sizeof(q_q
->pad2
)))
1422 if(!prs_uint32("ptr3", ps
, depth
, &q_q
->ptr3
))
1425 if (q_q
->ptr3
!= 0) {
1426 if(!smb_io_time("", &q_q
->time
, ps
, depth
))
1433 /*******************************************************************
1434 reads or writes a structure.
1435 ********************************************************************/
1437 BOOL
reg_io_r_enum_key(char *desc
, REG_R_ENUM_KEY
*r_q
, prs_struct
*ps
, int depth
)
1442 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_key");
1448 if(!prs_uint16("key_name_len", ps
, depth
, &r_q
->key_name_len
))
1450 if(!prs_uint16("unknown_1", ps
, depth
, &r_q
->unknown_1
))
1453 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
1456 if (r_q
->ptr1
!= 0) {
1457 if(!prs_uint32("unknown_2", ps
, depth
, &r_q
->unknown_2
))
1459 if(!prs_uint32("unknown_3", ps
, depth
, &r_q
->unknown_3
))
1461 if(!smb_io_unistr3("key_name", &r_q
->key_name
, ps
, depth
))
1467 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
1470 if (r_q
->ptr2
!= 0) {
1471 if(!prs_uint8s(False
, "pad2", ps
, depth
, r_q
->pad2
, sizeof(r_q
->pad2
)))
1475 if(!prs_uint32("ptr3", ps
, depth
, &r_q
->ptr3
))
1478 if (r_q
->ptr3
!= 0) {
1479 if(!smb_io_time("", &r_q
->time
, ps
, depth
))
1483 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1489 /*******************************************************************
1491 ********************************************************************/
1493 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY
*r_q
, POLICY_HND
*pol
,
1494 char *key_name
, uint32 access_desired
)
1496 int len_name
= strlen(key_name
)+1;
1498 memcpy(&r_q
->pol
, pol
, sizeof(r_q
->pol
));
1500 init_uni_hdr(&r_q
->hdr_name
, len_name
);
1501 init_unistr2(&r_q
->uni_name
, key_name
, len_name
);
1503 r_q
->unknown_0
= 0x00000000;
1504 r_q
->access_desired
= access_desired
;
1507 /*******************************************************************
1508 reads or writes a structure.
1509 ********************************************************************/
1511 BOOL
reg_io_q_open_entry(char *desc
, REG_Q_OPEN_ENTRY
*r_q
, prs_struct
*ps
, int depth
)
1516 prs_debug(ps
, depth
, desc
, "reg_io_q_entry");
1522 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
1524 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
1526 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
1532 if(!prs_uint32("unknown_0 ", ps
, depth
, &r_q
->unknown_0
))
1534 if(!prs_uint32("asccess_desired ", ps
, depth
, &r_q
->access_desired
))
1540 /*******************************************************************
1542 ********************************************************************/
1544 void init_reg_r_open_entry(REG_R_OPEN_ENTRY
*r_r
,
1545 POLICY_HND
*pol
, NTSTATUS status
)
1547 memcpy(&r_r
->pol
, pol
, sizeof(r_r
->pol
));
1548 r_r
->status
= status
;
1551 /*******************************************************************
1552 reads or writes a structure.
1553 ********************************************************************/
1555 BOOL
reg_io_r_open_entry(char *desc
, REG_R_OPEN_ENTRY
*r_r
, prs_struct
*ps
, int depth
)
1560 prs_debug(ps
, depth
, desc
, "reg_io_r_open_entry");
1566 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
1569 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
1575 /*******************************************************************
1577 ********************************************************************/
1578 void init_reg_q_shutdown(REG_Q_SHUTDOWN
* q_s
,
1579 const char *msg
, uint32 timeout
, uint16 flags
)
1582 msg_len
= strlen(msg
);
1588 init_uni_hdr(&(q_s
->hdr_msg
), msg_len
);
1589 init_unistr2(&(q_s
->uni_msg
), msg
, msg_len
);
1591 q_s
->timeout
= timeout
;
1596 /*******************************************************************
1597 reads or writes a structure.
1598 ********************************************************************/
1599 BOOL
reg_io_q_shutdown(char *desc
, REG_Q_SHUTDOWN
* q_s
, prs_struct
*ps
,
1605 prs_debug(ps
, depth
, desc
, "reg_io_q_shutdown");
1611 if (!prs_uint32("ptr_0", ps
, depth
, &(q_s
->ptr_0
)))
1613 if (!prs_uint32("ptr_1", ps
, depth
, &(q_s
->ptr_1
)))
1615 if (!prs_uint32("ptr_2", ps
, depth
, &(q_s
->ptr_2
)))
1618 if (!smb_io_unihdr("hdr_msg", &(q_s
->hdr_msg
), ps
, depth
))
1620 if (!smb_io_unistr2("uni_msg", &(q_s
->uni_msg
), q_s
->hdr_msg
.buffer
, ps
, depth
))
1625 if (!prs_uint32("timeout", ps
, depth
, &(q_s
->timeout
)))
1627 if (!prs_uint16("flags ", ps
, depth
, &(q_s
->flags
)))
1633 /*******************************************************************
1634 reads or writes a structure.
1635 ********************************************************************/
1636 BOOL
reg_io_r_shutdown(char *desc
, REG_R_SHUTDOWN
* r_s
, prs_struct
*ps
,
1642 prs_debug(ps
, depth
, desc
, "reg_io_r_shutdown");
1648 if(!prs_ntstatus("status", ps
, depth
, &r_s
->status
))
1654 /*******************************************************************
1656 ********************************************************************/
1657 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN
* q_s
)
1660 q_s
->ptr_server
= 0;
1664 /*******************************************************************
1665 reads or writes a structure.
1666 ********************************************************************/
1667 BOOL
reg_io_q_abort_shutdown(char *desc
, REG_Q_ABORT_SHUTDOWN
* q_s
,
1668 prs_struct
*ps
, int depth
)
1673 prs_debug(ps
, depth
, desc
, "reg_io_q_abort_shutdown");
1679 if (!prs_uint32("ptr_server", ps
, depth
, &(q_s
->ptr_server
)))
1681 if (q_s
->ptr_server
!= 0)
1682 if (!prs_uint16("server", ps
, depth
, &(q_s
->server
)))
1688 /*******************************************************************
1689 reads or writes a structure.
1690 ********************************************************************/
1691 BOOL
reg_io_r_abort_shutdown(char *desc
, REG_R_ABORT_SHUTDOWN
* r_s
,
1692 prs_struct
*ps
, int depth
)
1697 prs_debug(ps
, depth
, desc
, "reg_io_r_abort_shutdown");
1703 if (!prs_ntstatus("status", ps
, depth
, &r_s
->status
))