本文整理汇总了C++中UNMARSHALLING函数的典型用法代码示例。如果您正苦于以下问题:C++ UNMARSHALLING函数的具体用法?C++ UNMARSHALLING怎么用?C++ UNMARSHALLING使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UNMARSHALLING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prs_string2
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;
}
示例2: sec_io_desc_buf
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;
}
示例3: prs_unistr4_array
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;
}
示例4: svcctl_io_service_fa
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;
}
示例5: prs_dcerpc_status
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;
}
示例6: prs_grow
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;
}
示例7: io_SMBSTR
/*******************************************************************
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;
}
示例8: smb_io_pol_hnd
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;
}
示例9: prs_string
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;
}
示例10: prs_werror
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;
}
示例11: dbg_rw_punival
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"));
}
示例12: prs_ntstatus
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;
}
示例13: prs_rpcbuffer_p
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);
}
示例14: smb_io_rpc_context
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;
}
示例15: prs_unistr2
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;
}