diff options
Diffstat (limited to 'source/rpc_parse')
-rw-r--r-- | source/rpc_parse/parse_buffer.c | 491 | ||||
-rw-r--r-- | source/rpc_parse/parse_eventlog.c | 457 | ||||
-rw-r--r-- | source/rpc_parse/parse_lsa.c | 171 | ||||
-rw-r--r-- | source/rpc_parse/parse_misc.c | 480 | ||||
-rw-r--r-- | source/rpc_parse/parse_net.c | 21 | ||||
-rw-r--r-- | source/rpc_parse/parse_prs.c | 53 | ||||
-rw-r--r-- | source/rpc_parse/parse_reg.c | 1103 | ||||
-rw-r--r-- | source/rpc_parse/parse_rpc.c | 45 | ||||
-rw-r--r-- | source/rpc_parse/parse_samr.c | 221 | ||||
-rw-r--r-- | source/rpc_parse/parse_sec.c | 2 | ||||
-rw-r--r-- | source/rpc_parse/parse_shutdown.c | 123 | ||||
-rw-r--r-- | source/rpc_parse/parse_spoolss.c | 689 | ||||
-rw-r--r-- | source/rpc_parse/parse_srv.c | 73 | ||||
-rw-r--r-- | source/rpc_parse/parse_svcctl.c | 660 |
14 files changed, 2936 insertions, 1653 deletions
diff --git a/source/rpc_parse/parse_buffer.c b/source/rpc_parse/parse_buffer.c new file mode 100644 index 00000000000..a48d5cfa982 --- /dev/null +++ b/source/rpc_parse/parse_buffer.c @@ -0,0 +1,491 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * + * Copyright (C) Andrew Tridgell 1992-2000, + * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, + * Copyright (C) Jean François Micouleau 1998-2000, + * Copyright (C) Gerald Carter 2000-2005, + * Copyright (C) Tim Potter 2001-2002. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_PARSE + +/********************************************************************** + Initialize a new spoolss buff for use by a client rpc +**********************************************************************/ +void rpcbuf_init(RPC_BUFFER *buffer, uint32 size, TALLOC_CTX *ctx) +{ + buffer->size = size; + buffer->string_at_end = size; + prs_init(&buffer->prs, size, ctx, MARSHALL); + buffer->struct_start = prs_offset(&buffer->prs); +} + +/******************************************************************* + Read/write a RPC_BUFFER struct. +********************************************************************/ + +BOOL prs_rpcbuffer(const char *desc, prs_struct *ps, int depth, RPC_BUFFER *buffer) +{ + prs_debug(ps, depth, desc, "prs_rpcbuffer"); + depth++; + + /* reading */ + if (UNMARSHALLING(ps)) { + buffer->size=0; + buffer->string_at_end=0; + + if (!prs_uint32("size", ps, depth, &buffer->size)) + return False; + + /* + * JRA. I'm not sure if the data in here is in big-endian format if + * the client is big-endian. Leave as default (little endian) for now. + */ + + if (!prs_init(&buffer->prs, buffer->size, prs_get_mem_context(ps), UNMARSHALL)) + return False; + + if (!prs_append_some_prs_data(&buffer->prs, ps, prs_offset(ps), buffer->size)) + return False; + + if (!prs_set_offset(&buffer->prs, 0)) + return False; + + if (!prs_set_offset(ps, buffer->size+prs_offset(ps))) + return False; + + buffer->string_at_end=buffer->size; + + return True; + } + else { + BOOL ret = False; + + if (!prs_uint32("size", ps, depth, &buffer->size)) + goto out; + + if (!prs_append_some_prs_data(ps, &buffer->prs, 0, buffer->size)) + goto out; + + ret = True; + out: + + /* We have finished with the data in buffer->prs - free it. */ + prs_mem_free(&buffer->prs); + + return ret; + } +} + +/******************************************************************* + Read/write an RPC_BUFFER* struct.(allocate memory if unmarshalling) +********************************************************************/ + +BOOL prs_rpcbuffer_p(const char *desc, prs_struct *ps, int depth, RPC_BUFFER **buffer) +{ + uint32 data_p; + + /* caputure the pointer value to stream */ + + data_p = (uint32) *buffer; + + if ( !prs_uint32("ptr", ps, depth, &data_p )) + return False; + + /* we're done if there is no data */ + + if ( !data_p ) + return True; + + if ( UNMARSHALLING(ps) ) { + if ( !(*buffer = PRS_ALLOC_MEM(ps, RPC_BUFFER, 1)) ) + return False; + } + + return prs_rpcbuffer( desc, ps, depth, *buffer); +} + +/**************************************************************************** + Allocate more memory for a RPC_BUFFER. +****************************************************************************/ + +BOOL rpcbuf_alloc_size(RPC_BUFFER *buffer, uint32 buffer_size) +{ + prs_struct *ps; + uint32 extra_space; + uint32 old_offset; + + /* if we don't need anything. don't do anything */ + + if ( buffer_size == 0x0 ) + return True; + + ps= &buffer->prs; + + /* damn, I'm doing the reverse operation of prs_grow() :) */ + if (buffer_size < prs_data_size(ps)) + extra_space=0; + else + extra_space = buffer_size - prs_data_size(ps); + + /* + * save the offset and move to the end of the buffer + * prs_grow() checks the extra_space against the offset + */ + old_offset=prs_offset(ps); + prs_set_offset(ps, prs_data_size(ps)); + + if (!prs_grow(ps, extra_space)) + return False; + + prs_set_offset(ps, old_offset); + + buffer->string_at_end=prs_data_size(ps); + + return True; +} + +/******************************************************************* + move a BUFFER from the query to the reply. + As the data pointers in RPC_BUFFER are malloc'ed, not talloc'ed, + this is ok. This is an OPTIMIZATION and is not strictly neccessary. + Clears the memory to zero also. +********************************************************************/ + +void rpcbuf_move(RPC_BUFFER *src, RPC_BUFFER **dest) +{ + SMB_ASSERT( src != NULL ); + + prs_switch_type(&src->prs, MARSHALL); + if(!prs_set_offset(&src->prs, 0)) + return; + prs_force_dynamic(&src->prs); + prs_mem_clear(&src->prs); + *dest=src; +} + +/******************************************************************* + Get the size of a BUFFER struct. +********************************************************************/ + +uint32 rpcbuf_get_size(RPC_BUFFER *buffer) +{ + return (buffer->size); +} + + +/******************************************************************* + * write a UNICODE string and its relative pointer. + * used by all the RPC structs passing a buffer + * + * As I'm a nice guy, I'm forcing myself to explain this code. + * MS did a good job in the overall spoolss code except in some + * functions where they are passing the API buffer directly in the + * RPC request/reply. That's to maintain compatiility at the API level. + * They could have done it the good way the first time. + * + * So what happen is: the strings are written at the buffer's end, + * in the reverse order of the original structure. Some pointers to + * the strings are also in the buffer. Those are relative to the + * buffer's start. + * + * If you don't understand or want to change that function, + * first get in touch with me: jfm@samba.org + * + ********************************************************************/ + +BOOL smb_io_relstr(const char *desc, RPC_BUFFER *buffer, int depth, UNISTR *string) +{ + prs_struct *ps=&buffer->prs; + + if (MARSHALLING(ps)) { + uint32 struct_offset = prs_offset(ps); + uint32 relative_offset; + + buffer->string_at_end -= (size_of_relative_string(string) - 4); + if(!prs_set_offset(ps, buffer->string_at_end)) + return False; +#if 0 /* JERRY */ + /* + * Win2k does not align strings in a buffer + * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry + */ + if (!prs_align(ps)) + return False; +#endif + buffer->string_at_end = prs_offset(ps); + + /* write the string */ + if (!smb_io_unistr(desc, string, ps, depth)) + return False; + + if(!prs_set_offset(ps, struct_offset)) + return False; + + relative_offset=buffer->string_at_end - buffer->struct_start; + /* write its offset */ + if (!prs_uint32("offset", ps, depth, &relative_offset)) + return False; + } + else { + uint32 old_offset; + + /* read the offset */ + if (!prs_uint32("offset", ps, depth, &(buffer->string_at_end))) + return False; + + if (buffer->string_at_end == 0) + return True; + + old_offset = prs_offset(ps); + if(!prs_set_offset(ps, buffer->string_at_end+buffer->struct_start)) + return False; + + /* read the string */ + if (!smb_io_unistr(desc, string, ps, depth)) + return False; + + if(!prs_set_offset(ps, old_offset)) + return False; + } + return True; +} + +/******************************************************************* + * write a array of UNICODE strings and its relative pointer. + * used by 2 RPC structs + ********************************************************************/ + +BOOL smb_io_relarraystr(const char *desc, RPC_BUFFER *buffer, int depth, uint16 **string) +{ + UNISTR chaine; + + prs_struct *ps=&buffer->prs; + + if (MARSHALLING(ps)) { + uint32 struct_offset = prs_offset(ps); + uint32 relative_offset; + uint16 *p; + uint16 *q; + uint16 zero=0; + p=*string; + q=*string; + + /* first write the last 0 */ + buffer->string_at_end -= 2; + if(!prs_set_offset(ps, buffer->string_at_end)) + return False; + + if(!prs_uint16("leading zero", ps, depth, &zero)) + return False; + + while (p && (*p!=0)) { + while (*q!=0) + q++; + + /* Yes this should be malloc not talloc. Don't change. */ + + chaine.buffer = SMB_MALLOC((q-p+1)*sizeof(uint16)); + if (chaine.buffer == NULL) + return False; + + memcpy(chaine.buffer, p, (q-p+1)*sizeof(uint16)); + + buffer->string_at_end -= (q-p+1)*sizeof(uint16); + + if(!prs_set_offset(ps, buffer->string_at_end)) { + SAFE_FREE(chaine.buffer); + return False; + } + + /* write the string */ + if (!smb_io_unistr(desc, &chaine, ps, depth)) { + SAFE_FREE(chaine.buffer); + return False; + } + q++; + p=q; + + SAFE_FREE(chaine.buffer); + } + + if(!prs_set_offset(ps, struct_offset)) + return False; + + relative_offset=buffer->string_at_end - buffer->struct_start; + /* write its offset */ + if (!prs_uint32("offset", ps, depth, &relative_offset)) + return False; + + } else { + + /* UNMARSHALLING */ + + uint32 old_offset; + uint16 *chaine2=NULL; + int l_chaine=0; + int l_chaine2=0; + size_t realloc_size = 0; + + *string=NULL; + + /* read the offset */ + if (!prs_uint32("offset", ps, depth, &buffer->string_at_end)) + return False; + + old_offset = prs_offset(ps); + if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start)) + return False; + + do { + if (!smb_io_unistr(desc, &chaine, ps, depth)) + return False; + + l_chaine=str_len_uni(&chaine); + + /* we're going to add two more bytes here in case this + is the last string in the array and we need to add + an extra NULL for termination */ + if (l_chaine > 0) + { + uint16 *tc2; + + realloc_size = (l_chaine2+l_chaine+2)*sizeof(uint16); + + /* Yes this should be realloc - it's freed below. JRA */ + + if((tc2=(uint16 *)SMB_REALLOC(chaine2, realloc_size)) == NULL) { + SAFE_FREE(chaine2); + return False; + } + else chaine2 = tc2; + memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16)); + l_chaine2+=l_chaine+1; + } + + } while(l_chaine!=0); + + /* the end should be bould NULL terminated so add + the second one here */ + if (chaine2) + { + chaine2[l_chaine2] = '\0'; + *string=(uint16 *)TALLOC_MEMDUP(prs_get_mem_context(ps),chaine2,realloc_size); + SAFE_FREE(chaine2); + } + + if(!prs_set_offset(ps, old_offset)) + return False; + } + return True; +} + +/******************************************************************* + Parse a DEVMODE structure and its relative pointer. +********************************************************************/ + +BOOL smb_io_relsecdesc(const char *desc, RPC_BUFFER *buffer, int depth, SEC_DESC **secdesc) +{ + prs_struct *ps= &buffer->prs; + + prs_debug(ps, depth, desc, "smb_io_relsecdesc"); + depth++; + + if (MARSHALLING(ps)) { + uint32 struct_offset = prs_offset(ps); + uint32 relative_offset; + + if (! *secdesc) { + relative_offset = 0; + if (!prs_uint32("offset", ps, depth, &relative_offset)) + return False; + return True; + } + + if (*secdesc != NULL) { + buffer->string_at_end -= sec_desc_size(*secdesc); + + if(!prs_set_offset(ps, buffer->string_at_end)) + return False; + /* write the secdesc */ + if (!sec_io_desc(desc, secdesc, ps, depth)) + return False; + + if(!prs_set_offset(ps, struct_offset)) + return False; + } + + relative_offset=buffer->string_at_end - buffer->struct_start; + /* write its offset */ + + if (!prs_uint32("offset", ps, depth, &relative_offset)) + return False; + } else { + uint32 old_offset; + + /* read the offset */ + if (!prs_uint32("offset", ps, depth, &buffer->string_at_end)) + return False; + + old_offset = prs_offset(ps); + if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start)) + return False; + + /* read the sd */ + if (!sec_io_desc(desc, secdesc, ps, depth)) + return False; + + if(!prs_set_offset(ps, old_offset)) + return False; + } + return True; +} + + + +/******************************************************************* + * return the length of a UNICODE string in number of char, includes: + * - the leading zero + * - the relative pointer size + ********************************************************************/ + +uint32 size_of_relative_string(UNISTR *string) +{ + uint32 size=0; + + size=str_len_uni(string); /* the string length */ + size=size+1; /* add the trailing zero */ + size=size*2; /* convert in char */ + size=size+4; /* add the size of the ptr */ + +#if 0 /* JERRY */ + /* + * Do not include alignment as Win2k does not align relative + * strings within a buffer --jerry + */ + /* Ensure size is 4 byte multiple (prs_align is being called...). */ + /* size += ((4 - (size & 3)) & 3); */ +#endif + + return size; +} + diff --git a/source/rpc_parse/parse_eventlog.c b/source/rpc_parse/parse_eventlog.c new file mode 100644 index 00000000000..9bb0a131697 --- /dev/null +++ b/source/rpc_parse/parse_eventlog.c @@ -0,0 +1,457 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Marcin Krzysztof Porwit 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_PARSE + +/* + * called from eventlog_q_open_eventlog (srv_eventlog.c) + */ + +BOOL eventlog_io_q_open_eventlog(const char *desc, EVENTLOG_Q_OPEN_EVENTLOG *q_u, + prs_struct *ps, int depth) +{ + if(q_u == NULL) + return False; + + /* Data format seems to be: + UNKNOWN structure + uint32 unknown + uint16 unknown + uint16 unknown + Eventlog name + uint16 eventlog name length + uint16 eventlog name size + Character Array + uint32 unknown + uint32 max count + uint32 offset + uint32 actual count + UNISTR2 log file name + Server Name + uint16 server name length + uint16 server name size + Character Array + UNISTR2 server name + */ + + prs_debug(ps, depth, desc, "eventlog_io_q_open_eventlog"); + depth++; + + if(!prs_align(ps)) + return False; + + /* Munch unknown bits */ + + if(!prs_uint32("", ps, depth, &q_u->unknown1)) + return False; + if(!prs_uint16("", ps, depth, &q_u->unknown2)) + return False; + if(!prs_uint16("", ps, depth, &q_u->unknown3)) + return False; + if(!prs_align(ps)) + return False; + + /* Get name of log source */ + + if(!prs_uint16("sourcename_length", ps, depth, &q_u->sourcename_length)) + return False; + if(!prs_uint16("sourcename_size", ps, depth, &q_u->sourcename_size)) + return False; + if(!prs_uint32("sourcename_ptr", ps, depth, &q_u->sourcename_ptr)) + return False; + if(!smb_io_unistr2("", &q_u->sourcename, q_u->sourcename_ptr, ps, depth)) + return False; + if(!prs_align(ps)) + return False; + + /* Get server name */ + + if(!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr)) + return False; + if(!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth)) + return False; + + return True; +} + +BOOL eventlog_io_r_open_eventlog(const char *desc, EVENTLOG_R_OPEN_EVENTLOG *r_u, + prs_struct *ps, int depth) +{ + if(r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_r_open_eventlog"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!(smb_io_pol_hnd("log handle", &(r_u->handle), ps, depth))) + return False; + + if(!(prs_werror("status code", ps, depth, &(r_u->status)))) + return False; + + return True; +} + +BOOL eventlog_io_q_get_num_records(const char *desc, EVENTLOG_Q_GET_NUM_RECORDS *q_u, + prs_struct *ps, int depth) +{ + if(q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_q_get_num_records"); + depth++; + + if(!(prs_align(ps))) + return False; + + if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth))) + return False; + + return True; +} + +BOOL eventlog_io_r_get_num_records(const char *desc, EVENTLOG_R_GET_NUM_RECORDS *r_u, + prs_struct *ps, int depth) +{ + if(r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_r_get_num_records"); + depth++; + + if(!(prs_align(ps))) + return False; + + if(!(prs_uint32("num records", ps, depth, &(r_u->num_records)))) + return False; + + if(!(prs_werror("status code", ps, depth, &(r_u->status)))) + return False; + + return True; +} + +BOOL eventlog_io_q_get_oldest_entry(const char *desc, EVENTLOG_Q_GET_OLDEST_ENTRY *q_u, + prs_struct *ps, int depth) +{ + if(q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_q_get_oldest_entry"); + depth++; + + if(!(prs_align(ps))) + return False; + + if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth))) + return False; + + return True; +} + +BOOL eventlog_io_r_get_oldest_entry(const char *desc, EVENTLOG_R_GET_OLDEST_ENTRY *r_u, + prs_struct *ps, int depth) +{ + if(r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_r_get_oldest_entry"); + depth++; + + if(!(prs_align(ps))) + return False; + + if(!(prs_uint32("oldest entry", ps, depth, &(r_u->oldest_entry)))) + return False; + + if(!(prs_werror("status code", ps, depth, &(r_u->status)))) + return False; + + return True; +} + +BOOL eventlog_io_q_close_eventlog(const char *desc, EVENTLOG_Q_CLOSE_EVENTLOG *q_u, + prs_struct *ps, int depth) +{ + if(q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_q_close_eventlog"); + depth++; + + if(!(prs_align(ps))) + return False; + + if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth))) + return False; + + return True; +} + +BOOL eventlog_io_r_close_eventlog(const char *desc, EVENTLOG_R_CLOSE_EVENTLOG *r_u, + prs_struct *ps, int depth) +{ + if(r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_r_close_eventlog"); + depth++; + + if(!(prs_align(ps))) + return False; + + if(!(smb_io_pol_hnd("log handle", &(r_u->handle), ps, depth))) + return False; + + if(!(prs_werror("status code", ps, depth, &(r_u->status)))) + return False; + + return True; +} + +BOOL eventlog_io_q_read_eventlog(const char *desc, EVENTLOG_Q_READ_EVENTLOG *q_u, + prs_struct *ps, int depth) +{ + if(q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_q_read_eventlog"); + depth++; + + if(!(prs_align(ps))) + return False; + + if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth))) + return False; + + if(!(prs_uint32("read flags", ps, depth, &(q_u->flags)))) + return False; + + if(!(prs_uint32("read offset", ps, depth, &(q_u->offset)))) + return False; + + if(!(prs_uint32("read buf size", ps, depth, &(q_u->max_read_size)))) + return False; + + return True; +} +/* Structure of response seems to be: + DWORD num_bytes_in_resp -- MUST be the same as q_u->max_read_size + for i=0..n + EVENTLOGRECORD record + DWORD sent_size -- sum of EVENTLOGRECORD lengths if records returned, 0 otherwise + DWORD real_size -- 0 if records returned, otherwise length of next record to be returned + WERROR status */ +BOOL eventlog_io_r_read_eventlog(const char *desc, + EVENTLOG_Q_READ_EVENTLOG *q_u, + EVENTLOG_R_READ_EVENTLOG *r_u, + prs_struct *ps, + int depth) +{ + Eventlog_entry *entry; + uint32 record_written = 0; + uint32 record_total = 0; + + if(r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_r_read_eventlog"); + depth++; + + /* First, see if we've read more logs than we can output */ + + if(r_u->num_bytes_in_resp > q_u->max_read_size) { + entry = r_u->entry; + + /* remove the size of the last entry from the list */ + + while(entry->next != NULL) + entry = entry->next; + + r_u->num_bytes_in_resp -= entry->record.length; + + /* do not output the last log entry */ + + r_u->num_records--; + } + + entry = r_u->entry; + record_total = r_u->num_records; + + if(r_u->num_bytes_in_resp != 0) + r_u->sent_size = r_u->num_bytes_in_resp; + else + r_u->real_size = entry->record.length; + + if(!(prs_align(ps))) + return False; + if(!(prs_uint32("bytes in resp", ps, depth, &(q_u->max_read_size)))) + return False; + + while(entry != NULL && record_written < record_total) + { + DEBUG(10, ("eventlog_io_r_read_eventlog: writing record [%d] out of [%d].\n", record_written, record_total)); + + /* Encode the actual eventlog record record */ + + if(!(prs_uint32("length", ps, depth, &(entry->record.length)))) + return False; + if(!(prs_uint32("reserved", ps, depth, &(entry->record.reserved1)))) + return False; + if(!(prs_uint32("record number", ps, depth, &(entry->record.record_number)))) + return False; + if(!(prs_uint32("time generated", ps, depth, &(entry->record.time_generated)))) + return False; + if(!(prs_uint32("time written", ps, depth, &(entry->record.time_written)))) + return False; + if(!(prs_uint32("event id", ps, depth, &(entry->record.event_id)))) + return False; + if(!(prs_uint16("event type", ps, depth, &(entry->record.event_type)))) + return False; + if(!(prs_uint16("num strings", ps, depth, &(entry->record.num_strings)))) + return False; + if(!(prs_uint16("event category", ps, depth, &(entry->record.event_category)))) + return False; + if(!(prs_uint16("reserved2", ps, depth, &(entry->record.reserved2)))) + return False; + if(!(prs_uint32("closing record", ps, depth, &(entry->record.closing_record_number)))) + return False; + if(!(prs_uint32("string offset", ps, depth, &(entry->record.string_offset)))) + return False; + if(!(prs_uint32("user sid length", ps, depth, &(entry->record.user_sid_length)))) + return False; + if(!(prs_uint32("user sid offset", ps, depth, &(entry->record.user_sid_offset)))) + return False; + if(!(prs_uint32("data length", ps, depth, &(entry->record.data_length)))) + return False; + if(!(prs_uint32("data offset", ps, depth, &(entry->record.data_offset)))) + return False; + if(!(prs_align(ps))) + return False; + + /* Now encoding data */ + + if(!(prs_uint8s(False, "buffer", ps, depth, entry->data, + entry->record.length - sizeof(Eventlog_record) - sizeof(entry->record.length)))) + { + return False; + } + + if(!(prs_align(ps))) + return False; + if(!(prs_uint32("length 2", ps, depth, &(entry->record.length)))) + return False; + + entry = entry->next; + record_written++; + + } /* end of encoding EVENTLOGRECORD */ + + /* Now pad with whitespace until the end of the response buffer */ + + r_u->end_of_entries_padding = (uint8 *)calloc(q_u->max_read_size - r_u->num_bytes_in_resp, sizeof(uint8)); + + if(!(prs_uint8s(False, "end of entries padding", ps, + depth, r_u->end_of_entries_padding, + (q_u->max_read_size - r_u->num_bytes_in_resp)))) + { + return False; + } + + free(r_u->end_of_entries_padding); + + /* We had better be DWORD aligned here */ + + if(!(prs_uint32("sent size", ps, depth, &(r_u->sent_size)))) + return False; + if(!(prs_uint32("real size", ps, depth, &(r_u->real_size)))) + return False; + if(!(prs_werror("status code", ps, depth, &(r_u->status)))) + return False; + + return True; +} + +/* The windows client seems to be doing something funny with the file name + A call like + ClearEventLog(handle, "backup_file") + on the client side will result in the backup file name looking like this on the + server side: + \??\${CWD of client}\backup_file + If an absolute path gets specified, such as + ClearEventLog(handle, "C:\\temp\\backup_file") + then it is still mangled by the client into this: + \??\C:\temp\backup_file + when it is on the wire. + I'm not sure where the \?? is coming from, or why the ${CWD} of the client process + would be added in given that the backup file gets written on the server side. */ + +BOOL eventlog_io_q_clear_eventlog(const char *desc, EVENTLOG_Q_CLEAR_EVENTLOG *q_u, + prs_struct *ps, int depth) +{ + if(q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_q_clear_eventlog"); + depth++; + + if(!prs_align(ps)) + return False; + if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth))) + return False; + if(!prs_align(ps)) + return False; + if(!(prs_uint32("unknown1", ps, depth, &q_u->unknown1))) + return False; + if(!(prs_uint16("backup_file_length", ps, depth, &q_u->backup_file_length))) + return False; + if(!(prs_uint16("backup_file_size", ps, depth, &q_u->backup_file_size))) + return False; + if(!prs_uint32("backup_file_ptr", ps, depth, &q_u->backup_file_ptr)) + return False; + if(!smb_io_unistr2("backup file", &q_u->backup_file, q_u->backup_file_ptr, ps, depth)) + return False; + + return True; + +} + +BOOL eventlog_io_r_clear_eventlog(const char *desc, EVENTLOG_R_CLEAR_EVENTLOG *r_u, + prs_struct *ps, int depth) +{ + if(r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "eventlog_io_r_clear_eventlog"); + depth++; + + if(!prs_align(ps)) + return False; + if(!(prs_werror("status code", ps, depth, &(r_u->status)))) + return False; + + return True; +} diff --git a/source/rpc_parse/parse_lsa.c b/source/rpc_parse/parse_lsa.c index bbff258722a..ab3d3fcfe81 100644 --- a/source/rpc_parse/parse_lsa.c +++ b/source/rpc_parse/parse_lsa.c @@ -6,6 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Andrew Bartlett 2002, * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002. + * Copyright (C) Gerald )Jerry) Carter 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -516,100 +517,99 @@ void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *r_e, uint32 en DEBUG(5, ("init_r_enum_trust_dom\n")); - r_e->enum_context = enum_context; - r_e->num_domains = num_domains; - r_e->ptr_enum_domains = 0; - r_e->num_domains2 = num_domains; - - if (num_domains != 0) { + r_e->enum_context = enum_context; + r_e->count = num_domains; + + if ( num_domains != 0 ) { - /* - * allocating empty arrays of unicode headers, strings - * and sids of enumerated trusted domains - */ - if (!(r_e->hdr_domain_name = TALLOC_ARRAY(ctx,UNIHDR2,num_domains))) { - r_e->status = NT_STATUS_NO_MEMORY; - return; - } + /* allocate container memory */ - if (!(r_e->uni_domain_name = TALLOC_ARRAY(ctx,UNISTR2,num_domains))) { - r_e->status = NT_STATUS_NO_MEMORY; - return; - } - - if (!(r_e->domain_sid = TALLOC_ARRAY(ctx,DOM_SID2,num_domains))) { + r_e->domlist = TALLOC_P( ctx, DOMAIN_LIST ); + r_e->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO, r_e->count ); + + if ( !r_e->domlist || !r_e->domlist->domains ) { r_e->status = NT_STATUS_NO_MEMORY; return; } + + r_e->domlist->count = r_e->count; + + /* initialize the list of domains and their sid */ + + for (i = 0; i < num_domains; i++) { + if ( !(r_e->domlist->domains[i].sid = TALLOC_P(ctx, DOM_SID2)) ) { + r_e->status = NT_STATUS_NO_MEMORY; + return; + } - for (i = 0; i < num_domains; i++) { - - /* don't know what actually is this for */ - r_e->ptr_enum_domains = 1; - - init_dom_sid2(&r_e->domain_sid[i], &(td[i])->sid); - - init_unistr2_w(ctx, &r_e->uni_domain_name[i], (td[i])->name); - init_uni_hdr2(&r_e->hdr_domain_name[i], &r_e->uni_domain_name[i]); - - }; + init_dom_sid2(r_e->domlist->domains[i].sid, &(td[i])->sid); + init_unistr4_w(ctx, &r_e->domlist->domains[i].name, (td[i])->name); + } } } /******************************************************************* - Reads or writes an LSA_R_ENUM_TRUST_DOM structure. ********************************************************************/ -BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e, - prs_struct *ps, int depth) +BOOL lsa_io_domain_list( const char *desc, prs_struct *ps, int depth, DOMAIN_LIST *domlist ) { - prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom"); + int i; + + prs_debug(ps, depth, desc, "lsa_io_domain_list"); depth++; - if(!prs_uint32("enum_context ", ps, depth, &r_e->enum_context)) - return False; - if(!prs_uint32("num_domains ", ps, depth, &r_e->num_domains)) - return False; - if(!prs_uint32("ptr_enum_domains", ps, depth, &r_e->ptr_enum_domains)) + if(!prs_uint32("count", ps, depth, &domlist->count)) return False; - if (r_e->ptr_enum_domains) { - int i, num_domains; + if ( domlist->count == 0 ) + return True; + + if ( UNMARSHALLING(ps) ) { + if ( !(domlist->domains = PRS_ALLOC_MEM( ps, DOMAIN_INFO, domlist->count )) ) + return False; + } + + /* headers */ + + for ( i=0; i<domlist->count; i++ ) { + if ( !prs_unistr4_hdr("name_header", ps, depth, &domlist->domains[i].name) ) + return False; + if ( !smb_io_dom_sid2_p("sid_header", ps, depth, &domlist->domains[i].sid) ) + return False; + } - if(!prs_uint32("num_domains2", ps, depth, &r_e->num_domains2)) + /* data */ + + for ( i=0; i<domlist->count; i++ ) { + if ( !prs_unistr4_str("name", ps, depth, &domlist->domains[i].name) ) return False; + if( !smb_io_dom_sid2("sid", domlist->domains[i].sid, ps, depth) ) + return False; + } + + return True; +} - num_domains = r_e->num_domains2; +/******************************************************************* + Reads or writes an LSA_R_ENUM_TRUST_DOM structure. +********************************************************************/ - if (UNMARSHALLING(ps)) { - if (!(r_e->hdr_domain_name = PRS_ALLOC_MEM(ps,UNIHDR2,num_domains))) - return False; +BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e, + prs_struct *ps, int depth) +{ + prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom"); + depth++; - if (!(r_e->uni_domain_name = PRS_ALLOC_MEM(ps,UNISTR2,num_domains))) - return False; + if(!prs_uint32("enum_context", ps, depth, &r_e->enum_context)) + return False; - if (!(r_e->domain_sid = PRS_ALLOC_MEM(ps,DOM_SID2,num_domains))) - return False; - } + if(!prs_uint32("count", ps, depth, &r_e->count)) + return False; - for (i = 0; i < num_domains; i++) { - if(!smb_io_unihdr2 ("", &r_e->hdr_domain_name[i], ps, - depth)) - return False; - } + if ( !prs_pointer("trusted_domains", ps, depth, (void**)&r_e->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list)) + return False; - for (i = 0; i < num_domains; i++) { - if(!smb_io_unistr2 ("", &r_e->uni_domain_name[i], - r_e->hdr_domain_name[i].buffer, - ps, depth)) - return False; - if(!smb_io_dom_sid2("", &r_e->domain_sid[i], ps, - depth)) - return False; - } - } - if(!prs_ntstatus("status", ps, depth, &r_e->status)) return False; @@ -906,7 +906,7 @@ void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l, memcpy(&q_l->pol, hnd, sizeof(q_l->pol)); init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids); - q_l->level.value = level; + q_l->level = level; } /******************************************************************* @@ -928,7 +928,10 @@ BOOL lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct * return False; if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */ return False; - if(!smb_io_lookup_level("switch ", &q_s->level, ps, depth)) /* lookup level */ + + if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */ + return False; + if(!prs_align(ps)) return False; if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count)) @@ -2319,7 +2322,9 @@ NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *r_u, PRIVILEGE_SET *pr } if ( num_priv ) { - if ( !init_unistr2_array( &r_u->rights, num_priv, privname_array ) ) + r_u->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY ); + + if ( !init_unistr4_array( r_u->rights, num_priv, privname_array ) ) return NT_STATUS_NO_MEMORY; r_u->count = num_priv; @@ -2361,7 +2366,7 @@ BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, pr if(!prs_uint32("count ", ps, depth, &r_c->count)) return False; - if(!smb_io_unistr2_array("rights", &r_c->rights, ps, depth)) + if ( !prs_pointer("rights", ps, depth, (void**)&r_c->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) return False; if(!prs_align(ps)) @@ -2377,17 +2382,17 @@ BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, pr /******************************************************************* Inits an LSA_Q_ADD_ACCT_RIGHTS structure. ********************************************************************/ -void init_q_add_acct_rights(LSA_Q_ADD_ACCT_RIGHTS *q_q, - POLICY_HND *hnd, - DOM_SID *sid, - uint32 count, - const char **rights) +void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *q_q, POLICY_HND *hnd, + DOM_SID *sid, uint32 count, const char **rights ) { DEBUG(5, ("init_q_add_acct_rights\n")); q_q->pol = *hnd; init_dom_sid2(&q_q->sid, sid); - init_unistr2_array(&q_q->rights, count, rights); + + q_q->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY ); + init_unistr4_array( q_q->rights, count, rights ); + q_q->count = count; } @@ -2409,7 +2414,7 @@ BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *q_q, prs_ if(!prs_uint32("count", ps, depth, &q_q->count)) return False; - if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth)) + if ( !prs_pointer("rights", ps, depth, (void**)&q_q->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) return False; return True; @@ -2443,10 +2448,14 @@ void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *q_q, DEBUG(5, ("init_q_remove_acct_rights\n")); q_q->pol = *hnd; + init_dom_sid2(&q_q->sid, sid); + q_q->removeall = removeall; - init_unistr2_array(&q_q->rights, count, rights); q_q->count = count; + + q_q->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY ); + init_unistr4_array( q_q->rights, count, rights ); } @@ -2470,7 +2479,7 @@ BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *q_q if(!prs_uint32("count", ps, depth, &q_q->count)) return False; - if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth)) + if ( !prs_pointer("rights", ps, depth, (void**)&q_q->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) return False; return True; diff --git a/source/rpc_parse/parse_misc.c b/source/rpc_parse/parse_misc.c index bca40a64c82..faa00d18624 100644 --- a/source/rpc_parse/parse_misc.c +++ b/source/rpc_parse/parse_misc.c @@ -4,6 +4,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. + * Copyright (C) Gerald (Jerry) Carter 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -132,28 +133,6 @@ BOOL smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth) } /******************************************************************* - Reads or writes a LOOKUP_LEVEL structure. -********************************************************************/ - -BOOL smb_io_lookup_level(const char *desc, LOOKUP_LEVEL *level, prs_struct *ps, int depth) -{ - if (level == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_lookup_level"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint16("value", ps, depth, &level->value)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* Gets an enumeration handle from an ENUM_HND structure. ********************************************************************/ @@ -302,6 +281,33 @@ void init_dom_sid2(DOM_SID2 *sid2, const DOM_SID *sid) Reads or writes a DOM_SID2 structure. ********************************************************************/ +BOOL smb_io_dom_sid2_p(const char *desc, prs_struct *ps, int depth, DOM_SID2 **sid2) +{ + uint32 data_p; + + /* caputure the pointer value to stream */ + + data_p = (uint32) *sid2; + + if ( !prs_uint32("dom_sid2_p", ps, depth, &data_p )) + return False; + + /* we're done if there is no data */ + + if ( !data_p ) + return True; + + if (UNMARSHALLING(ps)) { + if ( !(*sid2 = PRS_ALLOC_MEM(ps, DOM_SID2, 1)) ) + return False; + } + + return True; +} +/******************************************************************* + Reads or writes a DOM_SID2 structure. +********************************************************************/ + BOOL smb_io_dom_sid2(const char *desc, DOM_SID2 *sid, prs_struct *ps, int depth) { if (sid == NULL) @@ -507,39 +513,6 @@ BOOL smb_io_hdrbuf(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth) } /******************************************************************* -creates a UNIHDR2 structure. -********************************************************************/ - -void init_uni_hdr2(UNIHDR2 *hdr, UNISTR2 *str2) -{ - init_uni_hdr(&hdr->unihdr, str2); - hdr->buffer = (str2->uni_str_len > 0) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a UNIHDR2 structure. -********************************************************************/ - -BOOL smb_io_unihdr2(const char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth) -{ - if (hdr2 == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_unihdr2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr("hdr", &hdr2->unihdr, ps, depth)) - return False; - if(!prs_uint32("buffer", ps, depth, &hdr2->buffer)) - return False; - - return True; -} - -/******************************************************************* Inits a UNISTR structure. ********************************************************************/ @@ -581,105 +554,69 @@ BOOL smb_io_unistr(const char *desc, UNISTR *uni, prs_struct *ps, int depth) } /******************************************************************* - Allocate the BUFFER3 memory. + Allocate the RPC_DATA_BLOB memory. ********************************************************************/ -static size_t create_buffer3(BUFFER3 *str, size_t len) +static size_t create_rpc_blob(RPC_DATA_BLOB *str, size_t len) { str->buffer = TALLOC_ZERO(get_talloc_ctx(), len); if (str->buffer == NULL) - smb_panic("create_buffer3: talloc fail\n"); + smb_panic("create_rpc_blob: talloc fail\n"); return len; } /******************************************************************* - Inits a BUFFER3 structure from a uint32 + Inits a RPC_DATA_BLOB structure from a uint32 ********************************************************************/ -void init_buffer3_uint32(BUFFER3 *str, uint32 val) +void init_rpc_blob_uint32(RPC_DATA_BLOB *str, uint32 val) { ZERO_STRUCTP(str); /* set up string lengths. */ - str->buf_max_len = str->buf_len = create_buffer3(str, sizeof(uint32)); + str->buf_len = create_rpc_blob(str, sizeof(uint32)); SIVAL(str->buffer, 0, val); } /******************************************************************* - Inits a BUFFER3 structure. + Inits a RPC_DATA_BLOB structure. ********************************************************************/ -void init_buffer3_str(BUFFER3 *str, const char *buf, int len) +void init_rpc_blob_str(RPC_DATA_BLOB *str, const char *buf, int len) { ZERO_STRUCTP(str); /* set up string lengths. */ - str->buf_max_len = str->buf_len = create_buffer3(str, len*2); - rpcstr_push(str->buffer, buf, str->buf_max_len, STR_TERMINATE); + str->buf_len = create_rpc_blob(str, len*2); + rpcstr_push(str->buffer, buf, str->buf_len, STR_TERMINATE); } /******************************************************************* - Inits a BUFFER3 structure from a hex string. + Inits a RPC_DATA_BLOB structure from a hex string. ********************************************************************/ -void init_buffer3_hex(BUFFER3 *str, const char *buf) +void init_rpc_blob_hex(RPC_DATA_BLOB *str, const char *buf) { ZERO_STRUCTP(str); - str->buf_max_len = str->buf_len = create_buffer3(str, strlen(buf)); - str->buf_max_len = str->buf_len = strhex_to_str((char *)str->buffer, str->buf_len, buf); + str->buf_len = create_rpc_blob(str, strlen(buf)); + str->buf_len = strhex_to_str((char *)str->buffer, str->buf_len, buf); } /******************************************************************* - Inits a BUFFER3 structure. + Inits a RPC_DATA_BLOB structure. ********************************************************************/ -void init_buffer3_bytes(BUFFER3 *str, uint8 *buf, size_t len) +void init_rpc_blob_bytes(RPC_DATA_BLOB *str, uint8 *buf, size_t len) { ZERO_STRUCTP(str); /* max buffer size (allocated size) */ if (buf != NULL) { - len = create_buffer3(str, len); + len = create_rpc_blob(str, len); memcpy(str->buffer, buf, len); } - str->buf_max_len = len; - str->buf_len = buf != NULL ? len : 0; -} - -/******************************************************************* - Reads or writes a BUFFER3 structure. - the uni_max_len member tells you how large the buffer is. - the uni_str_len member tells you how much of the buffer is really used. -********************************************************************/ - -BOOL smb_io_buffer3(const char *desc, BUFFER3 *buf3, prs_struct *ps, int depth) -{ - if (buf3 == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_buffer3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("uni_max_len", ps, depth, &buf3->buf_max_len)) - return False; - - if (UNMARSHALLING(ps)) { - buf3->buffer = PRS_ALLOC_MEM(ps, unsigned char, buf3->buf_max_len); - if (buf3->buffer == NULL) - return False; - } - - if(!prs_uint8s(True, "buffer ", ps, depth, buf3->buffer, buf3->buf_max_len)) - return False; - - if(!prs_uint32("buf_len ", ps, depth, &buf3->buf_len)) - return False; - - return True; + str->buf_len = len; } /******************************************************************* @@ -707,10 +644,10 @@ BOOL smb_io_buffer5(const char *desc, BUFFER5 *buf5, prs_struct *ps, int depth) } /******************************************************************* - Inits a BUFFER2 structure. + Inits a REGVAL_BUFFER structure. ********************************************************************/ -void init_buffer2(BUFFER2 *str, const uint8 *buf, size_t len) +void init_regval_buffer(REGVAL_BUFFER *str, const uint8 *buf, size_t len) { ZERO_STRUCTP(str); @@ -723,50 +660,39 @@ void init_buffer2(BUFFER2 *str, const uint8 *buf, size_t len) SMB_ASSERT(str->buf_max_len >= str->buf_len); str->buffer = TALLOC_ZERO(get_talloc_ctx(), str->buf_max_len); if (str->buffer == NULL) - smb_panic("init_buffer2: talloc fail\n"); + smb_panic("init_regval_buffer: talloc fail\n"); memcpy(str->buffer, buf, str->buf_len); } } /******************************************************************* - Reads or writes a BUFFER2 structure. + Reads or writes a REGVAL_BUFFER structure. the uni_max_len member tells you how large the buffer is. the uni_str_len member tells you how much of the buffer is really used. ********************************************************************/ -BOOL smb_io_buffer2(const char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth) +BOOL smb_io_regval_buffer(const char *desc, prs_struct *ps, int depth, REGVAL_BUFFER *buf2) { - if (buf2 == NULL) - return False; - if (buffer) { - - prs_debug(ps, depth, desc, "smb_io_buffer2"); - depth++; + prs_debug(ps, depth, desc, "smb_io_regval_buffer"); + depth++; - if(!prs_align(ps)) - return False; + if(!prs_align(ps)) + return False; - if(!prs_uint32("uni_max_len", ps, depth, &buf2->buf_max_len)) - return False; - if(!prs_uint32("offset ", ps, depth, &buf2->offset)) - return False; - if(!prs_uint32("buf_len ", ps, depth, &buf2->buf_len)) - return False; - - /* buffer advanced by indicated length of string - NOT by searching for null-termination */ - - if(!prs_buffer2(True, "buffer ", ps, depth, buf2)) - return False; + if(!prs_uint32("uni_max_len", ps, depth, &buf2->buf_max_len)) + return False; + if(!prs_uint32("offset ", ps, depth, &buf2->offset)) + return False; + if(!prs_uint32("buf_len ", ps, depth, &buf2->buf_len)) + return False; - } else { + /* buffer advanced by indicated length of string + NOT by searching for null-termination */ - prs_debug(ps, depth, desc, "smb_io_buffer2 - NULL"); - depth++; - memset((char *)buf2, '\0', sizeof(*buf2)); + if(!prs_regval_buffer(True, "buffer ", ps, depth, buf2)) + return False; - } return True; } @@ -933,6 +859,28 @@ void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags) str->uni_max_len++; } +/******************************************************************* + Inits a UNISTR4 structure. +********************************************************************/ + +void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags) +{ + uni4->string = TALLOC_P( get_talloc_ctx(), UNISTR2 ); + init_unistr2( uni4->string, buf, flags ); + + uni4->length = 2 * (uni4->string->uni_str_len); + uni4->size = 2 * (uni4->string->uni_max_len); +} + +void init_unistr4_w( TALLOC_CTX *ctx, UNISTR4 *uni4, const smb_ucs2_t *buf ) +{ + uni4->string = TALLOC_P( ctx, UNISTR2 ); + init_unistr2_w( ctx, uni4->string, buf ); + + uni4->length = 2 * (uni4->string->uni_str_len); + uni4->size = 2 * (uni4->string->uni_max_len); +} + /** * Inits a UNISTR2 structure. * @param ctx talloc context to allocate string on @@ -1034,6 +982,57 @@ void init_unistr2_from_datablob(UNISTR2 *str, DATA_BLOB *blob) } /******************************************************************* + UNISTR2* are a little different in that the pointer and the UNISTR2 + are not necessarily read/written back to back. So we break it up + into 2 separate functions. + See SPOOL_USER_1 in include/rpc_spoolss.h for an example. +********************************************************************/ + +BOOL prs_io_unistr2_p(const char *desc, prs_struct *ps, int depth, UNISTR2 **uni2) +{ + uint32 data_p; + + /* caputure the pointer value to stream */ + + data_p = (uint32) *uni2; + + if ( !prs_uint32("ptr", ps, depth, &data_p )) + return False; + + /* we're done if there is no data */ + + if ( !data_p ) + return True; + + if (UNMARSHALLING(ps)) { + if ( !(*uni2 = PRS_ALLOC_MEM(ps, UNISTR2, 1)) ) + return False; + } + + return True; +} + +/******************************************************************* + now read/write the actual UNISTR2. Memory for the UNISTR2 (but + not UNISTR2.buffer) has been allocated previously by prs_unistr2_p() +********************************************************************/ + +BOOL prs_io_unistr2(const char *desc, prs_struct *ps, int depth, UNISTR2 *uni2 ) +{ + /* just return true if there is no pointer to deal with. + the memory must have been previously allocated on unmarshalling + by prs_unistr2_p() */ + + if ( !uni2 ) + return True; + + /* just pass off to smb_io_unstr2() passing the uni2 address as + the pointer (like you would expect) */ + + return smb_io_unistr2( desc, uni2, (uint32)uni2, ps, depth ); +} + +/******************************************************************* Reads or writes a UNISTR2 structure. XXXX NOTE: UNISTR2 structures need NOT be null-terminated. the uni_str_len member tells you how long the string is; @@ -1076,32 +1075,114 @@ BOOL smb_io_unistr2(const char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct * return True; } +/******************************************************************* + now read/write UNISTR4 +********************************************************************/ + +BOOL prs_unistr4(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4) +{ + if ( !prs_uint16("length", ps, depth, &uni4->length )) + return False; + if ( !prs_uint16("size", ps, depth, &uni4->size )) + return False; + + if ( !prs_pointer( desc, ps, depth, (void**)&uni4->string, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) ) + return False; + + return True; +} + +/******************************************************************* + now read/write UNISTR4 header +********************************************************************/ + +BOOL prs_unistr4_hdr(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4) +{ + prs_debug(ps, depth, desc, "prs_unistr4_hdr"); + depth++; + + if ( !prs_uint16("length", ps, depth, &uni4->length) ) + return False; + if ( !prs_uint16("size", ps, depth, &uni4->size) ) + return False; + if ( !prs_io_unistr2_p(desc, ps, depth, &uni4->string) ) + return False; + + return True; +} + +/******************************************************************* + now read/write UNISTR4 string +********************************************************************/ + +BOOL prs_unistr4_str(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4) +{ + prs_debug(ps, depth, desc, "prs_unistr4_str"); + depth++; + + if ( !prs_io_unistr2(desc, ps, depth, uni4->string) ) + return False; + + return True; +} + +/******************************************************************* + Reads or writes a UNISTR2_ARRAY structure. +********************************************************************/ -/* +BOOL prs_unistr4_array(const char *desc, prs_struct *ps, int depth, UNISTR4_ARRAY *array ) +{ + unsigned int i; + + prs_debug(ps, depth, desc, "prs_unistr4_array"); + depth++; + + if(!prs_uint32("count", ps, depth, &array->count)) + return False; + + if ( array->count == 0 ) + return True; + + if (UNMARSHALLING(ps)) { + if ( !(array->strings = TALLOC_ZERO_ARRAY( get_talloc_ctx(), UNISTR4, array->count)) ) + return False; + } + + /* write the headers and then the actual string buffer */ + + for ( i=0; i<array->count; i++ ) { + if ( !prs_unistr4_hdr( "string", ps, depth, &array->strings[i]) ) + return False; + } + + for (i=0;i<array->count;i++) { + if ( !prs_unistr4_str("string", ps, depth, &array->strings[i]) ) + return False; + } + + return True; +} + +/******************************************************************** initialise a UNISTR_ARRAY from a char** -*/ -BOOL init_unistr2_array(UNISTR2_ARRAY *array, - uint32 count, const char **strings) +********************************************************************/ + +BOOL init_unistr4_array( UNISTR4_ARRAY *array, uint32 count, const char **strings ) { unsigned int i; array->count = count; - array->ref_id = count?1:0; - if (array->count == 0) { + + if ( array->count == 0 ) return True; - } - array->strings = TALLOC_ZERO_ARRAY(get_talloc_ctx(), UNISTR2_ARRAY_EL, count ); - if (!array->strings) { + /* allocate memory for the array of UNISTR4 objects */ + + if ( !(array->strings = TALLOC_ZERO_ARRAY(get_talloc_ctx(), UNISTR4, count )) ) return False; - } - for (i=0;i<count;i++) { - init_unistr2(&array->strings[i].string, strings[i], UNI_FLAGS_NONE); - array->strings[i].size = array->strings[i].string.uni_max_len*2; - array->strings[i].length = array->strings[i].size; - array->strings[i].ref_id = 1; - } + for ( i=0; i<count; i++ ) + init_unistr4( &array->strings[i], strings[i], STR_TERMINATE ); return True; } @@ -1154,55 +1235,6 @@ BOOL smb_io_account_lockout_str(const char *desc, LOCKOUT_STRING *account_lockou } /******************************************************************* - Reads or writes a UNISTR2_ARRAY structure. -********************************************************************/ -BOOL smb_io_unistr2_array(const char *desc, UNISTR2_ARRAY *array, prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "smb_io_unistr2_array"); - depth++; - - if(!prs_uint32("ref_id", ps, depth, &array->ref_id)) - return False; - - if (! array->ref_id) { - return True; - } - - if(!prs_uint32("count", ps, depth, &array->count)) - return False; - - if (array->count == 0) { - return True; - } - - if (UNMARSHALLING(ps)) { - array->strings = TALLOC_ZERO_ARRAY(get_talloc_ctx(), UNISTR2_ARRAY_EL, array->count ); - } - if (! array->strings) { - return False; - } - - for (i=0;i<array->count;i++) { - if(!prs_uint16("length", ps, depth, &array->strings[i].length)) - return False; - if(!prs_uint16("size", ps, depth, &array->strings[i].size)) - return False; - if(!prs_uint32("ref_id", ps, depth, &array->strings[i].ref_id)) - return False; - } - - for (i=0;i<array->count;i++) { - if (! smb_io_unistr2("string", &array->strings[i].string, array->strings[i].ref_id, ps, depth)) - return False; - } - - return True; -} - - -/******************************************************************* Inits a DOM_RID2 structure. ********************************************************************/ @@ -1748,23 +1780,30 @@ BOOL smb_io_bufhdr4(const char *desc, BUFHDR4 *hdr, prs_struct *ps, int depth) } /******************************************************************* -reads or writes a BUFFER4 structure. +reads or writes a RPC_DATA_BLOB structure. ********************************************************************/ -BOOL smb_io_buffer4(const char *desc, BUFFER4 *buf4, uint32 buffer, prs_struct *ps, int depth) +BOOL smb_io_rpc_blob(const char *desc, RPC_DATA_BLOB *blob, prs_struct *ps, int depth) { - prs_debug(ps, depth, desc, "smb_io_buffer4"); + prs_debug(ps, depth, desc, "smb_io_rpc_blob"); depth++; prs_align(ps); - prs_uint32("buf_len", ps, depth, &buf4->buf_len); + if ( !prs_uint32("buf_len", ps, depth, &blob->buf_len) ) + return False; + + if ( blob->buf_len == 0 ) + return True; + if (UNMARSHALLING(ps)) { - buf4->buffer = PRS_ALLOC_MEM(ps, uint8, buf4->buf_len); - if (!buf4->buffer) { + blob->buffer = PRS_ALLOC_MEM(ps, uint8, blob->buf_len); + if (!blob->buffer) { return False; } } - prs_uint8s(True, "buffer", ps, depth, buf4->buffer, buf4->buf_len); + + if ( !prs_uint8s(True, "buffer", ps, depth, blob->buffer, blob->buf_len) ) + return False; return True; } @@ -1797,3 +1836,22 @@ BOOL make_bufhdr2(BUFHDR2 *hdr, uint32 info_level, uint32 length, uint32 buffer) return True; } + +/******************************************************************* +return the length of a UNISTR string. +********************************************************************/ + +uint32 str_len_uni(UNISTR *source) +{ + uint32 i=0; + + if (!source->buffer) + return 0; + + while (source->buffer[i]) + i++; + + return i; +} + + diff --git a/source/rpc_parse/parse_net.c b/source/rpc_parse/parse_net.c index d7bdca4df99..ed95656fdae 100644 --- a/source/rpc_parse/parse_net.c +++ b/source/rpc_parse/parse_net.c @@ -1972,8 +1972,7 @@ static BOOL net_io_sam_domain_info(const char *desc, SAM_DOMAIN_INFO * info, info->hdr_oem_info.buffer, ps, depth)) return False; - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) + if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) return False; if (!smb_io_account_lockout_str("account_lockout", &info->account_lockout, @@ -2021,8 +2020,7 @@ static BOOL net_io_sam_group_info(const char *desc, SAM_GROUP_INFO * info, if (!smb_io_unistr2("uni_grp_desc", &info->uni_grp_desc, info->hdr_grp_desc.buffer, ps, depth)) return False; - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) + if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) return False; return True; @@ -2274,8 +2272,7 @@ static BOOL net_io_sam_account_info(const char *desc, uint8 sess_key[16], if (!prs_uint32("unknown2", ps, depth, &info->unknown2)) return False; - if (!smb_io_buffer4("buf_logon_hrs", &info->buf_logon_hrs, - info->ptr_logon_hrs, ps, depth)) + if (!smb_io_rpc_blob("buf_logon_hrs", &info->buf_logon_hrs, ps, depth)) return False; prs_align(ps); if (!smb_io_unistr2("uni_comment", &info->uni_comment, @@ -2316,8 +2313,7 @@ static BOOL net_io_sam_account_info(const char *desc, uint8 sess_key[16], return False; ps->data_offset = old_offset + len; } - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) + if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) return False; prs_align(ps); if (!smb_io_unistr2("uni_profile", &info->uni_profile, @@ -2436,8 +2432,7 @@ static BOOL net_io_sam_alias_info(const char *desc, SAM_ALIAS_INFO * info, if (!smb_io_unistr2("uni_als_name", &info->uni_als_name, info->hdr_als_name.buffer, ps, depth)) return False; - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) + if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) return False; if (!smb_io_unistr2("uni_als_desc", &info->uni_als_desc, @@ -2596,8 +2591,7 @@ static BOOL net_io_sam_policy_info(const char *desc, SAM_DELTA_POLICY *info, if(!smb_io_dom_sid2("domain_sid", &info->domain_sid, ps, depth)) return False; - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) + if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) return False; @@ -2831,8 +2825,7 @@ static BOOL net_io_sam_privs_info(const char *desc, SAM_DELTA_PRIVS *info, if (!smb_io_unistr2("uni_privslist", &info->uni_privslist[i], True, ps, depth)) return False; - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) + if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) return False; return True; diff --git a/source/rpc_parse/parse_prs.c b/source/rpc_parse/parse_prs.c index 4b78d373bab..1b9ac51c613 100644 --- a/source/rpc_parse/parse_prs.c +++ b/source/rpc_parse/parse_prs.c @@ -589,6 +589,37 @@ BOOL prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8) } /******************************************************************* + Stream a uint16* (allocate memory if unmarshalling) + ********************************************************************/ + +BOOL prs_pointer( const char *name, prs_struct *ps, int depth, + void **data, size_t data_size, + BOOL(*prs_fn)(const char*, prs_struct*, int, void*) ) +{ + uint32 data_p; + + /* caputure the pointer value to stream */ + + data_p = (uint32) *data; + + if ( !prs_uint32("ptr", ps, depth, &data_p )) + return False; + + /* we're done if there is no data */ + + if ( !data_p ) + return True; + + if (UNMARSHALLING(ps)) { + if ( !(*data = PRS_ALLOC_MEM_VOID(ps, data_size)) ) + return False; + } + + return prs_fn(name, ps, depth, *data); +} + + +/******************************************************************* Stream a uint16. ********************************************************************/ @@ -598,12 +629,12 @@ BOOL prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16) if (q == NULL) return False; - if (UNMARSHALLING(ps)) { + if (UNMARSHALLING(ps)) { if (ps->bigendian_data) *data16 = RSVAL(q,0); else *data16 = SVAL(q,0); - } else { + } else { if (ps->bigendian_data) RSSVAL(q,0,*data16); else @@ -916,28 +947,28 @@ BOOL prs_buffer5(BOOL charmode, const char *name, prs_struct *ps, int depth, BUF in byte chars. String is in little-endian format. ********************************************************************/ -BOOL prs_buffer2(BOOL charmode, const char *name, prs_struct *ps, int depth, BUFFER2 *str) +BOOL prs_regval_buffer(BOOL charmode, const char *name, prs_struct *ps, int depth, REGVAL_BUFFER *buf) { char *p; - char *q = prs_mem_get(ps, str->buf_len); + char *q = prs_mem_get(ps, buf->buf_len); if (q == NULL) return False; if (UNMARSHALLING(ps)) { - if (str->buf_len > str->buf_max_len) { + if (buf->buf_len > buf->buf_max_len) { return False; } - if ( str->buf_max_len ) { - str->buffer = PRS_ALLOC_MEM(ps, uint16, str->buf_max_len); - if ( str->buffer == NULL ) + if ( buf->buf_max_len ) { + buf->buffer = PRS_ALLOC_MEM(ps, uint16, buf->buf_max_len); + if ( buf->buffer == NULL ) return False; } } - p = (char *)str->buffer; + p = (char *)buf->buffer; - dbg_rw_punival(charmode, name, depth, ps, q, p, str->buf_len/2); - ps->data_offset += str->buf_len; + dbg_rw_punival(charmode, name, depth, ps, q, p, buf->buf_len/2); + ps->data_offset += buf->buf_len; return True; } diff --git a/source/rpc_parse/parse_reg.c b/source/rpc_parse/parse_reg.c index a67a3973b95..a51b4269e3a 100644 --- a/source/rpc_parse/parse_reg.c +++ b/source/rpc_parse/parse_reg.c @@ -6,7 +6,8 @@ * Copyright (C) Paul Ashton 1997. * Copyright (C) Marc Jacobsen 1999. * Copyright (C) Simo Sorce 2000. - * Copyright (C) Gerald Carter 2002. + * Copyright (C) Jeremy Cooper 2004 + * Copyright (C) Gerald Carter 2002-2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,10 +30,10 @@ #define DBGC_CLASS DBGC_RPC_PARSE /******************************************************************* - Fill in a BUFFER2 for the data given a REGISTRY_VALUE + Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE *******************************************************************/ -static uint32 reg_init_buffer2( BUFFER2 *buf2, REGISTRY_VALUE *val ) +static uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val ) { uint32 real_size = 0; @@ -40,151 +41,72 @@ static uint32 reg_init_buffer2( BUFFER2 *buf2, REGISTRY_VALUE *val ) return 0; real_size = regval_size(val); - init_buffer2( buf2, (unsigned char*)regval_data_p(val), real_size ); + init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size ); return real_size; } /******************************************************************* - Inits a structure. + Inits a hive connect request structure ********************************************************************/ -void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o, - uint16 unknown_0, uint32 level) +void init_reg_q_open_hive( REG_Q_OPEN_HIVE *q_o, uint32 access_desired ) { - q_o->ptr = 1; - q_o->unknown_0 = unknown_0; - q_o->unknown_1 = 0x0; /* random - changes */ - q_o->level = level; + + q_o->server = TALLOC_P( get_talloc_ctx(), uint16); + *q_o->server = 0x1; + + q_o->access = access_desired; } /******************************************************************* -reads or writes a structure. +Marshalls a hive connect request ********************************************************************/ -BOOL reg_io_q_open_hkcr(const char *desc, REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_open_hive(const char *desc, REG_Q_OPEN_HIVE *q_u, + prs_struct *ps, int depth) { - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_open_hkcr"); + prs_debug(ps, depth, desc, "reg_io_q_open_hive"); depth++; if(!prs_align(ps)) return False; - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) + if(!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; - if (r_q->ptr != 0) { - if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0)) - return False; - if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1)) - return False; - if(!prs_uint32("level ", ps, depth, &r_q->level)) - return False; - } + if(!prs_uint32("access", ps, depth, &q_u->access)) + return False; return True; } /******************************************************************* -reads or writes a structure. +Unmarshalls a hive connect response ********************************************************************/ -BOOL reg_io_r_open_hkcr(const char *desc, REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_open_hive(const char *desc, REG_R_OPEN_HIVE *r_u, + prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; - prs_debug(ps, depth, desc, "reg_io_r_open_hkcr"); + prs_debug(ps, depth, desc, "reg_io_r_open_hive"); depth++; if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o, - uint16 unknown_0, uint32 access_mask) -{ - q_o->ptr = 1; - q_o->unknown_0 = unknown_0; - q_o->unknown_1 = 0x0; /* random - changes */ - q_o->access_mask = access_mask; - -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_q_open_hklm(const char *desc, REG_Q_OPEN_HKLM * r_q, prs_struct *ps, - int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_open_hklm"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr ", ps, depth, &(r_q->ptr))) - return False; - if (r_q->ptr != 0) - { - if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0))) - return False; - if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1))) - return False; - if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask))) - return False; - } - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_r_open_hklm(const char *desc, REG_R_OPEN_HKLM * r_r, prs_struct *ps, - int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_open_hklm"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("", &r_r->pol, ps, depth)) + if(!smb_io_pol_hnd("", &r_u->pol, ps, depth)) return False; - if (!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; } - - - /******************************************************************* Inits a structure. ********************************************************************/ @@ -198,9 +120,9 @@ void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol) reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_flush_key(const char *desc, REG_Q_FLUSH_KEY *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_flush_key(const char *desc, REG_Q_FLUSH_KEY *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_flush_key"); @@ -209,19 +131,20 @@ BOOL reg_io_q_flush_key(const char *desc, REG_Q_FLUSH_KEY *r_q, prs_struct *ps, if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; return True; } /******************************************************************* -reads or writes a structure. +Unmarshalls a registry key flush response ********************************************************************/ -BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_u, + prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_flush_key"); @@ -230,7 +153,7 @@ BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, if(!prs_align(ps)) return False; - if(!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; @@ -240,12 +163,14 @@ BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, reads or writes SEC_DESC_BUF and SEC_DATA structures. ********************************************************************/ -static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DESC_BUF *data, prs_struct *ps, int depth) +static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, + SEC_DESC_BUF *data, prs_struct *ps, int depth) { if (ptr != 0) { uint32 hdr_offset; uint32 old_offset; - if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset)) + if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, + &hdr_offset)) return False; old_offset = prs_offset(ps); @@ -256,14 +181,16 @@ static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DES } if (ptr3 == NULL || *ptr3 != 0) { - if(!sec_io_desc_buf("data ", &data, ps, depth)) /* JRA - this line is probably wrong... */ + /* JRA - this next line is probably wrong... */ + if(!sec_io_desc_buf("data ", &data, ps, depth)) return False; } - if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset, - data->max_len, data->len)) + if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, + hdr_offset, data->max_len, data->len)) return False; - if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3))) + if(!prs_set_offset(ps, old_offset + data->len + + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3))) return False; if(!prs_align(ps)) @@ -274,28 +201,25 @@ static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DES } /******************************************************************* - Inits a structure. + Inits a registry key create request ********************************************************************/ void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd, - char *name, char *class, SEC_ACCESS *sam_access, - SEC_DESC_BUF *sec_buf) + char *name, char *class, uint32 access_desired, + SEC_DESC_BUF *sec_buf) { ZERO_STRUCTP(q_c); memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); - init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE); - init_uni_hdr(&q_c->hdr_name, &q_c->uni_name); - init_unistr2(&q_c->uni_class, class, UNI_STR_TERMINATE); - init_uni_hdr(&q_c->hdr_class, &q_c->uni_class); + init_unistr4( &q_c->name, name, UNI_STR_TERMINATE ); + init_unistr4( &q_c->class, class, UNI_STR_TERMINATE ); - q_c->reserved = 0x00000000; - memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access)); + q_c->access = access_desired; - q_c->ptr1 = 1; - q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION; + q_c->sec_info = TALLOC_P( get_talloc_ctx(), uint32 ); + *q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION; q_c->data = sec_buf; q_c->ptr2 = 1; @@ -305,12 +229,13 @@ void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd, } /******************************************************************* -reads or writes a structure. +Marshalls a registry key create request ********************************************************************/ -BOOL reg_io_q_create_key(const char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_create_key(const char *desc, REG_Q_CREATE_KEY *q_u, + prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_create_key"); @@ -319,54 +244,49 @@ BOOL reg_io_q_create_key(const char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *p if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pnt_pol, ps, depth)) return False; - if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) + if(!prs_unistr4 ("name", ps, depth, &q_u->name)) return False; if(!prs_align(ps)) return False; - if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth)) + if(!prs_unistr4 ("class", ps, depth, &q_u->class)) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("reserved", ps, depth, &r_q->reserved)) + if(!prs_uint32("reserved", ps, depth, &q_u->reserved)) return False; - if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth)) + if(!prs_uint32("access", ps, depth, &q_u->access)) return False; - if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) + if(!prs_pointer("sec_info", ps, depth, (void**)&q_u->sec_info, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - if (r_q->ptr1 != 0) { - if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) - return False; - } - - if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) + if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2)) return False; - if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth)) + if(!reg_io_hdrbuf_sec(q_u->ptr2, &q_u->ptr3, &q_u->hdr_sec, q_u->data, + ps, depth)) return False; - if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2)) +#if 0 + if(!prs_uint32("unknown_2", ps, depth, &q_u->unknown_2)) return False; +#endif return True; } /******************************************************************* -reads or writes a structure. +Unmarshalls a registry key create response ********************************************************************/ -BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_u, + prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_create_key"); @@ -375,12 +295,12 @@ BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_r, prs_struct *p if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth)) + if(!smb_io_pol_hnd("", &r_u->key_pol, ps, depth)) return False; - if(!prs_uint32("unknown", ps, depth, &r_r->unknown)) + if(!prs_uint32("unknown", ps, depth, &r_u->unknown)) return False; - if(!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; @@ -392,23 +312,22 @@ BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_r, prs_struct *p ********************************************************************/ void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd, - char *name) + char *name) { ZERO_STRUCTP(q_c); memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); - - init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE); - init_uni_hdr(&q_c->hdr_name, &q_c->uni_name); + init_unistr4(&q_c->name, name, UNI_STR_TERMINATE); } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_delete_val(const char *desc, REG_Q_DELETE_VALUE *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_delete_val(const char *desc, REG_Q_DELETE_VALUE *q_u, + prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_delete_val"); @@ -417,12 +336,10 @@ BOOL reg_io_q_delete_val(const char *desc, REG_Q_DELETE_VALUE *r_q, prs_struct if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pnt_pol, ps, depth)) return False; - if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) + if(!prs_unistr4("name", ps, depth, &q_u->name)) return False; if(!prs_align(ps)) return False; @@ -435,9 +352,10 @@ BOOL reg_io_q_delete_val(const char *desc, REG_Q_DELETE_VALUE *r_q, prs_struct reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_u, + prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_delete_val"); @@ -446,7 +364,7 @@ BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_r, prs_struct if(!prs_align(ps)) return False; - if(!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; @@ -457,23 +375,23 @@ BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_r, prs_struct ********************************************************************/ void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd, - char *name) + char *name) { ZERO_STRUCTP(q_c); memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); - init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE); - init_uni_hdr(&q_c->hdr_name, &q_c->uni_name); + init_unistr4(&q_c->name, name, UNI_STR_TERMINATE); } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *q_u, + prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_delete_key"); @@ -482,12 +400,10 @@ BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *p if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pnt_pol, ps, depth)) return False; - if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) + if(!prs_unistr4("", ps, depth, &q_u->name)) return False; if(!prs_align(ps)) return False; @@ -499,9 +415,9 @@ BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *p reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_u, prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_delete_key"); @@ -510,7 +426,7 @@ BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_r, prs_struct *p if(!prs_align(ps)) return False; - if(!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; @@ -520,21 +436,21 @@ BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_r, prs_struct *p Inits a structure. ********************************************************************/ -void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, UNISTR2 *uni2) +void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, const char *class) { ZERO_STRUCTP(q_o); memcpy(&q_o->pol, hnd, sizeof(q_o->pol)); - init_uni_hdr(&q_o->hdr_class, uni2); + init_unistr4(&q_o->class, class, UNI_STR_TERMINATE); } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_query_key"); @@ -543,11 +459,9 @@ BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth)) + if(!prs_unistr4("class", ps, depth, &q_u->class)) return False; if(!prs_align(ps)) @@ -561,9 +475,9 @@ BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_u, prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_query_key"); @@ -572,32 +486,30 @@ BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, if(!prs_align(ps)) return False; - if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth)) + if(!prs_unistr4("class", ps, depth, &r_u->class)) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("num_subkeys ", ps, depth, &r_r->num_subkeys)) + if(!prs_uint32("num_subkeys ", ps, depth, &r_u->num_subkeys)) return False; - if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen)) + if(!prs_uint32("max_subkeylen ", ps, depth, &r_u->max_subkeylen)) return False; - if(!prs_uint32("reserved ", ps, depth, &r_r->reserved)) + if(!prs_uint32("reserved ", ps, depth, &r_u->reserved)) return False; - if(!prs_uint32("num_values ", ps, depth, &r_r->num_values)) + if(!prs_uint32("num_values ", ps, depth, &r_u->num_values)) return False; - if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen)) + if(!prs_uint32("max_valnamelen", ps, depth, &r_u->max_valnamelen)) return False; - if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize)) + if(!prs_uint32("max_valbufsize", ps, depth, &r_u->max_valbufsize)) return False; - if(!prs_uint32("sec_desc ", ps, depth, &r_r->sec_desc)) + if(!prs_uint32("sec_desc ", ps, depth, &r_u->sec_desc)) return False; - if(!smb_io_time("mod_time ", &r_r->mod_time, ps, depth)) + if(!smb_io_time("mod_time ", &r_u->mod_time, ps, depth)) return False; - if(!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; @@ -607,7 +519,7 @@ BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, Inits a structure. ********************************************************************/ -void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A *q_o, POLICY_HND *hnd) +void init_reg_q_getversion(REG_Q_GETVERSION *q_o, POLICY_HND *hnd) { memcpy(&q_o->pol, hnd, sizeof(q_o->pol)); } @@ -617,18 +529,18 @@ void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A *q_o, POLICY_HND *hnd) reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_unknown_1a(const char *desc, REG_Q_UNKNOWN_1A *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_getversion(const char *desc, REG_Q_GETVERSION *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; - prs_debug(ps, depth, desc, "reg_io_q_unknown_1a"); + prs_debug(ps, depth, desc, "reg_io_q_getversion"); depth++; if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; return True; @@ -638,20 +550,20 @@ BOOL reg_io_q_unknown_1a(const char *desc, REG_Q_UNKNOWN_1A *r_q, prs_struct *p reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_unknown_1a(const char *desc, REG_R_UNKNOWN_1A *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_getversion(const char *desc, REG_R_GETVERSION *r_u, prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; - prs_debug(ps, depth, desc, "reg_io_r_unknown_1a"); + prs_debug(ps, depth, desc, "reg_io_r_getversion"); depth++; if(!prs_align(ps)) return False; - if(!prs_uint32("unknown", ps, depth, &r_r->unknown)) + if(!prs_uint32("unknown", ps, depth, &r_u->unknown)) return False; - if(!prs_werror("status" , ps, depth, &r_r->status)) + if(!prs_werror("status" , ps, depth, &r_u->status)) return False; return True; @@ -662,26 +574,24 @@ BOOL reg_io_r_unknown_1a(const char *desc, REG_R_UNKNOWN_1A *r_r, prs_struct *p reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_restore_key(const char *desc, REG_Q_RESTORE_KEY *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; - prs_debug(ps, depth, desc, "reg_io_q_save_key"); + prs_debug(ps, depth, desc, "reg_io_q_restore_key"); depth++; if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!smb_io_unihdr ("hdr_file", &r_q->hdr_file, ps, depth)) - return False; - if(!smb_io_unistr2("uni_file", &r_q->uni_file, r_q->hdr_file.buffer, ps, depth)) + if(!prs_unistr4("filename", ps, depth, &q_u->filename)) return False; - if(!prs_uint32("unknown", ps, depth, &r_q->unknown)) + if(!prs_uint32("flags", ps, depth, &q_u->flags)) return False; return True; @@ -691,61 +601,48 @@ BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *r_q, prs_struct *ps, i reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_save_key(const char *desc, REG_R_SAVE_KEY *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_restore_key(const char *desc, REG_R_RESTORE_KEY *r_u, prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; - prs_debug(ps, depth, desc, "reg_io_r_save_key"); + prs_debug(ps, depth, desc, "reg_io_r_restore_key"); depth++; if(!prs_align(ps)) return False; - if(!prs_werror("status" , ps, depth, &r_r->status)) + if(!prs_werror("status" , ps, depth, &r_u->status)) return False; return True; } /******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o, - uint16 unknown_0, uint32 access_mask) -{ - q_o->ptr = 1; - q_o->unknown_0 = unknown_0; - q_o->unknown_1 = 0x0; /* random - changes */ - q_o->access_mask = access_mask; -} - -/******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_open_hku(const char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; - prs_debug(ps, depth, desc, "reg_io_q_open_hku"); + prs_debug(ps, depth, desc, "reg_io_q_save_key"); depth++; if(!prs_align(ps)) return False; - - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) + + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if (r_q->ptr != 0) { - if(!prs_uint16("unknown_0 ", ps, depth, &r_q->unknown_0)) - return False; - if(!prs_uint16("unknown_1 ", ps, depth, &r_q->unknown_1)) - return False; - if(!prs_uint32("access_mask ", ps, depth, &r_q->access_mask)) - return False; - } + + if(!prs_unistr4("filename", ps, depth, &q_u->filename)) + return False; + +#if 0 /* reg_io_sec_attr() */ + if(!prs_uint32("unknown", ps, depth, &q_u->unknown)) + return False; +#endif return True; } @@ -754,21 +651,18 @@ BOOL reg_io_q_open_hku(const char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, i reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_open_hku(const char *desc, REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_save_key(const char *desc, REG_R_SAVE_KEY *r_u, prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; - prs_debug(ps, depth, desc, "reg_io_r_open_hku"); + prs_debug(ps, depth, desc, "reg_io_r_save_key"); depth++; if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status" , ps, depth, &r_u->status)) return False; return True; @@ -814,7 +708,7 @@ reads or writes a structure. BOOL reg_io_r_close(const char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth) { - if (r_u == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_close"); @@ -838,24 +732,25 @@ BOOL reg_io_r_close(const char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int dep makes a structure. ********************************************************************/ -void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf) +void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_u, POLICY_HND *pol, + uint32 sec_info, SEC_DESC_BUF *sec_desc_buf) { - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); + memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - q_i->sec_info = DACL_SECURITY_INFORMATION; + q_u->sec_info = sec_info; - q_i->ptr = 1; - init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len); - q_i->data = sec_desc_buf; + q_u->ptr = 1; + init_buf_hdr(&q_u->hdr_sec, sec_desc_buf->len, sec_desc_buf->len); + q_u->data = sec_desc_buf; } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_set_key_sec"); @@ -864,15 +759,15 @@ BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) + if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info)) return False; - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) + if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) return False; - if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth)) + if(!reg_io_hdrbuf_sec(q_u->ptr, NULL, &q_u->hdr_sec, q_u->data, ps, depth)) return False; return True; @@ -882,9 +777,9 @@ BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth) +BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_set_key_sec"); @@ -893,7 +788,7 @@ BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct * if(!prs_align(ps)) return False; - if(!prs_werror("status", ps, depth, &r_q->status)) + if(!prs_werror("status", ps, depth, &q_u->status)) return False; return True; @@ -904,28 +799,27 @@ BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct * makes a structure. ********************************************************************/ -void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol, - uint32 sec_buf_size, SEC_DESC_BUF *psdb) +void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_u, POLICY_HND *pol, + uint32 sec_info, uint32 sec_buf_size, + SEC_DESC_BUF *psdb) { - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); + memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - q_i->sec_info = OWNER_SECURITY_INFORMATION | - GROUP_SECURITY_INFORMATION | - DACL_SECURITY_INFORMATION; + q_u->sec_info = sec_info; - q_i->ptr = psdb != NULL ? 1 : 0; - q_i->data = psdb; + q_u->ptr = psdb != NULL ? 1 : 0; + q_u->data = psdb; - init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0); + init_buf_hdr(&q_u->hdr_sec, sec_buf_size, 0); } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_get_key_sec"); @@ -934,15 +828,15 @@ BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) + if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info)) return False; - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) + if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) return False; - if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth)) + if(!reg_io_hdrbuf_sec(q_u->ptr, NULL, &q_u->hdr_sec, q_u->data, ps, depth)) return False; return True; @@ -968,9 +862,9 @@ makes a structure. reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth) +BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_get_key_sec"); @@ -979,19 +873,19 @@ BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct if(!prs_align(ps)) return False; - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) + if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) return False; - if (r_q->ptr != 0) { - if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth)) + if (q_u->ptr != 0) { + if(!smb_io_hdrbuf("", &q_u->hdr_sec, ps, depth)) return False; - if(!sec_io_desc_buf("", &r_q->data, ps, depth)) + if(!sec_io_desc_buf("", &q_u->data, ps, depth)) return False; if(!prs_align(ps)) return False; } - if(!prs_werror("status", ps, depth, &r_q->status)) + if(!prs_werror("status", ps, depth, &q_u->status)) return False; return True; @@ -1001,29 +895,29 @@ BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct makes a structure. ********************************************************************/ -BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name) +BOOL init_reg_q_info(REG_Q_INFO *q_u, POLICY_HND *pol, const char *val_name, + REGVAL_BUFFER *value_output) { - if (q_i == NULL) + if (q_u == NULL) return False; - q_i->pol = *pol; + q_u->pol = *pol; - init_unistr2(&q_i->uni_type, val_name, UNI_STR_TERMINATE); - init_uni_hdr(&q_i->hdr_type, &q_i->uni_type); + init_unistr4(&q_u->name, val_name, UNI_STR_TERMINATE); - q_i->ptr_reserved = 1; - q_i->ptr_buf = 1; + q_u->ptr_reserved = 1; + q_u->ptr_buf = 1; - q_i->ptr_bufsize = 1; - q_i->bufsize = 0; - q_i->buf_unk = 0; + q_u->ptr_bufsize = 1; + q_u->bufsize = value_output->buf_max_len; + q_u->buf_unk = 0; - q_i->unk1 = 0; - q_i->ptr_buflen = 1; - q_i->buflen = 0; + q_u->unk1 = 0; + q_u->ptr_buflen = 1; + q_u->buflen = value_output->buf_max_len; - q_i->ptr_buflen2 = 1; - q_i->buflen2 = 0; + q_u->ptr_buflen2 = 1; + q_u->buflen2 = 0; return True; } @@ -1032,9 +926,9 @@ BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name) reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_info(const char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_info(const char *desc, REG_Q_INFO *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_info"); @@ -1043,43 +937,41 @@ BOOL reg_io_q_info(const char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth)) + if(!prs_unistr4("name", ps, depth, &q_u->name)) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved))) + if(!prs_uint32("ptr_reserved", ps, depth, &(q_u->ptr_reserved))) return False; - if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf))) + if(!prs_uint32("ptr_buf", ps, depth, &(q_u->ptr_buf))) return False; - if(r_q->ptr_buf) { - if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize))) + if(q_u->ptr_buf) { + if(!prs_uint32("ptr_bufsize", ps, depth, &(q_u->ptr_bufsize))) return False; - if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize))) + if(!prs_uint32("bufsize", ps, depth, &(q_u->bufsize))) return False; - if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk))) + if(!prs_uint32("buf_unk", ps, depth, &(q_u->buf_unk))) return False; } - if(!prs_uint32("unk1", ps, depth, &(r_q->unk1))) + if(!prs_uint32("unk1", ps, depth, &(q_u->unk1))) return False; - if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen))) + if(!prs_uint32("ptr_buflen", ps, depth, &(q_u->ptr_buflen))) return False; - if (r_q->ptr_buflen) { - if(!prs_uint32("buflen", ps, depth, &(r_q->buflen))) + if (q_u->ptr_buflen) { + if(!prs_uint32("buflen", ps, depth, &(q_u->buflen))) return False; - if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2))) + if(!prs_uint32("ptr_buflen2", ps, depth, &(q_u->ptr_buflen2))) return False; - if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2))) + if(!prs_uint32("buflen2", ps, depth, &(q_u->buflen2))) return False; } @@ -1091,72 +983,36 @@ BOOL reg_io_q_info(const char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth New version to replace older init_reg_r_info() ********************************************************************/ -BOOL new_init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, +BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_u, REGISTRY_VALUE *val, WERROR status) { - uint32 buf_len = 0; - BUFFER2 buf2; + uint32 buf_len = 0; + REGVAL_BUFFER buf2; - if(r_r == NULL) + if( !r_u || !val ) return False; - if ( !val ) - return False; - - r_r->ptr_type = 1; - r_r->type = val->type; + r_u->type = TALLOC_P( get_talloc_ctx(), uint32 ); + *r_u->type = val->type; - /* if include_keyval is not set, don't send the key value, just - the buflen data. probably used by NT5 to allocate buffer space - SK */ - - if ( include_keyval ) { - r_r->ptr_uni_val = 1; - buf_len = reg_init_buffer2( &r_r->uni_val, val ); + buf_len = reg_init_regval_buffer( &buf2, val ); - } - else { - /* dummy buffer used so we can get the size */ - r_r->ptr_uni_val = 0; - buf_len = reg_init_buffer2( &buf2, val ); - } - - r_r->ptr_max_len = 1; - r_r->buf_max_len = buf_len; - - r_r->ptr_len = 1; - r_r->buf_len = buf_len; - - r_r->status = status; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, - BUFFER2* buf, uint32 type, WERROR status) -{ - if(r_r == NULL) - return False; - - r_r->ptr_type = 1; - r_r->type = type; + r_u->buf_max_len = TALLOC_P( get_talloc_ctx(), uint32 ); + *r_u->buf_max_len = buf_len; + r_u->buf_len = TALLOC_P( get_talloc_ctx(), uint32 ); + *r_u->buf_len = buf_len; + /* if include_keyval is not set, don't send the key value, just the buflen data. probably used by NT5 to allocate buffer space - SK */ - r_r->ptr_uni_val = include_keyval ? 1:0; - r_r->uni_val = *buf; - - r_r->ptr_max_len = 1; - r_r->buf_max_len = r_r->uni_val.buf_max_len; - - r_r->ptr_len = 1; - r_r->buf_len = r_r->uni_val.buf_len; + if ( include_keyval ) { + r_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER ); + /* steal the memory */ + *r_u->value = buf2; + } - r_r->status = status; + r_u->status = status; return True; } @@ -1165,9 +1021,9 @@ BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_info(const char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_info(const char *desc, REG_R_INFO *r_u, prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_info"); @@ -1176,41 +1032,20 @@ BOOL reg_io_r_info(const char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) if(!prs_align(ps)) return False; - if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type))) + if ( !prs_pointer("type", ps, depth, (void**)&r_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - if (r_r->ptr_type != 0) { - if(!prs_uint32("type", ps, depth, &r_r->type)) - return False; - } - - if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val))) + if ( !prs_pointer("value", ps, depth, (void**)&r_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer)) return False; - - if(r_r->ptr_uni_val != 0) { - if(!smb_io_buffer2("uni_val", &r_r->uni_val, r_r->ptr_uni_val, ps, depth)) - return False; - } - if(!prs_align(ps)) return False; - if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len))) + if ( !prs_pointer("buf_max_len", ps, depth, (void**)&r_u->buf_max_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - - if (r_r->ptr_max_len != 0) { - if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len))) + if ( !prs_pointer("buf_len", ps, depth, (void**)&r_u->buf_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - } - if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len))) - return False; - if (r_r->ptr_len != 0) { - if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len))) - return False; - } - - if(!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; @@ -1220,28 +1055,29 @@ BOOL reg_io_r_info(const char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) makes a structure. ********************************************************************/ -void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol, - uint32 val_idx, UNISTR2 *uni2, +void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_u, POLICY_HND *pol, + uint32 val_idx, char *name, uint32 max_buf_len) { - ZERO_STRUCTP(q_i); + ZERO_STRUCTP(q_u); + + memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); + q_u->val_index = val_idx; - q_i->val_index = val_idx; - init_uni_hdr(&q_i->hdr_name, uni2); + init_unistr4( &q_u->name, name, UNI_STR_TERMINATE ); - q_i->ptr_type = 1; - q_i->type = 0x0; + q_u->type = TALLOC_P( get_talloc_ctx(), uint32 ); + *q_u->type = 0x0; - q_i->ptr_value = 1; - q_i->buf_value.buf_max_len = max_buf_len; + q_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER ); + q_u->value->buf_max_len = max_buf_len; - q_i->ptr1 = 1; - q_i->len_value1 = max_buf_len; + q_u->len_value1 = TALLOC_P( get_talloc_ctx(), uint32 ); + *q_u->len_value1 = max_buf_len; - q_i->ptr2 = 1; - q_i->len_value2 = 0; + q_u->len_value2 = TALLOC_P( get_talloc_ctx(), uint32 ); + *q_u->len_value2 = max_buf_len; } /******************************************************************* @@ -1260,26 +1096,25 @@ void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val ) DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename)); - init_unistr2( &r_u->uni_name, val->valuename, UNI_STR_TERMINATE); - init_uni_hdr( &r_u->hdr_name, &r_u->uni_name); + init_unistr4( &r_u->name, val->valuename, UNI_STR_TERMINATE); /* type */ - r_u->ptr_type = 1; - r_u->type = val->type; + r_u->type = TALLOC_P( get_talloc_ctx(), uint32 ); + *r_u->type = val->type; /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */ - r_u->ptr_value = 1; - real_size = reg_init_buffer2( &r_u->buf_value, val ); + r_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER ); + real_size = reg_init_regval_buffer( r_u->value, val ); /* lengths */ - r_u->ptr1 = 1; - r_u->len_value1 = real_size; + r_u->len_value1 = TALLOC_P( get_talloc_ctx(), uint32 ); + *r_u->len_value1 = real_size; - r_u->ptr2 = 1; - r_u->len_value2 = real_size; + r_u->len_value2 = TALLOC_P( get_talloc_ctx(), uint32 ); + *r_u->len_value2 = real_size; DEBUG(8,("init_reg_r_enum_val: Exit\n")); } @@ -1288,9 +1123,9 @@ void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val ) reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth) +BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_u, prs_struct *ps, int depth) { - if (q_q == NULL) + if (q_u == NULL) return False; prs_debug(ps, depth, desc, "reg_io_q_enum_val"); @@ -1299,46 +1134,29 @@ BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!prs_uint32("val_index", ps, depth, &q_q->val_index)) + if(!prs_uint32("val_index", ps, depth, &q_u->val_index)) return False; - if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth)) + if(!prs_unistr4("name", ps, depth, &q_u->name )) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type)) + if(!prs_pointer("type", ps, depth, (void**)&q_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - if (q_q->ptr_type != 0) { - if(!prs_uint32("type", ps, depth, &q_q->type)) - return False; - } - - if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value)) - return False; - if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth)) + if ( !prs_pointer("value", ps, depth, (void**)&q_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer)) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1)) + if(!prs_pointer("len_value1", ps, depth, (void**)&q_u->len_value1, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - if (q_q->ptr1 != 0) { - if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1)) - return False; - } - if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2)) + if(!prs_pointer("len_value2", ps, depth, (void**)&q_u->len_value2, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - if (q_q->ptr2 != 0) { - if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2)) - return False; - } return True; } @@ -1347,9 +1165,9 @@ BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth) +BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_enum_val"); @@ -1358,43 +1176,26 @@ BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, if(!prs_align(ps)) return False; - if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) + if(!prs_unistr4("name", ps, depth, &r_u->name )) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type)) + if(!prs_pointer("type", ps, depth, (void**)&r_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - if (r_q->ptr_type != 0) { - if(!prs_uint32("type", ps, depth, &r_q->type)) - return False; - } - - if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value)) - return False; - if(!smb_io_buffer2("buf_value", &r_q->buf_value, r_q->ptr_value, ps, depth)) + if ( !prs_pointer("value", ps, depth, (void**)&r_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer)) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) + if(!prs_pointer("len_value1", ps, depth, (void**)&r_u->len_value1, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - if (r_q->ptr1 != 0) { - if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1)) - return False; - } - - if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) + if(!prs_pointer("len_value2", ps, depth, (void**)&r_u->len_value2, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; - if (r_q->ptr2 != 0) { - if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2)) - return False; - } - if(!prs_werror("status", ps, depth, &r_q->status)) + + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; @@ -1404,53 +1205,55 @@ BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, makes a structure. ********************************************************************/ -void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol, +void init_reg_q_set_val(REG_Q_SET_VALUE *q_u, POLICY_HND *pol, char *val_name, uint32 type, - BUFFER3 *val) + RPC_DATA_BLOB *val) { - ZERO_STRUCTP(q_i); + ZERO_STRUCTP(q_u); - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); + memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - init_unistr2(&q_i->uni_name, val_name, UNI_STR_TERMINATE); - init_uni_hdr(&q_i->hdr_name, &q_i->uni_name); + init_unistr4(&q_u->name, val_name, UNI_STR_TERMINATE); - q_i->type = type; - q_i->buf_value = val; + q_u->type = type; + q_u->value = *val; + q_u->size = val->buf_len; } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_create_val(const char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth) +BOOL reg_io_q_set_val(const char *desc, REG_Q_SET_VALUE *q_u, prs_struct *ps, int depth) { - if (q_q == NULL) + if (q_u == NULL) return False; - prs_debug(ps, depth, desc, "reg_io_q_create_val"); + prs_debug(ps, depth, desc, "reg_io_q_set_val"); depth++; if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth)) + if(!prs_unistr4("name", ps, depth, &q_u->name )) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("type", ps, depth, &q_q->type)) + if(!prs_uint32("type", ps, depth, &q_u->type)) return False; - if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth)) + + if(!smb_io_rpc_blob("value", &q_u->value, ps, depth )) return False; if(!prs_align(ps)) return False; + if(!prs_uint32("size", ps, depth, &q_u->size)) + return False; + return True; } @@ -1458,18 +1261,18 @@ BOOL reg_io_q_create_val(const char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_create_val(const char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth) +BOOL reg_io_r_set_val(const char *desc, REG_R_SET_VALUE *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; - prs_debug(ps, depth, desc, "reg_io_r_create_val"); + prs_debug(ps, depth, desc, "reg_io_r_set_val"); depth++; if(!prs_align(ps)) return False; - if(!prs_werror("status", ps, depth, &r_q->status)) + if(!prs_werror("status", ps, depth, &q_u->status)) return False; return True; @@ -1479,23 +1282,23 @@ BOOL reg_io_r_create_val(const char *desc, REG_R_CREATE_VALUE *r_q, prs_struct makes a structure. ********************************************************************/ -void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx) +void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_u, POLICY_HND *pol, uint32 key_idx) { - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); + memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - q_i->key_index = key_idx; - q_i->key_name_len = 0; - q_i->unknown_1 = 0x0414; + q_u->key_index = key_idx; + q_u->key_name_len = 0; + q_u->unknown_1 = 0x0414; - q_i->ptr1 = 1; - q_i->unknown_2 = 0x0000020A; - memset(q_i->pad1, 0, sizeof(q_i->pad1)); + q_u->ptr1 = 1; + q_u->unknown_2 = 0x0000020A; + memset(q_u->pad1, 0, sizeof(q_u->pad1)); - q_i->ptr2 = 1; - memset(q_i->pad2, 0, sizeof(q_i->pad2)); + q_u->ptr2 = 1; + memset(q_u->pad2, 0, sizeof(q_u->pad2)); - q_i->ptr3 = 1; - unix_to_nt_time(&q_i->time, 0); /* current time? */ + q_u->ptr3 = 1; + unix_to_nt_time(&q_u->time, 0); /* current time? */ } /******************************************************************* @@ -1525,9 +1328,9 @@ void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey, uint32 unknown_1, reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth) +BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_u, prs_struct *ps, int depth) { - if (q_q == NULL) + if (q_u == NULL) return False; prs_debug(ps, depth, desc, "reg_io_q_enum_key"); @@ -1536,39 +1339,39 @@ BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, i if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!prs_uint32("key_index", ps, depth, &q_q->key_index)) + if(!prs_uint32("key_index", ps, depth, &q_u->key_index)) return False; - if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len)) + if(!prs_uint16("key_name_len", ps, depth, &q_u->key_name_len)) return False; - if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1)) + if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1)) return False; - if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1)) + if(!prs_uint32("ptr1", ps, depth, &q_u->ptr1)) return False; - if (q_q->ptr1 != 0) { - if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2)) + if (q_u->ptr1 != 0) { + if(!prs_uint32("unknown_2", ps, depth, &q_u->unknown_2)) return False; - if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1))) + if(!prs_uint8s(False, "pad1", ps, depth, q_u->pad1, sizeof(q_u->pad1))) return False; } - if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2)) + if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2)) return False; - if (q_q->ptr2 != 0) { - if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2))) + if (q_u->ptr2 != 0) { + if(!prs_uint8s(False, "pad2", ps, depth, q_u->pad2, sizeof(q_u->pad2))) return False; } - if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3)) + if(!prs_uint32("ptr3", ps, depth, &q_u->ptr3)) return False; - if (q_q->ptr3 != 0) { - if(!smb_io_time("", &q_q->time, ps, depth)) + if (q_u->ptr3 != 0) { + if(!smb_io_time("", &q_u->time, ps, depth)) return False; } @@ -1579,9 +1382,9 @@ BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, i reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth) +BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_enum_key"); @@ -1590,42 +1393,42 @@ BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, i if(!prs_align(ps)) return False; - if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len)) + if(!prs_uint16("key_name_len", ps, depth, &q_u->key_name_len)) return False; - if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1)) + if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1)) return False; - if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) + if(!prs_uint32("ptr1", ps, depth, &q_u->ptr1)) return False; - if (r_q->ptr1 != 0) { - if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2)) + if (q_u->ptr1 != 0) { + if(!prs_uint32("unknown_2", ps, depth, &q_u->unknown_2)) return False; - if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3)) + if(!prs_uint32("unknown_3", ps, depth, &q_u->unknown_3)) return False; - if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth)) + if(!smb_io_unistr3("key_name", &q_u->key_name, ps, depth)) return False; if(!prs_align(ps)) return False; } - if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) + if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2)) return False; - if (r_q->ptr2 != 0) { - if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2))) + if (q_u->ptr2 != 0) { + if(!prs_uint8s(False, "pad2", ps, depth, q_u->pad2, sizeof(q_u->pad2))) return False; } - if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3)) + if(!prs_uint32("ptr3", ps, depth, &q_u->ptr3)) return False; - if (r_q->ptr3 != 0) { - if(!smb_io_time("", &r_q->time, ps, depth)) + if (q_u->ptr3 != 0) { + if(!smb_io_time("", &q_u->time, ps, depth)) return False; } - if(!prs_werror("status", ps, depth, &r_q->status)) + if(!prs_werror("status", ps, depth, &q_u->status)) return False; return True; @@ -1635,46 +1438,43 @@ BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, i makes a structure. ********************************************************************/ -void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol, +void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *q_u, POLICY_HND *pol, char *key_name, uint32 access_desired) { - memcpy(&r_q->pol, pol, sizeof(r_q->pol)); + memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - init_unistr2(&r_q->uni_name, key_name, UNI_STR_TERMINATE); - init_uni_hdr(&r_q->hdr_name, &r_q->uni_name); + init_unistr4(&q_u->name, key_name, UNI_STR_TERMINATE); - r_q->unknown_0 = 0x00000000; - r_q->access_desired = access_desired; + q_u->unknown_0 = 0x00000000; + q_u->access = access_desired; } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth) +BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *q_u, prs_struct *ps, int depth) { - if (r_q == NULL) + if ( !q_u ) return False; - prs_debug(ps, depth, desc, "reg_io_q_entry"); + prs_debug(ps, depth, desc, "reg_io_q_open_entry"); depth++; if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) + if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) return False; - if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) + if(!prs_unistr4("name", ps, depth, &q_u->name)) return False; if(!prs_align(ps)) return False; - if(!prs_uint32("unknown_0 ", ps, depth, &r_q->unknown_0)) + if(!prs_uint32("unknown_0 ", ps, depth, &q_u->unknown_0)) return False; - if(!prs_uint32("access_desired ", ps, depth, &r_q->access_desired)) + if(!prs_uint32("access", ps, depth, &q_u->access)) return False; return True; @@ -1684,24 +1484,24 @@ BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *p Inits a structure. ********************************************************************/ -void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r, +void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_u, POLICY_HND *pol, WERROR werr) { if (W_ERROR_IS_OK(werr)) { - memcpy(&r_r->pol, pol, sizeof(r_r->pol)); + memcpy(&r_u->pol, pol, sizeof(r_u->pol)); } else { - ZERO_STRUCT(r_r->pol); + ZERO_STRUCT(r_u->pol); } - r_r->status = werr; + r_u->status = werr; } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth) +BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_u, prs_struct *ps, int depth) { - if (r_r == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_open_entry"); @@ -1710,10 +1510,10 @@ BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *p if(!prs_align(ps)) return False; - if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) + if(!smb_io_pol_hnd("", &r_u->pol, ps, depth)) return False; - if(!prs_werror("status", ps, depth, &r_r->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; @@ -1723,30 +1523,53 @@ BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *p Inits a structure. ********************************************************************/ -void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s, const char *msg, +void init_reg_q_shutdown(REG_Q_SHUTDOWN *q_u, const char *msg, uint32 timeout, BOOL do_reboot, BOOL force) { - q_s->ptr_0 = 1; - q_s->ptr_1 = 1; - q_s->ptr_2 = 1; + q_u->server = TALLOC_P( get_talloc_ctx(), uint16 ); + *q_u->server = 0x1; + + q_u->message = TALLOC_P( get_talloc_ctx(), UNISTR4 ); + init_unistr4( q_u->message, msg, UNI_FLAGS_NONE ); - init_unistr2(&q_s->uni_msg, msg, UNI_FLAGS_NONE); - init_uni_hdr(&q_s->hdr_msg, &q_s->uni_msg); + q_u->timeout = timeout; + + q_u->reboot = do_reboot ? 1 : 0; + q_u->force = force ? 1 : 0; +} - q_s->timeout = timeout; +/******************************************************************* +Inits a REG_Q_SHUTDOWN_EX structure. +********************************************************************/ - q_s->reboot = do_reboot ? 1 : 0; - q_s->force = force ? 1 : 0; +void init_reg_q_shutdown_ex(REG_Q_SHUTDOWN_EX * q_u_ex, const char *msg, + uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason) +{ + REG_Q_SHUTDOWN q_u; + + ZERO_STRUCT( q_u ); + + init_reg_q_shutdown( &q_u, msg, timeout, do_reboot, force ); + + /* steal memory */ + + q_u_ex->server = q_u.server; + q_u_ex->message = q_u.message; + + q_u_ex->reboot = q_u.reboot; + q_u_ex->force = q_u.force; + + q_u_ex->reason = reason; } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps, +BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN *q_u, prs_struct *ps, int depth) { - if (q_s == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_shutdown"); @@ -1755,37 +1578,34 @@ BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps, if (!prs_align(ps)) return False; - if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0))) - return False; - if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1))) - return False; - if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2))) + if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; - if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth)) - return False; - if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth)) + if (!prs_pointer("message", ps, depth, (void**)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) return False; + if (!prs_align(ps)) return False; - if (!prs_uint32("timeout", ps, depth, &(q_s->timeout))) + if (!prs_uint32("timeout", ps, depth, &(q_u->timeout))) return False; - if (!prs_uint8("force ", ps, depth, &(q_s->force))) + + if (!prs_uint8("force ", ps, depth, &(q_u->force))) return False; - if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot))) + if (!prs_uint8("reboot ", ps, depth, &(q_u->reboot))) return False; + return True; } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps, +BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN *r_u, prs_struct *ps, int depth) { - if (r_s == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_shutdown"); @@ -1794,29 +1614,93 @@ BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps, if(!prs_align(ps)) return False; - if(!prs_werror("status", ps, depth, &r_s->status)) + if(!prs_werror("status", ps, depth, &r_u->status)) return False; return True; } /******************************************************************* -Inits a structure. +reads or writes a REG_Q_SHUTDOWN_EX structure. ********************************************************************/ -void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s) + +BOOL reg_io_q_shutdown_ex(const char *desc, REG_Q_SHUTDOWN_EX *q_u, prs_struct *ps, + int depth) { + if ( !q_u ) + return False; + + prs_debug(ps, depth, desc, "reg_io_q_shutdown_ex"); + depth++; + + if (!prs_align(ps)) + return False; + + if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) + return False; + + if (!prs_pointer("message", ps, depth, (void**)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) + return False; - q_s->ptr_server = 0; + if (!prs_align(ps)) + return False; + if (!prs_uint32("timeout", ps, depth, &(q_u->timeout))) + return False; + + if (!prs_uint8("force ", ps, depth, &(q_u->force))) + return False; + if (!prs_uint8("reboot ", ps, depth, &(q_u->reboot))) + return False; + + if (!prs_align(ps)) + return False; + if (!prs_uint32("reason", ps, depth, &(q_u->reason))) + return False; + + + return True; +} + +/******************************************************************* +reads or writes a REG_R_SHUTDOWN_EX structure. +********************************************************************/ +BOOL reg_io_r_shutdown_ex(const char *desc, REG_R_SHUTDOWN_EX *r_u, prs_struct *ps, + int depth) +{ + if ( !r_u ) + return False; + + prs_debug(ps, depth, desc, "reg_io_r_shutdown_ex"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + + + +/******************************************************************* +Inits a structure. +********************************************************************/ +void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN *q_u) +{ + q_u->server = TALLOC_P( get_talloc_ctx(), uint16 ); + *q_u->server = 0x1; } /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN * q_s, +BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN *q_u, prs_struct *ps, int depth) { - if (q_s == NULL) + if ( !q_u ) return False; prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown"); @@ -1825,11 +1709,8 @@ BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN * q_s, if (!prs_align(ps)) return False; - if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server))) + if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; - if (q_s->ptr_server != 0) - if (!prs_uint16("server", ps, depth, &(q_s->server))) - return False; return True; } @@ -1837,10 +1718,10 @@ BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN * q_s, /******************************************************************* reads or writes a structure. ********************************************************************/ -BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN * r_s, +BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN *r_u, prs_struct *ps, int depth) { - if (r_s == NULL) + if ( !r_u ) return False; prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown"); @@ -1849,7 +1730,7 @@ BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN * r_s, if (!prs_align(ps)) return False; - if (!prs_werror("status", ps, depth, &r_s->status)) + if (!prs_werror("status", ps, depth, &r_u->status)) return False; return True; diff --git a/source/rpc_parse/parse_rpc.c b/source/rpc_parse/parse_rpc.c index aa296eb70a1..6bdab2e437c 100644 --- a/source/rpc_parse/parse_rpc.c +++ b/source/rpc_parse/parse_rpc.c @@ -36,7 +36,7 @@ interface/version dce/rpc pipe identification 0x8a885d04, 0x1ceb, 0x11c9, \ { 0x9f, 0xe8 }, \ { 0x08, 0x00, \ - 0x2b, 0x10, 0x48, 0x60 } \ + 0x2b, 0x10, 0x48, 0x60 } \ }, 0x02 \ } @@ -46,7 +46,7 @@ interface/version dce/rpc pipe identification 0x8a885d04, 0x1ceb, 0x11c9, \ { 0x9f, 0xe8 }, \ { 0x08, 0x00, \ - 0x2b, 0x10, 0x48, 0x60 } \ + 0x2b, 0x10, 0x48, 0x60 } \ }, 0x02 \ } @@ -56,7 +56,7 @@ interface/version dce/rpc pipe identification 0x6bffd098, 0xa112, 0x3610, \ { 0x98, 0x33 }, \ { 0x46, 0xc3, \ - 0xf8, 0x7e, 0x34, 0x5a } \ + 0xf8, 0x7e, 0x34, 0x5a } \ }, 0x01 \ } @@ -66,7 +66,7 @@ interface/version dce/rpc pipe identification 0x4b324fc8, 0x1670, 0x01d3, \ { 0x12, 0x78 }, \ { 0x5a, 0x47, \ - 0xbf, 0x6e, 0xe1, 0x88 } \ + 0xbf, 0x6e, 0xe1, 0x88 } \ }, 0x03 \ } @@ -76,7 +76,7 @@ interface/version dce/rpc pipe identification 0x12345778, 0x1234, 0xabcd, \ { 0xef, 0x00 }, \ { 0x01, 0x23, \ - 0x45, 0x67, 0x89, 0xab } \ + 0x45, 0x67, 0x89, 0xab } \ }, 0x00 \ } @@ -86,7 +86,7 @@ interface/version dce/rpc pipe identification 0x3919286a, 0xb10c, 0x11d0, \ { 0x9b, 0xa8 }, \ { 0x00, 0xc0, \ - 0x4f, 0xd9, 0x2e, 0xf5 } \ + 0x4f, 0xd9, 0x2e, 0xf5 } \ }, 0x00 \ } @@ -96,7 +96,7 @@ interface/version dce/rpc pipe identification 0x12345778, 0x1234, 0xabcd, \ { 0xef, 0x00 }, \ { 0x01, 0x23, \ - 0x45, 0x67, 0x89, 0xac } \ + 0x45, 0x67, 0x89, 0xac } \ }, 0x01 \ } @@ -106,7 +106,7 @@ interface/version dce/rpc pipe identification 0x12345678, 0x1234, 0xabcd, \ { 0xef, 0x00 }, \ { 0x01, 0x23, \ - 0x45, 0x67, 0xcf, 0xfb } \ + 0x45, 0x67, 0xcf, 0xfb } \ }, 0x01 \ } @@ -116,7 +116,7 @@ interface/version dce/rpc pipe identification 0x338cd001, 0x2244, 0x31f1, \ { 0xaa, 0xaa }, \ { 0x90, 0x00, \ - 0x38, 0x00, 0x10, 0x03 } \ + 0x38, 0x00, 0x10, 0x03 } \ }, 0x01 \ } @@ -126,7 +126,7 @@ interface/version dce/rpc pipe identification 0x12345678, 0x1234, 0xabcd, \ { 0xef, 0x00 }, \ { 0x01, 0x23, \ - 0x45, 0x67, 0x89, 0xab } \ + 0x45, 0x67, 0x89, 0xab } \ }, 0x01 \ } @@ -136,7 +136,7 @@ interface/version dce/rpc pipe identification 0x0, 0x0, 0x0, \ { 0x00, 0x00 }, \ { 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00 } \ + 0x00, 0x00, 0x00, 0x00 } \ }, 0x00 \ } @@ -170,6 +170,27 @@ interface/version dce/rpc pipe identification }, 0x01 \ } +#define SYNT_SVCCTL_V2 \ +{ \ + { \ + 0x367abb81, 0x9844, 0x35f1, \ + { 0xad, 0x32 }, \ + { 0x98, 0xf0, \ + 0x38, 0x00, 0x10, 0x03 } \ + }, 0x02 \ +} + + +#define SYNT_EVENTLOG_V0 \ +{ \ + { \ + 0x82273fdc, 0xe32a, 0x18c3, \ + { 0x3f, 0x78 }, \ + { 0x82, 0x79, \ + 0x29, 0xdc, 0x23, 0xea } \ + }, 0x00 \ +} + /* * IMPORTANT!! If you update this structure, make sure to * update the index #defines in smb.h. @@ -189,6 +210,8 @@ const struct pipe_id_info pipe_names [] = { PIPE_NETDFS , SYNT_NETDFS_V3 , PIPE_NETDFS , TRANS_SYNT_V2 }, { PIPE_ECHO , SYNT_ECHO_V1 , PIPE_ECHO , TRANS_SYNT_V2 }, { PIPE_SHUTDOWN, SYNT_SHUTDOWN_V1 , PIPE_SHUTDOWN , TRANS_SYNT_V2 }, + { PIPE_SVCCTL , SYNT_SVCCTL_V2 , PIPE_NTSVCS , TRANS_SYNT_V2 }, + { PIPE_EVENTLOG, SYNT_EVENTLOG_V0 , PIPE_EVENTLOG , TRANS_SYNT_V2 }, { NULL , SYNT_NONE_V0 , NULL , SYNT_NONE_V0 } }; diff --git a/source/rpc_parse/parse_samr.c b/source/rpc_parse/parse_samr.c index 14d4bb9fdf7..d3f709c352c 100644 --- a/source/rpc_parse/parse_samr.c +++ b/source/rpc_parse/parse_samr.c @@ -1516,75 +1516,42 @@ BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e, inits a SAM_DISPINFO_1 structure. ********************************************************************/ -NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries, - uint32 start_idx, SAM_ACCOUNT *disp_user_info, - DOM_SID *domain_sid) +NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam, + uint32 num_entries, uint32 start_idx, + struct samr_displayentry *entries) { uint32 i; - SAM_ACCOUNT *pwd = NULL; - ZERO_STRUCTP(sam); - DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries)); if (num_entries==0) return NT_STATUS_OK; - sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries); - if (!sam->sam) + *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries); + if (*sam == NULL) return NT_STATUS_NO_MEMORY; - sam->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries); - if (!sam->str) + (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries); + if ((*sam)->sam == NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); + (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries); + if ((*sam)->str == NULL) + return NT_STATUS_NO_MEMORY; for (i = 0; i < num_entries ; i++) { - const char *username; - const char *fullname; - const char *acct_desc; - uint32 user_rid; - const DOM_SID *user_sid; - fstring user_sid_string, domain_sid_string; - - DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i)); - - pwd=&disp_user_info[i+start_idx]; - - username = pdb_get_username(pwd); - fullname = pdb_get_fullname(pwd); - acct_desc = pdb_get_acct_desc(pwd); - - if (!username) - username = ""; - - if (!fullname) - fullname = ""; - - if (!acct_desc) - acct_desc = ""; - - user_sid = pdb_get_user_sid(pwd); - - if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { - DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with " - "the domain sid %s. Failing operation.\n", - username, - sid_to_string(user_sid_string, user_sid), - sid_to_string(domain_sid_string, domain_sid))); - return NT_STATUS_UNSUCCESSFUL; - } - - init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), UNI_FLAGS_NONE); - init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), UNI_FLAGS_NONE); - init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), UNI_FLAGS_NONE); - - init_sam_entry1(&sam->sam[i], start_idx + i + 1, - &sam->str[i].uni_acct_name, &sam->str[i].uni_full_name, &sam->str[i].uni_acct_desc, - user_rid, pdb_get_acct_ctrl(pwd)); - + init_unistr2(&(*sam)->str[i].uni_acct_name, + entries[i].account_name, UNI_FLAGS_NONE); + init_unistr2(&(*sam)->str[i].uni_full_name, + entries[i].fullname, UNI_FLAGS_NONE); + init_unistr2(&(*sam)->str[i].uni_acct_desc, + entries[i].description, UNI_FLAGS_NONE); + + init_sam_entry1(&(*sam)->sam[i], start_idx+i+1, + &(*sam)->str[i].uni_acct_name, + &(*sam)->str[i].uni_full_name, + &(*sam)->str[i].uni_acct_desc, + entries[i].rid, entries[i].acct_flags); } return NT_STATUS_OK; @@ -1639,58 +1606,39 @@ static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam, inits a SAM_DISPINFO_2 structure. ********************************************************************/ -NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries, - uint32 start_idx, SAM_ACCOUNT *disp_user_info, - DOM_SID *domain_sid ) +NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam, + uint32 num_entries, uint32 start_idx, + struct samr_displayentry *entries) { uint32 i; - SAM_ACCOUNT *pwd = NULL; - ZERO_STRUCTP(sam); - DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries)); if (num_entries==0) return NT_STATUS_OK; - if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries))) + *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries); + if (*sam == NULL) return NT_STATUS_NO_MEMORY; - if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries))) + (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries); + if ((*sam)->sam == NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); + (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries); + if ((*sam)->str == NULL) + return NT_STATUS_NO_MEMORY; for (i = 0; i < num_entries; i++) { - uint32 user_rid; - const DOM_SID *user_sid; - const char *username; - const char *acct_desc; - fstring user_sid_string, domain_sid_string; - - DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i)); - pwd=&disp_user_info[i+start_idx]; - - username = pdb_get_username(pwd); - acct_desc = pdb_get_acct_desc(pwd); - user_sid = pdb_get_user_sid(pwd); - - if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { - DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with " - "the domain sid %s. Failing operation.\n", - username, - sid_to_string(user_sid_string, user_sid), - sid_to_string(domain_sid_string, domain_sid))); - return NT_STATUS_UNSUCCESSFUL; - } - - init_unistr2(&sam->str[i].uni_srv_name, username, UNI_FLAGS_NONE); - init_unistr2(&sam->str[i].uni_srv_desc, acct_desc, UNI_FLAGS_NONE); - - init_sam_entry2(&sam->sam[i], start_idx + i + 1, - &sam->str[i].uni_srv_name, &sam->str[i].uni_srv_desc, - user_rid, pdb_get_acct_ctrl(pwd)); + init_unistr2(&(*sam)->str[i].uni_srv_name, + entries[i].account_name, UNI_FLAGS_NONE); + init_unistr2(&(*sam)->str[i].uni_srv_desc, + entries[i].description, UNI_FLAGS_NONE); + + init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1, + &(*sam)->str[i].uni_srv_name, + &(*sam)->str[i].uni_srv_desc, + entries[i].rid, entries[i].acct_flags); } return NT_STATUS_OK; @@ -1747,37 +1695,39 @@ static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam, inits a SAM_DISPINFO_3 structure. ********************************************************************/ -NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries, - uint32 start_idx, DOMAIN_GRP *disp_group_info) +NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam, + uint32 num_entries, uint32 start_idx, + struct samr_displayentry *entries) { uint32 i; - ZERO_STRUCTP(sam); - DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries)); if (num_entries==0) return NT_STATUS_OK; - if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries))) + *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries); + if (*sam == NULL) return NT_STATUS_NO_MEMORY; - if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries))) + if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries))) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); + if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries))) + return NT_STATUS_NO_MEMORY; for (i = 0; i < num_entries; i++) { - DOMAIN_GRP *grp = &disp_group_info[i+start_idx]; - DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i)); - init_unistr2(&sam->str[i].uni_grp_name, grp->name, UNI_FLAGS_NONE); - init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, UNI_FLAGS_NONE); + init_unistr2(&(*sam)->str[i].uni_grp_name, + entries[i].account_name, UNI_FLAGS_NONE); + init_unistr2(&(*sam)->str[i].uni_grp_desc, + entries[i].description, UNI_FLAGS_NONE); - init_sam_entry3(&sam->sam[i], start_idx + i + 1, &sam->str[i].uni_grp_name, - &sam->str[i].uni_grp_desc, grp->rid); + init_sam_entry3(&(*sam)->sam[i], start_idx+i+1, + &(*sam)->str[i].uni_grp_name, + &(*sam)->str[i].uni_grp_desc, + entries[i].rid); } return NT_STATUS_OK; @@ -1834,38 +1784,40 @@ static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam, inits a SAM_DISPINFO_4 structure. ********************************************************************/ -NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries, - uint32 start_idx, SAM_ACCOUNT *disp_user_info) +NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam, + uint32 num_entries, uint32 start_idx, + struct samr_displayentry *entries) { - uint32 len_sam_name; uint32 i; - SAM_ACCOUNT *pwd = NULL; - ZERO_STRUCTP(sam); - DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries)); if (num_entries==0) return NT_STATUS_OK; - if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries))) + *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries); + if (*sam == NULL) return NT_STATUS_NO_MEMORY; - if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries))) + (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries); + if ((*sam)->sam == NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); + (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries); + if ((*sam)->str == NULL) + return NT_STATUS_NO_MEMORY; for (i = 0; i < num_entries; i++) { - DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i)); - pwd=&disp_user_info[i+start_idx]; + size_t len_sam_name = strlen(entries[i].account_name); - len_sam_name = strlen(pdb_get_username(pwd)); + DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i)); - init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name); + init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1, + len_sam_name); - init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name); + init_string2(&(*sam)->str[i].acct_name, + entries[i].account_name, len_sam_name+1, + len_sam_name); } return NT_STATUS_OK; @@ -1921,37 +1873,36 @@ static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam, inits a SAM_DISPINFO_5 structure. ********************************************************************/ -NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries, - uint32 start_idx, DOMAIN_GRP *disp_group_info) +NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam, + uint32 num_entries, uint32 start_idx, + struct samr_displayentry *entries) { uint32 len_sam_name; uint32 i; - ZERO_STRUCTP(sam); - DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries)); if (num_entries==0) return NT_STATUS_OK; - if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries))) + *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries); + if (*sam == NULL) return NT_STATUS_NO_MEMORY; - if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries))) + if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries))) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); + if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries))) + return NT_STATUS_NO_MEMORY; for (i = 0; i < num_entries; i++) { - DOMAIN_GRP *grp = &disp_group_info[i+start_idx]; - DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i)); - len_sam_name = strlen(grp->name); + len_sam_name = strlen(entries[i].account_name); - init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name); - init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name); + init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name); + init_string2(&(*sam)->str[i].grp_name, entries[i].account_name, + len_sam_name+1, len_sam_name); } return NT_STATUS_OK; diff --git a/source/rpc_parse/parse_sec.c b/source/rpc_parse/parse_sec.c index f6fdf102928..6a752688a0b 100644 --- a/source/rpc_parse/parse_sec.c +++ b/source/rpc_parse/parse_sec.c @@ -133,7 +133,7 @@ BOOL sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth) * Note that the size is always a multiple of 4 bytes due to the * nature of the data structure. Therefore the prs_align() calls * have been removed as they through us off when doing two-layer - * marshalling such as in the printing code (NEW_BUFFER). --jerry + * marshalling such as in the printing code (RPC_BUFFER). --jerry */ if (ppsa == NULL) diff --git a/source/rpc_parse/parse_shutdown.c b/source/rpc_parse/parse_shutdown.c index ad2d6e1a028..00daeaaaee7 100644 --- a/source/rpc_parse/parse_shutdown.c +++ b/source/rpc_parse/parse_shutdown.c @@ -2,6 +2,7 @@ * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. + * Copyright (C) Gerald (Jerry) Carter 2002-2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,12 +31,11 @@ Inits a structure. void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg, uint32 timeout, BOOL do_reboot, BOOL force) { - q_s->ptr_server = 1; - q_s->server = 1; - q_s->ptr_msg = 1; + q_s->server = TALLOC_P( get_talloc_ctx(), uint16 ); + *q_s->server = 0x1; - init_unistr2(&q_s->uni_msg, msg, UNI_FLAGS_NONE); - init_uni_hdr(&q_s->hdr_msg, &q_s->uni_msg); + q_s->message = TALLOC_P( get_talloc_ctx(), UNISTR4 ); + init_unistr4( q_s->message, msg, UNI_FLAGS_NONE ); q_s->timeout = timeout; @@ -44,6 +44,29 @@ void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg, } /******************************************************************* +********************************************************************/ + +void init_shutdown_q_init_ex(SHUTDOWN_Q_INIT_EX * q_u_ex, const char *msg, + uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason) +{ + SHUTDOWN_Q_INIT q_u; + + ZERO_STRUCT( q_u ); + + init_shutdown_q_init( &q_u, msg, timeout, do_reboot, force ); + + /* steal memory */ + + q_u_ex->server = q_u.server; + q_u_ex->message = q_u.message; + + q_u_ex->reboot = q_u.reboot; + q_u_ex->force = q_u.force; + + q_u_ex->reason = reason; +} + +/******************************************************************* reads or writes a structure. ********************************************************************/ @@ -59,62 +82,119 @@ BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps, if (!prs_align(ps)) return False; - if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server))) + if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; - if (!prs_uint16("server", ps, depth, &(q_s->server))) + + if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) return False; if (!prs_align(ps)) return False; - if (!prs_uint32("ptr_msg", ps, depth, &(q_s->ptr_msg))) + + if (!prs_uint32("timeout", ps, depth, &(q_s->timeout))) return False; - if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth)) + if (!prs_uint8("force ", ps, depth, &(q_s->force))) return False; - if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth)) + if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot))) return False; + + + return True; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps, + int depth) +{ + if (r_s == NULL) + return False; + + prs_debug(ps, depth, desc, "shutdown_io_r_init"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_werror("status", ps, depth, &r_s->status)) + return False; + + return True; +} + +/******************************************************************* +reads or writes a REG_Q_SHUTDOWN_EX structure. +********************************************************************/ + +BOOL shutdown_io_q_init_ex(const char *desc, SHUTDOWN_Q_INIT_EX * q_s, prs_struct *ps, + int depth) +{ + if (q_s == NULL) + return False; + + prs_debug(ps, depth, desc, "shutdown_io_q_init_ex"); + depth++; + + if (!prs_align(ps)) + return False; + + if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) + return False; + + if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) + return False; + if (!prs_align(ps)) return False; if (!prs_uint32("timeout", ps, depth, &(q_s->timeout))) return False; + if (!prs_uint8("force ", ps, depth, &(q_s->force))) return False; if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot))) return False; + if (!prs_align(ps)) + return False; + if (!prs_uint32("reason", ps, depth, &(q_s->reason))) + return False; + + return True; } /******************************************************************* -reads or writes a structure. +reads or writes a REG_R_SHUTDOWN_EX structure. ********************************************************************/ -BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps, - int depth) +BOOL shutdown_io_r_init_ex(const char *desc, SHUTDOWN_R_INIT_EX * r_s, prs_struct *ps, + int depth) { if (r_s == NULL) return False; - prs_debug(ps, depth, desc, "shutdown_io_r_init"); + prs_debug(ps, depth, desc, "shutdown_io_r_init_ex"); depth++; if(!prs_align(ps)) return False; - if(!prs_ntstatus("status", ps, depth, &r_s->status)) + if(!prs_werror("status", ps, depth, &r_s->status)) return False; return True; } + /******************************************************************* Inits a structure. ********************************************************************/ void init_shutdown_q_abort(SHUTDOWN_Q_ABORT *q_s) { - - q_s->ptr_server = 0; - + q_s->server = TALLOC_P( get_talloc_ctx(), uint16 ); + *q_s->server = 0x1; } /******************************************************************* @@ -132,11 +212,8 @@ BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s, if (!prs_align(ps)) return False; - if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server))) + if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; - if (q_s->ptr_server != 0) - if (!prs_uint16("server", ps, depth, &(q_s->server))) - return False; return True; } @@ -156,7 +233,7 @@ BOOL shutdown_io_r_abort(const char *desc, SHUTDOWN_R_ABORT *r_s, if (!prs_align(ps)) return False; - if (!prs_ntstatus("status", ps, depth, &r_s->status)) + if (!prs_werror("status", ps, depth, &r_s->status)) return False; return True; diff --git a/source/rpc_parse/parse_spoolss.c b/source/rpc_parse/parse_spoolss.c index dc419a73b5f..78602dd806a 100644 --- a/source/rpc_parse/parse_spoolss.c +++ b/source/rpc_parse/parse_spoolss.c @@ -27,22 +27,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_PARSE -/******************************************************************* -return the length of a UNISTR string. -********************************************************************/ - -static uint32 str_len_uni(UNISTR *source) -{ - uint32 i=0; - - if (!source->buffer) - return 0; - - while (source->buffer[i]) - i++; - - return i; -} /******************************************************************* This should be moved in a more generic lib. @@ -566,23 +550,22 @@ static BOOL smb_io_notify_info(const char *desc, SPOOL_NOTIFY_INFO *info, prs_st /******************************************************************* ********************************************************************/ -static BOOL spool_io_user_level_1(const char *desc, SPOOL_USER_1 *q_u, prs_struct *ps, int depth) +BOOL spool_io_user_level_1( const char *desc, prs_struct *ps, int depth, SPOOL_USER_1 *q_u ) { prs_debug(ps, depth, desc, ""); depth++; - /* reading */ - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(q_u); - if (!prs_align(ps)) return False; + if (!prs_uint32("size", ps, depth, &q_u->size)) return False; - if (!prs_uint32("client_name_ptr", ps, depth, &q_u->client_name_ptr)) + + if (!prs_io_unistr2_p("", ps, depth, &q_u->client_name)) return False; - if (!prs_uint32("user_name_ptr", ps, depth, &q_u->user_name_ptr)) + if (!prs_io_unistr2_p("", ps, depth, &q_u->user_name)) return False; + if (!prs_uint32("build", ps, depth, &q_u->build)) return False; if (!prs_uint32("major", ps, depth, &q_u->major)) @@ -592,11 +575,12 @@ static BOOL spool_io_user_level_1(const char *desc, SPOOL_USER_1 *q_u, prs_struc if (!prs_uint32("processor", ps, depth, &q_u->processor)) return False; - if (!smb_io_unistr2("", &q_u->client_name, q_u->client_name_ptr, ps, depth)) + if (!prs_io_unistr2("", ps, depth, q_u->client_name)) return False; if (!prs_align(ps)) return False; - if (!smb_io_unistr2("", &q_u->user_name, q_u->user_name_ptr, ps, depth)) + + if (!prs_io_unistr2("", ps, depth, q_u->user_name)) return False; return True; @@ -616,21 +600,20 @@ static BOOL spool_io_user_level(const char *desc, SPOOL_USER_CTR *q_u, prs_struc if (!prs_align(ps)) return False; - /* From looking at many captures in ethereal, it looks like - the level and ptr fields should be transposed. -tpot */ - if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if (!prs_uint32("ptr", ps, depth, &q_u->ptr)) - return False; - switch (q_u->level) { - case 1: - if (!spool_io_user_level_1("", &q_u->user1, ps, depth)) - return False; - break; - default: - return False; + switch ( q_u->level ) + { + case 1: + if ( !prs_pointer( "" , ps, depth, (void**)&q_u->user.user1, + sizeof(SPOOL_USER_1), (PRS_POINTER_CAST)spool_io_user_level_1 )) + { + return False; + } + break; + default: + return False; } return True; @@ -915,30 +898,31 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, const fstring user_name) { DEBUG(5,("make_spoolss_q_open_printer_ex\n")); - q_u->printername_ptr = (printername!=NULL)?1:0; - init_unistr2(&q_u->printername, printername, UNI_STR_TERMINATE); + + q_u->printername = TALLOC_P( get_talloc_ctx(), UNISTR2 ); + init_unistr2(q_u->printername, printername, UNI_STR_TERMINATE); q_u->printer_default.datatype_ptr = 0; -/* - q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0; - init_unistr2(&q_u->printer_default.datatype, datatype, UNI_FLAGS_NONE); -*/ + q_u->printer_default.devmode_cont.size=0; q_u->printer_default.devmode_cont.devmode_ptr=0; q_u->printer_default.devmode_cont.devmode=NULL; q_u->printer_default.access_required=access_required; - q_u->user_switch=1; - q_u->user_ctr.level=1; - q_u->user_ctr.ptr=1; - q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+10; - q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0; - q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0; - q_u->user_ctr.user1.build=1381; - q_u->user_ctr.user1.major=2; - q_u->user_ctr.user1.minor=0; - q_u->user_ctr.user1.processor=0; - init_unistr2(&q_u->user_ctr.user1.client_name, clientname, UNI_STR_TERMINATE); - init_unistr2(&q_u->user_ctr.user1.user_name, user_name, UNI_STR_TERMINATE); + + q_u->user_switch = 1; + + q_u->user_ctr.level = 1; + q_u->user_ctr.user.user1->size = strlen(clientname) + strlen(user_name) + 10; + q_u->user_ctr.user.user1->build = 1381; + q_u->user_ctr.user.user1->major = 2; + q_u->user_ctr.user.user1->minor = 0; + q_u->user_ctr.user.user1->processor = 0; + + q_u->user_ctr.user.user1->client_name = TALLOC_P( get_talloc_ctx(), UNISTR2 ); + q_u->user_ctr.user.user1->user_name = TALLOC_P( get_talloc_ctx(), UNISTR2 ); + + init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE); + init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE); return True; } @@ -947,23 +931,19 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, * init a structure. ********************************************************************/ -BOOL make_spoolss_q_addprinterex( - TALLOC_CTX *mem_ctx, - SPOOL_Q_ADDPRINTEREX *q_u, - const char *srv_name, - const char* clientname, - const char* user_name, - uint32 level, - PRINTER_INFO_CTR *ctr) +BOOL make_spoolss_q_addprinterex( TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTEREX *q_u, + const char *srv_name, const char* clientname, const char* user_name, + uint32 level, PRINTER_INFO_CTR *ctr) { DEBUG(5,("make_spoolss_q_addprinterex\n")); - if (!ctr) return False; + if (!ctr) + return False; ZERO_STRUCTP(q_u); - q_u->server_name_ptr = (srv_name!=NULL)?1:0; - init_unistr2(&q_u->server_name, srv_name, UNI_FLAGS_NONE); + q_u->server_name = TALLOC_P( mem_ctx, UNISTR2 ); + init_unistr2(q_u->server_name, srv_name, UNI_FLAGS_NONE); q_u->level = level; @@ -983,18 +963,20 @@ BOOL make_spoolss_q_addprinterex( q_u->user_switch=1; - q_u->user_ctr.level=1; - q_u->user_ctr.ptr=1; - q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0; - q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0; - q_u->user_ctr.user1.build=1381; - q_u->user_ctr.user1.major=2; - q_u->user_ctr.user1.minor=0; - q_u->user_ctr.user1.processor=0; - init_unistr2(&q_u->user_ctr.user1.client_name, clientname, UNI_STR_TERMINATE); - init_unistr2(&q_u->user_ctr.user1.user_name, user_name, UNI_STR_TERMINATE); - q_u->user_ctr.user1.size=q_u->user_ctr.user1.user_name.uni_str_len + - q_u->user_ctr.user1.client_name.uni_str_len + 2; + q_u->user_ctr.level = 1; + q_u->user_ctr.user.user1->build = 1381; + q_u->user_ctr.user.user1->major = 2; + q_u->user_ctr.user.user1->minor = 0; + q_u->user_ctr.user.user1->processor = 0; + + q_u->user_ctr.user.user1->client_name = TALLOC_P( mem_ctx, UNISTR2 ); + q_u->user_ctr.user.user1->user_name = TALLOC_P( mem_ctx, UNISTR2 ); + + init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE); + init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE); + + q_u->user_ctr.user.user1->size = q_u->user_ctr.user.user1->user_name->uni_str_len + + q_u->user_ctr.user.user1->client_name->uni_str_len + 2; return True; } @@ -1118,9 +1100,9 @@ BOOL spoolss_io_q_open_printer(const char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_ if (!prs_align(ps)) return False; - if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr)) + if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->printername)) return False; - if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth)) + if (!prs_io_unistr2("printername", ps, depth, q_u->printername)) return False; if (!prs_align(ps)) @@ -1174,9 +1156,9 @@ BOOL spoolss_io_q_open_printer_ex(const char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u if (!prs_align(ps)) return False; - if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr)) + if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->printername)) return False; - if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth)) + if (!prs_io_unistr2("printername", ps, depth, q_u->printername)) return False; if (!prs_align(ps)) @@ -2068,33 +2050,6 @@ static uint32 size_of_nttime(NTTIME *value) } /******************************************************************* - * return the length of a UNICODE string in number of char, includes: - * - the leading zero - * - the relative pointer size - ********************************************************************/ - -static uint32 size_of_relative_string(UNISTR *string) -{ - uint32 size=0; - - size=str_len_uni(string); /* the string length */ - size=size+1; /* add the trailing zero */ - size=size*2; /* convert in char */ - size=size+4; /* add the size of the ptr */ - -#if 0 /* JERRY */ - /* - * Do not include alignment as Win2k does not align relative - * strings within a buffer --jerry - */ - /* Ensure size is 4 byte multiple (prs_align is being called...). */ - /* size += ((4 - (size & 3)) & 3); */ -#endif - - return size; -} - -/******************************************************************* * return the length of a uint32 (obvious, but the code is clean) ********************************************************************/ @@ -2119,277 +2074,10 @@ static uint32 size_of_systemtime(SYSTEMTIME *systime) } /******************************************************************* - * write a UNICODE string and its relative pointer. - * used by all the RPC structs passing a buffer - * - * As I'm a nice guy, I'm forcing myself to explain this code. - * MS did a good job in the overall spoolss code except in some - * functions where they are passing the API buffer directly in the - * RPC request/reply. That's to maintain compatiility at the API level. - * They could have done it the good way the first time. - * - * So what happen is: the strings are written at the buffer's end, - * in the reverse order of the original structure. Some pointers to - * the strings are also in the buffer. Those are relative to the - * buffer's start. - * - * If you don't understand or want to change that function, - * first get in touch with me: jfm@samba.org - * - ********************************************************************/ - -static BOOL smb_io_relstr(const char *desc, NEW_BUFFER *buffer, int depth, UNISTR *string) -{ - prs_struct *ps=&buffer->prs; - - if (MARSHALLING(ps)) { - uint32 struct_offset = prs_offset(ps); - uint32 relative_offset; - - buffer->string_at_end -= (size_of_relative_string(string) - 4); - if(!prs_set_offset(ps, buffer->string_at_end)) - return False; -#if 0 /* JERRY */ - /* - * Win2k does not align strings in a buffer - * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry - */ - if (!prs_align(ps)) - return False; -#endif - buffer->string_at_end = prs_offset(ps); - - /* write the string */ - if (!smb_io_unistr(desc, string, ps, depth)) - return False; - - if(!prs_set_offset(ps, struct_offset)) - return False; - - relative_offset=buffer->string_at_end - buffer->struct_start; - /* write its offset */ - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - } - else { - uint32 old_offset; - - /* read the offset */ - if (!prs_uint32("offset", ps, depth, &(buffer->string_at_end))) - return False; - - if (buffer->string_at_end == 0) - return True; - - old_offset = prs_offset(ps); - if(!prs_set_offset(ps, buffer->string_at_end+buffer->struct_start)) - return False; - - /* read the string */ - if (!smb_io_unistr(desc, string, ps, depth)) - return False; - - if(!prs_set_offset(ps, old_offset)) - return False; - } - return True; -} - -/******************************************************************* - * write a array of UNICODE strings and its relative pointer. - * used by 2 RPC structs - ********************************************************************/ - -static BOOL smb_io_relarraystr(const char *desc, NEW_BUFFER *buffer, int depth, uint16 **string) -{ - UNISTR chaine; - - prs_struct *ps=&buffer->prs; - - if (MARSHALLING(ps)) { - uint32 struct_offset = prs_offset(ps); - uint32 relative_offset; - uint16 *p; - uint16 *q; - uint16 zero=0; - p=*string; - q=*string; - - /* first write the last 0 */ - buffer->string_at_end -= 2; - if(!prs_set_offset(ps, buffer->string_at_end)) - return False; - - if(!prs_uint16("leading zero", ps, depth, &zero)) - return False; - - while (p && (*p!=0)) { - while (*q!=0) - q++; - - /* Yes this should be malloc not talloc. Don't change. */ - - chaine.buffer = SMB_MALLOC((q-p+1)*sizeof(uint16)); - if (chaine.buffer == NULL) - return False; - - memcpy(chaine.buffer, p, (q-p+1)*sizeof(uint16)); - - buffer->string_at_end -= (q-p+1)*sizeof(uint16); - - if(!prs_set_offset(ps, buffer->string_at_end)) { - SAFE_FREE(chaine.buffer); - return False; - } - - /* write the string */ - if (!smb_io_unistr(desc, &chaine, ps, depth)) { - SAFE_FREE(chaine.buffer); - return False; - } - q++; - p=q; - - SAFE_FREE(chaine.buffer); - } - - if(!prs_set_offset(ps, struct_offset)) - return False; - - relative_offset=buffer->string_at_end - buffer->struct_start; - /* write its offset */ - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - - } else { - - /* UNMARSHALLING */ - - uint32 old_offset; - uint16 *chaine2=NULL; - int l_chaine=0; - int l_chaine2=0; - size_t realloc_size = 0; - - *string=NULL; - - /* read the offset */ - if (!prs_uint32("offset", ps, depth, &buffer->string_at_end)) - return False; - - old_offset = prs_offset(ps); - if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start)) - return False; - - do { - if (!smb_io_unistr(desc, &chaine, ps, depth)) - return False; - - l_chaine=str_len_uni(&chaine); - - /* we're going to add two more bytes here in case this - is the last string in the array and we need to add - an extra NULL for termination */ - if (l_chaine > 0) - { - uint16 *tc2; - - realloc_size = (l_chaine2+l_chaine+2)*sizeof(uint16); - - /* Yes this should be realloc - it's freed below. JRA */ - - if((tc2=(uint16 *)SMB_REALLOC(chaine2, realloc_size)) == NULL) { - SAFE_FREE(chaine2); - return False; - } - else chaine2 = tc2; - memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16)); - l_chaine2+=l_chaine+1; - } - - } while(l_chaine!=0); - - /* the end should be bould NULL terminated so add - the second one here */ - if (chaine2) - { - chaine2[l_chaine2] = '\0'; - *string=(uint16 *)TALLOC_MEMDUP(prs_get_mem_context(ps),chaine2,realloc_size); - SAFE_FREE(chaine2); - } - - if(!prs_set_offset(ps, old_offset)) - return False; - } - return True; -} - -/******************************************************************* Parse a DEVMODE structure and its relative pointer. ********************************************************************/ -static BOOL smb_io_relsecdesc(const char *desc, NEW_BUFFER *buffer, int depth, SEC_DESC **secdesc) -{ - prs_struct *ps= &buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_relsecdesc"); - depth++; - - if (MARSHALLING(ps)) { - uint32 struct_offset = prs_offset(ps); - uint32 relative_offset; - - if (! *secdesc) { - relative_offset = 0; - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - return True; - } - - if (*secdesc != NULL) { - buffer->string_at_end -= sec_desc_size(*secdesc); - - if(!prs_set_offset(ps, buffer->string_at_end)) - return False; - /* write the secdesc */ - if (!sec_io_desc(desc, secdesc, ps, depth)) - return False; - - if(!prs_set_offset(ps, struct_offset)) - return False; - } - - relative_offset=buffer->string_at_end - buffer->struct_start; - /* write its offset */ - - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - } else { - uint32 old_offset; - - /* read the offset */ - if (!prs_uint32("offset", ps, depth, &buffer->string_at_end)) - return False; - - old_offset = prs_offset(ps); - if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start)) - return False; - - /* read the sd */ - if (!sec_io_desc(desc, secdesc, ps, depth)) - return False; - - if(!prs_set_offset(ps, old_offset)) - return False; - } - return True; -} - -/******************************************************************* - Parse a DEVMODE structure and its relative pointer. -********************************************************************/ - -static BOOL smb_io_reldevmode(const char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE **devmode) +static BOOL smb_io_reldevmode(const char *desc, RPC_BUFFER *buffer, int depth, DEVICEMODE **devmode) { prs_struct *ps=&buffer->prs; @@ -2457,7 +2145,7 @@ static BOOL smb_io_reldevmode(const char *desc, NEW_BUFFER *buffer, int depth, D Parse a PRINTER_INFO_0 structure. ********************************************************************/ -BOOL smb_io_printer_info_0(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_0 *info, int depth) +BOOL smb_io_printer_info_0(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_0 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2558,7 +2246,7 @@ BOOL smb_io_printer_info_0(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_0 Parse a PRINTER_INFO_1 structure. ********************************************************************/ -BOOL smb_io_printer_info_1(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth) +BOOL smb_io_printer_info_1(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2583,7 +2271,7 @@ BOOL smb_io_printer_info_1(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 Parse a PRINTER_INFO_2 structure. ********************************************************************/ -BOOL smb_io_printer_info_2(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth) +BOOL smb_io_printer_info_2(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_2 *info, int depth) { prs_struct *ps=&buffer->prs; uint32 dm_offset, sd_offset, current_offset; @@ -2674,7 +2362,7 @@ BOOL smb_io_printer_info_2(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 Parse a PRINTER_INFO_3 structure. ********************************************************************/ -BOOL smb_io_printer_info_3(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 *info, int depth) +BOOL smb_io_printer_info_3(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_3 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2695,7 +2383,7 @@ BOOL smb_io_printer_info_3(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 Parse a PRINTER_INFO_4 structure. ********************************************************************/ -BOOL smb_io_printer_info_4(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_4 *info, int depth) +BOOL smb_io_printer_info_4(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_4 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2717,7 +2405,7 @@ BOOL smb_io_printer_info_4(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_4 Parse a PRINTER_INFO_5 structure. ********************************************************************/ -BOOL smb_io_printer_info_5(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_5 *info, int depth) +BOOL smb_io_printer_info_5(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_5 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2743,7 +2431,7 @@ BOOL smb_io_printer_info_5(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_5 Parse a PRINTER_INFO_7 structure. ********************************************************************/ -BOOL smb_io_printer_info_7(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_7 *info, int depth) +BOOL smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2763,7 +2451,7 @@ BOOL smb_io_printer_info_7(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_7 Parse a PORT_INFO_1 structure. ********************************************************************/ -BOOL smb_io_port_info_1(const char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth) +BOOL smb_io_port_info_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2782,7 +2470,7 @@ BOOL smb_io_port_info_1(const char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, Parse a PORT_INFO_2 structure. ********************************************************************/ -BOOL smb_io_port_info_2(const char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth) +BOOL smb_io_port_info_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2809,7 +2497,7 @@ BOOL smb_io_port_info_2(const char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, Parse a DRIVER_INFO_1 structure. ********************************************************************/ -BOOL smb_io_printer_driver_info_1(const char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth) +BOOL smb_io_printer_driver_info_1(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2828,7 +2516,7 @@ BOOL smb_io_printer_driver_info_1(const char *desc, NEW_BUFFER *buffer, DRIVER_I Parse a DRIVER_INFO_2 structure. ********************************************************************/ -BOOL smb_io_printer_driver_info_2(const char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth) +BOOL smb_io_printer_driver_info_2(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_2 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2857,7 +2545,7 @@ BOOL smb_io_printer_driver_info_2(const char *desc, NEW_BUFFER *buffer, DRIVER_I Parse a DRIVER_INFO_3 structure. ********************************************************************/ -BOOL smb_io_printer_driver_info_3(const char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth) +BOOL smb_io_printer_driver_info_3(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_3 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2896,7 +2584,7 @@ BOOL smb_io_printer_driver_info_3(const char *desc, NEW_BUFFER *buffer, DRIVER_I Parse a DRIVER_INFO_6 structure. ********************************************************************/ -BOOL smb_io_printer_driver_info_6(const char *desc, NEW_BUFFER *buffer, DRIVER_INFO_6 *info, int depth) +BOOL smb_io_printer_driver_info_6(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_6 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -2961,7 +2649,7 @@ BOOL smb_io_printer_driver_info_6(const char *desc, NEW_BUFFER *buffer, DRIVER_I Parse a JOB_INFO_1 structure. ********************************************************************/ -BOOL smb_io_job_info_1(const char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth) +BOOL smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3004,7 +2692,7 @@ BOOL smb_io_job_info_1(const char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, i Parse a JOB_INFO_2 structure. ********************************************************************/ -BOOL smb_io_job_info_2(const char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth) +BOOL smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth) { uint32 pipo=0; prs_struct *ps=&buffer->prs; @@ -3071,7 +2759,7 @@ BOOL smb_io_job_info_2(const char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, i /******************************************************************* ********************************************************************/ -BOOL smb_io_form_1(const char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth) +BOOL smb_io_form_1(const char *desc, RPC_BUFFER *buffer, FORM_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3102,123 +2790,13 @@ BOOL smb_io_form_1(const char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth return True; } -/******************************************************************* - Read/write a BUFFER struct. -********************************************************************/ -static BOOL spoolss_io_buffer(const char *desc, prs_struct *ps, int depth, NEW_BUFFER **pp_buffer) -{ - NEW_BUFFER *buffer = *pp_buffer; - - prs_debug(ps, depth, desc, "spoolss_io_buffer"); - depth++; - - if (UNMARSHALLING(ps)) - buffer = *pp_buffer = PRS_ALLOC_MEM(ps, NEW_BUFFER, 1); - - if (buffer == NULL) - return False; - - if (!prs_uint32("ptr", ps, depth, &buffer->ptr)) - return False; - - /* reading */ - if (UNMARSHALLING(ps)) { - buffer->size=0; - buffer->string_at_end=0; - - if (buffer->ptr==0) { - /* - * JRA. I'm not sure if the data in here is in big-endian format if - * the client is big-endian. Leave as default (little endian) for now. - */ - - if (!prs_init(&buffer->prs, 0, prs_get_mem_context(ps), UNMARSHALL)) - return False; - return True; - } - - if (!prs_uint32("size", ps, depth, &buffer->size)) - return False; - - /* - * JRA. I'm not sure if the data in here is in big-endian format if - * the client is big-endian. Leave as default (little endian) for now. - */ - - if (!prs_init(&buffer->prs, buffer->size, prs_get_mem_context(ps), UNMARSHALL)) - return False; - - if (!prs_append_some_prs_data(&buffer->prs, ps, prs_offset(ps), buffer->size)) - return False; - - if (!prs_set_offset(&buffer->prs, 0)) - return False; - - if (!prs_set_offset(ps, buffer->size+prs_offset(ps))) - return False; - - buffer->string_at_end=buffer->size; - - return True; - } - else { - BOOL ret = False; - - /* writing */ - if (buffer->ptr==0) { - /* We have finished with the data in buffer->prs - free it. */ - prs_mem_free(&buffer->prs); - return True; - } - - if (!prs_uint32("size", ps, depth, &buffer->size)) - goto out; - - if (!prs_append_some_prs_data(ps, &buffer->prs, 0, buffer->size)) - goto out; - - ret = True; - out: - - /* We have finished with the data in buffer->prs - free it. */ - prs_mem_free(&buffer->prs); - - return ret; - } -} - -/******************************************************************* - move a BUFFER from the query to the reply. - As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed, - this is ok. This is an OPTIMIZATION and is not strictly neccessary. - Clears the memory to zero also. -********************************************************************/ - -void spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest) -{ - prs_switch_type(&src->prs, MARSHALL); - if(!prs_set_offset(&src->prs, 0)) - return; - prs_force_dynamic(&src->prs); - prs_mem_clear(&src->prs); - *dest=src; -} - -/******************************************************************* - Get the size of a BUFFER struct. -********************************************************************/ - -uint32 new_get_buffer_size(NEW_BUFFER *buffer) -{ - return (buffer->size); -} /******************************************************************* Parse a DRIVER_DIRECTORY_1 structure. ********************************************************************/ -BOOL smb_io_driverdir_1(const char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth) +BOOL smb_io_driverdir_1(const char *desc, RPC_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3237,7 +2815,7 @@ BOOL smb_io_driverdir_1(const char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 Parse a PORT_INFO_1 structure. ********************************************************************/ -BOOL smb_io_port_1(const char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth) +BOOL smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3256,7 +2834,7 @@ BOOL smb_io_port_1(const char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int Parse a PORT_INFO_2 structure. ********************************************************************/ -BOOL smb_io_port_2(const char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth) +BOOL smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3282,7 +2860,7 @@ BOOL smb_io_port_2(const char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int /******************************************************************* ********************************************************************/ -BOOL smb_io_printprocessor_info_1(const char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth) +BOOL smb_io_printprocessor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3300,7 +2878,7 @@ BOOL smb_io_printprocessor_info_1(const char *desc, NEW_BUFFER *buffer, PRINTPRO /******************************************************************* ********************************************************************/ -BOOL smb_io_printprocdatatype_info_1(const char *desc, NEW_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth) +BOOL smb_io_printprocdatatype_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3318,7 +2896,7 @@ BOOL smb_io_printprocdatatype_info_1(const char *desc, NEW_BUFFER *buffer, PRINT /******************************************************************* ********************************************************************/ -BOOL smb_io_printmonitor_info_1(const char *desc, NEW_BUFFER *buffer, PRINTMONITOR_1 *info, int depth) +BOOL smb_io_printmonitor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3336,7 +2914,7 @@ BOOL smb_io_printmonitor_info_1(const char *desc, NEW_BUFFER *buffer, PRINTMONIT /******************************************************************* ********************************************************************/ -BOOL smb_io_printmonitor_info_2(const char *desc, NEW_BUFFER *buffer, PRINTMONITOR_2 *info, int depth) +BOOL smb_io_printmonitor_info_2(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_2 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -3859,7 +3437,7 @@ BOOL make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, const POLICY_HND *hnd, const fstring architecture, uint32 level, uint32 clientmajor, uint32 clientminor, - NEW_BUFFER *buffer, uint32 offered) + RPC_BUFFER *buffer, uint32 offered) { if (q_u == NULL) return False; @@ -3903,7 +3481,7 @@ BOOL spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 if(!prs_uint32("level", ps, depth, &q_u->level)) return False; - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if(!prs_align(ps)) @@ -3933,7 +3511,7 @@ BOOL spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -3959,7 +3537,7 @@ BOOL make_spoolss_q_enumprinters( uint32 flags, char *servername, uint32 level, - NEW_BUFFER *buffer, + RPC_BUFFER *buffer, uint32 offered ) { @@ -3981,7 +3559,7 @@ BOOL make_spoolss_q_enumprinters( BOOL make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u, fstring servername, uint32 level, - NEW_BUFFER *buffer, uint32 offered) + RPC_BUFFER *buffer, uint32 offered) { q_u->name_ptr = (servername != NULL) ? 1 : 0; init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername); @@ -4019,7 +3597,7 @@ BOOL spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_ if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -4042,7 +3620,7 @@ BOOL spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_ if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -4074,7 +3652,7 @@ BOOL spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_stru if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -4107,7 +3685,7 @@ BOOL spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_stru if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -4127,7 +3705,7 @@ BOOL make_spoolss_q_getprinter( SPOOL_Q_GETPRINTER *q_u, const POLICY_HND *hnd, uint32 level, - NEW_BUFFER *buffer, + RPC_BUFFER *buffer, uint32 offered ) { @@ -4349,7 +3927,7 @@ BOOL spoolss_io_r_addjob(const char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, if(!prs_align(ps)) return False; - if(!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if(!prs_align(ps)) @@ -4380,7 +3958,7 @@ BOOL spoolss_io_q_addjob(const char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, if(!prs_uint32("level", ps, depth, &q_u->level)) return False; - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if(!prs_align(ps)) @@ -4403,7 +3981,7 @@ BOOL spoolss_io_r_enumjobs(const char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct * if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -4428,7 +4006,7 @@ BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd, uint32 firstjob, uint32 numofjobs, uint32 level, - NEW_BUFFER *buffer, + RPC_BUFFER *buffer, uint32 offered) { if (q_u == NULL) @@ -4465,7 +4043,7 @@ BOOL spoolss_io_q_enumjobs(const char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct * if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if(!prs_align(ps)) @@ -4569,7 +4147,7 @@ BOOL spoolss_io_r_enumprinterdrivers(const char *desc, SPOOL_R_ENUMPRINTERDRIVER if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -4595,7 +4173,7 @@ BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, const char *name, const char *environment, uint32 level, - NEW_BUFFER *buffer, uint32 offered) + RPC_BUFFER *buffer, uint32 offered) { init_buf_unistr2(&q_u->name, &q_u->name_ptr, name); init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment); @@ -4637,7 +4215,7 @@ BOOL spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVER if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -4665,7 +4243,7 @@ BOOL spoolss_io_q_enumforms(const char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -4687,7 +4265,7 @@ BOOL spoolss_io_r_enumforms(const char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -4727,7 +4305,7 @@ BOOL spoolss_io_q_getform(const char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -4749,7 +4327,7 @@ BOOL spoolss_io_r_getform(const char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -4776,7 +4354,7 @@ BOOL spoolss_io_r_enumports(const char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -4815,7 +4393,7 @@ BOOL spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -5065,9 +4643,10 @@ BOOL spoolss_io_q_addprinterex(const char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_ if(!prs_align(ps)) return False; - if(!prs_uint32("", ps, depth, &q_u->server_name_ptr)) + + if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->server_name)) return False; - if(!smb_io_unistr2("", &q_u->server_name, q_u->server_name_ptr, ps, depth)) + if (!prs_io_unistr2("servername", ps, depth, q_u->server_name)) return False; if(!prs_align(ps)) @@ -5815,7 +5394,7 @@ BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni, BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u, fstring servername, fstring env_name, uint32 level, - NEW_BUFFER *buffer, uint32 offered) + RPC_BUFFER *buffer, uint32 offered) { init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername); init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name); @@ -5857,7 +5436,7 @@ BOOL spoolss_io_q_getprinterdriverdir(const char *desc, SPOOL_Q_GETPRINTERDRIVER if(!prs_uint32("level", ps, depth, &q_u->level)) return False; - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if(!prs_align(ps)) @@ -5881,7 +5460,7 @@ BOOL spoolss_io_r_getprinterdriverdir(const char *desc, SPOOL_R_GETPRINTERDRIVER if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -5907,7 +5486,7 @@ BOOL spoolss_io_r_enumprintprocessors(const char *desc, SPOOL_R_ENUMPRINTPROCESS if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -5955,7 +5534,7 @@ BOOL spoolss_io_q_enumprintprocessors(const char *desc, SPOOL_Q_ENUMPRINTPROCESS if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -6029,7 +5608,7 @@ BOOL spoolss_io_r_enumprintprocdatatypes(const char *desc, SPOOL_R_ENUMPRINTPROC if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -6077,7 +5656,7 @@ BOOL spoolss_io_q_enumprintprocdatatypes(const char *desc, SPOOL_Q_ENUMPRINTPROC if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if(!spoolss_io_buffer("buffer", ps, depth, &q_u->buffer)) + if(!prs_rpcbuffer_p("buffer", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -6112,7 +5691,7 @@ BOOL spoolss_io_q_enumprintmonitors(const char *desc, SPOOL_Q_ENUMPRINTMONITORS if (!prs_uint32("level", ps, depth, &q_u->level)) return False; - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if (!prs_align(ps)) @@ -6135,7 +5714,7 @@ BOOL spoolss_io_r_enumprintmonitors(const char *desc, SPOOL_R_ENUMPRINTMONITORS if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -6578,7 +6157,7 @@ BOOL spoolss_io_r_getjob(const char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, if (!prs_align(ps)) return False; - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if (!prs_align(ps)) @@ -6612,7 +6191,7 @@ BOOL spoolss_io_q_getjob(const char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, if(!prs_uint32("level", ps, depth, &q_u->level)) return False; - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if(!prs_align(ps)) @@ -7463,7 +7042,7 @@ BOOL spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX [in] unistr2 *name, [in] unistr2 *environment, [in] uint32 level, - [in,out] NEW_BUFFER buffer, + [in,out] RPC_BUFFER buffer, [in] uint32 offered, [out] uint32 needed, [out] uint32 returned @@ -7471,7 +7050,7 @@ BOOL spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX */ -BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, const char *name, char *environment, int level, NEW_BUFFER *buffer, uint32 offered) +BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, const char *name, char *environment, int level, RPC_BUFFER *buffer, uint32 offered) { DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n")); @@ -7522,7 +7101,7 @@ BOOL spoolss_io_q_getprintprocessordirectory(const char *desc, SPOOL_Q_GETPRINTP if(!prs_uint32("level", ps, depth, &q_u->level)) return False; - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) return False; if(!prs_align(ps)) @@ -7546,7 +7125,7 @@ BOOL spoolss_io_r_getprintprocessordirectory(const char *desc, SPOOL_R_GETPRINTP if(!prs_align(ps)) return False; - if(!spoolss_io_buffer("", ps, depth, &r_u->buffer)) + if(!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) return False; if(!prs_align(ps)) @@ -7561,7 +7140,7 @@ BOOL spoolss_io_r_getprintprocessordirectory(const char *desc, SPOOL_R_GETPRINTP return True; } -BOOL smb_io_printprocessordirectory_1(const char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_DIRECTORY_1 *info, int depth) +BOOL smb_io_printprocessordirectory_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_DIRECTORY_1 *info, int depth) { prs_struct *ps=&buffer->prs; @@ -7625,7 +7204,7 @@ BOOL make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM *q_u, POLICY_HND *handle, BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle, const char *formname, uint32 level, - NEW_BUFFER *buffer, uint32 offered) + RPC_BUFFER *buffer, uint32 offered) { memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); q_u->level = level; @@ -7641,7 +7220,7 @@ BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle, ********************************************************************/ BOOL make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle, - uint32 level, NEW_BUFFER *buffer, + uint32 level, RPC_BUFFER *buffer, uint32 offered) { memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); @@ -7676,7 +7255,7 @@ BOOL make_spoolss_q_setjob(SPOOL_Q_SETJOB *q_u, POLICY_HND *handle, ********************************************************************/ BOOL make_spoolss_q_getjob(SPOOL_Q_GETJOB *q_u, POLICY_HND *handle, - uint32 jobid, uint32 level, NEW_BUFFER *buffer, + uint32 jobid, uint32 level, RPC_BUFFER *buffer, uint32 offered) { memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); diff --git a/source/rpc_parse/parse_srv.c b/source/rpc_parse/parse_srv.c index 84c45b59014..7d15eda630f 100644 --- a/source/rpc_parse/parse_srv.c +++ b/source/rpc_parse/parse_srv.c @@ -1996,6 +1996,79 @@ BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_stru } /******************************************************************* + Inits a SRV_Q_NET_SESS_DEL structure. +********************************************************************/ + +void init_srv_q_net_sess_del(SRV_Q_NET_SESS_DEL *q_n, const char *srv_name, + const char *cli_name, const char *user_name) +{ + DEBUG(5,("init_q_net_sess_enum\n")); + + init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); + init_buf_unistr2(&q_n->uni_cli_name, &q_n->ptr_cli_name, cli_name); + init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name); +} + +/******************************************************************* + Reads or writes a structure. +********************************************************************/ + +BOOL srv_io_q_net_sess_del(const char *desc, SRV_Q_NET_SESS_DEL *q_n, prs_struct *ps, int depth) +{ + if (q_n == NULL) + return False; + + prs_debug(ps, depth, desc, "srv_io_q_net_sess_del"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) + return False; + if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("ptr_cli_name", ps, depth, &q_n->ptr_cli_name)) + return False; + if(!smb_io_unistr2("", &q_n->uni_cli_name, q_n->ptr_cli_name, ps, depth)) + return False; + + if(!prs_align(ps)) + return False; + if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name)) + return False; + if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth)) + return False; + + return True; +} + +/******************************************************************* + Reads or writes a structure. +********************************************************************/ + +BOOL srv_io_r_net_sess_del(const char *desc, SRV_R_NET_SESS_DEL *r_n, prs_struct *ps, int depth) +{ + if (r_n == NULL) + return False; + + prs_debug(ps, depth, desc, "srv_io_r_net_sess_del"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_werror("status", ps, depth, &r_n->status)) + return False; + + return True; +} + +/******************************************************************* Inits a CONN_INFO_0 structure ********************************************************************/ diff --git a/source/rpc_parse/parse_svcctl.c b/source/rpc_parse/parse_svcctl.c new file mode 100644 index 00000000000..1c41a18b99e --- /dev/null +++ b/source/rpc_parse/parse_svcctl.c @@ -0,0 +1,660 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Gerald (Jerry) Carter 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_PARSE + +/******************************************************************* +********************************************************************/ + +static BOOL svcctl_io_service_status( const char *desc, SERVICE_STATUS *status, prs_struct *ps, int depth ) +{ + + prs_debug(ps, depth, desc, "svcctl_io_service_status"); + depth++; + + if(!prs_uint32("type", ps, depth, &status->type)) + return False; + + if(!prs_uint32("state", ps, depth, &status->state)) + return False; + + if(!prs_uint32("controls_accepted", ps, depth, &status->controls_accepted)) + return False; + + if(!prs_uint32("win32_exit_code", ps, depth, &status->win32_exit_code)) + return False; + + if(!prs_uint32("service_exit_code", ps, depth, &status->service_exit_code)) + return False; + + if(!prs_uint32("check_point", ps, depth, &status->check_point)) + return False; + + if(!prs_uint32("wait_hint", ps, depth, &status->wait_hint)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +static BOOL svcctl_io_service_config( const char *desc, SERVICE_CONFIG *config, prs_struct *ps, int depth ) +{ + + prs_debug(ps, depth, desc, "svcctl_io_service_config"); + depth++; + + if(!prs_uint32("service_type", ps, depth, &config->service_type)) + return False; + if(!prs_uint32("start_type", ps, depth, &config->start_type)) + return False; + if(!prs_uint32("error_control", ps, depth, &config->error_control)) + return False; + + if (!prs_io_unistr2_p("", ps, depth, &config->executablepath)) + return False; + if (!prs_io_unistr2_p("", ps, depth, &config->loadordergroup)) + return False; + + if(!prs_uint32("tag_id", ps, depth, &config->tag_id)) + return False; + + if (!prs_io_unistr2_p("", ps, depth, &config->dependencies)) + return False; + if (!prs_io_unistr2_p("", ps, depth, &config->startname)) + return False; + if (!prs_io_unistr2_p("", ps, depth, &config->displayname)) + return False; + + if (!prs_io_unistr2("", ps, depth, config->executablepath)) + return False; + if (!prs_io_unistr2("", ps, depth, config->loadordergroup)) + return False; + if (!prs_io_unistr2("", ps, depth, config->dependencies)) + return False; + if (!prs_io_unistr2("", ps, depth, config->startname)) + return False; + if (!prs_io_unistr2("", ps, depth, config->displayname)) + return False; + + return True; +} + + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_enum_services_status( const char *desc, ENUM_SERVICES_STATUS *enum_status, RPC_BUFFER *buffer, int depth ) +{ + prs_struct *ps=&buffer->prs; + + prs_debug(ps, depth, desc, "svcctl_io_enum_services_status"); + depth++; + + if ( !smb_io_relstr("servicename", buffer, depth, &enum_status->servicename) ) + return False; + if ( !smb_io_relstr("displayname", buffer, depth, &enum_status->displayname) ) + return False; + + if ( !svcctl_io_service_status("svc_status", &enum_status->status, ps, depth) ) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +uint32 svcctl_sizeof_enum_services_status( ENUM_SERVICES_STATUS *status ) +{ + uint32 size = 0; + + size += size_of_relative_string( &status->servicename ); + size += size_of_relative_string( &status->displayname ); + size += sizeof(SERVICE_STATUS); + + return size; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_close_service(const char *desc, SVCCTL_Q_CLOSE_SERVICE *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_close_service"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth)) + return False; + + return True; +} + + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_close_service(const char *desc, SVCCTL_R_CLOSE_SERVICE *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_close_service"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_open_scmanager(const char *desc, SVCCTL_Q_OPEN_SCMANAGER *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_open_scmanager"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_pointer("servername", ps, depth, (void**)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) + return False; + if(!prs_align(ps)) + return False; + + if(!prs_pointer("database", ps, depth, (void**)&q_u->database, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) + return False; + if(!prs_align(ps)) + return False; + + if(!prs_uint32("access", ps, depth, &q_u->access)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_open_scmanager(const char *desc, SVCCTL_R_OPEN_SCMANAGER *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_open_scmanager"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("scm_pol", &r_u->handle, ps, depth)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_get_display_name(const char *desc, SVCCTL_Q_GET_DISPLAY_NAME *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_get_display_name"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth)) + return False; + + if(!smb_io_unistr2("servicename", &q_u->servicename, 1, ps, depth)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("display_name_len", ps, depth, &q_u->display_name_len)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL init_svcctl_r_get_display_name( SVCCTL_R_GET_DISPLAY_NAME *r_u, const char *displayname ) +{ + r_u->display_name_len = strlen(displayname); + init_unistr2( &r_u->displayname, displayname, UNI_STR_TERMINATE ); + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_get_display_name(const char *desc, SVCCTL_R_GET_DISPLAY_NAME *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_get_display_name"); + depth++; + + if(!prs_align(ps)) + return False; + + + if(!smb_io_unistr2("displayname", &r_u->displayname, 1, ps, depth)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("display_name_len", ps, depth, &r_u->display_name_len)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_open_service(const char *desc, SVCCTL_Q_OPEN_SERVICE *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_open_service"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth)) + return False; + + if(!smb_io_unistr2("servicename", &q_u->servicename, 1, ps, depth)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("access", ps, depth, &q_u->access)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_open_service(const char *desc, SVCCTL_R_OPEN_SERVICE *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_open_service"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("service_pol", &r_u->handle, ps, depth)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_query_status(const char *desc, SVCCTL_Q_QUERY_STATUS *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_query_status"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_query_status(const char *desc, SVCCTL_R_QUERY_STATUS *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_query_status"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!svcctl_io_service_status("service_status", &r_u->svc_status, ps, depth)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_enum_services_status(const char *desc, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_enum_services_status"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth)) + return False; + + if(!prs_uint32("type", ps, depth, &q_u->type)) + return False; + if(!prs_uint32("state", ps, depth, &q_u->state)) + return False; + if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) + return False; + + if(!prs_pointer("resume", ps, depth, (void**)&q_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_STATUS *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_enum_services_status"); + depth++; + + if(!prs_align(ps)) + return False; + + if (!prs_rpcbuffer("", ps, depth, &r_u->buffer)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("needed", ps, depth, &r_u->needed)) + return False; + if(!prs_uint32("returned", ps, depth, &r_u->returned)) + return False; + + if(!prs_pointer("resume", ps, depth, (void**)&r_u->resume, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_start_service(const char *desc, SVCCTL_Q_START_SERVICE *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_start_service"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) + return False; + + if(!prs_uint32("parmcount", ps, depth, &q_u->parmcount)) + return False; + + if ( !prs_pointer("rights", ps, depth, (void**)&q_u->parameters, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_start_service(const char *desc, SVCCTL_R_START_SERVICE *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_start_service"); + depth++; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_enum_dependent_services(const char *desc, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_enum_dependent_services"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) + return False; + + if(!prs_uint32("state", ps, depth, &q_u->state)) + return False; + if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_enum_dependent_services(const char *desc, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_enum_dependent_services"); + depth++; + + if(!prs_align(ps)) + return False; + + if (!prs_rpcbuffer("", ps, depth, &r_u->buffer)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("needed", ps, depth, &r_u->needed)) + return False; + if(!prs_uint32("returned", ps, depth, &r_u->returned)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_control_service(const char *desc, SVCCTL_Q_CONTROL_SERVICE *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_control_service"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) + return False; + + if(!prs_uint32("control", ps, depth, &q_u->control)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_control_service(const char *desc, SVCCTL_R_CONTROL_SERVICE *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_control_service"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!svcctl_io_service_status("service_status", &r_u->svc_status, ps, depth)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_query_service_config(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) + return False; + + if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_query_service_config(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!svcctl_io_service_config("config", &r_u->config, ps, depth)) + return False; + + if(!prs_uint32("needed", ps, depth, &r_u->needed)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + + |