static bool test_list_values(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; char data[4]; uint32_t type; DATA_BLOB value; const char *name; int data_val = 42; SIVAL(data, 0, data_val); error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, data_blob_talloc(mem_ctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, &type, &value); torture_assert_werr_ok(tctx, error, "getting value"); torture_assert_str_equal(tctx, name, "Answer", "value name"); torture_assert_int_equal(tctx, value.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); torture_assert_int_equal(tctx, data_val, IVAL(value.data, 0), "value data"); error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &value); torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, "getting missing value"); return true; }
static bool test_list_values(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; uint32_t type; uint8_t d[] = { 0x42, 0x00, 0x00, 0x00 }; DATA_BLOB db = { d, 4 }, data; const char *name; error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, db); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, &type, &data); torture_assert_werr_ok(tctx, error, "getting value"); torture_assert_str_equal(tctx, name, "Answer", "value name"); torture_assert_int_equal(tctx, data.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); torture_assert_mem_equal(tctx, data.data, db.data, 4, "value data"); error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &data); torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, "getting missing value"); return true; }