1/* 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. 10 * 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. 15 * 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. 20 * 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. 24 */ 25 26#include "includes.h" 27 28#undef DBGC_CLASS 29#define DBGC_CLASS DBGC_RPC_PARSE 30 31/******************************************************************* 32 Fill in a BUFFER2 for the data given a REGISTRY_VALUE 33 *******************************************************************/ 34 35static uint32 reg_init_buffer2( BUFFER2 *buf2, REGISTRY_VALUE *val ) 36{ 37 uint32 real_size = 0; 38 39 if ( !buf2 || !val ) 40 return 0; 41 42 real_size = regval_size(val); 43 init_buffer2( buf2, (unsigned char*)regval_data_p(val), real_size ); 44 45 return real_size; 46} 47 48/******************************************************************* 49 Inits a structure. 50********************************************************************/ 51 52void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o, 53 uint16 unknown_0, uint32 level) 54{ 55 q_o->ptr = 1; 56 q_o->unknown_0 = unknown_0; 57 q_o->unknown_1 = 0x0; /* random - changes */ 58 q_o->level = level; 59} 60 61/******************************************************************* 62reads or writes a structure. 63********************************************************************/ 64 65BOOL reg_io_q_open_hkcr(const char *desc, REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth) 66{ 67 if (r_q == NULL) 68 return False; 69 70 prs_debug(ps, depth, desc, "reg_io_q_open_hkcr"); 71 depth++; 72 73 if(!prs_align(ps)) 74 return False; 75 76 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) 77 return False; 78 79 if (r_q->ptr != 0) { 80 if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0)) 81 return False; 82 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1)) 83 return False; 84 if(!prs_uint32("level ", ps, depth, &r_q->level)) 85 return False; 86 } 87 88 return True; 89} 90 91 92/******************************************************************* 93reads or writes a structure. 94********************************************************************/ 95 96BOOL reg_io_r_open_hkcr(const char *desc, REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth) 97{ 98 if (r_r == NULL) 99 return False; 100 101 prs_debug(ps, depth, desc, "reg_io_r_open_hkcr"); 102 depth++; 103 104 if(!prs_align(ps)) 105 return False; 106 107 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) 108 return False; 109 110 if(!prs_werror("status", ps, depth, &r_r->status)) 111 return False; 112 113 return True; 114} 115 116/******************************************************************* 117 Inits a structure. 118********************************************************************/ 119 120void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o, 121 uint16 unknown_0, uint32 access_mask) 122{ 123 q_o->ptr = 1; 124 q_o->unknown_0 = unknown_0; 125 q_o->unknown_1 = 0x0; /* random - changes */ 126 q_o->access_mask = access_mask; 127 128} 129 130/******************************************************************* 131reads or writes a structure. 132********************************************************************/ 133BOOL reg_io_q_open_hklm(const char *desc, REG_Q_OPEN_HKLM * r_q, prs_struct *ps, 134 int depth) 135{ 136 if (r_q == NULL) 137 return False; 138 139 prs_debug(ps, depth, desc, "reg_io_q_open_hklm"); 140 depth++; 141 142 if (!prs_align(ps)) 143 return False; 144 145 if (!prs_uint32("ptr ", ps, depth, &(r_q->ptr))) 146 return False; 147 if (r_q->ptr != 0) 148 { 149 if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0))) 150 return False; 151 if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1))) 152 return False; 153 if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask))) 154 return False; 155 } 156 157 return True; 158} 159 160 161/******************************************************************* 162reads or writes a structure. 163********************************************************************/ 164BOOL reg_io_r_open_hklm(const char *desc, REG_R_OPEN_HKLM * r_r, prs_struct *ps, 165 int depth) 166{ 167 if (r_r == NULL) 168 return False; 169 170 prs_debug(ps, depth, desc, "reg_io_r_open_hklm"); 171 depth++; 172 173 if (!prs_align(ps)) 174 return False; 175 176 if (!smb_io_pol_hnd("", &r_r->pol, ps, depth)) 177 return False; 178 179 if (!prs_werror("status", ps, depth, &r_r->status)) 180 return False; 181 182 return True; 183} 184 185 186 187 188/******************************************************************* 189 Inits a structure. 190********************************************************************/ 191 192void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol) 193{ 194 memcpy(&q_u->pol, pol, sizeof(q_u->pol)); 195} 196 197/******************************************************************* 198reads or writes a structure. 199********************************************************************/ 200 201BOOL reg_io_q_flush_key(const char *desc, REG_Q_FLUSH_KEY *r_q, prs_struct *ps, int depth) 202{ 203 if (r_q == NULL) 204 return False; 205 206 prs_debug(ps, depth, desc, "reg_io_q_flush_key"); 207 depth++; 208 209 if(!prs_align(ps)) 210 return False; 211 212 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) 213 return False; 214 215 return True; 216} 217 218/******************************************************************* 219reads or writes a structure. 220********************************************************************/ 221 222BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, int depth) 223{ 224 if (r_r == NULL) 225 return False; 226 227 prs_debug(ps, depth, desc, "reg_io_r_flush_key"); 228 depth++; 229 230 if(!prs_align(ps)) 231 return False; 232 233 if(!prs_werror("status", ps, depth, &r_r->status)) 234 return False; 235 236 return True; 237} 238 239/******************************************************************* 240reads or writes SEC_DESC_BUF and SEC_DATA structures. 241********************************************************************/ 242 243static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DESC_BUF *data, prs_struct *ps, int depth) 244{ 245 if (ptr != 0) { 246 uint32 hdr_offset; 247 uint32 old_offset; 248 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset)) 249 return False; 250 251 old_offset = prs_offset(ps); 252 253 if (ptr3 != NULL) { 254 if(!prs_uint32("ptr3", ps, depth, ptr3)) 255 return False; 256 } 257 258 if (ptr3 == NULL || *ptr3 != 0) { 259 if(!sec_io_desc_buf("data ", &data, ps, depth)) /* JRA - this line is probably wrong... */ 260 return False; 261 } 262 263 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset, 264 data->max_len, data->len)) 265 return False; 266 if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3))) 267 return False; 268 269 if(!prs_align(ps)) 270 return False; 271 } 272 273 return True; 274} 275 276/******************************************************************* 277 Inits a structure. 278********************************************************************/ 279 280void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd, 281 char *name, char *class, SEC_ACCESS *sam_access, 282 SEC_DESC_BUF *sec_buf) 283{ 284 ZERO_STRUCTP(q_c); 285 286 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); 287 288 init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE); 289 init_uni_hdr(&q_c->hdr_name, &q_c->uni_name); 290 291 init_unistr2(&q_c->uni_class, class, UNI_STR_TERMINATE); 292 init_uni_hdr(&q_c->hdr_class, &q_c->uni_class); 293 294 q_c->reserved = 0x00000000; 295 memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access)); 296 297 q_c->ptr1 = 1; 298 q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION; 299 300 q_c->data = sec_buf; 301 q_c->ptr2 = 1; 302 init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len); 303 q_c->ptr3 = 1; 304 q_c->unknown_2 = 0x00000000; 305} 306 307/******************************************************************* 308reads or writes a structure. 309********************************************************************/ 310 311BOOL reg_io_q_create_key(const char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth) 312{ 313 if (r_q == NULL) 314 return False; 315 316 prs_debug(ps, depth, desc, "reg_io_q_create_key"); 317 depth++; 318 319 if(!prs_align(ps)) 320 return False; 321 322 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) 323 return False; 324 325 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) 326 return False; 327 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) 328 return False; 329 if(!prs_align(ps)) 330 return False; 331 332 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth)) 333 return False; 334 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth)) 335 return False; 336 if(!prs_align(ps)) 337 return False; 338 339 if(!prs_uint32("reserved", ps, depth, &r_q->reserved)) 340 return False; 341 if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth)) 342 return False; 343 344 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) 345 return False; 346 347 if (r_q->ptr1 != 0) { 348 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) 349 return False; 350 } 351 352 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) 353 return False; 354 if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth)) 355 return False; 356 357 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2)) 358 return False; 359 360 return True; 361} 362 363/******************************************************************* 364reads or writes a structure. 365********************************************************************/ 366 367BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth) 368{ 369 if (r_r == NULL) 370 return False; 371 372 prs_debug(ps, depth, desc, "reg_io_r_create_key"); 373 depth++; 374 375 if(!prs_align(ps)) 376 return False; 377 378 if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth)) 379 return False; 380 if(!prs_uint32("unknown", ps, depth, &r_r->unknown)) 381 return False; 382 383 if(!prs_werror("status", ps, depth, &r_r->status)) 384 return False; 385 386 return True; 387} 388 389 390/******************************************************************* 391 Inits a structure. 392********************************************************************/ 393 394void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd, 395 char *name) 396{ 397 ZERO_STRUCTP(q_c); 398 399 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); 400 401 init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE); 402 init_uni_hdr(&q_c->hdr_name, &q_c->uni_name); 403} 404 405/******************************************************************* 406reads or writes a structure. 407********************************************************************/ 408 409BOOL reg_io_q_delete_val(const char *desc, REG_Q_DELETE_VALUE *r_q, prs_struct *ps, int depth) 410{ 411 if (r_q == NULL) 412 return False; 413 414 prs_debug(ps, depth, desc, "reg_io_q_delete_val"); 415 depth++; 416 417 if(!prs_align(ps)) 418 return False; 419 420 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) 421 return False; 422 423 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) 424 return False; 425 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) 426 return False; 427 if(!prs_align(ps)) 428 return False; 429 430 return True; 431} 432 433 434/******************************************************************* 435reads or writes a structure. 436********************************************************************/ 437 438BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_r, prs_struct *ps, int depth) 439{ 440 if (r_r == NULL) 441 return False; 442 443 prs_debug(ps, depth, desc, "reg_io_r_delete_val"); 444 depth++; 445 446 if(!prs_align(ps)) 447 return False; 448 449 if(!prs_werror("status", ps, depth, &r_r->status)) 450 return False; 451 452 return True; 453} 454 455/******************************************************************* 456 Inits a structure. 457********************************************************************/ 458 459void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd, 460 char *name) 461{ 462 ZERO_STRUCTP(q_c); 463 464 memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); 465 466 init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE); 467 init_uni_hdr(&q_c->hdr_name, &q_c->uni_name); 468} 469 470/******************************************************************* 471reads or writes a structure. 472********************************************************************/ 473 474BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth) 475{ 476 if (r_q == NULL) 477 return False; 478 479 prs_debug(ps, depth, desc, "reg_io_q_delete_key"); 480 depth++; 481 482 if(!prs_align(ps)) 483 return False; 484 485 if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) 486 return False; 487 488 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) 489 return False; 490 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) 491 return False; 492 if(!prs_align(ps)) 493 return False; 494 495 return True; 496} 497 498/******************************************************************* 499reads or writes a structure. 500********************************************************************/ 501 502BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth) 503{ 504 if (r_r == NULL) 505 return False; 506 507 prs_debug(ps, depth, desc, "reg_io_r_delete_key"); 508 depth++; 509 510 if(!prs_align(ps)) 511 return False; 512 513 if(!prs_werror("status", ps, depth, &r_r->status)) 514 return False; 515 516 return True; 517} 518 519/******************************************************************* 520 Inits a structure. 521********************************************************************/ 522 523void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, UNISTR2 *uni2) 524{ 525 ZERO_STRUCTP(q_o); 526 527 memcpy(&q_o->pol, hnd, sizeof(q_o->pol)); 528 init_uni_hdr(&q_o->hdr_class, uni2); 529} 530 531/******************************************************************* 532reads or writes a structure. 533********************************************************************/ 534 535BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth) 536{ 537 if (r_q == NULL) 538 return False; 539 540 prs_debug(ps, depth, desc, "reg_io_q_query_key"); 541 depth++; 542 543 if(!prs_align(ps)) 544 return False; 545 546 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) 547 return False; 548 if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth)) 549 return False; 550 if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth)) 551 return False; 552 553 if(!prs_align(ps)) 554 return False; 555 556 return True; 557} 558 559 560/******************************************************************* 561reads or writes a structure. 562********************************************************************/ 563 564BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth) 565{ 566 if (r_r == NULL) 567 return False; 568 569 prs_debug(ps, depth, desc, "reg_io_r_query_key"); 570 depth++; 571 572 if(!prs_align(ps)) 573 return False; 574 575 if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth)) 576 return False; 577 if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth)) 578 return False; 579 580 if(!prs_align(ps)) 581 return False; 582 583 if(!prs_uint32("num_subkeys ", ps, depth, &r_r->num_subkeys)) 584 return False; 585 if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen)) 586 return False; 587 if(!prs_uint32("reserved ", ps, depth, &r_r->reserved)) 588 return False; 589 if(!prs_uint32("num_values ", ps, depth, &r_r->num_values)) 590 return False; 591 if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen)) 592 return False; 593 if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize)) 594 return False; 595 if(!prs_uint32("sec_desc ", ps, depth, &r_r->sec_desc)) 596 return False; 597 if(!smb_io_time("mod_time ", &r_r->mod_time, ps, depth)) 598 return False; 599 600 if(!prs_werror("status", ps, depth, &r_r->status)) 601 return False; 602 603 return True; 604} 605 606/******************************************************************* 607 Inits a structure. 608********************************************************************/ 609 610void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A *q_o, POLICY_HND *hnd) 611{ 612 memcpy(&q_o->pol, hnd, sizeof(q_o->pol)); 613} 614 615 616/******************************************************************* 617reads or writes a structure. 618********************************************************************/ 619 620BOOL reg_io_q_unknown_1a(const char *desc, REG_Q_UNKNOWN_1A *r_q, prs_struct *ps, int depth) 621{ 622 if (r_q == NULL) 623 return False; 624 625 prs_debug(ps, depth, desc, "reg_io_q_unknown_1a"); 626 depth++; 627 628 if(!prs_align(ps)) 629 return False; 630 631 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) 632 return False; 633 634 return True; 635} 636 637/******************************************************************* 638reads or writes a structure. 639********************************************************************/ 640 641BOOL reg_io_r_unknown_1a(const char *desc, REG_R_UNKNOWN_1A *r_r, prs_struct *ps, int depth) 642{ 643 if (r_r == NULL) 644 return False; 645 646 prs_debug(ps, depth, desc, "reg_io_r_unknown_1a"); 647 depth++; 648 649 if(!prs_align(ps)) 650 return False; 651 652 if(!prs_uint32("unknown", ps, depth, &r_r->unknown)) 653 return False; 654 if(!prs_werror("status" , ps, depth, &r_r->status)) 655 return False; 656 657 return True; 658} 659 660 661/******************************************************************* 662reads or writes a structure. 663********************************************************************/ 664 665BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *r_q, prs_struct *ps, int depth) 666{ 667 if (r_q == NULL) 668 return False; 669 670 prs_debug(ps, depth, desc, "reg_io_q_save_key"); 671 depth++; 672 673 if(!prs_align(ps)) 674 return False; 675 676 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) 677 return False; 678 679 if(!smb_io_unihdr ("hdr_file", &r_q->hdr_file, ps, depth)) 680 return False; 681 if(!smb_io_unistr2("uni_file", &r_q->uni_file, r_q->hdr_file.buffer, ps, depth)) 682 return False; 683 684 if(!prs_uint32("unknown", ps, depth, &r_q->unknown)) 685 return False; 686 687 return True; 688} 689 690/******************************************************************* 691reads or writes a structure. 692********************************************************************/ 693 694BOOL reg_io_r_save_key(const char *desc, REG_R_SAVE_KEY *r_r, prs_struct *ps, int depth) 695{ 696 if (r_r == NULL) 697 return False; 698 699 prs_debug(ps, depth, desc, "reg_io_r_save_key"); 700 depth++; 701 702 if(!prs_align(ps)) 703 return False; 704 705 if(!prs_werror("status" , ps, depth, &r_r->status)) 706 return False; 707 708 return True; 709} 710 711/******************************************************************* 712 Inits a structure. 713********************************************************************/ 714 715void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o, 716 uint16 unknown_0, uint32 access_mask) 717{ 718 q_o->ptr = 1; 719 q_o->unknown_0 = unknown_0; 720 q_o->unknown_1 = 0x0; /* random - changes */ 721 q_o->access_mask = access_mask; 722} 723 724/******************************************************************* 725reads or writes a structure. 726********************************************************************/ 727 728BOOL reg_io_q_open_hku(const char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth) 729{ 730 if (r_q == NULL) 731 return False; 732 733 prs_debug(ps, depth, desc, "reg_io_q_open_hku"); 734 depth++; 735 736 if(!prs_align(ps)) 737 return False; 738 739 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) 740 return False; 741 if (r_q->ptr != 0) { 742 if(!prs_uint16("unknown_0 ", ps, depth, &r_q->unknown_0)) 743 return False; 744 if(!prs_uint16("unknown_1 ", ps, depth, &r_q->unknown_1)) 745 return False; 746 if(!prs_uint32("access_mask ", ps, depth, &r_q->access_mask)) 747 return False; 748 } 749 750 return True; 751} 752 753/******************************************************************* 754reads or writes a structure. 755********************************************************************/ 756 757BOOL reg_io_r_open_hku(const char *desc, REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth) 758{ 759 if (r_r == NULL) 760 return False; 761 762 prs_debug(ps, depth, desc, "reg_io_r_open_hku"); 763 depth++; 764 765 if(!prs_align(ps)) 766 return False; 767 768 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) 769 return False; 770 771 if(!prs_werror("status", ps, depth, &r_r->status)) 772 return False; 773 774 return True; 775} 776 777/******************************************************************* 778 Inits an REG_Q_CLOSE structure. 779********************************************************************/ 780 781void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd) 782{ 783 DEBUG(5,("init_reg_q_close\n")); 784 785 memcpy(&q_c->pol, hnd, sizeof(q_c->pol)); 786} 787 788/******************************************************************* 789reads or writes a structure. 790********************************************************************/ 791 792BOOL reg_io_q_close(const char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth) 793{ 794 if (q_u == NULL) 795 return False; 796 797 prs_debug(ps, depth, desc, "reg_io_q_close"); 798 depth++; 799 800 if(!prs_align(ps)) 801 return False; 802 803 if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) 804 return False; 805 if(!prs_align(ps)) 806 return False; 807 808 return True; 809} 810 811/******************************************************************* 812reads or writes a structure. 813********************************************************************/ 814 815BOOL reg_io_r_close(const char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth) 816{ 817 if (r_u == NULL) 818 return False; 819 820 prs_debug(ps, depth, desc, "reg_io_r_close"); 821 depth++; 822 823 if(!prs_align(ps)) 824 return False; 825 826 if(!smb_io_pol_hnd("", &r_u->pol, ps, depth)) 827 return False; 828 if(!prs_align(ps)) 829 return False; 830 831 if(!prs_werror("status", ps, depth, &r_u->status)) 832 return False; 833 834 return True; 835} 836 837/******************************************************************* 838makes a structure. 839********************************************************************/ 840 841void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf) 842{ 843 memcpy(&q_i->pol, pol, sizeof(q_i->pol)); 844 845 q_i->sec_info = DACL_SECURITY_INFORMATION; 846 847 q_i->ptr = 1; 848 init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len); 849 q_i->data = sec_desc_buf; 850} 851 852/******************************************************************* 853reads or writes a structure. 854********************************************************************/ 855 856BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth) 857{ 858 if (r_q == NULL) 859 return False; 860 861 prs_debug(ps, depth, desc, "reg_io_q_set_key_sec"); 862 depth++; 863 864 if(!prs_align(ps)) 865 return False; 866 867 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) 868 return False; 869 870 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) 871 return False; 872 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) 873 return False; 874 875 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth)) 876 return False; 877 878 return True; 879} 880 881/******************************************************************* 882reads or writes a structure. 883********************************************************************/ 884 885BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth) 886{ 887 if (r_q == NULL) 888 return False; 889 890 prs_debug(ps, depth, desc, "reg_io_r_set_key_sec"); 891 depth++; 892 893 if(!prs_align(ps)) 894 return False; 895 896 if(!prs_werror("status", ps, depth, &r_q->status)) 897 return False; 898 899 return True; 900} 901 902 903/******************************************************************* 904makes a structure. 905********************************************************************/ 906 907void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol, 908 uint32 sec_buf_size, SEC_DESC_BUF *psdb) 909{ 910 memcpy(&q_i->pol, pol, sizeof(q_i->pol)); 911 912 q_i->sec_info = OWNER_SECURITY_INFORMATION | 913 GROUP_SECURITY_INFORMATION | 914 DACL_SECURITY_INFORMATION; 915 916 q_i->ptr = psdb != NULL ? 1 : 0; 917 q_i->data = psdb; 918 919 init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0); 920} 921 922/******************************************************************* 923reads or writes a structure. 924********************************************************************/ 925 926BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth) 927{ 928 if (r_q == NULL) 929 return False; 930 931 prs_debug(ps, depth, desc, "reg_io_q_get_key_sec"); 932 depth++; 933 934 if(!prs_align(ps)) 935 return False; 936 937 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) 938 return False; 939 940 if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) 941 return False; 942 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) 943 return False; 944 945 if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth)) 946 return False; 947 948 return True; 949} 950 951#if 0 952/******************************************************************* 953makes a structure. 954********************************************************************/ 955 void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol, 956 uint32 buf_len, uint8 *buf, 957 NTSTATUS status) 958{ 959 r_i->ptr = 1; 960 init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len); 961 init_sec_desc_buf(r_i->data, buf_len, 1); 962 963 r_i->status = status; /* 0x0000 0000 or 0x0000 007a */ 964} 965#endif 966 967/******************************************************************* 968reads or writes a structure. 969********************************************************************/ 970 971BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth) 972{ 973 if (r_q == NULL) 974 return False; 975 976 prs_debug(ps, depth, desc, "reg_io_r_get_key_sec"); 977 depth++; 978 979 if(!prs_align(ps)) 980 return False; 981 982 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) 983 return False; 984 985 if (r_q->ptr != 0) { 986 if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth)) 987 return False; 988 if(!sec_io_desc_buf("", &r_q->data, ps, depth)) 989 return False; 990 if(!prs_align(ps)) 991 return False; 992 } 993 994 if(!prs_werror("status", ps, depth, &r_q->status)) 995 return False; 996 997 return True; 998} 999 1000/******************************************************************* 1001makes a structure. 1002********************************************************************/ 1003 1004BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name) 1005{ 1006 if (q_i == NULL) 1007 return False; 1008 1009 q_i->pol = *pol; 1010 1011 init_unistr2(&q_i->uni_type, val_name, UNI_STR_TERMINATE); 1012 init_uni_hdr(&q_i->hdr_type, &q_i->uni_type); 1013 1014 q_i->ptr_reserved = 1; 1015 q_i->ptr_buf = 1; 1016 1017 q_i->ptr_bufsize = 1; 1018 q_i->bufsize = 0; 1019 q_i->buf_unk = 0; 1020 1021 q_i->unk1 = 0; 1022 q_i->ptr_buflen = 1; 1023 q_i->buflen = 0; 1024 1025 q_i->ptr_buflen2 = 1; 1026 q_i->buflen2 = 0; 1027 1028 return True; 1029} 1030 1031/******************************************************************* 1032reads or writes a structure. 1033********************************************************************/ 1034 1035BOOL reg_io_q_info(const char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth) 1036{ 1037 if (r_q == NULL) 1038 return False; 1039 1040 prs_debug(ps, depth, desc, "reg_io_q_info"); 1041 depth++; 1042 1043 if(!prs_align(ps)) 1044 return False; 1045 1046 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) 1047 return False; 1048 if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth)) 1049 return False; 1050 if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth)) 1051 return False; 1052 1053 if(!prs_align(ps)) 1054 return False; 1055 1056 if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved))) 1057 return False; 1058 1059 if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf))) 1060 return False; 1061 1062 if(r_q->ptr_buf) { 1063 if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize))) 1064 return False; 1065 if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize))) 1066 return False; 1067 if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk))) 1068 return False; 1069 } 1070 1071 if(!prs_uint32("unk1", ps, depth, &(r_q->unk1))) 1072 return False; 1073 1074 if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen))) 1075 return False; 1076 1077 if (r_q->ptr_buflen) { 1078 if(!prs_uint32("buflen", ps, depth, &(r_q->buflen))) 1079 return False; 1080 if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2))) 1081 return False; 1082 if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2))) 1083 return False; 1084 } 1085 1086 return True; 1087} 1088 1089/******************************************************************* 1090 Inits a structure. 1091 New version to replace older init_reg_r_info() 1092********************************************************************/ 1093 1094BOOL new_init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, 1095 REGISTRY_VALUE *val, WERROR status) 1096{ 1097 uint32 buf_len = 0; 1098 BUFFER2 buf2; 1099 1100 if(r_r == NULL) 1101 return False; 1102 1103 if ( !val ) 1104 return False; 1105 1106 r_r->ptr_type = 1; 1107 r_r->type = val->type; 1108 1109 /* if include_keyval is not set, don't send the key value, just 1110 the buflen data. probably used by NT5 to allocate buffer space - SK */ 1111 1112 if ( include_keyval ) { 1113 r_r->ptr_uni_val = 1; 1114 buf_len = reg_init_buffer2( &r_r->uni_val, val ); 1115 1116 } 1117 else { 1118 /* dummy buffer used so we can get the size */ 1119 r_r->ptr_uni_val = 0; 1120 buf_len = reg_init_buffer2( &buf2, val ); 1121 } 1122 1123 r_r->ptr_max_len = 1; 1124 r_r->buf_max_len = buf_len; 1125 1126 r_r->ptr_len = 1; 1127 r_r->buf_len = buf_len; 1128 1129 r_r->status = status; 1130 1131 return True; 1132} 1133 1134/******************************************************************* 1135 Inits a structure. 1136********************************************************************/ 1137 1138BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, 1139 BUFFER2* buf, uint32 type, WERROR status) 1140{ 1141 if(r_r == NULL) 1142 return False; 1143 1144 r_r->ptr_type = 1; 1145 r_r->type = type; 1146 1147 /* if include_keyval is not set, don't send the key value, just 1148 the buflen data. probably used by NT5 to allocate buffer space - SK */ 1149 1150 r_r->ptr_uni_val = include_keyval ? 1:0; 1151 r_r->uni_val = *buf; 1152 1153 r_r->ptr_max_len = 1; 1154 r_r->buf_max_len = r_r->uni_val.buf_max_len; 1155 1156 r_r->ptr_len = 1; 1157 r_r->buf_len = r_r->uni_val.buf_len; 1158 1159 r_r->status = status; 1160 1161 return True; 1162} 1163 1164/******************************************************************* 1165reads or writes a structure. 1166********************************************************************/ 1167 1168BOOL reg_io_r_info(const char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) 1169{ 1170 if (r_r == NULL) 1171 return False; 1172 1173 prs_debug(ps, depth, desc, "reg_io_r_info"); 1174 depth++; 1175 1176 if(!prs_align(ps)) 1177 return False; 1178 1179 if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type))) 1180 return False; 1181 1182 if (r_r->ptr_type != 0) { 1183 if(!prs_uint32("type", ps, depth, &r_r->type)) 1184 return False; 1185 } 1186 1187 if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val))) 1188 return False; 1189 1190 if(r_r->ptr_uni_val != 0) { 1191 if(!smb_io_buffer2("uni_val", &r_r->uni_val, r_r->ptr_uni_val, ps, depth)) 1192 return False; 1193 } 1194 1195 if(!prs_align(ps)) 1196 return False; 1197 1198 if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len))) 1199 return False; 1200 1201 if (r_r->ptr_max_len != 0) { 1202 if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len))) 1203 return False; 1204 } 1205 1206 if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len))) 1207 return False; 1208 if (r_r->ptr_len != 0) { 1209 if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len))) 1210 return False; 1211 } 1212 1213 if(!prs_werror("status", ps, depth, &r_r->status)) 1214 return False; 1215 1216 return True; 1217} 1218 1219/******************************************************************* 1220makes a structure. 1221********************************************************************/ 1222 1223void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol, 1224 uint32 val_idx, UNISTR2 *uni2, 1225 uint32 max_buf_len) 1226{ 1227 ZERO_STRUCTP(q_i); 1228 1229 memcpy(&q_i->pol, pol, sizeof(q_i->pol)); 1230 1231 q_i->val_index = val_idx; 1232 init_uni_hdr(&q_i->hdr_name, uni2); 1233 1234 q_i->ptr_type = 1; 1235 q_i->type = 0x0; 1236 1237 q_i->ptr_value = 1; 1238 q_i->buf_value.buf_max_len = max_buf_len; 1239 1240 q_i->ptr1 = 1; 1241 q_i->len_value1 = max_buf_len; 1242 1243 q_i->ptr2 = 1; 1244 q_i->len_value2 = 0; 1245} 1246 1247/******************************************************************* 1248makes a structure. 1249********************************************************************/ 1250 1251void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val ) 1252{ 1253 uint32 real_size; 1254 1255 DEBUG(8,("init_reg_r_enum_val: Enter\n")); 1256 1257 ZERO_STRUCTP(r_u); 1258 1259 /* value name */ 1260 1261 DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename)); 1262 1263 init_unistr2( &r_u->uni_name, val->valuename, UNI_STR_TERMINATE); 1264 init_uni_hdr( &r_u->hdr_name, &r_u->uni_name); 1265 1266 /* type */ 1267 1268 r_u->ptr_type = 1; 1269 r_u->type = val->type; 1270 1271 /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */ 1272 1273 r_u->ptr_value = 1; 1274 real_size = reg_init_buffer2( &r_u->buf_value, val ); 1275 1276 /* lengths */ 1277 1278 r_u->ptr1 = 1; 1279 r_u->len_value1 = real_size; 1280 1281 r_u->ptr2 = 1; 1282 r_u->len_value2 = real_size; 1283 1284 DEBUG(8,("init_reg_r_enum_val: Exit\n")); 1285} 1286 1287/******************************************************************* 1288reads or writes a structure. 1289********************************************************************/ 1290 1291BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth) 1292{ 1293 if (q_q == NULL) 1294 return False; 1295 1296 prs_debug(ps, depth, desc, "reg_io_q_enum_val"); 1297 depth++; 1298 1299 if(!prs_align(ps)) 1300 return False; 1301 1302 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 1303 return False; 1304 1305 if(!prs_uint32("val_index", ps, depth, &q_q->val_index)) 1306 return False; 1307 1308 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth)) 1309 return False; 1310 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth)) 1311 return False; 1312 if(!prs_align(ps)) 1313 return False; 1314 1315 if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type)) 1316 return False; 1317 1318 if (q_q->ptr_type != 0) { 1319 if(!prs_uint32("type", ps, depth, &q_q->type)) 1320 return False; 1321 } 1322 1323 if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value)) 1324 return False; 1325 if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth)) 1326 return False; 1327 if(!prs_align(ps)) 1328 return False; 1329 1330 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1)) 1331 return False; 1332 if (q_q->ptr1 != 0) { 1333 if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1)) 1334 return False; 1335 } 1336 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2)) 1337 return False; 1338 if (q_q->ptr2 != 0) { 1339 if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2)) 1340 return False; 1341 } 1342 1343 return True; 1344} 1345 1346/******************************************************************* 1347reads or writes a structure. 1348********************************************************************/ 1349 1350BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth) 1351{ 1352 if (r_q == NULL) 1353 return False; 1354 1355 prs_debug(ps, depth, desc, "reg_io_r_enum_val"); 1356 depth++; 1357 1358 if(!prs_align(ps)) 1359 return False; 1360 1361 if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth)) 1362 return False; 1363 if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) 1364 return False; 1365 if(!prs_align(ps)) 1366 return False; 1367 1368 if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type)) 1369 return False; 1370 1371 if (r_q->ptr_type != 0) { 1372 if(!prs_uint32("type", ps, depth, &r_q->type)) 1373 return False; 1374 } 1375 1376 if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value)) 1377 return False; 1378 if(!smb_io_buffer2("buf_value", &r_q->buf_value, r_q->ptr_value, ps, depth)) 1379 return False; 1380 if(!prs_align(ps)) 1381 return False; 1382 1383 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) 1384 return False; 1385 if (r_q->ptr1 != 0) { 1386 if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1)) 1387 return False; 1388 } 1389 1390 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) 1391 return False; 1392 if (r_q->ptr2 != 0) { 1393 if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2)) 1394 return False; 1395 } 1396 1397 if(!prs_werror("status", ps, depth, &r_q->status)) 1398 return False; 1399 1400 return True; 1401} 1402 1403/******************************************************************* 1404makes a structure. 1405********************************************************************/ 1406 1407void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol, 1408 char *val_name, uint32 type, 1409 BUFFER3 *val) 1410{ 1411 ZERO_STRUCTP(q_i); 1412 1413 memcpy(&q_i->pol, pol, sizeof(q_i->pol)); 1414 1415 init_unistr2(&q_i->uni_name, val_name, UNI_STR_TERMINATE); 1416 init_uni_hdr(&q_i->hdr_name, &q_i->uni_name); 1417 1418 q_i->type = type; 1419 q_i->buf_value = val; 1420} 1421 1422/******************************************************************* 1423reads or writes a structure. 1424********************************************************************/ 1425 1426BOOL reg_io_q_create_val(const char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth) 1427{ 1428 if (q_q == NULL) 1429 return False; 1430 1431 prs_debug(ps, depth, desc, "reg_io_q_create_val"); 1432 depth++; 1433 1434 if(!prs_align(ps)) 1435 return False; 1436 1437 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 1438 return False; 1439 1440 if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth)) 1441 return False; 1442 if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth)) 1443 return False; 1444 if(!prs_align(ps)) 1445 return False; 1446 1447 if(!prs_uint32("type", ps, depth, &q_q->type)) 1448 return False; 1449 if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth)) 1450 return False; 1451 if(!prs_align(ps)) 1452 return False; 1453 1454 return True; 1455} 1456 1457/******************************************************************* 1458reads or writes a structure. 1459********************************************************************/ 1460 1461BOOL reg_io_r_create_val(const char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth) 1462{ 1463 if (r_q == NULL) 1464 return False; 1465 1466 prs_debug(ps, depth, desc, "reg_io_r_create_val"); 1467 depth++; 1468 1469 if(!prs_align(ps)) 1470 return False; 1471 1472 if(!prs_werror("status", ps, depth, &r_q->status)) 1473 return False; 1474 1475 return True; 1476} 1477 1478/******************************************************************* 1479makes a structure. 1480********************************************************************/ 1481 1482void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx) 1483{ 1484 memcpy(&q_i->pol, pol, sizeof(q_i->pol)); 1485 1486 q_i->key_index = key_idx; 1487 q_i->key_name_len = 0; 1488 q_i->unknown_1 = 0x0414; 1489 1490 q_i->ptr1 = 1; 1491 q_i->unknown_2 = 0x0000020A; 1492 memset(q_i->pad1, 0, sizeof(q_i->pad1)); 1493 1494 q_i->ptr2 = 1; 1495 memset(q_i->pad2, 0, sizeof(q_i->pad2)); 1496 1497 q_i->ptr3 = 1; 1498 unix_to_nt_time(&q_i->time, 0); /* current time? */ 1499} 1500 1501/******************************************************************* 1502makes a reply structure. 1503********************************************************************/ 1504 1505void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey, uint32 unknown_1, 1506 uint32 unknown_2) 1507{ 1508 if ( !r_u ) 1509 return; 1510 1511 r_u->unknown_1 = unknown_1; 1512 r_u->unknown_2 = unknown_2; 1513 r_u->unknown_3 = 0x0; 1514 1515 r_u->key_name_len = (strlen(subkey)+1) * 2; 1516 if (r_u->key_name_len) 1517 r_u->ptr1 = 0x1; 1518 init_unistr3( &r_u->key_name, subkey ); 1519 1520 r_u->ptr2 = 0x1; 1521 r_u->ptr3 = 0x1; 1522} 1523 1524/******************************************************************* 1525reads or writes a structure. 1526********************************************************************/ 1527 1528BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth) 1529{ 1530 if (q_q == NULL) 1531 return False; 1532 1533 prs_debug(ps, depth, desc, "reg_io_q_enum_key"); 1534 depth++; 1535 1536 if(!prs_align(ps)) 1537 return False; 1538 1539 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 1540 return False; 1541 1542 if(!prs_uint32("key_index", ps, depth, &q_q->key_index)) 1543 return False; 1544 if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len)) 1545 return False; 1546 if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1)) 1547 return False; 1548 1549 if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1)) 1550 return False; 1551 1552 if (q_q->ptr1 != 0) { 1553 if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2)) 1554 return False; 1555 if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1))) 1556 return False; 1557 } 1558 1559 if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2)) 1560 return False; 1561 1562 if (q_q->ptr2 != 0) { 1563 if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2))) 1564 return False; 1565 } 1566 1567 if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3)) 1568 return False; 1569 1570 if (q_q->ptr3 != 0) { 1571 if(!smb_io_time("", &q_q->time, ps, depth)) 1572 return False; 1573 } 1574 1575 return True; 1576} 1577 1578/******************************************************************* 1579reads or writes a structure. 1580********************************************************************/ 1581 1582BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth) 1583{ 1584 if (r_q == NULL) 1585 return False; 1586 1587 prs_debug(ps, depth, desc, "reg_io_r_enum_key"); 1588 depth++; 1589 1590 if(!prs_align(ps)) 1591 return False; 1592 1593 if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len)) 1594 return False; 1595 if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1)) 1596 return False; 1597 1598 if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) 1599 return False; 1600 1601 if (r_q->ptr1 != 0) { 1602 if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2)) 1603 return False; 1604 if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3)) 1605 return False; 1606 if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth)) 1607 return False; 1608 if(!prs_align(ps)) 1609 return False; 1610 } 1611 1612 if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) 1613 return False; 1614 1615 if (r_q->ptr2 != 0) { 1616 if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2))) 1617 return False; 1618 } 1619 1620 if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3)) 1621 return False; 1622 1623 if (r_q->ptr3 != 0) { 1624 if(!smb_io_time("", &r_q->time, ps, depth)) 1625 return False; 1626 } 1627 1628 if(!prs_werror("status", ps, depth, &r_q->status)) 1629 return False; 1630 1631 return True; 1632} 1633 1634/******************************************************************* 1635makes a structure. 1636********************************************************************/ 1637 1638void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol, 1639 char *key_name, uint32 access_desired) 1640{ 1641 memcpy(&r_q->pol, pol, sizeof(r_q->pol)); 1642 1643 init_unistr2(&r_q->uni_name, key_name, UNI_STR_TERMINATE); 1644 init_uni_hdr(&r_q->hdr_name, &r_q->uni_name); 1645 1646 r_q->unknown_0 = 0x00000000; 1647 r_q->access_desired = access_desired; 1648} 1649 1650/******************************************************************* 1651reads or writes a structure. 1652********************************************************************/ 1653 1654BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth) 1655{ 1656 if (r_q == NULL) 1657 return False; 1658 1659 prs_debug(ps, depth, desc, "reg_io_q_entry"); 1660 depth++; 1661 1662 if(!prs_align(ps)) 1663 return False; 1664 1665 if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) 1666 return False; 1667 if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) 1668 return False; 1669 if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) 1670 return False; 1671 1672 if(!prs_align(ps)) 1673 return False; 1674 1675 if(!prs_uint32("unknown_0 ", ps, depth, &r_q->unknown_0)) 1676 return False; 1677 if(!prs_uint32("access_desired ", ps, depth, &r_q->access_desired)) 1678 return False; 1679 1680 return True; 1681} 1682 1683/******************************************************************* 1684 Inits a structure. 1685********************************************************************/ 1686 1687void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r, 1688 POLICY_HND *pol, WERROR werr) 1689{ 1690 if (W_ERROR_IS_OK(werr)) { 1691 memcpy(&r_r->pol, pol, sizeof(r_r->pol)); 1692 } else { 1693 ZERO_STRUCT(r_r->pol); 1694 } 1695 r_r->status = werr; 1696} 1697 1698/******************************************************************* 1699reads or writes a structure. 1700********************************************************************/ 1701 1702BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth) 1703{ 1704 if (r_r == NULL) 1705 return False; 1706 1707 prs_debug(ps, depth, desc, "reg_io_r_open_entry"); 1708 depth++; 1709 1710 if(!prs_align(ps)) 1711 return False; 1712 1713 if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) 1714 return False; 1715 1716 if(!prs_werror("status", ps, depth, &r_r->status)) 1717 return False; 1718 1719 return True; 1720} 1721 1722/******************************************************************* 1723Inits a structure. 1724********************************************************************/ 1725 1726void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s, const char *msg, 1727 uint32 timeout, BOOL do_reboot, BOOL force) 1728{ 1729 q_s->ptr_0 = 1; 1730 q_s->ptr_1 = 1; 1731 q_s->ptr_2 = 1; 1732 1733 init_unistr2(&q_s->uni_msg, msg, UNI_FLAGS_NONE); 1734 init_uni_hdr(&q_s->hdr_msg, &q_s->uni_msg); 1735 1736 q_s->timeout = timeout; 1737 1738 q_s->reboot = do_reboot ? 1 : 0; 1739 q_s->force = force ? 1 : 0; 1740} 1741 1742/******************************************************************* 1743reads or writes a structure. 1744********************************************************************/ 1745 1746BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps, 1747 int depth) 1748{ 1749 if (q_s == NULL) 1750 return False; 1751 1752 prs_debug(ps, depth, desc, "reg_io_q_shutdown"); 1753 depth++; 1754 1755 if (!prs_align(ps)) 1756 return False; 1757 1758 if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0))) 1759 return False; 1760 if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1))) 1761 return False; 1762 if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2))) 1763 return False; 1764 1765 if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth)) 1766 return False; 1767 if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth)) 1768 return False; 1769 if (!prs_align(ps)) 1770 return False; 1771 1772 if (!prs_uint32("timeout", ps, depth, &(q_s->timeout))) 1773 return False; 1774 if (!prs_uint8("force ", ps, depth, &(q_s->force))) 1775 return False; 1776 if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot))) 1777 return False; 1778 1779 return True; 1780} 1781 1782/******************************************************************* 1783reads or writes a structure. 1784********************************************************************/ 1785BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps, 1786 int depth) 1787{ 1788 if (r_s == NULL) 1789 return False; 1790 1791 prs_debug(ps, depth, desc, "reg_io_r_shutdown"); 1792 depth++; 1793 1794 if(!prs_align(ps)) 1795 return False; 1796 1797 if(!prs_werror("status", ps, depth, &r_s->status)) 1798 return False; 1799 1800 return True; 1801} 1802 1803/******************************************************************* 1804Inits a structure. 1805********************************************************************/ 1806void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s) 1807{ 1808 1809 q_s->ptr_server = 0; 1810 1811} 1812 1813/******************************************************************* 1814reads or writes a structure. 1815********************************************************************/ 1816BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN * q_s, 1817 prs_struct *ps, int depth) 1818{ 1819 if (q_s == NULL) 1820 return False; 1821 1822 prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown"); 1823 depth++; 1824 1825 if (!prs_align(ps)) 1826 return False; 1827 1828 if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server))) 1829 return False; 1830 if (q_s->ptr_server != 0) 1831 if (!prs_uint16("server", ps, depth, &(q_s->server))) 1832 return False; 1833 1834 return True; 1835} 1836 1837/******************************************************************* 1838reads or writes a structure. 1839********************************************************************/ 1840BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN * r_s, 1841 prs_struct *ps, int depth) 1842{ 1843 if (r_s == NULL) 1844 return False; 1845 1846 prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown"); 1847 depth++; 1848 1849 if (!prs_align(ps)) 1850 return False; 1851 1852 if (!prs_werror("status", ps, depth, &r_s->status)) 1853 return False; 1854 1855 return True; 1856} 1857