diff options
author | Luke Leighton <lkcl@samba.org> | 1998-11-10 19:05:00 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1998-11-10 19:05:00 +0000 |
commit | 1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c (patch) | |
tree | 1bf71664960c671d6447a085a5087ce13bb14fea /source3/rpc_parse | |
parent | 313d8ef27df81118b57f3d214db75be25e38b612 (diff) | |
download | samba-1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c.tar.gz samba-1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c.tar.bz2 samba-1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c.zip |
rpcclient registry commands.
(This used to be commit 36fcb4a6e643a05d06a2a273d74318fee7f2c647)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r-- | source3/rpc_parse/parse_lsa.c | 2 | ||||
-rw-r--r-- | source3/rpc_parse/parse_misc.c | 171 | ||||
-rw-r--r-- | source3/rpc_parse/parse_prs.c | 58 | ||||
-rw-r--r-- | source3/rpc_parse/parse_reg.c | 732 | ||||
-rw-r--r-- | source3/rpc_parse/parse_samr.c | 2 |
5 files changed, 918 insertions, 47 deletions
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index cc60ace9fc..a5c523fdb6 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -692,7 +692,7 @@ void lsa_io_q_lookup_rids(char *desc, LSA_Q_LOOKUP_RIDS *q_r, prs_struct *ps, i for (i = 0; i < q_r->num_entries; i++) { - smb_io_dom_name("", &(q_r->lookup_name[i]), ps, depth); /* names to be looked up */ + smb_io_unistr3("", &(q_r->lookup_name[i]), ps, depth); /* names to be looked up */ } prs_uint8s (False, "undoc ", ps, depth, q_r->undoc, UNKNOWN_LEN); diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index 0f242c4738..3a74d11e52 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -261,8 +261,8 @@ creates a UNIHDR structure. ********************************************************************/ void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint32 buffer) { - hdr->uni_max_len = 2 * max_len; hdr->uni_str_len = 2 * len; + hdr->uni_max_len = 2 * max_len; hdr->buffer = buffer; } @@ -288,6 +288,35 @@ void smb_io_unihdr(char *desc, UNIHDR *hdr, prs_struct *ps, int depth) } /******************************************************************* +creates a BUFHDR structure. +********************************************************************/ +void make_buf_hdr(BUFHDR *hdr, int max_len, int len) +{ + hdr->buf_max_len = max_len; + hdr->buf_len = len; +} + +/******************************************************************* +reads or writes a BUFHDR structure. +********************************************************************/ +void smb_io_hdrbuf(char *desc, BUFHDR *hdr, prs_struct *ps, int depth) +{ + if (hdr == NULL) return; + + prs_debug(ps, depth, desc, "smb_io_hdrbuf"); + depth++; + + prs_align(ps); + + prs_uint32("buf_max_len", ps, depth, &(hdr->buf_max_len)); + prs_uint32("buf_len ", ps, depth, &(hdr->buf_len )); + + /* oops! XXXX maybe issue a warning that this is happening... */ + if (hdr->buf_max_len > MAX_BUFFERLEN) hdr->buf_max_len = MAX_BUFFERLEN; + if (hdr->buf_len > MAX_BUFFERLEN) hdr->buf_len = MAX_BUFFERLEN; +} + +/******************************************************************* creates a UNIHDR2 structure. ********************************************************************/ void make_uni_hdr2(UNIHDR2 *hdr, int max_len, int len, uint16 terminate) @@ -337,53 +366,133 @@ void smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth) } /******************************************************************* -creates a UNINOTSTR2 structure. +creates a BUFFER3 structure from a uint32 ********************************************************************/ -void make_uninotstr2(UNINOTSTR2 *str, char *buf, int len) +void make_buffer3_uint32(BUFFER3 *str, uint32 val) { - /* set up string lengths. add one if string is not null-terminated */ - str->uni_max_len = (len+1)*2; + ZERO_STRUCTP(str); + + /* set up string lengths. */ + str->buf_max_len = sizeof(uint32); + str->buf_len = sizeof(uint32); + + SIVAL(str->buffer, 0, val); +} + +/******************************************************************* +creates a BUFFER3 structure. +********************************************************************/ +void make_buffer3_str(BUFFER3 *str, char *buf, int len) +{ + ZERO_STRUCTP(str); + + /* set up string lengths. */ + str->buf_max_len = len * 2; + str->buf_len = len * 2; + + /* store the string (null-terminated 8 bit chars into 16 bit chars) */ + struni2((uint16*)str->buffer, buf); +} + +/******************************************************************* +creates a BUFFER3 structure from a hex string. +********************************************************************/ +void make_buffer3_hex(BUFFER3 *str, char *buf) +{ + ZERO_STRUCTP(str); + str->buf_max_len = str->buf_len = strhex_to_str(str->buffer, sizeof(str->buffer), buf); +} + +/******************************************************************* +creates a BUFFER3 structure. +********************************************************************/ +void make_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len) +{ + ZERO_STRUCTP(str); + + /* max buffer size (allocated size) */ + str->buf_max_len = len; + if (buf != NULL) + { + memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer))); + } + 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. +********************************************************************/ +void smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth) +{ + if (buf3 == NULL) return; + + prs_debug(ps, depth, desc, "smb_io_buffer3"); + depth++; + + prs_align(ps); + + prs_uint32("uni_max_len", ps, depth, &(buf3->buf_max_len)); + if (buf3->buf_max_len > MAX_UNISTRLEN) buf3->buf_max_len = MAX_UNISTRLEN; + + prs_uint8s(True, "buffer ", ps, depth, buf3->buffer, buf3->buf_max_len); + + prs_uint32("buf_len ", ps, depth, &(buf3->buf_len)); + if (buf3->buf_len > MAX_UNISTRLEN) buf3->buf_len = MAX_UNISTRLEN; +} + +/******************************************************************* +creates a BUFFER2 structure. +********************************************************************/ +void make_buffer2(BUFFER2 *str, uint8 *buf, int len) +{ + ZERO_STRUCTP(str); + + /* max buffer size (allocated size) */ + str->buf_max_len = len; str->undoc = 0; - str->uni_buf_len = (len+1)*2; + str->buf_len = buf != NULL ? len : 0; - /* store the string (null-terminated copy) */ - struni2(str->buffer, buf); + if (buf != NULL) + { + memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer))); + } } /******************************************************************* -reads or writes a UNINOTSTR2 structure. -XXXX NOTE: UNISTR2 structures need NOT be null-terminated. - the uni_str_len member tells you how long the string is; +reads or writes a BUFFER2 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. ********************************************************************/ -void smb_io_uninotstr2(char *desc, UNINOTSTR2 *uni2, uint32 buffer, prs_struct *ps, int depth) +void smb_io_buffer2(char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth) { - if (uni2 == NULL) return; + if (buf2 == NULL) return; if (buffer) { - prs_debug(ps, depth, desc, "smb_io_uninotstr2"); + prs_debug(ps, depth, desc, "smb_io_buffer2"); depth++; prs_align(ps); - prs_uint32("uni_max_len", ps, depth, &(uni2->uni_max_len)); - prs_uint32("undoc ", ps, depth, &(uni2->undoc )); - prs_uint32("uni_buf_len", ps, depth, &(uni2->uni_buf_len)); + prs_uint32("uni_max_len", ps, depth, &(buf2->buf_max_len)); + prs_uint32("undoc ", ps, depth, &(buf2->undoc )); + prs_uint32("buf_len ", ps, depth, &(buf2->buf_len)); /* oops! XXXX maybe issue a warning that this is happening... */ - if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN; - if (uni2->uni_buf_len > MAX_UNISTRLEN) uni2->uni_buf_len = MAX_UNISTRLEN; + if (buf2->buf_max_len > MAX_UNISTRLEN) buf2->buf_max_len = MAX_UNISTRLEN; + if (buf2->buf_len > MAX_UNISTRLEN) buf2->buf_len = MAX_UNISTRLEN; /* buffer advanced by indicated length of string NOT by searching for null-termination */ - prs_uninotstr2(True, "buffer ", ps, depth, uni2); + prs_buffer2(True, "buffer ", ps, depth, buf2); } else { - prs_debug(ps, depth, desc, "smb_io_uninotstr2 - NULL"); + prs_debug(ps, depth, desc, "smb_io_buffer2 - NULL"); depth++; - bzero(uni2, sizeof(*uni2)); + bzero(buf2, sizeof(*buf2)); } } @@ -475,7 +584,7 @@ creates a UNISTR2 structure. ********************************************************************/ void make_unistr2(UNISTR2 *str, char *buf, int len) { - ZERO_STRUCTP(str); + ZERO_STRUCTP(str); /* set up string lengths. */ str->uni_max_len = len; @@ -526,9 +635,9 @@ void smb_io_unistr2(char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, i /******************************************************************* creates a DOM_RID2 structure. ********************************************************************/ -void make_dom_rid2(DOM_RID2 *rid2, uint32 rid) +void make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type) { - rid2->type = 0x5; + rid2->type = type; rid2->undoc = 0x5; rid2->rid = rid; rid2->rid_idx = 0; @@ -561,10 +670,10 @@ void smb_io_dom_rid2(char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth) /******************************************************************* creates a DOM_RID3 structure. ********************************************************************/ -void make_dom_rid3(DOM_RID3 *rid3, uint32 rid) +void make_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type) { rid3->rid = rid; - rid3->type1 = 0x1; + rid3->type1 = type; rid3->ptr_type = 0x1; /* non-zero, basically. */ rid3->type2 = 0x1; } @@ -946,13 +1055,13 @@ void smb_io_dom_query_5(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth /******************************************************************* -reads or writes a DOM_NAME structure. +reads or writes a UNISTR3 structure. ********************************************************************/ -void smb_io_dom_name(char *desc, DOM_NAME *name, prs_struct *ps, int depth) +void smb_io_unistr3(char *desc, UNISTR3 *name, prs_struct *ps, int depth) { if (name == NULL) return; - prs_debug(ps, depth, desc, "smb_io_dom_name"); + prs_debug(ps, depth, desc, "smb_io_unistr3"); depth++; prs_align(ps); @@ -962,7 +1071,7 @@ void smb_io_dom_name(char *desc, DOM_NAME *name, prs_struct *ps, int depth) /* don't know if len is specified by uni_str_len member... */ /* assume unicode string is unicode-null-terminated, instead */ - smb_io_unistr("", &(name->str), ps, depth); + prs_unistr3(True, "unistr", name, ps, depth); } diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c index d031a828f1..873a689792 100644 --- a/source3/rpc_parse/parse_prs.c +++ b/source3/rpc_parse/parse_prs.c @@ -175,13 +175,13 @@ BOOL prs_uint32s(BOOL charmode, char *name, prs_struct *ps, int depth, uint32 *d stream a "not" unicode string, length/buffer specified separately, in byte chars ********************************************************************/ -BOOL prs_uninotstr2(BOOL charmode, char *name, prs_struct *ps, int depth, UNINOTSTR2 *str) +BOOL prs_buffer2(BOOL charmode, char *name, prs_struct *ps, int depth, BUFFER2 *str) { char *q = mem_data(&(ps->data), ps->offset); if (q == NULL) return False; - DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->buffer, str->uni_max_len) - ps->offset += str->uni_buf_len; + DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->buffer, str->buf_len/2) + ps->offset += str->buf_len; return True; } @@ -210,7 +210,22 @@ BOOL prs_unistr2(BOOL charmode, char *name, prs_struct *ps, int depth, UNISTR2 * char *q = mem_data(&(ps->data), ps->offset); if (q == NULL) return False; - DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->buffer, str->uni_max_len) + DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->buffer, str->uni_str_len) + ps->offset += str->uni_str_len * sizeof(uint16); + + return True; +} + +/****************************************************************** + stream a unicode string, length/buffer specified separately, + in uint16 chars. + ********************************************************************/ +BOOL prs_unistr3(BOOL charmode, char *name, UNISTR3 *str, prs_struct *ps, int depth) +{ + char *q = mem_data(&(ps->data), ps->offset); + if (q == NULL) return False; + + DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->str.buffer, str->uni_str_len) ps->offset += str->uni_str_len * sizeof(uint16); return True; @@ -284,3 +299,38 @@ BOOL prs_string(char *name, prs_struct *ps, int depth, char *str, uint16 len, ui return True; } +/******************************************************************* + prs_uint16 wrapper. call this and it sets up a pointer to where the + uint16 should be stored, or gets the size if reading + ********************************************************************/ +BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *off_ptr) +{ + (*off_ptr) = ps->offset; + if (ps->io) + { + /* reading. */ + return prs_uint16(name, ps, depth, data16); + } + return True; +} + +/******************************************************************* + prs_uint16 wrapper. call this and it retrospectively stores the size. + does nothing on reading, as that is already handled by ...._pre() + ********************************************************************/ +BOOL prs_uint16_post(char *name, prs_struct *ps, int depth, + uint32 ptr_uint16, uint32 start_offset) +{ + if (!ps->io) + { + /* storing: go back and do a retrospective job. i hate this */ + uint16 data_size = ps->offset - start_offset; + uint32 old_offset = ps->offset; + + ps->offset = ptr_uint16; + prs_uint16(name, ps, depth, &data_size); + ps->offset = old_offset; + } + return True; +} + diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c index 6b464645e5..329da974fb 100644 --- a/source3/rpc_parse/parse_reg.c +++ b/source3/rpc_parse/parse_reg.c @@ -28,6 +28,18 @@ extern int DEBUGLEVEL; /******************************************************************* +creates a structure. +********************************************************************/ +void make_reg_q_open_pol(REG_Q_OPEN_POLICY *q_o, + uint16 unknown_0, uint32 level) +{ + q_o->ptr = 1; + q_o->unknown_0 = unknown_0; + q_o->unknown_1 = 0x0; /* random - changes */ + q_o->level = level; +} + +/******************************************************************* reads or writes a structure. ********************************************************************/ void reg_io_q_open_policy(char *desc, REG_Q_OPEN_POLICY *r_q, prs_struct *ps, int depth) @@ -43,8 +55,8 @@ void reg_io_q_open_policy(char *desc, REG_Q_OPEN_POLICY *r_q, prs_struct *ps, i if (r_q->ptr != 0) { prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0)); - prs_uint32("level ", ps, depth, &(r_q->level )); prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)); + prs_uint32("level ", ps, depth, &(r_q->level )); } } @@ -67,6 +79,286 @@ void reg_io_r_open_policy(char *desc, REG_R_OPEN_POLICY *r_r, prs_struct *ps, i } + +/******************************************************************* +creates a structure. +********************************************************************/ +void make_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd, + char *name, char *class, + SEC_INFO *sam_access) +{ + int len_name = name != NULL ? strlen(name ) + 1: 0; + int len_class = class != NULL ? strlen(class) + 1: 0; + + static char data[] = + { + 0x01, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + + ZERO_STRUCTP(q_c); + + memcpy(&(q_c->pnt_pol), hnd, sizeof(q_c->pnt_pol)); + + make_uni_hdr(&(q_c->hdr_name), len_name, len_name, 1); + make_unistr2(&(q_c->uni_name), name, len_name); + + make_uni_hdr(&(q_c->hdr_class), len_class, len_class, 1); + make_unistr2(&(q_c->uni_class), class, len_class); + + q_c->reserved = 0x00000000; + memcpy(&(q_c->sam_access), sam_access, sizeof(q_c->sam_access)); + + q_c->ptr1 = 1; + q_c->unknown_0 = 0x0000000C; + + q_c->ptr2 = 1; + q_c->unk_len1 = 0x14; + q_c->unk_len2 = 0x14; + q_c->unknown_1 = 0x00020000; + + make_buffer2(&q_c->buf_unk, data, sizeof(data)); + + q_c->unknown_2 = 0x00000000; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_q_create_key(char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_q_create_key"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(r_q->pnt_pol), ps, depth); + + smb_io_unihdr ("", &(r_q->hdr_name), ps, depth); + smb_io_unistr2("", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth); + prs_align(ps); + + smb_io_unihdr ("", &(r_q->hdr_class), ps, depth); + smb_io_unistr2("", &(r_q->uni_class), r_q->hdr_class.buffer, ps, depth); + prs_align(ps); + + prs_uint32("reserved", ps, depth, &(r_q->reserved)); + sec_io_info("sam_access", &r_q->sam_access, ps, depth); + + prs_uint32("ptr1", ps, depth, &(r_q->ptr1)); + if (r_q->ptr2 != 0) + { + prs_uint32("unknown_0", ps, depth, &(r_q->unknown_0)); + } + + prs_uint32("ptr2", ps, depth, &(r_q->ptr2)); + if (r_q->ptr2) + { + prs_uint32("unk_len1", ps, depth, &(r_q->unk_len1)); + prs_uint32("unk_len2", ps, depth, &(r_q->unk_len2)); + prs_uint32("unknown_1", ps, depth, &(r_q->unknown_1)); + smb_io_buffer2("buf_unk", &r_q->buf_unk, 1, ps, depth); + prs_align(ps); + + prs_uint32("unknown_2", ps, depth, &(r_q->unknown_2)); + } + + prs_align(ps); +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_r_create_key(char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth) +{ + if (r_r == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_r_create_key"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(r_r->key_pol), ps, depth); + prs_uint32("unknown", ps, depth, &(r_r->unknown)); + + prs_uint32("status", ps, depth, &(r_r->status)); +} + + +/******************************************************************* +creates a structure. +********************************************************************/ +void make_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, + uint32 max_class_len) +{ + ZERO_STRUCTP(q_o); + + memcpy(&(q_o->pol), hnd, sizeof(q_o->pol)); + make_uni_hdr(&q_o->hdr_class, max_class_len, 0, max_class_len > 0 ? 1 : 0); + q_o->uni_class.uni_max_len = max_class_len; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_q_query_key(char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_q_query_key"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(r_q->pol), ps, depth); + smb_io_unihdr ("", &(r_q->hdr_class), ps, depth); + smb_io_unistr2("", &(r_q->uni_class), r_q->hdr_class.buffer, ps, depth); + + prs_align(ps); +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_r_query_key(char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth) +{ + if (r_r == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_r_query_key"); + depth++; + + prs_align(ps); + + smb_io_unihdr ("", &(r_r->hdr_class), ps, depth); + smb_io_unistr2("", &(r_r->uni_class), r_r->hdr_class.buffer, ps, depth); + + prs_align(ps); + + prs_uint32("num_subkeys ", ps, depth, &(r_r->num_subkeys )); + prs_uint32("max_subkeylen ", ps, depth, &(r_r->max_subkeylen )); + prs_uint32("mak_subkeysize", ps, depth, &(r_r->max_subkeysize)); + prs_uint32("num_values ", ps, depth, &(r_r->num_values )); + prs_uint32("max_valnamelen", ps, depth, &(r_r->max_valnamelen)); + prs_uint32("max_valbufsize", ps, depth, &(r_r->max_valbufsize)); + prs_uint32("sec_desc ", ps, depth, &(r_r->sec_desc )); + smb_io_time("mod_time ", &(r_r->mod_time), ps, depth); + + prs_uint32("status", ps, depth, &(r_r->status)); +} + + +/******************************************************************* +creates a structure. +********************************************************************/ +void make_reg_q_unk_1a(REG_Q_UNK_1A *q_o, POLICY_HND *hnd) +{ + memcpy(&(q_o->pol), hnd, sizeof(q_o->pol)); +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_q_unk_1a(char *desc, REG_Q_UNK_1A *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_q_unk_1a"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(r_q->pol), ps, depth); +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_r_unk_1a(char *desc, REG_R_UNK_1A *r_r, prs_struct *ps, int depth) +{ + if (r_r == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_r_unk_1a"); + depth++; + + prs_align(ps); + + prs_uint32("unknown", ps, depth, &(r_r->unknown)); + prs_uint32("status" , ps, depth, &(r_r->status )); +} + + +/******************************************************************* +creates a structure. +********************************************************************/ +void make_reg_q_open_unk_4(REG_Q_OPEN_UNK_4 *q_o, + uint16 unknown_0, uint32 level) +{ + q_o->ptr = 1; + q_o->unknown_0 = unknown_0; + q_o->unknown_1 = 0x0; /* random - changes */ + q_o->level = level; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_q_open_unk_4(char *desc, REG_Q_OPEN_UNK_4 *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_q_open_unk_4"); + depth++; + + prs_align(ps); + + prs_uint32("ptr ", ps, depth, &(r_q->ptr )); + if (r_q->ptr != 0) + { + prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0)); + prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)); + prs_uint32("level ", ps, depth, &(r_q->level )); + } +} + + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_r_open_unk_4(char *desc, REG_R_OPEN_UNK_4 *r_r, prs_struct *ps, int depth) +{ + if (r_r == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_r_open_unk_4"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(r_r->pol), ps, depth); + + prs_uint32("status", ps, depth, &(r_r->status)); +} + + +/******************************************************************* +makes an REG_Q_CLOSE structure. +********************************************************************/ +void make_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd) +{ + if (q_c == NULL || hnd == NULL) return; + + DEBUG(5,("make_reg_q_close\n")); + + memcpy(&(q_c->pol), hnd, sizeof(q_c->pol)); +} + /******************************************************************* reads or writes a structure. ********************************************************************/ @@ -102,6 +394,123 @@ void reg_io_r_close(char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth) } /******************************************************************* +makes a structure. +********************************************************************/ +void make_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol, + uint32 buf_len, SEC_DESC_BUF *sec_buf) +{ + if (q_i == NULL) return; + + memcpy(&(q_i->pol), pol, sizeof(q_i->pol)); + + q_i->unknown = 0x7; + + q_i->ptr = 1; + q_i->data = sec_buf; + + make_buf_hdr(&(q_i->hdr_sec), buf_len, 0); + make_sec_desc_buf(q_i->data, buf_len, 0); +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_q_get_key_sec(char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_q_get_key_sec"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(r_q->pol), ps, depth); + + prs_uint32("unknown", ps, depth, &(r_q->unknown)); + prs_uint32("ptr ", ps, depth, &(r_q->ptr )); + + if (r_q->ptr != 0) + { + smb_io_hdrbuf ("hdr_sec", &(r_q->hdr_sec), ps, depth); + sec_io_desc_buf("data ", r_q->data , ps, depth); + + prs_align(ps); + } +} + +/******************************************************************* +makes a structure. +********************************************************************/ +void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol, + uint32 buf_len, uint8 *buf, + uint32 status) +{ + if (r_i == NULL) return; + + r_i->ptr = 1; + make_buf_hdr(&(r_i->hdr_sec), buf_len, buf_len); + make_sec_desc_buf(r_i->data, buf_len, 1); + + r_i->status = status; /* 0x0000 0000 or 0x0000 007a */ +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_r_get_key_sec(char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_r_get_key_sec"); + depth++; + + prs_align(ps); + + prs_uint32("ptr ", ps, depth, &(r_q->ptr )); + + if (r_q->ptr != 0) + { + smb_io_hdrbuf("", &(r_q->hdr_sec), ps, depth); + sec_io_desc_buf("", r_q->data, ps, depth); + + prs_align(ps); + } + + prs_uint32("status", ps, depth, &(r_q->status)); +} + + +/******************************************************************* +makes a structure. +********************************************************************/ +void make_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char *product_type, + time_t unix_time, uint8 major, uint8 minor) +{ + int len_type = strlen(product_type); + + if (q_i == NULL) return; + + memcpy(&(q_i->pol), pol, sizeof(q_i->pol)); + + make_uni_hdr(&(q_i->hdr_type), len_type, len_type, 1); + make_unistr2(&(q_i->uni_type), product_type, len_type); + + q_i->ptr1 = 1; + unix_to_nt_time(&(q_i->time), unix_time); + q_i->major_version1 = major; + q_i->minor_version1 = minor; + memset(q_i->pad1, 0, sizeof(q_i->pad1)); + + q_i->ptr2 = 1; + q_i->major_version2 = major; + q_i->minor_version2 = minor; + memset(q_i->pad2, 0, sizeof(q_i->pad2)); + + q_i->ptr3 = 1; + q_i->unknown = 0x00000000; +} + +/******************************************************************* reads or writes a structure. ********************************************************************/ void reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth) @@ -117,6 +526,8 @@ void reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth) smb_io_unihdr ("", &(r_q->hdr_type), ps, depth); smb_io_unistr2("", &(r_q->uni_type), r_q->hdr_type.buffer, ps, depth); + prs_align(ps); + prs_uint32("ptr1", ps, depth, &(r_q->ptr1)); if (r_q->ptr1 != 0) @@ -153,13 +564,14 @@ void make_reg_r_info(REG_R_INFO *r_r, uint32 unknown_0, uint32 unknown_1, uint32 status) { - int type_len = strlen(os_type); + uint8 buf[512]; + int len = struni2((uint16*)buf, os_type); r_r->ptr1 = 1; r_r->level = level; r_r->ptr_type = 1; - make_uninotstr2(&(r_r->uni_type), os_type, type_len); + make_buffer2(&(r_r->uni_type), buf, len*2); r_r->ptr2 = 1; r_r->unknown_0 = unknown_0; @@ -173,7 +585,7 @@ void make_reg_r_info(REG_R_INFO *r_r, /******************************************************************* reads or writes a structure. ********************************************************************/ -void reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) +void reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) { if (r_r == NULL) return; @@ -187,10 +599,9 @@ void reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) if (r_r->ptr1 != 0) { prs_uint32("level", ps, depth, &(r_r->level)); - prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type)); - smb_io_uninotstr2("", &(r_r->uni_type), r_r->ptr_type, ps, depth); - prs_align(ps); + + smb_io_buffer2("uni_type", &(r_r->uni_type), r_r->ptr_type, ps, depth); prs_uint32("ptr2", ps, depth, &(r_r->ptr2)); @@ -205,11 +616,311 @@ void reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) { prs_uint32("unknown_1", ps, depth, &(r_r->unknown_1)); } - } + } prs_uint32("status", ps, depth, &(r_r->status)); } +/******************************************************************* +makes a structure. +********************************************************************/ +void make_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol, + uint32 val_idx, uint32 max_val_len, + uint32 max_buf_len) +{ + if (q_i == NULL) return; + + ZERO_STRUCTP(q_i); + + memcpy(&(q_i->pol), pol, sizeof(q_i->pol)); + + q_i->val_index = val_idx; + make_uni_hdr(&q_i->hdr_name, max_val_len, 0, 1); + q_i->uni_name.uni_max_len = max_val_len; + + q_i->ptr_type = 1; + q_i->type = 0x0; + + q_i->ptr_value = 1; + q_i->buf_value.buf_max_len = max_buf_len; + + q_i->ptr1 = 1; + q_i->len_value1 = max_buf_len; + + q_i->ptr2 = 1; + q_i->len_value2 = 0; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_q_enum_val(char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth) +{ + if (q_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_q_enum_val"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(q_q->pol), ps, depth); + + prs_uint32("val_index", ps, depth, &(q_q->val_index)); + smb_io_unihdr ("hdr_name", &(q_q->hdr_name), ps, depth); + smb_io_unistr2("uni_name", &(q_q->uni_name), q_q->hdr_name.buffer, ps, depth); + prs_align(ps); + + prs_uint32("ptr_type", ps, depth, &(q_q->ptr_type)); + + if (q_q->ptr_type != 0) + { + prs_uint32("type", ps, depth, &(q_q->type)); + } + + prs_uint32("ptr_value", ps, depth, &(q_q->ptr_value)); + smb_io_buffer2("buf_value", &(q_q->buf_value), q_q->ptr_value, ps, depth); + prs_align(ps); + + prs_uint32("ptr1", ps, depth, &(q_q->ptr1)); + if (q_q->ptr1 != 0) + { + prs_uint32("len_value1", ps, depth, &(q_q->len_value1)); + } + prs_uint32("ptr2", ps, depth, &(q_q->ptr2)); + if (q_q->ptr2 != 0) + { + prs_uint32("len_value2", ps, depth, &(q_q->len_value2)); + } +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_r_enum_val(char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_r_enum_val"); + depth++; + + prs_align(ps); + + smb_io_unihdr ("hdr_name", &(r_q->hdr_name), ps, depth); + smb_io_unistr2("uni_name", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth); + prs_align(ps); + + prs_uint32("ptr_type", ps, depth, &(r_q->ptr_type)); + + if (r_q->ptr_type != 0) + { + prs_uint32("type", ps, depth, &(r_q->type)); + } + + prs_uint32("ptr_value", ps, depth, &(r_q->ptr_value)); + smb_io_buffer2("buf_value", r_q->buf_value, r_q->ptr_value, ps, depth); + prs_align(ps); + + prs_uint32("ptr1", ps, depth, &(r_q->ptr1)); + if (r_q->ptr1 != 0) + { + prs_uint32("len_value1", ps, depth, &(r_q->len_value1)); + } + + prs_uint32("ptr2", ps, depth, &(r_q->ptr2)); + if (r_q->ptr2 != 0) + { + prs_uint32("len_value2", ps, depth, &(r_q->len_value2)); + } + + prs_uint32("status", ps, depth, &(r_q->status)); +} + +/******************************************************************* +makes a structure. +********************************************************************/ +void make_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol, + char *val_name, uint32 type, + BUFFER3 *val) +{ + int val_len = strlen(val_name) + 1; + + if (q_i == NULL) return; + + ZERO_STRUCTP(q_i); + + memcpy(&(q_i->pol), pol, sizeof(q_i->pol)); + + make_uni_hdr(&q_i->hdr_name, val_len, val_len, 1); + make_unistr2(&(q_i->uni_name), val_name, val_len); + + q_i->type = type; + q_i->buf_value = val; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_q_create_val(char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth) +{ + if (q_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_q_create_val"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(q_q->pol), ps, depth); + + smb_io_unihdr ("hdr_name", &(q_q->hdr_name), ps, depth); + smb_io_unistr2("uni_name", &(q_q->uni_name), q_q->hdr_name.buffer, ps, depth); + prs_align(ps); + + prs_uint32("type", ps, depth, &(q_q->type)); + smb_io_buffer3("buf_value", q_q->buf_value, ps, depth); + prs_align(ps); +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_r_create_val(char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_r_create_val"); + depth++; + + prs_align(ps); + + prs_uint32("status", ps, depth, &(r_q->status)); +} + +/******************************************************************* +makes a structure. +********************************************************************/ +void make_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx) +{ + if (q_i == NULL) return; + + memcpy(&(q_i->pol), pol, sizeof(q_i->pol)); + + q_i->key_index = key_idx; + q_i->key_name_len = 0; + q_i->unknown_1 = 0x0414; + + q_i->ptr1 = 1; + q_i->unknown_2 = 0x0000020A; + memset(q_i->pad1, 0, sizeof(q_i->pad1)); + + q_i->ptr2 = 1; + memset(q_i->pad2, 0, sizeof(q_i->pad2)); + + q_i->ptr3 = 1; + unix_to_nt_time(&q_i->time, 0); /* current time? */ +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_q_enum_key(char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth) +{ + if (q_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_q_enum_key"); + depth++; + + prs_align(ps); + + smb_io_pol_hnd("", &(q_q->pol), ps, depth); + + prs_uint32("key_index", ps, depth, &(q_q->key_index)); + prs_uint16("key_name_len", ps, depth, &(q_q->key_name_len)); + prs_uint16("unknown_1", ps, depth, &(q_q->unknown_1)); + + prs_uint32("ptr1", ps, depth, &(q_q->ptr1)); + + if (q_q->ptr1 != 0) + { + prs_uint32("unknown_2", ps, depth, &(q_q->unknown_2)); + prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1)); + } + + prs_uint32("ptr2", ps, depth, &(q_q->ptr2)); + + if (q_q->ptr2 != 0) + { + prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2)); + } + + prs_uint32("ptr3", ps, depth, &(q_q->ptr3)); + + if (q_q->ptr3 != 0) + { + smb_io_time("", &(q_q->time), ps, depth); + } +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +void reg_io_r_enum_key(char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth) +{ + if (r_q == NULL) return; + + prs_debug(ps, depth, desc, "reg_io_r_enum_key"); + depth++; + + prs_align(ps); + + prs_uint16("key_name_len", ps, depth, &(r_q->key_name_len)); + prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)); + + prs_uint32("ptr1", ps, depth, &(r_q->ptr1)); + + if (r_q->ptr1 != 0) + { + prs_uint32("unknown_2", ps, depth, &(r_q->unknown_2)); + prs_uint32("unknown_3", ps, depth, &(r_q->unknown_3)); + smb_io_unistr3("key_name", &(r_q->key_name), ps, depth); + prs_align(ps); + } + + prs_uint32("ptr2", ps, depth, &(r_q->ptr2)); + + if (r_q->ptr2 != 0) + { + prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2)); + } + + prs_uint32("ptr3", ps, depth, &(r_q->ptr3)); + + if (r_q->ptr3 != 0) + { + smb_io_time("", &(r_q->time), ps, depth); + } + + prs_uint32("status", ps, depth, &(r_q->status)); +} + + +/******************************************************************* +makes a structure. +********************************************************************/ +void make_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol, + char *key_name, uint32 unk) +{ + int len_name = strlen(key_name)+1; + + if (r_q == NULL) return; + + memcpy(&(r_q->pol), pol, sizeof(r_q->pol)); + + make_uni_hdr(&(r_q->hdr_name), len_name, len_name, 1); + make_unistr2(&(r_q->uni_name), key_name, len_name); + + r_q->unknown_0 = 0x00000000; + r_q->unknown_1 = unk; +} /******************************************************************* reads or writes a structure. @@ -227,9 +938,10 @@ void reg_io_q_open_entry(char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int smb_io_unihdr ("", &(r_q->hdr_name), ps, depth); smb_io_unistr2("", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth); + prs_align(ps); + prs_uint32("unknown_0", ps, depth, &(r_q->unknown_0)); - prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)); - prs_uint16("unknown_2", ps, depth, &(r_q->unknown_2)); + prs_uint32("unknown_1", ps, depth, &(r_q->unknown_1)); } diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c index ba6a8d3556..ec4411b783 100644 --- a/source3/rpc_parse/parse_samr.c +++ b/source3/rpc_parse/parse_samr.c @@ -1810,7 +1810,7 @@ void make_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES *r_u, for (i = 0; i < num_rids; i++) { - make_dom_rid3(&(r_u->dom_rid[i]), rid[i]); + make_dom_rid3(&(r_u->dom_rid[i]), rid[i], 0x01); } r_u->num_entries3 = num_rids; |