WHATSNEW: Add some information on migrating printers.
[Samba.git] / source4 / torture / ndr / winreg.c
blobb6da7bccd2420198069e723d2b9f402908ed2529
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"
27 static const uint8_t closekey_in_data[] = {
28 0x00, 0x00, 0x00, 0x00, 0x1d, 0xd8, 0xd7, 0xaa, 0x8d, 0x6c, 0x3f, 0x48,
29 0xa7, 0x1e, 0x02, 0x6a, 0x47, 0xf6, 0x7b, 0xae
32 static bool closekey_in_check(struct torture_context *tctx,
33 struct winreg_CloseKey *ck)
35 torture_assert(tctx, ck->in.handle != NULL, "handle invalid");
36 torture_assert_int_equal(tctx, ck->in.handle->handle_type, 0, "handle type");
37 return true;
40 const static uint8_t closekey_out_data[] = {
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
45 static bool closekey_out_check(struct torture_context *tctx,
46 struct winreg_CloseKey *ck)
48 torture_assert_int_equal(tctx, ck->out.handle->handle_type, 0, "handle type");
49 torture_assert_werr_ok(tctx, ck->out.result, "return code");
50 return true;
53 static const uint8_t OpenHKLM_In[] = {
54 0x01, 0x00, 0x00, 0x00, 0xe0, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
57 static bool openhklm_in_check(struct torture_context *tctx,
58 struct winreg_OpenHKLM *r)
60 torture_assert(tctx, r->in.system_name != NULL, "system name pointer");
61 torture_assert_int_equal(tctx, *r->in.system_name, 34016, "system name");
62 torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
63 return true;
66 static const uint8_t openhklm_out_data[] = {
67 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
68 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00
71 static bool openhklm_out_check(struct torture_context *tctx,
72 struct winreg_OpenHKLM *r)
74 torture_assert(tctx, r->out.handle != NULL, "handle pointer");
75 torture_assert_int_equal(tctx, r->out.handle->handle_type, 0, "handle_type");
76 torture_assert_werr_ok(tctx, r->out.result, "return code");
77 return true;
80 static const uint8_t createkey_in_data[] = {
81 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
82 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
83 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
84 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
85 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
88 0x00, 0x00, 0x00, 0x00
91 static bool createkey_in_check(struct torture_context *tctx,
92 struct winreg_CreateKey *r)
94 torture_assert_str_equal(tctx, r->in.name.name, "spottyfoot", "name");
95 torture_assert(tctx, r->in.keyclass.name == NULL, "keyclass");
96 torture_assert_int_equal(tctx, r->in.options, 0, "option");
97 torture_assert_int_equal(tctx, r->in.access_mask, 0x2000000, "access mask");
98 torture_assert(tctx, r->in.secdesc == NULL, "secdesc");
99 torture_assert(tctx, r->in.action_taken == NULL, "action_taken");
101 return true;
104 static const uint8_t createkey_out_data[] = {
105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x57, 0x00, 0x00, 0x00
110 static bool createkey_out_check(struct torture_context *tctx,
111 struct winreg_CreateKey *r)
113 torture_assert(tctx, GUID_all_zero(&r->out.new_handle->uuid), "new_handle");
114 torture_assert(tctx, r->out.action_taken == NULL, "action_taken pointer");
115 torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM,
116 "return code");
118 return true;
121 static const uint8_t enumvalue_in_data[] = {
122 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
123 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x05, 0x00, 0x00, 0x00,
124 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
126 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
128 0xff, 0xff, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
131 static bool enumvalue_in_check(struct torture_context *tctx,
132 struct winreg_EnumValue *r)
134 torture_assert_int_equal(tctx, r->in.enum_index, 5, "enum index");
135 torture_assert(tctx, r->in.type != NULL, "type pointer");
136 torture_assert_int_equal(tctx, *r->in.type, 0, "type");
137 torture_assert_int_equal(tctx, *r->in.size, 65535, "size");
138 torture_assert_int_equal(tctx, *r->in.length, 0, "length");
139 torture_assert_int_equal(tctx, r->in.name->size, 512, "name size");
140 torture_assert_int_equal(tctx, r->in.name->length, 0, "name length");
142 return true;
145 static const uint8_t enumvalue_out_data[] = {
146 0x12, 0x00, 0x00, 0x02, 0x28, 0x91, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00,
147 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
148 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
149 0x00, 0x00, 0x00, 0x00, 0xd8, 0x8c, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
150 0xe0, 0x00, 0x0c, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151 0x4c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x63, 0x00,
152 0x75, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x73, 0x00,
153 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x20, 0x00, 0x53, 0x00,
154 0x65, 0x00, 0x74, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00,
155 0x73, 0x00, 0x5c, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6d, 0x00, 0x69, 0x00,
156 0x6e, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00,
157 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x00, 0x00, 0xf0, 0x8c, 0x07, 0x00,
158 0x4c, 0x00, 0x00, 0x00, 0xf8, 0x8c, 0x07, 0x00, 0x4c, 0x00, 0x00, 0x00,
159 0x00, 0x00, 0x00, 0x00
162 static bool enumvalue_out_check(struct torture_context *tctx,
163 struct winreg_EnumValue *r)
165 torture_assert_int_equal(tctx, r->out.name->size, 512, "name size");
166 torture_assert_int_equal(tctx, r->out.name->length, 18, "name length");
167 torture_assert_str_equal(tctx, r->out.name->name, "HOMEPATH", "name");
168 torture_assert_int_equal(tctx, *r->out.type, 1, "type");
169 torture_assert_int_equal(tctx, *r->out.size, 76, "size");
170 torture_assert_int_equal(tctx, *r->out.length, 76, "length");
171 torture_assert_werr_ok(tctx, r->out.result, "return code");
173 return true;
176 unsigned char enumvalue_in_data2[] = {
177 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0xda, 0x45, 0x9c, 0xed, 0xe2, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x02, 0xcc, 0xf9, 0x06, 0x00, 0x00, 0x01, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xf9, 0x06, 0x00,
181 0x39, 0xa6, 0x07, 0x00, 0x00, 0xc4, 0x04, 0x01, 0x00, 0x80, 0x00, 0x00,
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xf9, 0x06, 0x00,
183 0x00, 0x80, 0x00, 0x00, 0x94, 0xf9, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00
186 static const uint8_t queryvalue_in_data[] = {
187 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
188 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x12, 0x00, 0x12, 0x00,
189 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00,
191 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00,
192 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
193 0x03, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
194 0x00, 0x00, 0x00, 0x00
197 static bool queryvalue_in_check(struct torture_context *tctx,
198 struct winreg_QueryValue *r)
200 torture_assert_str_equal(tctx, r->in.value_name->name, "HOMEPATH", "name");
201 torture_assert_int_equal(tctx, *r->in.type, 0, "type");
202 torture_assert_int_equal(tctx, *r->in.data_size, 4095, "size");
203 torture_assert_int_equal(tctx, *r->in.data_length, 0, "length");
204 torture_assert(tctx, r->in.data == NULL, "data pointer");
206 return true;
209 static const uint8_t queryvalue_out_data[] = {
210 0xd8, 0xf5, 0x0b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0xe4, 0xf5, 0x0b, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xec, 0xf5, 0x0b, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
215 static bool queryvalue_out_check(struct torture_context *tctx,
216 struct winreg_QueryValue *r)
218 torture_assert_werr_ok(tctx, r->out.result, "return code");
219 torture_assert_int_equal(tctx, *r->out.type, 1, "type");
220 torture_assert(tctx, r->out.data == NULL, "data pointer");
221 torture_assert_int_equal(tctx, *r->out.data_size, 76, "size");
222 torture_assert_int_equal(tctx, *r->out.data_length, 0, "length");
224 return true;
227 static const uint8_t querymultiplevalues_in_data[] = {
228 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
229 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x01, 0x00, 0x00, 0x00,
230 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232 0x12, 0x00, 0x12, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
233 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
234 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
235 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
236 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0x20, 0x00, 0x00, 0x00
242 static bool querymultiplevalues_in_check(struct torture_context *tctx,
243 struct winreg_QueryMultipleValues *r)
245 torture_assert_int_equal(tctx, r->in.num_values, 1, "num values");
246 torture_assert_str_equal(tctx, r->in.values_in[0].ve_valuename->name, "HOMEPATH", "name");
247 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuename->length, 18, "name len");
248 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuename->size, 18, "name size");
249 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuelen, 0, "length");
250 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valueptr, 0, "ve_valueptr");
251 torture_assert_int_equal(tctx, r->in.values_in[0].ve_type, 0, "type");
252 torture_assert_int_equal(tctx, *r->in.buffer_size, 32, "buffer size");
254 return true;
257 static const uint8_t querymultiplevalues_out_data[] = {
258 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
259 0xd8, 0x8c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
260 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x38, 0x87, 0x07, 0x00,
261 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
262 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00,
263 0x54, 0x00, 0x48, 0x00, 0xc8, 0x95, 0x08, 0x00, 0x4c, 0x00, 0x00, 0x00,
264 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
265 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0x4c, 0x4d, 0x45, 0x4d, 0xc8, 0x95, 0x08, 0x00,
268 0x50, 0x87, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x07, 0x00,
269 0x00, 0x01, 0x0c, 0x00, 0x50, 0x95, 0x08, 0x00, 0x48, 0x96, 0x08, 0x00,
270 0xdc, 0x00, 0x00, 0x00, 0xc0, 0x83, 0x00, 0x01, 0x0d, 0xf0, 0xff, 0xff,
271 0x4c, 0x00, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00
274 static bool querymultiplevalues_out_check(struct torture_context *tctx,
275 struct winreg_QueryMultipleValues *r)
277 torture_assert_str_equal(tctx, r->out.values_out[0].ve_valuename->name, "HOMEPATH", "name");
278 torture_assert_int_equal(tctx, r->out.values_out[0].ve_type, 0, "type");
279 torture_assert_int_equal(tctx, r->out.values_out[0].ve_valuelen, 0, "length");
280 /* FIXME: r->out.buffer */
281 torture_assert_int_equal(tctx, *r->out.buffer_size, 76, "buffer size");
282 torture_assert_werr_equal(tctx, r->out.result, WERR_MORE_DATA, "return code");
284 return true;
287 const uint8_t querymultiplevalues2_in_data[] = {
288 0x00, 0x00, 0x00, 0x00, 0x98, 0xe4, 0xdf, 0x3c, 0x70, 0xde, 0x69, 0x4a,
289 0x90, 0xb4, 0x85, 0x36, 0x33, 0x79, 0x89, 0x32, 0x01, 0x00, 0x00, 0x00,
290 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
291 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
292 0x0a, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
293 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x54, 0x00, 0x45, 0x00,
294 0x4d, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
298 static bool querymultiplevalues2_in_check(struct torture_context *tctx,
299 struct winreg_QueryMultipleValues2 *r)
301 torture_assert_int_equal(tctx, r->in.num_values, 1, "num values");
302 torture_assert_str_equal(tctx, r->in.values_in[0].ve_valuename->name, "TEMP", "name");
303 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuename->length, 10, "name len");
304 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuename->size, 10, "name size");
305 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valuelen, 0, "length");
306 torture_assert_int_equal(tctx, r->in.values_in[0].ve_valueptr, 0, "ve_valueptr");
307 torture_assert_int_equal(tctx, r->in.values_in[0].ve_type, 0, "type");
308 torture_assert_int_equal(tctx, *r->in.offered, 0, "buffer size");
310 return true;
313 const uint8_t querymultiplevalues2_out_data[] = {
314 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
315 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
316 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x02, 0x00,
317 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
318 0x54, 0x00, 0x45, 0x00, 0x4d, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
319 0x42, 0x00, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00
322 static bool querymultiplevalues2_out_check(struct torture_context *tctx,
323 struct winreg_QueryMultipleValues2 *r)
325 return true;
328 static const uint8_t flushkey_in_data[] = {
329 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
330 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3
333 static bool flushkey_in_check(struct torture_context *tctx,
334 struct winreg_FlushKey *r)
336 torture_assert_int_equal(tctx, r->in.handle->handle_type, 0, "handle type");
337 return true;
340 static const uint8_t flushkey_out_data[] = {
341 0x00, 0x00, 0x00, 0x00
344 static bool flushkey_out_check(struct torture_context *tctx,
345 struct winreg_FlushKey *r)
347 torture_assert_werr_ok(tctx, r->out.result, "return code");
348 return true;
352 static const uint8_t openkey_in_data[] = {
353 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
354 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
355 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
356 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
357 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
358 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
361 static bool openkey_in_check(struct torture_context *tctx, struct winreg_OpenKey *r)
363 torture_assert_int_equal(tctx, r->in.options, 0, "unknown");
364 torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
365 torture_assert_str_equal(tctx, r->in.keyname.name, "spottyfoot", "keyname");
366 /* FIXME: parent handle */
367 return true;
370 static const uint8_t openkey_out_data[] = {
371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00
375 static bool openkey_out_check(struct torture_context *tctx, struct winreg_OpenKey *r)
377 torture_assert(tctx, GUID_all_zero(&r->out.handle->uuid), "handle");
378 torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
379 return true;
382 static const uint8_t deletekey_in_data[] = {
383 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
384 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
385 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
386 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
387 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
388 0x00, 0x00
391 static bool deletekey_in_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
393 /* FIXME: Handle */
394 torture_assert_str_equal(tctx, r->in.key.name, "spottyfoot", "key name");
395 return true;
398 static const uint8_t deletekey_out_data[] = {
399 0x02, 0x00, 0x00, 0x00
402 static bool deletekey_out_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
404 torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
405 return true;
408 static const uint8_t getversion_in_data[] = {
409 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
410 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3
413 static bool getversion_in_check(struct torture_context *tctx, struct winreg_GetVersion *r)
415 /* FIXME: Handle */
416 return true;
419 static const uint8_t getversion_out_data[] = {
420 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
423 static bool getversion_out_check(struct torture_context *tctx, struct winreg_GetVersion *r)
425 torture_assert_int_equal(tctx, *r->out.version, 5, "version");
426 torture_assert_werr_ok(tctx, r->out.result, "return code");
427 return true;
430 static const uint8_t queryinfokey_in_data[] = {
431 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
432 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00,
433 0x00, 0x00, 0x00, 0x00
436 static bool queryinfokey_in_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
438 /* FIXME: Handle */
439 torture_assert(tctx, r->in.classname->name == NULL, "class in");
440 return true;
443 static const uint8_t queryinfokey_out_data[] = {
444 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
445 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
446 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
447 0x10, 0x48, 0x02, 0x3a, 0xcf, 0xfd, 0xc4, 0x01, 0x00, 0x00, 0x00, 0x00
450 static bool queryinfokey_out_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
452 torture_assert(tctx, r->out.classname != NULL, "class out");
453 torture_assert(tctx, r->out.classname->name != NULL, "class out name");
454 torture_assert_str_equal(tctx, r->out.classname->name, "", "class out name");
455 torture_assert_int_equal(tctx, *r->out.num_subkeys, 0, "num subkeys");
456 torture_assert_int_equal(tctx, *r->out.max_subkeylen, 0, "subkey length");
457 torture_assert_int_equal(tctx, *r->out.max_classlen, 140, "subkey size");
458 torture_assert_werr_ok(tctx, r->out.result, "return code");
459 return true;
462 static const uint8_t notifychangekeyvalue_in_data[] = {
463 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
464 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x01, 0x00, 0x00, 0x00,
465 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
466 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
467 0x00, 0x00, 0x00, 0x00
470 static bool notifychangekeyvalue_in_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
472 torture_assert_int_equal(tctx, r->in.watch_subtree, 1, "watch subtree");
473 torture_assert_int_equal(tctx, r->in.notify_filter, 0, "notify filter");
474 torture_assert_int_equal(tctx, r->in.unknown, 0, "unknown");
475 torture_assert(tctx, r->in.string1.name == NULL, "string1");
476 torture_assert(tctx, r->in.string2.name == NULL, "string2");
477 torture_assert_int_equal(tctx, r->in.unknown2, 0, "unknown2");
478 return true;
481 static const uint8_t notifychangekeyvalue_out_data[] = {
482 0x57, 0x00, 0x00, 0x00
485 static bool notifychangekeyvalue_out_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
487 torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM, "notify change key value");
488 return true;
491 static const uint8_t getkeysecurity_in_data[] = {
492 0x00, 0x00, 0x00, 0x00, 0xbd, 0xaa, 0xf6, 0x59, 0xc1, 0x82, 0x1f, 0x4d,
493 0x84, 0xa9, 0xdd, 0xae, 0x60, 0x77, 0x1e, 0x45, 0x00, 0x00, 0x00, 0x02,
494 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
497 static bool getkeysecurity_in_check(struct torture_context *tctx,
498 struct winreg_GetKeySecurity *r)
500 /* FIXME: Handle */
501 torture_assert_int_equal(tctx, r->in.sec_info, 2, "sec info");
502 torture_assert_int_equal(tctx, r->in.sd->size, 65536, "sd size");
503 torture_assert_int_equal(tctx, r->in.sd->len, 0, "sd len");
504 torture_assert(tctx, r->in.sd->data == NULL, "sd data");
505 return true;
508 static const uint8_t getkeysecurity_out_data[] = {
509 0x08, 0x91, 0x08, 0x00, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
510 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
511 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
512 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
515 static bool getkeysecurity_out_check(struct torture_context *tctx,
516 struct winreg_GetKeySecurity *r)
518 torture_assert_int_equal(tctx, r->in.sd->size, 20, "sd size");
519 torture_assert_int_equal(tctx, r->in.sd->len, 20, "sd len");
520 torture_assert_werr_ok(tctx, r->out.result, "return code");
521 return true;
524 static const uint8_t enumkey_in_data[] = {
525 0x00, 0x00, 0x00, 0x00, 0x85, 0xb8, 0x41, 0xb0, 0x17, 0xe4, 0x28, 0x45,
526 0x8a, 0x69, 0xbf, 0x40, 0x79, 0x82, 0x8b, 0xcb, 0x00, 0x00, 0x00, 0x00,
527 0x00, 0x00, 0x14, 0x04, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x02, 0x00, 0x00,
528 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
529 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
530 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f
533 static bool enumkey_in_check(struct torture_context *tctx, struct winreg_EnumKey *r)
535 torture_assert_int_equal(tctx, r->in.enum_index, 0, "enum index");
536 torture_assert_int_equal(tctx, r->in.name->size, 1044, "name size");
537 torture_assert_int_equal(tctx, r->in.name->length, 0, "name len");
538 torture_assert(tctx, r->in.keyclass != NULL, "keyclass pointer");
539 torture_assert(tctx, r->in.keyclass->name == NULL, "keyclass");
540 torture_assert(tctx, r->in.last_changed_time != NULL, "last_changed_time != NULL");
541 return true;
544 static const uint8_t enumkey_out_data[] = {
545 0x08, 0x00, 0x14, 0x04, 0x18, 0xe8, 0x07, 0x00, 0x0a, 0x02, 0x00, 0x00,
546 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x53, 0x00, 0x41, 0x00,
547 0x4d, 0x00, 0x00, 0x00, 0xd0, 0x62, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
548 0x00, 0x00, 0x00, 0x00, 0xdc, 0x62, 0x07, 0x00, 0x50, 0x67, 0xd0, 0x8b,
549 0x16, 0x06, 0xc2, 0x01, 0x00, 0x00, 0x00, 0x00
552 static bool enumkey_out_check(struct torture_context *tctx, struct winreg_EnumKey *r)
554 torture_assert_int_equal(tctx, r->out.name->size, 1044, "name size");
555 torture_assert_int_equal(tctx, r->out.name->length, 8, "name len");
556 torture_assert(tctx, r->out.keyclass != NULL, "keyclass pointer");
557 torture_assert(tctx, r->out.keyclass->name == NULL, "keyclass");
558 torture_assert(tctx, r->out.last_changed_time != NULL, "last_changed_time pointer");
559 /* FIXME: *last_changed_time */
560 return true;
563 struct torture_suite *ndr_winreg_suite(TALLOC_CTX *ctx)
565 struct torture_suite *suite = torture_suite_create(ctx, "winreg");
567 torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_in_data, NDR_IN, closekey_in_check );
568 torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_out_data, NDR_OUT, closekey_out_check );
570 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, OpenHKLM_In, NDR_IN, openhklm_in_check );
571 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, openhklm_out_data, NDR_OUT, openhklm_out_check );
573 torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_in_data, NDR_IN, createkey_in_check );
574 torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_out_data, NDR_OUT, createkey_out_check );
576 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data, NDR_IN, enumvalue_in_check );
577 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_out_data, NDR_OUT, enumvalue_out_check );
578 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data2, NDR_IN, NULL);
580 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_in_data, NDR_IN, queryvalue_in_check );
581 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_out_data, NDR_OUT, queryvalue_out_check );
583 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_in_data, NDR_IN, querymultiplevalues_in_check );
584 torture_suite_add_ndr_pull_io_test(suite, winreg_QueryMultipleValues, querymultiplevalues_in_data, querymultiplevalues_out_data, querymultiplevalues_out_check);
586 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues2, querymultiplevalues2_in_data, NDR_IN, querymultiplevalues2_in_check );
587 torture_suite_add_ndr_pull_io_test(suite, winreg_QueryMultipleValues2, querymultiplevalues2_in_data, querymultiplevalues2_out_data, querymultiplevalues2_out_check);
589 torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_in_data, NDR_IN, flushkey_in_check );
590 torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_out_data, NDR_OUT, flushkey_out_check );
592 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_in_data, NDR_IN, openkey_in_check );
593 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_out_data, NDR_OUT, openkey_out_check );
595 torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_in_data, NDR_IN, deletekey_in_check );
596 torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_out_data, NDR_OUT, deletekey_out_check );
598 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_in_data, NDR_IN, getversion_in_check );
599 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_out_data, NDR_OUT, getversion_out_check );
601 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_in_data, NDR_IN, queryinfokey_in_check );
602 /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_out_data, NDR_OUT, queryinfokey_out_check );*/
604 torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_in_data, NDR_IN, notifychangekeyvalue_in_check );
605 torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_out_data, NDR_OUT, notifychangekeyvalue_out_check );
607 /*torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_in_data, NDR_IN, getkeysecurity_in_check );
608 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_out_data, NDR_OUT, getkeysecurity_out_check );*/
610 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumKey, enumkey_in_data, NDR_IN, enumkey_in_check );
611 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumKey, enumkey_out_data, NDR_OUT, enumkey_out_check );
613 return suite;