2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
8 * Copyright (C) Marc Jacobsen 1999.
9 * Copyright (C) Simo Sorce 2000.
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.
28 /*******************************************************************
30 ********************************************************************/
32 void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR
*q_o
,
33 uint16 unknown_0
, uint32 level
)
36 q_o
->unknown_0
= unknown_0
;
37 q_o
->unknown_1
= 0x0; /* random - changes */
41 /*******************************************************************
42 reads or writes a structure.
43 ********************************************************************/
45 BOOL
reg_io_q_open_hkcr(char *desc
, REG_Q_OPEN_HKCR
*r_q
, prs_struct
*ps
, int depth
)
50 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hkcr");
56 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
60 if(!prs_uint16("unknown_0", ps
, depth
, &r_q
->unknown_0
))
62 if(!prs_uint16("unknown_1", ps
, depth
, &r_q
->unknown_1
))
64 if(!prs_uint32("level ", ps
, depth
, &r_q
->level
))
72 /*******************************************************************
73 reads or writes a structure.
74 ********************************************************************/
76 BOOL
reg_io_r_open_hkcr(char *desc
, REG_R_OPEN_HKCR
*r_r
, prs_struct
*ps
, int depth
)
81 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hkcr");
87 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
90 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
96 /*******************************************************************
98 ********************************************************************/
100 void init_reg_q_open_hklm(REG_Q_OPEN_HKLM
* q_o
,
101 uint16 unknown_0
, uint32 access_mask
)
104 q_o
->unknown_0
= unknown_0
;
105 q_o
->unknown_1
= 0x0; /* random - changes */
106 q_o
->access_mask
= access_mask
;
110 /*******************************************************************
111 reads or writes a structure.
112 ********************************************************************/
113 BOOL
reg_io_q_open_hklm(char *desc
, REG_Q_OPEN_HKLM
* r_q
, prs_struct
*ps
,
119 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hklm");
125 if (!prs_uint32("ptr ", ps
, depth
, &(r_q
->ptr
)))
129 if (!prs_uint16("unknown_0", ps
, depth
, &(r_q
->unknown_0
)))
131 if (!prs_uint16("unknown_1", ps
, depth
, &(r_q
->unknown_1
)))
133 if (!prs_uint32("access_mask", ps
, depth
, &(r_q
->access_mask
)))
141 /*******************************************************************
142 reads or writes a structure.
143 ********************************************************************/
144 BOOL
reg_io_r_open_hklm(char *desc
, REG_R_OPEN_HKLM
* r_r
, prs_struct
*ps
,
150 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hklm");
156 if (!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
159 if (!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
166 /*******************************************************************
168 ********************************************************************/
170 void init_reg_q_flush_key(REG_Q_FLUSH_KEY
*q_u
, POLICY_HND
*pol
)
172 memcpy(&q_u
->pol
, pol
, sizeof(q_u
->pol
));
175 /*******************************************************************
176 reads or writes a structure.
177 ********************************************************************/
179 BOOL
reg_io_q_flush_key(char *desc
, REG_Q_FLUSH_KEY
*r_q
, prs_struct
*ps
, int depth
)
184 prs_debug(ps
, depth
, desc
, "reg_io_q_flush_key");
190 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
196 /*******************************************************************
197 reads or writes a structure.
198 ********************************************************************/
200 BOOL
reg_io_r_flush_key(char *desc
, REG_R_FLUSH_KEY
*r_r
, prs_struct
*ps
, int depth
)
205 prs_debug(ps
, depth
, desc
, "reg_io_r_flush_key");
211 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
217 /*******************************************************************
218 reads or writes SEC_DESC_BUF and SEC_DATA structures.
219 ********************************************************************/
221 static BOOL
reg_io_hdrbuf_sec(uint32 ptr
, uint32
*ptr3
, BUFHDR
*hdr_sec
, SEC_DESC_BUF
*data
, prs_struct
*ps
, int depth
)
226 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec
, ps
, depth
, &hdr_offset
))
229 old_offset
= prs_offset(ps
);
232 if(!prs_uint32("ptr3", ps
, depth
, ptr3
))
236 if (ptr3
== NULL
|| *ptr3
!= 0) {
237 if(!sec_io_desc_buf("data ", &data
, ps
, depth
)) /* JRA - this line is probably wrong... */
241 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec
, ps
, depth
, hdr_offset
,
242 data
->max_len
, data
->len
))
244 if(!prs_set_offset(ps
, old_offset
+ data
->len
+ sizeof(uint32
) * ((ptr3
!= NULL
) ? 5 : 3)))
254 /*******************************************************************
256 ********************************************************************/
258 void init_reg_q_create_key(REG_Q_CREATE_KEY
*q_c
, POLICY_HND
*hnd
,
259 char *name
, char *class, SEC_ACCESS
*sam_access
,
260 SEC_DESC_BUF
*sec_buf
)
262 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
263 int len_class
= class != NULL
? strlen(class) + 1: 0;
267 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
269 init_uni_hdr(&q_c
->hdr_name
, len_name
);
270 init_unistr2(&q_c
->uni_name
, name
, len_name
);
272 init_uni_hdr(&q_c
->hdr_class
, len_class
);
273 init_unistr2(&q_c
->uni_class
, class, len_class
);
275 q_c
->reserved
= 0x00000000;
276 memcpy(&q_c
->sam_access
, sam_access
, sizeof(q_c
->sam_access
));
279 q_c
->sec_info
= DACL_SECURITY_INFORMATION
| SACL_SECURITY_INFORMATION
;
283 init_buf_hdr(&q_c
->hdr_sec
, sec_buf
->len
, sec_buf
->len
);
285 q_c
->unknown_2
= 0x00000000;
288 /*******************************************************************
289 reads or writes a structure.
290 ********************************************************************/
292 BOOL
reg_io_q_create_key(char *desc
, REG_Q_CREATE_KEY
*r_q
, prs_struct
*ps
, int depth
)
297 prs_debug(ps
, depth
, desc
, "reg_io_q_create_key");
303 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
306 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
308 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
313 if(!smb_io_unihdr ("", &r_q
->hdr_class
, ps
, depth
))
315 if(!smb_io_unistr2("", &r_q
->uni_class
, r_q
->hdr_class
.buffer
, ps
, depth
))
320 if(!prs_uint32("reserved", ps
, depth
, &r_q
->reserved
))
322 if(!sec_io_access("sam_access", &r_q
->sam_access
, ps
, depth
))
325 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
328 if (r_q
->ptr1
!= 0) {
329 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
333 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
335 if(!reg_io_hdrbuf_sec(r_q
->ptr2
, &r_q
->ptr3
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
338 if(!prs_uint32("unknown_2", ps
, depth
, &r_q
->unknown_2
))
344 /*******************************************************************
345 reads or writes a structure.
346 ********************************************************************/
348 BOOL
reg_io_r_create_key(char *desc
, REG_R_CREATE_KEY
*r_r
, prs_struct
*ps
, int depth
)
353 prs_debug(ps
, depth
, desc
, "reg_io_r_create_key");
359 if(!smb_io_pol_hnd("", &r_r
->key_pol
, ps
, depth
))
361 if(!prs_uint32("unknown", ps
, depth
, &r_r
->unknown
))
364 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
371 /*******************************************************************
373 ********************************************************************/
375 void init_reg_q_delete_val(REG_Q_DELETE_VALUE
*q_c
, POLICY_HND
*hnd
,
378 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
381 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
383 init_uni_hdr(&q_c
->hdr_name
, len_name
);
384 init_unistr2(&q_c
->uni_name
, name
, len_name
);
387 /*******************************************************************
388 reads or writes a structure.
389 ********************************************************************/
391 BOOL
reg_io_q_delete_val(char *desc
, REG_Q_DELETE_VALUE
*r_q
, prs_struct
*ps
, int depth
)
396 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_val");
402 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
405 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
407 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
416 /*******************************************************************
417 reads or writes a structure.
418 ********************************************************************/
420 BOOL
reg_io_r_delete_val(char *desc
, REG_R_DELETE_VALUE
*r_r
, prs_struct
*ps
, int depth
)
425 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_val");
431 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
437 /*******************************************************************
439 ********************************************************************/
441 void init_reg_q_delete_key(REG_Q_DELETE_KEY
*q_c
, POLICY_HND
*hnd
,
444 int len_name
= name
!= NULL
? strlen(name
) + 1: 0;
447 memcpy(&q_c
->pnt_pol
, hnd
, sizeof(q_c
->pnt_pol
));
449 init_uni_hdr(&q_c
->hdr_name
, len_name
);
450 init_unistr2(&q_c
->uni_name
, name
, len_name
);
453 /*******************************************************************
454 reads or writes a structure.
455 ********************************************************************/
457 BOOL
reg_io_q_delete_key(char *desc
, REG_Q_DELETE_KEY
*r_q
, prs_struct
*ps
, int depth
)
462 prs_debug(ps
, depth
, desc
, "reg_io_q_delete_key");
468 if(!smb_io_pol_hnd("", &r_q
->pnt_pol
, ps
, depth
))
471 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
473 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
481 /*******************************************************************
482 reads or writes a structure.
483 ********************************************************************/
485 BOOL
reg_io_r_delete_key(char *desc
, REG_R_DELETE_KEY
*r_r
, prs_struct
*ps
, int depth
)
490 prs_debug(ps
, depth
, desc
, "reg_io_r_delete_key");
496 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
502 /*******************************************************************
504 ********************************************************************/
506 void init_reg_q_query_key(REG_Q_QUERY_KEY
*q_o
, POLICY_HND
*hnd
,
507 uint32 max_class_len
)
511 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
512 init_uni_hdr(&q_o
->hdr_class
, max_class_len
);
513 q_o
->uni_class
.uni_max_len
= max_class_len
;
516 /*******************************************************************
517 reads or writes a structure.
518 ********************************************************************/
520 BOOL
reg_io_q_query_key(char *desc
, REG_Q_QUERY_KEY
*r_q
, prs_struct
*ps
, int depth
)
525 prs_debug(ps
, depth
, desc
, "reg_io_q_query_key");
531 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
533 if(!smb_io_unihdr ("", &r_q
->hdr_class
, ps
, depth
))
535 if(!smb_io_unistr2("", &r_q
->uni_class
, r_q
->hdr_class
.buffer
, ps
, depth
))
545 /*******************************************************************
546 reads or writes a structure.
547 ********************************************************************/
549 BOOL
reg_io_r_query_key(char *desc
, REG_R_QUERY_KEY
*r_r
, prs_struct
*ps
, int depth
)
554 prs_debug(ps
, depth
, desc
, "reg_io_r_query_key");
560 if(!smb_io_unihdr ("", &r_r
->hdr_class
, ps
, depth
))
562 if(!smb_io_unistr2("", &r_r
->uni_class
, r_r
->hdr_class
.buffer
, ps
, depth
))
568 if(!prs_uint32("num_subkeys ", ps
, depth
, &r_r
->num_subkeys
))
570 if(!prs_uint32("max_subkeylen ", ps
, depth
, &r_r
->max_subkeylen
))
572 if(!prs_uint32("mak_subkeysize", ps
, depth
, &r_r
->max_subkeysize
))
574 if(!prs_uint32("num_values ", ps
, depth
, &r_r
->num_values
))
576 if(!prs_uint32("max_valnamelen", ps
, depth
, &r_r
->max_valnamelen
))
578 if(!prs_uint32("max_valbufsize", ps
, depth
, &r_r
->max_valbufsize
))
580 if(!prs_uint32("sec_desc ", ps
, depth
, &r_r
->sec_desc
))
582 if(!smb_io_time("mod_time ", &r_r
->mod_time
, ps
, depth
))
585 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
591 /*******************************************************************
593 ********************************************************************/
595 void init_reg_q_unk_1a(REG_Q_UNK_1A
*q_o
, POLICY_HND
*hnd
)
597 memcpy(&q_o
->pol
, hnd
, sizeof(q_o
->pol
));
600 /*******************************************************************
601 reads or writes a structure.
602 ********************************************************************/
604 BOOL
reg_io_q_unk_1a(char *desc
, REG_Q_UNK_1A
*r_q
, prs_struct
*ps
, int depth
)
609 prs_debug(ps
, depth
, desc
, "reg_io_q_unk_1a");
615 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
621 /*******************************************************************
622 reads or writes a structure.
623 ********************************************************************/
625 BOOL
reg_io_r_unk_1a(char *desc
, REG_R_UNK_1A
*r_r
, prs_struct
*ps
, int depth
)
630 prs_debug(ps
, depth
, desc
, "reg_io_r_unk_1a");
636 if(!prs_uint32("unknown", ps
, depth
, &r_r
->unknown
))
638 if(!prs_ntstatus("status" , ps
, depth
, &r_r
->status
))
644 /*******************************************************************
646 ********************************************************************/
648 void init_reg_q_open_hku(REG_Q_OPEN_HKU
*q_o
,
649 uint16 unknown_0
, uint32 level
)
652 q_o
->unknown_0
= unknown_0
;
653 q_o
->unknown_1
= 0x0; /* random - changes */
657 /*******************************************************************
658 reads or writes a structure.
659 ********************************************************************/
661 BOOL
reg_io_q_open_hku(char *desc
, REG_Q_OPEN_HKU
*r_q
, prs_struct
*ps
, int depth
)
666 prs_debug(ps
, depth
, desc
, "reg_io_q_open_hku");
672 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
675 if(!prs_uint16("unknown_0", ps
, depth
, &r_q
->unknown_0
))
677 if(!prs_uint16("unknown_1", ps
, depth
, &r_q
->unknown_1
))
679 if(!prs_uint32("level ", ps
, depth
, &r_q
->level
))
686 /*******************************************************************
687 reads or writes a structure.
688 ********************************************************************/
690 BOOL
reg_io_r_open_hku(char *desc
, REG_R_OPEN_HKU
*r_r
, prs_struct
*ps
, int depth
)
695 prs_debug(ps
, depth
, desc
, "reg_io_r_open_hku");
701 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
704 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
710 /*******************************************************************
711 Inits an REG_Q_CLOSE structure.
712 ********************************************************************/
714 void init_reg_q_close(REG_Q_CLOSE
*q_c
, POLICY_HND
*hnd
)
716 DEBUG(5,("init_reg_q_close\n"));
718 memcpy(&q_c
->pol
, hnd
, sizeof(q_c
->pol
));
721 /*******************************************************************
722 reads or writes a structure.
723 ********************************************************************/
725 BOOL
reg_io_q_close(char *desc
, REG_Q_CLOSE
*q_u
, prs_struct
*ps
, int depth
)
730 prs_debug(ps
, depth
, desc
, "reg_io_q_unknown_1");
736 if(!smb_io_pol_hnd("", &q_u
->pol
, ps
, depth
))
744 /*******************************************************************
745 reads or writes a structure.
746 ********************************************************************/
748 BOOL
reg_io_r_close(char *desc
, REG_R_CLOSE
*r_u
, prs_struct
*ps
, int depth
)
753 prs_debug(ps
, depth
, desc
, "reg_io_r_unknown_1");
759 if(!smb_io_pol_hnd("", &r_u
->pol
, ps
, depth
))
764 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
770 /*******************************************************************
772 ********************************************************************/
774 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC
*q_i
, POLICY_HND
*pol
, SEC_DESC_BUF
*sec_desc_buf
)
776 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
778 q_i
->sec_info
= DACL_SECURITY_INFORMATION
;
781 init_buf_hdr(&q_i
->hdr_sec
, sec_desc_buf
->len
, sec_desc_buf
->len
);
782 q_i
->data
= sec_desc_buf
;
785 /*******************************************************************
786 reads or writes a structure.
787 ********************************************************************/
789 BOOL
reg_io_q_set_key_sec(char *desc
, REG_Q_SET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
794 prs_debug(ps
, depth
, desc
, "reg_io_q_set_key_sec");
800 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
803 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
805 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
808 if(!reg_io_hdrbuf_sec(r_q
->ptr
, NULL
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
814 /*******************************************************************
815 reads or writes a structure.
816 ********************************************************************/
818 BOOL
reg_io_r_set_key_sec(char *desc
, REG_R_SET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
823 prs_debug(ps
, depth
, desc
, "reg_io_r_set_key_sec");
829 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
836 /*******************************************************************
838 ********************************************************************/
840 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC
*q_i
, POLICY_HND
*pol
,
841 uint32 sec_buf_size
, SEC_DESC_BUF
*psdb
)
843 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
845 q_i
->sec_info
= OWNER_SECURITY_INFORMATION
|
846 GROUP_SECURITY_INFORMATION
|
847 DACL_SECURITY_INFORMATION
;
849 q_i
->ptr
= psdb
!= NULL
? 1 : 0;
852 init_buf_hdr(&q_i
->hdr_sec
, sec_buf_size
, 0);
855 /*******************************************************************
856 reads or writes a structure.
857 ********************************************************************/
859 BOOL
reg_io_q_get_key_sec(char *desc
, REG_Q_GET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
864 prs_debug(ps
, depth
, desc
, "reg_io_q_get_key_sec");
870 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
873 if(!prs_uint32("sec_info", ps
, depth
, &r_q
->sec_info
))
875 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
878 if(!reg_io_hdrbuf_sec(r_q
->ptr
, NULL
, &r_q
->hdr_sec
, r_q
->data
, ps
, depth
))
885 /*******************************************************************
887 ********************************************************************/
888 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC
*r_i
, POLICY_HND
*pol
,
889 uint32 buf_len
, uint8
*buf
,
893 init_buf_hdr(&r_i
->hdr_sec
, buf_len
, buf_len
);
894 init_sec_desc_buf(r_i
->data
, buf_len
, 1);
896 r_i
->status
= status
; /* 0x0000 0000 or 0x0000 007a */
900 /*******************************************************************
901 reads or writes a structure.
902 ********************************************************************/
904 BOOL
reg_io_r_get_key_sec(char *desc
, REG_R_GET_KEY_SEC
*r_q
, prs_struct
*ps
, int depth
)
909 prs_debug(ps
, depth
, desc
, "reg_io_r_get_key_sec");
915 if(!prs_uint32("ptr ", ps
, depth
, &r_q
->ptr
))
919 if(!smb_io_hdrbuf("", &r_q
->hdr_sec
, ps
, depth
))
921 if(!sec_io_desc_buf("", &r_q
->data
, ps
, depth
))
927 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
933 /*******************************************************************
935 ********************************************************************/
937 BOOL
init_reg_q_info(REG_Q_INFO
*q_i
, POLICY_HND
*pol
, char* val_name
)
939 int len_type
= val_name
!= NULL
? strlen(val_name
) + 1 : 0;
946 init_uni_hdr(&(q_i
->hdr_type
), len_type
);
947 init_unistr2(&(q_i
->uni_type
), val_name
, len_type
);
949 q_i
->ptr_reserved
= 1;
952 q_i
->ptr_bufsize
= 1;
960 q_i
->ptr_buflen2
= 1;
966 /*******************************************************************
967 reads or writes a structure.
968 ********************************************************************/
970 BOOL
reg_io_q_info(char *desc
, REG_Q_INFO
*r_q
, prs_struct
*ps
, int depth
)
975 prs_debug(ps
, depth
, desc
, "reg_io_q_info");
981 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
983 if(!smb_io_unihdr ("", &r_q
->hdr_type
, ps
, depth
))
985 if(!smb_io_unistr2("", &r_q
->uni_type
, r_q
->hdr_type
.buffer
, ps
, depth
))
991 if(!prs_uint32("ptr_reserved", ps
, depth
, &(r_q
->ptr_reserved
)))
994 if(!prs_uint32("ptr_buf", ps
, depth
, &(r_q
->ptr_buf
)))
998 if(!prs_uint32("ptr_bufsize", ps
, depth
, &(r_q
->ptr_bufsize
)))
1000 if(!prs_uint32("bufsize", ps
, depth
, &(r_q
->bufsize
)))
1002 if(!prs_uint32("buf_unk", ps
, depth
, &(r_q
->buf_unk
)))
1006 if(!prs_uint32("unk1", ps
, depth
, &(r_q
->unk1
)))
1009 if(!prs_uint32("ptr_buflen", ps
, depth
, &(r_q
->ptr_buflen
)))
1012 if (r_q
->ptr_buflen
) {
1013 if(!prs_uint32("buflen", ps
, depth
, &(r_q
->buflen
)))
1015 if(!prs_uint32("ptr_buflen2", ps
, depth
, &(r_q
->ptr_buflen2
)))
1017 if(!prs_uint32("buflen2", ps
, depth
, &(r_q
->buflen2
)))
1024 /*******************************************************************
1026 ********************************************************************/
1028 BOOL
init_reg_r_info(uint32 include_keyval
, REG_R_INFO
*r_r
,
1029 BUFFER2
* buf
, uint32 type
, NTSTATUS status
)
1038 /* if include_keyval is not set, don't send the key value, just
1039 the buflen data. probably used by NT5 to allocate buffer space - SK */
1040 r_r
->ptr_uni_val
= include_keyval
? 1:0;
1043 r_r
->ptr_max_len
= 1;
1044 r_r
->buf_max_len
= r_r
->uni_val
->buf_max_len
;
1047 r_r
->buf_len
= r_r
->uni_val
->buf_len
;
1049 r_r
->status
= status
;
1055 /*******************************************************************
1056 reads or writes a structure.
1057 ********************************************************************/
1059 BOOL
reg_io_r_info(char *desc
, REG_R_INFO
*r_r
, prs_struct
*ps
, int depth
)
1064 prs_debug(ps
, depth
, desc
, "reg_io_r_info");
1070 if(!prs_uint32("ptr_type", ps
, depth
, &(r_r
->ptr_type
)))
1073 if (r_r
->ptr_type
!= 0) {
1074 if(!prs_uint32("type", ps
, depth
, &r_r
->type
))
1078 if(!prs_uint32("ptr_uni_val", ps
, depth
, &(r_r
->ptr_uni_val
)))
1081 if(r_r
->ptr_uni_val
!= 0) {
1082 if(!smb_io_buffer2("uni_val", r_r
->uni_val
, r_r
->ptr_uni_val
, ps
, depth
))
1089 if(!prs_uint32("ptr_max_len", ps
, depth
, &(r_r
->ptr_max_len
)))
1092 if (r_r
->ptr_max_len
!= 0) {
1093 if(!prs_uint32("buf_max_len", ps
, depth
, &(r_r
->buf_max_len
)))
1097 if(!prs_uint32("ptr_len", ps
, depth
, &(r_r
->ptr_len
)))
1099 if (r_r
->ptr_len
!= 0) {
1100 if(!prs_uint32("buf_len", ps
, depth
, &(r_r
->buf_len
)))
1104 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
1110 /*******************************************************************
1112 ********************************************************************/
1114 void init_reg_q_enum_val(REG_Q_ENUM_VALUE
*q_i
, POLICY_HND
*pol
,
1115 uint32 val_idx
, uint32 max_val_len
,
1120 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1122 q_i
->val_index
= val_idx
;
1123 init_uni_hdr(&q_i
->hdr_name
, max_val_len
);
1124 q_i
->uni_name
.uni_max_len
= max_val_len
;
1130 q_i
->buf_value
.buf_max_len
= max_buf_len
;
1133 q_i
->len_value1
= max_buf_len
;
1136 q_i
->len_value2
= 0;
1139 /*******************************************************************
1140 reads or writes a structure.
1141 ********************************************************************/
1143 BOOL
reg_io_q_enum_val(char *desc
, REG_Q_ENUM_VALUE
*q_q
, prs_struct
*ps
, int depth
)
1148 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_val");
1154 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1157 if(!prs_uint32("val_index", ps
, depth
, &q_q
->val_index
))
1159 if(!smb_io_unihdr ("hdr_name", &q_q
->hdr_name
, ps
, depth
))
1161 if(!smb_io_unistr2("uni_name", &q_q
->uni_name
, q_q
->hdr_name
.buffer
, ps
, depth
))
1166 if(!prs_uint32("ptr_type", ps
, depth
, &q_q
->ptr_type
))
1169 if (q_q
->ptr_type
!= 0) {
1170 if(!prs_uint32("type", ps
, depth
, &q_q
->type
))
1174 if(!prs_uint32("ptr_value", ps
, depth
, &q_q
->ptr_value
))
1176 if(!smb_io_buffer2("buf_value", &q_q
->buf_value
, q_q
->ptr_value
, ps
, depth
))
1181 if(!prs_uint32("ptr1", ps
, depth
, &q_q
->ptr1
))
1183 if (q_q
->ptr1
!= 0) {
1184 if(!prs_uint32("len_value1", ps
, depth
, &q_q
->len_value1
))
1187 if(!prs_uint32("ptr2", ps
, depth
, &q_q
->ptr2
))
1189 if (q_q
->ptr2
!= 0) {
1190 if(!prs_uint32("len_value2", ps
, depth
, &q_q
->len_value2
))
1197 /*******************************************************************
1198 reads or writes a structure.
1199 ********************************************************************/
1201 BOOL
reg_io_r_enum_val(char *desc
, REG_R_ENUM_VALUE
*r_q
, prs_struct
*ps
, int depth
)
1206 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_val");
1212 if(!smb_io_unihdr ("hdr_name", &r_q
->hdr_name
, ps
, depth
))
1214 if(!smb_io_unistr2("uni_name", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
1219 if(!prs_uint32("ptr_type", ps
, depth
, &r_q
->ptr_type
))
1222 if (r_q
->ptr_type
!= 0) {
1223 if(!prs_uint32("type", ps
, depth
, &r_q
->type
))
1227 if(!prs_uint32("ptr_value", ps
, depth
, &r_q
->ptr_value
))
1229 if(!smb_io_buffer2("buf_value", r_q
->buf_value
, r_q
->ptr_value
, ps
, depth
))
1234 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
1236 if (r_q
->ptr1
!= 0) {
1237 if(!prs_uint32("len_value1", ps
, depth
, &r_q
->len_value1
))
1241 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
1243 if (r_q
->ptr2
!= 0) {
1244 if(!prs_uint32("len_value2", ps
, depth
, &r_q
->len_value2
))
1248 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1254 /*******************************************************************
1256 ********************************************************************/
1258 void init_reg_q_create_val(REG_Q_CREATE_VALUE
*q_i
, POLICY_HND
*pol
,
1259 char *val_name
, uint32 type
,
1262 int val_len
= strlen(val_name
) + 1;
1266 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1268 init_uni_hdr(&q_i
->hdr_name
, val_len
);
1269 init_unistr2(&q_i
->uni_name
, val_name
, val_len
);
1272 q_i
->buf_value
= val
;
1275 /*******************************************************************
1276 reads or writes a structure.
1277 ********************************************************************/
1279 BOOL
reg_io_q_create_val(char *desc
, REG_Q_CREATE_VALUE
*q_q
, prs_struct
*ps
, int depth
)
1284 prs_debug(ps
, depth
, desc
, "reg_io_q_create_val");
1290 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1293 if(!smb_io_unihdr ("hdr_name", &q_q
->hdr_name
, ps
, depth
))
1295 if(!smb_io_unistr2("uni_name", &q_q
->uni_name
, q_q
->hdr_name
.buffer
, ps
, depth
))
1300 if(!prs_uint32("type", ps
, depth
, &q_q
->type
))
1302 if(!smb_io_buffer3("buf_value", q_q
->buf_value
, ps
, depth
))
1310 /*******************************************************************
1311 reads or writes a structure.
1312 ********************************************************************/
1314 BOOL
reg_io_r_create_val(char *desc
, REG_R_CREATE_VALUE
*r_q
, prs_struct
*ps
, int depth
)
1319 prs_debug(ps
, depth
, desc
, "reg_io_r_create_val");
1325 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1331 /*******************************************************************
1333 ********************************************************************/
1335 void init_reg_q_enum_key(REG_Q_ENUM_KEY
*q_i
, POLICY_HND
*pol
, uint32 key_idx
)
1337 memcpy(&q_i
->pol
, pol
, sizeof(q_i
->pol
));
1339 q_i
->key_index
= key_idx
;
1340 q_i
->key_name_len
= 0;
1341 q_i
->unknown_1
= 0x0414;
1344 q_i
->unknown_2
= 0x0000020A;
1345 memset(q_i
->pad1
, 0, sizeof(q_i
->pad1
));
1348 memset(q_i
->pad2
, 0, sizeof(q_i
->pad2
));
1351 unix_to_nt_time(&q_i
->time
, 0); /* current time? */
1354 /*******************************************************************
1355 reads or writes a structure.
1356 ********************************************************************/
1358 BOOL
reg_io_q_enum_key(char *desc
, REG_Q_ENUM_KEY
*q_q
, prs_struct
*ps
, int depth
)
1363 prs_debug(ps
, depth
, desc
, "reg_io_q_enum_key");
1369 if(!smb_io_pol_hnd("", &q_q
->pol
, ps
, depth
))
1372 if(!prs_uint32("key_index", ps
, depth
, &q_q
->key_index
))
1374 if(!prs_uint16("key_name_len", ps
, depth
, &q_q
->key_name_len
))
1376 if(!prs_uint16("unknown_1", ps
, depth
, &q_q
->unknown_1
))
1379 if(!prs_uint32("ptr1", ps
, depth
, &q_q
->ptr1
))
1382 if (q_q
->ptr1
!= 0) {
1383 if(!prs_uint32("unknown_2", ps
, depth
, &q_q
->unknown_2
))
1385 if(!prs_uint8s(False
, "pad1", ps
, depth
, q_q
->pad1
, sizeof(q_q
->pad1
)))
1389 if(!prs_uint32("ptr2", ps
, depth
, &q_q
->ptr2
))
1392 if (q_q
->ptr2
!= 0) {
1393 if(!prs_uint8s(False
, "pad2", ps
, depth
, q_q
->pad2
, sizeof(q_q
->pad2
)))
1397 if(!prs_uint32("ptr3", ps
, depth
, &q_q
->ptr3
))
1400 if (q_q
->ptr3
!= 0) {
1401 if(!smb_io_time("", &q_q
->time
, ps
, depth
))
1408 /*******************************************************************
1409 reads or writes a structure.
1410 ********************************************************************/
1412 BOOL
reg_io_r_enum_key(char *desc
, REG_R_ENUM_KEY
*r_q
, prs_struct
*ps
, int depth
)
1417 prs_debug(ps
, depth
, desc
, "reg_io_r_enum_key");
1423 if(!prs_uint16("key_name_len", ps
, depth
, &r_q
->key_name_len
))
1425 if(!prs_uint16("unknown_1", ps
, depth
, &r_q
->unknown_1
))
1428 if(!prs_uint32("ptr1", ps
, depth
, &r_q
->ptr1
))
1431 if (r_q
->ptr1
!= 0) {
1432 if(!prs_uint32("unknown_2", ps
, depth
, &r_q
->unknown_2
))
1434 if(!prs_uint32("unknown_3", ps
, depth
, &r_q
->unknown_3
))
1436 if(!smb_io_unistr3("key_name", &r_q
->key_name
, ps
, depth
))
1442 if(!prs_uint32("ptr2", ps
, depth
, &r_q
->ptr2
))
1445 if (r_q
->ptr2
!= 0) {
1446 if(!prs_uint8s(False
, "pad2", ps
, depth
, r_q
->pad2
, sizeof(r_q
->pad2
)))
1450 if(!prs_uint32("ptr3", ps
, depth
, &r_q
->ptr3
))
1453 if (r_q
->ptr3
!= 0) {
1454 if(!smb_io_time("", &r_q
->time
, ps
, depth
))
1458 if(!prs_ntstatus("status", ps
, depth
, &r_q
->status
))
1464 /*******************************************************************
1466 ********************************************************************/
1468 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY
*r_q
, POLICY_HND
*pol
,
1469 char *key_name
, uint32 unk
)
1471 int len_name
= strlen(key_name
)+1;
1473 memcpy(&r_q
->pol
, pol
, sizeof(r_q
->pol
));
1475 init_uni_hdr(&r_q
->hdr_name
, len_name
);
1476 init_unistr2(&r_q
->uni_name
, key_name
, len_name
);
1478 r_q
->unknown_0
= 0x00000000;
1479 r_q
->unknown_1
= unk
;
1482 /*******************************************************************
1483 reads or writes a structure.
1484 ********************************************************************/
1486 BOOL
reg_io_q_open_entry(char *desc
, REG_Q_OPEN_ENTRY
*r_q
, prs_struct
*ps
, int depth
)
1491 prs_debug(ps
, depth
, desc
, "reg_io_q_entry");
1497 if(!smb_io_pol_hnd("", &r_q
->pol
, ps
, depth
))
1499 if(!smb_io_unihdr ("", &r_q
->hdr_name
, ps
, depth
))
1501 if(!smb_io_unistr2("", &r_q
->uni_name
, r_q
->hdr_name
.buffer
, ps
, depth
))
1507 if(!prs_uint32("unknown_0", ps
, depth
, &r_q
->unknown_0
))
1509 if(!prs_uint32("unknown_1", ps
, depth
, &r_q
->unknown_1
))
1515 /*******************************************************************
1517 ********************************************************************/
1519 void init_reg_r_open_entry(REG_R_OPEN_ENTRY
*r_r
,
1520 POLICY_HND
*pol
, NTSTATUS status
)
1522 memcpy(&r_r
->pol
, pol
, sizeof(r_r
->pol
));
1523 r_r
->status
= status
;
1526 /*******************************************************************
1527 reads or writes a structure.
1528 ********************************************************************/
1530 BOOL
reg_io_r_open_entry(char *desc
, REG_R_OPEN_ENTRY
*r_r
, prs_struct
*ps
, int depth
)
1535 prs_debug(ps
, depth
, desc
, "reg_io_r_open_entry");
1541 if(!smb_io_pol_hnd("", &r_r
->pol
, ps
, depth
))
1544 if(!prs_ntstatus("status", ps
, depth
, &r_r
->status
))
1550 /*******************************************************************
1552 ********************************************************************/
1553 void init_reg_q_shutdown(REG_Q_SHUTDOWN
* q_s
,
1554 const char *msg
, uint32 timeout
, uint16 flags
)
1557 msg_len
= strlen(msg
);
1563 init_uni_hdr(&(q_s
->hdr_msg
), msg_len
);
1564 init_unistr2(&(q_s
->uni_msg
), msg
, msg_len
);
1566 q_s
->timeout
= timeout
;
1571 /*******************************************************************
1572 reads or writes a structure.
1573 ********************************************************************/
1574 BOOL
reg_io_q_shutdown(char *desc
, REG_Q_SHUTDOWN
* q_s
, prs_struct
*ps
,
1580 prs_debug(ps
, depth
, desc
, "reg_io_q_shutdown");
1586 if (!prs_uint32("ptr_0", ps
, depth
, &(q_s
->ptr_0
)))
1588 if (!prs_uint32("ptr_1", ps
, depth
, &(q_s
->ptr_1
)))
1590 if (!prs_uint32("ptr_2", ps
, depth
, &(q_s
->ptr_2
)))
1593 if (!smb_io_unihdr("hdr_msg", &(q_s
->hdr_msg
), ps
, depth
))
1595 if (!smb_io_unistr2("uni_msg", &(q_s
->uni_msg
), q_s
->hdr_msg
.buffer
, ps
, depth
))
1600 if (!prs_uint32("timeout", ps
, depth
, &(q_s
->timeout
)))
1602 if (!prs_uint16("flags ", ps
, depth
, &(q_s
->flags
)))
1608 /*******************************************************************
1609 reads or writes a structure.
1610 ********************************************************************/
1611 BOOL
reg_io_r_shutdown(char *desc
, REG_R_SHUTDOWN
* r_s
, prs_struct
*ps
,
1617 prs_debug(ps
, depth
, desc
, "reg_io_r_shutdown");
1623 if(!prs_ntstatus("status", ps
, depth
, &r_s
->status
))
1629 /*******************************************************************
1631 ********************************************************************/
1632 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN
* q_s
)
1635 q_s
->ptr_server
= 0;
1639 /*******************************************************************
1640 reads or writes a structure.
1641 ********************************************************************/
1642 BOOL
reg_io_q_abort_shutdown(char *desc
, REG_Q_ABORT_SHUTDOWN
* q_s
,
1643 prs_struct
*ps
, int depth
)
1648 prs_debug(ps
, depth
, desc
, "reg_io_q_abort_shutdown");
1654 if (!prs_uint32("ptr_server", ps
, depth
, &(q_s
->ptr_server
)))
1656 if (q_s
->ptr_server
!= 0)
1657 if (!prs_uint16("server", ps
, depth
, &(q_s
->server
)))
1663 /*******************************************************************
1664 reads or writes a structure.
1665 ********************************************************************/
1666 BOOL
reg_io_r_abort_shutdown(char *desc
, REG_R_ABORT_SHUTDOWN
* r_s
,
1667 prs_struct
*ps
, int depth
)
1672 prs_debug(ps
, depth
, desc
, "reg_io_r_abort_shutdown");
1678 if (!prs_ntstatus("status", ps
, depth
, &r_s
->status
))