VERSION: Bump version number up to 4.0.4.
[Samba.git] / source4 / torture / ndr / winreg.c
blob08c2a05c9667f2be653b3a0230f92e5982c79a29
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for winreg ndr operations
5 Copyright (C) Jelmer Vernooij 2007
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "torture/ndr/ndr.h"
23 #include "librpc/gen_ndr/ndr_winreg.h"
24 #include "librpc/gen_ndr/ndr_security.h"
25 #include "libcli/security/security.h"
26 #include "torture/ndr/proto.h"
28 static const uint8_t closekey_in_data[] = {
29 0x00, 0x00, 0x00, 0x00, 0x1d, 0xd8, 0xd7, 0xaa, 0x8d, 0x6c, 0x3f, 0x48,
30 0xa7, 0x1e, 0x02, 0x6a, 0x47, 0xf6, 0x7b, 0xae
33 static bool closekey_in_check(struct torture_context *tctx,
34 struct winreg_CloseKey *ck)
36 torture_assert(tctx, ck->in.handle != NULL, "handle invalid");
37 torture_assert_int_equal(tctx, ck->in.handle->handle_type, 0, "handle type");
38 return true;
41 const static uint8_t closekey_out_data[] = {
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
46 static bool closekey_out_check(struct torture_context *tctx,
47 struct winreg_CloseKey *ck)
49 torture_assert_int_equal(tctx, ck->out.handle->handle_type, 0, "handle type");
50 torture_assert_werr_ok(tctx, ck->out.result, "return code");
51 return true;
54 static const uint8_t OpenHKLM_In[] = {
55 0x01, 0x00, 0x00, 0x00, 0xe0, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
58 static bool openhklm_in_check(struct torture_context *tctx,
59 struct winreg_OpenHKLM *r)
61 torture_assert(tctx, r->in.system_name != NULL, "system name pointer");
62 torture_assert_int_equal(tctx, *r->in.system_name, 34016, "system name");
63 torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
64 return true;
67 static const uint8_t openhklm_out_data[] = {
68 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
69 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00
72 static bool openhklm_out_check(struct torture_context *tctx,
73 struct winreg_OpenHKLM *r)
75 torture_assert(tctx, r->out.handle != NULL, "handle pointer");
76 torture_assert_int_equal(tctx, r->out.handle->handle_type, 0, "handle_type");
77 torture_assert_werr_ok(tctx, r->out.result, "return code");
78 return true;
81 static const uint8_t createkey_in_data[] = {
82 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
83 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
84 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
85 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
86 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
89 0x00, 0x00, 0x00, 0x00
92 static bool createkey_in_check(struct torture_context *tctx,
93 struct winreg_CreateKey *r)
95 torture_assert_str_equal(tctx, r->in.name.name, "spottyfoot", "name");
96 torture_assert(tctx, r->in.keyclass.name == NULL, "keyclass");
97 torture_assert_int_equal(tctx, r->in.options, 0, "option");
98 torture_assert_int_equal(tctx, r->in.access_mask, 0x2000000, "access mask");
99 torture_assert(tctx, r->in.secdesc == NULL, "secdesc");
100 torture_assert(tctx, r->in.action_taken == NULL, "action_taken");
102 return true;
105 static const uint8_t createkey_out_data[] = {
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
108 0x57, 0x00, 0x00, 0x00
111 static bool createkey_out_check(struct torture_context *tctx,
112 struct winreg_CreateKey *r)
114 torture_assert(tctx, GUID_all_zero(&r->out.new_handle->uuid), "new_handle");
115 torture_assert(tctx, r->out.action_taken == NULL, "action_taken pointer");
116 torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM,
117 "return code");
119 return true;
122 static const uint8_t enumvalue_in_data[] = {
123 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
124 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x05, 0x00, 0x00, 0x00,
125 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
127 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
129 0xff, 0xff, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
132 static bool enumvalue_in_check(struct torture_context *tctx,
133 struct winreg_EnumValue *r)
135 torture_assert_int_equal(tctx, r->in.enum_index, 5, "enum index");
136 torture_assert(tctx, r->in.type != NULL, "type pointer");
137 torture_assert_int_equal(tctx, *r->in.type, 0, "type");
138 torture_assert_int_equal(tctx, *r->in.size, 65535, "size");
139 torture_assert_int_equal(tctx, *r->in.length, 0, "length");
140 torture_assert_int_equal(tctx, r->in.name->size, 512, "name size");
141 torture_assert_int_equal(tctx, r->in.name->length, 0, "name length");
143 return true;
146 static const uint8_t enumvalue_out_data[] = {
147 0x12, 0x00, 0x00, 0x02, 0x28, 0x91, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00,
148 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
149 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
150 0x00, 0x00, 0x00, 0x00, 0xd8, 0x8c, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
151 0xe0, 0x00, 0x0c, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152 0x4c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x63, 0x00,
153 0x75, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x73, 0x00,
154 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x20, 0x00, 0x53, 0x00,
155 0x65, 0x00, 0x74, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00,
156 0x73, 0x00, 0x5c, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6d, 0x00, 0x69, 0x00,
157 0x6e, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00,
158 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x00, 0x00, 0xf0, 0x8c, 0x07, 0x00,
159 0x4c, 0x00, 0x00, 0x00, 0xf8, 0x8c, 0x07, 0x00, 0x4c, 0x00, 0x00, 0x00,
160 0x00, 0x00, 0x00, 0x00
163 static bool enumvalue_out_check(struct torture_context *tctx,
164 struct winreg_EnumValue *r)
166 torture_assert_int_equal(tctx, r->out.name->size, 512, "name size");
167 torture_assert_int_equal(tctx, r->out.name->length, 18, "name length");
168 torture_assert_str_equal(tctx, r->out.name->name, "HOMEPATH", "name");
169 torture_assert_int_equal(tctx, *r->out.type, 1, "type");
170 torture_assert_int_equal(tctx, *r->out.size, 76, "size");
171 torture_assert_int_equal(tctx, *r->out.length, 76, "length");
172 torture_assert_werr_ok(tctx, r->out.result, "return code");
174 return true;
177 unsigned char enumvalue_in_data2[] = {
178 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0xda, 0x45, 0x9c, 0xed, 0xe2, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x02, 0xcc, 0xf9, 0x06, 0x00, 0x00, 0x01, 0x00, 0x00,
181 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xf9, 0x06, 0x00,
182 0x39, 0xa6, 0x07, 0x00, 0x00, 0xc4, 0x04, 0x01, 0x00, 0x80, 0x00, 0x00,
183 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xf9, 0x06, 0x00,
184 0x00, 0x80, 0x00, 0x00, 0x94, 0xf9, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00
187 static const uint8_t queryvalue_in_data[] = {
188 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
189 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x12, 0x00, 0x12, 0x00,
190 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00,
192 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00,
193 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
194 0x03, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
195 0x00, 0x00, 0x00, 0x00
198 static bool queryvalue_in_check(struct torture_context *tctx,
199 struct winreg_QueryValue *r)
201 torture_assert_str_equal(tctx, r->in.value_name->name, "HOMEPATH", "name");
202 torture_assert_int_equal(tctx, *r->in.type, 0, "type");
203 torture_assert_int_equal(tctx, *r->in.data_size, 4095, "size");
204 torture_assert_int_equal(tctx, *r->in.data_length, 0, "length");
205 torture_assert(tctx, r->in.data == NULL, "data pointer");
207 return true;
210 static const uint8_t queryvalue_out_data[] = {
211 0xd8, 0xf5, 0x0b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
212 0xe4, 0xf5, 0x0b, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xec, 0xf5, 0x0b, 0x00,
213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
216 static bool queryvalue_out_check(struct torture_context *tctx,
217 struct winreg_QueryValue *r)
219 torture_assert_werr_ok(tctx, r->out.result, "return code");
220 torture_assert_int_equal(tctx, *r->out.type, 1, "type");
221 torture_assert(tctx, r->out.data == NULL, "data pointer");
222 torture_assert_int_equal(tctx, *r->out.data_size, 76, "size");
223 torture_assert_int_equal(tctx, *r->out.data_length, 0, "length");
225 return true;
228 static const uint8_t querymultiplevalues_in_data[] = {
229 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
230 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x01, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
233 0x12, 0x00, 0x12, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
234 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
235 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
236 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
237 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00
243 static bool querymultiplevalues_in_check(struct torture_context *tctx,
244 struct winreg_QueryMultipleValues *r)
246 torture_assert_int_equal(tctx, r->in.num_values, 1, "num values");
247 torture_assert_str_equal(tctx, r->in.values_in[0].ve_valuename->name, "HOMEPATH", "name");
248 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuename->length, 18, "name len");
249 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuename->size, 18, "name size");
250 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuelen, 0, "length");
251 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valueptr, 0, "ve_valueptr");
252 torture_assert_int_equal(tctx, r->in.values_in[0].ve_type, 0, "type");
253 torture_assert_int_equal(tctx, *r->in.buffer_size, 32, "buffer size");
255 return true;
258 static const uint8_t querymultiplevalues_out_data[] = {
259 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
260 0xd8, 0x8c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
261 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x38, 0x87, 0x07, 0x00,
262 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
263 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00,
264 0x54, 0x00, 0x48, 0x00, 0xc8, 0x95, 0x08, 0x00, 0x4c, 0x00, 0x00, 0x00,
265 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
268 0x00, 0x00, 0x00, 0x00, 0x4c, 0x4d, 0x45, 0x4d, 0xc8, 0x95, 0x08, 0x00,
269 0x50, 0x87, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x07, 0x00,
270 0x00, 0x01, 0x0c, 0x00, 0x50, 0x95, 0x08, 0x00, 0x48, 0x96, 0x08, 0x00,
271 0xdc, 0x00, 0x00, 0x00, 0xc0, 0x83, 0x00, 0x01, 0x0d, 0xf0, 0xff, 0xff,
272 0x4c, 0x00, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00
275 static bool querymultiplevalues_out_check(struct torture_context *tctx,
276 struct winreg_QueryMultipleValues *r)
278 torture_assert_str_equal(tctx, r->out.values_out[0].ve_valuename->name, "HOMEPATH", "name");
279 torture_assert_int_equal(tctx, r->out.values_out[0].ve_type, 0, "type");
280 torture_assert_int_equal(tctx, r->out.values_out[0].ve_valuelen, 0, "length");
281 /* FIXME: r->out.buffer */
282 torture_assert_int_equal(tctx, *r->out.buffer_size, 76, "buffer size");
283 torture_assert_werr_equal(tctx, r->out.result, WERR_MORE_DATA, "return code");
285 return true;
288 const uint8_t querymultiplevalues2_in_data[] = {
289 0x00, 0x00, 0x00, 0x00, 0x98, 0xe4, 0xdf, 0x3c, 0x70, 0xde, 0x69, 0x4a,
290 0x90, 0xb4, 0x85, 0x36, 0x33, 0x79, 0x89, 0x32, 0x01, 0x00, 0x00, 0x00,
291 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293 0x0a, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
294 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x54, 0x00, 0x45, 0x00,
295 0x4d, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
299 static bool querymultiplevalues2_in_check(struct torture_context *tctx,
300 struct winreg_QueryMultipleValues2 *r)
302 torture_assert_int_equal(tctx, r->in.num_values, 1, "num values");
303 torture_assert_str_equal(tctx, r->in.values_in[0].ve_valuename->name, "TEMP", "name");
304 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuename->length, 10, "name len");
305 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuename->size, 10, "name size");
306 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuelen, 0, "length");
307 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valueptr, 0, "ve_valueptr");
308 torture_assert_int_equal(tctx, r->in.values_in[0].ve_type, 0, "type");
309 torture_assert_int_equal(tctx, *r->in.offered, 0, "buffer size");
311 return true;
314 const uint8_t querymultiplevalues2_out_data[] = {
315 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
316 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
317 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x02, 0x00,
318 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
319 0x54, 0x00, 0x45, 0x00, 0x4d, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
320 0x42, 0x00, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00
323 static bool querymultiplevalues2_out_check(struct torture_context *tctx,
324 struct winreg_QueryMultipleValues2 *r)
326 return true;
329 static const uint8_t flushkey_in_data[] = {
330 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
331 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3
334 static bool flushkey_in_check(struct torture_context *tctx,
335 struct winreg_FlushKey *r)
337 torture_assert_int_equal(tctx, r->in.handle->handle_type, 0, "handle type");
338 return true;
341 static const uint8_t flushkey_out_data[] = {
342 0x00, 0x00, 0x00, 0x00
345 static bool flushkey_out_check(struct torture_context *tctx,
346 struct winreg_FlushKey *r)
348 torture_assert_werr_ok(tctx, r->out.result, "return code");
349 return true;
353 static const uint8_t openkey_in_data[] = {
354 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
355 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
356 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
357 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
358 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
362 static bool openkey_in_check(struct torture_context *tctx, struct winreg_OpenKey *r)
364 torture_assert_int_equal(tctx, r->in.options, 0, "unknown");
365 torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
366 torture_assert_str_equal(tctx, r->in.keyname.name, "spottyfoot", "keyname");
367 /* FIXME: parent handle */
368 return true;
371 static const uint8_t openkey_out_data[] = {
372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00
376 static bool openkey_out_check(struct torture_context *tctx, struct winreg_OpenKey *r)
378 torture_assert(tctx, GUID_all_zero(&r->out.handle->uuid), "handle");
379 torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
380 return true;
383 static const uint8_t deletekey_in_data[] = {
384 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
385 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
386 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
388 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
389 0x00, 0x00
392 static bool deletekey_in_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
394 /* FIXME: Handle */
395 torture_assert_str_equal(tctx, r->in.key.name, "spottyfoot", "key name");
396 return true;
399 static const uint8_t deletekey_out_data[] = {
400 0x02, 0x00, 0x00, 0x00
403 static bool deletekey_out_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
405 torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
406 return true;
409 static const uint8_t getversion_in_data[] = {
410 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
411 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3
414 static bool getversion_in_check(struct torture_context *tctx, struct winreg_GetVersion *r)
416 /* FIXME: Handle */
417 return true;
420 static const uint8_t getversion_out_data[] = {
421 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
424 static bool getversion_out_check(struct torture_context *tctx, struct winreg_GetVersion *r)
426 torture_assert_int_equal(tctx, *r->out.version, 5, "version");
427 torture_assert_werr_ok(tctx, r->out.result, "return code");
428 return true;
431 static const uint8_t queryinfokey_in_data[] = {
432 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
433 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00,
434 0x00, 0x00, 0x00, 0x00
437 static bool queryinfokey_in_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
439 /* FIXME: Handle */
440 torture_assert(tctx, r->in.classname->name == NULL, "class in");
441 return true;
444 static const uint8_t queryinfokey_out_data[] = {
445 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
446 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
447 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
448 0x10, 0x48, 0x02, 0x3a, 0xcf, 0xfd, 0xc4, 0x01, 0x00, 0x00, 0x00, 0x00
451 static bool queryinfokey_out_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
453 torture_assert(tctx, r->out.classname != NULL, "class out");
454 torture_assert(tctx, r->out.classname->name != NULL, "class out name");
455 torture_assert_str_equal(tctx, r->out.classname->name, "", "class out name");
456 torture_assert_int_equal(tctx, *r->out.num_subkeys, 0, "num subkeys");
457 torture_assert_int_equal(tctx, *r->out.max_subkeylen, 0, "subkey length");
458 torture_assert_int_equal(tctx, *r->out.max_classlen, 140, "subkey size");
459 torture_assert_werr_ok(tctx, r->out.result, "return code");
460 return true;
463 static const uint8_t notifychangekeyvalue_in_data[] = {
464 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
465 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x01, 0x00, 0x00, 0x00,
466 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
467 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
468 0x00, 0x00, 0x00, 0x00
471 static bool notifychangekeyvalue_in_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
473 torture_assert_int_equal(tctx, r->in.watch_subtree, 1, "watch subtree");
474 torture_assert_int_equal(tctx, r->in.notify_filter, 0, "notify filter");
475 torture_assert_int_equal(tctx, r->in.unknown, 0, "unknown");
476 torture_assert(tctx, r->in.string1.name == NULL, "string1");
477 torture_assert(tctx, r->in.string2.name == NULL, "string2");
478 torture_assert_int_equal(tctx, r->in.unknown2, 0, "unknown2");
479 return true;
482 static const uint8_t notifychangekeyvalue_out_data[] = {
483 0x57, 0x00, 0x00, 0x00
486 static bool notifychangekeyvalue_out_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
488 torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM, "notify change key value");
489 return true;
492 static const uint8_t getkeysecurity_in_data[] = {
493 0x00, 0x00, 0x00, 0x00, 0xbd, 0xaa, 0xf6, 0x59, 0xc1, 0x82, 0x1f, 0x4d,
494 0x84, 0xa9, 0xdd, 0xae, 0x60, 0x77, 0x1e, 0x45, 0x00, 0x00, 0x00, 0x02,
495 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
498 static bool getkeysecurity_in_check(struct torture_context *tctx,
499 struct winreg_GetKeySecurity *r)
501 /* FIXME: Handle */
502 torture_assert_int_equal(tctx, r->in.sec_info, 2, "sec info");
503 torture_assert_int_equal(tctx, r->in.sd->size, 65536, "sd size");
504 torture_assert_int_equal(tctx, r->in.sd->len, 0, "sd len");
505 torture_assert(tctx, r->in.sd->data == NULL, "sd data");
506 return true;
509 static const uint8_t getkeysecurity_out_data[] = {
510 0x08, 0x91, 0x08, 0x00, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
511 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
512 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
513 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
516 static bool getkeysecurity_out_check(struct torture_context *tctx,
517 struct winreg_GetKeySecurity *r)
519 torture_assert_int_equal(tctx, r->in.sd->size, 20, "sd size");
520 torture_assert_int_equal(tctx, r->in.sd->len, 20, "sd len");
521 torture_assert_werr_ok(tctx, r->out.result, "return code");
522 return true;
525 static const uint8_t enumkey_in_data[] = {
526 0x00, 0x00, 0x00, 0x00, 0x85, 0xb8, 0x41, 0xb0, 0x17, 0xe4, 0x28, 0x45,
527 0x8a, 0x69, 0xbf, 0x40, 0x79, 0x82, 0x8b, 0xcb, 0x00, 0x00, 0x00, 0x00,
528 0x00, 0x00, 0x14, 0x04, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x02, 0x00, 0x00,
529 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
530 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
531 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f
534 static bool enumkey_in_check(struct torture_context *tctx, struct winreg_EnumKey *r)
536 torture_assert_int_equal(tctx, r->in.enum_index, 0, "enum index");
537 torture_assert_int_equal(tctx, r->in.name->size, 1044, "name size");
538 torture_assert_int_equal(tctx, r->in.name->length, 0, "name len");
539 torture_assert(tctx, r->in.keyclass != NULL, "keyclass pointer");
540 torture_assert(tctx, r->in.keyclass->name == NULL, "keyclass");
541 torture_assert(tctx, r->in.last_changed_time != NULL, "last_changed_time != NULL");
542 return true;
545 static const uint8_t enumkey_out_data[] = {
546 0x08, 0x00, 0x14, 0x04, 0x18, 0xe8, 0x07, 0x00, 0x0a, 0x02, 0x00, 0x00,
547 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x53, 0x00, 0x41, 0x00,
548 0x4d, 0x00, 0x00, 0x00, 0xd0, 0x62, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
549 0x00, 0x00, 0x00, 0x00, 0xdc, 0x62, 0x07, 0x00, 0x50, 0x67, 0xd0, 0x8b,
550 0x16, 0x06, 0xc2, 0x01, 0x00, 0x00, 0x00, 0x00
553 static bool enumkey_out_check(struct torture_context *tctx, struct winreg_EnumKey *r)
555 torture_assert_int_equal(tctx, r->out.name->size, 1044, "name size");
556 torture_assert_int_equal(tctx, r->out.name->length, 8, "name len");
557 torture_assert(tctx, r->out.keyclass != NULL, "keyclass pointer");
558 torture_assert(tctx, r->out.keyclass->name == NULL, "keyclass");
559 torture_assert(tctx, r->out.last_changed_time != NULL, "last_changed_time pointer");
560 /* FIXME: *last_changed_time */
561 return true;
564 struct torture_suite *ndr_winreg_suite(TALLOC_CTX *ctx)
566 struct torture_suite *suite = torture_suite_create(ctx, "winreg");
568 torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_in_data, NDR_IN, closekey_in_check );
569 torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_out_data, NDR_OUT, closekey_out_check );
571 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, OpenHKLM_In, NDR_IN, openhklm_in_check );
572 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, openhklm_out_data, NDR_OUT, openhklm_out_check );
574 torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_in_data, NDR_IN, createkey_in_check );
575 torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_out_data, NDR_OUT, createkey_out_check );
577 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data, NDR_IN, enumvalue_in_check );
578 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_out_data, NDR_OUT, enumvalue_out_check );
579 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data2, NDR_IN, NULL);
581 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_in_data, NDR_IN, queryvalue_in_check );
582 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_out_data, NDR_OUT, queryvalue_out_check );
584 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_in_data, NDR_IN, querymultiplevalues_in_check );
585 torture_suite_add_ndr_pull_io_test(suite, winreg_QueryMultipleValues, querymultiplevalues_in_data, querymultiplevalues_out_data, querymultiplevalues_out_check);
587 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues2, querymultiplevalues2_in_data, NDR_IN, querymultiplevalues2_in_check );
588 torture_suite_add_ndr_pull_io_test(suite, winreg_QueryMultipleValues2, querymultiplevalues2_in_data, querymultiplevalues2_out_data, querymultiplevalues2_out_check);
590 torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_in_data, NDR_IN, flushkey_in_check );
591 torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_out_data, NDR_OUT, flushkey_out_check );
593 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_in_data, NDR_IN, openkey_in_check );
594 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_out_data, NDR_OUT, openkey_out_check );
596 torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_in_data, NDR_IN, deletekey_in_check );
597 torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_out_data, NDR_OUT, deletekey_out_check );
599 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_in_data, NDR_IN, getversion_in_check );
600 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_out_data, NDR_OUT, getversion_out_check );
602 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_in_data, NDR_IN, queryinfokey_in_check );
603 /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_out_data, NDR_OUT, queryinfokey_out_check );*/
605 torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_in_data, NDR_IN, notifychangekeyvalue_in_check );
606 torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_out_data, NDR_OUT, notifychangekeyvalue_out_check );
608 /*torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_in_data, NDR_IN, getkeysecurity_in_check );
609 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_out_data, NDR_OUT, getkeysecurity_out_check );*/
611 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumKey, enumkey_in_data, NDR_IN, enumkey_in_check );
612 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumKey, enumkey_out_data, NDR_OUT, enumkey_out_check );
614 return suite;