static NTSTATUS ndr_pull_security_ace_flags(struct ndr_pull *ndr, int ndr_flags, uint8_t *r) { uint8_t v; NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v)); *r = v; return NT_STATUS_OK; }
_PUBLIC_ enum ndr_err_code ndr_pull_security_ace_flags(struct ndr_pull *ndr, int ndr_flags, uint8_t *r) { uint8_t v; NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v)); *r = v; return NDR_ERR_SUCCESS; }
_PUBLIC_ enum ndr_err_code ndr_pull_dnsp_DnssrvRpcRecord(struct ndr_pull *ndr, int ndr_flags, struct dnsp_DnssrvRpcRecord *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->wDataLength)); NDR_CHECK(ndr_pull_dns_record_type(ndr, NDR_SCALARS, &r->wType)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->version)); NDR_CHECK(ndr_pull_dns_record_rank(ndr, NDR_SCALARS, &r->rank)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->flags)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dwSerial)); { uint32_t _flags_save_uint32 = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dwTtlSeconds)); ndr->flags = _flags_save_uint32; } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dwReserved)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dwTimeStamp)); NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->data, r->wType)); NDR_CHECK(ndr_pull_dnsRecordData(ndr, NDR_SCALARS, &r->data)); NDR_CHECK(ndr_pull_trailer_align(ndr, 4)); } if (ndr_flags & NDR_BUFFERS) { } return NDR_ERR_SUCCESS; }
_PUBLIC_ enum ndr_err_code ndr_pull_PERF_INSTANCE_DEFINITION(struct ndr_pull *ndr, int ndr_flags, struct PERF_INSTANCE_DEFINITION *r) { uint32_t _ptr_data; TALLOC_CTX *_mem_save_data_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 5)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ByteLength)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ParentObjectTitleIndex)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ParentObjectTitlePointer)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->UniqueID)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->NameOffset)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->NameLength)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); if (_ptr_data) { NDR_PULL_ALLOC(ndr, r->data); } else { r->data = NULL; } NDR_CHECK(ndr_pull_PERF_COUNTER_BLOCK(ndr, NDR_SCALARS, &r->counter_data)); NDR_CHECK(ndr_pull_trailer_align(ndr, 5)); } if (ndr_flags & NDR_BUFFERS) { if (r->data) { _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->data, 0); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, r->data)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); } } return NDR_ERR_SUCCESS; }
static NTSTATUS ndr_pull_security_descriptor_revision(struct ndr_pull *ndr, int ndr_flags, enum security_descriptor_revision *r) { uint8_t v; NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v)); *r = (enum security_descriptor_revision)v; return NT_STATUS_OK; }
static NTSTATUS ndr_pull_security_ace_type(struct ndr_pull *ndr, int ndr_flags, enum security_ace_type *r) { uint8_t v; NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v)); *r = (enum security_ace_type)v; return NT_STATUS_OK; }
NTSTATUS ndr_pull_CIMSTRING(struct ndr_pull *ndr, int ndr_flags, CIMSTRING *r) { uint8_t u; NTSTATUS status; if (!(ndr_flags & NDR_SCALARS)) return NT_STATUS_OK; NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &u)); switch (u) { case 0: u = ndr->flags; ndr->flags |= LIBNDR_FLAG_STR_ASCII | LIBNDR_FLAG_STR_NULLTERM; status = ndr_pull_string(ndr, NDR_SCALARS, r); DEBUG(9, ("%08X: Pull string: %s\n", ndr->offset, *r)); ndr->flags = u; return status; case 1: u = ndr->flags; ndr->flags |= LIBNDR_FLAG_STR_NULLTERM; status = ndr_pull_string(ndr, NDR_SCALARS, r); DEBUG(9, ("%08X: Pull string: %s\n", ndr->offset, *r)); ndr->flags = u; return status; default: return NT_STATUS_NOT_SUPPORTED; } }
static enum ndr_err_code ndr_pull_echo_info1(struct ndr_pull *ndr, int ndr_flags, struct echo_info1 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 1)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->v)); } if (ndr_flags & NDR_BUFFERS) { } return NDR_ERR_SUCCESS; }
NTSTATUS ndr_pull_dom_sid(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *r) { uint32_t cntr_sub_auths_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->sid_rev_num)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->num_auths)); if (r->num_auths > 15) { return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); } NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6)); for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) { NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sub_auths[cntr_sub_auths_0])); } } if (ndr_flags & NDR_BUFFERS) { } return NT_STATUS_OK; }
static enum ndr_err_code ndr_pull_initshutdown_InitEx(struct ndr_pull *ndr, int flags, struct initshutdown_InitEx *r) { uint32_t _ptr_hostname; uint32_t _ptr_message; TALLOC_CTX *_mem_save_hostname_0; TALLOC_CTX *_mem_save_message_0; if (flags & NDR_IN) { NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_hostname)); if (_ptr_hostname) { NDR_PULL_ALLOC(ndr, r->in.hostname); } else { r->in.hostname = NULL; } if (r->in.hostname) { _mem_save_hostname_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.hostname, 0); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, r->in.hostname)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_hostname_0, 0); } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_message)); if (_ptr_message) { NDR_PULL_ALLOC(ndr, r->in.message); } else { r->in.message = NULL; } if (r->in.message) { _mem_save_message_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.message, 0); NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_message_0, 0); } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.timeout)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->in.force_apps)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->in.do_reboot)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.reason)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; }
/* Manually modified to only pull some parts of the structure if certain flags provided */ enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_EX *r, uint32_t nt_version_flags) { { uint32_t _flags_save_STRUCT = ndr->flags; ZERO_STRUCTP(r); ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz)); NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain_name)); NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name)); NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name)); NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site)); NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site)); if (nt_version_flags & NETLOGON_NT_VERSION_5EX_WITH_IP) { NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->sockaddr_size)); { struct ndr_pull *_ndr_sockaddr; NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sockaddr, 0, r->sockaddr_size)); NDR_CHECK(ndr_pull_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS|NDR_BUFFERS, &r->sockaddr)); NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sockaddr, 0, r->sockaddr_size)); } } if (nt_version_flags & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) { NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->next_closest_site)); } NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version)); if (r->nt_version != nt_version_flags) { return NDR_ERR_VALIDATE; } NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->domain_uuid)); } ndr->flags = _flags_save_STRUCT; } return NDR_ERR_SUCCESS; }
_PUBLIC_ enum ndr_err_code ndr_pull_dom_sid(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *r) { uint32_t cntr_sub_auths_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->sid_rev_num)); NDR_CHECK(ndr_pull_int8(ndr, NDR_SCALARS, &r->num_auths)); if (r->num_auths < 0 || r->num_auths > ARRAY_SIZE(r->sub_auths)) { return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); } NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6)); for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) { NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sub_auths[cntr_sub_auths_0])); } } return NDR_ERR_SUCCESS; }
/* handle subcontext buffers, which in midl land are user-marshalled, but we use magic in pidl to make them easier to cope with */ _PUBLIC_ enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr, struct ndr_pull **_subndr, size_t header_size, ssize_t size_is) { struct ndr_pull *subndr; uint32_t r_content_size; bool force_le = false; bool force_be = false; switch (header_size) { case 0: { uint32_t content_size = ndr->data_size - ndr->offset; if (size_is >= 0) { content_size = size_is; } r_content_size = content_size; break; } case 2: { uint16_t content_size; NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &content_size)); if (size_is >= 0 && size_is != content_size) { return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) mismatch content_size %d", (int)size_is, (int)content_size); } r_content_size = content_size; break; } case 4: { uint32_t content_size; NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &content_size)); if (size_is >= 0 && size_is != content_size) { return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) mismatch content_size %d", (int)size_is, (int)content_size); } r_content_size = content_size; break; } case 0xFFFFFC01: { /* * Common Type Header for the Serialization Stream * See [MS-RPCE] 2.2.6 Type Serialization Version 1 */ uint8_t version; uint8_t drep; uint16_t hdrlen; uint32_t filler; uint32_t content_size; uint32_t reserved; /* version */ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &version)); if (version != 1) { return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) Common Type Header version %d != 1", (int)version); } /* * 0x10 little endian * 0x00 big endian */ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &drep)); if (drep == 0x10) { force_le = true; } else if (drep == 0x00) { force_be = true; } else { return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) Common Type Header invalid drep 0x%02X", (unsigned int)drep); } /* length of the "Private Header for Constructed Type" */ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &hdrlen)); if (hdrlen != 8) { return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) Common Type Header length %d != 8", (int)hdrlen); } /* filler should be ignored */ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &filler)); /* * Private Header for Constructed Type */ /* length - will be updated latter */ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &content_size)); if (size_is >= 0 && size_is != content_size) { return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) mismatch content_size %d", (int)size_is, (int)content_size); } /* the content size must be a multiple of 8 */ if ((content_size % 8) != 0) { return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) not padded to 8 content_size %d", (int)size_is, (int)content_size); } r_content_size = content_size; /* reserved */ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &reserved)); break; } default: return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) header_size %d", (int)header_size); } NDR_PULL_NEED_BYTES(ndr, r_content_size); subndr = talloc_zero(ndr, struct ndr_pull); NDR_ERR_HAVE_NO_MEMORY(subndr); subndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64; subndr->current_mem_ctx = ndr->current_mem_ctx; subndr->data = ndr->data + ndr->offset; subndr->offset = 0; subndr->data_size = r_content_size; subndr->iconv_convenience = talloc_reference(subndr, ndr->iconv_convenience); if (force_le) { ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN); } else if (force_be) { ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN); } *_subndr = subndr; return NDR_ERR_SUCCESS; }
_PUBLIC_ enum ndr_err_code ndr_pull_PERF_DATA_BLOCK(struct ndr_pull *ndr, int ndr_flags, struct PERF_DATA_BLOCK *r) { uint32_t size_Signature_0 = 0; uint32_t cntr_Signature_0; uint32_t _ptr_data; TALLOC_CTX *_mem_save_data_0; uint32_t size_objects_0 = 0; uint32_t cntr_objects_0; TALLOC_CTX *_mem_save_objects_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 8)); size_Signature_0 = 4; for (cntr_Signature_0 = 0; cntr_Signature_0 < size_Signature_0; cntr_Signature_0++) { NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->Signature[cntr_Signature_0])); } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->LittleEndian)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Version)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Revision)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->TotalByteLength)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->HeaderLength)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->NumObjectTypes)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->DefaultObject)); NDR_CHECK(ndr_pull_SYSTEMTIME(ndr, NDR_SCALARS, &r->SystemTime)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Padding)); NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->PerfTime)); NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->PerfFreq)); NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->PerfTime100nSec)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->SystemNameLength)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->SystemNameOffset)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); if (_ptr_data) { NDR_PULL_ALLOC(ndr, r->data); } else { r->data = NULL; } size_objects_0 = r->NumObjectTypes; NDR_PULL_ALLOC_N(ndr, r->objects, size_objects_0); _mem_save_objects_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->objects, 0); for (cntr_objects_0 = 0; cntr_objects_0 < size_objects_0; cntr_objects_0++) { NDR_CHECK(ndr_pull_PERF_OBJECT_TYPE(ndr, NDR_SCALARS, &r->objects[cntr_objects_0])); } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_objects_0, 0); NDR_CHECK(ndr_pull_trailer_align(ndr, 8)); } if (ndr_flags & NDR_BUFFERS) { if (r->data) { _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->data, 0); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, r->data)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); } size_objects_0 = r->NumObjectTypes; _mem_save_objects_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->objects, 0); for (cntr_objects_0 = 0; cntr_objects_0 < size_objects_0; cntr_objects_0++) { NDR_CHECK(ndr_pull_PERF_OBJECT_TYPE(ndr, NDR_BUFFERS, &r->objects[cntr_objects_0])); } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_objects_0, 0); } return NDR_ERR_SUCCESS; }
/* parse a uint8_t enum */ _PUBLIC_ enum ndr_err_code ndr_pull_enum_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) { return ndr_pull_uint8(ndr, ndr_flags, v); }