rpc_parse/parse_reg.c

説明を見る。
00001 /*
00002  *  Unix SMB/CIFS implementation.
00003  *  RPC Pipe client / server routines
00004  *  Copyright (C) Andrew Tridgell              1992-1997,
00005  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
00006  *  Copyright (C) Paul Ashton                       1997.
00007  *  Copyright (C) Marc Jacobsen                     1999.
00008  *  Copyright (C) Simo Sorce                        2000.
00009  *  Copyright (C) Jeremy Cooper                     2004
00010  *  Copyright (C) Gerald Carter                     2002-2005.
00011  *  
00012  *  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; either version 2 of the License, or
00015  *  (at your option) any later version.
00016  *  
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU General Public License for more details.
00021  *  
00022  *  You should have received a copy of the GNU General Public License
00023  *  along with this program; if not, write to the Free Software
00024  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  */
00026 
00027 #include "includes.h"
00028 
00029 #undef DBGC_CLASS
00030 #define DBGC_CLASS DBGC_RPC_PARSE
00031 
00032 /*******************************************************************
00033  Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE
00034  *******************************************************************/
00035 
00036 uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val )
00037 {
00038         uint32          real_size = 0;
00039         
00040         if ( !buf2 || !val )
00041                 return 0;
00042                 
00043         real_size = regval_size(val);
00044         init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size );
00045 
00046         return real_size;
00047 }
00048 
00049 /*******************************************************************
00050  Inits a hive connect request structure
00051 ********************************************************************/
00052 
00053 void init_reg_q_open_hive( REG_Q_OPEN_HIVE *q_o, uint32 access_desired )
00054 {
00055         
00056         q_o->server = TALLOC_P( get_talloc_ctx(), uint16);
00057         if (!q_o->server) {
00058                 smb_panic("init_reg_q_open_hive: talloc fail.\n");
00059                 return;
00060         }
00061         *q_o->server = 0x1;
00062         
00063         q_o->access = access_desired;
00064 }
00065 
00066 /*******************************************************************
00067 Marshalls a hive connect request
00068 ********************************************************************/
00069 
00070 BOOL reg_io_q_open_hive(const char *desc, REG_Q_OPEN_HIVE *q_u,
00071                         prs_struct *ps, int depth)
00072 {
00073         prs_debug(ps, depth, desc, "reg_io_q_open_hive");
00074         depth++;
00075 
00076         if(!prs_align(ps))
00077                 return False;
00078 
00079         if(!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
00080                 return False;
00081 
00082         if(!prs_align(ps))
00083                 return False;
00084         if(!prs_uint32("access", ps, depth, &q_u->access))
00085                 return False;
00086 
00087         return True;
00088 }
00089 
00090 
00091 /*******************************************************************
00092 Unmarshalls a hive connect response
00093 ********************************************************************/
00094 
00095 BOOL reg_io_r_open_hive(const char *desc,  REG_R_OPEN_HIVE *r_u,
00096                         prs_struct *ps, int depth)
00097 {
00098         if ( !r_u )
00099                 return False;
00100 
00101         prs_debug(ps, depth, desc, "reg_io_r_open_hive");
00102         depth++;
00103 
00104         if(!prs_align(ps))
00105                 return False;
00106         
00107         if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
00108                 return False;
00109 
00110         if(!prs_werror("status", ps, depth, &r_u->status))
00111                 return False;
00112 
00113         return True;
00114 }
00115 
00116 /*******************************************************************
00117  Inits a structure.
00118 ********************************************************************/
00119 
00120 void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol)
00121 {
00122         memcpy(&q_u->pol, pol, sizeof(q_u->pol));
00123 }
00124 
00125 /*******************************************************************
00126 reads or writes a structure.
00127 ********************************************************************/
00128 
00129 BOOL reg_io_q_flush_key(const char *desc,  REG_Q_FLUSH_KEY *q_u, prs_struct *ps, int depth)
00130 {
00131         if ( !q_u )
00132                 return False;
00133 
00134         prs_debug(ps, depth, desc, "reg_io_q_flush_key");
00135         depth++;
00136 
00137         if(!prs_align(ps))
00138                 return False;
00139         
00140         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
00141                 return False;
00142 
00143         return True;
00144 }
00145 
00146 /*******************************************************************
00147 Unmarshalls a registry key flush response
00148 ********************************************************************/
00149 
00150 BOOL reg_io_r_flush_key(const char *desc,  REG_R_FLUSH_KEY *r_u,
00151                         prs_struct *ps, int depth)
00152 {
00153         if ( !r_u )
00154                 return False;
00155 
00156         prs_debug(ps, depth, desc, "reg_io_r_flush_key");
00157         depth++;
00158 
00159         if(!prs_align(ps))
00160                 return False;
00161         
00162         if(!prs_werror("status", ps, depth, &r_u->status))
00163                 return False;
00164 
00165         return True;
00166 }
00167 
00168 /*******************************************************************
00169 reads or writes SEC_DESC_BUF and SEC_DATA structures.
00170 ********************************************************************/
00171 
00172 static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec,
00173                               SEC_DESC_BUF *data, prs_struct *ps, int depth)
00174 {
00175         if (ptr != 0) {
00176                 uint32 hdr_offset;
00177                 uint32 old_offset;
00178                 if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth,
00179                                       &hdr_offset))
00180                         return False;
00181 
00182                 old_offset = prs_offset(ps);
00183 
00184                 if (ptr3 != NULL) {
00185                         if(!prs_uint32("ptr3", ps, depth, ptr3))
00186                                 return False;
00187                 }
00188 
00189                 if (ptr3 == NULL || *ptr3 != 0) {
00190                         /* JRA - this next line is probably wrong... */
00191                         if(!sec_io_desc_buf("data   ", &data, ps, depth))
00192                                 return False;
00193                 }
00194 
00195                 if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth,
00196                                        hdr_offset, data->max_len, data->len))
00197                                 return False;
00198                 if(!prs_set_offset(ps, old_offset + data->len +
00199                                        sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3)))
00200                         return False;
00201 
00202                 if(!prs_align(ps))
00203                         return False;
00204         }
00205 
00206         return True;
00207 }
00208 
00209 /*******************************************************************
00210  Inits a registry key create request
00211 ********************************************************************/
00212 
00213 void init_reg_q_create_key_ex(REG_Q_CREATE_KEY_EX *q_c, POLICY_HND *hnd,
00214                            char *name, char *key_class, uint32 access_desired,
00215                            SEC_DESC_BUF *sec_buf)
00216 {
00217         ZERO_STRUCTP(q_c);
00218 
00219         memcpy(&q_c->handle, hnd, sizeof(q_c->handle));
00220 
00221 
00222         init_unistr4( &q_c->name, name, UNI_STR_TERMINATE );
00223         init_unistr4( &q_c->key_class, key_class, UNI_STR_TERMINATE );
00224 
00225         q_c->access = access_desired;
00226 
00227         q_c->sec_info = TALLOC_P( get_talloc_ctx(), uint32 );
00228         if (!q_c->sec_info) {
00229                 smb_panic("init_reg_q_create_key_ex: talloc fail\n");
00230                 return;
00231         }
00232         *q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
00233 
00234         q_c->data = sec_buf;
00235         q_c->ptr2 = 1;
00236         init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len);
00237         q_c->ptr3 = 1;
00238         q_c->disposition = TALLOC_P( get_talloc_ctx(), uint32 );
00239         if (!q_c->disposition) {
00240                 smb_panic("init_reg_q_create_key_ex: talloc fail\n");
00241                 return;
00242         }
00243 }
00244 
00245 /*******************************************************************
00246 Marshalls a registry key create request
00247 ********************************************************************/
00248 
00249 BOOL reg_io_q_create_key_ex(const char *desc,  REG_Q_CREATE_KEY_EX *q_u,
00250                          prs_struct *ps, int depth)
00251 {
00252         if ( !q_u )
00253                 return False;
00254 
00255         prs_debug(ps, depth, desc, "reg_io_q_create_key_ex");
00256         depth++;
00257 
00258         if(!prs_align(ps))
00259                 return False;
00260         
00261         if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
00262                 return False;
00263 
00264         if(!prs_unistr4 ("name", ps, depth, &q_u->name))
00265                 return False;
00266         if(!prs_align(ps))
00267                 return False;
00268 
00269         if(!prs_unistr4 ("key_class", ps, depth, &q_u->key_class))
00270                 return False;
00271         if(!prs_align(ps))
00272                 return False;
00273 
00274         if(!prs_uint32("options", ps, depth, &q_u->options))
00275                 return False;
00276         if(!prs_uint32("access", ps, depth, &q_u->access))
00277                 return False;
00278 
00279         if(!prs_pointer("sec_info", ps, depth, (void**)&q_u->sec_info, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
00280                 return False;
00281 
00282         if ( q_u->sec_info ) {
00283                 if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2))
00284                         return False;
00285                 if(!reg_io_hdrbuf_sec(q_u->ptr2, &q_u->ptr3, &q_u->hdr_sec, q_u->data, ps, depth))
00286                         return False;
00287         }
00288 
00289         if(!prs_pointer("disposition", ps, depth, (void**)&q_u->disposition, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
00290                 return False;
00291 
00292         return True;
00293 }
00294 
00295 /*******************************************************************
00296 Unmarshalls a registry key create response
00297 ********************************************************************/
00298 
00299 BOOL reg_io_r_create_key_ex(const char *desc,  REG_R_CREATE_KEY_EX *r_u,
00300                          prs_struct *ps, int depth)
00301 {
00302         if ( !r_u )
00303                 return False;
00304 
00305         prs_debug(ps, depth, desc, "reg_io_r_create_key_ex");
00306         depth++;
00307 
00308         if(!prs_align(ps))
00309                 return False;
00310         
00311         if(!smb_io_pol_hnd("", &r_u->handle, ps, depth))
00312                 return False;
00313         if(!prs_uint32("disposition", ps, depth, &r_u->disposition))
00314                 return False;
00315 
00316         if(!prs_werror("status", ps, depth, &r_u->status))
00317                 return False;
00318 
00319         return True;
00320 }
00321 
00322 
00323 /*******************************************************************
00324  Inits a structure.
00325 ********************************************************************/
00326 
00327 void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd,
00328                            char *name)
00329 {
00330         ZERO_STRUCTP(q_c);
00331 
00332         memcpy(&q_c->handle, hnd, sizeof(q_c->handle));
00333         init_unistr4(&q_c->name, name, UNI_STR_TERMINATE);
00334 }
00335 
00336 /*******************************************************************
00337 reads or writes a structure.
00338 ********************************************************************/
00339 
00340 BOOL reg_io_q_delete_value(const char *desc, REG_Q_DELETE_VALUE *q_u,
00341                          prs_struct *ps, int depth)
00342 {
00343         if ( !q_u )
00344                 return False;
00345 
00346         prs_debug(ps, depth, desc, "reg_io_q_delete_value");
00347         depth++;
00348 
00349         if(!prs_align(ps))
00350                 return False;
00351         
00352         if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
00353                 return False;
00354 
00355         if(!prs_unistr4("name", ps, depth, &q_u->name))
00356                 return False;
00357 
00358         return True;
00359 }
00360 
00361 
00362 /*******************************************************************
00363 reads or writes a structure.
00364 ********************************************************************/
00365 
00366 BOOL reg_io_r_delete_value(const char *desc,  REG_R_DELETE_VALUE *r_u,
00367                          prs_struct *ps, int depth)
00368 {
00369         if ( !r_u )
00370                 return False;
00371 
00372         prs_debug(ps, depth, desc, "reg_io_r_delete_value");
00373         depth++;
00374 
00375         if(!prs_align(ps))
00376                 return False;
00377         
00378         if(!prs_werror("status", ps, depth, &r_u->status))
00379                 return False;
00380 
00381         return True;
00382 }
00383 
00384 /*******************************************************************
00385  Inits a structure.
00386 ********************************************************************/
00387 
00388 void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
00389                            char *name)
00390 {
00391         ZERO_STRUCTP(q_c);
00392 
00393         memcpy(&q_c->handle, hnd, sizeof(q_c->handle));
00394 
00395         init_unistr4(&q_c->name, name, UNI_STR_TERMINATE);
00396 }
00397 
00398 /*******************************************************************
00399 reads or writes a structure.
00400 ********************************************************************/
00401 
00402 BOOL reg_io_q_delete_key(const char *desc,  REG_Q_DELETE_KEY *q_u,
00403                          prs_struct *ps, int depth)
00404 {
00405         if ( !q_u )
00406                 return False;
00407 
00408         prs_debug(ps, depth, desc, "reg_io_q_delete_key");
00409         depth++;
00410 
00411         if(!prs_align(ps))
00412                 return False;
00413         
00414         if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
00415                 return False;
00416 
00417         if(!prs_unistr4("", ps, depth, &q_u->name))
00418                 return False;
00419 
00420         return True;
00421 }
00422 
00423 /*******************************************************************
00424 reads or writes a structure.
00425 ********************************************************************/
00426 
00427 BOOL reg_io_r_delete_key(const char *desc,  REG_R_DELETE_KEY *r_u, prs_struct *ps, int depth)
00428 {
00429         if ( !r_u )
00430                 return False;
00431 
00432         prs_debug(ps, depth, desc, "reg_io_r_delete_key");
00433         depth++;
00434 
00435         if(!prs_align(ps))
00436                 return False;
00437         
00438         if(!prs_werror("status", ps, depth, &r_u->status))
00439                 return False;
00440 
00441         return True;
00442 }
00443 
00444 /*******************************************************************
00445  Inits a structure.
00446 ********************************************************************/
00447 
00448 void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, const char *key_class)
00449 {
00450         ZERO_STRUCTP(q_o);
00451 
00452         memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
00453         init_unistr4(&q_o->key_class, key_class, UNI_STR_TERMINATE);
00454 }
00455 
00456 /*******************************************************************
00457 reads or writes a structure.
00458 ********************************************************************/
00459 
00460 BOOL reg_io_q_query_key(const char *desc,  REG_Q_QUERY_KEY *q_u, prs_struct *ps, int depth)
00461 {
00462         if ( !q_u )
00463                 return False;
00464 
00465         prs_debug(ps, depth, desc, "reg_io_q_query_key");
00466         depth++;
00467 
00468         if(!prs_align(ps))
00469                 return False;
00470         
00471         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
00472                 return False;
00473         if(!prs_unistr4("key_class", ps, depth, &q_u->key_class))
00474                 return False;
00475 
00476         return True;
00477 }
00478 
00479 
00480 /*******************************************************************
00481 reads or writes a structure.
00482 ********************************************************************/
00483 
00484 BOOL reg_io_r_query_key(const char *desc,  REG_R_QUERY_KEY *r_u, prs_struct *ps, int depth)
00485 {
00486         if ( !r_u )
00487                 return False;
00488 
00489         prs_debug(ps, depth, desc, "reg_io_r_query_key");
00490         depth++;
00491 
00492         if(!prs_align(ps))
00493                 return False;
00494         
00495         if(!prs_unistr4("key_class", ps, depth, &r_u->key_class))
00496                 return False;
00497 
00498         if(!prs_align(ps))
00499                 return False;
00500 
00501         if(!prs_uint32("num_subkeys   ", ps, depth, &r_u->num_subkeys))
00502                 return False;
00503         if(!prs_uint32("max_subkeylen ", ps, depth, &r_u->max_subkeylen))
00504                 return False;
00505         if(!prs_uint32("reserved      ", ps, depth, &r_u->reserved))
00506                 return False;
00507         if(!prs_uint32("num_values    ", ps, depth, &r_u->num_values))
00508                 return False;
00509         if(!prs_uint32("max_valnamelen", ps, depth, &r_u->max_valnamelen))
00510                 return False;
00511         if(!prs_uint32("max_valbufsize", ps, depth, &r_u->max_valbufsize))
00512                 return False;
00513         if(!prs_uint32("sec_desc      ", ps, depth, &r_u->sec_desc))
00514                 return False;
00515         if(!smb_io_time("mod_time     ", &r_u->mod_time, ps, depth))
00516                 return False;
00517 
00518         if(!prs_werror("status", ps, depth, &r_u->status))
00519                 return False;
00520 
00521         return True;
00522 }
00523 
00524 /*******************************************************************
00525  Inits a structure.
00526 ********************************************************************/
00527 
00528 void init_reg_q_getversion(REG_Q_GETVERSION *q_o, POLICY_HND *hnd)
00529 {
00530         memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
00531 }
00532 
00533 
00534 /*******************************************************************
00535 reads or writes a structure.
00536 ********************************************************************/
00537 
00538 BOOL reg_io_q_getversion(const char *desc,  REG_Q_GETVERSION *q_u, prs_struct *ps, int depth)
00539 {
00540         if ( !q_u )
00541                 return False;
00542 
00543         prs_debug(ps, depth, desc, "reg_io_q_getversion");
00544         depth++;
00545 
00546         if(!prs_align(ps))
00547                 return False;
00548 
00549         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
00550                 return False;
00551 
00552         return True;
00553 }
00554 
00555 /*******************************************************************
00556 reads or writes a structure.
00557 ********************************************************************/
00558 
00559 BOOL reg_io_r_getversion(const char *desc,  REG_R_GETVERSION *r_u, prs_struct *ps, int depth)
00560 {
00561         if ( !r_u )
00562                 return False;
00563 
00564         prs_debug(ps, depth, desc, "reg_io_r_getversion");
00565         depth++;
00566 
00567         if(!prs_align(ps))
00568                 return False;
00569 
00570         if(!prs_uint32("win_version", ps, depth, &r_u->win_version))
00571                 return False;
00572         if(!prs_werror("status" , ps, depth, &r_u->status))
00573                 return False;
00574 
00575         return True;
00576 }
00577 
00578 
00579 /*******************************************************************
00580 reads or writes a structure.
00581 ********************************************************************/
00582 
00583 BOOL reg_io_q_restore_key(const char *desc,  REG_Q_RESTORE_KEY *q_u, prs_struct *ps, int depth)
00584 {
00585         if ( !q_u )
00586                 return False;
00587 
00588         prs_debug(ps, depth, desc, "reg_io_q_restore_key");
00589         depth++;
00590 
00591         if(!prs_align(ps))
00592                 return False;
00593 
00594         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
00595                 return False;
00596 
00597         if(!prs_unistr4("filename", ps, depth, &q_u->filename))
00598                 return False;
00599 
00600         if(!prs_uint32("flags", ps, depth, &q_u->flags))
00601                 return False;
00602 
00603         return True;
00604 }
00605 
00606 /*******************************************************************
00607 reads or writes a structure.
00608 ********************************************************************/
00609 
00610 BOOL reg_io_r_restore_key(const char *desc,  REG_R_RESTORE_KEY *r_u, prs_struct *ps, int depth)
00611 {
00612         if ( !r_u )
00613                 return False;
00614 
00615         prs_debug(ps, depth, desc, "reg_io_r_restore_key");
00616         depth++;
00617 
00618         if(!prs_align(ps))
00619                 return False;
00620         
00621         if(!prs_werror("status" , ps, depth, &r_u->status))
00622                 return False;
00623 
00624         return True;
00625 }
00626 
00627 /*******************************************************************
00628 ********************************************************************/
00629 
00630 void init_q_reg_save_key( REG_Q_SAVE_KEY *q_u, POLICY_HND *handle, const char *fname )
00631 {
00632         memcpy(&q_u->pol, handle, sizeof(q_u->pol));
00633         init_unistr4( &q_u->filename, fname, UNI_STR_TERMINATE );
00634         q_u->sec_attr = NULL;
00635 }
00636 
00637 /*******************************************************************
00638 reads or writes a structure.
00639 ********************************************************************/
00640 
00641 BOOL reg_io_q_save_key(const char *desc,  REG_Q_SAVE_KEY *q_u, prs_struct *ps, int depth)
00642 {
00643         if ( !q_u )
00644                 return False;
00645 
00646         prs_debug(ps, depth, desc, "reg_io_q_save_key");
00647         depth++;
00648 
00649         if(!prs_align(ps))
00650                 return False;
00651 
00652         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
00653                 return False;
00654 
00655         if(!prs_unistr4("filename", ps, depth, &q_u->filename))
00656                 return False;
00657 
00658 #if 0   /* reg_io_sec_attr() */
00659         if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
00660                 return False;
00661 #endif
00662 
00663         return True;
00664 }
00665 
00666 /*******************************************************************
00667 reads or writes a structure.
00668 ********************************************************************/
00669 
00670 BOOL reg_io_r_save_key(const char *desc,  REG_R_SAVE_KEY *r_u, prs_struct *ps, int depth)
00671 {
00672         if ( !r_u )
00673                 return False;
00674 
00675         prs_debug(ps, depth, desc, "reg_io_r_save_key");
00676         depth++;
00677 
00678         if(!prs_align(ps))
00679                 return False;
00680         
00681         if(!prs_werror("status" , ps, depth, &r_u->status))
00682                 return False;
00683 
00684         return True;
00685 }
00686 
00687 /*******************************************************************
00688  Inits an REG_Q_CLOSE structure.
00689 ********************************************************************/
00690 
00691 void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd)
00692 {
00693         DEBUG(5,("init_reg_q_close\n"));
00694 
00695         memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
00696 }
00697 
00698 /*******************************************************************
00699 reads or writes a structure.
00700 ********************************************************************/
00701 
00702 BOOL reg_io_q_close(const char *desc,  REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
00703 {
00704         if (q_u == NULL)
00705                 return False;
00706 
00707         prs_debug(ps, depth, desc, "reg_io_q_close");
00708         depth++;
00709 
00710         if(!prs_align(ps))
00711                 return False;
00712 
00713         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
00714                 return False;
00715         if(!prs_align(ps))
00716                 return False;
00717 
00718         return True;
00719 }
00720 
00721 /*******************************************************************
00722 reads or writes a structure.
00723 ********************************************************************/
00724 
00725 BOOL reg_io_r_close(const char *desc,  REG_R_CLOSE *r_u, prs_struct *ps, int depth)
00726 {
00727         if ( !r_u )
00728                 return False;
00729 
00730         prs_debug(ps, depth, desc, "reg_io_r_close");
00731         depth++;
00732 
00733         if(!prs_align(ps))
00734                 return False;
00735 
00736         if(!smb_io_pol_hnd("", &r_u->pol, ps, depth))
00737                 return False;
00738         if(!prs_align(ps))
00739                 return False;
00740 
00741         if(!prs_werror("status", ps, depth, &r_u->status))
00742                 return False;
00743 
00744         return True;
00745 }
00746 
00747 /*******************************************************************
00748 makes a structure.
00749 ********************************************************************/
00750 
00751 void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_u, POLICY_HND *pol,
00752                             uint32 sec_info, SEC_DESC_BUF *sec_desc_buf)
00753 {
00754         memcpy(&q_u->handle, pol, sizeof(q_u->handle));
00755 
00756         q_u->sec_info = sec_info;
00757 
00758         q_u->ptr = 1;
00759         init_buf_hdr(&q_u->hdr_sec, sec_desc_buf->len, sec_desc_buf->len);
00760         q_u->data = sec_desc_buf;
00761 }
00762 
00763 /*******************************************************************
00764 reads or writes a structure.
00765 ********************************************************************/
00766 
00767 BOOL reg_io_q_set_key_sec(const char *desc,  REG_Q_SET_KEY_SEC *q_u, prs_struct *ps, int depth)
00768 {
00769         if ( !q_u )
00770                 return False;
00771 
00772         prs_debug(ps, depth, desc, "reg_io_q_set_key_sec");
00773         depth++;
00774 
00775         if(!prs_align(ps))
00776                 return False;
00777         
00778         if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
00779                 return False;
00780 
00781         if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
00782                 return False;
00783         if(!prs_uint32("ptr    ", ps, depth, &q_u->ptr))
00784                 return False;
00785 
00786         if(!reg_io_hdrbuf_sec(q_u->ptr, NULL, &q_u->hdr_sec, q_u->data, ps, depth))
00787                 return False;
00788 
00789         return True;
00790 }
00791 
00792 /*******************************************************************
00793 reads or writes a structure.
00794 ********************************************************************/
00795 
00796 BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *q_u, prs_struct *ps, int depth)
00797 {
00798         if ( !q_u )
00799                 return False;
00800 
00801         prs_debug(ps, depth, desc, "reg_io_r_set_key_sec");
00802         depth++;
00803 
00804         if(!prs_align(ps))
00805                 return False;
00806         
00807         if(!prs_werror("status", ps, depth, &q_u->status))
00808                 return False;
00809 
00810         return True;
00811 }
00812 
00813 
00814 /*******************************************************************
00815 makes a structure.
00816 ********************************************************************/
00817 
00818 void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_u, POLICY_HND *pol, 
00819                             uint32 sec_info, uint32 sec_buf_size,
00820                             SEC_DESC_BUF *psdb)
00821 {
00822         memcpy(&q_u->handle, pol, sizeof(q_u->handle));
00823 
00824         q_u->sec_info = sec_info;
00825 
00826         q_u->ptr = psdb != NULL ? 1 : 0;
00827         q_u->data = psdb;
00828 
00829         init_buf_hdr(&q_u->hdr_sec, sec_buf_size, 0);
00830 }
00831 
00832 /*******************************************************************
00833 reads or writes a structure.
00834 ********************************************************************/
00835 
00836 BOOL reg_io_q_get_key_sec(const char *desc,  REG_Q_GET_KEY_SEC *q_u, prs_struct *ps, int depth)
00837 {
00838         if ( !q_u )
00839                 return False;
00840 
00841         prs_debug(ps, depth, desc, "reg_io_q_get_key_sec");
00842         depth++;
00843 
00844         if(!prs_align(ps))
00845                 return False;
00846         
00847         if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
00848                 return False;
00849 
00850         if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
00851                 return False;
00852         if(!prs_uint32("ptr     ", ps, depth, &q_u->ptr))
00853                 return False;
00854 
00855         if(!reg_io_hdrbuf_sec(q_u->ptr, NULL, &q_u->hdr_sec, q_u->data, ps, depth))
00856                 return False;
00857 
00858         return True;
00859 }
00860 
00861 #if 0
00862 /*******************************************************************
00863 makes a structure.
00864 ********************************************************************/
00865  void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol, 
00866                                 uint32 buf_len, uint8 *buf,
00867                                 NTSTATUS status)
00868 {
00869         r_i->ptr = 1;
00870         init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len);
00871         init_sec_desc_buf(r_i->data, buf_len, 1);
00872 
00873         r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
00874 }
00875 #endif 
00876 
00877 /*******************************************************************
00878 reads or writes a structure.
00879 ********************************************************************/
00880 
00881 BOOL reg_io_r_get_key_sec(const char *desc,  REG_R_GET_KEY_SEC *q_u, prs_struct *ps, int depth)
00882 {
00883         if ( !q_u )
00884                 return False;
00885 
00886         prs_debug(ps, depth, desc, "reg_io_r_get_key_sec");
00887         depth++;
00888 
00889         if(!prs_align(ps))
00890                 return False;
00891         
00892         if(!prs_uint32("ptr      ", ps, depth, &q_u->ptr))
00893                 return False;
00894 
00895         if (q_u->ptr != 0) {
00896                 if(!smb_io_hdrbuf("", &q_u->hdr_sec, ps, depth))
00897                         return False;
00898                 if(!sec_io_desc_buf("", &q_u->data, ps, depth))
00899                         return False;
00900                 if(!prs_align(ps))
00901                         return False;
00902         }
00903 
00904         if(!prs_werror("status", ps, depth, &q_u->status))
00905                 return False;
00906 
00907         return True;
00908 }
00909 
00910 /*******************************************************************
00911 makes a structure.
00912 ********************************************************************/
00913 
00914 BOOL init_reg_q_query_value(REG_Q_QUERY_VALUE *q_u, POLICY_HND *pol, const char *val_name,
00915                      REGVAL_BUFFER *value_output)
00916 {
00917         if (q_u == NULL)
00918                 return False;
00919 
00920         q_u->pol = *pol;
00921 
00922         init_unistr4(&q_u->name, val_name, UNI_STR_TERMINATE);
00923 
00924         q_u->ptr_reserved = 1;
00925         q_u->ptr_buf = 1;
00926 
00927         q_u->ptr_bufsize = 1;
00928         q_u->bufsize = value_output->buf_max_len;
00929         q_u->buf_unk = 0;
00930 
00931         q_u->unk1 = 0;
00932         q_u->ptr_buflen = 1;
00933         q_u->buflen = value_output->buf_max_len; 
00934 
00935         q_u->ptr_buflen2 = 1;
00936         q_u->buflen2 = 0;
00937 
00938         return True;
00939 }
00940 
00941 /*******************************************************************
00942 reads or writes a structure.
00943 ********************************************************************/
00944 
00945 BOOL reg_io_q_query_value(const char *desc,  REG_Q_QUERY_VALUE *q_u, prs_struct *ps, int depth)
00946 {
00947         if ( !q_u )
00948                 return False;
00949 
00950         prs_debug(ps, depth, desc, "reg_io_q_query_value");
00951         depth++;
00952 
00953         if(!prs_align(ps))
00954                 return False;
00955         
00956         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
00957                 return False;
00958         if(!prs_unistr4("name", ps, depth, &q_u->name))
00959                 return False;
00960 
00961         if(!prs_align(ps))
00962                 return False;
00963         
00964         if(!prs_uint32("ptr_reserved", ps, depth, &(q_u->ptr_reserved)))
00965                 return False;
00966 
00967         if(!prs_uint32("ptr_buf", ps, depth, &(q_u->ptr_buf)))
00968                 return False;
00969 
00970         if(q_u->ptr_buf) {
00971                 if(!prs_uint32("ptr_bufsize", ps, depth, &(q_u->ptr_bufsize)))
00972                         return False;
00973                 if(!prs_uint32("bufsize", ps, depth, &(q_u->bufsize)))
00974                         return False;
00975                 if(!prs_uint32("buf_unk", ps, depth, &(q_u->buf_unk)))
00976                         return False;
00977         }
00978 
00979         if(!prs_uint32("unk1", ps, depth, &(q_u->unk1)))
00980                 return False;
00981 
00982         if(!prs_uint32("ptr_buflen", ps, depth, &(q_u->ptr_buflen)))
00983                 return False;
00984 
00985         if (q_u->ptr_buflen) {
00986                 if(!prs_uint32("buflen", ps, depth, &(q_u->buflen)))
00987                         return False;
00988                 if(!prs_uint32("ptr_buflen2", ps, depth, &(q_u->ptr_buflen2)))
00989                         return False;
00990                 if(!prs_uint32("buflen2", ps, depth, &(q_u->buflen2)))
00991                         return False;
00992         }
00993 
00994         return True;
00995 }
00996 
00997 /*******************************************************************
00998  Inits a structure.
00999  New version to replace older init_reg_r_query_value()
01000 ********************************************************************/
01001 
01002 BOOL init_reg_r_query_value(uint32 include_keyval, REG_R_QUERY_VALUE *r_u,
01003                      REGISTRY_VALUE *val, WERROR status)
01004 {
01005         uint32                  buf_len = 0;
01006         REGVAL_BUFFER           buf2;
01007                 
01008         if( !r_u || !val )
01009                 return False;
01010         
01011         r_u->type = TALLOC_P( get_talloc_ctx(), uint32 );
01012         if (!r_u->type) {
01013                 return False;
01014         }
01015         *r_u->type = val->type;
01016 
01017         buf_len = reg_init_regval_buffer( &buf2, val );
01018         
01019         r_u->buf_max_len = TALLOC_P( get_talloc_ctx(), uint32 );
01020         if (!r_u->buf_max_len) {
01021                 return False;
01022         }
01023         *r_u->buf_max_len = buf_len;
01024 
01025         r_u->buf_len = TALLOC_P( get_talloc_ctx(), uint32 );
01026         if (!r_u->buf_len) {
01027                 return False;
01028         }
01029         *r_u->buf_len = buf_len;
01030         
01031         /* if include_keyval is not set, don't send the key value, just
01032            the buflen data. probably used by NT5 to allocate buffer space - SK */
01033 
01034         if ( include_keyval ) {
01035                 r_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER );
01036                 if (!r_u->value) {
01037                         return False;
01038                 }
01039                 /* steal the memory */
01040                 *r_u->value = buf2;
01041         }
01042 
01043         r_u->status = status;
01044 
01045         return True;
01046 }
01047 
01048 /*******************************************************************
01049 reads or writes a structure.
01050 ********************************************************************/
01051 
01052 BOOL reg_io_r_query_value(const char *desc, REG_R_QUERY_VALUE *r_u, prs_struct *ps, int depth)
01053 {
01054         if ( !r_u )
01055                 return False;
01056 
01057         prs_debug(ps, depth, desc, "reg_io_r_query_value");
01058         depth++;
01059 
01060         if(!prs_align(ps))
01061                 return False;
01062         
01063         if ( !prs_pointer("type", ps, depth, (void**)&r_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01064                 return False;
01065 
01066         if ( !prs_pointer("value", ps, depth, (void**)&r_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer))
01067                 return False;
01068         if(!prs_align(ps))
01069                 return False;
01070 
01071         if ( !prs_pointer("buf_max_len", ps, depth, (void**)&r_u->buf_max_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01072                 return False;
01073         if ( !prs_pointer("buf_len", ps, depth, (void**)&r_u->buf_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01074                 return False;
01075 
01076         if(!prs_werror("status", ps, depth, &r_u->status))
01077                 return False;
01078 
01079         return True;
01080 }
01081 
01082 /*******************************************************************
01083 makes a structure.
01084 ********************************************************************/
01085 
01086 void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_u, POLICY_HND *pol,
01087                                 uint32 val_idx,
01088                                 uint32 max_name_len, uint32 max_buf_len)
01089 {
01090         ZERO_STRUCTP(q_u);
01091 
01092         memcpy(&q_u->pol, pol, sizeof(q_u->pol));
01093 
01094         q_u->val_index = val_idx;
01095 
01096         q_u->name.size = max_name_len*2;
01097         q_u->name.string = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR2 );
01098         if (!q_u->name.string) {
01099                 smb_panic("init_reg_q_enum_val: talloc fail\n");
01100                 return;
01101         }
01102         q_u->name.string->uni_max_len = max_name_len;
01103         
01104         q_u->type = TALLOC_P( get_talloc_ctx(), uint32 );
01105         if (!q_u->type) {
01106                 smb_panic("init_reg_q_enum_val: talloc fail\n");
01107                 return;
01108         }
01109         *q_u->type = 0x0;
01110 
01111         q_u->value = TALLOC_ZERO_P( get_talloc_ctx(), REGVAL_BUFFER );
01112         if (!q_u->value) {
01113                 smb_panic("init_reg_q_enum_val: talloc fail\n");
01114                 return;
01115         }
01116                 
01117         q_u->value->buf_max_len = max_buf_len;
01118 
01119         q_u->buffer_len = TALLOC_P( get_talloc_ctx(), uint32 );
01120         if (!q_u->buffer_len) {
01121                 smb_panic("init_reg_q_enum_val: talloc fail\n");
01122                 return;
01123         }
01124         *q_u->buffer_len = max_buf_len;
01125 
01126         q_u->name_len = TALLOC_P( get_talloc_ctx(), uint32 );
01127         if (!q_u->name_len) {
01128                 smb_panic("init_reg_q_enum_val: talloc fail\n");
01129                 return;
01130         }
01131         *q_u->name_len = 0x0;
01132 }
01133 
01134 /*******************************************************************
01135 makes a structure.
01136 ********************************************************************/
01137 
01138 void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val )
01139 {
01140         uint32 real_size;
01141         
01142         ZERO_STRUCTP(r_u);
01143 
01144         /* value name */
01145 
01146         DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename));
01147         
01148         init_unistr4( &r_u->name, val->valuename, UNI_STR_TERMINATE);
01149                 
01150         /* type */
01151         
01152         r_u->type = TALLOC_P( get_talloc_ctx(), uint32 );
01153         if (!r_u->type) {
01154                 smb_panic("init_reg_r_enum_val: talloc fail\n");
01155                 return;
01156         }
01157         *r_u->type = val->type;
01158 
01159         /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */
01160         
01161         r_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER );
01162         if (!r_u->value) {
01163                 smb_panic("init_reg_r_enum_val: talloc fail\n");
01164                 return;
01165         }
01166         real_size = reg_init_regval_buffer( r_u->value, val );
01167         
01168         /* lengths */
01169 
01170         r_u->buffer_len1 = TALLOC_P( get_talloc_ctx(), uint32 );
01171         if (!r_u->buffer_len1) {
01172                 smb_panic("init_reg_r_enum_val: talloc fail\n");
01173                 return;
01174         }
01175         *r_u->buffer_len1 = real_size;
01176         r_u->buffer_len2 = TALLOC_P( get_talloc_ctx(), uint32 );
01177         if (!r_u->buffer_len2) {
01178                 smb_panic("init_reg_r_enum_val: talloc fail\n");
01179                 return;
01180         }
01181         *r_u->buffer_len2 = real_size;
01182 }
01183 
01184 /*******************************************************************
01185 reads or writes a structure.
01186 ********************************************************************/
01187 
01188 BOOL reg_io_q_enum_val(const char *desc,  REG_Q_ENUM_VALUE *q_u, prs_struct *ps, int depth)
01189 {
01190         if (q_u == NULL)
01191                 return False;
01192 
01193         prs_debug(ps, depth, desc, "reg_io_q_enum_val");
01194         depth++;
01195 
01196         if(!prs_align(ps))
01197                 return False;
01198         
01199         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
01200                 return False;
01201         
01202         if(!prs_uint32("val_index", ps, depth, &q_u->val_index))
01203                 return False;
01204                 
01205         if(!prs_unistr4("name", ps, depth, &q_u->name ))
01206                 return False;
01207         if(!prs_align(ps))
01208                 return False;
01209 
01210         if(!prs_pointer("type", ps, depth, (void**)&q_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01211                 return False;
01212 
01213         if ( !prs_pointer("value", ps, depth, (void**)&q_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer))
01214                 return False;
01215         if(!prs_align(ps))
01216                 return False;
01217 
01218         if(!prs_pointer("buffer_len", ps, depth, (void**)&q_u->buffer_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01219                 return False;
01220         if(!prs_pointer("name_len", ps, depth, (void**)&q_u->name_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01221                 return False;
01222 
01223         return True;
01224 }
01225 
01226 /*******************************************************************
01227 reads or writes a structure.
01228 ********************************************************************/
01229 
01230 BOOL reg_io_r_enum_val(const char *desc,  REG_R_ENUM_VALUE *r_u, prs_struct *ps, int depth)
01231 {
01232         if ( !r_u )
01233                 return False;
01234 
01235         prs_debug(ps, depth, desc, "reg_io_r_enum_val");
01236         depth++;
01237 
01238         if(!prs_align(ps))
01239                 return False;
01240         
01241         if(!prs_unistr4("name", ps, depth, &r_u->name ))
01242                 return False;
01243         if(!prs_align(ps))
01244                 return False;
01245 
01246         if(!prs_pointer("type", ps, depth, (void**)&r_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01247                 return False;
01248 
01249         if ( !prs_pointer("value", ps, depth, (void**)&r_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer))
01250                 return False;
01251         if(!prs_align(ps))
01252                 return False;
01253 
01254         if(!prs_pointer("buffer_len1", ps, depth, (void**)&r_u->buffer_len1, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01255                 return False;
01256         if(!prs_pointer("buffer_len2", ps, depth, (void**)&r_u->buffer_len2, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32))
01257                 return False;
01258 
01259         if(!prs_werror("status", ps, depth, &r_u->status))
01260                 return False;
01261 
01262         return True;
01263 }
01264 
01265 /*******************************************************************
01266 makes a structure.
01267 ********************************************************************/
01268 
01269 void init_reg_q_set_val(REG_Q_SET_VALUE *q_u, POLICY_HND *pol,
01270                                 char *val_name, uint32 type,
01271                                 RPC_DATA_BLOB *val)
01272 {
01273         ZERO_STRUCTP(q_u);
01274 
01275         memcpy(&q_u->handle, pol, sizeof(q_u->handle));
01276 
01277         init_unistr4(&q_u->name, val_name, UNI_STR_TERMINATE);
01278         
01279         q_u->type      = type;
01280         q_u->value     = *val;
01281         q_u->size      = val->buf_len;
01282 }
01283 
01284 /*******************************************************************
01285 reads or writes a structure.
01286 ********************************************************************/
01287 
01288 BOOL reg_io_q_set_value(const char *desc,  REG_Q_SET_VALUE *q_u, prs_struct *ps, int depth)
01289 {
01290         if (q_u == NULL)
01291                 return False;
01292 
01293         prs_debug(ps, depth, desc, "reg_io_q_set_value");
01294         depth++;
01295 
01296         if(!prs_align(ps))
01297                 return False;
01298         
01299         if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
01300                 return False;
01301         
01302         if(!prs_unistr4("name", ps, depth, &q_u->name ))
01303                 return False;
01304         if(!prs_align(ps))
01305                 return False;
01306 
01307         if(!prs_uint32("type", ps, depth, &q_u->type))
01308                 return False;
01309 
01310         if(!smb_io_rpc_blob("value", &q_u->value, ps, depth ))
01311                 return False;
01312         if(!prs_align(ps))
01313                 return False;
01314 
01315         if(!prs_uint32("size", ps, depth, &q_u->size))
01316                 return False;
01317 
01318         return True;
01319 }
01320 
01321 /*******************************************************************
01322 reads or writes a structure.
01323 ********************************************************************/
01324 
01325 BOOL reg_io_r_set_value(const char *desc,  REG_R_SET_VALUE *q_u, prs_struct *ps, int depth)
01326 {
01327         if ( !q_u )
01328                 return False;
01329 
01330         prs_debug(ps, depth, desc, "reg_io_r_set_value");
01331         depth++;
01332 
01333         if(!prs_align(ps))
01334                 return False;
01335         
01336         if(!prs_werror("status", ps, depth, &q_u->status))
01337                 return False;
01338 
01339         return True;
01340 }
01341 
01342 /*******************************************************************
01343 makes a structure.
01344 ********************************************************************/
01345 
01346 void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_u, POLICY_HND *pol, uint32 key_idx)
01347 {
01348         memcpy(&q_u->pol, pol, sizeof(q_u->pol));
01349 
01350         q_u->key_index = key_idx;
01351         q_u->key_name_len = 0;
01352         q_u->unknown_1 = 0x0414;
01353 
01354         q_u->ptr1 = 1;
01355         q_u->unknown_2 = 0x0000020A;
01356         memset(q_u->pad1, 0, sizeof(q_u->pad1));
01357 
01358         q_u->ptr2 = 1;
01359         memset(q_u->pad2, 0, sizeof(q_u->pad2));
01360 
01361         q_u->ptr3 = 1;
01362         unix_to_nt_time(&q_u->time, 0);            /* current time? */
01363 }
01364 
01365 /*******************************************************************
01366 makes a reply structure.
01367 ********************************************************************/
01368 
01369 void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey )
01370 {
01371         if ( !r_u )
01372                 return;
01373                 
01374         init_unistr4( &r_u->keyname, subkey, UNI_STR_TERMINATE );
01375         r_u->classname = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 );
01376         if (!r_u->classname) {
01377                 smb_panic("init_reg_r_enum_key: talloc fail\n");
01378                 return;
01379         }
01380         r_u->time = TALLOC_ZERO_P( get_talloc_ctx(), NTTIME );
01381         if (!r_u->time) {
01382                 smb_panic("init_reg_r_enum_key: talloc fail\n");
01383                 return;
01384         }
01385 }
01386 
01387 /*******************************************************************
01388 reads or writes a structure.
01389 ********************************************************************/
01390 
01391 BOOL reg_io_q_enum_key(const char *desc,  REG_Q_ENUM_KEY *q_u, prs_struct *ps, int depth)
01392 {
01393         if (q_u == NULL)
01394                 return False;
01395 
01396         prs_debug(ps, depth, desc, "reg_io_q_enum_key");
01397         depth++;
01398 
01399         if(!prs_align(ps))
01400                 return False;
01401         
01402         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
01403                 return False;
01404         
01405         if(!prs_uint32("key_index", ps, depth, &q_u->key_index))
01406                 return False;
01407         if(!prs_uint16("key_name_len", ps, depth, &q_u->key_name_len))
01408                 return False;
01409         if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
01410                 return False;
01411 
01412         if(!prs_uint32("ptr1", ps, depth, &q_u->ptr1))
01413                 return False;
01414 
01415         if (q_u->ptr1 != 0) {
01416                 if(!prs_uint32("unknown_2", ps, depth, &q_u->unknown_2))
01417                         return False;
01418                 if(!prs_uint8s(False, "pad1", ps, depth, q_u->pad1, sizeof(q_u->pad1)))
01419                         return False;
01420         }
01421 
01422         if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2))
01423                 return False;
01424 
01425         if (q_u->ptr2 != 0) {
01426                 if(!prs_uint8s(False, "pad2", ps, depth, q_u->pad2, sizeof(q_u->pad2)))
01427                         return False;
01428         }
01429 
01430         if(!prs_uint32("ptr3", ps, depth, &q_u->ptr3))
01431                 return False;
01432 
01433         if (q_u->ptr3 != 0) {
01434                 if(!smb_io_time("", &q_u->time, ps, depth))
01435                         return False;
01436         }
01437 
01438         return True;
01439 }
01440 
01441 /*******************************************************************
01442 reads or writes a structure.
01443 ********************************************************************/
01444 
01445 BOOL reg_io_r_enum_key(const char *desc,  REG_R_ENUM_KEY *q_u, prs_struct *ps, int depth)
01446 {
01447         if ( !q_u )
01448                 return False;
01449 
01450         prs_debug(ps, depth, desc, "reg_io_r_enum_key");
01451         depth++;
01452 
01453         if(!prs_align(ps))
01454                 return False;
01455         if ( !prs_unistr4( "keyname", ps, depth, &q_u->keyname ) )
01456                 return False;
01457         
01458         if(!prs_align(ps))
01459                 return False;
01460         if (!prs_pointer("class", ps, depth, (void**)&q_u->classname, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
01461                 return False;
01462 
01463         if(!prs_align(ps))
01464                 return False;
01465         if (!prs_pointer("time", ps, depth, (void**)&q_u->time, sizeof(NTTIME), (PRS_POINTER_CAST)smb_io_nttime))
01466                 return False;
01467 
01468         if(!prs_align(ps))
01469                 return False;
01470         if(!prs_werror("status", ps, depth, &q_u->status))
01471                 return False;
01472 
01473         return True;
01474 }
01475 
01476 /*******************************************************************
01477 makes a structure.
01478 ********************************************************************/
01479 
01480 void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *q_u, POLICY_HND *pol,
01481                                 char *key_name, uint32 access_desired)
01482 {
01483         memcpy(&q_u->pol, pol, sizeof(q_u->pol));
01484 
01485         init_unistr4(&q_u->name, key_name, UNI_STR_TERMINATE);
01486 
01487         q_u->unknown_0 = 0x00000000;
01488         q_u->access = access_desired;
01489 }
01490 
01491 /*******************************************************************
01492 reads or writes a structure.
01493 ********************************************************************/
01494 
01495 BOOL reg_io_q_open_entry(const char *desc,  REG_Q_OPEN_ENTRY *q_u, prs_struct *ps, int depth)
01496 {
01497         if ( !q_u )
01498                 return False;
01499 
01500         prs_debug(ps, depth, desc, "reg_io_q_open_entry");
01501         depth++;
01502 
01503         if(!prs_align(ps))
01504                 return False;
01505         
01506         if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
01507                 return False;
01508         if(!prs_unistr4("name", ps, depth, &q_u->name))
01509                 return False;
01510 
01511         if(!prs_align(ps))
01512                 return False;
01513         
01514         if(!prs_uint32("unknown_0        ", ps, depth, &q_u->unknown_0))
01515                 return False;
01516         if(!prs_uint32("access", ps, depth, &q_u->access))
01517                 return False;
01518 
01519         return True;
01520 }
01521 
01522 /*******************************************************************
01523 reads or writes a structure.
01524 ********************************************************************/
01525 
01526 BOOL reg_io_r_open_entry(const char *desc,  REG_R_OPEN_ENTRY *r_u, prs_struct *ps, int depth)
01527 {
01528         if ( !r_u )
01529                 return False;
01530 
01531         prs_debug(ps, depth, desc, "reg_io_r_open_entry");
01532         depth++;
01533 
01534         if(!prs_align(ps))
01535                 return False;
01536         
01537         if(!smb_io_pol_hnd("handle", &r_u->handle, ps, depth))
01538                 return False;
01539 
01540         if(!prs_werror("status", ps, depth, &r_u->status))
01541                 return False;
01542 
01543         return True;
01544 }
01545 
01546 /*******************************************************************
01547 Inits a structure.
01548 ********************************************************************/
01549 
01550 void init_reg_q_shutdown(REG_Q_SHUTDOWN *q_u, const char *msg,
01551                         uint32 timeout, BOOL do_reboot, BOOL force)
01552 {
01553         q_u->server = TALLOC_P( get_talloc_ctx(), uint16 );
01554         if (!q_u->server) {
01555                 smb_panic("init_reg_q_shutdown: talloc fail\n");
01556                 return;
01557         }
01558         *q_u->server = 0x1;
01559 
01560         q_u->message = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 );
01561         if (!q_u->message) {
01562                 smb_panic("init_reg_q_shutdown: talloc fail\n");
01563                 return;
01564         }
01565 
01566         if ( msg && *msg ) { 
01567                 init_unistr4( q_u->message, msg, UNI_FLAGS_NONE );
01568 
01569                 /* Win2000 is apparently very sensitive to these lengths */
01570                 /* do a special case here */
01571 
01572                 q_u->message->string->uni_max_len++;
01573                 q_u->message->size += 2;
01574 
01575         }
01576 
01577         q_u->timeout = timeout;
01578 
01579         q_u->reboot = do_reboot ? 1 : 0;
01580         q_u->force = force ? 1 : 0;
01581 }
01582 
01583 /*******************************************************************
01584 Inits a REG_Q_SHUTDOWN_EX structure.
01585 ********************************************************************/
01586 
01587 void init_reg_q_shutdown_ex(REG_Q_SHUTDOWN_EX * q_u_ex, const char *msg,
01588                         uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason)
01589 {
01590         REG_Q_SHUTDOWN q_u;
01591         
01592         ZERO_STRUCT( q_u );
01593         
01594         init_reg_q_shutdown( &q_u, msg, timeout, do_reboot, force );
01595         
01596         /* steal memory */
01597         
01598         q_u_ex->server  = q_u.server;
01599         q_u_ex->message = q_u.message;
01600         
01601         q_u_ex->reboot  = q_u.reboot;
01602         q_u_ex->force   = q_u.force;
01603         
01604         q_u_ex->reason = reason;
01605 }
01606 
01607 /*******************************************************************
01608 reads or writes a structure.
01609 ********************************************************************/
01610 
01611 BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN *q_u, prs_struct *ps,
01612                        int depth)
01613 {
01614         if ( !q_u )
01615                 return False;
01616 
01617         prs_debug(ps, depth, desc, "reg_io_q_shutdown");
01618         depth++;
01619 
01620         if (!prs_align(ps))
01621                 return False;
01622 
01623         if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
01624                 return False;
01625         if (!prs_align(ps))
01626                 return False;
01627 
01628         if (!prs_pointer("message", ps, depth, (void**)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
01629                 return False;
01630 
01631         if (!prs_align(ps))
01632                 return False;
01633 
01634         if (!prs_uint32("timeout", ps, depth, &(q_u->timeout)))
01635                 return False;
01636 
01637         if (!prs_uint8("force  ", ps, depth, &(q_u->force)))
01638                 return False;
01639         if (!prs_uint8("reboot ", ps, depth, &(q_u->reboot)))
01640                 return False;
01641 
01642 
01643         return True;
01644 }
01645 
01646 /*******************************************************************
01647 reads or writes a structure.
01648 ********************************************************************/
01649 BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN *r_u, prs_struct *ps,
01650                        int depth)
01651 {
01652         if ( !r_u )
01653                 return False;
01654 
01655         prs_debug(ps, depth, desc, "reg_io_r_shutdown");
01656         depth++;
01657 
01658         if(!prs_align(ps))
01659                 return False;
01660 
01661         if(!prs_werror("status", ps, depth, &r_u->status))
01662                 return False;
01663 
01664         return True;
01665 }
01666 
01667 /*******************************************************************
01668 reads or writes a REG_Q_SHUTDOWN_EX structure.
01669 ********************************************************************/
01670 
01671 BOOL reg_io_q_shutdown_ex(const char *desc, REG_Q_SHUTDOWN_EX *q_u, prs_struct *ps,
01672                        int depth)
01673 {
01674         if ( !q_u )
01675                 return False;
01676 
01677         prs_debug(ps, depth, desc, "reg_io_q_shutdown_ex");
01678         depth++;
01679 
01680         if (!prs_align(ps))
01681                 return False;
01682 
01683         if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
01684                 return False;
01685         if (!prs_align(ps))
01686                 return False;
01687 
01688         if (!prs_pointer("message", ps, depth, (void**)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
01689                 return False;
01690 
01691         if (!prs_align(ps))
01692                 return False;
01693 
01694         if (!prs_uint32("timeout", ps, depth, &(q_u->timeout)))
01695                 return False;
01696 
01697         if (!prs_uint8("force  ", ps, depth, &(q_u->force)))
01698                 return False;
01699         if (!prs_uint8("reboot ", ps, depth, &(q_u->reboot)))
01700                 return False;
01701 
01702         if (!prs_align(ps))
01703                 return False;
01704         if (!prs_uint32("reason", ps, depth, &(q_u->reason)))
01705                 return False;
01706 
01707 
01708         return True;
01709 }
01710 
01711 /*******************************************************************
01712 reads or writes a REG_R_SHUTDOWN_EX structure.
01713 ********************************************************************/
01714 BOOL reg_io_r_shutdown_ex(const char *desc, REG_R_SHUTDOWN_EX *r_u, prs_struct *ps,
01715                        int depth)
01716 {
01717         if ( !r_u )
01718                 return False;
01719 
01720         prs_debug(ps, depth, desc, "reg_io_r_shutdown_ex");
01721         depth++;
01722 
01723         if(!prs_align(ps))
01724                 return False;
01725 
01726         if(!prs_werror("status", ps, depth, &r_u->status))
01727                 return False;
01728 
01729         return True;
01730 }
01731 
01732 /*******************************************************************
01733 Inits a structure.
01734 ********************************************************************/
01735 
01736 void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN *q_u)
01737 {
01738         q_u->server = TALLOC_P( get_talloc_ctx(), uint16 );
01739         if (!q_u->server) {
01740                 smb_panic("init_reg_q_abort_shutdown: talloc fail\n");
01741                 return;
01742         }
01743         *q_u->server = 0x1;
01744 }
01745 
01746 /*******************************************************************
01747 reads or writes a structure.
01748 ********************************************************************/
01749 
01750 BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN *q_u,
01751                              prs_struct *ps, int depth)
01752 {
01753         if ( !q_u )
01754                 return False;
01755 
01756         prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
01757         depth++;
01758 
01759         if (!prs_align(ps))
01760                 return False;
01761 
01762         if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
01763                 return False;
01764         if (!prs_align(ps))
01765                 return False;
01766 
01767         return True;
01768 }
01769 
01770 /*******************************************************************
01771 reads or writes a structure.
01772 ********************************************************************/
01773 BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN *r_u,
01774                              prs_struct *ps, int depth)
01775 {
01776         if ( !r_u )
01777                 return False;
01778 
01779         prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
01780         depth++;
01781 
01782         if (!prs_align(ps))
01783                 return False;
01784 
01785         if (!prs_werror("status", ps, depth, &r_u->status))
01786                 return False;
01787 
01788         return True;
01789 }

Sambaに対してSat Aug 29 21:23:17 2009に生成されました。  doxygen 1.4.7