BOOL prs_string2(BOOL charmode, const char *name, prs_struct *ps, int depth, STRING2 *str) { int i; char *q = prs_mem_get(ps, str->str_max_len); if (q == NULL) return False; if (UNMARSHALLING(ps)) { str->buffer = (unsigned char *)prs_alloc_mem(ps,str->str_max_len); if (str->buffer == NULL) return False; } if (UNMARSHALLING(ps)) { for (i = 0; i < str->str_str_len; i++) str->buffer[i] = CVAL(q,i); } else { for (i = 0; i < str->str_str_len; i++) SCVAL(q, i, str->buffer[i]); } DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name)); if (charmode) print_asc(5, (unsigned char*)str->buffer, str->str_str_len); else { for (i = 0; i < str->str_str_len; i++) DEBUG(5,("%02x ", str->buffer[i])); } DEBUG(5,("\n")); ps->data_offset += str->str_str_len; return True; }
BOOL sec_io_desc_buf(const char *desc, SEC_DESC_BUF **ppsdb, prs_struct *ps, int depth) { uint32 off_len; uint32 off_max_len; uint32 old_offset; uint32 size; SEC_DESC_BUF *psdb; if (ppsdb == NULL) return False; psdb = *ppsdb; if (UNMARSHALLING(ps) && psdb == NULL) { if((psdb = (SEC_DESC_BUF *)prs_alloc_mem(ps,sizeof(SEC_DESC_BUF))) == NULL) return False; *ppsdb = psdb; } prs_debug(ps, depth, desc, "sec_io_desc_buf"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32_pre("max_len", ps, depth, &psdb->max_len, &off_max_len)) return False; if(!prs_uint32 ("ptr ", ps, depth, &psdb->ptr)) return False; if(!prs_uint32_pre("len ", ps, depth, &psdb->len, &off_len)) return False; old_offset = prs_offset(ps); /* reading, length is non-zero; writing, descriptor is non-NULL */ if ((UNMARSHALLING(ps) && psdb->len != 0) || (MARSHALLING(ps) && psdb->sec != NULL)) { if(!sec_io_desc("sec ", &psdb->sec, ps, depth)) return False; } if(!prs_align(ps)) return False; size = prs_offset(ps) - old_offset; if(!prs_uint32_post("max_len", ps, depth, &psdb->max_len, off_max_len, size == 0 ? psdb->max_len : size)) return False; if(!prs_uint32_post("len ", ps, depth, &psdb->len, off_len, size)) return False; return True; }
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; }
BOOL svcctl_io_service_fa( const char *desc, SERVICE_FAILURE_ACTIONS *fa, RPC_BUFFER *buffer, int depth ) { prs_struct *ps = &buffer->prs; int i; prs_debug(ps, depth, desc, "svcctl_io_service_description"); depth++; if ( !prs_uint32("reset_period", ps, depth, &fa->reset_period) ) return False; if ( !prs_pointer( desc, ps, depth, (void**)&fa->rebootmsg, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) ) return False; if ( !prs_pointer( desc, ps, depth, (void**)&fa->command, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) ) return False; if ( !prs_uint32("num_actions", ps, depth, &fa->num_actions) ) return False; if ( UNMARSHALLING(ps) && fa->num_actions ) { if ( !(fa->actions = TALLOC_ARRAY( get_talloc_ctx(), SC_ACTION, fa->num_actions )) ) { DEBUG(0,("svcctl_io_service_fa: talloc() failure!\n")); return False; } } for ( i=0; i<fa->num_actions; i++ ) { if ( !svcctl_io_action( "actions", &fa->actions[i], ps, depth ) ) return False; } return True; }
bool prs_dcerpc_status(const char *name, prs_struct *ps, int depth, NTSTATUS *status) { char *q = prs_mem_get(ps, sizeof(uint32)); if (q == NULL) return False; if (UNMARSHALLING(ps)) { if (ps->bigendian_data) *status = NT_STATUS(RIVAL(q,0)); else *status = NT_STATUS(IVAL(q,0)); } else { if (ps->bigendian_data) RSIVAL(q,0,NT_STATUS_V(*status)); else SIVAL(q,0,NT_STATUS_V(*status)); } DEBUGADD(5,("%s%04x %s: %s\n", tab_depth(5,depth), ps->data_offset, name, dcerpc_errstr(talloc_tos(), NT_STATUS_V(*status)))); ps->data_offset += sizeof(uint32); return True; }
bool prs_grow(prs_struct *ps, uint32 extra_space) { uint32 new_size; ps->grow_size = MAX(ps->grow_size, ps->data_offset + extra_space); if(ps->data_offset + extra_space <= ps->buffer_size) return True; /* * We cannot grow the buffer if we're not reading * into the prs_struct, or if we don't own the memory. */ if(UNMARSHALLING(ps) || !ps->is_dynamic) { DEBUG(0,("prs_grow: Buffer overflow - unable to expand buffer by %u bytes.\n", (unsigned int)extra_space)); return False; } /* * Decide how much extra space we really need. */ extra_space -= (ps->buffer_size - ps->data_offset); if(ps->buffer_size == 0) { /* * Start with 128 bytes (arbitrary value), enough for small rpc * requests */ new_size = MAX(128, extra_space); if((ps->data_p = (char *)SMB_MALLOC(new_size)) == NULL) { DEBUG(0,("prs_grow: Malloc failure for size %u.\n", (unsigned int)new_size)); return False; } memset(ps->data_p, '\0', (size_t)new_size ); } else { /* * If the current buffer size is bigger than the space needed, * just double it, else add extra_space. Always keep 64 bytes * more, so that after we added a large blob we don't have to * realloc immediately again. */ new_size = MAX(ps->buffer_size*2, ps->buffer_size + extra_space + 64); if ((ps->data_p = (char *)SMB_REALLOC(ps->data_p, new_size)) == NULL) { DEBUG(0,("prs_grow: Realloc failure for size %u.\n", (unsigned int)new_size)); return False; } memset(&ps->data_p[ps->buffer_size], '\0', (size_t)(new_size - ps->buffer_size)); } ps->buffer_size = new_size; return True; }
/******************************************************************* Stream a null-terminated string. ********************************************************************/ BOOL io_SMBSTR(char *name, io_struct *ps, int depth, SMBSTR *str, unsigned flags) { size_t len; int start_offset = ps->data_offset; if (!(flags & PARSE_SCALARS)) return True; if (UNMARSHALLING(ps)) { char *q; q = io_mem_get(ps, 0); if (q == NULL) return False; len = strlen(q); smbstr_initA(str, q, len); ps->data_offset += len + 1; DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth), start_offset, name, q)); } else { uint8 *q; q = smbstrA(str); /* a typecast that don't happen, it's ok */ len = smbstr_len(str)+1; if (!io_uint8s(name, ps, depth, &q, len, flags)) return False; } return True; }
BOOL smb_io_pol_hnd(const char *desc, POLICY_HND *pol, prs_struct *ps, int depth) { if (pol == NULL) return False; prs_debug(ps, depth, desc, "smb_io_pol_hnd"); depth++; if(!prs_align(ps)) return False; if(UNMARSHALLING(ps)) ZERO_STRUCTP(pol); if (!prs_uint32("data1", ps, depth, &pol->data1)) return False; if (!prs_uint32("data2", ps, depth, &pol->data2)) return False; if (!prs_uint16("data3", ps, depth, &pol->data3)) return False; if (!prs_uint16("data4", ps, depth, &pol->data4)) return False; if(!prs_uint8s (False, "data5", ps, depth, pol->data5, sizeof(pol->data5))) return False; return True; }
BOOL prs_string(const char *name, prs_struct *ps, int depth, char *str, int len, int max_buf_size) { char *q; int i; len = MIN(len, (max_buf_size-1)); q = prs_mem_get(ps, len+1); if (q == NULL) return False; for(i = 0; i < len; i++) { if (UNMARSHALLING(ps)) str[i] = q[i]; else q[i] = str[i]; } /* The terminating null. */ str[i] = '\0'; if (MARSHALLING(ps)) { q[i] = '\0'; } ps->data_offset += len+1; dump_data(5+depth, q, len); return True; }
BOOL prs_werror(const char *name, prs_struct *ps, int depth, WERROR *status) { char *q = prs_mem_get(ps, sizeof(uint32)); if (q == NULL) return False; if (UNMARSHALLING(ps)) { if (ps->bigendian_data) *status = W_ERROR(RIVAL(q,0)); else *status = W_ERROR(IVAL(q,0)); } else { if (ps->bigendian_data) RSIVAL(q,0,W_ERROR_V(*status)); else SIVAL(q,0,W_ERROR_V(*status)); } DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth), ps->data_offset, name, dos_errstr(*status))); ps->data_offset += sizeof(uint32); return True; }
static void dbg_rw_punival(BOOL charmode, const char *name, int depth, prs_struct *ps, char *in_buf, char *out_buf, int len) { int i; if (UNMARSHALLING(ps)) { if (ps->bigendian_data) { for (i = 0; i < len; i++) SSVAL(out_buf,2*i,RSVAL(in_buf, 2*i)); } else { for (i = 0; i < len; i++) SSVAL(out_buf, 2*i, SVAL(in_buf, 2*i)); } } else { if (ps->bigendian_data) { for (i = 0; i < len; i++) RSSVAL(in_buf, 2*i, SVAL(out_buf,2*i)); } else { for (i = 0; i < len; i++) SSVAL(in_buf, 2*i, SVAL(out_buf,2*i)); } } DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name)); if (charmode) print_asc(5, (unsigned char*)out_buf, 2*len); else { for (i = 0; i < len; i++) DEBUG(5,("%04x ", out_buf[i])); } DEBUG(5,("\n")); }
BOOL prs_ntstatus(const char *name, prs_struct *ps, int depth, NTSTATUS *status) { char *q = prs_mem_get(ps, sizeof(uint32)); if (q == NULL) return False; if (UNMARSHALLING(ps)) { if (ps->bigendian_data) *status = NT_STATUS(RIVAL(q,0)); else *status = NT_STATUS(IVAL(q,0)); } else { if (ps->bigendian_data) RSIVAL(q,0,NT_STATUS_V(*status)); else SIVAL(q,0,NT_STATUS_V(*status)); } DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth), ps->data_offset, name, get_nt_error_msg(*status))); ps->data_offset += sizeof(uint32); return True; }
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 = *buffer ? 0xf000baaa : 0; 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; } else { /* Marshalling case. - coverity paranoia - should already be ok if data_p != 0 */ if (!*buffer) { return True; } } return prs_rpcbuffer( desc, ps, depth, *buffer); }
bool smb_io_rpc_context(const char *desc, RPC_CONTEXT *rpc_ctx, prs_struct *ps, int depth) { int i; if (rpc_ctx == NULL) return False; if(!prs_align(ps)) return False; if(!prs_uint16("context_id ", ps, depth, &rpc_ctx->context_id )) return False; if(!prs_uint8 ("num_transfer_syntaxes", ps, depth, &rpc_ctx->num_transfer_syntaxes)) return False; /* num_transfer_syntaxes must not be zero. */ if (rpc_ctx->num_transfer_syntaxes == 0) return False; if(!smb_io_rpc_iface("", &rpc_ctx->abstract, ps, depth)) return False; if (UNMARSHALLING(ps)) { if (!(rpc_ctx->transfer = PRS_ALLOC_MEM(ps, RPC_IFACE, rpc_ctx->num_transfer_syntaxes))) { return False; } } for (i = 0; i < rpc_ctx->num_transfer_syntaxes; i++ ) { if (!smb_io_rpc_iface("", &rpc_ctx->transfer[i], ps, depth)) return False; } return True; }
BOOL prs_unistr2(BOOL charmode, const char *name, prs_struct *ps, int depth, UNISTR2 *str) { char *p; char *q = prs_mem_get(ps, str->uni_str_len * sizeof(uint16)); if (q == NULL) return False; /* If the string is empty, we don't have anything to stream */ if (str->uni_str_len==0) return True; if (UNMARSHALLING(ps)) { str->buffer = (uint16 *)prs_alloc_mem(ps,str->uni_max_len * sizeof(uint16)); if (str->buffer == NULL) return False; } p = (char *)str->buffer; dbg_rw_punival(charmode, name, depth, ps, q, p, str->uni_str_len); ps->data_offset += (str->uni_str_len * sizeof(uint16)); return True; }
bool smb_io_rpc_hdr_rb(const char *desc, RPC_HDR_RB *rpc, prs_struct *ps, int depth) { int i; if (rpc == NULL) return False; prs_debug(ps, depth, desc, "smb_io_rpc_hdr_rb"); depth++; if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth)) return False; if(!prs_uint8("num_contexts", ps, depth, &rpc->num_contexts)) return False; /* 3 pad bytes following - will be mopped up by the prs_align in smb_io_rpc_context(). */ /* num_contexts must not be zero. */ if (rpc->num_contexts == 0) return False; if (UNMARSHALLING(ps)) { if (!(rpc->rpc_context = PRS_ALLOC_MEM(ps, RPC_CONTEXT, rpc->num_contexts))) { return False; } } for (i = 0; i < rpc->num_contexts; i++ ) { if (!smb_io_rpc_context("", &rpc->rpc_context[i], ps, depth)) return False; } return True; }
BOOL prs_uint8s(BOOL charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len) { int i; char *q = prs_mem_get(ps, len); if (q == NULL) return False; if (UNMARSHALLING(ps)) { for (i = 0; i < len; i++) data8s[i] = CVAL(q,i); } else { for (i = 0; i < len; i++) SCVAL(q, i, data8s[i]); } DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset ,name)); if (charmode) print_asc(5, (unsigned char*)data8s, len); else { for (i = 0; i < len; i++) DEBUG(5,("%02x ", data8s[i])); } DEBUG(5,("\n")); ps->data_offset += len; return True; }
BOOL prs_grow(prs_struct *ps, uint32 extra_space) { uint32 new_size; char *new_data; ps->grow_size = MAX(ps->grow_size, ps->data_offset + extra_space); if(ps->data_offset + extra_space <= ps->buffer_size) return True; /* * We cannot grow the buffer if we're not reading * into the prs_struct, or if we don't own the memory. */ if(UNMARSHALLING(ps) || !ps->is_dynamic) { DEBUG(0,("prs_grow: Buffer overflow - unable to expand buffer by %u bytes.\n", (unsigned int)extra_space)); return False; } /* * Decide how much extra space we really need. */ extra_space -= (ps->buffer_size - ps->data_offset); if(ps->buffer_size == 0) { /* * Ensure we have at least a PDU's length, or extra_space, whichever * is greater. */ new_size = MAX(MAX_PDU_FRAG_LEN,extra_space); if((new_data = malloc(new_size)) == NULL) { DEBUG(0,("prs_grow: Malloc failure for size %u.\n", (unsigned int)new_size)); return False; } memset(new_data, '\0', (size_t)new_size ); } else { /* * If the current buffer size is bigger than the space needed, just * double it, else add extra_space. */ new_size = MAX(ps->buffer_size*2, ps->buffer_size + extra_space); if ((new_data = Realloc(ps->data_p, new_size)) == NULL) { DEBUG(0,("prs_grow: Realloc failure for size %u.\n", (unsigned int)new_size)); return False; } memset(&new_data[ps->buffer_size], '\0', (size_t)(new_size - ps->buffer_size)); } ps->buffer_size = new_size; ps->data_p = new_data; return True; }
BOOL prs_uint32_pre(const char *name, prs_struct *ps, int depth, uint32 *data32, uint32 *offset) { *offset = ps->data_offset; if (UNMARSHALLING(ps) && (data32 != NULL)) { /* reading. */ return prs_uint32(name, ps, depth, data32); } else { ps->data_offset += sizeof(uint32); } return True; }
/******************************************************************* do IO on an entry count. ********************************************************************/ BOOL io_RCVBUF(char *name, io_struct *ps, int depth, RCVBUF *buf, unsigned flags) { if (!(flags & PARSE_SCALARS)) return True; if (UNMARSHALLING(ps)) { *buf = *ps->receive_buf; return True; } return False; }
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; } }
BOOL prs_uint16_pre(const char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *offset) { *offset = ps->data_offset; if (UNMARSHALLING(ps)) { /* reading. */ return prs_uint16(name, ps, depth, data16); } else { char *q = prs_mem_get(ps, sizeof(uint16)); if(q ==NULL) return False; ps->data_offset += sizeof(uint16); } return True; }
/******************************************************************* do IO on an entry count. ********************************************************************/ BOOL io_ENTCOUNT(char *name, io_struct *ps, int depth, ENTCOUNT *entries, unsigned flags) { if (!(flags & PARSE_SCALARS)) return True; ps->entry_count = entries; if (UNMARSHALLING(ps)) { return True; } if (ps->entry_count == NULL) return False; return io_uint16(name, ps, depth, ps->entry_count, flags); }
bool smb_io_rpc_hdr(const char *desc, RPC_HDR *rpc, prs_struct *ps, int depth) { if (rpc == NULL) return False; prs_debug(ps, depth, desc, "smb_io_rpc_hdr"); depth++; if(!prs_uint8 ("major ", ps, depth, &rpc->major)) return False; if(!prs_uint8 ("minor ", ps, depth, &rpc->minor)) return False; if(!prs_uint8 ("pkt_type ", ps, depth, &rpc->pkt_type)) return False; if(!prs_uint8 ("flags ", ps, depth, &rpc->flags)) return False; /* We always marshall in little endian format. */ if (MARSHALLING(ps)) rpc->pack_type[0] = 0x10; if(!prs_uint8("pack_type0", ps, depth, &rpc->pack_type[0])) return False; if(!prs_uint8("pack_type1", ps, depth, &rpc->pack_type[1])) return False; if(!prs_uint8("pack_type2", ps, depth, &rpc->pack_type[2])) return False; if(!prs_uint8("pack_type3", ps, depth, &rpc->pack_type[3])) return False; /* * If reading and pack_type[0] == 0 then the data is in big-endian * format. Set the flag in the prs_struct to specify reverse-endainness. */ if (UNMARSHALLING(ps) && rpc->pack_type[0] == 0) { DEBUG(10,("smb_io_rpc_hdr: PDU data format is big-endian. Setting flag.\n")); prs_set_endian_data(ps, RPC_BIG_ENDIAN); } if(!prs_uint16("frag_len ", ps, depth, &rpc->frag_len)) return False; if(!prs_uint16("auth_len ", ps, depth, &rpc->auth_len)) return False; if(!prs_uint32("call_id ", ps, depth, &rpc->call_id)) return False; return True; }
static BOOL ds_io_dominfobasic( const char *desc, prs_struct *ps, int depth, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **basic) { DSROLE_PRIMARY_DOMAIN_INFO_BASIC *p = *basic; if ( UNMARSHALLING(ps) ) p = *basic = (DSROLE_PRIMARY_DOMAIN_INFO_BASIC *)prs_alloc_mem(ps, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC)); if ( !p ) return False; if ( !prs_uint16("machine_role", ps, depth, &p->machine_role) ) return False; if ( !prs_uint16("unknown", ps, depth, &p->unknown) ) return False; if ( !prs_uint32("flags", ps, depth, &p->flags) ) return False; if ( !prs_uint32("netbios_ptr", ps, depth, &p->netbios_ptr) ) return False; if ( !prs_uint32("dnsname_ptr", ps, depth, &p->dnsname_ptr) ) return False; if ( !prs_uint32("forestname_ptr", ps, depth, &p->forestname_ptr) ) return False; if ( !prs_uint8s(False, "domain_guid", ps, depth, p->domain_guid.info, GUID_SIZE) ) return False; if ( !smb_io_unistr2( "netbios_domain", &p->netbios_domain, p->netbios_ptr, ps, depth) ) return False; if ( !prs_align(ps) ) return False; if ( !smb_io_unistr2( "dns_domain", &p->dns_domain, p->dnsname_ptr, ps, depth) ) return False; if ( !prs_align(ps) ) return False; if ( !smb_io_unistr2( "forest_domain", &p->forest_domain, p->forestname_ptr, ps, depth) ) return False; if ( !prs_align(ps) ) return False; return True; }
BOOL prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8) { char *q = prs_mem_get(ps, 1); if (q == NULL) return False; if (UNMARSHALLING(ps)) *data8 = CVAL(q,0); else SCVAL(q,0,*data8); DEBUG(5,("%s%04x %s: %02x\n", tab_depth(depth), ps->data_offset, name, *data8)); ps->data_offset += 1; return True; }
char *prs_mem_get(prs_struct *ps, uint32 extra_size) { if(UNMARSHALLING(ps)) { /* * If reading, ensure that we can read the requested size item. */ if (ps->data_offset + extra_size > ps->buffer_size) { DEBUG(0,("prs_mem_get: reading data of size %u would overrun buffer.\n", (unsigned int)extra_size )); return NULL; } } else { /* * Writing - grow the buffer if needed. */ if(!prs_grow(ps, extra_size)) return NULL; } return &ps->data_p[ps->data_offset]; }
BOOL prs_unistr3(BOOL charmode, const char *name, UNISTR3 *str, prs_struct *ps, int depth) { char *p; char *q = prs_mem_get(ps, str->uni_str_len * sizeof(uint16)); if (q == NULL) return False; if (UNMARSHALLING(ps)) { str->str.buffer = (uint16 *)prs_alloc_mem(ps,str->uni_str_len * sizeof(uint16)); if (str->str.buffer == NULL) return False; } p = (char *)str->str.buffer; dbg_rw_punival(charmode, name, depth, ps, q, p, str->uni_str_len); ps->data_offset += (str->uni_str_len * sizeof(uint16)); return True; }
/******************************************************************* Stream a uint64_struct ********************************************************************/ bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64_t *data64) { if (UNMARSHALLING(ps)) { uint32_t high, low; if (!prs_uint32(name, ps, depth+1, &low)) return False; if (!prs_uint32(name, ps, depth+1, &high)) return False; *data64 = ((uint64_t)high << 32) + low; return True; } else { uint32_t high = (*data64) >> 32, low = (*data64) & 0xFFFFFFFF; return prs_uint32(name, ps, depth+1, &low) && prs_uint32(name, ps, depth+1, &high); } }
BOOL prs_buffer2(BOOL charmode, const char *name, prs_struct *ps, int depth, BUFFER2 *str) { char *p; char *q = prs_mem_get(ps, str->buf_len); if (q == NULL) return False; if (UNMARSHALLING(ps)) { str->buffer = (uint16 *)prs_alloc_mem(ps,str->buf_len); if (str->buffer == NULL) return False; } p = (char *)str->buffer; dbg_rw_punival(charmode, name, depth, ps, q, p, str->buf_len/2); ps->data_offset += str->buf_len; return True; }