diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/gtk/tools/gregedit.c | 6 | ||||
-rw-r--r-- | source4/include/registry.h | 14 | ||||
-rw-r--r-- | source4/lib/registry/TODO | 2 | ||||
-rw-r--r-- | source4/lib/registry/common/reg_interface.c | 10 | ||||
-rw-r--r-- | source4/lib/registry/common/reg_util.c | 34 | ||||
-rw-r--r-- | source4/lib/registry/reg_backend_ldb.c | 34 | ||||
-rw-r--r-- | source4/lib/registry/reg_backend_nt4.c | 30 | ||||
-rw-r--r-- | source4/lib/registry/reg_backend_rpc.c | 9 | ||||
-rw-r--r-- | source4/lib/registry/reg_backend_w95.c | 5 | ||||
-rw-r--r-- | source4/lib/registry/regf.idl | 22 | ||||
-rw-r--r-- | source4/lib/registry/tools/regdiff.c | 2 | ||||
-rw-r--r-- | source4/lib/registry/tools/regpatch.c | 8 | ||||
-rw-r--r-- | source4/lib/registry/tools/regshell.c | 2 | ||||
-rw-r--r-- | source4/rpc_server/winreg/rpc_winreg.c | 17 |
14 files changed, 92 insertions, 103 deletions
diff --git a/source4/gtk/tools/gregedit.c b/source4/gtk/tools/gregedit.c index 5501059c5a..26aedf2084 100644 --- a/source4/gtk/tools/gregedit.c +++ b/source4/gtk/tools/gregedit.c @@ -269,7 +269,7 @@ static void expand_key(GtkTreeView *treeview, GtkTreeIter *parent, GtkTreePath * g_assert(k); for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(mem_ctx, k, i, &sub)); i++) { - int count; + uint32_t count; /* Replace the blank child with the first directory entry You may be tempted to remove the blank child node and then append a new one. Don't. If you remove the blank child @@ -559,7 +559,7 @@ static void on_value_activate(GtkTreeView *treeview, GtkTreePath *arg1, reg_string_to_val(mem_ctx,str_regtype(gtk_combo_box_get_active(GTK_COMBO_BOX(entry_type))), gtk_entry_get_text(GTK_ENTRY(entry_value)), &val); - error = reg_val_set(current_key, gtk_entry_get_text(GTK_ENTRY(entry_name)), val->data_type, val->data_blk, val->data_len); + error = reg_val_set(current_key, gtk_entry_get_text(GTK_ENTRY(entry_name)), val->data_type, val->data); if (!W_ERROR_IS_OK(error)) { gtk_show_werror(NULL, "Error while setting value", error); @@ -580,7 +580,7 @@ static void on_set_value_activate(GtkMenuItem *menuitem, gpointer user_data) reg_string_to_val(mem_ctx,str_regtype(gtk_combo_box_get_active(GTK_COMBO_BOX(entry_type))), gtk_entry_get_text(GTK_ENTRY(entry_value)), &val); - error = reg_val_set(current_key, gtk_entry_get_text(GTK_ENTRY(entry_name)), val->data_type, val->data_blk, val->data_len); + error = reg_val_set(current_key, gtk_entry_get_text(GTK_ENTRY(entry_name)), val->data_type, val->data); if (!W_ERROR_IS_OK(error)) { gtk_show_werror(NULL, "Error while setting value", error); diff --git a/source4/include/registry.h b/source4/include/registry.h index e472ed6a87..dc17eb06b1 100644 --- a/source4/include/registry.h +++ b/source4/include/registry.h @@ -64,8 +64,7 @@ struct registry_key { struct registry_value { char *name; unsigned int data_type; - int data_len; - void *data_blk; /* Might want a separate block */ + DATA_BLOB data; }; /* FIXME */ @@ -94,9 +93,8 @@ struct hive_operations { /* Or this one */ WERROR (*open_key) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **); - /* Either implement these */ - WERROR (*num_subkeys) (struct registry_key *, int *count); - WERROR (*num_values) (struct registry_key *, int *count); + WERROR (*num_subkeys) (struct registry_key *, uint32_t *count); + WERROR (*num_values) (struct registry_key *, uint32_t *count); WERROR (*get_subkey_by_index) (TALLOC_CTX *, struct registry_key *, int idx, struct registry_key **); /* Can not contain more then one level */ @@ -120,7 +118,7 @@ struct hive_operations { WERROR (*flush_key) (struct registry_key *); /* Value management */ - WERROR (*set_value)(struct registry_key *, const char *name, uint32_t type, void *data, int len); + WERROR (*set_value)(struct registry_key *, const char *name, uint32_t type, DATA_BLOB data); WERROR (*del_value)(struct registry_key *, const char *valname); }; @@ -139,12 +137,8 @@ struct registry_context { }; struct reg_init_function_entry { - /* Function to create a member of the pdb_methods list */ const struct hive_operations *hive_functions; struct reg_init_function_entry *prev, *next; }; -/* Used internally */ -#define SMB_REG_ASSERT(a) { if(!(a)) { DEBUG(0,("%s failed! (%s:%d)", #a, __FILE__, __LINE__)); }} - #endif /* _REGISTRY_H */ diff --git a/source4/lib/registry/TODO b/source4/lib/registry/TODO index 1dea9d2650..3f48d031e1 100644 --- a/source4/lib/registry/TODO +++ b/source4/lib/registry/TODO @@ -31,3 +31,5 @@ gregedit.c: - support for editing values / adding values / deleting values - support for adding/deleting keys - support for security descriptors + +- pass parsed paths around rather then strings (i.e. just a list of strings) diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c index 2abe90f2d1..7f745143e6 100644 --- a/source4/lib/registry/common/reg_interface.c +++ b/source4/lib/registry/common/reg_interface.c @@ -252,7 +252,7 @@ WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx, struct registry_key *key, return WERR_OK; } -WERROR reg_key_num_subkeys(struct registry_key *key, int *count) +WERROR reg_key_num_subkeys(struct registry_key *key, uint32_t *count) { if(!key) return WERR_INVALID_PARAM; @@ -277,7 +277,7 @@ WERROR reg_key_num_subkeys(struct registry_key *key, int *count) return WERR_NOT_SUPPORTED; } -WERROR reg_key_num_values(struct registry_key *key, int *count) +WERROR reg_key_num_values(struct registry_key *key, uint32_t *count) { if(!key) return WERR_INVALID_PARAM; @@ -416,11 +416,11 @@ WERROR reg_key_add_name(TALLOC_CTX *mem_ctx, struct registry_key *parent, const return WERR_OK; } -WERROR reg_val_set(struct registry_key *key, const char *value, uint32_t type, void *data, int len) +WERROR reg_val_set(struct registry_key *key, const char *value, uint32_t type, DATA_BLOB data) { /* A 'real' set function has preference */ if (key->hive->functions->set_value) - return key->hive->functions->set_value(key, value, type, data, len); + return key->hive->functions->set_value(key, value, type, data); DEBUG(1, ("Backend '%s' doesn't support method set_value\n", key->hive->functions->name)); return WERR_NOT_SUPPORTED; @@ -501,7 +501,7 @@ WERROR reg_key_valuesizes(struct registry_key *key, uint32_t *max_valnamelen, ui if (value->name) { *max_valnamelen = MAX(*max_valnamelen, strlen(value->name)); } - *max_valbufsize = MAX(*max_valbufsize, value->data_len); + *max_valbufsize = MAX(*max_valbufsize, value->data.length); } i++; diff --git a/source4/lib/registry/common/reg_util.c b/source4/lib/registry/common/reg_util.c index 65f1167832..a0d4db6f57 100644 --- a/source4/lib/registry/common/reg_util.c +++ b/source4/lib/registry/common/reg_util.c @@ -48,35 +48,25 @@ const char *str_regtype(int type) char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct registry_value *v) { - char *asciip; char *ret = NULL; - int i; - if(v->data_len == 0) return talloc_strdup(mem_ctx, ""); + if(v->data.length == 0) return talloc_strdup(mem_ctx, ""); switch (v->data_type) { case REG_EXPAND_SZ: case REG_SZ: - convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, v->data_blk, v->data_len, (void **)&ret); + convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, v->data.data, v->data.length, (void **)&ret); return ret; case REG_BINARY: - ret = talloc_array_size(mem_ctx, 3, v->data_len+1); - asciip = ret; - for (i=0; i<v->data_len; i++) { - int str_rem = v->data_len * 3 - (asciip - ret); - asciip += snprintf(asciip, str_rem, "%02x", *(uint8_t *)(((char *)v->data_blk)+i)); - if (i < v->data_len && str_rem > 0) - *asciip = ' '; asciip++; - } - *asciip = '\0'; + ret = data_blob_hex_string(mem_ctx, &v->data); return ret; case REG_DWORD: - if (*(int *)v->data_blk == 0) + if (*(int *)v->data.data == 0) return talloc_strdup(mem_ctx, "0"); - return talloc_asprintf(mem_ctx, "0x%x", *(int *)v->data_blk); + return talloc_asprintf(mem_ctx, "0x%x", *(int *)v->data.data); case REG_MULTI_SZ: /* FIXME */ @@ -117,17 +107,17 @@ BOOL reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *da { case REG_SZ: case REG_EXPAND_SZ: - (*value)->data_len = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), &(*value)->data_blk); + (*value)->data.length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), (void **)&(*value)->data.data); break; - case REG_DWORD: - (*value)->data_len = sizeof(uint32_t); - (*value)->data_blk = talloc(mem_ctx, uint32_t); - *((uint32_t *)(*value)->data_blk) = strtol(data_str, NULL, 0); + + case REG_DWORD: { + uint32_t tmp = strtol(data_str, NULL, 0); + (*value)->data = data_blob_talloc(mem_ctx, &tmp, 4); + } break; case REG_NONE: - (*value)->data_len = 0; - (*value)->data_blk = NULL; + ZERO_STRUCT((*value)->data); break; default: diff --git a/source4/lib/registry/reg_backend_ldb.c b/source4/lib/registry/reg_backend_ldb.c index 76ad1facc1..f51c02a286 100644 --- a/source4/lib/registry/reg_backend_ldb.c +++ b/source4/lib/registry/reg_backend_ldb.c @@ -38,7 +38,7 @@ static int ldb_free_hive (void *_hive) return 0; } -static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, char **name, uint32_t *type, void **data, int *len) +static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, char **name, uint32_t *type, DATA_BLOB *data) { const struct ldb_val *val; *name = talloc_strdup(mem_ctx, ldb_msg_find_string(msg, "value", NULL)); @@ -49,23 +49,22 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, c { case REG_SZ: case REG_EXPAND_SZ: - *len = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, val->data, val->length, data); + data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, val->data, val->length, (void **)&data->data); break; - case REG_DWORD: - *len = 4; - *data = talloc(mem_ctx, uint32_t); - SIVAL(*data, 0, strtol(val->data, NULL, 0)); + case REG_DWORD: { + uint32_t tmp = strtoul((char *)val->data, NULL, 0); + *data = data_blob_talloc(mem_ctx, &tmp, 4); + } break; default: - *data = talloc_memdup(mem_ctx, val->data, val->length); - *len = val->length; + *data = data_blob_talloc(mem_ctx, val->data, val->length); break; } } -static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, const char *name, uint32_t type, void *data, int len) +static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, const char *name, uint32_t type, DATA_BLOB data) { struct ldb_val val; struct ldb_message *msg = talloc_zero(mem_ctx, struct ldb_message); @@ -76,16 +75,15 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, TALLOC_CT switch (type) { case REG_SZ: case REG_EXPAND_SZ: - val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, data, len, &val.data); + val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, (void *)data.data, data.length, (void **)&val.data); ldb_msg_add_value(ctx, msg, "data", &val); break; + case REG_DWORD: - ldb_msg_add_string(ctx, msg, "data", talloc_asprintf(mem_ctx, "0x%x", IVAL(data, 0))); + ldb_msg_add_string(ctx, msg, "data", talloc_asprintf(mem_ctx, "0x%x", IVAL(data.data, 0))); break; default: - val.length = len; - val.data = data; - ldb_msg_add_value(ctx, msg, "data", &val); + ldb_msg_add_value(ctx, msg, "data", &data); } @@ -177,7 +175,7 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx, struct registry_key *k, *subkey = talloc(mem_ctx, struct registry_key); talloc_set_destructor(*subkey, reg_close_ldb_key); - (*subkey)->name = talloc_strdup(mem_ctx, el->values[0].data); + (*subkey)->name = talloc_strdup(mem_ctx, (char *)el->values[0].data); (*subkey)->backend_data = newkd = talloc_zero(*subkey, struct ldb_key_data); (*subkey)->last_mod = 0; /* TODO: we need to add this to the ldb backend properly */ @@ -205,7 +203,7 @@ static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, struct registry_key *k, i *value = talloc(mem_ctx, struct registry_value); - reg_ldb_unpack_value(mem_ctx, kd->values[idx], &(*value)->name, &(*value)->data_type, &(*value)->data_blk, &(*value)->data_len); + reg_ldb_unpack_value(mem_ctx, kd->values[idx], &(*value)->name, &(*value)->data_type, &(*value)->data); return WERR_OK; } @@ -333,7 +331,7 @@ static WERROR ldb_del_value (struct registry_key *key, const char *child) return WERR_OK; } -static WERROR ldb_set_value (struct registry_key *parent, const char *name, uint32_t type, void *data, int len) +static WERROR ldb_set_value (struct registry_key *parent, const char *name, uint32_t type, DATA_BLOB data) { struct ldb_context *ctx = parent->hive->backend_data; struct ldb_message *msg; @@ -341,7 +339,7 @@ static WERROR ldb_set_value (struct registry_key *parent, const char *name, uint int ret; TALLOC_CTX *mem_ctx = talloc_init("ldb_set_value"); - msg = reg_ldb_pack_value(ctx, mem_ctx, name, type, data, len); + msg = reg_ldb_pack_value(ctx, mem_ctx, name, type, data); msg->dn = ldb_dn_build_child(msg, "value", name, kd->dn); diff --git a/source4/lib/registry/reg_backend_nt4.c b/source4/lib/registry/reg_backend_nt4.c index e07534884c..06c0d78c85 100644 --- a/source4/lib/registry/reg_backend_nt4.c +++ b/source4/lib/registry/reg_backend_nt4.c @@ -624,7 +624,7 @@ static KEY_SEC_DESC *nt_create_init_sec(struct registry_hive *h) static REGF_HDR *nt_get_regf_hdr(struct registry_hive *h) { REGF *regf = h->backend_data; - SMB_REG_ASSERT(regf); + SMB_ASSERT(regf); if (!regf->base) { /* Try to mmap etc the file */ @@ -650,7 +650,7 @@ static REGF_HDR *nt_get_regf_hdr(struct registry_hive *h) * header */ - SMB_REG_ASSERT(regf->base != NULL); + SMB_ASSERT(regf->base != NULL); return (REGF_HDR *)regf->base; } @@ -828,7 +828,7 @@ static KEY_SEC_DESC *process_sk(struct registry_hive *regf, SK_HDR *sk_hdr, int /* Here, we have an item in the map that has been reserved, or tmp==NULL. */ - SMB_REG_ASSERT(tmp == NULL || (tmp && tmp->state != SEC_DESC_NON)); + SMB_ASSERT(tmp == NULL || (tmp && tmp->state != SEC_DESC_NON)); /* * Now, allocate a KEY_SEC_DESC, and parse the structure here, and add the @@ -870,10 +870,10 @@ static KEY_SEC_DESC *process_sk(struct registry_hive *regf, SK_HDR *sk_hdr, int sk_prev_off = IVAL(&sk_hdr->prev_off,0); tmp->prev = lookup_create_sec_key(regf, regf->sk_map, sk_prev_off); - SMB_REG_ASSERT(tmp->prev != NULL); + SMB_ASSERT(tmp->prev != NULL); sk_next_off = IVAL(&sk_hdr->next_off,0); tmp->next = lookup_create_sec_key(regf, regf->sk_map, sk_next_off); - SMB_REG_ASSERT(tmp->next != NULL); + SMB_ASSERT(tmp->next != NULL); return tmp; } @@ -934,9 +934,7 @@ static WERROR vk_to_val(TALLOC_CTX *mem_ctx, struct registry_key *parent, VK_HDR memcpy(dtmp, &dat_off, dat_len); } - - tmp->data_blk = dtmp; - tmp->data_len = dat_len; + tmp->data = data_blob_talloc(mem_ctx, dtmp, dat_len); } *value = tmp; @@ -968,14 +966,14 @@ static WERROR lf_verify(struct registry_hive *h, LF_HDR *lf_hdr, int size) return WERR_OK; } -static WERROR lf_num_entries(struct registry_hive *h, LF_HDR *lf_hdr, int size, int *count) +static WERROR lf_num_entries(struct registry_hive *h, LF_HDR *lf_hdr, int size, uint32_t *count) { WERROR error; error = lf_verify(h, lf_hdr, size); if(!W_ERROR_IS_OK(error)) return error; - SMB_REG_ASSERT(size < 0); + SMB_ASSERT(size < 0); *count = SVAL(&lf_hdr->key_count,0); DEBUG(2, ("Key Count: %u\n", *count)); @@ -1004,7 +1002,7 @@ static WERROR lf_get_entry(TALLOC_CTX *mem_ctx, struct registry_key *parent, LF_ error = lf_verify(parent->hive, lf_hdr, size); if(!W_ERROR_IS_OK(error)) return error; - SMB_REG_ASSERT(size < 0); + SMB_ASSERT(size < 0); count = SVAL(&lf_hdr->key_count,0); DEBUG(2, ("Key Count: %u\n", count)); @@ -1035,7 +1033,7 @@ static WERROR nk_to_key(TALLOC_CTX *mem_ctx, struct registry_hive *h, NK_HDR *nk return WERR_INVALID_PARAM; } - SMB_REG_ASSERT(size < 0); + SMB_ASSERT(size < 0); namlen = SVAL(&nk_hdr->nam_len,0); clsname_len = SVAL(&nk_hdr->clsnam_len,0); @@ -1059,7 +1057,7 @@ static WERROR nk_to_key(TALLOC_CTX *mem_ctx, struct registry_hive *h, NK_HDR *nk /* Fish out the key name and process the LF list */ - SMB_REG_ASSERT(namlen < sizeof(key_name)); + SMB_ASSERT(namlen < sizeof(key_name)); strncpy(key_name, nk_hdr->key_nam, namlen); key_name[namlen] = '\0'; @@ -1194,7 +1192,7 @@ static void *nt_alloc_regf_space(struct registry_hive *h, int size, uint_t *off) if (!regf || !size || !off) return NULL; - SMB_REG_ASSERT(regf->blk_head != NULL); + SMB_ASSERT(regf->blk_head != NULL); /* * round up size to include header and then to 8-byte boundary @@ -1653,7 +1651,7 @@ static WERROR nt_open_hive (struct registry_hive *h, struct registry_key **key) } -static WERROR nt_num_subkeys(struct registry_key *k, int *num) +static WERROR nt_num_subkeys(struct registry_key *k, uint32_t *num) { REGF *regf = k->hive->backend_data; LF_HDR *lf_hdr; @@ -1670,7 +1668,7 @@ static WERROR nt_num_subkeys(struct registry_key *k, int *num) return lf_num_entries(k->hive, lf_hdr, BLK_SIZE(lf_hdr), num); } -static WERROR nt_num_values(struct registry_key *k, int *count) +static WERROR nt_num_values(struct registry_key *k, uint32_t *count) { NK_HDR *nk_hdr = k->backend_data; *count = IVAL(&nk_hdr->val_cnt,0); diff --git a/source4/lib/registry/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc.c index 44de3bcd77..a00accc6be 100644 --- a/source4/lib/registry/reg_backend_rpc.c +++ b/source4/lib/registry/reg_backend_rpc.c @@ -204,8 +204,7 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx, struct registry_key *p *value = talloc(mem_ctx, struct registry_value); (*value)->name = talloc_strdup(mem_ctx, r.out.name->name); (*value)->data_type = type; - (*value)->data_len = *r.out.length; - (*value)->data_blk = talloc_memdup(mem_ctx, r.out.value, *r.out.length); + (*value)->data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length); return WERR_OK; } @@ -318,7 +317,8 @@ static WERROR rpc_del_key(struct registry_key *parent, const char *name) return r.out.result; } -static WERROR rpc_num_values(struct registry_key *key, int *count) { +static WERROR rpc_num_values(struct registry_key *key, uint32_t *count) +{ struct rpc_key_data *mykeydata = key->backend_data; WERROR error; @@ -331,7 +331,8 @@ static WERROR rpc_num_values(struct registry_key *key, int *count) { return WERR_OK; } -static WERROR rpc_num_subkeys(struct registry_key *key, int *count) { +static WERROR rpc_num_subkeys(struct registry_key *key, uint32_t *count) +{ struct rpc_key_data *mykeydata = key->backend_data; WERROR error; diff --git a/source4/lib/registry/reg_backend_w95.c b/source4/lib/registry/reg_backend_w95.c index 45b6105801..03460052da 100644 --- a/source4/lib/registry/reg_backend_w95.c +++ b/source4/lib/registry/reg_backend_w95.c @@ -303,7 +303,7 @@ static WERROR w95_get_subkey_by_index (TALLOC_CTX *mem_ctx, struct registry_key return WERR_NO_MORE_ITEMS; } -static WERROR w95_num_values(struct registry_key *k, int *count) +static WERROR w95_num_values(struct registry_key *k, uint32_t *count) { RGKN_KEY *rgkn_key = k->backend_data; RGDB_KEY *rgdb_key = LOCN_RGDB_KEY((CREG *)k->hive->backend_data, rgkn_key->id.rgdb, rgkn_key->id.id); @@ -335,8 +335,7 @@ static WERROR w95_get_value_by_id(TALLOC_CTX *mem_ctx, struct registry_key *k, i *value = talloc(mem_ctx, struct registry_value); (*value)->name = talloc_strndup(mem_ctx, (char *)curval+sizeof(RGDB_VALUE), curval->name_len); - (*value)->data_len = curval->data_len; - (*value)->data_blk = talloc_memdup(mem_ctx, (char *)curval+sizeof(RGDB_VALUE)+curval->name_len, curval->data_len); + (*value)->data = data_blob_talloc(mem_ctx, curval+sizeof(RGDB_VALUE)+curval->name_len, curval->data_len); (*value)->data_type = curval->type; return WERR_OK; diff --git a/source4/lib/registry/regf.idl b/source4/lib/registry/regf.idl index 8bef15c79e..03f63debc8 100644 --- a/source4/lib/registry/regf.idl +++ b/source4/lib/registry/regf.idl @@ -13,17 +13,18 @@ interface regf { - typedef struct { - uint32 major; - uint32 minor; - uint32 release; - uint32 build; - } regf_version; - - /* 1.3.0.1 for WinNT 4 + /* + * Registry version number + * 1.3.0.1 for WinNT 4 * 1.5.0.1 for WinXP */ + typedef struct { + [value(1)] uint32 major; + [value(3)] uint32 minor; + [value(0)] uint32 release; + [value(1)] uint32 build; + } regf_version; /* "regf" is obviously the abbreviation for "Registry file". "regf" is the @@ -70,7 +71,7 @@ interface regf typedef enum { REG_ROOT_KEY = 0x20, - REG_SUB_KEY = 0x2C, + REG_SUB_KEY = 0x2C, REG_SYM_LINK = 0x10 } reg_key_type; @@ -90,7 +91,7 @@ interface regf uint32 num_values; uint32 values_offset; uint32 sk_offset; - uint32 clsnam_offset; + uint32 clsname_offset; uint32 unk4[5]; uint16 name_length; uint16 clsname_length; @@ -112,6 +113,7 @@ interface regf uint32 base37; /* base37 of key name */ } lh_hash; + /* Subkey listing with hash of first 4 characters */ typedef struct { uint16 key_count; lh_hash hashes[key_count]; diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index a9d189c033..307ec3793e 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -72,7 +72,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(mem_ctx, newkey, i, &v1)); i++) { error2 = reg_key_get_value_by_name(mem_ctx, oldkey, v1->name, &v2); - if ((W_ERROR_IS_OK(error2) && (v2->data_len != v1->data_len || memcmp(v1->data_blk, v2->data_blk, v1->data_len))) + if ((W_ERROR_IS_OK(error2) && data_blob_equal(&v1->data, &v2->data)) || W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "\"%s\"=%s:%s\n", v1->name, str_regtype(v1->data_type), reg_val_data_string(mem_ctx, v1)); } diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index c2f01ce5b4..5f7d4376d4 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -704,9 +704,11 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd DEBUG(0, ("Error removing value '%s'\n", val->name)); } modified = True; - } - else { - if(!W_ERROR_IS_OK(reg_val_set(tmp, val->name, val->type, val->val, strlen(val->val)))) { + } else { + DATA_BLOB blob; + blob.data = (uint8_t *)val->val; + blob.length = strlen(val->val); + if(!W_ERROR_IS_OK(reg_val_set(tmp, val->name, val->type, blob))) { DEBUG(0, ("Error adding new value '%s'\n", val->name)); continue; } diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 108cc17336..496b9dc7e5 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -80,7 +80,7 @@ static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_context } else { struct registry_value *val; if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val)) { - WERROR error = reg_val_set(cur, argv[1], val->data_type, val->data_blk, val->data_len); + WERROR error = reg_val_set(cur, argv[1], val->data_type, val->data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); return NULL; diff --git a/source4/rpc_server/winreg/rpc_winreg.c b/source4/rpc_server/winreg/rpc_winreg.c index f03ca2fa86..ba11b07148 100644 --- a/source4/rpc_server/winreg/rpc_winreg.c +++ b/source4/rpc_server/winreg/rpc_winreg.c @@ -225,7 +225,7 @@ static WERROR winreg_EnumValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *m /* check the client has enough room for the value */ if (r->in.value != NULL && r->in.size != NULL && - value->data_len > *r->in.size) { + value->data.length > *r->in.size) { return WERR_MORE_DATA; } @@ -239,12 +239,12 @@ static WERROR winreg_EnumValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *m r->out.name->size = 2*strlen_m_term(value->name); if (r->in.value) { - r->out.value = value->data_blk; + r->out.value = value->data.data; } if (r->in.size) { r->out.size = talloc(mem_ctx, uint32_t); - *r->out.size = value->data_len; + *r->out.size = value->data.length; r->out.length = r->out.size; } @@ -398,13 +398,13 @@ static WERROR winreg_QueryValue(struct dcesrv_call_state *dce_call, TALLOC_CTX * /* Just asking for the size of the buffer */ r->out.type = &val->data_type; - r->out.length = &val->data_len; + r->out.length = &val->data.length; if (!r->in.data) { r->out.size = talloc(mem_ctx, uint32_t); - *r->out.size = val->data_len; + *r->out.size = val->data.length; } else { r->out.size = r->in.size; - r->out.data = val->data_blk; + r->out.data = val->data.data; } return WERR_OK; @@ -460,12 +460,15 @@ static WERROR winreg_SetValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *me struct dcesrv_handle *h; struct registry_key *key; WERROR result; + DATA_BLOB data; DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY); key = h->data; - result = reg_val_set(key, r->in.name.name, r->in.type, r->in.data, r->in.size); + data.data = r->in.data; + data.length = r->in.size; + result = reg_val_set(key, r->in.name.name, r->in.type, data); if (!W_ERROR_IS_OK(result)) { return result; |